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


PHP router函数代码示例

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


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

示例1: raise

    /**
     * Raises a new error message
     * @param integer $errNo
     * @param string $errMsg
     * @param string $file
     * @param integer $line
     * @return void
     * @access public
     */
    public function raise($errNo = false, $errMsg = 'An unidentified error occurred.', $file = false, $line = false)
    {
        // die if no errornum
        if (!$errNo) {
            return;
        }
        while (ob_get_level()) {
            ob_end_clean();
        }
        $errType = array(1 => "PHP Error", 2 => "PHP Warning", 4 => "PHP Parse Error", 8 => "PHP Notice", 16 => "PHP Core Error", 32 => "PHP Core Warning", 64 => "PHP Compile Error", 128 => "PHP Compile Warning", 256 => "PHP User Error", 512 => "PHP User Warning", 1024 => "PHP User Notice", 2048 => "Unknown", 4096 => "Unknown", 8192 => "Deprecated");
        $trace = array();
        $db = debug_backtrace();
        foreach ($db as $file_t) {
            if (isset($file_t['file'])) {
                $trace[] = array('file' => $file_t['file'], 'line' => $file_t['line'], 'function' => $file_t['function']);
            }
        }
        // determine uri
        if (is_object(app()->router) && method_exists(app()->router, 'fullUrl')) {
            $uri = router()->fullUrl();
        } else {
            $uri = $this->getServerValue('REQUEST_URI');
        }
        $error = array('application' => app()->config('application'), 'version_complete' => VERSION_COMPLETE, 'version' => VERSION, 'build' => BUILD, 'date' => date("Y-m-d H:i:s"), 'gmdate' => gmdate("Y-m-d H:i:s"), 'visitor_ip' => $this->getServerValue('REMOTE_ADDR'), 'referrer_url' => $this->getServerValue('HTTP_REFERER'), 'request_uri' => $uri, 'user_agent' => $this->getServerValue('HTTP_USER_AGENT'), 'error_type' => $errType[$errNo], 'error_message' => $errMsg, 'error_no' => $errNo, 'file' => $file, 'line' => $line, 'trace' => empty($trace) ? false : $trace);
        // if we're going to save to a db
        if (app()->config('save_error_to_db') && app()->checkDbConnection()) {
            $error_sql = sprintf('
				INSERT INTO error_log (
					application, version, date, visitor_ip, referer_url, request_uri,
					user_agent, error_type, error_file, error_line, error_message)
				VALUES ("%s","%s","%s","%s","%s","%s","%s","%s","%s","%s","%s")', mysql_real_escape_string($error['application']), mysql_real_escape_string($error['version_complete']), mysql_real_escape_string($error['date']), mysql_real_escape_string($error['visitor_ip']), mysql_real_escape_string($error['referrer_url']), mysql_real_escape_string($error['request_uri']), mysql_real_escape_string($error['user_agent']), mysql_real_escape_string($error['error_no']), mysql_real_escape_string($error['file']), mysql_real_escape_string($error['line']), mysql_real_escape_string($error['error_message']));
            if (!app()->db->Execute($error_sql)) {
                print 'There was an error trying to log the most recent error to the database:<p>' . app()->db->ErrorMsg() . '<p>Query was:</p>' . $error_sql;
                exit;
            }
        }
        // if logging exists, log this error
        if (isset(app()->log) && is_object(app()->log)) {
            app()->log->write(sprintf('ERROR (File: %s/%s: %s', $error['file'], $error['line'], $error['error_message']));
        }
        // If we need to display this error, do so
        if ($errNo <= app()->config('minimum_displayable_error')) {
            if (!app()->env->keyExists('SSH_CLIENT') && !app()->env->keyExists('TERM') && !app()->env->keyExists('SSH_CONNECTION') && app()->server->keyExists('HTTP_HOST')) {
                template()->setLayout('error');
                template()->display(array('error' => $error));
                exit;
            }
        }
        // post the errors to json-enabled api (snowy evening)
        if (app()->config('error_json_post_url')) {
            $params = array('api_key' => app()->config('error_json_post_api_key'), 'project_id' => app()->config('error_json_post_proj_id'), 'payload' => json_encode($error));
            $ch = curl_init();
            curl_setopt($ch, CURLOPT_URL, app()->config('error_json_post_url'));
            curl_setopt($ch, CURLOPT_POST, count($error));
            curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params));
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
            $result = curl_exec($ch);
            curl_close($ch);
        }
    }
开发者ID:viveleroi,项目名称:AspenMSM,代码行数:69,代码来源:Error.php

示例2: action

function action()
{
    router();
    if (empty($_GET[0]) || $_GET[0] == 'index.php') {
        $_GET[0] = SCRIPT_NAME;
    }
    if (empty($_GET[1])) {
        $_GET[1] = 'main';
    }
    //$_GET = array_map('strtolower', $_GET);
    // $file = CONTROLLERS_PATH . $_GET[0] . '.php';
    $file = CONTROLLERS_PATH . $_GET[0] . '.php';
    // var_dump($file ,__FILE__);exit;
    if (!file_exists($file)) {
        errors();
        exit;
        //die('The server is busy, please try again later.');
    }
    // echo  $_GET[1];eixt;
    $c = new index();
    // if( !method_exists( $c, $_GET[1] ) )
    // {
    // 	errors();
    // 	exit();
    // 	//die('The server is busy, please try again later.');
    // }
    $c->{$_GET}[1]();
    // $c->display($c->tpl);
}
开发者ID:noikiy,项目名称:webgame,代码行数:29,代码来源:functions.php

示例3: execute

 public function execute()
 {
     $ctrl = router()->getControllerName();
     if (strtolower($ctrl) == 'auth') {
         theme()->setLayout('layout.auth.tpl');
     }
 }
开发者ID:cruide,项目名称:wasp,代码行数:7,代码来源:auth_layout.php

示例4: view

 /**
  * Loads our index/default welcome/dashboard screen
  */
 public function view()
 {
     $form = new Form('config');
     // add all config variables to our form
     $sql = sprintf('SELECT * FROM config');
     $model = model()->open('config');
     $records = $model->results();
     if ($records) {
         foreach ($records as $record) {
             $value = $record['current_value'] == '' ? $record['default_value'] : $record['current_value'];
             $form->addField($record['config_key'], $value, $value);
         }
     }
     // process the form if submitted
     if ($form->isSubmitted()) {
         foreach (app()->params->getRawSource('post') as $field => $value) {
             $model->update(array('current_value' => $value), $field, 'config_key');
         }
         sml()->say('Website settings have been updated successfully.');
         router()->redirect('view');
     }
     $data['form'] = $form;
     $model = model()->open('pages');
     $model->where('page_is_live', 1);
     $data['pages'] = $model->results();
     //		$data['mods'] = app()->moduleControls();
     $data['themes'] = $this->listThemes();
     $data['live'] = settings()->getConfig('active_theme');
     template()->addCss('style.css');
     template()->addJs('admin/jquery.qtip.js');
     template()->addJs('view.js');
     template()->display($data);
 }
开发者ID:viveleroi,项目名称:AspenMSM,代码行数:36,代码来源:Admin_Admin.php

示例5: error_404

 /**
  * Activates the default loading of the 404 error
  */
 public function error_404()
 {
     router()->header_code(404);
     template()->setLayout('404');
     template()->display();
     exit;
 }
开发者ID:viveleroi,项目名称:AspenMSM,代码行数:10,代码来源:Module.php

