function buy_land($method_name, $params, $app_data) { global $economy_source_account; $req = $params[0]; $agentid = $req['agentId']; $sessionid = $req['secureSessionId']; $amount = $req['currencyBuy']; $real = $req['estimatedCost']; $billableArea = $req['billableArea']; $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) { if ($amount > 0) { if (!process_transaction($agentid, $real, $ipAddress)) { header("Content-type: text/xml"); $response_xml = xmlrpc_encode(array('success' => False, 'errorMessage' => "\n\nThe gateway has declined your transaction. Please update your payment method and try again later.", 'errorURI' => "" . SYSURL . "")); print $response_xml; return ""; } move_money($economy_source_account, $agentid, $amount, 0, 0, 0, 0, "Currency purchase", 0, $ipAddress); } header("Content-type: text/xml"); $response_xml = xmlrpc_encode(array('success' => True)); 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 ""; }
function region_move_money($method_name, $params, $app_data) { global $economy_sink_account; $req = $params[0]; $agentid = $req['agentId']; $sessionid = $req['secureSessionId']; $regionid = $req['regionId']; $secret = $req['secret']; $currencySecret = $req['currencySecret']; $destid = $req['destId']; $cash = $req['cash']; $aggregatePermInventory = $req['aggregatePermInventory']; $aggregatePermNextOwner = $req['aggregatePermNextOwner']; $flags = $req['flags']; $transactiontype = $req['transactionType']; $description = $req['description']; $ipAddress = $_SERVER['REMOTE_ADDR']; # # Validate region secret # $db = new DB(); $sql = "select UUID from " . C_REGIONS_TBL . " " . "where UUID='" . $db->escape($regionid) . "' and " . "regionSecret='" . $db->escape($secret) . "'"; $db->query($sql); list($region_id) = $db->next_record(); if ($region_id) { # We have a region, check agent session $sql = "select UUID from " . C_AGENTS_TBL . " " . "where UUID='" . $db->escape($agentid) . "' and " . "secureSessionID='" . $db->escape($sessionid) . "' and " . "agentOnline=1 and " . "currentRegion='" . $db->escape($regionid) . "'"; $db->query($sql); list($user_id) = $db->next_record(); if ($user_id) { if (get_balance($agentid) < $cash) { $response_xml = xmlrpc_encode(array('success' => False, 'errorMessage' => "You do not have sufficient funds for this purchase", 'errorURI' => " ")); } else { if ($destid == "00000000-0000-0000-0000-000000000000") { $destid = $economy_sink_account; } if ($transactiontype == 1002) { user_alert($agentid, "00000000-0000-0000-0000-000000000000", "You paid L\$ " . $cash . " to create a group"); $description = "Group creation fee"; } else { if ($transactiontype == 1101) { user_alert($agentid, "00000000-0000-0000-0000-000000000000", "You paid L\$ " . $cash . " to upload."); $description = "Upload Charge"; } else { if ($transactiontype == 3000) { $description = "Give Inventory"; } else { if ($transactiontype == 5001) { $destName = agent_name($destid); $sourceName = agent_name($agentid); user_alert($agentid, "00000000-0000-0000-0000-000000000000", "You paid " . $destName . " L\$" . $cash); user_alert($destid, "00000000-0000-0000-0000-000000000000", $sourceName . " paid you L\$" . $cash); $description = "Gift"; } else { if ($transactiontype == 5002) { if ($destid == $economy_sink_account) { user_alert($agentid, "00000000-0000-0000-0000-000000000000", "You paid L\$ " . $cash . " for a parcel of land."); } else { $destName = agent_name($destid); $sourceName = agent_name($agentid); user_alert($agentid, "00000000-0000-0000-0000-000000000000", "You paid " . $destName . " L\$" . $cash . " for a parcel of land."); user_alert($destid, "00000000-0000-0000-0000-000000000000", $sourceName . " paid you L\$" . $cash . " for a parcel of land"); } $description = "Land Sale"; } else { if ($transactiontype == 5008) { $destName = agent_name($destid); $sourceName = agent_name($agentid); user_alert($agentid, "00000000-0000-0000-0000-000000000000", "You paid " . $destName . " L\$" . $cash); user_alert($destid, "00000000-0000-0000-0000-000000000000", $sourceName . " paid you L\$" . $cash); } else { if ($transactiontype == 2) { $destName = agent_name($destid); $sourceName = agent_name($agentid); user_alert($agentid, "00000000-0000-0000-0000-000000000000", "You paid " . $destName . " L\$" . $cash); user_alert($destid, "00000000-0000-0000-0000-000000000000", $sourceName . " paid you L\$" . $cash); } } } } } } } move_money($agentid, $destid, $cash, $aggregatePermInventory, $aggregatePermNextOwner, $flags, $transactiontype, $description, $regionid, $ipAddress); $response_xml = xmlrpc_encode(array('success' => True, 'agentId' => $agentid, 'funds' => get_balance($agentid), 'funds2' => get_balance($destid), 'currencySecret' => " ")); } } else { $response_xml = xmlrpc_encode(array('success' => False, 'errorMessage' => "Unable to authenticate avatar. Money operations may be unavailable", 'errorURI' => " ")); } } else { $response_xml = xmlrpc_encode(array('success' => False, 'errorMessage' => "This region is not authorized to manage your money. Money operations may be unavailable", 'errorURI' => " ")); } header("Content-type: text/xml"); print $response_xml; $stri = update_simulator_balance($agentid); $stri = update_simulator_balance($destid); return ""; }