query($sql); $tid = $db->insert_id(); // update the log so it shows who created the ticket now. if ($pubpriv == "Public") $msg = "\$lang_createdbyweb ".$_POST[username].""; else $msg = "\$lang_taskcreatedby ".$_SESSION[user].""; $log = updateLog($tid, $msg); $sql = "update $tickets_table set update_log='$log' where id=$tid"; $db->query($sql); // insert the file into the database if it exists. // Modified by Adam Hall to allow attachment file upload support if ($enable_tattachments == 'On' && $_FILES['SelectedFile']['name'] != '' && $_FILES['SelectedFile']['name'] != 'none') { //Upload file and return new file name $mtime = explode(" ", microtime()); $mtime = $mtime[1].substr($mtime[0],5,3); $file_name = uploadAttachment($max_attachment_size, 'SelectedFile',$mtime); $file_type = $_FILES['SelectedFile']['type']; $file_size = $_FILES['SelectedFile']['size']; $sql = "INSERT into $attachments_table VALUES (NULL, NULL, $tid, '$file_name', '$file_upload_directory', '$file_type', '$file_size', NULL, 0, '$_SESSION[user]', $time)"; $db->query($sql); //insert all info about the attachment into the database. $file_id = $db->insert_id(); // insert the file into the database if it exists. // if ($enable_uattachments == 'On' && $the_file != '' && $the_file != 'none') { // $attachment = addslashes(fread(fopen($the_file, "rb"), filesize($the_file))); // if ($the_file_type == "application/x-gzip-compressed") { // $attachment = base64_decode($attachment); // } // $query = "INSERT into $attachments_table VALUES(NULL, NULL, $tid, '$the_file_name', '$the_file_type', '$the_file_size', '$attachment', 0, '$_SESSION[user]', $time)"; // $db->query($query); //insert all info about the attachment into the database. // $file_id = $db->insert_id(); // $attachsize = $file_size; if ($attachsize >= 1073741824) { $attachsize = round($attachsize / 1073741824 * 100) / 100 . "gb"; } elseif ($attachsize >= 1048576) { $attachsize = round($attachsize / 1048576 * 100) / 100 . "mb"; } elseif ($attachsize >= 1024) { $attachsize = round($attachsize / 1024 * 100) / 100 . "kb"; } else { $attachsize = $attachsize . "b"; } // update the update log $msg = "\$lang_fileattached : ".$_FILES['SelectedFile']['name']." ( $attachsize )"; $log = updateLog($tid, $msg); $sql = "update $tickets_table set update_log='$log' where id=$tid"; $db->query($sql); } //reset the userform session var... unset($_SESSION[userform]); // if the pager gateway is enabled...send a page to the supporters of that group if the ticket is set above the default. if ($enable_pager == 'On' && (getRank($_POST[priority], $tpriorities_table) <= $pager_rank_low)) { sendGroupPage($_POST[sg], $_POST[username], $_POST[short], $_POST[priority], $tid); } // now print out the html that lets the user know that their ticket was submitted successfully. header("Location: index.php?t=tsuc&id=$tid"); } } else { echo "
"; ?> "; echo ""; echo "   "; echo ""; //echo ""; echo "
"; echo ""; } function createTicketHeader($msg) { startTable($msg, "middle"); endTable(); } function createSupporterInfo() { global $lang_supporterinfo, $lang_supportergroup, $lang_priority, $lang_ticket; if ($_GET[sg] == '') { $_GET[sg] = getDefaultSupporterGroupID(); } startTable("$lang_supporterinfo", "left", 100, 4); echo ' '.$lang_supportergroup.': '; ?> '; createPriorityMenu(); echo ' '; endTable(); } function createSupporterMenu($group_id) { global $users_table, $db, $table_prefix; if ($group_id == '' || !isset ($group_id) || $group_id == 1) { $sql = "select id,user_name from $users_table where supporter=1 order by user_name asc"; $table = $users_table; } else { $table = $table_prefix."sgroup".$group_id; $sql = "select user_id,user_name from $table order by user_name asc"; } $result = $db->query($sql); while ($row = $db->fetch_array($result)) { echo ""; } } function createUserInfo() { global $pubpriv, $users_table, $db, $lang_username, $lang_email, $lang_office, $lang_phoneext, $lang_userinfo; if ($pubpriv == 'Private') { $sql = "SELECT * from $users_table where user_name='$_SESSION[user]'"; $result = $db->query($sql); $row = $db->fetch_array($result); $cookie_phone = $row[phone]; $cookie_email = $row[email]; $cookie_user_name = $row[user_name]; $cookie_office = $row[office]; } else { global $cookie_phone, $cookie_email, $cookie_user_name, $cookie_office; } startTable("$lang_userinfo", "left", 100, 4); if ($pubpriv == "Private") { echo " $lang_username: $cookie_user_name "; } else { echo " $lang_username: "; } echo " $lang_email: $lang_office: $lang_phoneext: "; endTable(); } function sendGroupPage($sg, $user_name, $short, $priority, $tid) { global $users_table, $admin_email, $helpdesk_name, $enable_smtp, $db, $templates_table, $tickets_table, $lang_ticket, $lang_from, $lang_created, $lang_taskcreatedby, $supporter_site_url, $lang_shortdesc, $lang_priority,$table_prefix; $sql = "SELECT * from $tickets_table where id=$tid"; $result = $db->query($sql); $ticket = $db->fetch_array($result); //setup the ticket array so all variables are available. // we have the groupid (sg), the username, short description. // get the list of supporters to page. if ($sg == 1) $sql = "SELECT pager_email from $users_table"; else $sql = "select pager_email from $users_table, ".$table_prefix."sgroup".$sg." where $users_table.user_name=".$table_prefix."sgroup".$sg.".user_name"; $result = $db->query($sql); while ($row = $db->fetch_array($result)) { // create the header list for the to address in the email. if ($row[pager_email] != '') { if ($list != 1) { $to_list = $row[pager_email]; $list = 1; } else { $to_list .= ", ".$row[pager_email]; $list = 1; } } } $sql = "SELECT template from $templates_table where name='email_group_page'"; $result = $db->query($sql); $template = $db->fetch_array($result); $template = str_replace("\\'", "'", $template[0]); eval ("\$email_msg = \"$template\";"); if ($to_list != ''){ //handle case where no pager users have email addresses setup sendEmail($to_list, $admin_email, $email_msg, "$lang_ticket $tid"); } // no other options...if enable_smtp is set to anything else, the email will not get sent. } ?>