• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP is_cli函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中is_cli函数的典型用法代码示例。如果您正苦于以下问题:PHP is_cli函数的具体用法?PHP is_cli怎么用?PHP is_cli使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: set_status_header

 /**
  * Set HTTP Status Header
  *
  * @param	int	the status code
  * @param	string
  * @return	void
  */
 function set_status_header($code = 200, $text = '')
 {
     if (is_cli()) {
         return;
     }
     if (empty($code) or !is_numeric($code)) {
         show_error('Status codes must be numeric', 500);
     }
     if (empty($text)) {
         is_int($code) or $code = (int) $code;
         $stati = [100 => 'Continue', 101 => 'Switching Protocols', 200 => 'OK', 201 => 'Created', 202 => 'Accepted', 203 => 'Non-Authoritative Information', 204 => 'No Content', 205 => 'Reset Content', 206 => 'Partial Content', 300 => 'Multiple Choices', 301 => 'Moved Permanently', 302 => 'Found', 303 => 'See Other', 304 => 'Not Modified', 305 => 'Use Proxy', 307 => 'Temporary Redirect', 400 => 'Bad Request', 401 => 'Unauthorized', 402 => 'Payment Required', 403 => 'Forbidden', 404 => 'Not Found', 405 => 'Method Not Allowed', 406 => 'Not Acceptable', 407 => 'Proxy Authentication Required', 408 => 'Request Timeout', 409 => 'Conflict', 410 => 'Gone', 411 => 'Length Required', 412 => 'Precondition Failed', 413 => 'Request Entity Too Large', 414 => 'Request-URI Too Long', 415 => 'Unsupported Media Type', 416 => 'Requested Range Not Satisfiable', 417 => 'Expectation Failed', 422 => 'Unprocessable Entity', 500 => 'Internal Server Error', 501 => 'Not Implemented', 502 => 'Bad Gateway', 503 => 'Service Unavailable', 504 => 'Gateway Timeout', 505 => 'HTTP Version Not Supported'];
         if (isset($stati[$code])) {
             $text = $stati[$code];
         } else {
             $ex = new Core\MyException();
             $ex->show_error('No status text available. Please check your status code number or supply your own message text.', 500);
         }
     }
     if (strpos(PHP_SAPI, 'cgi') === 0) {
         header('Status: ' . $code . ' ' . $text, TRUE);
     } else {
         $server_protocol = isset($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.1';
         header($server_protocol . ' ' . $code . ' ' . $text, TRUE, $code);
     }
 }
开发者ID:lucasnpinheiro,项目名称:Aulas,代码行数:32,代码来源:index.php


示例2: __construct

 /**
  * check is cli
  */
 public function __construct()
 {
     parent::__construct();
     if (!is_cli()) {
         return;
     }
 }
开发者ID:lanlin,项目名称:codeigniter-swoole,代码行数:10,代码来源:Swoole.php


示例3: show_404

 /**
  * 404 Error Handler
  *
  * @uses    CI_Exceptions::show_error()
  *
  * @param   string  $page       Page URI
  * @param   bool    $log_error  Whether to log the error
  * @return  void
  */
 public function show_404($page = '', $log_error = TRUE)
 {
     if (is_cli()) {
         $heading = 'Not Found';
         $message = 'The controller/method pair you requested was not found.';
     } else {
         $heading = lang('404_title');
         $message = lang('404_text');
     }
     // By default we log this, but allow a dev to skip it
     if ($log_error) {
         log_message('error', $heading . ': ' . $page);
     }
     $CI =& get_instance();
     $CI->output->set_status_header('404');
     $settings = $CI->settings_model->getValues(array('home_title', 'home_header', 'home_video', 'home_text', 'home_end_text'));
     $data['title'] = lang('404_title');
     $data['header'] = lang('404_title');
     $data['text'] = lang('404_text');
     $CI->load->helper('URL');
     $views = array('_head', '_header', 'site/error', '_footer');
     foreach ($views as $key => $view) {
         echo $CI->load->view('frontend/' . $view, $data, TRUE);
     }
     exit(4);
     // EXIT_UNKNOWN_FILE
 }
开发者ID:htmlpluscss,项目名称:reafit,代码行数:36,代码来源:MY_Exceptions.php


示例4: __construct

 public function __construct()
 {
     parent::__construct();
     // Load common used language
     // $this->load->language('base::app_common');
     // Load common used helpers
     $this->load->helper(['url', 'html']);
     if (!is_cli()) {
         // Load libraries & drivers
         $this->load->library('base::auths');
         // Use Redis cache
         // $this->load->driver('cache', [
         //     'adapter'    => 'redis',
         //     'backup'     => 'file',
         //     'key_prefix' => 'creasi_'
         // ]);
     }
     // Set default data keys
     $this->views->add_data(['page_name' => 'Aplikasi', 'path_name' => '/']);
     if ($this->load->config('base::lang_codes', true, true)) {
         $codes = $this->config->item('base::lang_codes', 'lang_codes');
         $lang = $this->config->item('language');
         $code = array_search($lang, $codes) ?: 'en';
     } else {
         $code = 'en';
     }
     $this->views->add_data(['lang' => $code, 'charset' => strtolower($this->config->item('charset'))]);
 }
开发者ID:bootigniter,项目名称:project,代码行数:28,代码来源:Controller.php


示例5: perform_scheduled_tasks

 public function perform_scheduled_tasks()
 {
     if (is_cli()) {
         $this->update_pending_projects();
         $this->update_closed_projects();
         if (date('Y-m-d') === date('Y-m-01')) {
             $this->generate_worker_salaries();
             $this->generate_vendor_salaries();
             $this->generate_worker_instalments();
             $this->generate_admin_salaries();
         }
         if (date('Y-m-d') === date('Y-m-t')) {
             $this->projects_closed_end_month_warning();
         }
         $this->non_payment_after_week();
         $this->non_payment_after_fortnight();
         $this->insufficient_payment_after_fortnight();
         $this->without_resources_three_days_before();
         $this->without_resources_fortnight_before();
         $this->project_start_week_before();
         $this->pending_selection_first_warning();
         $this->pending_selection_second_warning();
         $this->pending_selection_third_warning();
         $this->fortnightly_schedule();
     }
 }
开发者ID:unnus-ahmed,项目名称:chaar-bhai,代码行数:26,代码来源:Cron.php


示例6: __construct

 /**
  * Запрет на исполнение вне комендной строки
  */
 public function __construct()
 {
     parent::__construct();
     if (!is_cli()) {
         die('Only command line access');
     }
 }
开发者ID:IndiraWEB,项目名称:diplom,代码行数:10,代码来源:CLI_Controller.php


示例7: __construct

 /**
  * check is cli
  *
  * @params
  */
 public function __construct()
 {
     if (!is_cli()) {
         return;
     }
     set_time_limit(0);
 }
开发者ID:lanlin,项目名称:codeigniter-swoole,代码行数:12,代码来源:Server.php


示例8: create

 public static function create()
 {
     if (is_cli()) {
         return Sabel_Cookie_InMemory::create();
     } else {
         return Sabel_Cookie_Http::create();
     }
 }
开发者ID:reoring,项目名称:sabel,代码行数:8,代码来源:Factory.php


示例9: __construct

 /**
  * Constructor
  *
  * @access    public
  */
 public function __construct()
 {
     parent::__construct();
     // Prevent access via web. Uncomment when enough people have changed.
     if (!is_cli()) {
         die("Not Allowed");
     }
 }
开发者ID:marketcoinfork,项目名称:BitWasp-Fork,代码行数:13,代码来源:Callback.php


示例10: echo_title

function echo_title($title)
{
    if (is_cli()) {
        echo "\n** {$title} **\n\n";
    } else {
        echo "<h2>{$title}</h2>";
    }
}
开发者ID:rnrthk,项目名称:mvc_session,代码行数:8,代码来源:check_config.php


示例11: authenticate

 /**
  * Method to authenticate users before allowing install
  */
 protected function authenticate()
 {
     if (is_cli() === FALSE) {
         header('HTTP/1.1 401 Unauthorized.', TRUE, 401);
         echo 'This script can only be accessed via CLI.';
         exit(EXIT_ERROR);
     }
 }
开发者ID:versalle88,项目名称:CodeIgniter-Environment-Setup-CLI,代码行数:11,代码来源:Setup.php


示例12: __construct

 public function __construct()
 {
     parent::__construct();
     // allow execution from CLI only
     if (!is_cli()) {
         show_404();
     }
 }
开发者ID:NaszvadiG,项目名称:codeigniter_boilerplate,代码行数:8,代码来源:Cli.php


示例13: __construct

 public function __construct()
 {
     parent::__construct();
     $this->load->library('migration');
     if (!is_cli()) {
         exit('CLI mode only!');
     }
 }
开发者ID:harithaakella,项目名称:my_new_blog,代码行数:8,代码来源:Migrate.php


示例14: sendToValidateEmails

 public function sendToValidateEmails()
 {
     if (!is_cli()) {
         return;
     }
     $fodaURL = base_url() . "fodaStrategy";
     $metricURL = base_url() . "validar";
     $positions = ['coordinador', 'director'];
     $users = $this->getUsers($positions);
     $result = true;
     foreach ($users as $user) {
         $this->load->helper('email');
         if (!valid_email($user->email)) {
             echo "email de " . $user->name . ": " . $user->email . " no válido" . PHP_EOL;
             $result = false;
             continue;
         }
         $message = "Hola " . $user->name . ", se requiere su validación de los siguientes elementos:" . PHP_EOL;
         if (stristr($user->short_name, $positions[0])) {
             $this->load->model('Foda_model');
             $this->load->model('Strategy_model');
             $fodas = $this->getToValidate($this->Foda_model, 'getFoda', $user->org);
             $plans = $this->getToValidate($this->Strategy_model, 'getStrategicPlan', $user->org);
             $metric = $this->areMetricsToValidate([$user->org], ['proposed_value!=' => [null]]);
         } else {
             if (stristr($user->short_name, $positions[1])) {
                 $this->load->model('Organization_model');
                 $fodas = [];
                 $plans = [];
                 $metric = $this->areMetricsToValidate($this->Organization_model->getAllIds(), ['proposed_x_value!=' => [''], 'proposed_target!=' => [null], 'proposed_expected!=' => [null]]);
             }
         }
         if (!count($plans) && !count($fodas) && !$metric) {
             continue;
         }
         if (count($plans)) {
             $message .= " - Plan Estratégico: Tienes información que validar de " . $user->org_name . " (" . $this->getComaSeparatedYears($plans) . ")" . PHP_EOL;
         }
         if (count($fodas)) {
             $message .= " - FODA : Tienes información que validar de " . $user->org_name . " (" . $this->getComaSeparatedYears($fodas) . ")" . PHP_EOL;
         }
         if ($metric) {
             $message .= " - Tienes valores de métricas que validar." . PHP_EOL;
             $message .= "Los valores de las métricas se validan en " . $metricURL . PHP_EOL;
         }
         if (count($plans) || count($fodas)) {
             $message .= "El FODA y el plan estratégico se validan en " . $fodaURL . PHP_EOL;
         }
         $this->load->library('email');
         $this->email->from("[email protected]", "U-Dashboard");
         $this->email->to($user->email);
         $this->email->subject("Validaciones pendientes U-Dashboard");
         $this->email->message($message);
         $result = $this->email->send(false) && $result;
         echo $this->email->print_debugger();
     }
     echo PHP_EOL . ($result ? 1 : 0) . PHP_EOL;
 }
开发者ID:farodrig,项目名称:IndicadoresDCC,代码行数:58,代码来源:SendEmail.php


示例15: __construct

 function __construct()
 {
     parent::__construct();
     if (!is_cli()) {
         show_error('CLI request only.');
     }
     $this->load->helper('cron');
     echo 'Process notification queue' . PHP_EOL;
 }
开发者ID:RimeOfficial,项目名称:postmaster,代码行数:9,代码来源:Process_notification.php


示例16: __construct

 public function __construct()
 {
     parent::__construct();
     // This controller should not be called from a browser
     if (!is_cli()) {
         show_404();
     }
     $this->load->model('queue_model')->model('submit_model');
 }
开发者ID:shubham1559,项目名称:The-Campus-Judge,代码行数:9,代码来源:Queueprocess.php


示例17: is_session_started

 /**
  * Check session status
  *
  * @return bool
  */
 function is_session_started()
 {
     if (!is_cli()) {
         $result = session_status() === PHP_SESSION_ACTIVE ? TRUE : FALSE;
     } else {
         $result = FALSE;
     }
     return $result;
 }
开发者ID:madwings,项目名称:insanedb,代码行数:14,代码来源:DB_helpers.php


示例18: base_uri

 /**
  * This returns the base uri of the current module, if passed an argument
  * it automatically appended as uri.
  *
  * @param $extend_path To provide uri
  * @return string
  */
 function base_uri($extend_path = null)
 {
     if (is_cli()) {
         return;
     }
     $url = url()->getHost();
     $scheme = url()->getScheme();
     return url_trimmer($scheme . '/' . $url . '/' . $extend_path);
 }
开发者ID:ps-clarity,项目名称:support,代码行数:16,代码来源:url.php


示例19: dd

 /**
  * Debuging purposes
  *
  * @param   resource  $debug  Object or array
  * @return  string
  */
 function dd($debug = null)
 {
     if (!empty($debug)) {
         if (is_cli()) {
             $cli = new Projek\CI\Common\Console();
             return $cli->dump($debug);
         }
         echo '<pre>' . print_r($debug, true) . '</pre>';
     }
 }
开发者ID:projek-xyz,项目名称:ci-common,代码行数:16,代码来源:bootstrap.php


示例20: __construct

 /**
  * Ensures that we are running on the CLI, and collects basic settings
  * like collecting our command line arguments into a pretty array.
  */
 public function __construct()
 {
     parent::__construct();
     // Restrict usage to the command line.
     if (!is_cli()) {
         show_error(lang('cli_required'));
     }
     // Make sure the CLI library is loaded and ready.
     //        CLI::_init();
 }
开发者ID:leloulight,项目名称:Sprint,代码行数:14,代码来源:CLIController.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP is_comment_feed函数代码示例发布时间:2022-05-15
下一篇:
PHP is_child_theme函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap