Exemple #1
0
 /**
  * @param string $dir
  * @param bool   $append
  */
 public function loadFixturesFromDir($dir, $append = true)
 {
     if (!$append) {
         $this->purger->purge();
     }
     $this->loader->loadFromDirectory($dir);
     $this->executor->execute($this->loader->getFixtures());
 }
 public function testExpressionLanguageListenerCreateObject()
 {
     $fixtures = new FixtureCollection(array($this->createFixture('test1', array('key1' => array('foo' => '@expr(object("test2", "key2").test)'))), $this->createFixture('test2', array('key2' => array('test' => '@expr("foo" ~ "bar")')))));
     $this->executor->expects($this->once())->method('createObject')->will($this->returnValue((object) array('test' => 'foobar')));
     $event = new FixtureCollectionEvent($this->createFixtureManagerMock(), $fixtures);
     $this->listener->onPreExecute($event);
     $data1 = $fixtures->get('test1')->get('key1')->getData();
     $data2 = $fixtures->get('test2')->get('key2')->getData();
     $this->assertEquals('foobar', $data1['foo']);
     $this->assertEquals('foobar', $data2['test']);
 }
Exemple #3
0
 public function testFlush()
 {
     $streams = $this->provideStreams();
     $executor = new Executor();
     $this->assertSame(0, $executor->flush('echo foo', $streams));
     rewind($streams[0]);
     $this->assertSame('', fread($streams[0], 1024));
     rewind($streams[1]);
     $this->assertSame("foo\r\n", fread($streams[1], 1024));
     rewind($streams[2]);
     $this->assertSame('', fread($streams[2], 1024));
 }
 /**
  * Call this function to execute jobs which are due to occur now.
  */
 public function run()
 {
     $jobs = $this->jobFinder->find();
     if (is_null($jobs)) {
         return;
     }
     foreach ($jobs as $job) {
         // TODO Should jobs be locked prior to running them?
         $start = date('Y-m-d H:i:s', time());
         $executor = new Executor($job);
         $response = $executor->run();
         $finish = date('Y-m-d H:i:s', time());
         $this->addJobToHistory($job, $response, $start, $finish);
         $this->sendNotifications($job, $response, $start, $finish);
     }
 }
Exemple #5
0
 public static function getAllByPopular()
 {
     //		$sql = "select * from ".self::$tablename;
     $sql = "select *,count(*) as total from " . self::$tablename . " group by channel_id limit 10";
     $query = Executor::doit($sql);
     return Model::many($query[0], new FollowerData());
 }
 public function __construct()
 {
     $arr = Executor::execute("df -PB 1");
     foreach ($arr as $line) {
         $columns = preg_split("/ /", $line, -1, PREG_SPLIT_NO_EMPTY);
         $this->df[$columns[0]] = array("capacity" => $columns[1], "used" => $columns[2], "available" => $columns[3], "percent" => $columns[4], "path" => $columns[5]);
     }
 }
