| [ PHPXref.com ] | [ Generated: Sun Jul 20 19:05:01 2008 ] | [ OneOrZero 1.6.3 ] |
| [ Index ] [ Variables ] [ Functions ] [ Classes ] [ Constants ] [ Statistics ] | ||
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * file: tcreate.php 5 * 6 * This file contains the frontend for creating a new ticket. Provides error checking and also 7 * accesses the database to insert the information. 8 * 9 /*************************************************************************** 10 * This program is free software; you can redistribute it and/or 11 * modify it under the terms of the GNU General Public 12 * License as published by the Free Software Foundation; either 13 * version 2.1 of the License, or (at your option) any later version. 14 * 15 * This program is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 * General Public License for more details. 19 * 20 * You should have received a copy of the GNU General Public 21 * License along with This program; if not, write to: 22 * Free Software Foundation, Inc. 23 * 59 Temple Place 24 * Suite 330 25 * Boston, MA 02111-1307 USA 26 * 27 * Copyright 2005 One or Zero 28 * info@oneorzero.com 29 * http://www.oneorzero.com 30 * Developers: OneOrZero Team / Contributors: OneOrZero Community 31 ****************************************************************************/ 32 33 require_once "common/common.php"; 34 require_once "common/init_server_settings.php"; 35 require_once "common/$database.class.php"; 36 require_once "common/init_ooz.php"; 37 38 //Since we do some interesting autofill on the supporter 39 //version of this we need to 'simplify' the user create. 40 //We set this var, to keep the function from creating 41 //a strange option value for the GROUP pull down. 42 //we then unset this var after the create post is complete. 43 $_SESSION[userform] = 1; 44 45 if ($pubpriv == 'Private') 46 require_once "common/login.php"; 47 48 //check to see if the user is a viewer only, if they are disable this action 49 if (isViewer($_SESSION[user]) and $pubpriv == "Private") { 50 printError($lang_privelages); 51 exit; 52 } 53 $language = getLanguage($_SESSION[user]); 54 55 if ($language == '') 56 require_once "lang/$default_language.lang.php"; 57 else 58 require_once "lang/$language.lang.php"; 59 60 if (isset ($_POST[create])) { 61 // if the system is public, set some cookies so user information will be recorded for next time 62 setcookie("cookie_user_name", $username, time() + 31536000); 63 setcookie("cookie_email", $email, time() + 31536000); 64 setcookie("cookie_office", $office, time() + 31536000); 65 setcookie("cookie_phone", $phone, time() + 31536000); 66 67 $time = time() + ($time_offset * 3600); 68 69 //ensure there are no spaces/html characters in the short desc 70 $_POST[short]=strip_tags(trim(urldecode($_POST[short]))); 71 72 if ($_POST[sg] == '' || $_POST[priority] == '' || $_POST[username] == '' || $_POST[short] == '' || $_POST[description] == '') { 73 header("Location: index.php?t=terr"); 74 } else { 75 if ($_POST[short] == '') { 76 $short = "$lang_nodesc"; 77 } 78 79 $status = getStatus(getLowestRank($tstatus_table)); 80 81 $short = stripScripts($_POST[short]); 82 $description = stripScripts($_POST[description]); 83 84 $sql = "INSERT into $tickets_table values(NULL, '$time', $_POST[sg]" . 85 ", 'support_pool', 1, '$_POST[priority]', '$status'" . 86 ", '$_POST[username]', '$_POST[email]'" . 87 ", '$_POST[office]', '$_POST[phone]'" . 88 ", '$_POST[category]', '$_POST[platform]', '$short', '$description', NULL" . 89 ", 0, '$time')"; 90 $db->query($sql); 91 $tid = $db->insert_id(); 92 // update the log so it shows who created the ticket now. 93 if ($pubpriv == "Public") 94 $msg = "<i>\$lang_createdbyweb ".$_POST[username]."</i>"; 95 else 96 $msg = "<i>\$lang_taskcreatedby ".$_SESSION[user]."</i>"; 97 $log = updateLog($tid, $msg); 98 $sql = "update $tickets_table set update_log='$log' where id=$tid"; 99 $db->query($sql); 100 101 // insert the file into the database if it exists. 102 // Modified by Adam Hall to allow attachment file upload support 103 if ($enable_tattachments == 'On' && $_FILES['SelectedFile']['name'] != '' && $_FILES['SelectedFile']['name'] != 'none') { 104 //Upload file and return new file name 105 $mtime = explode(" ", microtime()); 106 $mtime = $mtime[1].substr($mtime[0],5,3); 107 $file_name = uploadAttachment($max_attachment_size, 'SelectedFile',$mtime); 108 $file_type = $_FILES['SelectedFile']['type']; 109 $file_size = $_FILES['SelectedFile']['size']; 110 $sql = "INSERT into $attachments_table VALUES (NULL, NULL, $tid, '$file_name', '$file_upload_directory', '$file_type', '$file_size', NULL, 0, '$_SESSION[user]', $time)"; 111 $db->query($sql); //insert all info about the attachment into the database. 112 $file_id = $db->insert_id(); 113 114 // insert the file into the database if it exists. 115 // if ($enable_uattachments == 'On' && $the_file != '' && $the_file != 'none') { 116 // $attachment = addslashes(fread(fopen($the_file, "rb"), filesize($the_file))); 117 // if ($the_file_type == "application/x-gzip-compressed") { 118 // $attachment = base64_decode($attachment); 119 // } 120 // $query = "INSERT into $attachments_table VALUES(NULL, NULL, $tid, '$the_file_name', '$the_file_type', '$the_file_size', '$attachment', 0, '$_SESSION[user]', $time)"; 121 // $db->query($query); //insert all info about the attachment into the database. 122 // $file_id = $db->insert_id(); 123 // 124 $attachsize = $file_size; 125 if ($attachsize >= 1073741824) { 126 $attachsize = round($attachsize / 1073741824 * 100) / 100 . "gb"; 127 } elseif ($attachsize >= 1048576) { 128 $attachsize = round($attachsize / 1048576 * 100) / 100 . "mb"; 129 } elseif ($attachsize >= 1024) { 130 $attachsize = round($attachsize / 1024 * 100) / 100 . "kb"; 131 } else { 132 $attachsize = $attachsize . "b"; 133 } 134 135 // update the update log 136 $msg = "\$lang_fileattached : ".$_FILES['SelectedFile']['name']." ( $attachsize )"; 137 $log = updateLog($tid, $msg); 138 $sql = "update $tickets_table set update_log='$log' where id=$tid"; 139 $db->query($sql); 140 } 141 //reset the userform session var... 142 unset($_SESSION[userform]); 143 144 // if the pager gateway is enabled...send a page to the supporters of that group if the ticket is set above the default. 145 if ($enable_pager == 'On' && (getRank($_POST[priority], $tpriorities_table) <= $pager_rank_low)) { 146 sendGroupPage($_POST[sg], $_POST[username], $_POST[short], $_POST[priority], $tid); 147 } 148 // now print out the html that lets the user know that their ticket was submitted successfully. 149 header("Location: index.php?t=tsuc&id=$tid"); 150 } 151 } else { 152 echo "<form action=tcreate.php method=post enctype=\"multipart/form-data\">"; 153 154 155 ?> 156 157 <script language="JavaScript"> 158 <!-- 159 160 161 function MM_jumpMenu(targ,selObj,restore){ //v3.0 162 eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'"); 163 if (restore) selObj.selectedIndex=0; 164 165 } 166 //--></script> 167 168 <?php 169 170 createTicketHeader("$lang_create $lang_ticket"); 171 createSupporterInfo(); 172 createUserInfo(); 173 if ($enable_uattachments == 'Off') { 174 createTicketInfo('disallow'); 175 } else { 176 createTicketInfo(); 177 } 178 179 echo "<center>"; 180 echo "<input type=submit name=create value=\"$lang_create $lang_ticket\">"; 181 echo " "; 182 echo "<input type=reset name=reset value=$lang_reset>"; 183 //echo "<input type=hidden name=sg value=".$_GET[sg].">"; 184 echo "</form>"; 185 echo "</center>"; 186 } 187 188 function createTicketHeader($msg) { 189 startTable($msg, "middle"); 190 endTable(); 191 } 192 193 function createSupporterInfo() { 194 global $lang_supporterinfo, $lang_supportergroup, $lang_priority, $lang_ticket; 195 196 if ($_GET[sg] == '') { 197 $_GET[sg] = getDefaultSupporterGroupID(); 198 } 199 200 startTable("$lang_supporterinfo", "left", 100, 4); 201 202 echo '<tr> 203 <td width=27% class=back2 align=right>'.$lang_supportergroup.':</td> 204 <td class=back width=20%>'; 205 206 207 ?> 208 <select name=sg> 209 <?php 210 211 $_SESSION[autofill_sg] = $_GET[sg]; 212 createGroupMenu(0); 213 214 echo '</select> 215 </td> 216 <td width=100 class=back2 align=right>'.$lang_ticket.' '.$lang_priority.':</td> 217 <td class=back> 218 <select name=priority>'; 219 220 createPriorityMenu(); 221 222 echo ' </select> 223 </td> 224 </tr>'; 225 226 endTable(); 227 } 228 229 function createSupporterMenu($group_id) { 230 global $users_table, $db, $table_prefix; 231 232 if ($group_id == '' || !isset ($group_id) || $group_id == 1) { 233 $sql = "select id,user_name from $users_table where supporter=1 order by user_name asc"; 234 $table = $users_table; 235 } else { 236 $table = $table_prefix."sgroup".$group_id; 237 $sql = "select user_id,user_name from $table order by user_name asc"; 238 } 239 240 $result = $db->query($sql); 241 242 while ($row = $db->fetch_array($result)) { 243 echo "<option value=\"$row[id]\"> $row[user_name] </option>"; 244 } 245 } 246 247 function createUserInfo() { 248 global $pubpriv, $users_table, $db, $lang_username, $lang_email, $lang_office, $lang_phoneext, $lang_userinfo; 249 250 if ($pubpriv == 'Private') { 251 $sql = "SELECT * from $users_table where user_name='$_SESSION[user]'"; 252 $result = $db->query($sql); 253 $row = $db->fetch_array($result); 254 $cookie_phone = $row[phone]; 255 $cookie_email = $row[email]; 256 $cookie_user_name = $row[user_name]; 257 $cookie_office = $row[office]; 258 } else { 259 global $cookie_phone, $cookie_email, $cookie_user_name, $cookie_office; 260 } 261 startTable("$lang_userinfo", "left", 100, 4); 262 if ($pubpriv == "Private") { 263 echo "<tr> 264 <td width=27% class=back2 align=right>$lang_username:</td> 265 <td class=back width=20%>$cookie_user_name 266 <input type=hidden name=username value=\"$cookie_user_name\"> 267 </td>"; 268 } else { 269 echo "<tr> 270 <td width=27% class=back2 align=right>$lang_username:</td> 271 <td class=back width=20%> 272 <input type=text size=16 name=username value=\"$cookie_user_name\"> 273 </td>"; 274 } 275 276 echo " 277 <td class=back2 align=right width=100> $lang_email: </td> 278 <td class=back align=left> 279 <input type=text name=email value=\"$cookie_email\"> 280 </td> 281 </tr> 282 <tr> 283 <td width=27% class=back2 align=right>$lang_office:</td> 284 <td class=back> 285 <input type=text size=16 name=office value=\"$cookie_office\"> 286 </td> 287 <td class=back2 align=right width=100>$lang_phoneext:</td> 288 <td class=back> 289 <input type=text name=phone value=\"$cookie_phone\"> 290 </td>"; 291 292 endTable(); 293 } 294 295 function sendGroupPage($sg, $user_name, $short, $priority, $tid) { 296 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; 297 298 $sql = "SELECT * from $tickets_table where id=$tid"; 299 $result = $db->query($sql); 300 $ticket = $db->fetch_array($result); //setup the ticket array so all variables are available. 301 // we have the groupid (sg), the username, short description. 302 // get the list of supporters to page. 303 if ($sg == 1) 304 $sql = "SELECT pager_email from $users_table"; 305 else 306 $sql = "select pager_email from $users_table, ".$table_prefix."sgroup".$sg." where $users_table.user_name=".$table_prefix."sgroup".$sg.".user_name"; 307 308 $result = $db->query($sql); 309 310 while ($row = $db->fetch_array($result)) { 311 // create the header list for the to address in the email. 312 if ($row[pager_email] != '') { 313 if ($list != 1) { 314 $to_list = $row[pager_email]; 315 $list = 1; 316 } else { 317 $to_list .= ", ".$row[pager_email]; 318 $list = 1; 319 } 320 } 321 } 322 323 $sql = "SELECT template from $templates_table where name='email_group_page'"; 324 $result = $db->query($sql); 325 $template = $db->fetch_array($result); 326 $template = str_replace("\\'", "'", $template[0]); 327 eval ("\$email_msg = \"$template\";"); 328 329 if ($to_list != ''){ //handle case where no pager users have email addresses setup 330 sendEmail($to_list, $admin_email, $email_msg, "$lang_ticket $tid"); 331 } 332 // no other options...if enable_smtp is set to anything else, the email will not get sent. 333 } 334 335 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| [ Powered by PHPXref - Served by Debian GNU/Linux ] |