Advertisement
i-Hmx

Untitled

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