Esempio n. 1
1
 function actionIndex()
 {
     $this->layout = '//layouts/none';
     //header('Content-type: application/json');
     $null_wallets = Wallet::model()->findAllByAttributes(array('wallet_address' => null));
     foreach ($null_wallets as $null_wallet) {
         // CoinAddress::set_debug(true);      // optional - show debugging messages
         // CoinAddress::set_reuse_keys(true); // optional - use same key for all addresses
         $newcoin = CoinAddress::bitcoin();
         Yii::log("Created new address for {$newcoin['public_hex']}", "info");
         $new_wallet = new SecureWallet();
         $new_wallet->wallet_address = $newcoin['public'];
         $new_wallet->private_key = $newcoin['private'];
         $new_wallet->save();
         $null_wallet->wallet_address = $new_wallet->wallet_address;
         $null_wallet->save();
     }
     echo CJSON::encode(array('status' => 'ok'));
     Yii::app()->end();
 }
 public function actionPurchases()
 {
     //Check to see if we can get new data
     $groupMembers = $this->getTrackingGroupMembers(1);
     $transactionInterface = new APITransactions();
     if (!$transactionInterface->getCacheExpiration($groupMembers[0]->characterID)) {
         foreach ($groupMembers as $member) {
             $orders = $transactionInterface->getEveData($member->characterID);
             $character = Characters::Model()->findByPk($member->characterID);
             if ($character->walletEnabled) {
                 $transactionInterface->storeData($member->characterID);
             }
         }
     }
     //Get our tracking group members
     $members = $this->getMembersAsArray(1);
     $sqlarray = '(' . implode(',', $members) . ')';
     //Create our db criteria
     $criteria = new CDbCriteria();
     $criteria->condition = 'transactionType = "buy" AND characterID IN ' . $sqlarray;
     $criteria->order = 'transactionDateTime DESC';
     $criteria->limit = 30;
     //Grab our last 30 transactions
     $results = Wallet::model()->findAll($criteria);
     //Create a new XML object
     $xmlObject = new DOMDocument();
     $root = $xmlObject->appendChild($xmlObject->createElement('TransactionList'));
     //Iterate over the db results and construct the XML
     foreach ($results as $result) {
         //Create the parent tag for this transaction
         $trans = $root->appendChild($xmlObject->createElement('Transaction'));
         //Populate with the data
         $trans->appendChild($xmlObject->createElement('transactionDateTime', $result->transactionDateTime));
         $trans->appendChild($xmlObject->createElement('transactionTimestamp', strtotime($result->transactionDateTime)));
         $trans->appendChild($xmlObject->createElement('typeID', $result->typeID));
         $trans->appendChild($xmlObject->createElement('typeName', $result->typeName));
         $trans->appendChild($xmlObject->createElement('quantity', $result->quantity));
         $trans->appendChild($xmlObject->createElement('profit', $result->profit));
         $trans->appendChild($xmlObject->createElement('price', $result->price));
         $trans->appendChild($xmlObject->createElement('stationName', $result->stationName));
         $trans->appendChild($xmlObject->createElement('icon', $this->getIcon($result->typeID)));
     }
     //Render the XML
     $xmlObject->formatOutput = false;
     echo $xmlObject->saveXML();
     //$this->renderPartial('transactions',array('results'=>$results));
 }
Esempio n. 3
0
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = Wallet::model()->findByPk((int) $id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }