Пример #1
0
 public function updateClient()
 {
     global $whmcs;
     $exinfo = getClientsDetails($this->getID());
     if (defined("ADMINAREA")) {
         $updatefieldsarray = array();
     } else {
         $updatefieldsarray = array("firstname" => "First Name", "lastname" => "Last Name", "companyname" => "Company Name", "email" => "Email Address", "address1" => "Address 1", "address2" => "Address 2", "city" => "City", "state" => "State", "postcode" => "Postcode", "country" => "Country", "phonenumber" => "Phone Number", "billingcid" => "Billing Contact");
         if ($whmcs->get_config("AllowClientsEmailOptOut")) {
             $updatefieldsarray['emailoptout'] = "Newsletter Email Opt Out";
         }
     }
     $changelist = array();
     $updateqry = array();
     foreach ($updatefieldsarray as $field => $displayname) {
         if ($this->isEditableField($field)) {
             $value = $whmcs->get_req_var($field);
             if ($field == "emailoptout" && !$value) {
                 $value = "0";
             }
             $updateqry[$field] = $value;
             if ($value != $exinfo[$field]) {
                 $changelist[] = "" . $displayname . ": '" . $exinfo[$field] . "' to '" . $value . "'";
                 continue;
             }
             continue;
         }
     }
     update_query("tblclients", $updateqry, array("id" => $this->getID()));
     $old_customfieldsarray = getCustomFields("client", "", $this->getID(), "", "");
     $customfields = getCustomFields("client", "", $this->getID(), "", "");
     foreach ($customfields as $v) {
         $k = $v['id'];
         $customfieldsarray[$k] = $_POST['customfield'][$k];
     }
     saveCustomFields($this->getID(), $customfieldsarray);
     $paymentmethod = $whmcs->get_req_var("paymentmethod");
     clientChangeDefaultGateway($this->getID(), $paymentmethod);
     if ($paymentmethod != $exinfo['defaultgateway']) {
         $changelist[] = "Default Payment Method: '" . getGatewayName($exinfo['defaultgateway']) . "' to '" . getGatewayName($paymentmethod) . "'<br>\n";
     }
     run_hook("ClientEdit", array_merge(array("userid" => $this->getID(), "olddata" => $exinfo), $updateqry));
     if (!defined("ADMINAREA") && $whmcs->get_config("SendEmailNotificationonUserDetailsChange")) {
         foreach ($old_customfieldsarray as $values) {
             if ($values['value'] != $_POST['customfield'][$values['id']]) {
                 $changelist[] = $values['name'] . ": '" . $values['value'] . "' to '" . $_POST['customfield'][$values['id']] . "'";
                 continue;
             }
         }
         if (0 < count($changelist)) {
             $adminurl = $whmcs->get_config("SystemSSLURL") ? $whmcs->get_config("SystemSSLURL") : $whmcs->get_config("SystemURL");
             $adminurl .= "/" . $whmcs->get_admin_folder_name() . "/clientssummary.php?userid=" . $this->getID();
             sendAdminNotification("account", "WHMCS User Details Change", "<p>Client ID: <a href=\"" . $adminurl . "\">" . $this->getID() . " - " . $exinfo['firstname'] . " " . $exinfo['lastname'] . "</a> has requested to change his/her details as indicated below:<br><br>" . implode("<br />\n", $changelist) . "<br>If you are unhappy with any of the changes, you need to login and revert them - this is the only record of the old details.</p>");
             logActivity("Client Profile Modified - " . implode(", ", $changelist) . " - User ID: " . $this->getID());
         }
     }
     return true;
 }
