예제 #1
0
function _doSirportlyAPICall($method, $postfields = array(), $jsonDecode = true)
{
    ## Include the configuration
    include "config.php";
    ## Tidy up the URL
    $apiUrl = rtrim($baseUrl, '/') . "/api/v2/";
    ## Specify default params
    $default_params = array('brand' => $BrandId);
    ## Merge the postfields
    $postfields = array_merge($default_params, $postfields);
    ## Set the required headers
    $headers = array('X-Auth-Token: ' . $apiToken, 'X-Auth-Secret: ' . $apiSecret);
    ## Make the API request
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $apiUrl . $method);
    curl_setopt($ch, CURLOPT_POST, TRUE);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $result = curl_exec($ch);
    ## Decode the response
    if ($jsonDecode) {
        $return = json_decode($result, true);
    } else {
        $return = $result;
    }
    ## Log the API call
    logModuleCall('Sirportly', $method, $postfields, $result, $return);
    ## Return the decoded response
    return $return;
}
예제 #2
0
function pushover_ticket_reply($vars)
{
    $ticketid = $vars['ticketid'];
    $userid = $vars['userid'];
    $deptid = $vars['deptid'];
    $deptname = $vars['deptname'];
    $subject = $vars['subject'];
    $message = $vars['message'];
    $priority = $vars['priority'];
    // Convert HTML entities (single/double quote) back to single or double quote
    $message = htmlspecialchars_decode($message, ENT_QUOTES);
    $pushover_userkey = po_get_userkey();
    if (!$pushover_userkey) {
        return false;
    }
    $po_ticket_url = po_get_admin_ticket_url($ticketid);
    $pushover_api_url = 'https://api.pushover.net/1/messages.json';
    $pushover_app_token = 'a7HcPjJeGmAtyG4e6tCYqyXk5wc5Xj';
    $pushover_title = '[Ticket ID: ' . $ticketid . '] New Support Ticket Response';
    $pushover_url = $po_ticket_url;
    $pushover_url_title = "Open Admin Area to View Ticket";
    $pushover_message = $message;
    $pushover_post_fields = array('token' => $pushover_app_token, 'user' => $pushover_userkey, 'title' => $pushover_title, 'message' => $pushover_message, 'url' => $pushover_url, 'url_title' => $pushover_url_title, 'priority' => 1);
    // Convert to URL-Encoded string to post as application/x-www-form-urlencoded
    $pushover_encoded_post_fields = http_build_query($pushover_post_fields);
    $pushover_resp = curlCall($pushover_api_url, $pushover_encoded_post_fields, $pushover_options);
    $parsed_resp = json_decode($pushover_resp, true);
    if ($parsed_resp['status'] != 1) {
        logModuleCall('pushover', 'pushover_server_error', $pushover_post_fields, $pushover_resp);
    }
    logModuleCall('pushover', 'hook_ticket_open', $pushover_post_fields, $pushover_resp);
}
 /**
  * Makes and API call to orderbox and Logs in WHMCS module if $module_name and $action_name are specified
  *
  * @param type $method http method to make api request
  * @param type $path api path request
  * @param type $params array of parameters for api request
  * @param type $response_headers raw response of the api call
  * @param type $module_name moduel name to be logged
  * @param type $action_name moduel action to be logged
  * @return type
  */
 public function api($method, $path, $params = array(), &$response_headers = array(), $module_name = '', $action_name = '')
 {
     $url = $this->api_baseurl . ltrim($path, '/');
     $query_params = empty($params) ? $this->auth_params : array_merge($params, $this->auth_params);
     $query = $this->orderbox_http_build_query($query_params);
     if ('POST' == $method) {
         $get_fields = '';
         $post_fields = empty($query_params) ? '' : $this->orderbox_http_build_query($query_params);
         $request_headers = array("Content-Type: application/x-www-form-urlencoded; charset=utf-8");
     } else {
         $get_fields = $query;
         $post_fields = '';
         $request_headers = array();
     }
     try {
         $response_json = $this->http_api_request($method, $url, $get_fields, $post_fields, $request_headers, $response_headers);
     } catch (Exception $e) {
         return "Exception oboxapi : " . $e->getMessage();
     }
     $response = json_decode($response_json, true);
     if ($this->log_flag && function_exists('logModuleCall') && (!empty($module_name) || !empty($action_name))) {
         logModuleCall($module_name, $action_name, array_merge(array('api' => $path), $params), $response_headers, $response);
     }
     return $response;
 }
예제 #4
0
 protected function execute($postParams, $existingSession = true)
 {
     if ($existingSession) {
         if (self::$sessionId === false) {
             $api = new TPPW_AuthAPI($this->params);
             $acountId = $this->params['AccountNo'];
             $userId = $this->params['Login'];
             $password = $this->params['Password'];
             $results = $api->authenticate($acountId, $userId, $password);
             if (!$results->isSuccess()) {
                 return $results;
             }
             self::$sessionId = $results->getResponse();
         }
         $postParams['SessionID'] = self::$sessionId;
     }
     $postParams = array_merge(TPPW_APIUtils::$API_COMMON_PARAMS, $postParams);
     $postFields = '';
     foreach ($postParams as $key => $values) {
         if (is_array($values)) {
             foreach ($values as $value) {
                 $postFields .= $key . '=' . urlencode($value) . '&';
             }
         } else {
             $postFields .= $key . '=' . urlencode($values) . '&';
         }
     }
     $conn = curl_init();
     curl_setopt($conn, CURLOPT_URL, $this->url);
     curl_setopt($conn, CURLOPT_POST, 1);
     curl_setopt($conn, CURLOPT_POSTFIELDS, $postFields);
     curl_setopt($conn, CURLOPT_HEADER, false);
     curl_setopt($conn, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($conn, CURLOPT_SSL_VERIFYPEER, false);
     curl_setopt($conn, CURLOPT_SSL_VERIFYHOST, false);
     $response = curl_exec($conn);
     $error = curl_error($conn);
     $errorNum = curl_errno($conn);
     $stats = curl_getinfo($conn);
     curl_close($conn);
     $message = "<p><strong>API Query:</strong> <pre>{$this->url}?{$postFields}</pre></p>";
     $message .= "<p><strong>Response:</strong> <pre>{$response}</pre></p>";
     $message .= "<p><strong>Stats:</strong> <pre>" . print_r($stats, true) . "</pre></p>";
     if (function_exists('logModuleCall')) {
         logModuleCall(TPPW_APIUtils::$MODULE_NAME, $this->url, $postFields, $response);
     }
     if ($this->params['Debug']) {
         logactivity($message);
     }
     if ($errorNum) {
         return new TPPW_APIResult("ERR-CURL: {$errorNum}, {$error}");
     }
     return new TPPW_APIResult($response);
 }
function purchaseorder_link($params)
{
    global $CONFIG;
    $code = "";
    $cart_action = filter_input(INPUT_GET, 'a', FILTER_SANITIZE_STRING);
    $actual_auto_activate_value = array();
    $actual_verified_account_value = array();
    $sysurl = $CONFIG['SystemSSLURL'] ? $CONFIG['SystemSSLURL'] : $CONFIG['SystemURL'];
    $invoiceid = $params['invoiceid'];
    if ($params['enableautoactivatefield'] == 'on' && !empty($params['autoactivatefield'])) {
        $auto_activate_field_label = $params['autoactivatefield'];
        $auto_activate_query = select_query('tblcustomfields', 'id', array('fieldname' => $auto_activate_field_label));
        $auto_activate_id = mysql_fetch_array($auto_activate_query);
    }
    if (!empty($params['verifiedaccountfield'])) {
        $verified_account_field_label = $params['verifiedaccountfield'];
        $verified_account_query = select_query('tblcustomfields', 'id', array('fieldname' => $verified_account_field_label));
        $verified_account_id = mysql_fetch_array($verified_account_query);
    }
    //	echo "AUTO ACTIVATE ID =" . $auto_activate_id;
    //	echo "VERIFIED ACCOUNT ID =" . $verified_account_id;
    foreach ($params['clientdetails']['customfields'] as $customfield) {
        if ($customfield['id'] == $auto_activate_id[0]) {
            $actual_auto_activate_value = $customfield['value'];
        }
        if ($customfield['id'] == $verified_account_id[0]) {
            $actual_verified_account_value = $customfield['value'];
        }
    }
    $orderid_req = select_query('tblorders', 'id', array('invoiceid' => $invoiceid));
    $orderid_data = mysql_fetch_array($orderid_req);
    if (!empty($orderid_data['id'])) {
        $orderid = $orderid_data['id'];
    }
    // Make sure you set the custom field value above
    if ($actual_verified_account_value == 'on') {
        $code .= html_entity_decode($params['approvedforpo']);
    } else {
        $code .= html_entity_decode($params['notapprovedforpo']);
    }
    if ($actual_auto_activate_value == 'on' && !empty($orderid) && $cart_action != 'complete') {
        purchaseorder_accept_order($orderid);
        logModuleCall('autoactivate', 'activate', 'accepting order...', $orderid);
    }
    // Required to redirect after checking out
    $code .= "<form method=\"POST\" action=\"{$sysurl}/viewinvoice.php?id={$invoiceid}\">";
    return $code;
}
예제 #6
0
function rrpproxy_call($params, $request)
{
    $url = "https://api.rrpproxy.net/api/call.cgi?";
    if ($params['TestMode']) {
        $url = "https://api-ote.rrpproxy.net/api/call.cgi?";
    }
    if (is_array($request)) {
        $query_string = "";
        foreach ($request as $k => $v) {
            $query_string .= $k . "=" . urlencode($v) . "&";
        }
    } else {
        $query_string = $request;
    }
    $url .= "s_login="******"&s_pw=" . urlencode($params['Password']) . "&" . $query_string;
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_TIMEOUT, 100);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    $retval = curl_exec($ch);
    if (curl_errno($ch)) {
        $retval = "CURL Error: " . curl_errno($ch) . " - " . curl_error($ch);
    }
    curl_close($ch);
    $lines = explode("\n", $retval);
    foreach ($lines as $tempvalue) {
        $tempvalue = explode("=", $tempvalue);
        $result[trim($tempvalue[0])] = trim($tempvalue[1]);
    }
    if (substr($retval, 0, 4) == "CURL") {
        $result['code'] = "999";
        $result['description'] = $retval;
    } else {
        if (!$retval) {
            $result['code'] = "998";
            $result['description'] = "An unhandled exception occurred";
        }
    }
    $action = explode("&", $query_string);
    $action = $action[0];
    $action = str_replace("command=", "", $action);
    logModuleCall("rrpproxy", $action, $url, $retval, $result, array($params['Username'], $params['Password']));
    return $result;
}
예제 #7
0
 public function call($action, $format = true)
 {
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, $this->url . "/api/" . $action . ($format ? "/format/json/" : ""));
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch, CURLOPT_USERPWD, $this->user . ":" . $this->pass);
     curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
     $this->response = json_decode(curl_exec($ch), true);
     $this->http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
     $this->curl_error = curl_error($ch);
     if ($this->response['messages']['error'][0]) {
         $this->error = $this->response['messages']['error'][0];
     }
     if ($this->debug) {
         logModuleCall('spamexpertsresller', $action, $this->url . "/api/" . $action . ($format ? "/format/json/" : ""), print_r($this->response, true));
     }
     curl_close($ch);
 }
