function run_sql_script($scriptlocation) { if ($script = file_get_contents($scriptlocation)) { // global $CONFIG; $errors = array(); $script = preg_replace('/\\-\\-.*\\n/', '', $script); $sql_statements = preg_split('/;[\\n\\r]+/', $script); foreach ($sql_statements as $statement) { $statement = trim($statement); // $statement = str_replace("prefix_",$CONFIG->dbprefix,$statement); if (!empty($statement)) { try { $result = do_query($statement); } catch (Exception $e) { $errors[] = $e->getMessage(); } } } if (!empty($errors)) { $errortxt = ""; foreach ($errors as $error) { $errortxt .= " {$error};"; } throw new Exception('error running script: ' . $scriptlocation . ":" . $errortxt); } } else { throw new Exception('ScriptNotFound:' . $scriptlocation); } }
function show_wahlen($row) { extract($row); $listen_gueltig = $stimmen_gesamt - $stimmzettel_ungueltig - $listen_ungueltig; $listen_summe = $listen_gueltig - $listen_enthaltungen; $kandidaten_gueltig = $stimmen_gesamt - $stimmzettel_ungueltig - $kandidaten_ungueltig; $kandidaten_summe = $kandidaten_gueltig - $kandidaten_enthaltungen; print "\\section{Wahl zum {$wahl_name}}\n"; if (simple_query("SELECT count(*) FROM liste " . "WHERE wahl = {$wahl_id}") > 1) { print "\\subsection*{Listenstimmen}\n"; // Gesamt-Informationen print "Wahlberechtigte: {$wahlberechtigt}, " . "abgegebene Stimmzettel: {$stimmen_gesamt}, " . "Wahlbeteiligung: " . percent($stimmen_gesamt, $wahlberechtigt) . "\\%" . "\n\n" . "ungültige Stimmzettel: {$stimmzettel_ungueltig}, " . "ungültige Stimmen: {$listen_ungueltig} " . "gültige Stimmen: {$listen_gueltig}, " . "\n\n" . "Enthaltungen: {$listen_enthaltungen} " . "\n\n"; print "\\begin{tabular}{lrrrrl}\n" . "Liste & Stimmen & Anteil & Quote & Sitze & \\\\\\hline\n"; // Listen-Tabelle do_query("SELECT liste.name_kurz, liste.name_lang, " . "anzeige_red as r, anzeige_green as g, " . "anzeige_blue as b, " . "hoechstzahl, sitze, los, " . "sum(liste_urne.stimmen) AS stimmen, " . "{$listen_summe} AS summe " . "FROM liste, urne, liste_urne " . "WHERE liste.id = liste_urne.liste " . "AND urne.id = liste_urne.urne " . "AND urne.status = " . $GLOBALS["ok_status"] . " " . "AND wahl = {$wahl_id} " . "GROUP BY liste.id " . "ORDER by liste.nummer", show_listen); print "\\hline\\end{tabular}\n\n"; $num_los = simple_query("SELECT los FROM liste " . "WHERE wahl = {$wahl_id} " . "AND los > 0"); if ($num_los > 0) { print "(+1): ggf. +1 von {$num_los} Restsitzen " . "per Los\n\n"; } } // Kandidaten print "\\subsection*{Kandidierendenstimmen}\n"; // Gesamt-Daten print "Wahlberechtigte: {$wahlberechtigt}, " . "abgegebene Stimmzettel: {$stimmen_gesamt}, " . "Wahlbeteiligung: " . percent($stimmen_gesamt, $wahlberechtigt) . "\\%" . "\n\n" . "ungültige Stimmzettel: {$stimmzettel_ungueltig}, " . "ungültige Stimmen: {$kandidaten_ungueltig}, " . "gültig: {$kandidaten_gueltig} " . "\n\n"; if ($max_stimmen_wert == 1) { print "Enthaltungen: {$kandidaten_enthaltungen} " . "\n\n"; } // Kandidaten do_query("SELECT liste.id AS liste_id, " . "liste.name_kurz AS liste_name_kurz, " . "liste.name_lang AS liste_name_lang, " . "anzeige_red AS r, " . "anzeige_green AS g, " . "anzeige_blue AS b, " . "kandidat.typ AS kandidat_typ, " . "kandidat.status AS status, " . "kandidat.vorname AS kandidat_vorname, " . "kandidat.nachname AS kandidat_nachname, " . "sum(kandidat_urne.stimmen) AS stimmen " . "FROM liste, kandidat, urne, kandidat_urne " . "WHERE kandidat.id = kandidat_urne.kandidat " . "AND urne.id = kandidat_urne.urne " . "AND liste.id = kandidat.liste " . "AND urne.status = " . $GLOBALS["ok_status"] . " " . "AND liste.wahl = {$wahl_id} " . "GROUP BY kandidat.id " . "ORDER BY liste.nummer, liste.id, status, stimmen DESC, " . "kandidat.listenplatz", show_kandidaten); if ($num_los != 0) { print "\\footnotemark{(*)} {$num_los} Restsitze werden per " . "Los auf die gekennzeichneten Listen verteilt.\n\n"; } }
function show_similar_codes($reference) { $reference = strtolower($reference); $result = do_query("\n SELECT deposref, uid FROM users WHERE uid > 1\n UNION\n SELECT deposref, uid FROM old_deposrefs\n ORDER BY deposref\n "); while ($row = mysql_fetch_assoc($result)) { $deposref = strtolower($row['deposref']); $scores[$deposref] = round((9 + similar_text($reference, $deposref) - levenshtein($reference, $deposref)) * 100 / 18); $uid[$deposref] = $row['uid']; } arsort($scores); $first = true; foreach ($scores as $deposref => $score) { if ($score >= 50) { if ($first) { $first = false; echo "<p>" . _("Did you mean one of these? Higher percentage = closer match.") . "</p>\n"; echo "<p>" . _("Click an entry to copy it to the form below, then click 'Deposit' again.") . "</p>\n"; echo "<table class='display_data'>\n"; echo "<tr><th>Reference</th><th>Match</th><th>UID</th></tr>\n"; } $formatted = format_deposref($deposref); echo "<tr", " class=\"me\"", " onmouseover=\"style.backgroundColor='#8ae3bf';\"", " onmouseout=\"style.backgroundColor='#7ad3af';\"", " onclick=\"ObjById('reference').value = '{$deposref}';\">"; echo "<td>{$formatted}</td><td>{$score}%</td><td>{$uid[$deposref]}</td></tr>\n"; } } if (!$first) { echo "</table>\n"; } }
function run_query() { if ($_GET["search_str"] != "") { $tmp_var = do_query($_GET["search_str"]); echo json_encode($tmp_var); } else { echo json_encode(array("-1" => array(""))); } }
function get_count() { global $DB_TABLE; $result = do_query("SELECT DISTINCT (id) AS count FROM {$DB_TABLE}"); $i = 0; while ($row = mysql_fetch_array($result)) { $items[$i]['count'] = $row['count']; $i++; } return $items; }
function delete_entry($mode, $sendername, $senderdomain, $src) { global $deleted; if ($mode == "email") { $query = "DELETE FROM from_awl WHERE sender_name='" . addslashes($sendername) . "' AND sender_domain='" . addslashes($senderdomain) . "' AND src='" . addslashes($src) . "'"; $deleted .= "<br />" . $sendername . "@" . $senderdomain . " (" . $src . ") deleted."; } else { $query = "DELETE FROM domain_awl WHERE sender_domain='" . addslashes($senderdomain) . "' AND src='" . addslashes($src) . "'"; $deleted .= "<br />" . $senderdomain . " (" . $src . ") deleted."; } do_query($query); }
function get_users_graph_data() { $users = array(); $query = "\n SELECT " . sql_format_date('timest') . " AS timest2\n FROM\n users\n WHERE\n uid != 1\n ORDER BY\n timest;\n "; $result = do_query($query); $count = 0; while ($row = mysql_fetch_array($result)) { $timest = $row['timest2']; $count++; $users[$timest] = $count; } return $users; }
function del_older_than($year, $month, $day, $hour, $minute, $seconds, $err) { global $warning, $message; if ($err) { $warning = "Aborted: invalid date."; } else { $nicedate = $year . '-' . substr("00" . $month, -2, 2) . '-' . substr("00" . $day, -2, 2) . ' ' . substr("00" . $hour, -2, 2) . ':' . substr("00" . $minute, -2, 2) . ':' . substr("00" . $seconds, -2, 2); $query = "DELETE FROM connect WHERE first_seen < " . $year . substr("00" . $month, -2, 2) . substr("00" . $day, -2, 2) . substr("00" . $hour, -2, 2) . substr("00" . $minute, -2, 2) . substr("00" . $seconds, -2, 2); do_query($query); $message = 'Entries older than ' . $nicedate . ' deleted.'; $warning = "<br />Sorting set to 'Seen at' (ascending)."; } }
function make_interval_select($current) { $rows = array(); $sql = "select seconds, name from intervals order by seconds"; $result = do_query($sql); while ($row = mysqli_fetch_array($result)) { $row['link'] = makelink("interval", $row['seconds']); if ($row['seconds'] == $current) { $row['selected'] = "selected"; } else { $row['selected'] = ""; } array_push($rows, $row); } return $rows; }
function show_withdrawals() { echo "<div class='content_box'>\n"; echo "<h3>" . _("Withdraw requests") . "</h3>\n"; $result = do_query("\n SELECT requests.reqid as reqid, uid, amount, " . sql_format_date("timest") . " as timest, name, bank, acc_num, sort_code\n FROM requests\n JOIN uk_requests\n ON uk_requests.reqid = requests.reqid\n WHERE req_type = 'WITHDR'\n AND curr_type = '" . CURRENCY . "'\n AND status = 'VERIFY'"); $first = true; while ($row = mysql_fetch_assoc($result)) { if ($first) { $first = false; echo "<table class='display_data'>\n"; echo "<tr>"; // echo "<th>User</th>"; echo "<th>" . CURRENCY . "</th>"; echo "<th>Time</th>"; echo "<th>Name</th>"; echo "<th>Bank</th>"; echo "<th>Account#</th>"; echo "<th>BSB</th>"; echo "</tr>\n"; } $reqid = $row['reqid']; // $uid = $row['uid']; $amount = internal_to_numstr($row['amount']); $timest = $row['timest']; $name = $row['name']; $bank = $row['bank']; $acc_num = $row['acc_num']; $sort_code = $row['sort_code']; echo "<tr>"; echo active_table_row("me", "?page=view_request&reqid={$reqid}&show_finish"); // echo "<td>$uid</td>"; echo "<td>{$amount}</td>"; echo "<td>{$timest}</td>"; echo "<td>{$name}</td>"; echo "<td>{$bank}</td>"; echo "<td>{$acc_num}</td>"; echo "<td>{$sort_code}</td>"; echo "</tr>\n"; } if ($first) { echo "<p>No pending withdrawals.</p>\n"; } else { echo "</table>\n"; } echo "</div>\n"; }
function summa($type) { $total_in = gmp_init('0'); $query = "\n SELECT SUM(amount) AS sum\n FROM purses\n WHERE type='{$type}'\n "; $result = do_query($query); $row = get_row($result); $v = gmp_init($row['sum']); $total_in = gmp_add($total_in, $v); $query = "\n SELECT SUM(amount) AS sum\n FROM orderbook\n WHERE type='{$type}' AND status='OPEN'\n "; $result = do_query($query); $row = get_row($result); if (isset($row['sum'])) { $v = gmp_init($row['sum']); $total_in = gmp_add($total_in, $v); } $query = "\n SELECT SUM(amount) AS sum\n FROM requests\n WHERE curr_type='{$type}' AND req_type='WITHDR' AND status='VERIFY'\n "; $result = do_query($query); $row = get_row($result); if (isset($row['sum'])) { $v = gmp_init($row['sum']); $total_in = gmp_add($total_in, $v); } $total_in = gmp_strval($total_in); $total_out = gmp_init('0'); $query = "\n SELECT SUM(amount) AS sum\n FROM requests\n WHERE curr_type='{$type}' AND req_type='DEPOS' AND status='FINAL'\n "; $result = do_query($query); $row = get_row($result); if (isset($row['sum'])) { $v = gmp_init($row['sum']); $total_out = gmp_add($total_out, $v); } $query = "\n SELECT SUM(amount) AS sum\n FROM requests\n WHERE curr_type='{$type}' AND req_type='WITHDR' AND status='FINAL'\n "; $result = do_query($query); $row = get_row($result); if (isset($row['sum'])) { $v = gmp_init($row['sum']); $total_out = gmp_sub($total_out, $v); } $total_out = gmp_strval($total_out); echo "{$type} = {$total_in}\t {$total_out}\n"; if (gmp_cmp($total_in, $total_out) != 0) { echo "*********** MISMATCH ****************\n"; } }
function get_orders() { global $is_logged_in; $result = do_query("\n SELECT\n orderid, initial_amount, amount, type, initial_want_amount, want_amount, want_type\n FROM\n orderbook\n WHERE\n status = 'OPEN'\n AND\n uid = {$is_logged_in}\n "); $orders = array(); while ($row = mysql_fetch_array($result)) { $orderid = $row['orderid']; $have_amount = $row['amount']; $have_currency = $row['type']; $want_amount = $row['want_amount']; $want_currency = $row['want_type']; if ($have_currency == 'BTC') { $text = sprintf("%s %s %s %s %s %s", _("Sell"), internal_to_numstr($have_amount, BTC_PRECISION), $have_currency, _("for"), internal_to_numstr($want_amount, FIAT_PRECISION), $want_currency); } else { $text = sprintf("%s %s %s %s %s %s", _("Buy"), internal_to_numstr($want_amount, BTC_PRECISION), $want_currency, _("for"), internal_to_numstr($have_amount, FIAT_PRECISION), $have_currency); } array_push($orders, array('orderid' => $orderid, 'text' => $text, 'have_amount' => internal_to_numstr($have_amount), 'have_currency' => $row['type'], 'want_amount' => internal_to_numstr($want_amount), 'want_currency' => $want_currency)); } return $orders; }
function get_article($id) { if (!($entry_all = return_query("SELECT * FROM enz_entries WHERE entry_id={$id}"))) { return 0; } $entry = $entry_all[0]; if ($cache_all = return_query("SELECT * FROM enz_cache WHERE cache_id={$id}")) { if ($cache_all[0]['creation_date'] + 604800 > time()) { $entry[text] = $cache_all[0][cached_text]; } else { $entry = update_crosslinks($entry); do_query("UPDATE enz_cache SET cached_text='{$entry['text']}',creation_date=" . time() . " WHERE cache_id={$id}"); } } else { $entry = update_crosslinks($entry); do_query("INSERT INTO enz_cache (cache_id,cached_text,creation_date) VALUES ({$id},'{$entry['text']}'," . time() . ")"); } $entry['text'] = stripslashes($entry['text']); $entry['titel'] = stripslashes($entry['titel']); return $entry; }
function fetch_depth($rate_query, $field, $have, $want) { $ret = array(); $minimum_btc_amount = numstr_to_internal(MINIMUM_BTC_AMOUNT); $minimum_fiat_amount = numstr_to_internal(MINIMUM_FIAT_AMOUNT); if ($have == "BTC") { $big_enough = "amount >= {$minimum_btc_amount} AND want_amount >= {$minimum_fiat_amount}"; } else { $big_enough = "amount >= {$minimum_fiat_amount} AND want_amount >= {$minimum_btc_amount} "; } $query = "\n SELECT\n {$rate_query} AS rate,\n {$field} as amount\n FROM\n orderbook\n WHERE\n type='{$have}'\n AND want_type='{$want}'\n AND status='OPEN'\n AND {$big_enough}\n ORDER BY\n rate DESC\n "; $result = do_query($query); while ($row = mysql_fetch_assoc($result)) { $amount = internal_to_numstr($row['amount']); $rate = $row['rate']; //bitcoincharts uses NUMERIC(18,8) if ($rate < 1000000000) { array_push($ret, "[{$rate}, {$amount}]"); } } return implode($ret, ", "); }
function bitcoin_withdraw($uid, $amount, $curr_type, &$voucher_code, &$reqid) { $voucher = isset($_POST['voucher']); if ($voucher) { syslog(LOG_NOTICE, "address=voucher"); $query = "\n INSERT INTO requests (req_type, uid, amount, curr_type)\n VALUES ('WITHDR', '{$uid}', '{$amount}', '{$curr_type}');\n "; } else { $addy = post('address'); try { $validaddy = bitcoin_validate_address($addy); } catch (Exception $e) { if ($e->getMessage() != 'Unable to connect.') { throw $e; } throw new Problem(_("Sorry..."), _("We are currently experiencing trouble connecting to the Bitcoin network and so cannot verify that you entered a valid Bitcoin address.") . "</p><p>" . _("Your withdrawal request has been cancelled.") . "</p><p>" . _("Please try again in a few minutes.")); } if (!$validaddy['isvalid']) { throw new Problem(_('Bitcoin says no'), _('That address you supplied was invalid.')); } syslog(LOG_NOTICE, "address={$addy}"); $we_have = bitcoin_get_balance("*", 0); if (gmp_cmp($we_have, $amount) <= 0) { $message = sprintf(_("User %s is asking to withdraw %s BTC. We only have %s BTC."), $uid, internal_to_numstr($amount, BTC_PRECISION), internal_to_numstr($we_have, BTC_PRECISION)); email_tech(_("Exchange Wallet Balance is Too Low"), $message); } $query = "\n INSERT INTO requests (req_type, uid, amount, curr_type)\n VALUES ('WITHDR', '{$uid}', '{$amount}', '{$curr_type}');\n "; } endlog(); do_query($query); $reqid = mysql_insert_id(); if ($voucher) { $voucher_code = store_new_bitcoin_voucher_code($reqid); } else { $query = "\n INSERT INTO bitcoin_requests (reqid, addy)\n VALUES ('{$reqid}', '{$addy}');\n "; do_query($query); } }
function show_links($is_logged_in, $is_admin, $is_verified) { $show_duo = 0; if ($is_logged_in) { require_once 'db.php'; $result = do_query("SELECT use_duo FROM users WHERE uid={$is_logged_in}"); $row = get_row($result); $show_duo = !$row['use_duo']; } if (!$is_logged_in) { show_link('login', _('Login'), _('Begin here')); } show_link('news', _('News'), _("What's new?")); show_link('trade', _('Trade'), _('Buy and sell')); if ($is_logged_in) { show_link('profile', _('Profile'), _('Dox on you')); } if ($is_logged_in) { show_link('statement', _('Statement'), _('Chronological ledger')); } if ($is_logged_in) { show_link('deposit', _('Deposit'), _('Top up your account')); } if ($is_logged_in) { show_link('withdraw', _('Withdraw'), _('Take out money')); } show_link('orderbook', _('Orderbook'), _('Show orders')); if ($show_duo) { show_link('turn_on_duo', _('Security'), _('Use two-factor authentification')); } if ($is_logged_in && !$is_verified) { show_link('identity', _('Identify'), _('Upload ID to get your account verified')); } if (CHARTS_PAGE) { printf("<li><a target='_blank' href='%s'>%s</a>%s\n", CHARTS_PAGE, _('Charts'), _('From bitcoincharts.com')); } show_link('help', _('Help'), _('Seek support')); if ($is_admin) { show_link('docs', _('Docs'), _('Show docs from unverified users'), 1); } if ($is_admin) { show_link('users', _('Users'), _('Show registered users'), 1); } if ($is_admin) { show_link('add_cash', _('Add cash'), _('Deposit using bank statement'), 1); } if ($is_admin) { show_link('commission', _('Commission'), _('Show commission statement'), 1); } if ($is_admin) { show_link('bank', _('Bank'), _('Show bank statement & pending withdrawals'), 1); } if ($is_admin) { show_link('freeze', _('Freeze'), _('Stop activity on the exchange'), 1); } if ($is_admin) { show_link('graph', _('Charts'), _('Various admin graphs'), 1); } if ($is_logged_in) { show_link('logout', _('Logout'), _('End this session')); } echo "<br/><g:plusone annotation=\"bubble\" href=\"https://www.worldbitcoinexchange.com/\"></g:plusone>\n"; }
$query = $_POST['query']; if (isset($_POST['time'])) { if ($other != "") { printf("%s <br />", $other); } $info = sprintf("OK, 明天%s点我们在深圳湾口岸集合, 不见不散!", $time); printf("%s <br />", $info); do_save($info); } else { if ($other != "") { $info = sprintf("%s", $other); printf("%s <br />", $info); do_save($info); } else { if ($query == "查询") { do_query(); } else { if (isset($_POST['other'])) { printf("你还没有回答我呢!<br />"); } } } } function connect_db(&$link) { $link = mysql_connect('localhost', 'test', '123456'); if (!$link) { die('Could not connect: ' . mysql_error()); } echo 'Connected successfully <br \\>'; $db = "research";
function show_api_keys() { global $is_logged_in, $is_admin; echo "<div class='content_box'>\n"; echo "<h3>" . _("API Keys") . "</h3>\n"; $result = do_query("\n SELECT\n name, api_key, secret,\n can_read,\n can_trade,\n can_withdraw,\n can_deposit\n FROM\n api_keys\n WHERE\n uid = {$is_logged_in}\n ORDER BY\n name\n "); $first = true; $count = 0; while ($row = mysql_fetch_array($result)) { if ($first) { $first = false; } $count++; $name = $row['name']; $key = $row['api_key']; $secret = $row['secret']; $can_read = $row['can_read']; $can_trade = $row['can_trade']; $can_withdraw = $row['can_withdraw']; $can_deposit = $row['can_deposit']; echo "<form action='' class='indent_form' method='post'>\n"; echo "<table class='display_data'>\n"; echo "<tr><th class='right'>" . _("Name") . "</th><th>{$name}</th></tr>\n"; echo "<tr><th class='right'>" . _("Key") . "</th><td class='small_mono'>{$key}</td></tr>\n"; echo "<tr><th class='right'>" . _("Secret") . "</th><td class='small_mono'>{$secret}</td></tr>\n"; echo "<tr><th class='right'>" . _("Permissions") . "</th><td>"; ?> <input type='hidden' name='csrf_token' value="<?php echo $_SESSION['csrf_token']; ?> " /> <input type='hidden' name='update_permissions' value='true' /> <input type='hidden' name='name' value='<?php echo $name; ?> ' /> <input type='checkbox' id='read<?php echo $count; ?> ' name='read' value='1'<?php if ($can_read) { echo " checked='checked'"; } ?> /> <label style="margin: 0px; display: inline;" for='read<?php echo $count; ?> '>read</label> <input type='checkbox' id='trade<?php echo $count; ?> ' name='trade' value='1'<?php if ($can_trade) { echo " checked='checked'"; } ?> /> <label style="margin: 0px; display: inline;" for='trade<?php echo $count; ?> '>trade</label> <input type='checkbox' id='withdraw<?php echo $count; ?> ' name='withdraw' value='1'<?php if ($can_withdraw) { echo " checked='checked'"; } ?> /> <label style="margin: 0px; display: inline;" for='withdraw<?php echo $count; ?> '>withdraw</label> <input type='checkbox' id='deposit<?php echo $count; ?> ' name='deposit' value='1'<?php if ($can_deposit) { echo " checked='checked'"; } ?> /> <label style="margin: 0px; display: inline;" for='deposit<?php echo $count; ?> '>deposit</label> </td></tr> <tr><td></td><td> <input type='submit' value='<?php echo _("Update Permissions"); ?> ' /> </form> <form action='' method='post' style='display: inline'> <input type='hidden' name='csrf_token' value="<?php echo $_SESSION['csrf_token']; ?> " /> <input type='hidden' name='delete_key' value='true' /> <input type='hidden' name='name' value='<?php echo $name; ?> ' /> <input type='submit' value='<?php echo _("Delete Key"); ?> ' /> </form> </td></tr> </table> <?php } if ($first) { echo "<p>You currently have no API keys.</p>\n"; } ?> </div> <div class='content_box'> <h3>Create New API Key</h3> <p> <form action='' class='indent_form' method='post'> <input type='hidden' name='csrf_token' value="<?php echo $_SESSION['csrf_token']; ?> " /> <input type='hidden' name='add_key' value='true' /> <label for='name'><?php echo _("Name"); ?> </label> <input id='name' type='text' name='name' value='my key' /> <p><?php echo _("Permissions"); ?> </p> <input id='read' type='checkbox' name='read' value='1' checked='checked' /> <label style="margin: 0px; display: inline;" for='read'>read</label> <input id='trade' type='checkbox' name='trade' value='1' /> <label style="margin: 0px; display: inline;" for='trade'>trade</label> <input id='withdraw' type='checkbox' name='withdraw' value='1' /> <label style="margin: 0px; display: inline;" for='withdraw'>withdraw</label> <input id='deposit' type='checkbox' name='deposit' value='1' /> <label style="margin: 0px; display: inline;" for='deposit'>deposit</label> <br/><br/><input type='submit' value='Add New API Key' /> </form> </p> <?php echo "</div>\n"; }
$index = $_POST['index']; $task = trim(preg_replace('/\\s{2,}/', ' ', $_POST['task'])); $answer = trim(preg_replace('/\\s{2,}/', ' ', $_POST['content'])); $task = htmlspecialchars($task, ENT_QUOTES); $strSQL = "INSERT INTO `task` (`content_id`, `index`, `task`, `answer`)\n VALUES ('{$content_id}', '{$index}', '{$task}', '{$answer}')"; $ins_paragraph = do_query($strSQL); echo "<meta http-equiv='refresh' content='0; url=post.php?content_id={$content_id}'>"; // header("Location: post.php?content_id=".$content_id); } ?> <div class="content"> <?php $strSQL = "SELECT * FROM task WHERE content_id={$content_id} ORDER BY `index` ASC"; $content_arr = do_query($strSQL); while ($content = mysql_fetch_array($content_arr)) { ?> <p> <div class="task"><?php echo $content['index'] . '. ' . $content['task']; ?> </div> <div class="answer"><?php echo '<p>' . $content['answer'] . '</p>'; ?> </div> <div><a href="<?php echo '?content_id=' . $content_id . '&task=' . $content['task_id']; ?> ">Изменить</a></div>
$table = "netflow_asn_" . $direction; $sql = "select " . $asq . " asq, as_name, "; $sql .= "sum(bytes)*8*" . $sampling_rate . "/" . $interval . " traffic, "; $sql .= "sum(packets)*" . $sampling_rate . "/" . $interval . " pps "; $sql .= "from " . $table . ",asn "; $sql .= "where " . $asq . "=as_number "; if ($if != "") { $sql .= "and tag = " . $if . " "; } if ($cust != "") { $sql .= "and tag2 = " . $cust . " "; } $sql .= "and stamp_inserted between '" . $stamp_min . "' and '" . $stamp_max . "' "; $sql .= "group by " . $asq . " order by sum(bytes) desc limit " . $entry_limit; $result = do_query($sql); $total_traffic = 0; $total_pps = 0; $rows = array(); while ($row = mysqli_fetch_array($result)) { array_push($rows, $row); $total_traffic += $row['traffic']; $total_pps += $row['pps']; } /* clean formating */ foreach ($rows as $key => $row) { $traffic = formatUnit($row['traffic']); $pps = formatUnit($row['pps']); $rows[$key]['traffic'] = $traffic; $rows[$key]['pps'] = $pps; }
function update_4_15_2015() { do_query("alter table forum\n alter timestamp set default 0,\n alter threads set default 0,\n alter posts set default 0,\n alter rate_min_expavg_credit set default 0,\n alter rate_min_total_credit set default 0,\n alter post_min_interval set default 0,\n alter post_min_expavg_credit set default 0,\n alter post_min_total_credit set default 0,\n alter parent_type set default 0\n "); }
</tr> <?php /* form query */ $select_fields = join(", ", $fields["columns"]); $query = "SELECT {$select_fields} FROM {$dbprefix}tickets WHERE "; if ($type == "My") { $query .= "type = 'Open' AND (assignment = '{$AppUI->user_id}' OR assignment = '0') AND "; } else { if ($type != "All") { $query .= "type = '{$type}' AND "; } } $query .= "parent = '0' ORDER BY " . urlencode($column) . " {$direction} LIMIT {$offset}, {$limit}"; /* do query */ $result = do_query($query); $parent_count = number_rows($result); /* output tickets */ if ($parent_count) { print "<tr>\n"; for ($loop = 0; $loop < count($fields["headings"]); $loop++) { print "<th align=" . $fields["aligns"][$loop] . ">"; print "<a href=\"?m=ticketsmith&type={$type}"; print "&column=" . $fields["columns"][$loop]; if ($column != $fields["columns"][$loop]) { $new_direction = "ASC"; } else { if ($direction == "ASC") { $new_direction = "DESC"; } else { $new_direction == "ASC";
print "<td bgcolor=\"{$color}\"><a href=\"index.php?m=ticketsmith&a=view&ticket=" . $row["ticket"] . "\">" . $AppUI->_($row["type"]) . "</a></td>\n"; /* do timestamp */ print "<td bgcolor=\"{$color}\">\n"; print get_time_ago($row["timestamp"]); print "</td>\n"; /* end row */ print "</tr>\n"; } print "</table>\n"; } else { print "<em>" . $AppUI->_('none') . "</em>\n"; } print "</td>\n</tr>\n"; } else { /* get peer followups */ $results = do_query("SELECT ticket, type FROM tickets WHERE parent = '{$ticket_parent}' ORDER BY ticket " . $CONFIG["followup_order"]); /* parse followups */ while ($row = result2hash($results)) { $peer_tickets[] = $row["ticket"]; } /* count peers */ $peer_count = count($peer_tickets); if ($peer_count > 1) { /* start row */ print "<tr>\n"; print "<td><strong>Followups</strong></td>\n"; /* start cell */ print "<td valign=\"middle\">"; /* form peer links */ for ($loop = 0; $loop < $peer_count; $loop++) { if ($peer_tickets[$loop] == $ticket) {
// header("Location: edit.php?content_id=".$cnt_id); } $typehist = $_SESSION['work_type']; $classhist = $_SESSION['class']; if (isset($classhist)) { $class = $classhist; $cw_f = "AND `class`={$class}"; } if (isset($typehist)) { $type = $typehist; $cw_f = $cw_f . " AND `work_type`='{$type}'"; } $strSQL = "SELECT * FROM content WHERE section_id={$section_id} {$cw_f} ORDER BY `index` DESC"; $histadded = do_query($strSQL); $strSQL2 = "SELECT `index` FROM `content` WHERE `section_id`={$section_id} {$cw_f} ORDER BY `index` DESC LIMIT 1"; $res2 = do_query($strSQL2); $count = mysql_fetch_array($res2); $count1 = $count[0] + 1; switch ($typehist) { case 'theme': $theme = 'checked'; break; case 'pract': $pract = 'checked'; break; case 'lab': $lab = 'checked'; break; case 'ticket': $ticket = 'checked'; break;
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=266 ; EOS ); do_query("UPDATE db_version SET version = 11"); $db->commit(); echo "... DB now at version 11! <br />"; } if ($version < 12) { // Fixes to the pairing updates echo "Updating to version 12 (final changes for the pairing)... <br />"; do_query("ALTER TABLE matches MODIFY COLUMN result VARCHAR(5) not null"); do_query("UPDATE db_version SET version = 12"); $db->commit(); echo "... DB now at version 12! <br />"; } if ($version < 13) { echo "Updating to version 13 (add players_editdecks to events)... <br />"; do_query("ALTER TABLE events ADD COLUMN player_editdecks TINYINT(1) NOT NULL DEFAULT '1'"); do_query("UPDATE events SET player_editdecks = (finalized != 1)"); do_query("UPDATE db_version SET version = 13"); $db->commit(); echo "... DB now at version 13! <br />"; } if ($version < 14) { echo "Updating to version 14 (add drop_round to entries)... <br />"; do_query("ALTER TABLE entries ADD COLUMN drop_round INTEGER"); do_query("UPDATE db_version SET version = 14"); $db->commit(); echo "... DB now at version 14! <br />"; } $db->autocommit(TRUE);
function display_double_entry($curr_a, $curr_b, $base_curr, $uid, $is_admin) { if (isset($_GET['show_all']) && get('show_all') == 'true') { $show_all = true; } else { $show_all = false; } echo "<div class='content_box'>\n"; if ($curr_a == 'BTC') { echo "<h3>" . sprintf(_("People selling %s for %s"), $curr_a, $curr_b) . "</h3>\n"; } else { echo "<h3>" . sprintf(_("People buying %s for %s"), $curr_b, $curr_a) . "</h3>\n"; } $exchange_fields = calc_exchange_rate($curr_a, $curr_b, $base_curr); if (!$exchange_fields) { if ($curr_a == 'BTC') { echo "<p>" . sprintf(_("Nobody is selling %s for %s."), $curr_a, $curr_b) . "</p>"; } else { echo "<p>" . sprintf(_("Nobody is buying %s for %s."), $curr_b, $curr_a) . "</p>"; } echo "</div>"; return; } list($total_amount, $total_want_amount, $rate) = $exchange_fields; echo "<p>" . _("Best exchange rate is") . " "; if ($base_curr == BASE_CURRENCY::A) { echo "<b>{$rate} {$curr_b}/{$curr_a}</b>"; } else { echo "<b>{$rate} {$curr_a}/{$curr_b}</b>"; } echo ".</p>"; if (!$show_all) { echo "<p>" . sprintf(_("Showing top %d entries"), DEFAULT_ORDERBOOK_DEPTH) . ":</p>"; } ?> <table class='display_data'> <tr> <th><?php echo _("Cost / BTC"); ?> </th> <th><?php echo _("Giving"); ?> </th> <th><?php echo _("Wanted"); ?> </th> <?php if ($is_admin) { ?> <th><?php echo _("User"); ?> </th> <?php } if (SHOW_CUMULATIVE_DEPTH) { ?> <th><?php echo _("Cumulative Give"); ?> </th> <th><?php echo _("Cumulative Want"); ?> </th> <?php } ?> </tr><?php $show_query = 'LIMIT ' . DEFAULT_ORDERBOOK_DEPTH; if ($show_all) { $show_query = ''; } $query = "\n SELECT\n orderid,\n amount,\n want_amount,\n uid={$uid} as me,\n uid,\n IF(\n type='BTC',\n initial_want_amount/initial_amount,\n initial_amount/initial_want_amount\n ) AS rate\n FROM orderbook\n WHERE type='{$curr_a}' AND want_type='{$curr_b}' AND status='OPEN'\n ORDER BY\n IF(type='BTC', rate, -rate) ASC, timest ASC\n {$show_query}\n "; $result = do_query($query); $cumulative_curr_a = 0; $cumulative_curr_b = 0; if ($curr_a == 'BTC') { $precision_a = BTC_PRECISION; $precision_b = FIAT_PRECISION; } else { $precision_a = FIAT_PRECISION; $precision_b = BTC_PRECISION; } while ($row = mysql_fetch_array($result)) { $amount_i = $row['amount']; $amount = internal_to_numstr($amount_i, $precision_a); $cumulative_curr_a = gmp_add($cumulative_curr_a, $amount_i); $want_amount_i = $row['want_amount']; $want_amount = internal_to_numstr($want_amount_i, $precision_b); $cumulative_curr_b = gmp_add($cumulative_curr_b, $want_amount_i); // MySQL kindly computes this for us. // we trim the excessive 0 $rate = clean_sql_numstr($row['rate']); $me = $row['me']; $uid = $row['uid']; if ($me) { echo " ", active_table_row("me", "?page=view_order&orderid={$row['orderid']}"); } else { echo " ", active_table_row("them", "?page=trade&in={$curr_b}&have={$want_amount_i}&want={$amount_i}&rate={$rate}"); } echo " <td>{$rate}</td>\n"; echo " <td>{$amount} {$curr_a}</td>\n"; echo " <td>{$want_amount} {$curr_b}</td>\n"; if ($is_admin) { echo " <td>{$uid}</td>\n"; } if (SHOW_CUMULATIVE_DEPTH) { echo " <td>" . internal_to_numstr($cumulative_curr_a, $precision_a) . " {$curr_a}</td>\n"; echo " <td>" . internal_to_numstr($cumulative_curr_b, $precision_b) . " {$curr_b}</td>\n"; } echo " </tr>\n"; } echo " <tr>\n"; echo " <td>" . _("Total") . ":</td>\n"; // strstr's 3rd argument only works in PHP 5.3.0 and newer // http://php.net/manual/en/function.strstr.php // use explode instead $total_amount = explode('.', $total_amount, 2); $total_amount = $total_amount[0]; echo " <td>{$total_amount} {$curr_a}</td>\n"; echo " <td></td>\n"; echo " </tr>\n"; echo "</table>\n"; if ($show_all) { echo "<p><a href='?page=orderbook&show_all=false'>>> " . _("hide") . "</a></p>\n"; } else { echo "<p><a href='?page=orderbook&show_all=true'>>> " . _("show all") . "</a></p>\n"; } echo "</div>\n"; }
function api_update_nonce($key, $old_nonce, $new_nonce) { if (gmp_cmp($old_nonce, $new_nonce) < 0) { do_query("UPDATE api_keys SET nonce = '{$new_nonce}' WHERE api_key = '{$key}'"); } else { throw new Exception("nonce should be monotonically increasing"); } }
function kandidatenliste() { do_query("SELECT " . "wahl.id AS wahl_id," . "wahl.name_lang AS wahl_name," . "wahl.max_stimmen_wert AS wahl_max_stimmen," . "wahl.max_kumulieren_wert AS wahl_max_kumulieren," . "wahl.panaschieren AS wahl_panaschieren," . "liste.id AS liste_id," . "liste.name_kurz AS liste_kurz," . "liste.name_lang AS liste_lang," . "liste.nummer AS liste_nummer," . "kandidat.typ AS kandidat_typ," . "kandidat.vorname AS kandidat_vorname," . "kandidat.nachname AS kandidat_nachname," . "kandidat.fach AS kandidat_extra," . "kandidat.listenplatz AS kandidat_listenplatz " . "FROM wahl, liste, kandidat " . "WHERE wahl.id = liste.wahl " . "AND liste.id = kandidat.liste " . "ORDER BY wahl.name_kurz, wahl.id, " . " liste.nummer, kandidat.listenplatz", do_row); }
function getAllSubCategories() { $query = sprintf("SELECT c.category_name, s.subcategory_name\n\t\t\tFROM categories c\n\t\t\tJOIN subcategories s \n\t\t\tON c.category_id = s.category_id"); $results = do_query($query); if ($results) { $rows = parse_categories($results); return array("status" => 1, "title" => "Success", "msg" => "Succesfully retrieved subcategories.", "results" => $rows); } else { return array("status" => 0, "title" => "Failure", "msg" => "Failed to connect to server."); } }
require_once '../../util.php'; if (count($argv) < 3) { echo "fix_badref [bank statement ID (bid)] [deposref]\n"; exit(-1); } $bid = $argv[1]; $deposref = $argv[2]; $query = "\n SELECT entry\n FROM bank_statement\n WHERE\n bid='{$bid}'\n AND reqid IS NULL\n AND status='BADREF'\n "; $result = do_query($query); if (!has_results($result)) { echo "No results found for bank statement {$bid}...\n"; exit(-1); } $row = get_row($result); $entry = $row['entry']; $entry = split(',', $entry); $amount = $entry[6]; $amount = numstr_to_internal($amount); $query = "\n SELECT uid\n FROM users\n WHERE deposref='{$deposref}'\n "; $result = do_query($query); if (!has_results($result)) { echo "No user found with deposref of {$deposref}...\n"; exit(-1); } $row = get_row($result); $uid = $row['uid']; $query = "\n INSERT INTO requests (\n req_type,\n uid,\n amount,\n curr_type\n ) VALUES (\n 'DEPOS',\n {$uid},\n {$amount},\n '" . CURRENCY . "'\n )"; do_query($query); $query = "\n UPDATE bank_statement\n SET\n reqid=LAST_INSERT_ID(),\n status='FINAL'\n WHERE\n bid='{$bid}'\n AND reqid is NULL\n AND status='BADREF'\n "; do_query($query); echo "Done.\n";