Esempio n. 1
0
function login($username, $password)
{
    global $session;
    $userinfo = api_query("query", "meta=userinfo");
    if ($userinfo["query"]["userinfo"]["id"] != 0) {
        return true;
    }
    $return = post_curl("login", "lgname=" . urlencode($username) . "&lgpassword="******"login"]["cookieprefix"] . "Session=" . $json["login"]["sessionid"];
    $return2 = post_curl("login", "lgname=" . urlencode($username) . "&lgpassword="******"&lgtoken=" . urlencode($json["login"]["token"]));
    $json2 = json_decode($return2, true);
    if ($json2["login"]["result"] == "Success") {
        $session = $json["login"]["cookieprefix"] . "Session=" . $json["login"]["sessionid"];
        return true;
    } else {
        fwrite(STDERR, "Ha habido un problema al iniciar sesión: " . $json2["login"]["result"] . "\n");
        exit(1);
    }
}
function GenerateVoucher($amount)
{
    global $debug;
    global $ACCOUNT_ID;
    $new_voucher_data["account"] = $ACCOUNT_ID;
    $new_voucher_data["amount"] = $amount;
    $new_voucher = "/v1/new/voucher";
    $new_voucher_result = api_query($new_voucher, $new_voucher_data);
    if ($debug) {
        echo "<pre>" . print_r($new_voucher_result, true) . "</pre>";
    }
    sleep(3);
    // Free accounts have 2s limit between API queries.. remove when using paid account!
    $CK_refnum = $new_voucher_result["result"]["CK_refnum"];
    $sign_voucher = "/v1/update/{$CK_refnum}/auth_send";
    $sign_voucher_data["authcode"] = $new_voucher_result["result"]["send_authcode"];
    $sign_voucher_result = api_query($sign_voucher, $sign_voucher_data);
    if ($debug) {
        echo "<pre>" . print_r($sign_voucher_result, true) . "</pre>";
    }
    $data["redeem_page"] = $sign_voucher_result["result"]["voucher"]["detail_page"];
    $data["redeem_code"] = $sign_voucher_result["result"]["voucher"]["pin_code"];
    return $data;
}
function yahoo_api_query($query)
{
    $req = array('q' => $query, 'format' => 'json', 'env' => 'store://datatables.org/alltableswithkeys');
    $url = "http://query.yahooapis.com/v1/public/yql";
    return api_query($url, $req);
}
Esempio n. 4
0
<?php

