i-Hmx

Untitled

Sep 2nd, 2012
290
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.39 KB | None | 0 0
  1. <?php
  2. /*********************/
  3. /* */
  4. /* By Or4nG.M4n */
  5. /* By Abdullah */
  6. /* */
  7. /*********************/
  8.  
  9. function ticketsummary( $text )
  10. {
  11. $tail = "...";
  12. $length = "100";
  13. $text = strip_tags( $text );
  14. $txtl = strlen( $text );
  15. if ( $length < $txtl )
  16. {
  17. $i = 1;
  18. while ( $text[$length - $i] != " " )
  19. {
  20. if ( $i == $length )
  21. {
  22. return substr( $text, 0, $length ).$tail;
  23. }
  24. ++$i;
  25. }
  26. $text = substr( $text, 0, $length - $i + 1 ).$tail;
  27. }
  28. return $text;
  29. }
  30.  
  31. define( "CLIENTAREA", true );
  32. require( "dbconnect.php" );
  33. require( "includes/functions.php" );
  34. require( "includes/clientareafunctions.php" );
  35. require( "includes/ticketfunctions.php" );
  36. require( "includes/customfieldfunctions.php" );
  37. require( "includes/clientfunctions.php" );
  38. $pagetitle = $_LANG['supportticketssubmitticket'];
  39. $breadcrumbnav = "<a href=\"index.php\">".$_LANG['globalsystemname']."</a> > <a href=\"clientarea.php\">".$_LANG['clientareatitle']."</a> > <a href=\"supporttickets.php\">".$_LANG['supportticketspagetitle']."</a> > <a href=\"submitticket.php\">".$_LANG['supportticketssubmitticket']."</a>";
  40. $pageicon = "images/submitticket_big.gif";
  41. initialiseClientArea( $pagetitle, $pageicon, $breadcrumbnav );
  42. if ( $action == "getkbarticles" )
  43. {
  44. $kbarticles = array( );
  45. $result = full_query( "SELECT id,parentid FROM tblknowledgebase WHERE CONCAT(title,article) LIKE '%".db_escape_string( $text )."%' OR MATCH (title,article) AGAINST ('".db_escape_string( $text )."') ORDER BY useful DESC LIMIT 0,5" );
  46. while ( $data = mysql_fetch_array( $result ) )
  47. {
  48. $articleid = $data['id'];
  49. $parentid = $data['parentid'];
  50. if ( $parentid )
  51. {
  52. $articleid = $parentid;
  53. }
  54. $result2 = full_query( "SELECT tblknowledgebaselinks.categoryid FROM tblknowledgebase INNER JOIN tblknowledgebaselinks ON tblknowledgebase.id=tblknowledgebaselinks.articleid INNER JOIN tblknowledgebasecats ON tblknowledgebasecats.id=tblknowledgebaselinks.categoryid WHERE (tblknowledgebase.id={$articleid} OR tblknowledgebase.parentid={$articleid}) AND tblknowledgebasecats.hidden=''" );
  55. $data = mysql_fetch_array( $result2 );
  56. $categoryid = $data['categoryid'];
  57. if ( $categoryid )
  58. {
  59. $result2 = full_query( "SELECT * FROM tblknowledgebase WHERE (id={$articleid} OR parentid={$articleid}) AND (language='".db_escape_string( $_SESSION['Language'] )."' OR language='') ORDER BY language DESC" );
  60. $data = mysql_fetch_array( $result2 );
  61. $title = $data['title'];
  62. $article = $data['article'];
  63. $views = $data['views'];
  64. $kbarticles[] = array( "id" => $articleid, "category" => $categoryid, "title" => $title, "article" => ticketsummary( $article ) );
  65. }
  66. }
  67. if ( $kbarticles )
  68. {
  69. $smarty->assign( "kbarticles", $kbarticles );
  70. echo $smarty->fetch( $CONFIG['Template']."/supportticketsubmit-kbsuggestions.tpl" );
  71. }
  72. exit( );
  73. }
  74. if ( $CONFIG['CaptchaSetting'] == "on" || $CONFIG['CaptchaSetting'] == "offloggedin" && !$_SESSION['uid'] )
  75. {
  76. $capatacha = "on";
  77. }
  78. $errormessage = "";
  79. if ( $step == "3" )
  80. {
  81. if ( !$_SESSION['uid'] )
  82. {
  83. if ( !$name )
  84. {
  85. $errormessage .= "<li>".$_LANG['supportticketserrornoname'];
  86. }
  87. if ( !$email )
  88. {
  89. $errormessage .= "<li>".$_LANG['supportticketserrornoemail'];
  90. }
  91. else if ( !preg_match( "/^([a-zA-Z0-9])+([\\.a-zA-Z0-9_-])*@([a-zA-Z0-9_-])+(\\.[a-zA-Z0-9_-]+)*\\.([a-zA-Z]{2,6})$/", $email ) )
  92. {
  93. $errormessage .= "<li>".$_LANG['clientareaerroremailinvalid'];
  94. }
  95. }
  96. if ( !$subject )
  97. {
  98. $errormessage .= "<li>".$_LANG['supportticketserrornosubject'];
  99. }
  100. if ( !$message )
  101. {
  102. $errormessage .= "<li>".$_LANG['supportticketserrornomessage'];
  103. }
  104. if ( $_FILES['attachments'] )
  105. {
  106. foreach ( $_FILES['attachments']['name'] as $num => $filename )
  107. {
  108. $filename = trim( $filename );
  109. if ( $filename )
  110. {
  111. $filename = preg_replace( "/[^a-zA-Z0-9-_. ]/", "", $filename );
  112. $validextension = checkTicketAttachmentExtension( $filename );
  113. if ( !$validextension )
  114. {
  115. $errormessage .= "<li>".$_LANG['supportticketsfilenotallowed'];
  116. }
  117. }
  118. }
  119. }
  120. if ( $capatacha && $_SESSION['image_random_value'] != md5( strtoupper( $code ) ) )
  121. {
  122. $errormessage .= "<li>".$_LANG['imagecheck'];
  123. }
  124. $errormessage .= checkCustomFields( $customfield );
  125. if ( $errormessage )
  126. {
  127. $step = "2";
  128. }
  129. }
  130. $supportmodulepath = "modules/support/".$CONFIG['SupportModule']."/submitticket.php";
  131. checkContactPermission( "tickets" );
  132. if ( $CONFIG['SupportModule'] && file_exists( $supportmodulepath ) )
  133. {
  134. if ( !$_SESSION['uid'] )
  135. {
  136. $goto = "submitticket";
  137. include( "login.php" );
  138. }
  139. $usingsupportmodule = true;
  140. require( $supportmodulepath );
  141. }
  142. else if ( $step == "" )
  143. {
  144. $templatefile = "supportticketsubmit-stepone";
  145. $result = select_query( "tblticketdepartments", "COUNT(*)", array( "hidden" => "" ) );
  146. $data = mysql_fetch_array( $result );
  147. $totaldepartments = $data[0];
  148. $where = "";
  149. $where['hidden'] = "";
  150. if ( !$_SESSION['uid'] )
  151. {
  152. $where['clientsonly'] = "";
  153. }
  154. $result = select_query( "tblticketdepartments", "", $where, "order", "ASC" );
  155. while ( $data = mysql_fetch_array( $result ) )
  156. {
  157. $id = $data['id'];
  158. $name = $data['name'];
  159. $description = $data['description'];
  160. $departments[] = array( "id" => $id, "name" => $name, "description" => $description );
  161. }
  162. if ( !$departments && $totaldepartments )
  163. {
  164. $goto = "submitticket";
  165. include( "login.php" );
  166. }
  167. $smarty->assign( "departments", $departments );
  168. }
  169. else if ( $step == "2" )
  170. {
  171. $templatefile = "supportticketsubmit-steptwo";
  172. $result = select_query( "tblticketdepartments", "id,name,clientsonly", array( "id" => $deptid ) );
  173. $data = mysql_fetch_array( $result );
  174. $deptid = $data['id'];
  175. if ( !$deptid )
  176. {
  177. header( "Location: submitticket.php" );
  178. exit( );
  179. }
  180. $deptname = $data['name'];
  181. $clientsonly = $data['clientsonly'];
  182. if ( $clientsonly && !$_SESSION['uid'] )
  183. {
  184. $templatefile = "supportticketsubmit-stepone";
  185. $goto = "submitticket";
  186. include( "login.php" );
  187. }
  188. $smarty->assign( "deptid", $deptid );
  189. $smarty->assign( "department", $deptname );
  190. if ( $_SESSION['uid'] )
  191. {
  192. $clientsdetails = getClientsDetails( $_SESSION['uid'], $_SESSION['cid'] );
  193. $clientname = $clientsdetails['firstname']." ".$clientsdetails['lastname'];
  194. $email = $clientsdetails['email'];
  195. $smarty->assign( "clientname", $clientname );
  196. $smarty->assign( "email", $email );
  197. $relatedservices = array( );
  198. $result = select_query( "tblhosting", "tblhosting.id,tblhosting.domain,tblhosting.domainstatus,tblproducts.name", array( "userid" => $_SESSION['uid'] ), "tblproducts`.`name` ASC,`tblhosting`.`domain", "ASC", "", "tblproducts ON tblproducts.id=tblhosting.packageid" );
  199. while ( $data = mysql_fetch_array( $result ) )
  200. {
  201. $productname = $data['name'];
  202. if ( $data['domain'] )
  203. {
  204. $productname .= " - ".$data['domain'];
  205. }
  206. $relatedservices[] = array( "id" => "S".$data['id'], "name" => $productname, "status" => $_LANG["clientarea".strtolower( $data['domainstatus'] )] );
  207. }
  208. $result = select_query( "tbldomains", "", array( "userid" => $_SESSION['uid'] ), "domain", "ASC" );
  209. while ( $data = mysql_fetch_array( $result ) )
  210. {
  211. $relatedservices[] = array( "id" => "D".$data['id'], "name" => $_LANG['clientareahostingdomain']." - ".$data['domain'], "status" => $_LANG["clientarea".strtolower( str_replace( "-", "", $data['status'] ) )] );
  212. }
  213. $smartyvalues['relatedservices'] = $relatedservices;
  214. }
  215. else
  216. {
  217. $smarty->assign( "name", $name );
  218. $smarty->assign( "email", $email );
  219. }
  220. $customfields = getCustomFields( "support", $deptid, "", "", "", $customfield );
  221. $smarty->assign( "customfields", $customfields );
  222. $smarty->assign( "allowedfiletypes", $CONFIG['TicketAllowedFileTypes'] );
  223. $smarty->assign( "errormessage", $errormessage );
  224. $smarty->assign( "subject", $subject );
  225. $smarty->assign( "message", $message );
  226. $smarty->assign( "capatacha", $capatacha );
  227. if ( $CONFIG['SupportTicketKBSuggestions'] )
  228. {
  229. $smarty->assign( "kbsuggestions", true );
  230. }
  231. }
  232. else if ( $step == "3" )
  233. {
  234. $result = select_query( "tblticketdepartments", "id,clientsonly", array( "id" => $deptid ) );
  235. $data = mysql_fetch_array( $result );
  236. $deptid = $data['id'];
  237. $check_clientsonly = $data['clientsonly'];
  238. if ( !$deptid || $check_clientsonly && !$_SESSION['uid'] )
  239. {
  240. exit( );
  241. }
  242. $attachments = uploadTicketAttachments( );
  243. $from['name'] = $name;
  244. $from['email'] = $email;
  245. $message .= "\n\n----------------------------\nIP Address: {$remote_ip}";
  246. $cc = "";
  247. if ( $_SESSION['cid'] )
  248. {
  249. $result = select_query( "tblcontacts", "email", array( "id" => $_SESSION['cid'], "userid" => $_SESSION['uid'] ) );
  250. $data = mysql_fetch_array( $result );
  251. $cc = $data['email'];
  252. }
  253. $ticketdetails = openNewTicket( $_SESSION['uid'], $deptid, $subject, $message, $urgency, $attachments, $from, $relatedservice, $cc );
  254. saveCustomFields( $ticketdetails['ID'], $customfield );
  255. $_SESSION['tempticketdata'] = $ticketdetails;
  256. header( "Location: submitticket.php?step=4" );
  257. exit( );
  258. }
  259. else if ( $step == "4" )
  260. {
  261. $ticketdetails = $_SESSION['tempticketdata'];
  262. $templatefile = "supportticketsubmit-confirm";
  263. $smarty->assign( "tid", $ticketdetails['TID'] );
  264. $smarty->assign( "c", $ticketdetails['C'] );
  265. $smarty->assign( "subject", $ticketdetails['Subject'] );
  266. }
  267. outputClientArea( $templatefile );
  268. ?>
Advertisement
Add Comment
Please, Sign In to add comment