Пример #2
0
if ($bwlimit) {
    $updateqry['bwlimit'] = $bwlimit;
}
if ($lastupdate) {
    $updateqry['lastupdate'] = $lastupdate;
}
if ($suspendreason) {
    $updateqry['suspendreason'] = $suspendreason;
}
update_query("tblhosting", $updateqry, array("id" => $serviceid));
if ($customfields) {
    if (!is_array($customfields)) {
        $customfields = base64_decode($customfields);
        $customfields = unserialize($customfields);
    }
    saveCustomFields($serviceid, $customfields, "product");
}
if ($configoptions) {
    if (!is_array($configoptions)) {
        $configoptions = base64_decode($configoptions);
        $configoptions = unserialize($configoptions);
    }
    foreach ($configoptions as $cid => $vals) {
        if (is_array($vals)) {
            $oid = $vals['optionid'];
            $qty = $vals['qty'];
        } else {
            $oid = $vals;
            $qty = 0;
        }
        if (get_query_val("tblhostingconfigoptions", "COUNT(*)", array("relid" => $serviceid, "configid" => $cid))) {
Пример #3
0
}
$_SESSION['currency'] = $currency;
$sendemail = $noemail ? false : true;
$langatstart = $_SESSION['Language'];
if ($language) {
    $_SESSION['Language'] = $language;
}
addClient($firstname, $lastname, $companyname, $email, $address1, $address2, $city, $state, $postcode, $country, $phonenumber, $password2, $securityqid, $securityqans, $sendemail);
if ($_POST['cctype']) {
    if (!function_exists("updateCCDetails")) {
        require ROOTDIR . "/includes/ccfunctions.php";
    }
    updateCCDetails($_SESSION['uid'], $_POST['cctype'], $_POST['cardnum'], $_POST['expdate'], $_POST['startdate'], $_POST['issuenumber']);
}
$updateqry = array();
if ($groupid) {
    $updateqry['groupid'] = $groupid;
}
if ($notes) {
    $updateqry['notes'] = $notes;
}
if (count($updateqry)) {
    update_query("tblclients", $updateqry, array("id" => $_SESSION['uid']));
}
if ($customfields) {
    $customfields = base64_decode($customfields);
    $customfields = unserialize($customfields);
    saveCustomFields($_SESSION['uid'], $customfields);
}
$apiresults = array("result" => "success", "clientid" => $_SESSION['uid']);
$_SESSION['Language'] = $langatstart;
Пример #4
0
            $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']);
Пример #5
0
        $changelist = array();
        foreach ($updatefieldsarray as $field => $displayname) {
            if ($array[$field] != $oldclientsdetails[$field]) {
                $changelist[] = "" . $displayname . ": '" . $oldclientsdetails[$field] . "' to '" . $array[$field] . "'";
                continue;
            }
        }
        foreach ($updatedtickboxarray as $field => $displayname) {
            $oldfield = $oldclientsdetails[$field] ? "Enabled" : "Disabled";
            $newfield = $array[$field] ? "Enabled" : "Disabled";
            if ($oldfield != $newfield) {
                $changelist[] = "" . $displayname . ": '" . $oldfield . "' to '" . $newfield . "'";
                continue;
            }
        }
        saveCustomFields($userid, $customfieldsarray);
        clientChangeDefaultGateway($userid, $paymentmethod);
        if (!count($changelist)) {
            $changelist[] = "No Changes";
        }
        logActivity("Client Profile Modified - " . implode(", ", $changelist) . (" - User ID: " . $userid), $userid);
        run_hook("AdminClientProfileTabFieldsSave", $_REQUEST);
        run_hook("ClientEdit", array_merge(array("userid" => $userid, "olddata" => $oldclientsdetails), $array));
        redir("userid=" . $userid . "&success=true");
        exit;
    }
}
releaseSession();
ob_start();
if ($whmcs->get_req_var("emailexists")) {
    infoBox($aInt->lang("clients", "duplicateemail"), $aInt->lang("clients", "duplicateemailexp"), "error");
Пример #6
0
        continue;
    }
}
if ($_POST['password2']) {
    $updatequery .= "password='" . generateClientPW($_POST['password2']) . "',";
}
if ($_POST['securityqans']) {
    $updatequery .= "securityqans='" . encrypt($_POST['securityqans']) . "',";
}
if (isset($_POST['cardnum'])) {
    $updatequery .= "cardlastfour='" . db_escape_string(substr($_POST['cardnum'], 0 - 4)) . "',";
}
$cchash = md5($whmcs->get_hash() . $clientid);
$fieldsarray = array("cardnum", "expdate", "startdate", "issuenumber", "bankcode", "bankacct");
foreach ($fieldsarray as $fieldname) {
    if (isset($_POST[$fieldname])) {
        $updatequery .= "" . $fieldname . "=AES_ENCRYPT('" . db_escape_string($_POST[$fieldname]) . ("','" . $cchash . "'),");
        continue;
    }
}
$query = "UPDATE tblclients SET " . substr($updatequery, 0, 0 - 1) . " WHERE id=" . (int) $clientid;
$result = full_query($query);
if ($customfields) {
    $customfields = base64_decode($customfields);
    $customfields = unserialize($customfields);
    saveCustomFields($clientid, $customfields);
}
if ($paymentmethod) {
    clientChangeDefaultGateway($_POST['clientid'], $paymentmethod);
}
$apiresults = array("result" => "success", "clientid" => $_POST['clientid']);
Пример #7
0
         if (!in_array($value, array("High", "Medium", "Low"))) {
             exit;
         }
         update_query("tbltickets", array("urgency" => $value), array("id" => (int) $id));
         addTicketLog($id, "Priority changed to " . $value);
         exit;
     }
 }
 if ($sub == "savecustomfields") {
     check_token("WHMCS.admin.default");
     $customfields = getCustomFields("support", $deptid, $id, true);
     foreach ($customfields as $v) {
         $k = $v['id'];
         $customfieldsarray[$k] = $customfield[$k];
     }
     saveCustomFields($id, $customfieldsarray);
     $adminname = getAdminName();
     addTicketLog($id, "Custom Field Values Modified by " . $adminname);
 }
 AdminRead($id);
 if ($replyingadmin && $replyingadmin != $_SESSION['adminid']) {
     $result = select_query("tbladmins", "", array("id" => $replyingadmin));
     $data = mysql_fetch_array($result);
     $replyingadmin = ucfirst($data['username']);
     $smartyvalues['replyingadmin'] = array("name" => $replyingadmin, "time" => $replyingtime);
 }
 $clientname = $contactname = $clientgroupcolour = "";
 if ($pauserid) {
     $clientname = strip_tags($aInt->outputClientLink($pauserid));
 }
 if ($pacontactid) {
Пример #8
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");
Пример #9
0
function addClient($firstname, $lastname, $companyname, $email, $address1, $address2, $city, $state, $postcode, $country, $phonenumber, $password, $securityqid = "", $securityqans = "", $sendemail = "on", $additionaldata = "")
{
    global $whmcs;
    global $remote_ip;
    if (!$country) {
        $country = $whmcs->get_config("DefaultCountry");
    }
    $fullhost = gethostbyaddr($remote_ip);
    $currency = is_array($_SESSION['currency']) ? $_SESSION['currency'] : getCurrency("", $_SESSION['currency']);
    $password_hash = generateClientPW($password);
    $table = "tblclients";
    $array = array("firstname" => $firstname, "lastname" => $lastname, "companyname" => $companyname, "email" => $email, "address1" => $address1, "address2" => $address2, "city" => $city, "state" => $state, "postcode" => $postcode, "country" => $country, "phonenumber" => $phonenumber, "password" => $password_hash, "lastlogin" => "now()", "securityqid" => $securityqid, "securityqans" => encrypt($securityqans), "ip" => $remote_ip, "host" => $fullhost, "status" => "Active", "datecreated" => "now()", "language" => $_SESSION['Language'], "currency" => $currency['id']);
    $uid = insert_query($table, $array);
    logActivity("Created Client " . $firstname . " " . $lastname . " - User ID: " . $uid);
    if ($additionaldata) {
        update_query("tblclients", $additionaldata, array("id" => $uid));
    }
    if (!function_exists("saveCustomFields")) {
        require ROOTDIR . "/includes/customfieldfunctions.php";
    }
    saveCustomFields($uid, $_POST['customfield'], "client");
    if ($sendemail) {
        sendMessage("Client Signup Email", $uid, array("client_password" => $password));
    }
    $_SESSION['uid'] = $uid;
    $haship = $whmcs->get_config("DisableSessionIPCheck") ? "" : $whmcs->get_user_ip();
    $_SESSION['upw'] = sha1($uid . $password_hash . $haship . substr(sha1($whmcs->get_hash()), 0, 20));
    $_SESSION['tkval'] = genRandomVal();
    run_hook("ClientAdd", array("userid" => $uid, "firstname" => $firstname, "lastname" => $lastname, "companyname" => $companyname, "email" => $email, "address1" => $address1, "address2" => $address2, "city" => $city, "state" => $state, "postcode" => $postcode, "country" => $country, "phonenumber" => $phonenumber, "password" => $password));
    run_hook("ClientLogin", array("userid" => $uid));
    return $uid;
}
Пример #10
0
            $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);
Пример #11
0
function migrateCustomFieldsBetweenProducts($serviceid, $newpid, $save = false)
{
    $customfieldsarray = array();
    $result = select_query("tblhosting", "packageid", array("id" => $serviceid));
    $data = mysql_fetch_array($result);
    $existingpid = $data[0];
    if ($save) {
        $customfields = getCustomFields("product", $existingpid, $serviceid, true);
        foreach ($customfields as $v) {
            $k = $v['id'];
            $customfieldsarray[$k] = $_POST['customfield'][$k];
        }
        saveCustomFields($serviceid, $customfieldsarray);
    }
    if ($existingpid != $newpid) {
        $customfields = getCustomFields("product", $existingpid, $serviceid, true);
        foreach ($customfields as $v) {
            $cfid = $v['id'];
            $cfname = $v['name'];
            $cfval = $v['rawvalue'];
            $customfieldsarray[$cfname] = $cfval;
            delete_query("tblcustomfieldsvalues", array("fieldid" => $cfid, "relid" => $serviceid));
        }
        $customfields = getCustomFields("product", $newpid, "", true);
        foreach ($customfields as $v) {
            $cfid = $v['id'];
            $cfname = $v['name'];
            if ($customfieldsarray[$cfname]) {
                insert_query("tblcustomfieldsvalues", array("fieldid" => $cfid, "relid" => $serviceid, "value" => $customfieldsarray[$cfname]));
                continue;
            }
        }
    }
}