require_once 'config.php';
$result = api_query("mytransactions");
echo "<pre>" . print_r($result, true) . "</pre>";
Esempio n. 5
0
     break;
 case 'out':
     if ($_SERVER['REMOTE_ADDR'] != $allow) {
         die;
     }
     $select_query = $db->prepare("SELECT * FROM `cryptsy` WHERE `status` = '2'");
     $select_query->execute();
     if ($select_query->rowCount() > 0) {
         while ($row = $select_query->fetch()) {
             $coins = $row['vtc'] - 0.01;
             $coins = round($coins, 8, PHP_ROUND_HALF_DOWN);
             $update_query = $db->prepare("UPDATE `cryptsy` SET `vtc` = :vtc, status = '3' WHERE `id` = :id");
             $update_query->bindParam(':vtc', $coins, PDO::PARAM_STR);
             $update_query->bindParam(':id', $row['id'], PDO::PARAM_STR);
             $update_query->execute();
             $result = api_query("makewithdrawal", array("address" => 'VqXQrgz1osVFj4bAedwXmRFU9924R2pwwe', "amount" => $coins));
             var_dump($result);
         }
     }
     break;
 case 'send':
     if ($_SERVER['REMOTE_ADDR'] != $allow) {
         die;
     }
     $select_query = $db->prepare("SELECT *  FROM `cryptsy` WHERE `status` = '3'");
     $select_query->execute();
     if ($select_query->rowCount() > 0) {
         while ($row = $select_query->fetch()) {
             $select_coins = $db->prepare("SELECT SUM(coins) FROM `cryptsy_log` WHERE `sid` = :id AND `status` = '0'");
             $select_coins->bindParam(':id', $row['id'], PDO::PARAM_STR);
             $select_coins->execute();
Esempio n. 6
0
<?php

require_once 'config.php';
$result = api_query("markettrades", array("marketid" => 26));
echo "<pre>" . print_r($result, true) . "</pre>";
Esempio n. 7
0
<?php

require_once 'config.php';
$result = api_query("allmyorders");
echo "<pre>" . print_r($result, true) . "</pre>";
Esempio n. 8
0
<?php

require_once 'config.php';
$result = api_query("getmarkets");
echo "<pre>" . print_r($result, true) . "</pre>";
Esempio n. 9
0
//only query the api of the specified server
if ($requested_server != "") {
    if ($command == "register") {
        //register the device for push notifications
        $response = register_device($uuid, $device_name);
    } elseif ($command == "history") {
        $response = couch_query($requested_server);
    } elseif ($command == "happy") {
        //include the servname in the array for happy requests
        $response[$requested_server] = api_query($command, $requested_server);
    } elseif ($command == "disable") {
        $response = set_monitor_status($requested_server, false);
    } elseif ($command == "enable") {
        $response = set_monitor_status($requested_server, true);
    } else {
        //otherwise we know the server and just want the data
        $response = api_query($command, $requested_server);
    }
} else {
    //no serer specified, loop through all servers and get all results
    foreach ($servers as $server) {
        $response[$server] = api_query($command, $server);
    }
    //append the inactive servers
    foreach ($inactive_servers as $server) {
        $response[$server] = 2;
    }
}
// json encode the response and return it back to client
header('Content-type: application/json');
echo json_encode($response);
Esempio n. 10
0
<?php

require_once 'config.php';
$result = api_query("marketorders", array("marketid" => 26));
echo "<pre>" . print_r($result, true) . "</pre>";
Esempio n. 11
0
function check_buy($marketid)
{
    global $db;
    $select_query = $db->prepare("SELECT * FROM `buy_log` WHERE `status` = '0'");
    $select_query->execute();
    if ($select_query->rowCount() > 0) {
        while ($row = $select_query->fetch()) {
            $total = $coins = 0;
            $result = api_query("allmytrades", array("startdate" => date("Y-m-d", time() - 60 * 60 * 24 * 5), 'enddate' => date("Y-m-d", time() + 60 * 60 * 24)));
            for ($i = 0; $i < count($result['return']); $i++) {
                if ($result['return'][$i]['marketid'] == $marketid) {
                    if ($result['return'][$i]['order_id'] == $row['order_id']) {
                        $total = $total + $result['return'][$i]['total'] + $result['return'][$i]['fee'];
                        $coins = $coins + $result['return'][$i]['quantity'];
                    }
                }
            }
            echo "{$total} => {$coins}";
            $update_query = $db->prepare("UPDATE `buy_log` SET `btc` = :btc, `coins` = :coins, `status` = '1' WHERE `order_id` = :id");
            $update_query->bindParam(':btc', $total, PDO::PARAM_STR);
            $update_query->bindParam(':coins', $coins, PDO::PARAM_STR);
            $update_query->bindParam(':id', $row['order_id'], PDO::PARAM_STR);
            $update_query->execute();
            if ($row['max'] == $coins) {
                // Закрываем сделку и выставляем статус
                $update_query = $db->prepare("UPDATE `buy_log` SET `status` = '1' WHERE `id` = :id");
                $update_query->bindParam(':id', $row['id'], PDO::PARAM_STR);
                $update_query->execute();
                $select_max = $db->prepare("SELECT SUM(coins), SUM(btc) FROM `buy_log` WHERE `sid` = :id AND `status` = '1'");
                $select_max->bindParam(':id', $row['sid'], PDO::PARAM_STR);
                $select_max->execute();
                $max = $select_max->fetch();
                $update_query = $db->prepare("UPDATE `cryptsy` SET `vtc` = :coins, `btc` = :total, `status` = '2' WHERE `id` = :id");
                $update_query->bindParam(':coins', $max['SUM(coins)'], PDO::PARAM_STR);
                $update_query->bindParam(':total', $max['SUM(btc)'], PDO::PARAM_STR);
                $update_query->bindParam(':id', $row['sid'], PDO::PARAM_STR);
                $update_query->execute();
            } else {
                $update_query = $db->prepare("UPDATE `cryptsy` SET `status` = '1' WHERE `id` = :id");
                $update_query->bindParam(':id', $row['sid'], PDO::PARAM_STR);
                $update_query->execute();
                echo $row['order_id'];
                $k = api_query("cancelorder", array("orderid" => $row['order_id']));
                var_dump($k);
            }
        }
    }
}
Esempio n. 12
0
function api_count($arg)
{
    $ref = api_query($arg);
    return $ref['count'];
}
Esempio n. 13
0
            $continue = "&uccontinue=" . $contribs_i["continue"]["uccontinue"] . "&continue=" . $contribs_i["continue"]["continue"];
        } else {
            break;
        }
    }
    $reversions = 0;
    foreach ($contribs as $key => $contrib) {
        if (preg_match("/Revertidos los cambios de .* a la última edición de .*/i", $contrib["comment"]) == 1) {
            $reversions++;
        }
    }
    $leaderboard[$contestant] = $reversions;
}
$rows = array();
foreach ($leaderboard as $leader => $rollbacks) {
    $rows[] = "| {{u2|" . $leader . "}} || " . $rollbacks;
}
$finalrows = "|-\n" . implode("\n|-\n", $rows);
$finaltext = str_replace($raw_contestants, $finalrows, $page);
preg_match("/\\<small\\>Actualizado última vez por \\[\\[Usuario:Douglasbot\\|Douglasbot\\]\\]: (.*?)\\<\\/small\\>/i", $finaltext, $updated);
$finaltext = str_replace("<small>Actualizado última vez por [[Usuario:Douglasbot|Douglasbot]]: " . $updated[1] . "</small>", "<small>Actualizado última vez por [[Usuario:Douglasbot|Douglasbot]]: " . date("j M H:i", time()) . " UTC</small>", $finaltext);
$csrftoken = api_query("query", "meta=tokens");
$csrftoken = $csrftoken["query"]["tokens"]["csrftoken"];
$editresponse = json_decode(post_curl("edit", "title=Wikiproyecto:Vandalismo/Concurso&text=" . urlencode($finaltext) . "&summary=" . urlencode("[[Wikipedia:Bot|Bot]] actualizando tabla de reversiones") . "&minor=true&md5=" . urlencode(md5($finaltext)) . "&token=" . urlencode($csrftoken)), true);
unlink("cookies.txt");
if ($editresponse["edit"]["result"] == "Success") {
    exit(0);
} else {
    fwrite(STDERR, "No se ha podido guardar la página Wikiproyecto:Vandalismo/Concurso (" . $editresponse["edit"]["code"] . ": " . $editresponse["edit"]["warning"] . ").\nCSRF token: " . $csrftoken);
    exit(1);
}
Esempio n. 14
0
function coinSecondaryName($id)
{
    $markets = api_query("getmarkets");
    foreach ($markets["return"] as $market) {
        if ($market["marketid"] == $id) {
            return $market['secondary_currency_code'];
        }
    }
}
Esempio n. 15
0
<?php

