public function run() { $G = new Github(); $req_url = $_SERVER['REQUEST_SCHEME'] . "://" . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; $path = parse_url($req_url, PHP_URL_PATH); $paths = explode("/", $path); $project_name = $paths[2] . '/' . $paths[3]; $this->state['project_name'] = $project_name; $this->state['repo'] = $G->load_stored_repo($project_name); if ($this->state['repo']['status'] == 4) { if (!$this->state['repo']['public']) { $G->load_user(); } $G->load_coin_owners($project_name); $this->state['date_minted'] = $G->date_minted; $this->state['last_commit'] = strftime("%b %d", strtotime(query_grab("SELECT max(commit_date) FROM commit_log WHERE repo = '" . $this->state['repo']['name'] . "'"))); $this->state['asset_hash'] = $G->asset_hash; $this->state['cal'] = $G->schedule; $this->state['contributors'] = $G->contributors; $this->state['equity'] = $G->equity; $this->state['today'] = $G->today; } else { $G->load_user(); $BTC = new Bitcoin(); $BTC->generate_address($project_name); $this->state['btc_address'] = $BTC->input_address; $this->state['status'] = $BTC->status; $this->state['hash'] = $BTC->transaction_hash; } $this->_load("mint.html"); }
public function run() { header("Content-type: text/plain"); $req_url = $_SERVER['REQUEST_SCHEME'] . "://" . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; $path = parse_url($req_url, PHP_URL_PATH); $paths = explode("/", $path); $secret = $paths[2]; $BTC = new Bitcoin(); //$BTC->generate_address(); $BTC->process_incoming($_GET, $secret); if ($_GET['confirmations'] >= 6) { echo "*ok*"; //XXX I'm worried this will be too slow to fire back an "OK" to blockchain, but cron is not firing reliably. $repo_name = query_grab("SELECT name FROM repo WHERE address = '" . escape($_GET['input_address']) . "'"); $A = new Asset(); $A->issue_asset($repo_name); } die; }
public function load_repos() { $url = "https://api.github.com/user/repos"; $this->api_call($url); $this->repos = $this->json_response; $sq = query("SELECT * FROM repo WHERE user_id = '" . escape($_SESSION['user']['github_id']) . "'"); query("UPDATE wallet SET created = NOW() WHERE user_id='" . escape($_SESSION['user']['github_id']) . "'"); while ($r = fa($sq)) { $status[$r['name']] = $r; } foreach ($this->repos as $k => $v) { if (array_key_exists($v->full_name, $status)) { $this->repos[$k]->status = $status[$v->full_name]['status']; $this->repos[$k]->address = $status[$v->full_name]['address']; if ($status[$v->full_name]['status'] == 2) { $live_data = query_assoc("SELECT * FROM wallet WHERE bitcoin_address = '" . escape($status[$v->full_name]['address']) . "'"); $this->repos[$k]->confirmations = $live_data['confirmations']; $this->repos[$k]->transaction_hash = $live_data['last_transaction_hash']; } elseif ($status[$v->full_name]['status'] >= 3) { $hash = query_grab("SELECT transaction_hash FROM asset WHERE name = '" . escape($v->full_name) . "'"); if (substr($hash, 0, 1) == '"' && substr($hash, -1, 1) == '"') { $hash = substr($hash, 1, strlen($hash) - 2); } $this->repos[$k]->transaction_hash = $hash; } } else { $this->repos[$k]->status = 0; } } return; //$user_url = $this->json_response->url; //$this->api_call($user_url); $repos_url = $this->json_response->repos_url; $this->api_call($repos_url); $contributors_url = $this->json_response[0]->url . '/collaborators'; $this->api_call($contributors_url); }