Пример #1
0
 function log($msg)
 {
     if (is_array($msg)) {
         $msg = print_r($msg, true);
     }
     logActivity($msg);
 }
function stop_users_vms()
{
    logActivity("Starting to stop vms for users.");
    //Find all users whos credit is low
    $table = "tblclients";
    $fields = "*";
    $result = select_query($table, $fields);
    if ($result) {
        while ($data = mysql_fetch_array($result)) {
            $userid = $data['id'];
            $balanceLimit = get_balance_limit($userid);
            if (!$balanceLimit || !is_numeric($balanceLimit)) {
                $balanceLimit = 0;
            }
            logActivity("Balance limit for user " . $userid . ": " . $balanceLimit);
            if (getCreditForUserId($userid) + $balanceLimit < 0) {
                logActivity("Stopping vms for user: "******"Stopped vms for user: "******". Result:" . $res);
                } else {
                    logActivity("Stoping vms failed for user: "******"Stopping vms for users ended.");
}
Пример #3
0
/**
 *
 * @ WHMCS FULL DECODED & NULLED
 *
 * @ Version  : 5.2.15
 * @ Author   : MTIMER
 * @ Release on : 2013-12-24
 * @ Website  : http://www.mtimer.cn
 *
 **/
function doUnsubscribe($email, $key)
{
    global $whmcs;
    global $_LANG;
    $whmcs->get_hash();
    if (!$email) {
        return $_LANG['pwresetemailrequired'];
    }
    $result = select_query("tblclients", "id,email,emailoptout", array("email" => $email));
    $data = mysql_fetch_array($result);
    $userid = $data['id'];
    $email = $data['email'];
    $emailoptout = $data['emailoptout'];
    $newkey = sha1($email . $userid . $cc_encryption_hash);
    if ($newkey == $key) {
        if (!$userid) {
            return $_LANG['unsubscribehashinvalid'];
        }
        if ($emailoptout == 1) {
            return $_LANG['alreadyunsubscribed'];
        }
        update_query("tblclients", array("emailoptout" => "1"), array("id" => $userid));
        sendMessage("Unsubscribe Confirmation", $userid);
        logActivity("Unsubscribed From Marketing Emails - User ID:" . $userid, $userid);
        return null;
    }
    return $_LANG['unsubscribehashinvalid'];
}
Пример #4
0
function getActiveFraudModule()
{
    global $CONFIG;
    $result = select_query("tblfraud", "fraud", array("setting" => "Enable", "value" => "on"));
    $data = mysql_fetch_array($result);
    $fraud = $data['fraud'];
    $orderid = $_SESSION['orderdetails']['OrderID'];
    if ($CONFIG['SkipFraudForExisting']) {
        $result = select_query("tblorders", "COUNT(*)", array("status" => "Active", "userid" => $_SESSION['uid']));
        $data = mysql_fetch_array($result);
        if ($data[0]) {
            $fraudmodule = "";
            logActivity("Order ID " . $orderid . " Skipped Fraud Check due to Already Active Orders");
        }
    }
    $hookresponses = run_hook("RunFraudCheck", array("orderid" => $orderid, "userid" => $_SESSION['uid']));
    foreach ($hookresponses as $hookresponse) {
        if ($hookresponse) {
            $fraud = "";
            logActivity("Order ID " . $orderid . " Skipped Fraud Check due to Custom Hook");
            continue;
        }
    }
    return $fraud;
}
function modify_oms_passwd($vars)
{
    $userid = $vars['userid'];
    $password = $vars['password'];
    $command = '/bin/passwd?arg=-u&arg=' . $userid . '&arg=' . $password;
    $result = oms_command($command);
    logActivity('Modified password of the OMS user ' . $username . ', result: ' . $result);
}
Пример #6
0
 public function createOrder($userid, $paymentmethod, $contactid = "")
 {
     global $whmcs;
     $order_number = generateUniqueID();
     $this->orderid = insert_query("tblorders", array("ordernum" => $order_number, "userid" => $userid, "contactid" => $contactid, "date" => "now()", "status" => "Pending", "paymentmethod" => $paymentmethod, "ipaddress" => $whmcs->get_user_ip()));
     logActivity("New Order Created - Order ID: " . $orderid . " - User ID: " . $userid);
     return $this->orderid;
 }
Пример #7
0
 public function process()
 {
     $event = Events::getById($this->getElementValue('id'));
     Events::setSignupStatus($this->user->getId(), $event['id'], 'SIGNEDUP');
     Events::appendSignupComment($this->user->getId(), $event['id'], 'Forced signup.', Session::getUser()->getUsername());
     logActivity('Forced signup of:' . $this->getElementValue('username') . ' to event: ' . $event['id'] . ' (' . $event['name'] . ')');
     redirect('viewEvent.php?id=' . $event['id'], 'They have been signed up.');
 }
 public function process()
 {
     $eventId = $this->getElementValue('event');
     $userId = $this->userId;
     $seatId = $this->getElementValue('seat');
     setSeatForUser($eventId, $userId, $seatId);
     logActivity('Moved user ' . $this->getElementValue('username') . ' to seat ' . $seatId);
 }
/**
 * Smarty {oms_bundle_products} function plugin
 *
 * Type:     function<br>
 * Name:     oms_bundle_products<br>
 * Date:     April 12, 2013<br>
 * Purpose:  Provides OMS bundles with product items sum and with product items names if not defined manually.
 * @version  1.0
 * @param array
 * @param Smarty
 * @return Integer logged in user credit amount
 */
function smarty_function_oms_bundle_products($params, &$smarty)
{
    $bundleId = empty($params['bundleId']) ? null : $params['bundleId'];
    $groupId = empty($params['groupId']) ? null : $params['groupId'];
    $smarty->assign('productSum', 0);
    if ($bundleId && $bundleId) {
        //Query for bundles
        $table = "tblbundles";
        $fields = "*";
        $where = array("gid" => $groupId, "id" => $bundleId);
        $sort = "id";
        $sortorder = "ASC";
        $result = select_query($table, $fields, $where, $sort, $sortorder);
        if ($result) {
            $productIds = array();
            while ($data = mysql_fetch_array($result)) {
                $itemdata = $data['itemdata'];
                //find product ids from string
                $ptn = "*\"pid\";[a-z]:[0-9]+:\"[0-9]+\"*";
                preg_match_all($ptn, $itemdata, $matches);
                foreach ($matches[0] as $match) {
                    $ptnNr = "/[0-9]+\$/";
                    $str = str_replace("\"", "", $match);
                    preg_match($ptnNr, $str, $matchNr);
                    if ($matchNr) {
                        $productIds[$matchNr[0]]++;
                    } else {
                        logActivity("Error parsing itemdata to get product id.");
                    }
                }
            }
            $productsNames = array();
            $sum = 0;
            foreach ($productIds as $id => $count) {
                //print_r("Product with id:".$id.", count:".$count);
                //Query for products
                $sql = "SELECT DISTINCT * FROM tblproducts product JOIN tblpricing price ON product.id = price.relid WHERE price.type='product' AND product.id = '" . $id . "'";
                $query = mysql_query($sql);
                $product = mysql_fetch_array($query);
                if ($product) {
                    $sum += $product['monthly'] * $count;
                    $productsNames[] = ($count > 1 ? $count . " x " : '') . $product['name'];
                } else {
                    logActivity("Error getting product");
                }
            }
            $smarty->assign('productSum', $sum);
            $smarty->assign('productNames', $productsNames);
            //print_r("<PRE>");
            //print_r($productIds);
            //print_r("</PRE>");
        } else {
            logActivity("Error getting bundles products");
        }
    }
}
Пример #10
0
 public function process()
 {
     global $db;
     $sql = 'INSERT INTO events (name, date, duration, venue) VALUES (:title, :start, :duration, :venue)';
     $stmt = $db->prepare($sql);
     $stmt->bindValue(':title', $this->getElementValue('title'));
     $stmt->bindValue(':start', $this->getElementValue('start'));
     $stmt->bindValue(':duration', $this->getElementValue('duration'));
     $stmt->bindValue(':venue', $this->getElementValue('venue'));
     $stmt->execute();
     logActivity('Event created: ' . $db->lastInsertId() . ' / ' . $this->getElementValue('title'));
 }
Пример #11
0
 public function processNew()
 {
     global $db;
     $sql = 'INSERT INTO page_content (page, content, updatedBy) VALUES (:title, :content, :userId) ';
     $stmt = $db->prepare($sql);
     $stmt->bindValue(':title', $this->getElementValue('title'));
     $stmt->bindValue(':content', $this->getElementValue('content'));
     $stmt->bindValue(':userId', Session::getUser()->getId());
     $stmt->execute();
     logActivity('Content created: ' . $this->getElementValue('title'));
     return true;
 }
Пример #12
0
function slack_post($text)
{
    $json = file_get_contents(dirname(__FILE__) . "/slack.json");
    $config = json_decode($json, true);
    $url = $config['hook_url'];
    $payload = array("text" => $text, "username" => $config["username"], "icon_emoji" => $config["emoji"], "channel" => $config["channel"]);
    $data = "payload=" . json_encode($payload);
    logActivity("Send slack notification:" . $text);
    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $result = curl_exec($ch);
}
function setUserInSeat($eventId, $seatId, $userId = null)
{
    if (empty($userId)) {
        $userId = Session::getUser()->getId();
    }
    logActivity('_u_' . ' selected seat ' . $seatId . ' for event _e_', null, array('user' => $userId, 'event' => $eventId));
    $sql = 'INSERT INTO seatingplan_seat_selections (seat, event, user) VALUES (:seat, :event, :user1) ON DUPLICATE KEY UPDATE user = :user2';
    $stmt = DatabaseFactory::getInstance()->prepare($sql);
    $stmt->bindValue(':seat', $seatId);
    $stmt->bindValue(':event', $eventId);
    $stmt->bindValue(':user1', $userId);
    $stmt->bindValue(':user2', $userId);
    $stmt->execute();
}
Пример #14
0
/**
 * Add information about the system's load average to the template
 *
 * @param array $params The current template variables to display
 * @return array key value pairs of variables to add to the template
 */
function populateLoadAverageInProductDetailsPage($params)
{
    $serviceId = $params['serviceid'];
    // See http://docs.whmcs.com/classes/classes/WHMCS.Service.Service.html for details on this model
    /** @var Service $service */
    try {
        $service = Service::findOrFail($serviceId);
    } catch (Exception $e) {
        logActivity('Exception caught when trying to load the Service Model:' . $e->getMessage());
        return null;
    }
    $loadAverage = getLoadAverageFromService($service);
    // Simple conversion from SimpleXMLElement to array
    return array('loadAverage' => (array) $loadAverage);
}
Пример #15
0
/**
 *
 * @ WHMCS FULL DECODED & NULLED
 *
 * @ Version  : 5.2.15
 * @ Author   : MTIMER
 * @ Release on : 2013-12-24
 * @ Website  : http://www.mtimer.cn
 *
 **/
function affiliateActivate($userid)
{
    global $CONFIG;
    $result = select_query("tblclients", "currency", array("id" => $userid));
    $data = mysql_fetch_array($result);
    $clientcurrency = $data['currency'];
    $bonusdeposit = convertCurrency($CONFIG['AffiliateBonusDeposit'], 1, $clientcurrency);
    $result = select_query("tblaffiliates", "id", array("clientid" => $userid));
    $data = mysql_fetch_array($result);
    $affiliateid = $data['id'];
    if (!$affiliateid) {
        $affiliateid = insert_query("tblaffiliates", array("date" => "now()", "clientid" => $userid, "balance" => $bonusdeposit));
    }
    logActivity("Activated Affiliate Account - Affiliate ID: " . $affiliateid . " - User ID: " . $userid, $userid);
    run_hook("AffiliateActivation", array("affid" => $affiliateid, "userid" => $userid));
}
Пример #16
0
/**
 * Updates a customer at Acumulus
 * @param $vars : $vars from the hook for API credentials
 * @param $clientid : clientid to update
 * @param null $customerid : customerid at Acumulus to update
 * @throws Exception
 * @return $customerid : new/updated customerid at Acumulus
 */
function updateCustomer($vars, $clientid, $customerid = null)
{
    global $whmcs;
    $whmcs->load_function('invoice');
    $clientQuery = mysql_query('SELECT tblclients.*, tblcustomfieldsvalues.value AS vatnumber FROM tblclients LEFT JOIN tblcustomfieldsvalues ON tblclients.id = tblcustomfieldsvalues.relid AND tblcustomfieldsvalues.fieldid = (SELECT id FROM tblcustomfields WHERE type = "client" AND fieldname = "' . $vars['vat_field'] . '" LIMIT 1) WHERE tblclients.id = ' . $clientid . ' LIMIT 1');
    if (mysql_num_rows($clientQuery) != 1) {
        throw new Exception('Failed to receive client ' . $clientid);
    }
    $clientFetch = mysql_fetch_assoc($clientQuery);
    $api = new api($vars['code'], $vars['username'], $vars['password']);
    $api->setCategory('contacts')->setAction('contact_manage');
    if (isset($vars['debug']) && $vars['debug'] == 'on') {
        $api->enableDebug($vars['debug_email']);
    }
    if ($clientFetch['acumulusid'] != null) {
        $api->setParam('contact/contactid', $clientFetch['acumulusid']);
    }
    if ($customerid != null) {
        $api->setParam('contact/contactid', $customerid);
    }
    if ($clientFetch['country'] == 'NL') {
        $api->setParam('contact/contactlocationcode', 1);
    } elseif (inEurope($clientFetch['country'])) {
        $api->setParam('contact/contactlocationcode', 2);
    } else {
        $api->setParam('contact/contactlocationcode', 3);
    }
    $taxData = getTaxRate(1, $clientQuery['state'], $clientQuery['country']);
    $api->setParams(array('contact' => array('contactemail' => $clientFetch['email'], 'contacttype' => 1, 'overwriteifexists' => 1, 'contactname1' => ucfirst($clientFetch['firstname']) . ' ' . $clientFetch['lastname'], 'contactname2' => '', 'contactperson' => '', 'contactsalutation' => '', 'contactaddress1' => $clientFetch['address1'], 'contactaddress2' => $clientFetch['address2'], 'contactpostalcode' => $clientFetch['postcode'], 'contactcity' => $clientFetch['city'], 'contactcountrycode' => inEurope($clientFetch['country']) ? $clientFetch['country'] : '', 'contactvatnumber' => $clientFetch['vatnumber'], 'contactvatratebase' => $clientFetch['taxexempt'] == 'on' ? -1 : round($taxData['rate']), 'contacttelephone' => $clientFetch['phonenumber'], 'contactfax' => '', 'contactsepaincassostatus' => 'FRST', 'contactinvoicetemplateid' => '', 'contactstatus' => 1)));
    if (!empty($clientFetch['companyname'])) {
        $api->setParams(array('contact' => array('contactname1' => $clientFetch['companyname'], 'contactperson' => ucfirst($clientFetch['firstname']) . ' ' . $clientFetch['lastname'])));
    }
    $api->execute();
    $response = $api->getResponse();
    if ($api->hasErrors()) {
        $errors = '';
        foreach ($api->getErrors() as $error) {
            $errors = $error['code'] . ' - ' . $error['message'] . ', ';
        }
        logActivity('Acumulus API error(s): ' . substr($errors, 0, -2));
        return false;
    } else {
        mysql_query('UPDATE tblclients SET acumulusid = ' . $response['contact']['contactid'] . ' WHERE id = ' . $clientid . ' LIMIT 1');
        return $response['contact']['contactid'];
    }
}
function add_oms_user_promotion($vars)
{
    global $whmcs_admin_user;
    // Get promo code (this is just very wrong on all levels)
    $sql = "SELECT id FROM tblcustomfields WHERE fieldname='promotion'";
    $result = mysql_query($sql);
    if (!$result) {
        logActivity("Error: failed to retrieve promotion field index from database (user ID: {$vars['userid']}), MySQL error: " . mysql_error());
        return;
    }
    $resultArr = mysql_fetch_assoc($result);
    $promotionFieldIndex = (int) $resultArr['id'];
    $promoCode = $_POST['customfield'][$promotionFieldIndex];
    if (!$promoCode) {
        logActivity("No promo code provided (user ID: {$vars['userid']}, promotion field ID: {$promotionFieldIndex})...");
        return;
    }
    // Get promotion
    $values = array('code' => $promoCode);
    $result = localAPI("getpromotions", $values, $whmcs_admin_user);
    if ($result['result'] != "success") {
        logActivity("Failed to retrieve promotions (user ID: {$vars['userid']}), API call result: " . print_r($result, true));
        return;
    }
    if ($result['totalresults'] < 1) {
        logActivity("No promotions found (user ID: {$vars['userid']})");
        return;
    }
    $promotion = $result['promotions']['promotion'][0];
    // TODO: What if multiple promotions are found for one code?
    if (!$promotion) {
        logActivity("API error: promotion count > 1 reported but no promotions returned (user ID: {$vars['userid']})");
        return;
    }
    logActivity("Promotion found (user ID: {$vars['userid']}, promo code: {$promoCode})");
    // TODO: check $promotion['uses'] < $promotion['maxuses']
    // TODO: check time() < strtotime($promotion['expirationdate'])
    // Add credit to client
    $values = array('amount' => $promotion['value'], 'clientid' => $vars['userid'], 'description' => "Promotion code: {$promoCode}");
    $result = localAPI("addcredit", $values, $whmcs_admin_user);
    if ($result['result'] != "success") {
        logActivity("Failed to add credit from promotion (user ID: {$vars['userid']}, promo code: {$promoCode}), API call result: " . print_r($result, true));
        return;
    }
}
Пример #18
0
function cpanelextender_addFtpAccount($serviceId, $ftpUsername, $ftpPassword)
{
    try {
        $service = Service::findOrFail($serviceId);
    } catch (Exception $e) {
        logActivity('Exception caught when trying to load the Service Model:' . $e->getMessage());
        return json_encode(array('message' => 'Unable to load service model for: ' . $serviceId, 'success' => 0));
    }
    $cPServer = cpanelextender_getCpanelAPIFromService($service);
    $cPServer->set_output('json');
    $args = array('user' => $ftpUsername, 'pass' => $ftpPassword);
    $result = $cPServer->api2_query($service->username, 'Ftp', 'addftp', $args);
    $result = json_decode($result, true);
    $result = $result['cpanelresult'];
    if (array_key_exists('error', $result)) {
        $result['return']['reason'] = $result['error'];
    }
    $result['return']['result'] = $result['data'][0]['result'];
    return json_encode($result['return']);
}
Пример #19
0
/**
 * @link http://docs.whmcs.com/Hooks:ClientEdit
 * @param array $vars
 */
function hook_coza_client_update($vars)
{
    $params = getRegistrarConfigOptions('coza');
    $contact = getClientsDetails($vars['userid'], 0);
    $epp_client = \COZA\Factory::build($params);
    try {
        $epp_client->connect();
        try {
            \COZA\Factory::updateContactIfExists($epp_client, \COZA\Factory::getContactHandle($params, (int) $vars['userid']), $contact);
        } catch (Exception $e) {
            unset($epp_client);
            logActivity($e->getMessage(), $vars['userid']);
            return;
        }
        unset($epp_client);
        return;
    } catch (Exception $e) {
        unset($epp_client);
        logActivity('COZA/ContactUpdate: ' . $e->getMessage(), $vars['userid']);
        return;
    }
}
Пример #20
0
 /**
  * Function that gets OMC VM data to display on template
  */
 public static function addOmsUsageClientAreaPage($vars)
 {
     global $oms_usage_db, $product_core_name, $product_disk_name, $product_memory_name;
     $userId = $_SESSION['uid'];
     if (!is_numeric($userId)) {
         return array();
     }
     //Get products prices
     $hours_per_month = 720;
     $p_core = getProductPriceByName($product_core_name) / $hours_per_month;
     $p_disk = getProductPriceByName($product_disk_name) / $hours_per_month;
     $p_memory = getProductPriceByName($product_memory_name) / $hours_per_month;
     //logActivity("Using product prices for calculations: Cores:" . $p_core . ". Disk:" . $p_disk . ".Memory:" . $p_memory);
     if (!$p_core || !$p_disk || !$p_memory) {
         logActivity("Error: Product prices not set.");
         return;
     }
     $username = $userId;
     // XXX a temporary solution due to the removal of usernames
     $balance_limit = get_balance_limit($userId);
     $table = $oms_usage_db . ".CONF_CHANGES";
     $sql = "select * from " . $table . " WHERE username='******' ORDER BY timestamp DESC LIMIT 1";
     $result = mysql_query($sql);
     if ($result) {
         $data = mysql_fetch_array($result);
         if ($data) {
             $id = $data['id'];
             $mbsInGb = 1024;
             $data['disk'] = $data['disk'] / $mbsInGb;
             $amount = $data['cores'] * $p_core + $data['disk'] * $p_disk + $data['memory'] * $p_memory;
             $data['vm_cost'] = \Opennode\Whmcs\Service\OmsReductionService::applyTax($userId, $amount);
         }
     }
     $data['currentcredit'] = getCreditForUserId($userId) + $balance_limit;
     return array('omsdata' => $data);
 }
/**
Open Ticket on ordering selected products for WHMCS
Version 1.0 by TinyTunnel_Tom (ThomasGlassUK.com)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
**/
function productOpenTicket($vars)
{
    //Configuration
    $products = array('1', '3');
    //Array of product IDs for this hook
    $adminuser = '******';
    //Set admin user to preform action (required for internal WHMCS API)
    $departmentid = '1';
    //Set support department to open ticket
    $subject = "Ticket Subject";
    //Subject for ticket
    $message = "Ticket Message";
    //Message in ticket
    $priority = "LOW";
    //Priority for ticket
    //The rest is magic
    $orderid = $vars['orderid'];
    //Get OrderID from WHMCS
    $result = select_query('tblhosting', '', array("orderid" => $orderid));
    //Find the product from the order
    $data = mysql_fetch_assoc($result);
    foreach ($products as $pid) {
        if ($data['packageid'] == $pid) {
            $command = "openticket";
            //WHMCS Internal API command
            $values = array('clientid' => $data['userid'], 'deptid' => $departmentid, 'subject' => $subject, 'message' => $message, 'priority' => $priority, 'admin' => '1');
            //WHMCS Internal API values
            $results = localAPI($command, $values, $adminuser);
            //Run command to open ticket
            if ($results['result'] != "success") {
                logActivity('An Error Occurred: ' . $results['message']);
                //Something went wrong check WHMCS logs
            }
        }
    }
}
Пример #22
0
function deleteTicket($ticketid, $replyid = "")
{
    global $attachments_dir;
    $where = array("tid" => $ticketid);
    if ($replyid) {
        $where = array("id" => $replyid);
    }
    $result = select_query("tblticketreplies", "", $where);
    while ($data = mysql_fetch_array($result)) {
        $attachment = $data['attachment'];
        if ($attachment) {
            $attachment = explode("|", $attachment);
            foreach ($attachment as $file) {
                deleteFile($attachments_dir, $file);
            }
        }
    }
    if (!$replyid) {
        $result = select_query("tbltickets", "", array("id" => $ticketid));
        $data = mysql_fetch_array($result);
        $attachment = $data['attachment'];
        if ($attachment) {
            $attachment = explode("|", $attachment);
            foreach ($attachment as $file) {
                deleteFile($attachments_dir, $file);
            }
        }
        delete_query("tblticketreplies", array("tid" => $ticketid));
        delete_query("tbltickets", array("id" => $ticketid));
        logActivity("Deleted Ticket - Ticket ID: " . $ticketid);
        return null;
    }
    delete_query("tblticketreplies", array("id" => $replyid));
    addTicketLog($ticketid, "Deleted Ticket Reply (ID: " . $replyid . ")");
    logActivity("Deleted Ticket Reply - ID: " . $replyid);
}
Пример #23
0
        $var_langDesc = "";
        $var_id = "";
        $var_message = MESSAGE_RECORD_DELETED;
        $flag_msg = 'class="msg_success"';
    } else {
        $var_message = MESSAGE_RECORD_ERROR;
        $flag_msg = 'class="msg_error"';
    }
} elseif ($_POST["postback"] == "U") {
    $var_langCode = trim($_POST["txtLangCode"]);
    $var_langDesc = trim($_POST["txtLangDesc"]);
    if (validateUpdation($var_langCode, $var_langDesc) == true and $var_langCode != "en") {
        $sql = "Update sptbl_lang set    vLangDesc='" . mysql_real_escape_string($var_langDesc) . "'  where vLangCode='" . mysql_real_escape_string($var_id) . "'";
        executeQuery($sql, $conn);
        //Insert the actionlog
        if (logActivity()) {
            $sql = "Insert into sptbl_actionlog(nALId,nStaffId,vAction,vArea,nRespId,dDate) Values('','{$var_staffid}','" . TEXT_UPDATION . "','Language','" . mysql_real_escape_string($var_id) . "',now())";
            executeQuery($sql, $conn);
        }
        $var_message = MESSAGE_RECORD_UPDATED;
        $flag_msg = 'class="msg_success"';
    } else {
        $var_message = MESSAGE_RECORD_ERROR;
        $flag_msg = 'class="msg_error"';
    }
}
function validateAddition($var_langCode, $var_langDesc)
{
    global $conn;
    $returnFlag = "";
    if (trim($_POST["txtLangCode"]) == "" || trim($_POST["txtLangDesc"]) == "") {
Пример #24
0
    check_token("WHMCS.admin.default");
    checkPermission("Delete Clients Products/Services");
    run_hook("ServiceDelete", array("userid" => $userid, "serviceid" => $id));
    delete_query("tblhosting", array("id" => $id));
    delete_query("tblhostingaddons", array("hostingid" => $id));
    delete_query("tblhostingconfigoptions", array("relid" => $id));
    full_query("DELETE FROM tblcustomfieldsvalues WHERE relid='" . db_escape_string($id) . "' AND fieldid IN (SELECT id FROM tblcustomfields WHERE type='product')");
    logActivity("Deleted Product/Service - User ID: " . $userid . " - Service ID: " . $id, $userid);
    redir("userid=" . $userid);
}
if ($action == "deladdon") {
    check_token("WHMCS.admin.default");
    checkPermission("Delete Clients Products/Services");
    run_hook("AddonDeleted", array("id" => $aid));
    delete_query("tblhostingaddons", array("id" => $aid));
    logActivity("Deleted Addon - User ID: " . $userid . " - Service ID: " . $id . " - Addon ID: " . $aid, $userid);
    redir("userid=" . $userid . "&id=" . $id);
}
ob_start();
$adminbuttonarray = "";
if ($module) {
    if (!isValidforPath($module)) {
        exit("Invalid Server Module Name");
    }
    $modulepath = ROOTDIR . "/modules/servers/" . $module . "/" . $module . ".php";
    if (file_exists($modulepath)) {
        require_once $modulepath;
    }
    if (function_exists($module . "_AdminCustomButtonArray")) {
        $adminbuttonarray = call_user_func($module . "_AdminCustomButtonArray");
    }
Пример #25
0
function disableAutoRenew($domainid)
{
    update_query("tbldomains", array("donotrenew" => "on"), array("id" => $domainid));
    $domainname = get_query_val("tbldomains", "domain", array("id" => $domainid));
    if ($_SESSION['adminid']) {
        logActivity("Admin Disabled Domain Auto Renew - Domain ID: " . $domainid . " - Domain: " . $domainname);
    } else {
        logActivity("Client Disabled Domain Auto Renew - Domain ID: " . $domainid . " - Domain: " . $domainname);
    }
    $result = select_query("tblinvoiceitems", "tblinvoiceitems.id,tblinvoiceitems.invoiceid", array("type" => "Domain", "relid" => $domainid, "status" => "Unpaid", "tblinvoices.userid" => $_SESSION['uid']), "", "", "", "tblinvoices ON tblinvoices.id=tblinvoiceitems.invoiceid");
    while ($data = mysql_fetch_array($result)) {
        $itemid = $data['id'];
        $invoiceid = $data['invoiceid'];
        $result2 = select_query("tblinvoiceitems", "COUNT(*)", array("invoiceid" => $invoiceid));
        $data = mysql_fetch_array($result2);
        $itemcount = $data[0];
        $otheritemcount = 0;
        if (1 < $itemcount) {
            $otheritemcount = get_query_val("tblinvoiceitems", "COUNT(*)", "invoiceid=" . (int) $invoiceid . (" AND id!=" . $itemid . " AND type NOT IN ('PromoHosting','PromoDomain','GroupDiscount')"));
        }
        if ($itemcount == 1 || $otheritemcount == 0) {
            update_query("tblinvoices", array("status" => "Cancelled"), array("id" => $invoiceid));
            logActivity("Cancelled Previous Domain Renewal Invoice - Invoice ID: " . $invoiceid . " - Domain: " . $domainname);
            run_hook("InvoiceCancelled", array("invoiceid" => $invoiceid));
        }
        delete_query("tblinvoiceitems", array("id" => $itemid));
        updateInvoiceTotal($invoiceid);
        logActivity("Removed Previous Domain Renewal Line Item - Invoice ID: " . $invoiceid . " - Domain: " . $domainname);
    }
}
Пример #26
0
<?php

require_once 'includes/common.php';
require_once 'includes/classes/FormRegistration.php';
$f = new FormRegistration();
if ($f->validate()) {
    $f->process();
    logActivity('User registered: ' . $f->getElementValue('username'), -1);
    redirect('login.php', 'Your account has been created.');
}
require_once 'includes/widgets/header.php';
require_once 'includes/widgets/sidebar.php';
$tpl->assignForm($f);
$tpl->display('form.tpl');
require_once 'includes/widgets/footer.php';
Пример #27
0
 public function failedLogin()
 {
     global $whmcs;
     $remote_ip = $whmcs->get_user_ip();
     if ($this->isWhitelistedIP($remote_ip)) {
         return false;
     }
     $loginfailures = unserialize($whmcs->get_config("LoginFailures"));
     if (!is_array($loginfailures[$remote_ip])) {
         $loginfailures[$remote_ip] = array();
     }
     if ($loginfailures[$remote_ip]['expires'] < time()) {
         $loginfailures[$remote_ip]['count'] = 0;
     }
     ++$loginfailures[$remote_ip]['count'];
     $loginfailures[$remote_ip]['expires'] = time() + 30 * 60;
     if (3 <= $loginfailures[$remote_ip]['count']) {
         unset($loginfailures[$remote_ip]);
         insert_query("tblbannedips", array("ip" => $remote_ip, "reason" => "3 Invalid Login Attempts", "expires" => $this->getLoginBanDate()));
     }
     $whmcs->set_config("LoginFailures", serialize($loginfailures));
     if (isset($this->admindata['username'])) {
         $username = $this->admindata['username'];
         sendAdminNotification("system", "WHMCS Admin Failed Login Attempt", "<p>A recent login attempt failed.  Details of the attempt are below.</p><p>Date/Time: " . date("d/m/Y H:i:s") . ("<br>Username: "******"<br>IP Address: " . $remote_ip . "<br>Hostname: ") . gethostbyaddr($remote_ip) . "</p>");
         logActivity("Failed Admin Login Attempt - Username: "******"system", "WHMCS Admin Failed Login Attempt", "<p>A recent login attempt failed.  Details of the attempt are below.</p><p>Date/Time: " . date("d/m/Y H:i:s") . "<br>Username: "******"<br>IP Address: " . $remote_ip . "<br>Hostname: ") . gethostbyaddr($remote_ip) . "</p>");
     logActivity("Failed Admin Login Attempt - IP: " . $remote_ip);
 }
Пример #28
0
}
if ($_REQUEST['stripecx'] == 'Install') {
    // Install required database table
    $pdo = Capsule::connection()->getPdo();
    $pdo->beginTransaction();
    try {
        $query = "CREATE TABLE IF NOT EXISTS `stripecx_transactions` (\n\t\t\t`id` int(5) NOT NULL AUTO_INCREMENT,\n\t\t\t`invoice_id` int(32) NOT NULL,\n\t\t\t`transaction_id` varchar(512) NOT NULL,\n\t\t\tPRIMARY KEY (`id`),\n\t\t\tUNIQUE KEY `id` (`id`)\n\t\t) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;";
        $statement = $pdo->prepare($query);
        $statement->execute();
        // COMMIT QUERYS
        $pdo->commit();
    } catch (\Exception $e) {
        $pdo->rollBack();
        logActivity('Error during GateCX activation: ' . $e->getMessage());
    }
}
if ($_REQUEST['stripecx'] == 'Uninstall') {
    // Remove required database table
    $pdo = Capsule::connection()->getPdo();
    $pdo->beginTransaction();
    try {
        $query = "DROP TABLE IF EXISTS `stripecx_transactions`;";
        $statement = $pdo->prepare($query);
        $statement->execute();
        // COMMIT QUERYS
        $pdo->commit();
    } catch (\Exception $e) {
        $pdo->rollBack();
        logActivity('Error during GateCX deactivation: ' . $e->getMessage());
    }
}
Пример #29
0
function changeStatus($id, $newstat)
{
    global $conn;
    global $var_staffid;
    $sql = "UPDATE sptbl_kb SET vStatus = '{$newstat}'  where nKBID= {$id} ";
    //echo "<br>".$sql ."<br>";
    executeQuery($sql, $conn);
    //Insert the actionlog
    if (logActivity()) {
        $sql = "Insert into sptbl_actionlog(nALId,nStaffId,vAction,vArea,nRespId,dDate) Values('','{$var_staffid}','" . TEXT_STATUS_CHANGE . "','Knowledgebase','" . mysql_real_escape_string($id) . "',now())";
        executeQuery($sql, $conn);
    }
}
Пример #30
0
}
if ($action == "adddownloadcat") {
    check_token("WHMCS.admin.default");
    if (!checkPermission("Edit Products/Services", true)) {
        exit("Access Denied");
    }
    $categorieslist = "";
    buildCategoriesList(0, 0);
    echo "<form method=\"post\" action=\"configproducts.php?action=createdownloadcat&id=" . $id . "\" id=\"adddownloadcatfrm\" enctype=\"multipart/form-data\">\n" . generate_token("form") . "\n<table width=\"100%\">\n<tr><td width=\"80\">Category:</td><td><select name=\"catid\" style=\"width:95%;\">" . $categorieslist . "</select></td></tr>\n<tr><td>Name:</td><td><input type=\"text\" name=\"title\" style=\"width:95%;\" /></td></tr>\n<tr><td>Description:</td><td><input type=\"text\" name=\"description\" style=\"width:95%;\" /></td></tr>\n</table>\n</form>";
    exit;
}
if ($action == "createdownloadcat") {
    check_token("WHMCS.admin.default");
    checkPermission("Edit Products/Services");
    insert_query("tbldownloadcats", array("parentid" => $catid, "name" => $title, "description" => html_entity_decode($description), "hidden" => ""));
    logActivity("Added New Download Category - " . $title);
    redir("action=edit&id=" . $id . "&tab=7");
    redir("action=edit&id=" . $id . "&tab=7");
}
if ($action == "add") {
    check_token("WHMCS.admin.default");
    checkPermission("Create New Products/Services");
    $pid = insert_query("tblproducts", array("type" => $type, "gid" => $gid, "name" => $productname, "paytype" => "free", "showdomainoptions" => "on"));
    redir("action=edit&id=" . $pid);
}
if ($action == "save") {
    check_token("WHMCS.admin.default");
    checkPermission("Edit Products/Services");
    $savefreedomainpaymentterms = $freedomainpaymentterms ? implode(",", $freedomainpaymentterms) : "";
    $savefreedomaintlds = $freedomaintlds ? implode(",", $freedomaintlds) : "";
    if ($tax == "on") {