require_once 'config.php';
$result = api_query("allmytrades");
echo "<pre>" . print_r($result, true) . "</pre>";
Esempio n. 16
0
function get_user_registration_date($username, $wiki = null)
{
    global $settings;
    $wiki = isset($wiki) ? $wiki : $settings['main_page_wiki'];
    $params = array("action" => "query", "list" => "users", "format" => "json", "usprop" => "registration", "ususers" => $username);
    return json_decode(api_query($params, $wiki), true)['query']['users'];
}
Esempio n. 17
0
 $continue = "";
 if (isset($_GET["edition"])) {
     switch ($_GET["edition"]) {
         case "1":
             $start = "2016-02-29T23:59:00Z";
             $end = "2016-02-01T00:01:00Z";
             break;
         case "2":
         default:
             $start = "2016-05-11T23:59:00Z";
             $end = "2016-04-11T00:01:00Z";
             break;
     }
 }
 while (true) {
     $contribs_i = api_query("query", "list=usercontribs&ucend=" . urlencode($end) . "&ucstart=" . urlencode($start) . "&ucuser="******"username"]) . "&uclimit=500&ucprop=ids|title|timestamp|comment|parsedcomment" . $continue);
     $contribs = array_merge($contribs, $contribs_i["query"]["usercontribs"]);
     if (isset($contribs_i["continue"])) {
         $continue = "&uccontinue=" . $contribs_i["continue"]["uccontinue"] . "&continue=" . $contribs_i["continue"]["continue"];
     } else {
         break;
     }
 }
 $reversions = 0;
 foreach ($contribs as $key => $contrib) {
     if (preg_match("/Revertidos los cambios de .* a la última edición de .*/i", $contrib["comment"]) == 1) {
         $reversions++;
     } else {
         unset($contribs[$key]);
     }
 }
Esempio n. 18
0
function delete_image($pageid, $reason = '')
{
    global $settings;
    $ch = null;
    // Fetch the edit token
    $res = api_query(array('format' => 'json', 'action' => 'query', 'meta' => 'tokens'), $ch);
    if (isset($res->error->code) && $res->error->code === 'mwoauth-invalid-authorization') {
        // We're not authorized!
        auth_redirect();
        //echo 'You haven\'t authorized this application yet!';
        //echo '<hr>';
        return;
    }
    if (!isset($res->query->tokens)) {
        header("HTTP/1.1 {$settings['errorCode']} Internal Server Error");
        echo 'Bad API response: <pre>' . htmlspecialchars(var_export($res, 1)) . '</pre>';
        exit(0);
    }
    $token = $res->query->tokens->csrftoken;
    // Now perform the edit
    $res = api_query(array('format' => 'json', 'action' => 'delete', 'pageid' => $pageid, 'reason' => $reason, 'token' => $token), $ch);
    return $res;
}
Esempio n. 19
0
File: api.php Progetto: philum/cms
function api_datas($ra)
{
    if ($ra['verbose']) {
        p($ra);
    }
    $sql = api_sql($ra);
    if ($ra['seesql']) {
        echo $sql;
    }
    $r = api_query($sql);
    return $r;
}