Example #1
0
<?php

use WHMCS\Cron;
use WHMCS\Exception\Fatal;
use WHMCS\Terminus;
/**
 * admin/cron.php
 *
 * This file is deprecated and here for backwards compatibility.
 *
 * The distributed version of WHMCS provides the main application cron in
 * crons/cron.php
 *
 * The crons folder may be moved to any place above or below the docroot.
 *
 * For more information please see http://docs.whmcs.com/Custom_Crons_Directory
 */
/** @var WHMCS\Application $whmcs */
require dirname(__DIR__) . DIRECTORY_SEPARATOR . 'init.php';
define('PROXY_FILE', true);
try {
    $path = Cron::getCronsPath(basename(__FILE__));
    require_once $path;
} catch (Fatal $e) {
    echo Cron::formatOutput(Cron::getCronRootDirErrorMessage());
    Terminus::getInstance()->doExit(1);
} catch (\Exception $e) {
    echo Cron::formatOutput(Cron::getCronPathErrorMessage());
    Terminus::getInstance()->doExit(1);
}
    curl_setopt($ch, CURLOPT_USERPWD, $GATEWAY['private-key'] . ":" . NULL);
    curl_setopt($ch, CURLOPT_TIMEOUT, 5);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, TRUE);
    curl_setopt($ch, CURLOPT_CAINFO, realpath(dirname(__FILE__) . "/cacert.pem"));
    $return = curl_exec($ch);
    curl_close($ch);
    return $return;
}
# Ensure that the module is active before attempting to run any code
$gateway = new Gateway();
if (!$gateway->isActiveGateway($gatewaymodule) || !$gateway->load($gatewaymodule)) {
    Terminus::getInstance()->doDie('Module not Active');
}
$pdo = Capsule::connection()->getPdo();
# Process and store transaction
if (isset($_REQUEST['id']) && !empty($_REQUEST['id'])) {
    $ca = new WHMCS_ClientArea();
    # Check login status
    if ($ca->isLoggedIn()) {
        $invoice_id = (int) $_REQUEST['id'];
        $store_token = $_REQUEST['token'];
        $currency = $_REQUEST['currency'];
        $amount = (int) $_REQUEST['amount'];
        if (preg_match("#^[A-Z]{3}\$#", $currency) && preg_match("#^[a-zA-Z 0-9\\_\\-]*\$#", $store_token)) {
            //Get invoice details
            $sql = "SELECT * FROM tblinvoices WHERE id = '{$invoice_id}'";
            $result = $pdo->query($sql);