예제 #8
0
function tunai_link($params)
{
    # Gateway Specific Variables
    $merchantid = $params['merchantid'];
    $accesskey = $params['accesskey'];
    $secretkey = $params['secretkey'];
    # Invoice Variables
    $invoiceid = $params['invoiceid'];
    $description = $params["description"];
    $amount = $params['amount'];
    # Format: ##.##
    $currency = $params['currency'];
    # Currency Code
    # Client Variables
    $firstname = $params['clientdetails']['firstname'];
    $lastname = $params['clientdetails']['lastname'];
    $email = $params['clientdetails']['email'];
    $address1 = $params['clientdetails']['address1'];
    $address2 = $params['clientdetails']['address2'];
    $city = $params['clientdetails']['city'];
    $state = $params['clientdetails']['state'];
    $postcode = $params['clientdetails']['postcode'];
    $country = $params['clientdetails']['country'];
    $phone = $params['clientdetails']['phonenumber'];
    # System Variables
    $companyname = $params['companyname'];
    $systemurl = $params['systemurl'];
    $currency = $params['currency'];
    $log_enable = $params['log_enable'];
    # Invoice Items
    $command = "getinvoice";
    $adminuser = $params['api_username'];
    $values["invoiceid"] = $invoiceid;
    $results = localAPI($command, $values, $adminuser);
    $parser = xml_parser_create();
    xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
    xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
    xml_parse_into_struct($parser, $results, $values, $tags);
    xml_parser_free($parser);
    if ($log_enable == true) {
        logModuleCall('tunai', 'getinvoice', $values, $results, $ressultarray, '');
    }
    $item_details = array();
    $itemid = 0;
    if ($results["result"] == "success") {
        $invoiceitems = $results['items']['item'];
        for ($i = 0; $i < count($invoiceitems); $i++) {
            $invoiceitem = $invoiceitems[$i];
            $itemdescription = $invoiceitem['description'];
            $itemdescription = preg_replace("/\r|\n/", ",", $itemdescription);
            if (strlen($itemdescription) > 50) {
                $itemdescription = substr($itemdescription, 0, 50);
            }
            $itemid++;
            $data = array('itemId' => strval($itemid), 'price' => $invoiceitem['amount'], 'quantity' => 1, 'description' => $itemdescription);
            $item_details[] = $data;
        }
        # PPn
        $tax = $results['tax'];
        if ($tax > 0) {
            $itemid++;
            $data = array('itemId' => strval($itemid), 'price' => $tax, 'quantity' => 1, 'description' => 'Pajak');
            $item_details[] = $data;
        }
        # credit
        $credit = $results['credit'];
        if ($credit > 0) {
            $itemid++;
            $data = array('itemId' => strval($itemid), 'price' => $credit * -1, 'quantity' => 1, 'description' => 'Saldo');
            $item_details[] = $data;
        }
    }
    if ($log_enable == true) {
        logModuleCall('tunai', 'itemdetails', $values, $results, $item_details, '');
    }
    $customer = array("name" => $firstname . " " . $lastname, "address" => $address1 . "\r\n" . $address2, "phone" => $phone, "city" => $city, "province" => $state, "zipcode" => $postcode, "country" => $country, "mobilephone" => "", "identity" => "");
    $data = array("refId" => strval($invoiceid), "expired" => (string) time() + 24 * 60 * 60 . '000', "amount" => $amount, "customer" => $customer, "items" => $item_details);
    $invoice = new Invoice($accesskey, $secretkey);
    $response = $invoice->getByRefOrCreate($data);
    $json = $response->getBody();
    if ($log_enable == true) {
        logModuleCall('tunai', 'getByRefOrCreate', $data, $json, $ressultarray, '');
    }
    $statusCode = $response->getStatusCode();
    $obj = json_decode($json);
    if ($statusCode == 200) {
        $code = '<img src="//files.tunai.id/images/tunai-button-white.png" alt="tunai" /><p>Kode Pembayaran: <strong>' . $obj->token . '</strong><br />Total: Rp ' . $obj->amount . ' </p><form method="post" action="https://pay.tunai.id/' . $obj->token . '"><input type="submit" value="Bayar ke Agen" /></form>';
        return $code;
    }
    return '<b>' . $obj->message . '</b>';
}
function resellerclubsdhostingin_UnsuspendAccount($params)
{
    global $orderbox;
    try {
        $plan_pieces = _get_plan_details($params['configoption1']);
        if ('windows' == $plan_pieces['type']) {
            $api_path_orderid_from_domain = '/singledomainhosting/windows/in/orderid.json';
        } else {
            $api_path_orderid_from_domain = '/singledomainhosting/linux/in/orderid.json';
        }
        $order_id_result = $orderbox->api('GET', $api_path_orderid_from_domain, array('domain-name' => $params['domain']), $response, 'resellerclubsdhostingin', 'unsuspend');
        if (is_array($order_id_result) && array_key_exists('status', $order_id_result) && strtolower($order_id_result['status']) == 'error') {
            return $order_id_result['message'];
        } else {
            $order_id = $order_id_result;
            $order_unsuspend_result = $orderbox->api('POST', '/orders/unsuspend.json', array('order-id' => $order_id), $response, 'resellerclubsdhostingin', 'unsuspend');
            if (is_array($order_unsuspend_result) && array_key_exists('status', $order_unsuspend_result)) {
                $status = strtolower($order_unsuspend_result['status']);
                if ($status == 'success') {
                    return 'success';
                } else {
                    return $order_unsuspend_result['message'];
                }
            }
        }
    } catch (Exception $e) {
        logModuleCall('resellerclubsdhostingin', 'unsuspend', 'unknown', 'Exception : ' . $e->getMessage());
        return "Order unsuspend error - " . $e->getMessage();
    }
}
예제 #10
0
/**
 * Client area output logic handling.
 *
 * This function is used to define module specific client area output. It should
 * return an array consisting of a template file and optional additional
 * template variables to make available to that template.
 *
 * The template file you return can be one of two types:
 *
 * * tabOverviewModuleOutputTemplate - The output of the template provided here
 *   will be displayed as part of the default product/service client area
 *   product overview page.
 *
 * * tabOverviewReplacementTemplate - Alternatively using this option allows you
 *   to entirely take control of the product/service overview page within the
 *   client area.
 *
 * Whichever option you choose, extra template variables are defined in the same
 * way. This demonstrates the use of the full replacement.
 *
 * Please Note: Using tabOverviewReplacementTemplate means you should display
 * the standard information such as pricing and billing details in your custom
 * template or they will not be visible to the end user.
 *
 * @param array $params common module parameters
 *
 * @see http://docs.whmcs.com/Provisioning_Module_SDK_Parameters
 *
 * @return array
 */
function budgetvm_ClientArea(array $params)
{
    // Determine the requested action and set service call parameters based on
    // the action.
    $requestedAction = isset($_REQUEST['customAction']) ? $_REQUEST['customAction'] : '';
    $service = $params['serviceid'];
    $bvmid = $params['customfields']['BudgetVM Service ID'];
    $var = new stdclass();
    $var->post = new stdclass();
    $var->post->service = $bvmid;
    $budgetvm->bvmid = $bvmid;
    $budgetvm->service = $service;
    $type = new BudgetVM_Api($params['serverpassword']);
    $type = $type->call("v2", "device", "type", "get", $var);
    $budgetvm->type = $type->result;
    if ($requestedAction == "manage") {
        $serviceAction = 'get_usage';
        $templateFile = 'templates/manage.tpl';
    } elseif ($requestedAction == 'reverse') {
        if ($_SERVER['REQUEST_METHOD'] == "POST" && is_array($_POST['update'])) {
            $update = new BudgetVM_Api($params['serverpassword']);
            $var->post->records = json_encode($_POST['update']);
            $budgetvm->return = $update->call("v2", "dns", "reverse", "put", $var);
            if (is_object($budgetvm->return->result)) {
                $fixed = "";
                foreach ($budgetvm->return->result as $ip => $ret) {
                    $fixed .= $ip . " - " . $ret . "<br>" . PHP_EOL;
                }
                $budgetvm->return->result = $fixed;
            }
        } else {
            $budgetvm->return = NULL;
        }
        $netblocks = new BudgetVM_Api($params['serverpassword']);
        $budgetvm->netblocks = $netblocks->call("v2", "network", "netblock", "get", $var);
        $serviceAction = 'get_usage';
        $templateFile = 'templates/rdns.tpl';
    } elseif ($requestedAction == 'network') {
        $bandwidth = new BudgetVM_Api($params['serverpassword']);
        if ($budgetvm->type == "dedicated") {
            if (isset($_GET['period'])) {
                switch ($_GET['period']) {
                    case "hour":
                        $var->post->start = strtotime("-1 hour");
                        break;
                    case "day":
                        $var->post->start = strtotime("-1 day");
                        break;
                    case "week":
                        $var->post->start = strtotime("-1 week");
                        break;
                    case "month":
                        $var->post->start = strtotime("-1 month");
                        break;
                    case "year":
                        $var->post->start = strtotime("-1 year");
                        break;
                    default:
                        $var->post->start = strtotime("-1 month");
                        break;
                }
            } else {
                $var->post->start = strtotime("last Month");
            }
            $var->post->end = strtotime("now");
            $budgetvm->bandwidth = $bandwidth->call("v2", "network", "bandwidth", "post", $var);
        } else {
            $budgetvm->bandwidth = $bandwidth->call("v2", "network", "bandwidth", "post", $var);
        }
        $serviceAction = 'get_usage';
        $templateFile = 'templates/network.tpl';
    } elseif ($requestedAction == 'power') {
        if ($_SERVER['REQUEST_METHOD'] == "POST") {
            if ($_POST['bootorder'] != "standard") {
                // Custom Boot Order was Requested
                $bootorder = new BudgetVM_Api($params['serverpassword']);
                $var->post->request = $_POST['bootorder'];
                $budgetvm->bootorder = $bootorder->call("v2", "device", "power", "put", $var);
            } else {
                $budgetvm->bootorder = NULL;
            }
            // Power Action
            $update = new BudgetVM_Api($params['serverpassword']);
            $var->post->action = $_POST['poweraction'];
            $budgetvm->return = $update->call("v2", "device", "power", "post", $var);
            if ($budgetvm->return->success == true) {
                if ($_POST['bootorder'] != "standard" && !empty($budgetvm->bootorder) && $budgetvm->bootorder->success == true) {
                    // Power Action with custom boot order
                    $budgetvm->return->result = $budgetvm->bootorder->result . " & " . $budgetvm->return->result;
                }
            }
        } else {
            $budgetvm->return = NULL;
        }
        $powerStatus = new BudgetVM_Api($params['serverpassword']);
        $budgetvm->powerStatus = $powerStatus->call("v2", "device", "power", "get", $var);
        $serviceAction = 'get_usage';
        $templateFile = 'templates/power.tpl';
    } elseif ($requestedAction == 'reinstall') {
        if ($_SERVER['REQUEST_METHOD'] == "POST") {
            $cancel = $_POST['cancel'];
            if (isset($cancel) && $cancel == true) {
                $stop = new BudgetVM_Api($params['serverpassword']);
                $budgetvm->return = $stop->call("v2", "device", "reload", "delete", $var);
            } else {
                $provision = new BudgetVM_Api($params['serverpassword']);
                $var->post->value = $_POST['profile'];
                $budgetvm->return = $provision->call("v2", "device", "reload", "post", $var);
                if ($budgetvm->return->success == true) {
                    if ($type->result == "dedicated") {
                        $budgetvm->return->result = "System Reinstall Started</br>Root Password: "******"dedicated") {
            $status = new BudgetVM_Api($params['serverpassword']);
            $budgetvm->status = $status->call("v2", "device", "reload", "put", $var)->result;
        } else {
            $budgetvm->status = NULL;
        }
        $profiles = new BudgetVM_Api($params['serverpassword']);
        $budgetvm->profiles = $profiles->call("v2", "device", "reload", "get", $var)->result;
        $serviceAction = 'get_usage';
        $templateFile = 'templates/reinstall.tpl';
    } elseif ($requestedAction == 'ipmi') {
        if ($_SERVER['REQUEST_METHOD'] == "POST") {
            if ($type->result == "dedicated") {
                if ($_POST['ipmi_reset'] == true) {
                    $reset_ipmi = new BudgetVM_Api($params['serverpassword']);
                    $budgetvm->return = $reset_ipmi->call("v2", "device", "console", "delete", $var);
                } elseif ($_POST['ipmi_launch'] == true) {
                    $launch_ipmi = new BudgetVM_Api($params['serverpassword']);
                    $budgetvm->return = $launch_ipmi->call("v2", "device", "console", "get", $var);
                    if ($budgetvm->return->success == true) {
                        $launch_ipmi->ipmiLaunch(base64_decode($budgetvm->return->result));
                        $budgetvm->return->result = "KVM Launched, File download started.";
                    }
                } elseif ($_POST['image_unmount'] == true) {
                    $unmount_image = new BudgetVM_Api($params['serverpassword']);
                    $budgetvm->return = $unmount_image->call("v2", "device", "iso", "delete", $var);
                } elseif ($_POST['image_mount'] == true) {
                    $mount_image = new BudgetVM_Api($params['serverpassword']);
                    $var->post->image = $_POST['profile'];
                    $budgetvm->return = $mount_image->call("v2", "device", "iso", "post", $var);
                    $mount_image = new BudgetVM_Api($params['serverpassword']);
                    $budgetvm->return = $mount_image->call("v2", "device", "iso", "put", $var);
                }
            } else {
                if ($_POST['ipmi_vm_launch'] == true) {
                    $ipmi_vm_launch = new BudgetVM_Api($params['serverpassword']);
                    $budgetvm->return = $ipmi_vm_launch->call("v2", "device", "console", "get", $var);
                    if ($budgetvm->return->success == true) {
                        $message = "<h4>Management Console</h4>";
                        $message .= "Username: "******"</br>" . PHP_EOL;
                        $message .= "Password: "******"</br>" . PHP_EOL;
                        $message .= "Host: <a href='" . $budgetvm->return->result->host . "' target='_blank'>" . $budgetvm->return->result->host . "</a>" . PHP_EOL;
                        $budgetvm->return->result = $message;
                    }
                }
            }
        } else {
            $budgetvm->return = NULL;
        }
        $images = new BudgetVM_Api($params['serverpassword']);
        $budgetvm->images = $images->call("v2", "device", "iso", "get", NULL);
        $status = new BudgetVM_Api($params['serverpassword']);
        $budgetvm->status = $status->call("v2", "device", "iso", "get", $var);
        $serviceAction = 'get_usage';
        $templateFile = 'templates/ipmi.tpl';
    } else {
        // Service Overview
        if ($type->success == true) {
            $budgetvm->type = $type->result;
            if ($type->result == "dedicated") {
                $device = new BudgetVM_Api($params['serverpassword']);
                $device = $device->call("v2", "device", "hardware", "get", $var);
                $network = new BudgetVM_Api($params['serverpassword']);
                $network = $network->call("v2", "network", "netblock", "get", $var);
                if ($network->result == true) {
                    $budgetvm->network = $network->result;
                }
            } else {
                $device = new BudgetVM_Api($params['serverpassword']);
                $device = $device->call("v2", "device", "stats", "get", $var);
            }
            if ($device->success == true) {
                $budgetvm->device = $device->result;
            }
        }
        $var->post->start = strtotime("last Month");
        $var->post->end = strtotime("now");
        $bandwidth = new BudgetVM_Api($params['serverpassword']);
        $budgetvm->bandwidth = $bandwidth->call("v2", "network", "bandwidth", "post", $var);
        $status = new BudgetVM_Api($params['serverpassword']);
        $status = $status->call("v2", "device", "power", "get", $var);
        if ($status->success == true && $status->success == true) {
            $budgetvm->status = $status->result;
        } else {
            $budgetvm->status = "Uknown";
        }
        $serviceAction = 'get_stats';
        $templateFile = 'templates/overview.tpl';
    }
    try {
        // Call the service's function based on the request action, using the
        // values provided by WHMCS in `$params`.
        return array('tabOverviewReplacementTemplate' => $templateFile, 'templateVariables' => array('budgetvm' => $budgetvm));
    } catch (Exception $e) {
        // Record the error in WHMCS's module log.
        logModuleCall('provisioningmodule', __FUNCTION__, $params, $e->getMessage(), $e->getTraceAsString());
        // In an error condition, display an error page.
        return array('tabOverviewReplacementTemplate' => 'error.tpl', 'templateVariables' => array('usefulErrorHelper' => $e->getMessage()));
    }
}
예제 #11
0
function namecheap_DeleteNameserver($params)
{
    require_once dirname(__FILE__) . "/namecheapapi.php";
    $testmode = (bool) $params['TestMode'];
    $username = $testmode ? $params['SandboxUsername'] : $params['Username'];
    $password = $testmode ? $params['SandboxPassword'] : $params['Password'];
    $tld = $params['tld'];
    $sld = $params['sld'];
    $oIDNA = new NamecheapRegistrarIDNA($sld, $tld);
    $sld = $oIDNA->getEncodedSld();
    $response = '';
    $result = $request_params = $values = array();
    try {
        $request_params = array('SLD' => $sld, 'TLD' => $tld, 'Nameserver' => $params['nameserver']);
        $api = new NamecheapRegistrarApi($username, $password, $testmode);
        $response = $api->request("namecheap.domains.ns.delete", $request_params);
        $result = $api->parseResponse($response);
    } catch (Exception $e) {
        $values['error'] = "An error occurred: " . $e->getMessage();
        logModuleCall('namecheap', 'DeleteNameserver', array('command' => "namecheap.domains.ns.delete") + $request_params, $response, $result, array($password));
    }
    return $values;
}
예제 #12
0
파일: dottk.php 프로젝트: billyprice1/whmcs
function dottk_put($xml, $callmethod, $params)
{
    global $DOTTKAPI_user;
    global $DOTTKAPI_phrase;
    $xurl = "https://secure.dot.tk/partners/partnerapi.tk";
    $DOTTKAPI_xmlout = 4;
    $headers = array("Accept: application/x-www-form-urlencoded", "Content-Type: application/x-www-form-urlencoded");
    $session = curl_init();
    curl_setopt($session, CURLOPT_URL, $xurl);
    curl_setopt($session, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
    curl_setopt($session, CURLOPT_POSTFIELDS, $xml);
    curl_setopt($session, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($session, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($session, CURLOPT_SSL_VERIFYPEER, false);
    $response = curl_exec($session);
    $action = explode("&", $xml);
    $action = explode("=", $action[0]);
    $action = end($action);
    logModuleCall("dottk", $action, $xml, $response, "", array(urlencode($params['Password']), urlencode($params['Email'])));
    if (curl_errno($session)) {
        $response['curlerror'] = "CURL Error: " . curl_errno($session) . " - " . curl_error($session);
        curl_close($session);
        return $response;
    }
    curl_close($session);
    if ($DOTTKAPI_xmlout == 0) {
        $xmlarray = XMLtoARRAY($response);
        return $xmlarray;
    }
    return $response;
}
예제 #13
0
function virtualmin_req($params, $postfields, $rawdata = false)
{
    $http = $params['serversecure'] ? "https" : "http";
    $domain = $params['serverhostname'] ? $params['serverhostname'] : $params['serverip'];
    $url = "" . $http . "://" . $domain . "/virtual-server/remote.cgi?" . $fieldstring;
    $fieldstring = "";
    foreach ($postfields as $k => $v) {
        $fieldstring .= "" . $k . "=" . urlencode($v) . "&";
    }
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $fieldstring);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_USERPWD, $params['serverusername'] . ":" . $params['serverpassword']);
    curl_setopt($ch, CURLOPT_TIMEOUT, 60);
    $data = curl_exec($ch);
    if (curl_errno($ch)) {
        $data = "Curl Error: " . curl_errno($ch) . " - " . curl_error($ch);
    }
    curl_close($ch);
    logModuleCall("virtualmin", $postfields['program'], $postfields, $data);
    if (strpos($data, "Unauthorized") == true) {
        return "Server Login Invalid";
    }
    if ($rawdata) {
        return $data;
    }
    $exitstatuspos = strpos($data, "Exit status:");
    $exitstatus = trim(substr($data, $exitstatuspos + 12));
    if ($exitstatus == "0") {
        $result = "success";
    } else {
        $dataarray = explode("\n", $data);
        $result = $dataarray[0];
    }
    return $result;
}
function opensrspro_logModuleCall($function, $callArray, $resultFullRaw, $return, $params)
{
    $module = 'OpenSRSPro';
    $action = substr($function, 0, 11) == 'opensrspro_' ? substr($function, 11) : $function;
    $requeststring = $callArray;
    $responsedata = $resultFullRaw;
    //$processeddata = $return;
    $replacevars = array($params["TestUsername"], $params["TestAPIKey"], $params["ProdUsername"], $params["ProdAPIKey"]);
    logModuleCall($module, $action, $requeststring, $responsedata, $return, $replacevars);
}
/**
 * Client area output logic handling.
 *
 * This function is used to define module specific client area output. It should
 * return an array consisting of a template file and optional additional
 * template variables to make available to that template.
 *
 * The template file you return can be one of two types:
 *
 * * tabOverviewModuleOutputTemplate - The output of the template provided here
 *   will be displayed as part of the default product/service client area
 *   product overview page.
 *
 * * tabOverviewReplacementTemplate - Alternatively using this option allows you
 *   to entirely take control of the product/service overview page within the
 *   client area.
 *
 * Whichever option you choose, extra template variables are defined in the same
 * way. This demonstrates the use of the full replacement.
 *
 * Please Note: Using tabOverviewReplacementTemplate means you should display
 * the standard information such as pricing and billing details in your custom
 * template or they will not be visible to the end user.
 *
 * @param array $params common module parameters
 *
 * @see http://docs.whmcs.com/Provisioning_Module_SDK_Parameters
 *
 * @return array
 */
function provisioningmodule_ClientArea(array $params)
{
    // Determine the requested action and set service call parameters based on
    // the action.
    $requestedAction = isset($_REQUEST['customAction']) ? $_REQUEST['customAction'] : '';
    if ($requestedAction == 'manage') {
        $serviceAction = 'get_usage';
        $templateFile = 'templates/manage.tpl';
    } else {
        $serviceAction = 'get_stats';
        $templateFile = 'templates/overview.tpl';
    }
    try {
        // Call the service's function based on the request action, using the
        // values provided by WHMCS in `$params`.
        $response = array();
        $extraVariable1 = 'abc';
        $extraVariable2 = '123';
        return array('tabOverviewReplacementTemplate' => $templateFile, 'templateVariables' => array('extraVariable1' => $extraVariable1, 'extraVariable2' => $extraVariable2));
    } catch (Exception $e) {
        // Record the error in WHMCS's module log.
        logModuleCall('provisioningmodule', __FUNCTION__, $params, $e->getMessage(), $e->getTraceAsString());
        // In an error condition, display an error page.
        return array('tabOverviewReplacementTemplate' => 'error.tpl', 'templateVariables' => array('usefulErrorHelper' => $e->getMessage()));
    }
}
예제 #16
0
function affordabledomains_connect_server($url, $postfields)
{
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
    $data = curl_exec($ch);
    curl_close($ch);
    $action = $url;
    $action = str_replace("http://dev.affordabledomains.co.nz/testlab/api/whmcs/", "", $action);
    $action = str_replace("http://www.affordabledomains.co.nz/api/whmcs/", "", $action);
    $action = str_replace(".php", "", $action);
    $action = curl_setopt($ch, CURLOPT_TIMEOUT, 100);
    logModuleCall("affordabledomains", $action, $postfields, $data, "", array($postfields['txtLoginUname'], $postfields['txtLoginPwd']));
    return $data;
}
예제 #17
0
파일: bizcn.php 프로젝트: billyprice1/whmcs
function com_71_call($params, $testModel = false)
{
    define("COM_71_API_TEST", "https://test.api.71.com/webrrpdomain");
    define("COM_71_API", "https://api.71.com/webrrpdomain");
    global $globalServerUrl;
    global $globalMessage;
    global $globalParams;
    if ($testModel == true) {
        $postUrl = COM_71_API_TEST;
    } else {
        $postUrl = COM_71_API;
    }
    $globalServerUrl = $postUrl;
    $sendParams = http_build_query($params, "", "&");
    $sendParams = str_replace("EQU", "=", $sendParams);
    $sendParams = str_replace("AND", "&", $sendParams);
    $globalParams = $sendParams;
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $postUrl);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $sendParams);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_NOBODY, 0);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
    $ret = curl_exec($ch);
    $globalMessage = $ret;
    logModuleCall("bizcn", $params['module'], $params, $ret, "", array($params['username'], $params['password']));
    return $ret;
}
예제 #18
0
function resellerclub_SendCommand($command, $type, $postfields, $params, $method, $nodecode = false)
{
    if ($params['TestMode']) {
        $url = "https://test.httpapi.com/api/" . $type . "/" . $command . ".json";
    } else {
        $url = "https://httpapi.com/api/" . $type . "/" . $command . ".json";
    }
    $ch = curl_init();
    if ($method == "GET") {
        $url .= "?";
        foreach ($postfields as $field => $data) {
            $url .= "" . $field . "=" . rawurlencode($data) . "&";
        }
        $url = substr($url, 0, 0 - 1);
        $postfields['url'] = $url;
    } else {
        $postfield = "";
        foreach ($postfields as $field => $data) {
            if ($field != "ns") {
                $data = rawurlencode($data);
            }
            if (preg_match('/es$/i', $params['tld']) && !$data && $field == "attr-value2") {
                $data = 6;
            }
            if (preg_match('/es$/i', $params['tld']) && !$data && $field == "attr-value3") {
                $data = rawurlencode($params['additionalfields']["ID Form Number"]);
            }
            $postfield .= "" . $field . "=" . $data . "&";
        }
        $postfield = substr($postfield, 0, 0 - 1);
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $postfield);
        $postfields['posteddata'] = $postfield;
    }
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_TIMEOUT, 100);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $data = curl_exec($ch);
    if (curl_errno($ch)) {
        $ip = resellerclub_GetIP();
        $ip2 = isset($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : $_SERVER['LOCAL_ADDR'];
        $result['response']['status'] = "ERROR";
        $result['response']['message'] = "CURL Error: " . curl_errno($ch) . " - " . curl_error($ch) . (" (IP: " . $ip . " & " . $ip2 . ")");
    } else {
        if ($nodecode && is_numeric($data)) {
            $result = $data;
        } else {
            $result = json_decode($data, true);
        }
    }
    curl_close($ch);
    logModuleCall("logicboxes", "" . $type . "/" . $command, $postfields, $data, $result, array($params['ResellerID'], $params['APIKey']));
    return $result;
}
예제 #19
0
function webnic_call($url, $rtype, $postfields, $params)
{
    if ($params['TestMode']) {
        $url = "http://ote.webnic.cc/jsp/" . $url;
    } else {
        $url = "https://my.webnic.cc/jsp/" . $url;
    }
    $query_string = "";
    foreach ($postfields as $k => $v) {
        $query_string .= "" . $k . "=" . urlencode($v) . "&";
    }
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($ch, CURLOPT_TIMEOUT, 50);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $query_string);
    $res_data = curl_exec($ch);
    if (curl_errno($ch)) {
        $res_data = "CURL Error: " . curl_errno($ch) . " - " . curl_error($ch);
    }
    curl_close($ch);
    $res_data = trim($res_data);
    $res_array = explode("\n", $res_data);
    logModuleCall("webnic", $rtype, $query_string, $res_data, $res_array, array($params['Source']));
    return $res_array;
}
예제 #20
0
function heartinternetreg_curlcall($xml, $verbose = "off", $params)
{
    if (!class_exists("HeartInternetReg_API")) {
        require ROOTDIR . "/modules/registrars/heartinternet/heartinternet.class.php";
    }
    $hi_api = new HeartInternetReg_API();
    if ($params['TestMode'] == "on") {
        $hi_api->connect(true);
    } else {
        $hi_api->connect();
    }
    $objects = array("urn:ietf:params:xml:ns:contact-1.0", "urn:ietf:params:xml:ns:domain-1.0", "http://www.heartinternet.co.uk/whapi/null-1.1");
    $extensions = array("http://www.heartinternet.co.uk/whapi/ext-domain-1.2", "http://www.heartinternet.co.uk/whapi/ext-contact-1.0", "http://www.heartinternet.co.uk/whapi/ext-host-1.0", "http://www.heartinternet.co.uk/whapi/ext-null-1.0", "http://www.heartinternet.co.uk/whapi/ext-whapi-1.0");
    try {
        $hi_api->logIn($params['Username'], $params['Password'], $objects, $extensions);
    } catch (Exception $e) {
        return "Caught exception: " . $e->getMessage();
    }
    $data = $hi_api->sendMessage($xml, true);
    logModuleCall("heartinternet", $action, $xml, $data, "", array($params['Username'], $params['Password']));
    if ($verbose == "on") {
        return heartinternetreg_xml2array($data);
    }
    return XMLtoArray($data);
}
예제 #21
0
 /**
  * Just a combined function of get_hostcontrol_id_from_user() and
  * create_reseller_customer() to make things easier
  * @param $params
  * @param $api_client
  * @throws HostControlHelperError
  * @return bool|mixed
  */
 public static function get_or_create_hostcontrol_customer_id($params, $api_client)
 {
     $hostcontrol_client_id = self::get_customer_id_from_whmcs_user($params['userid']);
     if (!empty($hostcontrol_client_id)) {
         return $hostcontrol_client_id;
     }
     try {
         $whmcs_client_email = strtolower(self::get_whmcs_client_email_address($params['userid']));
         if (empty($whmcs_client_email)) {
             logModuleCall('HostControl', 'lookup-customer-error', 'No customer emailaddress found for WHMCS customer ' . $params['userid'], $params['userid']);
             throw new HostControlHelperError('No customer emailaddress found for WHMCS client ' . $params['userid'] . '. Please insert an emailaddress for this client.');
         }
         $hostcontrol_customer = array_shift($api_client->customer->lookup($whmcs_client_email));
         if (!empty($hostcontrol_customer->id)) {
             self::store_customer_id($params['userid'], $hostcontrol_customer->id);
             return $hostcontrol_customer->id;
         }
     } catch (HostControlAPIClientError $e) {
         logModuleCall('HostControl', 'lookup-customer-error', $whmcs_client_email, $e);
     }
     return self::create_hostcontrol_customer($api_client, $params);
 }
예제 #22
0
function directadmin_req($command, $fields, $params, $post = "")
{
    $host = $params['serverhostname'] ? $params['serverhostname'] : $params['serverip'];
    $user = $params['serverusername'];
    $pass = $params['serverpassword'];
    $usessl = $params['serversecure'];
    $resultsarray = array();
    $fieldstring = "";
    foreach ($fields as $key => $value) {
        $fieldstring .= "" . $key . "=" . urlencode($value) . "&";
    }
    $authstr = $user . ":" . $pass;
    $directadminaccterr = "";
    $ch = curl_init();
    if ($usessl) {
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
        $url = "https://" . $host . ":2222/" . $command . "?" . $fieldstring;
    } else {
        $url = "http://" . $host . ":2222/" . $command . "?" . $fieldstring;
    }
    curl_setopt($ch, CURLOPT_URL, $url);
    if ($post) {
        curl_setopt($ch, CURLOPT_POSTFIELDS, $fieldstring);
    }
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $curlheaders[0] = "Authorization: Basic " . base64_encode($authstr);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $curlheaders);
    curl_setopt($ch, CURLOPT_TIMEOUT, 60);
    $data = curl_exec($ch);
    if (curl_errno($ch)) {
        $resultsarray['error'] = true;
        $resultsarray['details'] = curl_errno($ch) . " - " . curl_error($ch);
        $data = curl_errno($ch) . " - " . curl_error($ch);
    }
    curl_close($ch);
    if (!$resultsarray['error']) {
        if (strpos($data, "DirectAdmin Login") == true) {
            $resultsarray = array("error" => "1", "details" => "Login Failed");
        } else {
            if ($params['getip']) {
                $data2 = unhtmlentities($data);
                parse_str($data2, $output);
                foreach ($output as $key => $value) {
                    $key = str_replace("_", ".", urldecode($key));
                    $value = explode("&", urldecode($value));
                    foreach ($value as $temp) {
                        $temp = explode("=", $temp);
                        $resultsarray[urldecode($key)][$temp[0]] = $temp[1];
                    }
                }
            } else {
                $data = explode("&", $data);
                foreach ($data as $temp) {
                    $temp = explode("=", $temp);
                    $resultsarray[$temp[0]] = $temp[1];
                }
            }
        }
    }
    logModuleCall("directadmin", $command, $url, $data, $resultsarray);
    return $resultsarray;
}
예제 #23
0
function plesk10_connection($params, $packet)
{
    global $plesk10packetversion;
    if (!$plesk10packetversion) {
        $plesk10packetversion = "1.6.3.0";
    }
    $secure = $params['serversecure'] ? "https" : "http";
    $hostname = $params['serverhostname'] ? $params['serverhostname'] : $params['serverip'];
    $port = $params['serveraccesshash'] ? $params['serveraccesshash'] : "8443";
    $url = "" . $secure . "://" . $hostname . ":" . $port . "/enterprise/control/agent.php";
    $headers = array("HTTP_AUTH_LOGIN: "******"HTTP_AUTH_PASSWD: " . $params['serverpassword'], "Content-Type: text/xml");
    $packet = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><packet version=\"" . $plesk10packetversion . "\">" . $packet . "</packet>";
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_TIMEOUT, 300);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $packet);
    $retval = curl_exec($ch);
    if (curl_errno($ch)) {
        $result['curlerror'] = "CURL Error: " . curl_errno($ch) . " - " . curl_error($ch);
    } else {
        $result = XMLtoARRAY($retval);
    }
    curl_close($ch);
    logModuleCall("plesk10", $params['action'], $packet, $retval, $result);
    return $result;
}
예제 #24
0
function heartinternet_curlcall($xml, $verbose = "off", $params)
{
    if (!class_exists("HeartInternet_API")) {
        require ROOTDIR . "/modules/servers/heartinternet/heartinternet.class.php";
    }
    $hi_api = new HeartInternet_API();
    if ($params['configoption1'] == "on") {
        $hi_api->connect(true);
    } else {
        $hi_api->connect();
    }
    $objects = array("http://www.heartinternet.co.uk/whapi/null-1.1", "http://www.heartinternet.co.uk/whapi/package-1.4");
    $extensions = array("http://www.heartinternet.co.uk/whapi/ext-package-1.1", "http://www.heartinternet.co.uk/whapi/ext-whapi-1.0");
    try {
        $hi_api->logIn($params['serverusername'], $params['serverpassword'], $objects, $extensions);
    } catch (Exception $e) {
        logModuleCall("heartinternet", $params['action'], $xml, $e->getMessage());
        return "Caught exception: " . $e->getMessage();
    }
    $data = $hi_api->sendMessage($xml, true);
    $retxml = $verbose == "on" ? heartinternet_xml2array($data) : XMLtoArray($data);
    logModuleCall("heartinternet", $params['action'], $xml, $data, $retxml);
    return $retxml;
}
예제 #25
0
 /**
  * Make CURL call and check versions
  * @since 1.0.1
  *
  * @param  string  $url     HTTPS Full URL to raw file with version number
  * @param  integer $version Full current version number
  * @param  string  $module  Current module checking update for
  *
  * @return boolean         True if newer version is available, false if not
  */
 public static function check_need_update($url, $version, $module = 'whmcse')
 {
     //			$release = file_get_contents( $url, "r" );
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, $url);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
     curl_setopt($ch, CURLOPT_USERAGENT, 'tripflex/whmcs-pushover/' . $version);
     $release = curl_exec($ch);
     curl_close($ch);
     logModuleCall($module, 'update check', $version, $release);
     if (version_compare($release, $version) > 0) {
         return true;
     } else {
         return false;
     }
 }
