Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*********************/
- /* */
- /* By Or4nG.M4n */
- /* By Abdullah */
- /* priv8te@hotmail.com */
- /* */
- /*********************/
- function ticketsummary( $text )
- {
- $tail = "...";
- $length = "100";
- $text = strip_tags( $text );
- $txtl = strlen( $text );
- if ( $length < $txtl )
- {
- $i = 1;
- while ( $text[$length - $i] != " " )
- {
- if ( $i == $length )
- {
- return substr( $text, 0, $length ).$tail;
- }
- ++$i;
- }
- $text = substr( $text, 0, $length - $i + 1 ).$tail;
- }
- return $text;
- }
- define( "CLIENTAREA", true );
- require( "dbconnect.php" );
- require( "includes/functions.php" );
- require( "includes/clientareafunctions.php" );
- require( "includes/ticketfunctions.php" );
- require( "includes/customfieldfunctions.php" );
- require( "includes/clientfunctions.php" );
- $pagetitle = $_LANG['supportticketssubmitticket'];
- $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>";
- $pageicon = "images/submitticket_big.gif";
- initialiseClientArea( $pagetitle, $pageicon, $breadcrumbnav );
- if ( $action == "getkbarticles" )
- {
- $kbarticles = array( );
- $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" );
- while ( $data = mysql_fetch_array( $result ) )
- {
- $articleid = $data['id'];
- $parentid = $data['parentid'];
- if ( $parentid )
- {
- $articleid = $parentid;
- }
- $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=''" );
- $data = mysql_fetch_array( $result2 );
- $categoryid = $data['categoryid'];
- if ( $categoryid )
- {
- $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" );
- $data = mysql_fetch_array( $result2 );
- $title = $data['title'];
- $article = $data['article'];
- $views = $data['views'];
- $kbarticles[] = array( "id" => $articleid, "category" => $categoryid, "title" => $title, "article" => ticketsummary( $article ) );
- }
- }
- if ( $kbarticles )
- {
- $smarty->assign( "kbarticles", $kbarticles );
- echo $smarty->fetch( $CONFIG['Template']."/supportticketsubmit-kbsuggestions.tpl" );
- }
- exit( );
- }
- if ( $CONFIG['CaptchaSetting'] == "on" || $CONFIG['CaptchaSetting'] == "offloggedin" && !$_SESSION['uid'] )
- {
- $capatacha = "on";
- }
- $errormessage = "";
- if ( $step == "3" )
- {
- if ( !$_SESSION['uid'] )
- {
- if ( !$name )
- {
- $errormessage .= "<li>".$_LANG['supportticketserrornoname'];
- }
- if ( !$email )
- {
- $errormessage .= "<li>".$_LANG['supportticketserrornoemail'];
- }
- 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 ) )
- {
- $errormessage .= "<li>".$_LANG['clientareaerroremailinvalid'];
- }
- }
- if ( !$subject )
- {
- $errormessage .= "<li>".$_LANG['supportticketserrornosubject'];
- }
- if ( !$message )
- {
- $errormessage .= "<li>".$_LANG['supportticketserrornomessage'];
- }
- if ( $_FILES['attachments'] )
- {
- foreach ( $_FILES['attachments']['name'] as $num => $filename )
- {
- $filename = trim( $filename );
- if ( $filename )
- {
- $filename = preg_replace( "/[^a-zA-Z0-9-_. ]/", "", $filename );
- $validextension = checkTicketAttachmentExtension( $filename );
- if ( !$validextension )
- {
- $errormessage .= "<li>".$_LANG['supportticketsfilenotallowed'];
- }
- }
- }
- }
- if ( $capatacha && $_SESSION['image_random_value'] != md5( strtoupper( $code ) ) )
- {
- $errormessage .= "<li>".$_LANG['imagecheck'];
- }
- $errormessage .= checkCustomFields( $customfield );
- if ( $errormessage )
- {
- $step = "2";
- }
- }
- $supportmodulepath = "modules/support/".$CONFIG['SupportModule']."/submitticket.php";
- checkContactPermission( "tickets" );
- if ( $CONFIG['SupportModule'] && file_exists( $supportmodulepath ) )
- {
- if ( !$_SESSION['uid'] )
- {
- $goto = "submitticket";
- include( "login.php" );
- }
- $usingsupportmodule = true;
- require( $supportmodulepath );
- }
- else if ( $step == "" )
- {
- $templatefile = "supportticketsubmit-stepone";
- $result = select_query( "tblticketdepartments", "COUNT(*)", array( "hidden" => "" ) );
- $data = mysql_fetch_array( $result );
- $totaldepartments = $data[0];
- $where = "";
- $where['hidden'] = "";
- if ( !$_SESSION['uid'] )
- {
- $where['clientsonly'] = "";
- }
- $result = select_query( "tblticketdepartments", "", $where, "order", "ASC" );
- while ( $data = mysql_fetch_array( $result ) )
- {
- $id = $data['id'];
- $name = $data['name'];
- $description = $data['description'];
- $departments[] = array( "id" => $id, "name" => $name, "description" => $description );
- }
- if ( !$departments && $totaldepartments )
- {
- $goto = "submitticket";
- include( "login.php" );
- }
- $smarty->assign( "departments", $departments );
- }
- else if ( $step == "2" )
- {
- $templatefile = "supportticketsubmit-steptwo";
- $result = select_query( "tblticketdepartments", "id,name,clientsonly", array( "id" => $deptid ) );
- $data = mysql_fetch_array( $result );
- $deptid = $data['id'];
- if ( !$deptid )
- {
- header( "Location: submitticket.php" );
- exit( );
- }
- $deptname = $data['name'];
- $clientsonly = $data['clientsonly'];
- if ( $clientsonly && !$_SESSION['uid'] )
- {
- $templatefile = "supportticketsubmit-stepone";
- $goto = "submitticket";
- include( "login.php" );
- }
- $smarty->assign( "deptid", $deptid );
- $smarty->assign( "department", $deptname );
- if ( $_SESSION['uid'] )
- {
- $clientsdetails = getClientsDetails( $_SESSION['uid'], $_SESSION['cid'] );
- $clientname = $clientsdetails['firstname']." ".$clientsdetails['lastname'];
- $email = $clientsdetails['email'];
- $smarty->assign( "clientname", $clientname );
- $smarty->assign( "email", $email );
- $relatedservices = array( );
- $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" );
- while ( $data = mysql_fetch_array( $result ) )
- {
- $productname = $data['name'];
- if ( $data['domain'] )
- {
- $productname .= " - ".$data['domain'];
- }
- $relatedservices[] = array( "id" => "S".$data['id'], "name" => $productname, "status" => $_LANG["clientarea".strtolower( $data['domainstatus'] )] );
- }
- $result = select_query( "tbldomains", "", array( "userid" => $_SESSION['uid'] ), "domain", "ASC" );
- while ( $data = mysql_fetch_array( $result ) )
- {
- $relatedservices[] = array( "id" => "D".$data['id'], "name" => $_LANG['clientareahostingdomain']." - ".$data['domain'], "status" => $_LANG["clientarea".strtolower( str_replace( "-", "", $data['status'] ) )] );
- }
- $smartyvalues['relatedservices'] = $relatedservices;
- }
- else
- {
- $smarty->assign( "name", $name );
- $smarty->assign( "email", $email );
- }
- $customfields = getCustomFields( "support", $deptid, "", "", "", $customfield );
- $smarty->assign( "customfields", $customfields );
- $smarty->assign( "allowedfiletypes", $CONFIG['TicketAllowedFileTypes'] );
- $smarty->assign( "errormessage", $errormessage );
- $smarty->assign( "subject", $subject );
- $smarty->assign( "message", $message );
- $smarty->assign( "capatacha", $capatacha );
- if ( $CONFIG['SupportTicketKBSuggestions'] )
- {
- $smarty->assign( "kbsuggestions", true );
- }
- }
- else if ( $step == "3" )
- {
- $result = select_query( "tblticketdepartments", "id,clientsonly", array( "id" => $deptid ) );
- $data = mysql_fetch_array( $result );
- $deptid = $data['id'];
- $check_clientsonly = $data['clientsonly'];
- if ( !$deptid || $check_clientsonly && !$_SESSION['uid'] )
- {
- exit( );
- }
- $attachments = uploadTicketAttachments( );
- $from['name'] = $name;
- $from['email'] = $email;
- $message .= "\n\n----------------------------\nIP Address: {$remote_ip}";
- $cc = "";
- if ( $_SESSION['cid'] )
- {
- $result = select_query( "tblcontacts", "email", array( "id" => $_SESSION['cid'], "userid" => $_SESSION['uid'] ) );
- $data = mysql_fetch_array( $result );
- $cc = $data['email'];
- }
- $ticketdetails = openNewTicket( $_SESSION['uid'], $deptid, $subject, $message, $urgency, $attachments, $from, $relatedservice, $cc );
- saveCustomFields( $ticketdetails['ID'], $customfield );
- $_SESSION['tempticketdata'] = $ticketdetails;
- header( "Location: submitticket.php?step=4" );
- exit( );
- }
- else if ( $step == "4" )
- {
- $ticketdetails = $_SESSION['tempticketdata'];
- $templatefile = "supportticketsubmit-confirm";
- $smarty->assign( "tid", $ticketdetails['TID'] );
- $smarty->assign( "c", $ticketdetails['C'] );
- $smarty->assign( "subject", $ticketdetails['Subject'] );
- }
- outputClientArea( $templatefile );
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement