コード例 #1
0
ファイル: Index.php プロジェクト: Aimsam/BTCAutoTrade
 /**
  * @desc 获取价格Action
  * @param string market
  */
 public function getPriceAction()
 {
     Yaf\Registry::get('redis')->lPush('get_price_pids', getmypid());
     $market_name = $this->getRequest()->getParam('market');
     $market_name = "Market\\{$market_name}";
     $market = new $market_name();
     while (true) {
         if ($market_name == 'Market\\Btce') {
             $account_config = array();
             $account_config_model = new AccountConfigDao();
             foreach ($account_config_model->getConfigListByAccountId(9) as $config) {
                 $account_config[$config['name']] = format_val($config['value']);
             }
             $market = new $market_name($account_config);
         }
         if ($market_name == 'Market\\Bitfinex') {
             $account_config = array();
             $account_config_model = new AccountConfigDao();
             foreach ($account_config_model->getConfigListByAccountId(10) as $config) {
                 $account_config[$config['name']] = format_val($config['value']);
             }
             $market = new $market_name($account_config);
         }
         usleep(Yaf\Application::app()->getConfig()->console->price_sleep_delay);
         $market->getPrice();
     }
 }
コード例 #2
0
ファイル: Account.php プロジェクト: Aimsam/BTCAutoTrade
 function __construct($account_id = null)
 {
     if (!empty($account_id)) {
         $account_model = new AccountDao();
         $account = $account_model->get($account_id);
         if ($account) {
             $this->account_id = $account_id;
             // 市场类名
             $market_name = $account->market['name'];
             $market_name = 'Market\\' . $market_name;
             // 市场配置
             $account_config = array();
             $account_config_model = new AccountConfigDao();
             foreach ($account_config_model->getConfigListByAccountId($account['id']) as $config) {
                 $account_config[$config['name']] = format_val($config['value']);
             }
             try {
                 $this->market = new $market_name($account_config);
             } catch (Exception $e) {
                 throw new Exception("API {$market_name} not found.");
             }
         } else {
             throw new Exception('Account not found.');
         }
     }
 }
コード例 #3
0
ファイル: BaseMarket.php プロジェクト: Aimsam/BTCAutoTrade
 /**
  * @author Tuzki
  * @param array $params
  * @desc 用于设置市场的 API 等值
  */
 public function __construct(array $params = array())
 {
     foreach ($params as $key => $value) {
         if (array_key_exists($key, $this->config)) {
             $this->config[$key] = format_val($value);
         }
     }
 }
コード例 #4
0
ファイル: Config.php プロジェクト: Aimsam/BTCAutoTrade
 /**
  * @author Tuzki
  * @param $name string
  * @param $value mixed
  */
 public function set($name, $value)
 {
     if (array_key_exists($name, $this->config)) {
         $this->config[$name] = format_val($value);
     }
 }
コード例 #5
0
ファイル: tinymy.php プロジェクト: CristianCCIT/shop4office
function exec_sql_internal($sql_text = '', $show_stats = false, $show_query = false)
{
    global $db;
    $sql_text = trim($sql_text);
    if (!$sql_text || ';' == $sql_text || substr($sql_text, 0, 2) == '--') {
        return;
    }
    if ($show_query || $show_stats) {
        echo '<div class="sql">';
    }
    if ($show_query) {
        echo nl2br(htmlspecialchars($sql_text)) . '<br />';
    }
    $res = $db->query($sql_text);
    if ($show_stats && !$res['failed']) {
        echo '<em>Ok';
        if ($res['rows']) {
            if ($res['rows'] != $res['rows_affected']) {
                printf(', rows: %d', $res['rows']);
            }
        }
        if ($res['rows_affected']) {
            printf(', rows affected: %d', $res['rows_affected']);
        }
        if ($res['time']) {
            printf(', time: %.3f s', $res['time']);
        }
        echo '</em>';
    }
    if ($show_query || $show_stats) {
        echo '</div>';
    }
    if (!$res['failed']) {
        if ($res['rows'] != 0) {
            echo '<table class="result"><tr>';
            foreach ($res['field_names'] as $title) {
                echo '<th>' . htmlspecialchars($title) . '</th>';
            }
            echo '</tr>';
            $odd = true;
            for ($i = 0; $i < $res['rows']; $i++) {
                printf('<tr%s>', $odd ? ' class="odd"' : '');
                $odd = !$odd;
                foreach ($res['result'][$i] as $title => $value) {
                    printf('<td>%s</td>', format_val($value));
                }
                echo '</tr>';
            }
            echo '</table>';
        } else {
            echo '<p style="font-size: 70%;padding-left: 5px; margin-bottom: 10px;">Query executed, but returned no result.</p>';
        }
    }
}