예제 #26
0
function ispcfg3_ChangePassword($params)
{
    $username = $params['username'];
    $password = $params['password'];
    $clientsdetails = $params['clientsdetails'];
    $soapuser = $params['configoption1'];
    $soappassword = $params['configoption2'];
    $soapsvrurl = $params['configoption3'];
    $soapsvrssl = $params['configoption4'];
    if ($soapsvrssl == 'on') {
        $soap_url = 'https://' . $soapsvrurl . '/remote/index.php';
        $soap_uri = 'https://' . $soapsvrurl . '/remote/';
    } else {
        $soap_url = 'http://' . $soapsvrurl . '/remote/index.php';
        $soap_uri = 'http://' . $soapsvrurl . '/remote/';
    }
    if (isset($username) && $username != '' && (isset($password) && $password != '')) {
        try {
            /* Connect to SOAP Server */
            $client = new SoapClient(null, array('location' => $soap_url, 'uri' => $soap_uri, 'exceptions' => 1, 'trace' => false));
            /* Authenticate with the SOAP Server */
            $session_id = $client->login($soapuser, $soappassword);
            $domain_id = $client->client_get_by_username($session_id, $username);
            $client_id = $domain_id['client_id'];
            $returnresult = $client->client_change_password($session_id, $client_id, $password);
            logModuleCall('ispconfig', 'ChangePassword', $clientsdetails, $returnresult, '', '');
            if ($client->logout($session_id)) {
            }
            if ($returnresult == 1) {
                $successful = '1';
            } else {
                $successful = '0';
                $result = "Password change failed";
            }
        } catch (SoapFault $e) {
            $error = 'SOAP Error: ' . $e->getMessage();
            $successful = '0';
        }
        if ($successful == 1) {
            $result = 'success';
        } else {
            $result = 'Error: ' . $error;
        }
    } else {
        /*
         * No username or password set.
         */
        $result = 'Username or Password is Blank or Not Set';
    }
    return $result;
}
예제 #27
0
function interworx_GetResellers($params)
{
    $key = $params['serveraccesshash'];
    $api_controller = "/nodeworx/reseller";
    $action = "listIds";
    $input = array();
    $client = new soapclient("https://" . $params['serverip'] . ":2443/nodeworx/soap?wsdl");
    $result = $client->route($key, $api_controller, $action, $input);
    logModuleCall("interworx", $action, $input, $result);
    $resellers = array();
    foreach ($result['payload'] as $reseller) {
        $resellerid = $reseller[0];
        $reselleremail = $reseller[1];
        $reselleremail = explode("(", $reselleremail, 2);
        $reselleremail = $reselleremail[1];
        $reselleremail = substr($reselleremail, 0, 0 - 1);
        $resellers[$reselleremail] = $resellerid;
    }
    return $resellers;
}
예제 #28
0
 function logCall($action, $request)
 {
     if (function_exists("logModuleCall")) {
         logModuleCall("nominet", $action, $request, $this->getResponse(), $this->getResponseArray(), array($this->getParam("Username"), $this->getParam("Password")));
     }
     return true;
 }
