当前位置: 首页>>代码示例>>PHP>>正文


PHP Console::getInstance方法代码示例

本文整理汇总了PHP中Console::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP Console::getInstance方法的具体用法?PHP Console::getInstance怎么用?PHP Console::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Console的用法示例。


在下文中一共展示了Console::getInstance方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getPosition

 public function getPosition($from = 1, $count = 1)
 {
     $console = Console::getInstance();
     $console->operationStart('Collecting search results');
     $this->pageNumber = ceil($from / $this->positionsPerPage);
     if ($count < 1 || $count > 10) {
         $console->operationEnd();
         $console - error('Count must be in 1-10. ' . $count . ' is setted');
         return false;
     }
     $sites = array();
     $position = 1;
     do {
         $console->operationStep();
         $pageResults = $this->getPageResults();
         foreach ($pageResults as $pr) {
             $sitesCount = count($sites);
             $domain = ($domain = String::rebuildUrl($pr->url, false, false, true, false)) ? $domain : $pr->url;
             if (IgnoreList::isInList($domain) || $sitesCount && $sites[$sitesCount - 1]->domain == $domain) {
                 continue;
             }
             $site = new Site();
             $site->name = strip_tags($pr->title);
             $site->position = $position++;
             $site->link = $pr->url;
             $site->domain = $domain;
             $sites[] = $site;
         }
         $this->pageNumber++;
     } while ($sitesCount < $count);
     //$this->pageNumber++ * $this->positionsPerPage < $count // old
     $console->operationEnd();
     return array_slice($sites, 0, $count);
 }
开发者ID:evgeniys-hyuna,项目名称:leadsite,代码行数:34,代码来源:GoogleSearchEngine.php

示例2: actionIndex

 public function actionIndex($isForced = false, $isDebug = false)
 {
     $console = Console::getInstance($isForced, $isDebug);
     $console->debugStart('Entered');
     //        if (mail('evgeniy.siderka@hyuna.bb', 'test', 'test message')) {
     //            $console->writeLine('OK');
     //        } else {
     //            $console->writeLine('Failure');
     //        }
     $newExecutors = Site::getNewExecutors('2015-11-19 12:20:00');
     $report = '';
     foreach ($newExecutors as $e) {
         $sites = Site::model()->findAllByAttributes(array('executor_id' => $e));
         if (count($sites) < 1) {
             continue;
         }
         $report .= String::build('Positions for "{keyword}" ({date_from} - {date_to})', array('keyword' => $sites[0]->keyword->name, 'date_from' => Time::toPretty($sites[0]->updated_at), 'date_to' => Time::toPretty($sites[count($sites) - 1]->updated_at))) . PHP_EOL;
         foreach ($sites as $s) {
             $report .= String::build('{position}: {site}', array('position' => $s->position, 'site' => String::rebuildUrl($s->link, false, false, true, false))) . PHP_EOL;
         }
     }
     $console->writeLine($report);
     $console->debugEnd();
     return;
 }
开发者ID:evgeniys-hyuna,项目名称:leadsite,代码行数:25,代码来源:TestCommand.php

示例3: __callStatic

 public static function __callStatic($method, $args)
 {
     $instance = Console::getInstance();
     if (!method_exists($instance, $method)) {
         throw new \Exception('PHPConsoleLog - method "' . $method . '" does not exist.');
     }
     return call_user_func_array([$instance, $method], $args);
 }
开发者ID:nyratas,项目名称:php-console-log,代码行数:8,代码来源:Service.php

示例4: actionIndex

 public function actionIndex($isForced = false, $isDebug = false)
 {
     $console = Console::getInstance($isForced, $isDebug);
     $console->writeLine('Initializing');
     $criteria = new CDbCriteria();
     $criteria->alias = 'keyword';
     $criteria->addCondition('keyword.period > 0');
     $criteria->addNotInCondition('keyword.status', array(Keyword::STATUS_PENDING, Keyword::STATUS_TAKEN, Keyword::STATUS_IN_PROGRESS));
     $keyword = Keyword::model()->findAll($criteria);
     $console->progressStart('Updating keywords', count($keyword));
     foreach ($keyword as $k) {
         $console->progressStep();
         if (time() > strtotime($k->checked_at) + $k->period) {
             $k->setStatus(Keyword::STATUS_PENDING);
         }
     }
     $console->progressEnd();
 }
开发者ID:evgeniys-hyuna,项目名称:leadsite,代码行数:18,代码来源:KeywordServiceCommand.php

