function processPipedTicket($to, $name, $email, $subject, $message, $attachment) { global $whmcs; global $CONFIG; global $supportticketpipe; global $pipenonregisteredreplyonly; $supportticketpipe = true; $decodestring = $subject . "##||-MESSAGESPLIT-||##" . $message; $decodestring = pipeDecodeString($decodestring); $decodestring = explode("##||-MESSAGESPLIT-||##", $decodestring); $subject = $decodestring[0]; $message = $decodestring[1]; $raw_message = $message; $result = select_query("tblticketspamfilters", "", ""); while ($data = mysql_fetch_array($result)) { $id = $data['id']; $type = $data['type']; $content = $data['content']; if ($type == "sender") { if (strtolower($content) == strtolower($email)) { $mailstatus = "Blocked Sender"; } } if ($type == "subject") { if (strpos("x" . strtolower($subject), strtolower($content))) { $mailstatus = "Blocked Subject"; } } if ($type == "phrase") { if (strpos("x" . strtolower($message), strtolower($content))) { $mailstatus = "Blocked Phrase"; } } } run_hook("TicketPiping", array()); if (!$mailstatus) { $pos = strpos($subject, "[Ticket ID: "); if ($pos === false) { } else { $tid = substr($subject, $pos + 12); $tid = substr($tid, 0, strpos($tid, "]")); $result = select_query("tbltickets", "", array("tid" => $tid)); $data = mysql_fetch_array($result); $tid = $data['id']; } $to = trim($to); $toemails = explode(",", $to); $deptid = ""; foreach ($toemails as $toemail) { if (!$deptid) { $result = select_query("tblticketdepartments", "", array("email" => trim(strtolower($toemail)))); $data = mysql_fetch_array($result); $deptid = $data['id']; $to = $data['email']; $deptclientsonly = $data['clientsonly']; $deptpiperepliesonly = $data['piperepliesonly']; continue; } } if (!$deptid) { $result = select_query("tblticketdepartments", "", array("hidden" => ""), "order", "ASC", "1"); $data = mysql_fetch_array($result); $deptid = $data['id']; $to = $data['email']; $deptclientsonly = $data['clientsonly']; $deptpiperepliesonly = $data['piperepliesonly']; } if (!$deptid) { $mailstatus = "Department Not Found"; } else { if ($to == $email) { $mailstatus = "Blocked Potential Email Loop"; } else { $messagebackup = $message; $result = select_query("tblticketbreaklines", "", "", "id", "ASC"); while ($data = mysql_fetch_array($result)) { $breakpos = strpos($message, $data['breakline']); if ($breakpos) { $message = substr($message, 0, $breakpos); } } if (!$message) { $message = $messagebackup; } $message = trim($message); $result = select_query("tbladmins", "id", array("email" => $email)); $data = mysql_fetch_array($result); $adminid = $data['id']; if ($adminid) { if ($tid) { $_SESSION['adminid'] = $adminid; AddReply($tid, "", "", $message, true, $attachment); $_SESSION['adminid'] = ""; $mailstatus = "Ticket Reply Imported Successfully"; } else { $mailstatus = "Ticket ID Not Found"; } } else { $result = select_query("tblclients", "id", array("email" => $email)); $data = mysql_fetch_array($result); $userid = $data['id']; if (!$userid) { $result = select_query("tblcontacts", "id,userid", array("email" => $email)); $data = mysql_fetch_array($result); $userid = $data['userid']; $contactid = $data['id']; if ($userid) { $ccemail = $email; } } if ($deptclientsonly == "on" && !$userid) { $mailstatus = "Unregistered Email Address"; $result = select_query("tblticketdepartments", "", array("id" => $deptid)); $data = mysql_fetch_array($result); $noautoresponder = $data['noautoresponder']; if (!$noautoresponder) { sendMessage("Bounce Message", "", array($name, $email)); } } else { if ($userid == "") { $from['name'] = $name; $from['email'] = $email; } $filterdate = date("YmdHis", mktime(date("H"), date("i") - 15, date("s"), date("m"), date("d"), date("Y"))); $query = "SELECT count(*) FROM tbltickets WHERE date>'" . $filterdate . "' AND (email='" . mysql_real_escape_string($email) . "'"; if ($userid) { $query .= " OR userid=" . (int) $userid; } $query .= ")"; $result = full_query($query); $data = mysql_fetch_array($result); $numtickets = $data[0]; if (10 < $numtickets) { $mailstatus = "Exceeded Limit of 10 Tickets within 15 Minutes"; } else { run_hook("TransliterateTicketText", array("subject" => $subject, "message" => $message)); if ($tid) { AddReply($tid, $userid, $contactid, htmlspecialchars_array($message), "", $attachment, htmlspecialchars_array($from)); $mailstatus = "Ticket Reply Imported Successfully"; } else { if ($pipenonregisteredreplyonly && !$userid) { $mailstatus = "Blocked Ticket Opening from Unregistered User"; } else { if ($deptpiperepliesonly) { $mailstatus = "Only Replies Allowed by Email"; } else { openNewTicket(htmlspecialchars_array($userid), htmlspecialchars_array($contactid), htmlspecialchars_array($deptid), htmlspecialchars_array($subject), htmlspecialchars_array($message), "Medium", $attachment, htmlspecialchars_array($from), "", htmlspecialchars_array($ccemail)); $mailstatus = "Ticket Imported Successfully"; } } } } } } } } } else { if ($attachment) { global $attachments_dir; $attachment = explode("|", $attachment); foreach ($attachment as $file) { deleteFile($attachments_dir, $file); } } } if ($mailstatus == "") { $mailstatus = "Ticket Import Failed"; } $table = "tblticketmaillog"; $array = ""; $array = array("date" => "now()", "to" => $to, "name" => $name, "email" => $email, "subject" => $subject, "message" => $message, "status" => $mailstatus); insert_query($table, htmlspecialchars_array($array)); }
$smarty->assign("balance", formatCurrency($balance)); $smarty->assign("withdrawn", formatCurrency($withdrawn)); $affpayoutmin = $CONFIG['AffiliatePayout']; $affpayoutmin = convertCurrency($affpayoutmin, 1, $currency['id']); if ($affpayoutmin <= $balance) { $smarty->assign("withdrawlevel", "true"); if ($action == "withdrawrequest") { $deptid = ""; if ($CONFIG['AffiliateDepartment']) { $deptid = get_query_val("tblticketdepartments", "id", array("id" => $CONFIG['AffiliateDepartment'])); } if (!$deptid) { $deptid = get_query_val("tblticketdepartments", "id", array("hidden" => ""), "order", "ASC"); } $message = "Affiliate Account Withdrawal Request. Details below:\n\nClient ID: " . $_SESSION['uid'] . ("\nAffiliate ID: " . $id . "\nBalance: " . $balance); $ticketdetails = openNewTicket($_SESSION['uid'], $_SESSION['cid'], $deptid, "Affiliate Withdrawal Request", $message, "Medium"); redir("withdraw=1"); } } if ($whmcs->get_req_var("withdraw")) { $smarty->assign("withdrawrequestsent", "true"); } $content .= "\n<p><b>" . $_LANG['affiliatesreferals'] . "</b></p>\n<table align=\"center\" id=\"affiliates\" cellspacing=\"1\">\n<tr><td id=\"affiliatesheading\">" . $_LANG['affiliatessignupdate'] . "</td><td id=\"affiliatesheading\">" . $_LANG['affiliateshostingpackage'] . "</td><td id=\"affiliatesheading\">" . $_LANG['affiliatesamount'] . "</td><td id=\"affiliatesheading\">" . $_LANG['affiliatescommision'] . "</td><td id=\"affiliatesheading\">" . $_LANG['affiliatesstatus'] . "</td></tr>\n"; $numitems = get_query_val("tblaffiliatesaccounts", "COUNT(*)", array("affiliateid" => $affiliateid), "", "", "", "tblhosting ON tblhosting.id=tblaffiliatesaccounts.relid INNER JOIN tblproducts ON tblproducts.id=tblhosting.packageid INNER JOIN tblclients ON tblclients.id=tblhosting.userid"); list($orderby, $sort, $limit) = clientAreaTableInit("affiliates", "regdate", "DESC", $numitems); $smartyvalues['orderby'] = $orderby; $smartyvalues['sort'] = strtolower($sort); if ($orderby == "product") { $orderby = "tblproducts`.`name"; } else { if ($orderby == "amount") {
$apiresults = array("result" => "error", "message" => "Service ID Not Found"); return null; } $serviceid = "S" . $data['id']; } else { $serviceid = substr($serviceid, 1); $result = select_query("tbldomains", "id", array("id" => $serviceid, "userid" => $clientid)); $data = mysql_fetch_array($result); if (!$data['id']) { $apiresults = array("result" => "error", "message" => "Service ID Not Found"); return null; } $serviceid = "D" . $data['id']; } } if ($domainid) { $result = select_query("tbldomains", "id", array("id" => $domainid, "userid" => $clientid)); $data = mysql_fetch_array($result); if (!$data['id']) { $apiresults = array("result" => "error", "message" => "Domain ID Not Found"); return null; } $serviceid = "D" . $data['id']; } $ticketdata = openNewTicket($clientid, $contactid, $deptid, $subject, $message, $priority, "", $from, $serviceid, $cc, $noemail); if ($customfields) { $customfields = base64_decode($customfields); $customfields = unserialize($customfields); saveCustomFields($ticketdata['ID'], $customfields); } $apiresults = array("result" => "success", "id" => $ticketdata['ID'], "tid" => $ticketdata['TID'], "c" => $ticketdata['C']);
$data = mysql_fetch_array($result); $userid = $data['id']; if (!$userid) { $from = array("name" => $name, "email" => $email); } $pos = strpos($subject, "[Ticket ID: "); if ($pos === false) { $result = select_query("tblticketdepartments", "id", array("email" => $email)); $data = mysql_fetch_array($result); $deptid = $data['id']; if (!$deptid) { $result = select_query("tblticketdepartments", "id", "", "order", "ASC"); $data = mysql_fetch_array($result); $deptid = $data['id']; } openNewTicket($userid, "", $deptid, $subject, $message, "Medium", "", $from); $status = "Ticket Imported Successfully"; } else { $tid = substr($subject, $pos + 12, 6); $result = select_query("tbltickets", "", array("tid" => $tid)); $data = mysql_fetch_array($result); $tid = $data['id']; $result = select_query("tbladmins", "id", array("email" => $email)); $data = mysql_fetch_array($result); $adminid = $data['id']; if ($adminid) { $userid = 0; $from = ""; $admin = getAdminName($adminid); } AddReply($tid, $userid, "", $message, $admin, "", $from);
} if (!$client) { 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 = $aInt->lang("support", "ticketemailvalidationerror"); } if (!$email) { $errormessage = $aInt->lang("support", "ticketemailerror"); } if (!$name) { $errormessage = $aInt->lang("support", "ticketnameerror"); } } if (!$errormessage) { $attachments = uploadTicketAttachments(true); $client = (int) str_replace("UserID:", "", $client); $ticketdata = openNewTicket($client, $contactid, $deptid, $subject, $message, $priority, $attachments, array("name" => $name, "email" => $email), $relatedservice, $ccemail, $sendemail ? false : true, true); $id = $ticketdata['ID']; redir("action=viewticket&id=" . $id); exit; } else { $action = "open"; } } else { if ($action == "viewticket") { $access = validateAdminTicketAccess($id); if ($access == "invalidid") { $aInt->gracefulExit($aInt->lang("support", "ticketnotfound")); } if ($access == "deptblocked") { $aInt->gracefulExit($aInt->lang("support", "deptnoaccess")); }
$deptid = $data['id']; $check_clientsonly = $data['clientsonly']; if (!$deptid || $check_clientsonly && !$_SESSION['uid']) { exit; } $attachments = uploadTicketAttachments(); $from['name'] = $name; $from['email'] = $email; $message .= "\r\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'], $_SESSION['cid'], $deptid, $subject, $message, $urgency, $attachments, $from, $relatedservice, $cc); saveCustomFields($ticketdetails['ID'], $customfield); $_SESSION['tempticketdata'] = $ticketdetails; redir("step=4"); } 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);