예제 #29
0
function fluidvm_get_via_json($protocol, $server, $serverusername, $serverpassword, $port, $param)
{
    if ($protocol) {
        $protocol = "https";
        $port = "8087";
    } else {
        $protocol = "http";
        $port = "8086";
    }
    $param = "login-class=client&login-name=" . $serverusername . "&login-password="******"&output-type=json&" . $param;
    $url = "" . $protocol . "://" . $server . ":" . $port . "/webcommand.php";
    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $param);
    curl_setopt($ch, CURLOPT_TIMEOUT, 100);
    $totalout = curl_exec($ch);
    $totalout = trim($totalout);
    if (curl_errno($ch)) {
        $totalout = "Curl Error: " . curl_errno($ch) . " - " . curl_error($ch);
    }
    require_once dirname(__FILE__) . "/JSON.php";
    $json = new Services_JSON();
    $object = $json->decode($totalout);
    logModuleCall("fluidvm", "", $url . "?" . $param, $totalout, "", array($serverusername, $serverpassword));
    return $object;
}
예제 #30
0
function ventraip_APICall($command, $request, $params)
{
    $apiurl = "https://api.wholesalesystem.com.au/?wsdl";
    $values = array();
    $soaprequest = $request;
    $soaprequest['resellerID'] = $params['resellerID'];
    $soaprequest['apiKey'] = $params['apiKey'];
    $client = new SoapClient(null, array("location" => $apiurl, "uri" => ""));
    try {
        if ($command == "register") {
            $params['tld'] = end(explode(".", $params['tld']));
            if ($params['tld'] == "au") {
                $soapresult = get_object_vars($client->domainRegisterAU($soaprequest));
            } else {
                if ($params['tld'] == "uk") {
                    $soapresult = get_object_vars($client->domainRegisterUK($soaprequest));
                } else {
                    $soapresult = get_object_vars($client->domainRegister($soaprequest));
                }
            }
        } else {
            if ($command == "transfer") {
                if ($params['tld'] == "uk") {
                    $soapresult = get_object_vars($client->domainTransferUK($soaprequest));
                } else {
                    $soapresult = get_object_vars($client->transferDomain($soaprequest));
                }
            } else {
                if ($command == "renew") {
                    $soapresult = get_object_vars($client->renewDomain($soaprequest));
                } else {
                    if ($command == "getns") {
                        $soapresult = get_object_vars($client->domainInfo($soaprequest));
                        $values['ns1'] = $soapresult['nameServers'][0];
                        $values['ns2'] = $soapresult['nameServers'][1];
                        $values['ns3'] = $soapresult['nameServers'][2];
                        $values['ns4'] = $soapresult['nameServers'][3];
                        $values['ns5'] = $soapresult['nameServers'][4];
                    } else {
                        if ($command == "savens") {
                            $soapresult = get_object_vars($client->updateNameServers($soaprequest));
                        } else {
                            if ($command == "getlockstatus") {
                                $soapresult = get_object_vars($client->domainInfo($soaprequest));
                                if ($soapresult['domain_status'] == "clientTransferProhibited") {
                                    $values['lockstatus'] = "locked";
                                } else {
                                    $values['lockstatus'] = "unlocked";
                                }
                            } else {
                                if ($command == "getidprotectionstatus") {
                                    $soapresult = get_object_vars($client->domainInfo($soaprequest));
                                    if ($soapresult['idProtect'] == "Enabled") {
                                        $values['idProtect'] = "Enabled";
                                    } else {
                                        $values['idProtect'] = "Disabled";
                                    }
                                } else {
                                    if ($command == "geteppcode") {
                                        $soapresult = get_object_vars($client->domainInfo($soaprequest));
                                        $values['eppCode'] = $soapresult['domainPassword'];
                                    } else {
                                        if ($command == "getcontacts") {
                                            $soapresult = get_object_vars($client->listContacts($soaprequest));
                                            $values['Registrant']["First Name"] = $soapresult['registrant']->firstname;
                                            $values['Registrant']["Last Name"] = $soapresult['registrant']->lastname;
                                            $values['Registrant']["Address 1"] = $soapresult['registrant']->address1;
                                            $values['Registrant']["Address 2"] = $soapresult['registrant']->address2;
                                            $values['Registrant']['City'] = $soapresult['registrant']->suburb;
                                            $values['Registrant']['State'] = $soapresult['registrant']->state;
                                            $values['Registrant']['Postcode'] = $soapresult['registrant']->postcode;
                                            $values['Registrant']['Country'] = $soapresult['registrant']->country;
                                            $values['Registrant']['Phone'] = $soapresult['registrant']->phone;
                                            $values['Registrant']['Fax'] = $soapresult['registrant']->fax;
                                            $values['Registrant']['Email'] = $soapresult['registrant']->email;
                                            if (isset($soapresult['admin'])) {
                                                $values['Admin']["First Name"] = $soapresult['admin']->firstname;
                                                $values['Admin']["Last Name"] = $soapresult['admin']->lastname;
                                                $values['Admin']["Address 1"] = $soapresult['admin']->address1;
                                                $values['Admin']["Address 2"] = $soapresult['admin']->address2;
                                                $values['Admin']['City'] = $soapresult['admin']->suburb;
                                                $values['Admin']['State'] = $soapresult['admin']->state;
                                                $values['Admin']['Postcode'] = $soapresult['admin']->postcode;
                                                $values['Admin']['Country'] = $soapresult['admin']->country;
                                                $values['Admin']['Phone'] = $soapresult['admin']->phone;
                                                $values['Admin']['Fax'] = $soapresult['admin']->fax;
                                                $values['Admin']['Email'] = $soapresult['admin']->email;
                                            }
                                            if (isset($soapresult['billing'])) {
                                                $values['Billing']["First Name"] = $soapresult['billing']->firstname;
                                                $values['Billing']["Last Name"] = $soapresult['billing']->lastname;
                                                $values['Billing']["Address 1"] = $soapresult['billing']->address1;
                                                $values['Billing']["Address 2"] = $soapresult['billing']->address2;
                                                $values['Billing']['City'] = $soapresult['billing']->suburb;
                                                $values['Billing']['State'] = $soapresult['billing']->state;
                                                $values['Billing']['Postcode'] = $soapresult['billing']->postcode;
                                                $values['Billing']['Country'] = $soapresult['billing']->country;
                                                $values['Billing']['Phone'] = $soapresult['billing']->phone;
                                                $values['Billing']['Fax'] = $soapresult['billing']->fax;
                                                $values['Billing']['Email'] = $soapresult['billing']->email;
                                            }
                                            if (isset($soapresult['tech'])) {
                                                $values['Tech']["First Name"] = $soapresult['tech']->firstname;
                                                $values['Tech']["Last Name"] = $soapresult['tech']->lastname;
                                                $values['Tech']["Address 1"] = $soapresult['tech']->address1;
                                                $values['Tech']["Address 2"] = $soapresult['tech']->address2;
                                                $values['Tech']['City'] = $soapresult['tech']->suburb;
                                                $values['Tech']['State'] = $soapresult['tech']->state;
                                                $values['Tech']['Postcode'] = $soapresult['tech']->postcode;
                                                $values['Tech']['Country'] = $soapresult['tech']->country;
                                                $values['Tech']['Phone'] = $soapresult['tech']->phone;
                                                $values['Tech']['Fax'] = $soapresult['tech']->fax;
                                                $values['Tech']['Email'] = $soapresult['tech']->email;
                                            }
                                        } else {
                                            if ($command == "savecontacts") {
                                                $soapresult = get_object_vars($client->updateContact($soaprequest));
                                            } else {
                                                if ($command == "addhost") {
                                                    $soapresult = get_object_vars($client->addHost($soaprequest));
                                                } else {
                                                    if ($command == "delhost") {
                                                        $soapresult = get_object_vars($client->deleteHost($soaprequest));
                                                    } else {
                                                        if ($command == "addhostip") {
                                                            $soapresult = get_object_vars($client->addHostIP($soaprequest));
                                                        } else {
                                                            if ($command == "delhostip") {
                                                                $soapresult = get_object_vars($client->deleteHostIP($soaprequest));
                                                            } else {
                                                                if ($command == "sync") {
                                                                    $soapresult = get_object_vars($client->domainInfo($soaprequest));
                                                                    if (in_array($soapresult['domain_status'], array("ok", "clientTransferProhibited"))) {
                                                                        $values['status'] = "Active";
                                                                        $values['active'] = true;
                                                                    } else {
                                                                        if ($soapresult['domain_status'] == "Transferred Away") {
                                                                            update_query("tbldomains", array("status" => "Cancelled"), array("domain" => $params['sld'] . "." . $params['tld']));
                                                                        }
                                                                    }
                                                                    $values['expirydate'] = substr($soapresult['domain_expiry'], 0, 10);
                                                                } else {
                                                                    if ($command == "lockdomain") {
                                                                        $soapresult = get_object_vars($client->lockDomain($soaprequest));
                                                                    } else {
                                                                        if ($command == "unlockdomain") {
                                                                            $soapresult = get_object_vars($client->unlockDomain($soaprequest));
                                                                        } else {
                                                                            if ($command == "idprotect") {
                                                                                $soapresult = get_object_vars($client->enableIDProtection($soaprequest));
                                                                                if ($soapresult['status'] != "OK") {
                                                                                    $values = array("error" => $soapresult['errorMessage']);
                                                                                }
                                                                            } else {
                                                                                if ($command == "idunprotect") {
                                                                                    $soapresult = get_object_vars($client->disableIDProtection($soaprequest));
                                                                                    if ($soapresult['status'] != "OK") {
                                                                                        $values = array("error" => $soapresult['errorMessage']);
                                                                                    }
                                                                                } else {
                                                                                    if ($command == "releasedomain") {
                                                                                        $soapresult = get_object_vars($client->domainReleaseUK($soaprequest));
                                                                                    } else {
                                                                                        if ($command == "listMailForwards") {
                                                                                            $soapresult = get_object_vars($client->listMailForwards($soaprequest));
                                                                                            if (is_array($soapresult['forwards'])) {
                                                                                                foreach ($soapresult['forwards'] as $forward) {
                                                                                                    $forward = get_object_vars($forward);
                                                                                                    $values[$forward['id']]['prefix'] = str_replace("@" . $request['domainName'], "", $forward['source']);
                                                                                                    $values[$forward['id']]['forwardto'] = $forward['destination'];
                                                                                                }
                                                                                            }
                                                                                        } else {
                                                                                            if ($command == "addMailForward") {
                                                                                                $soapresult = get_object_vars($client->addMailForward($soaprequest));
                                                                                            } else {
                                                                                                if ($command == "deleteMailForward") {
                                                                                                    $soapresult = get_object_vars($client->deleteMailForward($soaprequest));
                                                                                                } else {
                                                                                                    if ($command == "deleteDNSRecord") {
                                                                                                        $soapresult = get_object_vars($client->deleteDNSRecord($soaprequest));
                                                                                                    } else {
                                                                                                        if ($command == "addDNSRecord") {
                                                                                                            $soapresult = get_object_vars($client->addDNSRecord($soaprequest));
                                                                                                        } else {
                                                                                                            if ($command == "listDNSZone") {
                                                                                                                $soapresult = get_object_vars($client->listDNSZone($soaprequest));
                                                                                                                if ($soapresult['status'] == "OK" && is_array($soapresult['records'])) {
                                                                                                                    $values = array();
                                                                                                                    foreach ($soapresult['records'] as $record) {
                                                                                                                        $record = get_object_vars($record);
                                                                                                                        if ($record['type'] != "SOA") {
                                                                                                                            if ($record['type'] == "MX") {
                                                                                                                                $values[] = array("hostname" => $record['hostName'], "type" => $record['type'], "address" => $record['content'], "priority" => $record['prio'], "recid" => $record['id']);
                                                                                                                                continue;
                                                                                                                            }
                                                                                                                            $values[] = array("hostname" => $record['hostName'], "type" => $record['type'], "address" => $record['content'], "recid" => $record['id']);
                                                                                                                            continue;
                                                                                                                        }
                                                                                                                    }
                                                                                                                }
                                                                                                            }
                                                                                                        }
                                                                                                    }
                                                                                                }
                                                                                            }
                                                                                        }
                                                                                    }
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        $not_in_status = array("OK", "OK_PENDING_REGO", "OK_TRANSFER_PENDING", "OK_TRANSFER_EMAILPENDING", "OK_TRANSFER_EMAIL", "OK_TRANSFER_UK_PENDING", "OK_TRANSFER_WAITING_AUTH");
        if (!in_array($soapresult['status'], $not_in_status)) {
            $values['error'] = $soapresult['errorMessage'] ? $soapresult['errorMessage'] : serialize($soapresult);
        }
        logModuleCall("ventraip", $command, $soaprequest, $soapresult, $soapresult, array($params['resellerID'], $params['apiKey']));
    } catch (SoapFault $e) {
        $values['error'] = $e->errorMessage ? $e->status . " - " . $e->errorMessage : $e;
        logModuleCall("ventraip", $command, $soaprequest, $soapresult, $e, array($params['resellerID'], $params['apiKey']));
        return $values;
    }
}