示例5: actionIndex

 public function actionIndex($isForced = false, $isDebug = false)
 {
     $console = Console::getInstance($isForced, $isDebug);
     $console->writeLine('Searching for tasks');
     $report = Report::model()->findAll();
     if (count($report) <= 0) {
         $console->writeLine('No tasks');
         return;
     }
     $console->progressStart('Sending reports', count($report));
     foreach ($report as $r) {
         $console->progressStep();
         if ($r->isTimeToUpdate()) {
             try {
                 $r->send();
             } catch (Exception $ex) {
                 $console->error($ex->getMessage());
             }
         }
     }
     $console->progressEnd();
     return;
 }
开发者ID:evgeniys-hyuna,项目名称:leadsite,代码行数:23,代码来源:ReportCommand.php

示例6: actionIndex

 public function actionIndex($isForced = false, $isDebug = false)
 {
     $console = Console::getInstance($isForced, $isDebug);
     $terminated = false;
     $console->writeLine('Initializing');
     //        if (Executor::model()->count() >= Settings::getValue(Settings::SIMULTANEOUS_EXECUTORS_LIMIT)) {
     //            $console->error('Executors limit is reached');
     //
     //            return;
     //        }
     $executor = new Executor();
     $executor->save();
     $executorTaskSearchCooldown = Settings::getValue(Settings::EXECUTOR_TASK_SEARCH_COOLDOWN);
     $executorTaskSearchLimit = Settings::getValue(Settings::EXECUTOR_TASK_SEARCH_LIMIT);
     while (!$terminated) {
         // Search for task
         $console->operationStart('Searching for tasks');
         $executor->setStatus(Executor::STATUS_SEARCHING);
         try {
             $attempt = 1;
             while (!$executor->findTask()) {
                 sleep($executorTaskSearchCooldown);
                 $console->operationStep();
                 if ($attempt++ > $executorTaskSearchLimit) {
                     $console->writeLine('No new tasks');
                     $executor->delete();
                     return;
                 }
             }
             $executor->refresh();
         } catch (Exception $ex) {
             $executor->keyword->setStatus(Keyword::STATUS_PENDING);
             $executor->setStatus(Executor::STATUS_ERROR);
             $console->error($ex->getMessage());
             $terminated = true;
             continue;
         }
         $console->operationEnd();
         // Start check
         $console->writeLine('Checking keyword "' . $executor->keyword->name . '"');
         $executor->keyword->setStatus(Keyword::STATUS_IN_PROGRESS);
         $executor->setStatus(Executor::STATUS_CHECKING);
         $googleSearchEngine = new GoogleSearchEngineIt();
         $googleSearchEngine->search($executor->keyword->name);
         $sites;
         try {
             $sites = $googleSearchEngine->getPosition(1, 10);
         } catch (Exception $ex) {
             $executor->keyword->setStatus(Keyword::STATUS_PENDING);
             $executor->status = Executor::STATUS_ERROR;
             $executor->message = $ex->getMessage();
             $executor->update();
             $console->error($ex->getMessage());
             $terminated = true;
             continue;
         }
         // Save results
         $console->progressStart('Saving results', count($sites));
         foreach ($sites as $s) {
             $console->progressStep();
             $s->keyword_id = $executor->keyword_id;
             $s->save();
         }
         $console->progressEnd();
         $executor->keyword->setStatus(Keyword::STATUS_CHECKED);
         $executor->setStatus(Executor::STATUS_PENDING);
     }
     if ($executor->status == Executor::STATUS_ERROR) {
         $executor->setStatus(Executor::STATUS_COOLDOWN);
         sleep(Settings::getValue(Settings::ABUSE_COOLDOWN));
     }
     $executor->delete();
     $console->writeLine('Execution terminated');
     return;
 }
开发者ID:evgeniys-hyuna,项目名称:leadsite,代码行数:75,代码来源:ExecutorTestCommand.php

