コード例 #1
0
 public function actionIndex()
 {
     if (isset($_COOKIE['mainbtc'])) {
         return;
     }
     if (!LimitRequest('explorer')) {
         return;
     }
     $id = getiparam('id');
     $coin = getdbo('db_coins', $id);
     $height = getparam('height');
     if ($coin && intval($height) > 0) {
         $remote = new Bitcoin($coin->rpcuser, $coin->rpcpasswd, $coin->rpchost, $coin->rpcport);
         $hash = $remote->getblockhash(intval($height));
     } else {
         $hash = getparam('hash');
     }
     $txid = getparam('txid');
     if ($coin && !empty($txid) && ctype_alnum($txid)) {
         $remote = new Bitcoin($coin->rpcuser, $coin->rpcpasswd, $coin->rpchost, $coin->rpcport);
         $tx = $remote->getrawtransaction($txid, 1);
         $hash = $tx['blockhash'];
     }
     if ($coin && !empty($hash) && ctype_alnum($hash)) {
         $this->render('block', array('coin' => $coin, 'hash' => substr($hash, 0, 64)));
     } else {
         if ($coin) {
             $this->render('coin', array('coin' => $coin));
         } else {
             $this->render('index');
         }
     }
 }
コード例 #2
0
ファイル: ApiController.php プロジェクト: zarethernet/yaamp
 public function actionRental()
 {
     if (!LimitRequest('api-rental', 10)) {
         return;
     }
     $key = getparam('key');
     $renter = getdbosql('db_renters', "apikey=:apikey", array(':apikey' => $key));
     if (!$renter) {
         return;
     }
     $balance = bitcoinvaluetoa($renter->balance);
     $unconfirmed = bitcoinvaluetoa($renter->unconfirmed);
     echo "{";
     echo "\"balance\": {$balance}, ";
     echo "\"unconfirmed\": {$unconfirmed}, ";
     echo "\"jobs\": [";
     $list = getdbolist('db_jobs', "renterid={$renter->id}");
     foreach ($list as $i => $job) {
         if ($i) {
             echo ", ";
         }
         $hashrate = yaamp_job_rate($job->id);
         $hashrate_bad = yaamp_job_rate_bad($job->id);
         echo '{';
         echo "\"jobid\": \"{$job->id}\", ";
         echo "\"algo\": \"{$job->algo}\", ";
         echo "\"price\": \"{$job->price}\", ";
         echo "\"hashrate\": \"{$job->speed}\", ";
         echo "\"server\": \"{$job->host}\", ";
         echo "\"port\": \"{$job->port}\", ";
         echo "\"username\": \"{$job->username}\", ";
         echo "\"password\": \"{$job->password}\", ";
         echo "\"started\": \"{$job->ready}\", ";
         echo "\"active\": \"{$job->active}\", ";
         echo "\"accepted\": \"{$hashrate}\", ";
         echo "\"rejected\": \"{$hashrate_bad}\", ";
         echo "\"diff\": \"{$job->difficulty}\"";
         echo '}';
     }
     echo "]}";
 }