示例6: check

 function check()
 {
     $paypal = (new Paypal())->where('paypal_hash', router()->get('payment'))->oneOrFail();
     $accessToken = $this->getAccessToken();
     $arrData = ["payer_id" => $_GET['PayerID']];
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, "https://" . $this->config['endpoint'] . "/v1/payments/payment/" . $paypal->paypal_id . "/execute/");
     curl_setopt($ch, CURLOPT_HTTPHEADER, ["Authorization: Bearer " . $accessToken, "Content-Type: application/json"]);
     curl_setopt($ch, CURLOPT_POST, true);
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
     curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($arrData));
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     $result = curl_exec($ch);
     curl_close($ch);
     if (empty($result)) {
         throw new Exception(__('error_title_cannot_execute_order'));
     } else {
         $json = json_decode($result);
         if (isset($json->state)) {
             // unknown error
             $paypal->set(["status" => $json->state, "paypal_payer_id" => $_GET['PayerID']])->save();
             /**
              * Handle successful payment.
              */
             if ($json->state == "approved") {
                 $this->order->getBills()->each(function (OrdersBill $ordersBill) use($paypal, $result) {
                     $ordersBill->confirm("Paypal " . $paypal->paypal_id . ' ' . $result, 'paypal');
                 });
             }
             if ($json->state == "pending") {
                 response()->redirect(url('derive.payment.waiting', ['handler' => 'paypal', 'order' => $this->order->getOrder()]));
                 /**
                  * Debug::addWarning(
                  * "Status naročila je <i>$json->state</i>. Ko bo naročilo potrjeno, vas bomo obvestili preko email naslova."
                  * );*/
             } else {
                 if ($json->state == "approved") {
                     response()->redirect(url('derive.payment.success', ['handler' => 'paypal', 'order' => $this->order->getOrder()]));
                 } else {
                     response()->redirect(url('derive.payment.error', ['handler' => 'paypal', 'order' => $this->order->getOrder()]));
                     /**
                      * Debug::addError(__('error_title_unknown_payment_status'));
                      *
                      */
                 }
             }
         } else {
             /*var_dump($json);
               echo '<pre>';
               print_r($json);
               echo '</pre>';
               echo $result;
               die("failed");*/
             response()->redirect(url('derive.payment.error', ['handler' => 'paypal', 'order' => $this->order->getOrder()]));
             /*Debug::addError(__('error_title_order_confirmation_failed'));*/
         }
     }
 }
开发者ID:pckg,项目名称:payment,代码行数:58,代码来源:PaypalGnp.php

示例7: authCheckRoute

 public function authCheckRoute()
 {
     try {
         $route = (new RouteResolver())->resolve(router()->getUri());
     } catch (NotFound $e) {
         return true;
     }
     return $route->hasPermissionToView();
 }
开发者ID:pckg,项目名称:generic,代码行数:9,代码来源:Generic.php

示例8: start

function start()
{
    if (!isset($_GET['page'])) {
        require 'views/home.php';
    } else {
        $page = $_GET['page'];
        router($page);
    }
}
开发者ID:AmbreB,项目名称:ExercicesSimplon,代码行数:9,代码来源:index.php

示例9: isActive

 public function isActive()
 {
     if (router()->getCleanUri() == $this->url) {
         return true;
     }
     if (router()->get('name') == 'dynamic.record.edit' && $this->url == '/dynamic/tables/list/' . explode('/', router()->getCleanUri())[4]) {
         return true;
     }
     return $this->isSubActive();
 }
开发者ID:pckg,项目名称:generic,代码行数:10,代码来源:MenuItem.php

示例10: __construct

 public function __construct()
 {
     /**
      * Просматриваем какие языки есть
      */
     foreach ($this->lagnuages as $key => $val) {
         $LF = wasp_strtolower($key . '.php');
         if (!is_file(LANGUAGE_DIR . DIR_SEP . $LF)) {
             unset($this->lagnuages[$key]);
         }
     }
     unset($LF, $key, $val);
     /**
      * Смотрим язык установленный в конфиге
      */
     $config = cfg('config')->application;
     $DL = !empty($config->language) ? $config->language : null;
     if (!empty($DL) && array_key_isset($DL, $this->lagnuages)) {
         $this->DEFAULT_LANG = $this->CURRENT_LANG = wasp_strtoupper($DL);
     }
     unset($config, $DL);
     $cookie_lang = cookie()->get('LANG');
     if (!empty($cookie_lang) && array_key_isset($cookie_lang, $this->lagnuages)) {
         $this->CURRENT_LANG = $cookie_lang;
     }
     /**
      * Загружаем языковые пакеты
      */
     $this->strings = new stdObject();
     $default_lang_file = wasp_strtolower($this->DEFAULT_LANG . '.php');
     if (is_dir(LANGUAGE_DIR) && is_file(LANGUAGE_DIR . DIR_SEP . $default_lang_file)) {
         $default_lng_strings = (include LANGUAGE_DIR . DIR_SEP . $default_lang_file);
         if (array_count($default_lng_strings) > 0) {
             foreach ($default_lng_strings as $key => $val) {
                 if (is_varible_name($key) && is_scalar($val)) {
                     $this->strings->{$key} = $val;
                 }
             }
         }
     }
     if ($this->DEFAULT_LANG != $this->CURRENT_LANG) {
         $default_lang_file = wasp_strtolower($this->CURRENT_LANG . '.php');
         if (is_dir(LANGUAGE_DIR) && is_file(LANGUAGE_DIR . DIR_SEP . $default_lang_file)) {
             $default_lng_strings = (include LANGUAGE_DIR . DIR_SEP . $default_lang_file);
             if (array_count($default_lng_strings) > 0) {
                 foreach ($default_lng_strings as $key => $val) {
                     if (is_varible_name($key) && is_scalar($val)) {
                         $this->strings->{$key} = $val;
                     }
                 }
             }
         }
     }
     $this->getControllerLang(router()->getControllerName());
 }
开发者ID:cruide,项目名称:wasp,代码行数:55,代码来源:i18n.php

示例11: __construct

 public function __construct()
 {
     $this->config = cfg('config');
     $this->cookie = cookie();
     $this->router = router();
     $this->input = input();
     $this->session = session();
     if (method_exists($this, '_prepare')) {
         $this->_prepare();
     }
 }
开发者ID:cruide,项目名称:wasp,代码行数:11,代码来源:library.php

示例12: execute

 public function execute(callable $next)
 {
     if ($this->request->isGet() && !$this->request->isAjax()) {
         $output = $this->response->getOutput();
         if (is_string($output) && substr($output, 0, 5) !== '<html' && strtolower(substr($output, 0, 9)) != '<!doctype') {
             $template = router()->get()['pckg']['generic']['template'] ?? 'Pckg\\Generic:generic';
             $output = Reflect::create(Generic::class)->wrapIntoGeneric($output, $template);
             $this->response->setOutput($output);
         }
     }
     return $next();
 }
开发者ID:pckg,项目名称:generic,代码行数:12,代码来源:EncapsulateResponse.php

示例13: getOgTags

    public function getOgTags()
    {
        $image = $this->image ? htmlspecialchars(config('url') . str_replace(' ', '%20', $this->image)) : '';
        $title = trim(strip_tags($this->title));
        $description = trim(strip_tags($this->description));
        return '<meta property="og:title" content="' . $title . '" />
		<meta property="og:site_name" content="' . $title . '" />
		<meta property="og:description" content="' . $description . '" />
		<meta property="og:type" content="website" />
		<meta property="og:url" content="' . router()->getUri(false) . '" />
		<meta property="fb:admins" content="1197210626" />
		<meta property="fb:app_id" content="' . config('pckg.manager.seo.app_id') . '" />
		<meta property="og:image" content="' . $image . '" />';
    }
开发者ID:pckg,项目名称:manager,代码行数:14,代码来源:Seo.php

示例14: __construct

 /**
  *
  */
 public function __construct()
 {
     parent::__construct();
     $this->setAttribute('action', router()->getUri());
     $this->setID('form' . array_reverse(explode('\\', get_class($this)))[0]);
     $this->setName('form' . array_reverse(explode('\\', get_class($this)))[0]);
     $this->setMethod('post');
     $this->setMultipart();
     foreach ($this->handlerFactory->create([Step::class]) as $handler) {
         $this->addHandler($handler);
     }
     $this->formFactory = new FormFactory();
     $this->addFieldset();
 }
开发者ID:pckg,项目名称:htmlbuilder,代码行数:17,代码来源:Form.php

示例15: __construct

 public function __construct()
 {
     $this->config = cfg('config');
     $this->session = session();
     $this->input = input();
     $this->cookie = cookie();
     $this->layout = theme();
     $this->router = router();
     $this->ui = new Ui();
     $this->ui->enableSecurity('Wasp_Smarty_Security');
     $this->ui->setTemplateDir($this->layout->getThemePath() . DIR_SEP . 'views' . DIR_SEP);
     $temp_dir = TEMP_DIR . DIR_SEP . 'smarty' . DIR_SEP . theme()->getThemeName() . DIR_SEP . 'views';
     if (!is_dir($temp_dir)) {
         wasp_mkdir($temp_dir);
     }
     $this->ui->setCompileDir($temp_dir . DIR_SEP);
     //        $this->ui->setCacheDir('');
 }
开发者ID:cruide,项目名称:wasp,代码行数:18,代码来源:controller.php


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