function send_mail($to, $subject, $msg, $cc = array(), $bcc = array(), $html = false, $dep = NULL, $message_id = NULL, $in_reply_to = NULL, $references = array()) { global $cluster, $cluster_cfg; $mailers = $cluster->list_servers_with_type("mailer"); $ids = array_keys($mailers); add_transaction($_SESSION["member"]["m_id"], $ids[0], 0, T_MAIL_SEND, array("from_name" => $cluster_cfg->get("mailer_from_name"), "from_mail" => $cluster_cfg->get("mailer_from_mail"), "to" => $to, "subject" => $subject, "msg" => $msg, "cc" => $cc, "bcc" => $bcc, "html" => $html, "msg_id" => $message_id, "in_reply_to" => $in_reply_to, "references" => $references, "date" => date("r")), NULL, $dep); }
function add_transaction_locationwide($m_id, $vps_id, $t_type, $t_param = 'none', $location_id) { global $db, $cluster; $sql = "INSERT INTO transaction_groups\n\t\t SET is_locationwide=1,\n\t\t\tlocation_id=" . $db->check($location_id); $db->query($sql); $group_id = $db->insert_id(); $servers = $cluster->list_servers_by_location($location_id); foreach ($servers as $id => $name) { add_transaction($m_id, $id, $vps_id, $t_type, $t_param, $group_id); } }
function nas_export_delete($id) { global $db; $e = nas_get_export_by_id($id); $children = nas_get_export_children($id); $vpses = array(); foreach ($children as $child) { nas_delete_export_mounts($child["id"], $vpses); nas_export_delete_direct($child["id"], false); } nas_delete_export_mounts($id, $vpses); nas_export_delete_direct($e, true); if ($e["default"] == "no") { $params = array("path" => $e["root_dataset"] . "/" . $e["dataset"], "recursive" => true); add_transaction($_SESSION["member"]["m_id"], $e["node_id"], 0, T_STORAGE_EXPORT_DELETE, $params); foreach ($vpses as $veid) { $vps = new vps_load($veid); $vps->mount_regen(); } } }
function withdraw_nmc($address, $amount = 0, $type = "", $intern_txid = 0) { global $namecoin, $db; $address = mysql_real_escape_string($address, $db); $slt_deposit_address_a = "SELECT * FROM deposit_address WHERE currency = 'NMC' AND address = '{$address}'"; $rlt_deposit_address_a = mysql_query($slt_deposit_address_a); if ($row_deposit_address_a = mysql_fetch_assoc($rlt_deposit_address_a)) { if ($amount <= 0) { return array("success" => true, "type" => "intern", "to_user" => $row_deposit_address_a["user"]); } $itxid = add_transaction($row_deposit_address_a["user"], "in", "intern", $amount, "NMC", "deposit", $intern_txid); return array("success" => true, "type" => "intern", "txid" => $itxid, "to_user" => $row_deposit_address_a["user"]); } if ($amount <= 0) { return array("success" => true, "type" => "extern"); } if (!isset($bitcoin)) { $namecoin = new jsonRPCClient("http://*****:*****@127.0.0.1:8336/"); } $txid = $namecoin->sendtoaddress($address, (double) $amount); $ins_crypto_transaction_a = "INSERT INTO crypto_transaction (txid) VALUES ('{$txid}')"; mysql_query($ins_crypto_transaction_a); return array("success" => true, "type" => "extern", "txid" => mysql_insert_id(), "to_user" => 0); }
$server_balance = $solidcoin->sc_getbalance("main") / 10000; if (count($errors) == 0 && $server_balance < $amountwithfee * 1.05 + 1) { $errors[] = "There's currently not enough Solidcoins on the Solidcoin24 servers to fulfill your withdrawal request. Don't worry, a Solidcoin24 admin has been informed and will resolve this for you. You will get an email as soon as the Solidcoins are available. Sorry for the inconvenience, but remember that a big part of the amounts are stored in a seperate wallets for your own security."; send_mail("Emergency! Solidcoin balance exhausted ({$server_balance} left)!", "A user with the email address " . $_SESSION["user_email"] . " legitimately tried to withdraw {$amount} Solidcoins. There are still {$server_balance} Solidcoins on the server. The request was denied. Please resolve this and make sure to inform the user.", "*****@*****.**"); } if (count($errors) == 0) { echo "{$amount} Solidcoins are being transferred to {$address}.<br />"; $result = withdraw_slc($address); if ($result["type"] == "extern") { $itxid = add_transaction($_SESSION["user_id"], "out", "extern", $amountwithfee, "SLC", "withdrawal", 0, $staticfee); $tx = withdraw_slc($address, $amount, "", $itxid); $udt_transaction_a = "UPDATE transaction SET info_id = '{$tx['txid']}' WHERE id = '{$itxid}'"; mysql_query($udt_transaction_a); echo "<small>Transaction (extern): " . crypte_transaction($tx["txid"]) . "</small>"; } else { $itxid = add_transaction($_SESSION["user_id"], "out", "intern", $amountwithfee, "SLC", "withdrawal", 0); $tx = withdraw_slc($address, $amount, "", $itxid); $udt_transaction_a = "UPDATE transaction SET info_id = '{$tx['txid']}' WHERE id = '{$itxid}'"; mysql_query($udt_transaction_a); echo "<small>Transaction (intern): {$tx['txid']}</small>"; } } else { foreach ($errors as $error) { echo "{$error}<br />"; } ?> <br /> The Solidcoins will be transferred immediately to the specified address and removed from your balance.<br /><br /> Current balance: <?php echo nice_format($balance, false, 0, 4); ?>
function process_order($id) { global $db; if (!is_numeric($id)) { die("Invalid trade order id."); } $slt_trade_order_a = "SELECT * FROM trade_order WHERE id = '{$id}'"; $rlt_trade_order_a = mysql_query($slt_trade_order_a); $row_trade_order_a = mysql_fetch_assoc($rlt_trade_order_a); $currency = $row_trade_order_a["currency"]; if ($row_trade_order_a["type"] == "buy") { $slt_trade_order_b = "SELECT * FROM trade_order WHERE active = 'yes' AND finished = 'no' AND type = 'sell' AND currency = '{$currency}' AND filing_time < '{$row_trade_order_a['filing_time']}' AND ROUND(price * 100000000) <= " . round($row_trade_order_a["price"] * 100000000) . " ORDER BY price ASC, filing_time ASC LIMIT 1"; $rlt_trade_order_b = mysql_query($slt_trade_order_b); $row_trade_order_b = mysql_fetch_assoc($rlt_trade_order_b); $price = $row_trade_order_b["price"]; $amount = min($row_trade_order_a["amount"] - $row_trade_order_a["completed"], $row_trade_order_b["amount"] - $row_trade_order_b["completed"]); if ($amount > 0) { $cur_amount = $amount * $price; $slc_amount = $amount; $slc_trid = add_transaction($row_trade_order_a["user"], "in", "intern", $slc_amount, "SLC", "trade_return", $row_trade_order_a["id"], 0); $ref_trid = 0; if ($amount * ($row_trade_order_a["price"] - $price) * 100000000 >= 1) { $ref_trid = add_transaction($row_trade_order_a["user"], "in", "intern", $amount * ($row_trade_order_a["price"] - $price), $row_trade_order_b["currency"], "trade_return", $row_trade_order_a["id"], 0); } $cur_trid = add_transaction($row_trade_order_b["user"], "in", "intern", $cur_amount * 0.997, $row_trade_order_b["currency"], "trade_return", $row_trade_order_b["id"], $cur_amount * 0.003); if ($row_trade_order_a["amount"] - $row_trade_order_a["completed"] - $amount <= 1.0E-7) { $udt_trade_order_a = "UPDATE trade_order SET completed = amount, finished = 'yes', active = 'no', finishing_time = NOW() WHERE id = {$row_trade_order_a['id']}"; mysql_query($udt_trade_order_a); } else { $udt_trade_order_a = "UPDATE trade_order SET completed = completed + {$amount} WHERE id = {$row_trade_order_a['id']}"; mysql_query($udt_trade_order_a); } if ($row_trade_order_b["amount"] - $row_trade_order_b["completed"] - $amount <= 1.0E-7) { $udt_trade_order_b = "UPDATE trade_order SET completed = amount, finished = 'yes', active = 'no', finishing_time = NOW() WHERE id = {$row_trade_order_b['id']}"; mysql_query($udt_trade_order_b); } else { $udt_trade_order_b = "UPDATE trade_order SET completed = completed + {$amount} WHERE id = {$row_trade_order_b['id']}"; mysql_query($udt_trade_order_b); } $ins_trade_a = "INSERT INTO trade (type, buy_trade_order, sell_trade_order, currency, slc_transaction, cur_transaction, refund, trade_time, price, amount) " . "VALUES ('buy', {$row_trade_order_a['id']}, {$row_trade_order_b['id']}, '{$currency}', '{$slc_trid}', '{$cur_trid}', '{$ref_trid}', NOW(), {$price}, {$amount})"; mysql_query($ins_trade_a); } } elseif ($row_trade_order_a["type"] == "sell") { $slt_trade_order_b = "SELECT * FROM trade_order WHERE active = 'yes' AND finished = 'no' AND type = 'buy' AND currency = '{$currency}' AND filing_time < '{$row_trade_order_a['filing_time']}' AND ROUND(price * 100000000) >= " . round($row_trade_order_a["price"] * 100000000) . " ORDER BY price DESC, filing_time ASC LIMIT 1"; $rlt_trade_order_b = mysql_query($slt_trade_order_b); $row_trade_order_b = mysql_fetch_assoc($rlt_trade_order_b); $price = $row_trade_order_b["price"]; $amount = min($row_trade_order_a["amount"] - $row_trade_order_a["completed"], $row_trade_order_b["amount"] - $row_trade_order_b["completed"]); if ($amount > 0) { $cur_amount = $amount * $price; $slc_amount = $amount; $cur_trid = add_transaction($row_trade_order_a["user"], "in", "intern", $cur_amount * 0.997, $row_trade_order_a["currency"], "trade_return", $row_trade_order_a["id"], $cur_amount * 0.003); $slc_trid = add_transaction($row_trade_order_b["user"], "in", "intern", $slc_amount, "SLC", "trade_return", $row_trade_order_b["id"], 0); if ($row_trade_order_a["amount"] - $row_trade_order_a["completed"] - $amount <= 1.0E-8) { $udt_trade_order_a = "UPDATE trade_order SET completed = amount, finished = 'yes', active = 'no', finishing_time = NOW() WHERE id = {$row_trade_order_a['id']}"; mysql_query($udt_trade_order_a); } else { $udt_trade_order_a = "UPDATE trade_order SET completed = completed + {$amount} WHERE id = {$row_trade_order_a['id']}"; mysql_query($udt_trade_order_a); } if ($row_trade_order_b["amount"] - $row_trade_order_b["completed"] - $amount <= 1.0E-8) { $udt_trade_order_b = "UPDATE trade_order SET completed = amount, finished = 'yes', active = 'no', finishing_time = NOW() WHERE id = {$row_trade_order_b['id']}"; mysql_query($udt_trade_order_b); } else { $udt_trade_order_b = "UPDATE trade_order SET completed = completed + {$amount} WHERE id = {$row_trade_order_b['id']}"; mysql_query($udt_trade_order_b); } $ins_trade_a = "INSERT INTO trade (type, buy_trade_order, sell_trade_order, currency, slc_transaction, cur_transaction, refund, trade_time, price, amount) " . "VALUES ('sell', {$row_trade_order_b['id']}, {$row_trade_order_a['id']}, '{$currency}', '{$slc_trid}', '{$cur_trid}', '{$ref_trid}', NOW(), {$price}, {$amount})"; mysql_query($ins_trade_a); } } }
function shaper_unset($ip, $dep = null) { global $db; $params = array('addr' => $ip['ip_addr'], 'version' => (int) $ip['ip_v'], 'shaper' => array('class_id' => $ip['class_id'])); add_transaction($_SESSION["member"]["m_id"], $this->ve["vps_server"], $this->veid, T_EXEC_SHAPER_UNSET, $params, null, $dep); return $db->insertId(); }
$new_ledger_info['text_key'] = $_REQUEST['text_key']; // ID for the logged-in member $new_ledger_info['posted_by'] = $_SESSION['member_id']; // Keep all this stuff the same as before $new_ledger_info['basket_id'] = $row_old_ledger_info['basket_id']; $new_ledger_info['bpid'] = $row_old_ledger_info['bpid']; $new_ledger_info['site_id'] = $row_old_ledger_info['site_id']; $new_ledger_info['delivery_id'] = $row_old_ledger_info['delivery_id']; $new_ledger_info['pvid'] = $row_old_ledger_info['pvid']; // We are targeting a specific transaction_id // $new_ledger_info['match_keys'] = array ('transaction_id'); // Create the messages array $messages['ledger comment'] = $_REQUEST['message']; $new_ledger_info['messages'] = $messages; // Post the updated transaction $affected_transaction_id = add_transaction($new_ledger_info); $response .= add_transaction_messages($affected_transaction_id, $new_ledger_info['messages']); } echo $response; exit(0); } //////////////////////////////////////////////////////////////////////////////////// // // // This is the main ajax call to get ledger information for display of // // the adjustment form controls. It will also get display basket information, // // if there is one and handle updates from the form. // // // // REQUIRED arguments: transaction_id=[transaction_id] // // OPTIONAL arguments: bpid=[basket product id] // // // ////////////////////////////////////////////////////////////////////////////////////
} elseif ($row_trade_order_a["currency"] == "NMC") { $currency = "NMC"; $currencyn = "Namecoin"; $currencynp = "Namecoins"; } if ($_GET["ca"] == 1) { if (!get_lock("global")) { die("Too many queries. Please try again later."); } $slt_trade_order_a = "SELECT *, UNIX_TIMESTAMP(filing_time) AS filing_time_u FROM trade_order WHERE id = '{$trade_id}' AND user = '******'user_id']}'"; $rlt_trade_order_a = mysql_query($slt_trade_order_a); $row_trade_order_a = mysql_fetch_assoc($rlt_trade_order_a); if ($row_trade_order_a["active"] == "yes") { if ($row_trade_order_a["type"] == "sell") { $refund = $row_trade_order_a["amount"] - $row_trade_order_a["completed"]; add_transaction($_SESSION["user_id"], "in", "intern", $refund, "SLC", "trade_cancellation", $trade_id); $udt_trade_order_a = "UPDATE trade_order SET active = 'no', finishing_time = NOW() WHERE id = {$row_trade_order_a['id']}"; mysql_query($udt_trade_order_a); } elseif ($row_trade_order_a["type"] == "buy") { $refund = ($row_trade_order_a["amount"] - $row_trade_order_a["completed"]) * $row_trade_order_a["price"]; add_transaction($_SESSION["user_id"], "in", "intern", $refund * 1.004, $currency, "trade_cancellation", $trade_id, -$refund * 0.004); $udt_trade_order_a = "UPDATE trade_order SET active = 'no', finishing_time = NOW() WHERE id = {$row_trade_order_a['id']}"; mysql_query($udt_trade_order_a); } } } if ($row_trade_order_a) { $_PRE["REQUEST_URI"] = "/?c=exchange/order&t={$trade_id}"; } else { $_PRE["REQUEST_URI"] = "/?c=exchange/orders"; }
function save_config($id, $name, $label, $config, $reapply = false) { global $db; $params = array("name" => $name, "config" => $config); if ($id != NULL) { $sql = "UPDATE `config` SET name = '" . $db->check($name) . "',\n\t\t\t label = '" . $db->check($label) . "',\n\t\t\t `config` = '" . $db->check($config) . "'\n\t\t\t WHERE id = '" . $db->check($id) . "'"; $c = $db->findByColumnOnce("config", "id", $id); if ($c["name"] != $name) { $params["old_name"] = $c["name"]; } } else { $sql = "INSERT INTO `config` SET name = '" . $db->check($name) . "',\n\t\t\t label = '" . $db->check($label) . "',\n\t\t\t `config` = '" . $db->check($config) . "'"; } $db->query($sql); $servers = list_servers(false, array('node')); foreach ($servers as $sid => $name) { add_transaction($_SESSION["member"]["m_id"], $sid, 0, T_CLUSTER_CONFIG_CREATE, $params); $dep = $db->insertId(); if ($reapply) { $rs = $db->query("SELECT v.vps_id FROM vps v INNER JOIN vps_has_config c ON v.vps_id = c.vps_id WHERE c.config_id = " . $db->check($id) . " AND vps_server = " . $db->check($sid)); while ($row = $db->fetch_array($rs)) { $vps = vps_load($row["vps_id"]); $vps->applyconfigs($dep); } } } }
function enable_device($device) { global $db; if (isset($this->devices[$device])) { $sql = 'UPDATE vps SET vps_' . $device . '_enabled = "1" WHERE vps_id = ' . $db->check($this->veid); $db->query($sql); if ($db->affected_rows() == 1) { if (isset($this->devices[$device][1])) { add_transaction($_SESSION["member"]["m_id"], $this->ve["vps_server"], $this->veid, T_ENABLE_DEVICES, $this->get_enabled_devices()); } add_transaction($_SESSION["member"]["m_id"], $this->ve["vps_server"], $this->veid, $this->devices[$device][0]); } } }
if (!isset($_GET['cmd'])) { exit; } switch ($_GET['cmd']) { case 0: get_barcodes(); break; case 1: get_product_names(); break; case 2: get_prices(); break; case 3: add_transaction(); break; default: break; } function get_barcodes() { include_once 'product.php'; $obj = new product(); if (!$obj->connect()) { $json = 'connection error'; echo $json; exit; } if ($obj->get_products()) { $row = $obj->fetch();
function process_cryptotransaction($txid, $address, $amount, $time, $currency = "SLC", $print = true) { global $db; $txid = mysql_real_escape_string($txid, $db); $address = mysql_real_escape_string($address, $db); $slt_crypto_transaction_a = "SELECT * FROM crypto_transaction WHERE txid = '{$txid}'"; $rlt_crypto_transaction_a = mysql_query($slt_crypto_transaction_a); if (!mysql_fetch_assoc($rlt_crypto_transaction_a)) { $ins_crypto_transaction_a = "INSERT INTO crypto_transaction (txid) VALUES ('{$txid}')"; mysql_query($ins_crypto_transaction_a); $itxid = mysql_insert_id(); if ($currency == "SLC") { $slt_transfer_deposit_address_a = "SELECT * FROM transfer_deposit_address WHERE address = '{$address}'"; $rlt_transfer_deposit_address_a = mysql_query($slt_transfer_deposit_address_a); if ($row_transfer_deposit_address_a = mysql_fetch_assoc($rlt_transfer_deposit_address_a)) { $ins_transfer_deposit_a = "INSERT INTO transfer_deposit (deposit_address, txid, amount, filing_time, type) VALUES ({$row_transfer_deposit_address_a['id']}, {$itxid}, '{$amount}', FROM_UNIXTIME({$time}), 'extern')"; mysql_query($ins_transfer_deposit_a); $tid = mysql_insert_id(); $slt_transfer_deposit_a = "SELECT SUM(amount) AS amount FROM transfer_deposit WHERE deposit_address = '{$row_transfer_deposit_address_a['id']}'"; $rlt_transfer_deposit_a = mysql_query($slt_transfer_deposit_a); $row_transfer_deposit_a = mysql_fetch_assoc($rlt_transfer_deposit_a); $total_amount = $row_transfer_deposit_a["amount"]; if (deposit_with_fee($amount, 0, $user_id) > 0) { add_transaction($row_transfer_deposit_address_a["user"], "in", "extern", deposit_with_fee($amount, 1, $user_id), "SLC", "transfer_deposit", $tid, $amount - deposit_with_fee($amount, 0, $user_id), $time); } if ($print) { echo "New transfer deposit of {$amount} to {$address} (user {$row_transfer_deposit_address_a['user']}).\n"; } if ($row_transfer_deposit_address_a["send_mail"] == "yes") { $slt_user_c = "SELECT * FROM user WHERE id = '{$row_transfer_deposit_address_a['user']}'"; $rlt_user_c = mysql_query($slt_user_c); $row_user_c = mysql_fetch_assoc($rlt_user_c); $content = ""; $content .= "Dear user,<br />\n<br />\nYou have received " . nice_format($amount, false, 0, 4) . " Solidcoins with your deposit address <a href=\"http://slc24.com/?c=services/transfer/deposit_address&a={$address}\">{$address}</a>.<br />\n<br />\n"; $content .= "More information about this deposit: <a href=\"http://slc24.com/?c=services/transfer/deposit&id={$tid}\">http://slc24.com/?c=services/transfer/deposit&id={$tid}</a><br />\n"; $content .= "More information about this deposit address: <a href=\"http://slc24.com/?c=services/transfer/deposit_address&a={$address}\">http://slc24.com/?c=services/transfer/deposit_address&a={$address}</a><br /><br />\n"; $content .= "Additional information:<br />\n"; $content .= "Type: external<br />\n"; $content .= "Amount received: " . nice_format($amount, false, 0, 4) . " Solidcoins<br />\n"; $content .= "Total amount received: " . nice_format($total_amount, false, 0, 4) . " Solidcoins<br />\n"; if ($row_transfer_deposit_address_a["group"]) { $content .= "Group: " . $row_transfer_deposit_address_a["group"] . "<br />\n"; } if ($row_transfer_deposit_address_a["data"]) { $content .= "Data: " . $row_transfer_deposit_address_a["data"] . "<br />\n"; } $content .= "Fee: " . nice_format($amount - deposit_with_fee($amount, 0, $user_id), false, 0, 4) . " Solidcoins<br />\n<br />\n"; $content .= "Your sc24 team"; send_mail("Deposit of " . nice_format($amount, false, 0, 4) . " Solidcoins received", $content, $row_user_c["email"]); if ($print) { echo "Sent mail to {$row_user_c['email']}.\n"; } } if (strlen($row_transfer_deposit_address_a["callback"]) > 0) { $callback = $row_transfer_deposit_address_a["callback"]; if (!strpos($callback, "?")) { $callback .= "?id={$row_transfer_deposit_address_a['id']}&group=" . urlencode($row_transfer_deposit_address_a["group"]) . "&address={$address}&total_amount=" . nice_format($total_amount, false, 0, 4) . "&new_amount=" . nice_format($amount, false, 0, 4) . "&fee=" . nice_format($amount - deposit_with_fee($amount, 0, $user_id), false, 0, 4) . "&type=extern"; } else { $callback .= "&id={$row_transfer_deposit_address_a['id']}&group=" . urlencode($row_transfer_deposit_address_a["group"]) . "&address={$address}&total_amount=" . nice_format($total_amount, false, 0, 4) . "&new_amount=" . nice_format($amount, false, 0, 4) . "&fee=" . nice_format($amount - deposit_with_fee($amount, 0, $user_id), false, 0, 4) . "&type=extern"; } $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $callback); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); $response = curl_exec($ch); curl_close($ch); if ($print) { echo "Called {$callback}.\nResponse: {$response}\n"; } } return; } $slt_deposit_address_a = "SELECT * FROM deposit_address WHERE currency = 'SLC' AND address = '{$address}'"; $rlt_deposit_address_a = mysql_query($slt_deposit_address_a); if ($row_deposit_address_a = mysql_fetch_assoc($rlt_deposit_address_a)) { if ($amount > 0.01) { $id = add_transaction($row_deposit_address_a["user"], "in", "extern", $amount - 0.01, "SLC", "deposit", $itxid, 0.01, $time); } $udt_address_a = "UPDATE deposit_address SET booked = booked + '{$amount}', used = 'yes' WHERE id = '{$row_deposit_address_a['id']}'"; mysql_query($udt_address_a); if ($print) { echo "New deposit of {$amount} SLC to {$address} (user {$row_deposit_address_a['user']}).\n"; } return; } if ($print) { echo "Unknown action (txid: {$txid}, address: {$address}, amount: {$amount}).\n"; } return; } if ($currency == "BTC") { $slt_deposit_address_a = "SELECT * FROM deposit_address WHERE currency = 'BTC' AND address = '{$address}'"; $rlt_deposit_address_a = mysql_query($slt_deposit_address_a); if ($row_deposit_address_a = mysql_fetch_assoc($rlt_deposit_address_a)) { add_transaction($row_deposit_address_a["user"], "in", "extern", $amount, "BTC", "deposit", $itxid, 0, $time); $udt_address_a = "UPDATE deposit_address SET booked = booked + '{$amount}', used = 'yes' WHERE id = '{$row_deposit_address_a['id']}'"; mysql_query($udt_address_a); if ($print) { echo "New deposit of {$amount} BTC to {$address} (user {$row_deposit_address_a['user']}).\n"; } return; } if ($print) { echo "Unknown action (txid: {$txid}, address: {$address}, amount: {$amount}).\n"; } return; } if ($currency == "NMC") { $slt_deposit_address_a = "SELECT * FROM deposit_address WHERE currency = 'NMC' AND address = '{$address}'"; $rlt_deposit_address_a = mysql_query($slt_deposit_address_a); if ($row_deposit_address_a = mysql_fetch_assoc($rlt_deposit_address_a)) { add_transaction($row_deposit_address_a["user"], "in", "extern", $amount, "NMC", "deposit", $itxid, 0, $time); $udt_address_a = "UPDATE deposit_address SET booked = booked + '{$amount}', used = 'yes' WHERE id = '{$row_deposit_address_a['id']}'"; mysql_query($udt_address_a); if ($print) { echo "New deposit of {$amount} NMC to {$address} (user {$row_deposit_address_a['user']}).\n"; } return; } if ($print) { echo "Unknown action (txid: {$txid}, address: {$address}, amount: {$amount}).\n"; } return; } } }
} break; case "templates_delete": if ($template = $cluster->get_template_by_id($_REQUEST["id"])) { $xtpl->perex(_("Are you sure to delete template") . ' ' . $template["templ_name"] . '?', '<a href="?page=cluster&action=templates">' . _("No") . '</a> | ' . '<a href="?page=cluster&action=templates_delete2&id=' . $template["templ_id"] . '">' . _("Yes") . '</a>'); } break; case "templates_delete2": if ($template = $cluster->get_template_by_id($_REQUEST["id"])) { $usage = $cluster->get_template_usage($template["templ_id"]); if ($usage <= 0) { $nodes_instances = $cluster->list_servers_class(); foreach ($nodes_instances as $node) { $params = array(); $params["templ_id"] = $_REQUEST["id"]; add_transaction($_SESSION["member"]["m_id"], $node->s["server_id"], 0, T_CLUSTER_TEMPLATE_DELETE, $params); } } else { $list_templates = true; } } else { $list_templates = true; } break; case "configs": $xtpl->sbar_add(_("Back"), '?page=cluster'); $list_configs = true; break; case "config_new": $xtpl->sbar_add(_("Back"), '?page=cluster&action=configs'); $xtpl->title2(_("Create config"));
if ($cur_amount * 1.004 > get_balance($_SESSION["user_id"], $currency)) { $errors[] = "You don't have that much."; } if (count($errors) == 0) { $slt_trade_order_a = "SELECT * FROM trade_order WHERE active = 'yes' AND finished = 'no' AND type = 'buy' AND ROUND(price * 100000000) = ROUND({$price} * 100000000) AND currency = '{$currency}' AND user = '******'user_id']}'"; $rlt_trade_order_a = mysql_query($slt_trade_order_a); if (mysql_num_rows($rlt_trade_order_a) == 0) { $ins_trade_order_a = "INSERT INTO trade_order (type, user, currency, price, amount, completed, active, finished, filing_time, change_time, finishing_time) " . "VALUES ('buy', '{$_SESSION['user_id']}', '{$currency}', '{$price}', '{$slc_amount}', '0', 'yes', 'no', NOW(), NOW(), '0000-00-00 00:00:00')"; mysql_query($ins_trade_order_a); $tid = mysql_insert_id(); add_transaction($_SESSION["user_id"], "out", "intern", $cur_amount * 1.004, $currency, "trade_placement", $tid, $cur_amount * 0.004); } else { $row_trade_order_a = mysql_fetch_assoc($rlt_trade_order_a); $udt_trade_order_a = "UPDATE trade_order SET amount = amount + {$slc_amount}, change_time = NOW() WHERE id = {$row_trade_order_a['id']}"; mysql_query($udt_trade_order_a); add_transaction($_SESSION["user_id"], "out", "intern", $cur_amount * 1.004, $currency, "trade_increase", $row_trade_order_a["id"], $cur_amount * 0.004); } } } else { $errors[] = "Invalid type."; } } if (count($errors) != 0) { foreach ($errors as $error) { echo "{$error}<br />"; } echo "<br />"; if ($currency == "NMC") { echo "<a href=\"?c=exchange&u=nmc\">Back to the trading page</a>"; } else { echo "<a href=\"?c=exchange\">Back to the trading page</a>";
$amount = round($amount * 100000000) / 100000000; } if (!get_lock("global")) { die("Too many queries. Please try again later."); } if ($amount > get_balance($_SESSION["user_id"], $currency)) { $errors[] = "You don't have that much."; } $slt_user_a = "SELECT * FROM user WHERE email = '{$recipient}'"; $rlt_user_a = mysql_query($slt_user_a); if (!($row_user_a = mysql_fetch_assoc($rlt_user_a))) { $errors[] = "A user with that email address does not exist."; } if (count($errors) == 0) { add_transaction($_SESSION["user_id"], "out", "intern", $amount, $currency, "internal_transfer"); add_transaction($row_user_a["id"], "in", "intern", $amount, $currency, "internal_transfer"); if ($currency == "SLC") { echo nice_format($amount, false, 0, 4) . " Solidcoins were transferred to " . htmlentities($_POST["recipient"]) . "."; } elseif ($currency == "BTC") { echo nice_format($amount, false, 0, 8) . " Bitcoins were transferred to " . htmlentities($_POST["recipient"]) . "."; } elseif ($currency == "NMC") { echo nice_format($amount, false, 0, 8) . " Namecoins were transferred to " . htmlentities($_POST["recipient"]) . "."; } } } if (count($errors) != 0) { foreach ($errors as $error) { echo $error . "<br />"; } ?> <form action="" method="post">
//mysql_query("LOCK TABLES transfer_withdrawal_address WRITE, transfer_withdrawal, transaction WRITE, transaction WRITE"); $slt_transfer_withdrawal_address_a = "SELECT * FROM transfer_withdrawal_address WHERE id = '{$id}'"; $rlt_transfer_withdrawal_address_a = mysql_query($slt_transfer_withdrawal_address_a); $row_transfer_withdrawal_address_a = mysql_fetch_assoc($rlt_transfer_withdrawal_address_a); if ($row_transfer_withdrawal_address_a["user"] != $user_id) { json_error("Invalid id."); } // START $type = $row_transfer_withdrawal_address_a["type"]; $address = $row_transfer_withdrawal_address_a["address"]; // NO TRANSACTION, NO WITHDRAWAL UNTIL HERE if ($type == "extern") { $itxid = add_transaction($user_id, "out", "extern", withdrawal_with_fee($amount, 1, $user_id), "SLC", "transfer_withdrawal", 0, withdrawal_with_fee($amount, 0, $user_id) - $amount); $tx = withdraw_slc($address, $amount, "", $itxid); } else { $itxid = add_transaction($user_id, "out", "intern", $amount, "SLC", "transfer_withdrawal", 0); $tx = withdraw_slc($address, $amount, "", $itxid); } $ins_transfer_withdrawal_a = "INSERT INTO transfer_withdrawal (withdrawal_address, txid, amount, filing_time) VALUES ({$id}, {$tx['txid']}, '{$amount}', NOW())"; mysql_query($ins_transfer_withdrawal_a); $wid = mysql_insert_id(); // update transaction $udt_transaction_a = "UPDATE transaction SET info_id = '{$wid}' WHERE id = '{$itxid}'"; mysql_query($udt_transaction_a); //mysql_query("UNLOCK TABLES"); if ($type == "extern") { json_success(array("address" => $row_transfer_withdrawal_address_a["address"], "txid" => crypte_transaction($tx["txid"]), "type" => $type)); } else { json_success(array("address" => $row_transfer_withdrawal_address_a["address"], "txid" => $tx["txid"], "type" => $type)); } }
/** * Copies template to all cluster nodes * @param $templ_id - ID of template * @param $source_node - server_id of source node * @return --- */ function copy_template_to_all_nodes($templ_id, $source_node) { global $db; $nodes = $this->list_servers_class($source_node); foreach ($nodes as $node) { $params = array(); $params["templ_id"] = $templ_id; $params["remote_server_id"] = $source_node; add_transaction($_SESSION["member"]["m_id"], $node->s["server_id"], 0, T_CLUSTER_TEMPLATE_COPY, $params); } }