Example #1
0
 /**
  * 消息页面
  *
  * @param string $message
  * @param string $url
  * @param integer $time
  * @param string $template
  *
  */
 public static function displayMessage($message, $url = '', $time = 3, $template = 'error/message.php')
 {
     $request = new \Yaf\Request\Simple();
     if (empty($url)) {
         $url = $request->getServer()['HTTP_REFERER'];
     }
     $view = new \Yaf\View\Simple($request);
     $view->setScriptPath(\Yaf\Registry::get('config')->application->view->path);
     $view->assign('message', \Yaf\Registry::get('lang')->translate($message));
     $view->assign('url', $url);
     $view->assign('time', $time);
     $view->display($template);
     exit;
 }
Example #2
0
#!/usr/bin/env php
<?php 
/**
 * 命令行执行PHP 入口
 * php ./app/cli.php "/crontab/sendmailt?a=1&b=c"
 * php ./app/cli.php "/{控制器名}/{方法名}?{参数}"
 */
set_time_limit(0);
ini_set('memory_limit', '256M');
// define it for not auto running.
// like testcase, so that we can depand cli argv to choose which controller run it.
define('APPLICATION_NOT_RUN', true);
// Import application and bootstrap.
\Yaf\Loader::import(dirname(__DIR__) . '/public/index.php');
$request = new \Yaf\Request\Simple();
// parse cli
global $argc, $argv;
if ($argc > 1) {
    $module = '';
    $uri = $argv[1];
    if (preg_match('/^[^?]*%/i', $uri)) {
        list($module, $uri) = explode('%', $uri, 2);
    }
    $module = strtolower($module);
    $modules = \Yaf\Application::app()->getModules();
    if (in_array(ucfirst($module), $modules)) {
        $request->setModuleName($module);
    }
    if (false === strpos($uri, '?')) {
        $args = array();
    } else {