Exemple #7
0
 /**
  * {@inheretDoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     foreach ($this->properties as $property) {
         $property->setValue($input->getOption($property->getName()));
     }
     foreach ($this->properties as $property) {
         $property->makeReady($this, $input, $output);
     }
     $this->executor->execute($this, $input, $output);
 }
Exemple #8
0
 public static function one_object($sql)
 {
     $query = Executor::doit($sql);
     $cnt = 0;
     $found = null;
     $data = null;
     while ($r = $query[0]->fetch_object()) {
         $data = $r;
         $found = $data;
         break;
     }
     return $found;
 }
Exemple #9
0
 public static function getByName($name)
 {
     $sql = "select * from " . self::$tablename . " where name=\"{$name}\"";
     $query = Executor::doit($sql);
     $found = null;
     $data = new StatusData();
     while ($r = $query->fetch_array()) {
         $data->id = $r['id'];
         $data->name = $r['name'];
         $found = $data;
         break;
     }
     return $found;
 }
Exemple #10
0
function PHP_debug_backtrace(Executor $executor, array $args, Zval $return)
{
    $array = array();
    $current = $executor->getCurrent();
    while ($current->parent) {
        $parent = $current->parent;
        $ret = array('line' => $parent->opLine->attributes['startLine'], 'file' => $parent->opArray->getFileName());
        if ($current->function) {
            if ($current->ci) {
                $ret['class'] = $current->ci->getClassEntry()->getName();
                $ret['object'] = $current->ci;
                $ret['type'] = '->';
                $ret['function'] = $current->ci->getClassEntry()->getMethodStore()->getName($current->function);
            } else {
                $ret['function'] = $current->executor->getFunctionStore()->getName($current->function);
            }
            $ret['args'] = $current->arguments;
        }
        $array[] = $ret;
        $current = $parent;
    }
    $return->setValue($array);
}
Exemple #11
0
 public static function getAll()
 {
     $sql = "select * from " . self::$tablename;
     $query = Executor::doit($sql);
     $array = array();
     $cnt = 0;
     while ($r = $query->fetch_array()) {
         $array[$cnt] = new UserTypeData();
         $array[$cnt]->id = $r['id'];
         $array[$cnt]->name = $r['name'];
         $cnt++;
     }
     return $array;
 }
 public static function getAll()
 {
     $sql = "select * from " . self::$tablename . " order by created_at desc";
     $query = Executor::doit($sql);
     $array = array();
     $cnt = 0;
     while ($r = $query[0]->fetch_array()) {
         $array[$cnt] = new OperationTypeData();
         $array[$cnt]->id = $r['id'];
         $array[$cnt]->name = $r['name'];
         $cnt++;
     }
     return $array;
 }
Exemple #13
0
 public static function getLike($q)
 {
     $sql = "select * from " . self::$tablename . " where name like '%{$q}%'";
     $query = Executor::doit($sql);
     $array = array();
     $cnt = 0;
     while ($r = $query[0]->fetch_array()) {
         $array[$cnt] = new BoxData();
         $array[$cnt]->id = $r['id'];
         $array[$cnt]->created_at = $r['created_at'];
         $cnt++;
     }
     return $array;
 }
Exemple #14
0
function Event_handler($handler)
{
    if (is_object($handler)) {
        return array('type' => 'object', 'object' => $handler, 'event_handler' => true);
    } elseif (is_string($handler) && class_exists($handler)) {
        return array('type' => 'class', 'class' => $handler, 'event_handler' => true);
    } else {
        if (is_array($handler)) {
            return array('type' => 'bootable', 'boot' => \Collection::create($handler), 'event_handler' => true);
        } else {
            return array('type' => 'bootable', 'boot' => \Executor::create($handler), 'event_handler' => true);
        }
    }
}
Exemple #15
0
 public static function getAll()
 {
     $sql = "select * from " . self::$tablename . " order by created_at desc";
     $query = Executor::doit($sql);
     $array = array();
     $cnt = 0;
     while ($r = $query->fetch_array()) {
         $array[$cnt] = new AlbumImageData();
         $array[$cnt]->album_id = $r['album_id'];
         $array[$cnt]->image_id = $r['image_id'];
         $array[$cnt]->created_at = $r['created_at'];
         $cnt++;
     }
     return $array;
 }
Exemple #16
0
 /**
  * Catch all calls, fire events and remap to real instance
  *
  * @access public
  * @param string $method
  * @param array $args
  * @return mixed
  */
 public function __call($method, array $args = array())
 {
     $event = $this->observer->createEvent()->setMethod($method)->setParams($args)->setInstance($this)->setType('before');
     $before = $this->observer->trigger()->getResult();
     if ($event->isPropagationStopped()) {
         return $before;
     }
     /** @var \Closure $closure */
     if ($closure = $this->observer->bound($method)) {
         $callback = $closure->bindTo($this, $this);
         $result = Executor::callClosure($callback, $event->getParams());
     } else {
         $result = Executor::call($this(true), $method, $event->getParams());
     }
     $event->setType('after')->setResult($result);
     return $this->observer->trigger()->getResult();
 }
