Exemple #1
0
 /**
  * 设置application
  */
 public function setApplication()
 {
     $application = null;
     define('APPLICATION_NOT_RUN', true);
     Loader::import(APPLICATION_PATH . 'public/index.php');
     Registry::set('application', $application);
 }
Exemple #2
0
 /**
  * 导入模块下lib目录下的文件
  *
  * @access public
  * @param string $class_name 包含命名空间的类名称
  * @return bool|void
  */
 public static function lib($class_name)
 {
     if (class_exists($class_name, false)) {
         return true;
     }
     return InternalLoader::import(ROOT_PATH . DS . APP_NAME . DS . 'modules' . DS . $class_name . ".php");
 }
Exemple #3
0
 public function init($yaf_app)
 {
     static $initialized = false;
     if (!$initialized) {
         $initialized = true;
         \Yaf\Loader::import(YK_CORE_ROOT . '/func.php');
         $config = $yaf_app->getConfig()->toArray();
         \Yaf\Registry::set('_config', $config);
         $level = $config['debug'] ? $config['debug'] == 1 ? E_ERROR : E_ALL : 0;
         define('MAIN_DEBUG', $config['debug']);
         if (MAIN_DEBUG) {
             ini_set('display_error', 'On');
         }
         error_reporting($level);
         define('TIMESTAMP', time());
         \Yaf\Registry::set('_clientip', isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : 'N/A');
         \Yaf\Registry::set('_clientport', isset($_SERVER['REMOTE_PORT']) ? $_SERVER['REMOTE_PORT'] : 0);
         \Yaf\Registry::set('_gzip', !isset($_SERVER['HTTP_ACCEPT_ENCODING']) || strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') === false || !function_exists('ob_gzhandler') ? false : true);
         set_timeoffset($config['timeoffset']);
         //重置视图
         $view = new view();
         \Yaf\Registry::set('_view', $view);
         $yaf_app->getDispatcher()->setView($view);
         define('CHARSET', 'utf-8');
         //end
     }
 }
Exemple #4
0
 function _initPlugin(Dispatcher $dispatcher)
 {
     Loader::import('vendor/autoload.php');
     $dispatcher->registerPlugin(new PHPConfig());
     $dispatcher->registerPlugin(new LoginPlugin());
     $dispatcher->registerPlugin(new Module(array(Module::TYPE_CLI => array('enable' => true))));
 }
Exemple #5
0
 /**
  * setup yaf
  */
 private function __setUpYafApplication()
 {
     $this->__setUpPHPIniVariables();
     // Import application and bootstrap.
     \Yaf\Loader::import(dirname(__DIR__) . '/public/index.php');
     $this->__setUpApplicationInit();
     \Yaf\Dispatcher::getInstance()->registerPlugin(new \YafUnit\Plugin\View());
     \Yaf\Registry::set('ApplicationInit', true);
 }
Exemple #6
0
 public function muneeAction()
 {
     // Define webroot
     define('WEBROOT', APPLICATION_PATH . "/public");
     // Include munee.phar
     Loader::import("Munee/autoload.php");
     //Error
     ob_clean();
     // Echo out the response
     echo \Munee\Dispatcher::run(new \Munee\Request(array('css' => array('lessifyAllCss' => false), 'image' => array('checkReferrer' => false))));
     die;
 }
Exemple #7
0
 /**
  * 加载函数目录
  */
 public function _initFunction(\Yaf\Dispatcher $dispatcher)
 {
     $import_function = $this->config->get('application.function');
     if ($import_function) {
         $import_function = explode(',', $import_function);
         foreach ($import_function as $item) {
             $item = trim($item);
             $file = CORE_LIB_PATH . '/function/' . $item . '.php';
             if (!is_file($file)) {
                 continue;
             }
             \Yaf\Loader::import($file);
         }
     }
 }
 public function _initSmarty(Dispatcher $dispatcher)
 {
     Loader::import("smarty/Adapter.php");
     $smarty = new Smarty_Adapter(null, Registry::get("config")->get("smarty")->get("index"));
     Registry::set("Smarty", $smarty);
     $dispatcher->setView($smarty);
 }
Exemple #9
0
 /**
  * 数据合法性检查
  */
 protected function validate()
 {
     try {
         // 读取校验文件
         $module = MODULES_NAME;
         $controller = CONTROLLER_NAME . 'Form';
         $action = ACTION_NAME . 'Rules';
         // 数据校验
         Loader::import(APPLICATION_PATH . "modules/{$module}/validates/{$controller}.php");
         $rules = $controller::$action();
         return Validate::validity($rules);
     } catch (\Security\FormException $e) {
         // ajax输出
         IS_AJAX and $this->jsonp([$rules[$e->getCode()][0] => $e->getMessage()], 412);
         // 页面输出
         $this->view(['notify' => $e->getMessage()], 'common/notify', TRUE);
         exit;
     }
 }
 public function _initHelper()
 {
     Loader::import(APP_PATH . 'helper' . DS . 'functions.php');
 }
Exemple #11
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 {
Exemple #12
0
/**
 * Created by PhpStorm.
 * User: admin
 * Date: 14/11/26
 * Time: 下午2:48
 */
namespace Smarty;

use Yaf\View_Interface;
use Yaf\Loader;
Loader::import("Smarty/libs/Smarty.class.php");
Loader::import("Smarty/libs/sysplugins/smarty_internal_templatecompilerbase.php");
Loader::import("Smarty/libs/sysplugins/smarty_internal_templatelexer.php");
Loader::import("Smarty/libs/sysplugins/smarty_internal_templateparser.php");
Loader::import("Smarty/libs/sysplugins/smarty_internal_compilebase.php");
Loader::import("Smarty/libs/sysplugins/smarty_internal_write_file.php");
class Adapter implements View_Interface
{
    /**
     * Smarty object
     * @var Smarty
     */
    public $_smarty;
    /**
     * smarty插件入口
     *
     * @param null $tmplPath
     * @param array $extraParams
     * @throws Exception
     * @throws \SmartyException
     */
Exemple #13
0
 function _initAutoload(Dispatcher $dispatcher)
 {
     Loader::import('vendor/autoload.php');
 }
Exemple #14
0
 /**
  * 公用函数载入
  */
 public function _initFunction()
 {
     \Yaf\Loader::import('Common/functions.php');
 }
Exemple #15
0
<?php

/**
 * 命令行执行PHP 入口
 * @author Lancer He <*****@*****.**>
 */
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(__FILE__) . '/../public/index.php');
// Init a request for cli mode, Like
//      php ./application/Cli.php "request_uri=/cli/crontab/sendmailtorepayment"
//          module:cli, controller:crontab, action:sendMailToPayment
//      php ./application/Cli.php "request_uri=/cli/daemon/backup"
//          module:cli, controller:daemon, action:backup
$request = new \Yaf\Request\Simple();
// route uri => request
\Yaf\Dispatcher::getInstance()->getRouter()->route($request);
// dispatch this request
\Yaf\Dispatcher::getInstance()->dispatch($request);
 public function _initUtil(\Yaf\Dispatcher $dispatcher)
 {
     \Yaf\Loader::import('Common/Util.php');
 }