Example #1
0
function gettrades()
{
    // get the json from http://exchange.bitparking.com:8080/api/t
    $opts = array('http' => array('method' => "GET", 'user_agent' => "MozillaXYZ/1.0"));
    $context = stream_context_create($opts);
    $json = file_get_contents('http://exchange.bitparking.com:8080/api/t', false, $context);
    //have the json
    $new_trade_array = json2array($json);
    $new_trade_array = array_reverse($new_trade_array);
    return $new_trade_array;
}
Example #2
0
 static function readJSONLines($file)
 {
     $res = array();
     foreach ($file->lines() as $line) {
         if ($line) {
             $res[] = json2array($line);
         }
     }
     return $res;
     //array_map("json2array",$file->lines());
 }
Example #3
0
function getdepth(&$bids, &$asks)
{
    // get the json from http://exchange.bitparking.com:8080/api/t
    $opts = array('http' => array('method' => "GET", 'user_agent' => "MozillaXYZ/1.0"));
    $context = stream_context_create($opts);
    $json = file_get_contents('http://exchange.bitparking.com:8080/api/o', false, $context);
    //var_dump($json);
    //have the json
    $new_depth_array = json2array($json);
    //var_dump($new_depth_array);
    $asks = $new_depth_array->asks;
    $bids = $new_depth_array->bids;
    //echo "<pre>";var_dump($bids);echo "</pre>";
    //echo "<pre>";var_dump($asks);echo "</pre>";
    if ($asks && $bids) {
        return true;
    } else {
        return false;
    }
}
Example #4
0
$class = Auth::curClass();
#print $class;
$vec = $logD->rel("{$class}-vector.json");
if (!$vec->exists()) {
    ?>
Run <a href="a.php?MkCluster">MkCluster</a><?php 
    return;
}
$vecs = $vec->obj();
$cluster = new VecCluster($vecs);
$count = 0;
foreach ($files as $file) {
    if ($file->startsWith($class) && $file->endsWith("-data.log")) {
        $data = array_map(function ($line) {
            global $count, $cluster;
            $e = json2array($line);
            $code = LogUtil::detectProgram($e);
            $vec = VecUtil::mkvec($code);
            $a = $cluster->nearest($vec);
            $e["nearest"] = $a[0];
            $e["dist"] = $a[1];
            /*if (isset($e["code"])) {
                  $code=$e["code"];
                  if (is_array($code)) {
                      $e["nearest"]=array();
                      $e["dist"]=array();
                      foreach ($code as $k=>$c) {
                          $v=VecUtil::mkvec($c);
                          $a=$cluster->nearest($v);
                          $e["nearest"][$k]=$a[0];
                          $e["dist"][$k]=$a[1];
Example #5
0
     }
 }
 // Retrive upload ID
 echo "<script type='text/javascript'>document.getElementById('login').style.display='none';</script>\n<div id='info' width='100%' align='center'>Retrieving upload ID</div>\n";
 // Create Share
 $page = geturl('open.ge.tt', 80, '/1/shares/create?accesstoken=' . urlencode($userInfo['accesstoken']) . '&t=' . jstime(), $referer, $cookie, '', 0, $_GET['proxy'], $pauth);
 is_page($page);
 $share = json2array($page, 'Create Share Error');
 if (empty($share['sharename'])) {
     html_error('Cannot get Share ID');
 }
 // Create File
 $post = array('filename' => $lname);
 $page = geturl('open.ge.tt', 80, '/1/files/' . urlencode($share['sharename']) . '/create?accesstoken=' . urlencode($userInfo['accesstoken']) . '&t=' . jstime(), $referer, $cookie, json_encode($post), 0, $_GET['proxy'], $pauth);
 is_page($page);
 $file = json2array($page, 'Create File Error');
 if (empty($file['getturl'])) {
     html_error('Download link not found.');
 }
 if (empty($file['upload']['posturl'])) {
     html_error('Upload URL not Found.');
 }
 // posturl		puturl
 // Uploading
 echo "<script type='text/javascript'>document.getElementById('info').style.display='none';</script>\n";
 $url = parse_url($file['upload']['posturl']);
 // .'&nounce='.exports_uuid()
 $upfiles = upfile($url['host'], defport($url), $url['path'] . (!empty($url['query']) ? '?' . $url['query'] : ''), $file['getturl'], $cookie, array(), $lfile, $lname, 'blob', '', $_GET['proxy'], $pauth, 0, $url['scheme']);
 //$upfiles = putfile($url['host'], defport($url), $url['path'].(!empty($url['query']) ? '?'.$url['query'] : ''), $file['getturl'], $cookie, $lfile, $lname, $_GET['proxy'], $pauth, 0, $url['scheme']);
 // Upload Finished
 echo "<script type='text/javascript'>document.getElementById('progressblock').style.display='none';</script>\n";
Example #6
0
function ApiReq($path, $post = array())
{
    if (!is_array($post)) {
        $post = array();
    }
    if ($path != 'user/login' && !empty($GLOBALS['login_json']['token'])) {
        $post['token'] = $GLOBALS['login_json']['token'];
    }
    $page = ul_GetPage("https://alfafile.net/api/v1/{$path}", 0, array_map('urlencode', $post), 'https://alfafile.net/');
    $reply = json2array($page, "ApiReq({$path}) Error");
    if (empty($reply['response']) && !empty($reply['details'])) {
        html_error("[ApiReq({$path}) Error] " . htmlspecialchars($reply['details'], ENT_QUOTES));
    }
    return $reply['response'];
}
             $uploadHeaders['x-archive-meta-description'] = $uploadHeaders['x-archive-meta-subject'] = 'test item';
             $uploadHeaders['x-archive-meta-collection'] = 'test_collection';
         } else {
             $uploadHeaders['x-archive-meta-description'] = 'Uploaded with Rapidleech';
             $uploadHeaders['x-archive-meta-subject'] = 'Rapidleech';
         }
         if (!empty($_REQUEST['up_mediatype']) && in_array($_REQUEST['up_mediatype'], $media_types)) {
             $uploadHeaders['x-archive-meta-mediatype'] = $_REQUEST['up_mediatype'];
         }
     } else {
         html_error('[Error Pre Checking Bucket]: HTTP ' . $status);
     }
 }
 // Pre-Upload test
 $page = ul_GetPage(($GLOBALS['use_https'] ? 'https' : 'http') . '://s3.us.archive.org/?check_limit=1&accesskey=' . urlencode($iaS3AccessKey) . '&bucket=' . urlencode($_REQUEST['bucket']));
 $json = json2array($page, 'Pre-Upload Error');
 if ($json['over_limit'] != 0) {
     textarea($json);
     html_error('The server is overloaded, please try to upload later.');
 }
 if (!empty($uploadHeaders)) {
     $uploadHeaders = array_map('iaS3HeaderEncode', $uploadHeaders);
 }
 $uploadHeaders['Authorization'] = 'LOW ' . $iaS3AccessKey . ':' . $iaS3SecretKey;
 $uploadReferer = $referer;
 foreach ($uploadHeaders as $tok => $val) {
     $uploadReferer .= "\r\n{$tok}: {$val}";
 }
 // Uploading
 echo "<script type='text/javascript'>document.getElementById('info').style.display='none';</script>\n";
 $url = parse_url('http://s3.us.archive.org/' . urlencode($_REQUEST['bucket']) . '/' . urlencode($lname));
Example #8
0
    }
    fclose($fp);
    ?>
    <script>location.href="a.php?MkCluster&state=1&k=<?php 
    echo $k;
    ?>
";</script>
    <?php 
} else {
    $logDir = LogUtil::getLogDir();
    $vecs = array();
    $lines = $logDir->rel("{$class}-allvec.txt")->lines();
    $c = count($lines);
    showProgress("Read lines");
    foreach ($lines as $i => $line) {
        $vecs[] = new Vec(json2array($line));
    }
    showProgress("Starting kmeans");
    VecUtil::$verbose = 1;
    $cluster = VecUtil::kmeans($k, $vecs);
    /*$res=array();
      foreach ($cluster->centroids as $vec) {
          $res[nameOf($vec)]=$vec->ary;
          //echo json_encode($vec)."<BR>";
      }
      $logD=LogUtil::getLogDir();
      $class=Auth::curClass();
      $vecFile=$logD->rel("$class-vector.json");
      $vecFile->obj($res);*/
    ?>
    <script>location.href="a.php?DetectFile";</script>
Example #9
0
<?php

require_once __DIR__ . "/auth.php";
require_once __DIR__ . "/json.php";
require_once __DIR__ . "/ErrorHandler.php";
$home = Auth::home();
$prj = $home->rel("/_test_run/");
$files = json2array($_POST["files"]);
foreach ($files as $name => $cont) {
    $prj->rel($name)->text($cont);
}
echo "/index.html?r=jsl_edit&dir=" . $prj->path() . "&autoexec=" . $_POST["autoexec"];
Example #10
0
function json2array($obj)
{
    $_arr = is_object($obj) ? get_object_vars($obj) : $obj;
    foreach ($_arr as $key => $val) {
        $val = is_array($val) || is_object($val) ? json2array($val) : $val;
        $arr[$key] = $val;
    }
    return $arr;
}