示例7: actionIndex

 public function actionIndex($isForced = false, $isDebug = false)
 {
     $console = Console::getInstance($isForced, $isDebug);
     $console->writeLine('Initializing');
     $executor = new Executor();
     // Search for task
     $console->writeLine('Searching for tasks');
     try {
         if (!$executor->findTask()) {
             $console->writeLine('No new tasks');
             return;
         }
     } catch (Exception $ex) {
         $console->error($ex->getMessage());
         return;
     }
     $executor->save();
     // Start check
     $console->writeLine('Checking keyword "' . $executor->keyword->name . '"');
     $executor->keyword->setStatus(Keyword::STATUS_IN_PROGRESS);
     $executor->setStatus(Executor::STATUS_CHECKING);
     // Select search engine
     $searchEngine;
     switch ($executor->keyword->search_engine) {
         case Keyword::SEARCH_ENGINE_GOOGLE:
             $searchEngine = new GoogleSearchEngine();
             break;
         case Keyword::SEARCH_ENGINE_GOOGLE_ES:
             $searchEngine = new GoogleSearchEngineEs();
             break;
         case Keyword::SEARCH_ENGINE_GOOGLE_IT:
             $searchEngine = new GoogleSearchEngineIt();
             break;
         case Keyword::SEARCH_ENGINE_GOOGLE_FR:
             $searchEngine = new GoogleSearchEngineFr();
             break;
         default:
             $errorMessage = 'Unknown search engine: ' . $executor->keyword->search_engine;
             $executor->keyword->setStatus(Keyword::STATUS_PENDING);
             $executor->status = Executor::STATUS_ERROR;
             $executor->message = $errorMessage;
             $executor->update();
             $console->error($errorMessage);
             return;
     }
     $console->writeLine('Using ' . $searchEngine->getSearchEngine() . ' search engine');
     $searchEngine->search($executor->keyword->name);
     $sites;
     try {
         $sites = $searchEngine->getPosition(1, 10);
     } catch (Exception $ex) {
         $executor->keyword->setStatus(Keyword::STATUS_PENDING);
         $executor->status = Executor::STATUS_ERROR;
         $executor->message = $ex->getMessage();
         $executor->update();
         $console->error($ex->getMessage());
         return;
     }
     // Mark previous results as deleted
     $previousSiteCriteria = new CDbCriteria();
     $previousSiteCriteria->alias = 'site';
     $previousSiteCriteria->addCondition('site.keyword_id = :keyword_id');
     $previousSiteCriteria->params = array(':keyword_id' => $executor->keyword_id);
     $previousSiteCriteria->order = 'site.executor_id DESC';
     $previousSiteCriteria->limit = 1;
     if ($previousSite = Site::model()->find($previousSiteCriteria)) {
         Site::model()->updateAll(array('deleted_at' => date(Time::FORMAT_STANDART)), 'executor_id = :executor_id', array(':executor_id' => $previousSite->executor_id));
     }
     // Save new results
     $console->progressStart('Saving results', count($sites));
     foreach ($sites as $s) {
         $console->progressStep();
         $s->keyword_id = $executor->keyword_id;
         $s->executor_id = $executor->id;
         $s->save();
     }
     $console->progressEnd();
     $executor->keyword->setStatus(Keyword::STATUS_CHECKED);
     $executor->setStatus(Executor::STATUS_PENDING);
     if ($executor->status == Executor::STATUS_ERROR) {
         $executor->setStatus(Executor::STATUS_COOLDOWN);
         sleep(Settings::getValue(Settings::ABUSE_COOLDOWN));
     }
     $executor->stop();
     $console->writeLine('Execution terminated');
     return;
 }
开发者ID:evgeniys-hyuna,项目名称:leadsite,代码行数:87,代码来源:ExecutorCommand.php

示例8: proccessSiteMap

}
function proccessSiteMap($siteMapXmlArray)
{
    if (isset($siteMapXmlArray['urlset']['url']['loc'])) {
        $siteMapXmlArray['urlset']['url'] = array($siteMapXmlArray['urlset']['url']);
    }
    foreach ($siteMapXmlArray['urlset']['url'] as $url) {
        $GLOBALS['urls'][] = $url;
    }
}
function get_http_response_code($theURL)
{
    $headers = get_headers($theURL);
    return (int) substr($headers[0], 9, 3);
}
$console = Console::getInstance();
if (!isset($argv[1])) {
    $console->writeLine("Sitemap url not set", Color::RED);
    die;
}
$sitemapUrl = $argv[1];
proccessSiteMapUrl($sitemapUrl);
$countUrls = count($urls);
$console->writeLine("Url count: " . $countUrls);
$i = 0;
foreach ($urls as $url) {
    $i++;
    echo "On " . $i . " of " . $countUrls . ($i === $countUrls ? "\n" : "\r");
    usleep(1000);
    $code = get_http_response_code($url['loc']);
    if (!isset($responseCodes[$code])) {
开发者ID:NeoCortexBg,项目名称:sitemap_checker,代码行数:31,代码来源:check_sitemap.php


注:本文中的Console::getInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。