function buy_land_prep($method_name, $params, $app_data)
{
    #	$confirmvalue = "password"; # Use this to request password re-entry
    $confirmvalue = "";
    $req = $params[0];
    $agentid = $req['agentId'];
    $sessionid = $req['secureSessionId'];
    $amount = $req['currencyBuy'];
    $billableArea = $req['billableArea'];
    #
    # Validate Requesting user has a session
    #
    $db = new DB();
    $db->query("select UUID from " . C_AGENTS_TBL . " where " . "UUID='" . $db->escape($agentid) . "' and " . "secureSessionID='" . $db->escape($sessionid) . "'");
    list($UUID) = $db->next_record();
    if ($UUID) {
        $membership_levels = array('levels' => array('id' => "00000000-0000-0000-0000-000000000000", 'description' => "some level"));
        $landUse = array('upgrade' => False, 'action' => "" . SYSURL . "");
        $currency = array('estimatedCost' => convert_to_real($amount));
        $membership = array('upgrade' => False, 'action' => "" . SYSURL . "", 'levels' => $membership_levels);
        $response_xml = xmlrpc_encode(array('success' => True, 'currency' => $currency, 'membership' => $membership, 'landUse' => $landUse, 'currency' => $currency, 'confirm' => $confirmvalue));
        header("Content-type: text/xml");
        print $response_xml;
    } else {
        header("Content-type: text/xml");
        $response_xml = xmlrpc_encode(array('success' => False, 'errorMessage' => "\n\nUnable to Authenticate\n\nClick URL for more info.", 'errorURI' => "" . SYSURL . ""));
        print $response_xml;
    }
    return "";
}
Esempio n. 2
0
 /**
  * Settings
  * New Function
  * load and merge configuration from file system & database
  *
  * @param	string	settings group (config filename/database group)
  * @param	string	name of the settings to return. optional if not included all settings for the matched group returned
  * @return mixed
  */
 public function setting($group = null, $name = null, $default = null)
 {
     /* Did we already load the cache? */
     if (!isset($this->settings)) {
         /* let's make sure the model is loaded */
         $this->model('o_setting_model');
         $this->cache = ci()->o_setting_model->get_cache_prefix() . $this->cache_suffix;
         /* let's make sure the cache is loaded */
         $this->driver('cache', ['adapter' => ci()->config->item('cache_default'), 'backup' => ci()->config->item('cache_backup')]);
         /* set the page request cached settings */
         if (!($this->settings = ci()->cache->get($this->cache))) {
             /* setup the empty array and load'em */
             $this->settings = [];
             /* get all file configs */
             $config_files = glob(ROOTPATH . '/application/config/*.php');
             foreach ($config_files as $file) {
                 $config = null;
                 require $file;
                 if (is_array($config)) {
                     $group_key = strtolower(basename($file, '.php'));
                     foreach ($config as $key => $value) {
                         $this->settings[$group_key][strtolower($key)] = $value;
                     }
                 }
             }
             /* get environment configuration - if it's set */
             if (ENVIRONMENT) {
                 $config_files = glob(ROOTPATH . '/application/config/' . ENVIRONMENT . '/*.php');
                 foreach ($config_files as $file) {
                     $config = null;
                     require $file;
                     if (is_array($config)) {
                         $group_key = strtolower(basename($file, '.php'));
                         foreach ($config as $key => $value) {
                             $this->settings[$group_key][strtolower($key)] = $value;
                         }
                     }
                 }
             }
             /* get all database "settings" */
             $db_array = ci()->o_setting_model->get_many_by(['enabled' => 1]);
             if (is_array($db_array)) {
                 foreach ($db_array as $record) {
                     /* let's make sure a boolean is a boolean and a integer is a integer etc... */
                     $this->settings[strtolower($record->group)][strtolower($record->name)] = convert_to_real($record->value);
                 }
             }
             ci()->cache->save($this->cache, $this->settings, 86400);
             /* 1 day */
         }
     }
     $rtn = $default;
     $group = strtolower($group);
     if ($name !== null) {
         $name = strtolower($name);
     }
     if ($name === null && isset($this->settings[$group])) {
         $rtn = $this->settings[$group];
     } elseif (isset($this->settings[$group][$name])) {
         $rtn = $this->settings[$group][$name];
     }
     return $rtn;
 }
 public function groupAction($which = null)
 {
     /* load file based */
     $this->load->config($which, true, true);
     $app_file = APPPATH . 'config/' . $which . '.php';
     if (file_exists($app_file)) {
         include APPPATH . 'config/' . $which . '.php';
         $file_array = (array) $config;
         unset($config);
     }
     $db_array = $this->o_setting_model->get_many_by(['enabled' => 1, 'group' => $which]);
     foreach ($db_array as $idx => $record) {
         unset($db_array[$idx]);
         $db_array[$record->name] = convert_to_real($record->value);
     }
     $merged = array_merge($file_array, $db_array);
     $env_array = [];
     if (ENVIRONMENT) {
         $env_file = APPPATH . 'config/' . ENVIRONMENT . '/' . $which . '.php';
         if (file_exists($env_file)) {
             include APPPATH . 'config/' . ENVIRONMENT . '/' . $which . '.php';
             $env_array = (array) $config;
             unset($config);
         }
     }
     $this->page->js('/themes/orange/assets/js/settings.js')->data(['controller_titles' => 'Complete Settings for "' . $which . '"', 'which' => $which, 'all' => ['merged' => $merged, 'env' => $env_array, 'file' => $file_array, 'db' => $db_array]])->build();
 }
function buy_currency($method_name, $params, $app_data)
{
    global $economy_source_account;
    global $minimum_real;
    global $low_amount_error;
    $req = $params[0];
    $agentid = $req['agentId'];
    $regionid = $req['regionId'];
    $sessionid = $req['secureSessionId'];
    $amount = $req['currencyBuy'];
    $ipAddress = $_SERVER['REMOTE_ADDR'];
    #
    # Validate Requesting user has a session
    #
    $db = new DB();
    $db->query("select UUID from " . C_AGENTS_TBL . " where " . "UUID='" . $db->escape($agentid) . "' and " . "secureSessionID='" . $db->escape($sessionid) . "'");
    list($UUID) = $db->next_record();
    if ($UUID) {
        $cost = convert_to_real($amount);
        if ($cost < $minimum_real) {
            $error = sprintf($low_amount_error, $minimum_real / 100.0);
            header("Content-type: text/xml");
            $response_xml = xmlrpc_encode(array('success' => False, 'errorMessage' => $error, 'errorURI' => "" . SYSURL . ""));
            print $response_xml;
            return "";
        }
        $transactionResult = process_transaction($agentid, $cost, $ipAddress);
        if ($transactionResult) {
            header("Content-type: text/xml");
            $response_xml = xmlrpc_encode(array('success' => True));
            print $response_xml;
            move_money($economy_source_account, $agentid, $amount, 0, 0, 0, 2100, "Currency purchased", $regionid, $ipAddress);
            update_simulator_balance($agentid);
        } else {
            header("Content-type: text/xml");
            $response_xml = xmlrpc_encode(array('success' => False, 'errorMessage' => "We were unable to process the transaction.  The gateway denied your charge", 'errorURI' => "" . SYSURL . ""));
            print $response_xml;
        }
    } else {
        header("Content-type: text/xml");
        $response_xml = xmlrpc_encode(array('success' => False, 'errorMessage' => "Unable to Authenticate\n\nClick URL for more info.", 'errorURI' => "" . SYSURL . ""));
        print $response_xml;
    }
    return "";
}