Example #1
0
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));
}
Example #2
0
                 $filename = implode(array_slice($filenameparts, 0, 0 - 1));
                 $filename = preg_replace("/[^a-zA-Z0-9-_ ]/", "", $filename);
                 $filename .= "." . $extension;
                 $validextension = checkTicketAttachmentExtension($filename);
                 if (!$validextension) {
                     $errormessage .= "<li>" . $_LANG['supportticketsfilenotallowed'];
                     continue;
                 }
                 continue;
             }
         }
     }
     if (!$errormessage) {
         $attachments = uploadTicketAttachments();
         $from = array("name" => $replyname, "email" => $replyemail);
         AddReply($id, $_SESSION['uid'], $_SESSION['cid'], $replymessage, "", $attachments, $from);
         redir("tid=" . $tid . "&c=" . $c);
     }
 }
 $id = $data['id'];
 $userid = $data['userid'];
 $contactid = $data['contactid'];
 $deptid = $data['did'];
 $date = $data['date'];
 $subject = $data['title'];
 $message = $data['message'];
 $status = $data['status'];
 $attachment = $data['attachment'];
 $urgency = $data['urgency'];
 $name = $data['name'];
 $email = $data['email'];
            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);
            $status = "Ticket Reply Imported Successfully";
        }
        update_query("tblticketmaillog", array("status" => $status), array("id" => $id));
        redir("display=true&id=" . $id);
    }
    $content = "<p><b>" . $aInt->lang("emails", "to") . ":</b> " . $to . "<br>\n<b>" . $aInt->lang("emails", "from") . ":</b> " . $name . " &laquo;" . $email . "&raquo;<br>\n<b>" . $aInt->lang("emails", "subject") . ":</b> " . $subject . "<br>\n<b>" . $aInt->lang("fields", "status") . ":</b> " . $status;
    if ($status != "Ticket Imported Successfully" && $status != "Ticket Reply Imported Successfully") {
        $content .= " <input type=\"button\" value=\"" . $aInt->lang("system", "ignoreimport") . "\" onclick=\"window.location='" . $_SERVER['PHP_SELF'] . "?display=true&id=" . $id . generate_token("link") . "&action=import'\" />";
    }
    $content .= "</p>\n<p>" . nl2br($message) . "</p>\n<p align=\"center\"><a href=\"#\" onClick=\"window.close();return false\">" . $aInt->lang("addons", "closewindow") . "</a></p>";
    $aInt->content = $content;
    $aInt->displayPopUp();
    exit;
}
ob_start();
Example #4
0
                $notify = explode(",", $notify);
                if (in_array("all", $notify)) {
                    sendAdminMessage("Escalation Rule Notification", array("rule_name" => $name, "ticket_id" => $ticketid, "ticket_tid" => $tickettid, "client_id" => $ticketuserid, "client_name" => get_query_val("tblclients", "CONCAT(firstname,' ',lastname)", array("id" => $ticketuserid)), "ticket_department" => getDepartmentName($newdepartment ? $newdepartment : $ticketdeptid), "ticket_subject" => $ticketsubject, "ticket_priority" => $newpriority ? $newpriority : $ticketpriority, "ticket_message" => ticketMessageFormat($ticketmsg)), "support", $newdepartment ? $newdepartment : $ticketdeptid);
                }
                foreach ($notify as $notifyid) {
                    if (is_numeric($notifyid)) {
                        sendAdminMessage("Escalation Rule Notification", array("rule_name" => $name, "ticket_id" => $ticketid, "ticket_tid" => $tickettid, "client_id" => $ticketuserid, "client_name" => get_query_val("tblclients", "CONCAT(firstname,' ',lastname)", array("id" => $ticketuserid)), "ticket_department" => getDepartmentName($newdepartment ? $newdepartment : $ticketdeptid), "ticket_subject" => $ticketsubject, "ticket_priority" => $newpriority ? $newpriority : $ticketpriority, "ticket_message" => ticketMessageFormat($ticketmsg), "ticket_status" => $ticketstatus), "support", "", $notifyid);
                        continue;
                    }
                }
            }
            if ($addreply) {
                if (!$newstatus) {
                    $newstatus = $ticketstatus;
                }
                AddReply($ticketid, "", "", $addreply, "System", "", "", $newstatus, "", true);
            }
        }
    }
    update_query("tblconfiguration", array("value" => date("Y-m-d H:i:s")), array("setting" => "TicketEscalationLastRun"));
    exit;
}
$cron->logactivity("Starting");
full_query("DELETE FROM tblinvoices WHERE userid NOT IN (SELECT id FROM tblclients)");
full_query("UPDATE tbltickets SET did=(SELECT id FROM tblticketdepartments ORDER BY `order` ASC LIMIT 1) WHERE did NOT IN (SELECT id FROM tblticketdepartments)");
update_query("tblclients", array("currency" => "1"), array("currency" => "0"));
update_query("tblaccounts", array("currency" => "1"), array("currency" => "0", "userid" => "0"));
if ($whmcs->get_config("CurrencyAutoUpdateExchangeRates") && $cron->isScheduled("updaterates")) {
    currencyUpdateRates();
    $cron->logActivity("Done", true);
}
Example #5
0
         $result = select_query("tblticketstatuses", "title", array("id" => substr($postaction, 9)));
         $data = mysql_fetch_array($result);
         $newstatus = $data[0];
     } else {
         if ($postaction == "onhold") {
             $newstatus = "On Hold";
         } else {
             if ($postaction == "inprogress") {
                 $newstatus = "In Progress";
             } else {
                 $newstatus = "Answered";
             }
         }
     }
 }
 AddReply($id, "", "", $message, true, $attachments, "", $newstatus);
 run_hook("TicketStatusChange", array("adminid" => $_SESSION['adminid'], "status" => $newstatus, "ticketid" => $id));
 if ($billingdescription && $billingdescription != $aInt->lang("support", "toinvoicedes")) {
     checkPermission("Create Invoice");
     $result = select_query("tbltickets", "", array("id" => $id));
     $data = mysql_fetch_array($result);
     $userid = $data['userid'];
     $contactid = $data['contactid'];
     $invoicenow = false;
     if ($billingaction == "3") {
         $invoicenow = true;
         $billingaction = "1";
     }
     $billingamount = preg_replace("/[^0-9.]/", "", $billingamount);
     insert_query("tblbillableitems", array("userid" => $userid, "description" => $billingdescription, "amount" => $billingamount, "recur" => 0, "recurcycle" => 0, "recurfor" => 0, "invoiceaction" => $billingaction, "duedate" => "now()"));
     if ($invoicenow) {
Example #6
0
    $data = mysql_fetch_array($result);
    if (!$data['id']) {
        $apiresults = array("result" => "error", "message" => "Client ID Not Found");
        return null;
    }
    if ($contactid) {
        $result = select_query("tblcontacts", "id", array("id" => $contactid, "userid" => $clientid));
        $data = mysql_fetch_array($result);
        if (!$data['id']) {
            $apiresults = array("result" => "error", "message" => "Contact ID Not Found");
            return null;
        }
    }
} else {
    if ((!$name || !$email) && !$adminusername) {
        $apiresults = array("result" => "error", "message" => "Name and email address are required if not a client");
        return null;
    }
    $from = array("name" => $name, "email" => $email);
}
if (!$message) {
    $apiresults = array("result" => "error", "message" => "Message is required");
    return null;
}
AddReply($ticketid, $clientid, $contactid, $message, $adminusername, "", $from, $status, $noemail, true);
if ($customfields) {
    $customfields = base64_decode($customfields);
    $customfields = unserialize($customfields);
    saveCustomFields($ticketid, $customfields);
}
$apiresults = array("result" => "success");