Exemple #17
0
 public static function getAll()
 {
     $sql = "select * from " . self::$tablename . "";
     $query = Executor::doit($sql);
     $array = array();
     $cnt = 0;
     while ($r = $query[0]->fetch_array()) {
         $array[$cnt] = new ThemeData();
         $array[$cnt]->id = $r['id'];
         $array[$cnt]->name = $r['name'];
         $array[$cnt]->header_background_color = $r['header_background_color'];
         $array[$cnt]->header_text_color = $r['header_text_color'];
         $array[$cnt]->body_background_color = $r['body_background_color'];
         $array[$cnt]->body_text_color = $r['body_text_color'];
         $cnt++;
     }
     return $array;
 }
 public static function getInputByProductIdCutIdYesF($product_id, $cut_id)
 {
     $sql = "select * from " . self::$tablename . " where product_id={$product_id} and cut_id={$cut_id} and operation_type_id=1 order by created_at desc";
     $query = Executor::doit($sql);
     return Model::many($query[0], new OperationData());
 }
Exemple #19
0
 function delete($where)
 {
     $this->sql = "delete from " . $this->tablename . " where {$where}";
     return Executor::doit($this->sql);
 }
Exemple #20
0
 /**
  * @param array
  * @param array
  * @param array
  * @return int
  * */
 public function _exec(array $argv, array $envp, array $redirections)
 {
     $descriptors = $this->descriptors;
     foreach ($redirections as $n => $redirection) {
         if (is_array($redirection)) {
             if (($handle = @fopen($redirection[1], $redirection[0])) === FALSE) {
                 throw new Error('cannot open file ' . $redirection[1]);
             }
             $descriptors[$n] = $handle;
         } else {
             assert(is_int($redirection));
             if (!isset($descriptors[$redirection])) {
                 throw new Error('bad file descriptor ' . $redirection);
             }
             $descriptors[$n] = $descriptors[$redirection];
         }
     }
     // BREAK
     if ($argv[0] === 'break') {
         $n = 1;
         if (isset($argv[1])) {
             $n = intval($argv[1]);
         }
         throw new BuiltinBreak($n);
         // COLON
     } else {
         if ($argv[0] === ':') {
             $this->variables['?'] = 0;
         } else {
             if ($argv[0] === 'continue') {
                 $n = 1;
                 if (isset($argv[1])) {
                     $n = intval($argv[1]);
                 }
                 throw new BuiltinContinue($n);
                 // DOT
             } else {
                 if ($argv[0] === '.') {
                     if (!(isset($argv[1]) && ($contents = file_get_contents($argv[1])) !== FALSE)) {
                         if (!isset($argv[1])) {
                             throw new Error('.: no file given');
                         } else {
                             throw new Error('.: cannot read file');
                         }
                     }
                     $saved_can_read = $this->can_read;
                     $this->can_read = FALSE;
                     $saved_tokens = $this->tokens;
                     $this->tokens = $this->tokenize($contents);
                     $saved_descriptors = $this->descriptors;
                     $this->descriptors = $descriptors;
                     try {
                         $this->interpretMoreCommands();
                     } catch (BuiltinReturn $r) {
                         $this->variables['?'] = $r->getExitStatus();
                     }
                     $this->can_read = $saved_can_read;
                     $this->tokens = $saved_tokens;
                     $this->descriptors = $saved_descriptors;
                     // EVAL
                 } else {
                     if ($argv[0] === 'eval') {
                         $newtokens = $this->tokenize(implode(' ', array_slice($argv, 1)));
                         if (end($newtokens) === ';') {
                             array_pop($newtokens);
                         }
                         $this->tokens = array_merge(array(';'), $newtokens, $this->tokens);
                         // EXEC
                     } else {
                         if ($argv[0] === 'exec') {
                             if (count($argv) > 1) {
                                 fwrite($descriptors[2], "exec: only file descriptors handling implemented\n");
                                 $this->variables['?'] = 255;
                             } else {
                                 $this->descriptors = $descriptors;
                                 $this->variables['?'] = 0;
                             }
                             // EXIT
                         } else {
                             if ($argv[0] === 'exit') {
                                 $n = 0;
                                 if (isset($argv[1])) {
                                     $n = intval($argv[1]);
                                 }
                                 throw new BuiltinExit($n);
                                 // EXPORT
                             } else {
                                 if ($argv[0] === 'export') {
                                     if (isset($argv[1]) && $argv[1] === '-p') {
                                         foreach ($this->exported as $exported => $_) {
                                             if (isset($this->variables[$exported])) {
                                                 fprintf($descriptors[1], "export %s='%s'\n", $exported, $this->variables[$exported]);
                                             } else {
                                                 fprintf($descriptors[1], "export %s\n", $exported);
                                             }
                                         }
                                     } else {
                                         foreach (array_slice($argv, 1) as $variable) {
                                             if (strpos($variable, '=') !== FALSE) {
                                                 list($variable, $value) = explode('=', $variable, 2);
                                                 $this->variables[$variable] = $value;
                                             }
                                             $this->exported[$variable] = TRUE;
                                         }
                                     }
                                     $this->variables['?'] = 0;
                                     // READONLY
                                 } else {
                                     if ($argv[0] === 'readonly') {
                                         fwrite($descriptors[2], "readonly: currently not supported\n");
                                         $this->variables['?'] = 255;
                                         // RETURN
                                     } else {
                                         if ($argv[0] === 'return') {
                                             $n = 0;
                                             if (isset($argv[1])) {
                                                 $n = intval($argv[1]);
                                             }
                                             throw new BuiltinReturn($n);
                                             // SET
                                         } else {
                                             if ($argv[0] === 'set') {
                                                 fwrite($descriptors[2], "set: currently not supported\n");
                                                 $this->variables['?'] = 255;
                                                 // SHIFT
                                             } else {
                                                 if ($argv[0] === 'shift') {
                                                     $n = 1;
                                                     if (isset($argv[1])) {
                                                         $n = intval($argv[1]);
                                                     }
                                                     for ($i = 1, $c = count($this->argv); $i < $c; ++$i) {
                                                         unset($this->variables[$i]);
                                                     }
                                                     foreach (array_slice($this->argv, count($this->argv) - $this->variables['#'] + $n) as $i => $arg) {
                                                         $this->variables[$i + 1] = $arg;
                                                     }
                                                     $this->variables['#'] = $this->variables['#'] - $n;
                                                     $this->variables['?'] = 0;
                                                     // TIMES
                                                 } else {
                                                     if ($argv[0] === 'times') {
                                                         fwrite($descriptors[2], "times: currently not supported\n");
                                                         $this->variables['?'] = 255;
                                                         // TRAP
                                                     } else {
                                                         if ($argv[0] === 'trap') {
                                                             fwrite($descriptors[2], "trap: currently not supported\n");
                                                             $this->variables['?'] = 255;
                                                             // UNSET
                                                         } else {
                                                             if ($argv[0] === 'unset') {
                                                                 if (count($argv) < 2) {
                                                                     fwrite($descriptors[2], "unset: [-fv] name...\n");
                                                                     $this->variables['?'] = 255;
                                                                 } else {
                                                                     if ($argv[1] === '-f') {
                                                                         foreach (array_slice($argv, 2) as $function) {
                                                                             unset($this->functions[$function]);
                                                                         }
                                                                     } else {
                                                                         $variables = array_slice($argv, 1);
                                                                         if ($argv[1] === '-v') {
                                                                             $variables = array_slice($argv, 2);
                                                                         }
                                                                         foreach ($variables as $variable) {
                                                                             unset($this->variables[$variable]);
                                                                         }
                                                                     }
                                                                     $this->variables['?'] = 0;
                                                                 }
                                                                 // FUNCTION?
                                                             } else {
                                                                 if (isset($this->functions[$argv[0]])) {
                                                                     $saved_argv = $this->argv;
                                                                     $this->argv = $argv;
                                                                     $saved_envp = $this->envp;
                                                                     $this->envp = $envp;
                                                                     $saved_variables = $this->variables;
                                                                     $this->variables = array();
                                                                     $this->variables['#'] = count($argv) - 1;
                                                                     foreach ($argv as $k => $v) {
                                                                         $this->variables[$k] = $v;
                                                                     }
                                                                     $saved_can_read = $this->can_read;
                                                                     $this->can_read = FALSE;
                                                                     $saved_tokens = $this->tokens;
                                                                     $this->tokens = $this->functions[$argv[0]];
                                                                     $this->interpretMoreCommands();
                                                                     $saved_variables['?'] = isset($this->variables['?']) ? $this->variables['?'] : 0;
                                                                     $this->argv = $saved_argv;
                                                                     $this->envp = $saved_envp;
                                                                     $this->variables = $saved_variables;
                                                                     $this->can_read = $saved_can_read;
                                                                     $this->tokens = $saved_tokens;
                                                                     return $this->variables['?'];
                                                                     // EXTERNAL EXECUTOR
                                                                 } else {
                                                                     $this->variables['?'] = $this->executor->exec($argv, $envp, $descriptors);
                                                                     if ($this->variables['?'] === 127 && $this->interactive) {
                                                                         fwrite($this->stderr, "sh: " . $argv[0] . " not found\r\n");
                                                                     }
                                                                     return $this->variables['?'];
                                                                 }
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
Exemple #21
0
 public static function getAllByUserId($user_id)
 {
     $sql = "select * from " . self::$tablename . " where user_id={$user_id} order by created_at desc";
     $query = Executor::doit($sql);
     return Model::many($query[0], new ProductData());
 }
Exemple #22
0
 public static function getLike($q)
 {
     $sql = "select * from " . self::$tablename . " inner join profile on (user.id=profile.user_id) where name like '%{$q}%' or lastname like '%{$q}%' ";
     $query = Executor::doit($sql);
     return Model::many($query[0], new UserData());
 }
Exemple #23
0
 public static function getAllByUserId($user_id)
 {
     $sql = "select * from " . self::$tablename . " where user_id={$user_id} order by created_at desc";
     $query = Executor::doit($sql);
     $array = array();
     $cnt = 0;
     while ($r = $query[0]->fetch_array()) {
         $array[$cnt] = new ProductData();
         $array[$cnt]->id = $r['id'];
         $array[$cnt]->name = $r['name'];
         $array[$cnt]->price_in = $r['price_in'];
         $array[$cnt]->price_out = $r['price_out'];
         $array[$cnt]->presentation = $r['presentation'];
         $array[$cnt]->unit = $r['unit'];
         $array[$cnt]->user_id = $r['user_id'];
         $array[$cnt]->created_at = $r['created_at'];
         $cnt++;
     }
     return $array;
 }
Exemple #24
0
 public static function getLike($q)
 {
     $sql = "select * from " . self::$tablename . " where title like '%{$q}%' or content like '%{$q}%'";
     $query = Executor::doit($sql);
     $array = array();
     $cnt = 0;
     while ($r = $query[0]->fetch_array()) {
         $array[$cnt] = new PostData();
         $array[$cnt]->id = $r['id'];
         $array[$cnt]->title = $r['title'];
         $array[$cnt]->content = $r['content'];
         $array[$cnt]->image = $r['image'];
         $array[$cnt]->is_public = $r['is_public'];
         $array[$cnt]->user_id = $r['user_id'];
         $array[$cnt]->created_at = $r['created_at'];
         $cnt++;
     }
     return $array;
 }
Exemple #25
0
 public function buildLeads()
 {
     $leads = array();
     $keywords = Keyword::model()->findAll('deleted_at IS NULL AND status = \'' . Keyword::STATUS_CHECKED . '\'');
     foreach ($keywords as $k) {
         $domain = '';
         $executorCriteria = new CDbCriteria();
         $executorCriteria->addCondition('keyword_id = :keyword_id');
         $executorCriteria->addCondition('status = :status');
         $executorCriteria->params = array(':keyword_id' => $k->id, ':status' => Executor::STATUS_DONE);
         $executorCriteria->order = 'id DESC';
         $executor = Executor::model()->find($executorCriteria);
         if ($executor) {
             $site = Site::model()->findAll('executor_id = :executor_id', array(':executor_id' => $executor->id));
             $domain .= $site[0]->domain;
         } else {
             $domain = 'This task has never been checked';
         }
         array_push($leads, array('id' => $k->id, 'keyword' => $k->name, 'domain' => strlen($domain) > 0 ? $domain : 'No results ' . $executor->id, 'search_engine' => $k->search_engine, 'updated' => $executor->deleted_at));
     }
     return new CArrayDataProvider($leads, array('sort' => array('attributes' => array('*')), 'pagination' => array('pageSize' => 50)));
 }
Exemple #26
0
 public static function getAllBySlideId($slide_id)
 {
     $sql = "select * from " . self::$tablename . " where slide_id={$slide_id} order by created_at desc";
     $query = Executor::doit($sql);
     $array = array();
     $cnt = 0;
     while ($r = $query[0]->fetch_array()) {
         $array[$cnt] = new LoveData();
         $array[$cnt]->id = $r['id'];
         $array[$cnt]->slide_id = $r['slide_id'];
         $array[$cnt]->user_id = $r['user_id'];
         $array[$cnt]->created_at = $r['created_at'];
         $cnt++;
     }
     return $array;
 }
Exemple #27
0
 public static function getLike($q)
 {
     $sql = "select * from " . self::$tablename . " where name like '%{$q}%'";
     $query = Executor::doit($sql);
     return Model::many($query[0], new BlockData());
 }
<?php

/* @var $this SiteController */
$this->pageTitle = Yii::app()->name;
?>

<p>Tasks done: <?php 
echo Executor::model()->count('status = \'' . Executor::STATUS_DONE . '\'');
?>
</p>
<p>Tasks in total: <?php 
echo Executor::model()->count();
?>
</p>
<p>Pending keywords: <?php 
echo Keyword::model()->count('status = \'' . Keyword::STATUS_PENDING . '\'');
?>
</p>

<h3>Active Executors</h3>

<div>
    <?php 
$this->widget('zii.widgets.grid.CGridView', array('id' => 'grvKeywords', 'dataProvider' => $executor->searchActive(), 'htmlOptions' => array(), 'columns' => array(array('name' => 'id', 'header' => 'ID', 'value' => function ($e) {
    return $e->id;
}), array('name' => 'keyword_id', 'header' => 'Keyword', 'value' => function ($e) {
    return String::build('{keyword_id}: {keyword}', array('keyword' => $e->keyword->name, 'keyword_id' => $e->keyword_id));
}), array('header' => 'Search Engine', 'value' => function ($e) {
    return ucwords($e->keyword->search_engine);
}), array('name' => 'status', 'header' => 'Status', 'value' => function ($e) {
    return ucwords($e->status);
Exemple #29
0
 public static function getPublics()
 {
     $sql = "select * from " . self::$tablename . " where is_public=1";
     $query = Executor::doit($sql);
     return Model::many($query[0], new StatusData());
 }
Exemple #30
0
 public static function getAll()
 {
     $sql = "select * from " . self::$tablename . " order by created_at desc";
     $query = Executor::doit($sql);
     $array = array();
     $cnt = 0;
     while ($r = $query->fetch_array()) {
         $array[$cnt] = new AlbumData();
         $array[$cnt]->id = $r['id'];
         $array[$cnt]->name = $r['name'];
         $array[$cnt]->title = $r['title'];
         $array[$cnt]->description = $r['description'];
         $array[$cnt]->tags = $r['tags'];
         $array[$cnt]->channel_id = $r['channel_id'];
         $array[$cnt]->category_id = $r['category_id'];
         $array[$cnt]->privacy_id = $r['privacy_id'];
         $array[$cnt]->created_at = $r['created_at'];
         $cnt++;
     }
     return $array;
 }