コード例 #1
0
 /**
  * 构造函数
  *
  * @access private
  * @return void
  */
 private function __construct($name)
 {
     $this->name = empty($name) ? '' : '_' . $name;
     if (empty(self::$mysql)) {
         self::$mysql = \Myfox\Lib\Mysql::instance('default');
     }
     if (empty(self::$mypos)) {
         self::$mypos = Context::addr(true);
     }
 }
コード例 #2
0
 public function test_should_import_hello_works_fine()
 {
     $controller = new \Myfox\App\Control\Import();
     \Myfox\Lib\Context::register('__ip__', '119.32.212.64');
     ob_start();
     $controller->execute('hello', array('table' => 'numsplit'));
     $output = ob_get_contents();
     $this->assertContains('[1100] Access Denied.', $output);
     \Myfox\Lib\Context::register('__ip__', '127.0.0.1');
     ob_clean();
     ob_start();
     $controller->execute('hello', array('table' => 'numsplit'));
     $output = ob_get_contents();
     $this->assertContains('[1200] Param "route" is required.', $output);
     ob_clean();
     ob_start();
     $controller->execute('hello', array('table' => 'numsplit', 'file' => 'ftp://*****:*****@www.helloworld.com/test_file.txt', 'route' => 'cid:1,thedate:20111001', 'lines' => 1111111));
     $output = ob_get_contents();
     $this->assertContains('[0] OK', $output);
     @ob_clean();
 }
コード例 #3
0
ファイル: import.php プロジェクト: ray-dong/Myfox-load-module
 /**
  * 切分好的分片数据装载, 外部切分程序调用
  *
  * @access protected
  * @return void
  */
 protected function actionQueque($gets, $data)
 {
     if (false === ($priority = self::priority())) {
         self::output(1100, 'Access Denied.');
         return false;
     }
     $table = self::vars('table', $data, $gets);
     if (empty($table)) {
         self::output(1200, 'Param "table" is required.');
         return false;
     }
     foreach (array('file', 'route', 'bucket', 'hosts') as $key) {
         if (empty($data[$key])) {
             self::output(1201, sprintf('Param "%s" is required in post data.', $key));
             return false;
         }
     }
     $info = array('table' => $table, 'route' => $data['route'], 'file' => $data['file'], 'bucket' => $data['bucket'], 'hosts' => $data['hosts']);
     $ipaddr = Context::userip();
     $agent = isset($param['agent']) ? (int) $param['agent'] : ip2long($ipaddr);
     $option = array('priority' => $priority, 'trytimes' => 3, 'task_flag' => \Myfox\App\Queque::FLAG_WAIT, 'adduser' => sprintf('web:%s', $ipaddr));
     $queque = \Myfox\App\Queque::instance();
     if (!$queque->insert('import', $info, $agent, $option)) {
         self::output(1300, sprintf('Inner Error (%s).', $queque->lastError()));
         return false;
     }
     self::output(0, 'OK', array('id' => $queque->lastId()));
 }
コード例 #4
0
 public function test_should_addr_works_fine()
 {
     $ip = trim(`hostname -i`);
     $this->assertEquals($ip, Context::addr());
 }
コード例 #5
0
 private static function access()
 {
     $secure = new \Myfox\App\Security(__DIR__ . '/../../etc/secure/agent.ini');
     return $secure->priority(Context::userip());
 }