Example #1
0
 /**
  * @param  string mysql database name
  * @return [type]
  */
 public static function linkDb($dbname = "_default")
 {
     if (isset(self::$link[$dbname])) {
         return self::$link[$dbname];
     }
     $config = Yaf_Registry::get('config');
     if (!$config->database->get($dbname)) {
         return false;
     }
     $host = $config->database->get($dbname)->host;
     $port = $config->database->get($dbname)->port;
     $user = $config->database->get($dbname)->username;
     $password = $config->database->get($dbname)->password;
     $name = $config->database->get($dbname)->dbname;
     $charset = isset($config->database->get($dbname)->charset) ? $config->database->get($dbname)->charset : "UTF8";
     try {
         $link_temp = new PDO('mysql:host=' . $host . ';port=' . $port . ';dbname=' . $name . ';charset=' . $charset, $user, $password, $arrayName = array(PDO::ATTR_PERSISTENT => false));
         $link_temp->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
         //PHP5.3.6以下,需禁用仿真预处理,防止注入
         $link_temp->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
         self::$link[$dbname] = new FluentPDO($link_temp);
     } catch (Exception $e) {
         self::$link[$dbname] = null;
     }
     if (!self::$link[$dbname]) {
         return false;
     }
     return self::$link[$dbname];
 }
Example #2
0
 /**
  * 实例化调用方法,传递需要的数据到模板
  */
 protected function run()
 {
     $_function_get = 'get_' . $this->class_key;
     #$_class_key = $this->object_code.'_'.$this->class_key;
     #$this->add_data($_class_key,$this->$_function_get());
     #DebugTools::print_r($this->$_function_get());
     if ($this->output == 'html') {
         $dir = Yaf_Registry::get('config')->application->directory . '/widgets/views/';
         $widget_view = new Yaf_View_Simple($dir);
         $widget_view->assign('data', $this->{$_function_get}());
         $widget_view->assign('assist_data', $this->assist_data);
         echo $widget_view->render($this->class_key . '.phtml');
         #DebugTools::print_r($res);
         #Yaf_Loader::getInstance()->import($dir.'/item_condition.phtml');
         #DebugTools::print_r($widget_view);
         /*if (empty($this->view)){$this->view = $this->class_key;}
           $this->render($this->view,array(
               'data'=>$this->$_function_get(),
               'assist_data'=>$this->assist_data
           ));*/
     } else {
         if ($this->output == 'json') {
             $this->output_json($this->{$_function_get}());
         } else {
             if ($this->output == 'array') {
                 $this->output_array($this->{$_function_get}());
             }
         }
     }
 }
Example #3
0
 public function startAction()
 {
     $config = Yaf_Registry::get('monitor_config');
     $dataName = $config['loghandle'][$this->logType]['data'];
     $stepTime = intval($config['loghandle'][$this->logType]['step']);
     $logPersistentService = new Service_Log_Persistent();
     $logApp = $logPersistentService->getAppId();
     foreach ($logApp as $table => $appId) {
         $pid = pcntl_fork();
         if (!$pid) {
             $logDataService = new Service_Log_Data($this->logType, $dataName);
             $dataResult = $logDataService->getWeblog($table, $stepTime);
             if (!$dataResult) {
                 return false;
             }
             $etlModel = Model_Loghandle_Etl_Factory::create($this->logType, 'key');
             $extraData = array('logapp' => $logApp, 'data' => $dataResult, 'table' => $table);
             $transData = $etlModel->transform($extraData);
             $firstData = current($dataResult);
             $time = $firstData['time']->sec;
             $etlModel->load($transData, $time);
             exit;
         }
     }
     return false;
 }
Example #4
0
 public function __construct()
 {
     $tWeixinarr = Yaf_Registry::get("config")->weixin->default->toArray();
     $this->appId = $tWeixinarr['appID'];
     $this->appSecret = $tWeixinarr['appsecret'];
     $this->token = $tWeixinarr['token'];
 }
Example #5
0
 public function startAction()
 {
     $config = Yaf_Registry::get('monitor_config');
     $dataName = $config['loghandle'][$this->logType]['data'];
     $stepTime = intval($config['loghandle'][$this->logType]['step']);
     $modes = explode(',', $config['loghandle'][$this->logType]['mode']);
     $tables = explode(",", trim($config['mongo'][$this->logType]['tables']));
     $logDataService = new Service_Log_Data($this->logType, $dataName);
     $dataResult = $logDataService->getAccessLog($tables, $stepTime);
     if (!$dataResult) {
         return false;
     }
     $firstData = current($dataResult);
     $time = $firstData['time']->sec;
     $modeNum = count($modes);
     $loghandleEtlParserModel = new Model_Loghandle_Etl_Parser();
     $extractData = $loghandleEtlParserModel->extract($dataResult);
     for ($i = 0; $i < $modeNum; $i++) {
         $pid = pcntl_fork();
         $mode = $modes[$i];
         if (!$pid) {
             $etlModel = Model_Loghandle_Etl_Factory::create($this->logType, $mode);
             $transData = $etlModel->transform($extractData);
             $etlModel->load($transData, $time);
             exit;
         }
     }
     return false;
 }
Example #6
0
 public function _init(Yaf_Dispatcher $dispatcher)
 {
     // auto start session
     Yaf_Session::getInstance()->start();
     // auto load config data
     $this->config = Yaf_Application::app()->getConfig();
     Yaf_Registry::set('Config', $this->config);
     //auto load redis
     $redis = new Redis();
     $redis->connect($this->config->redis->host, $this->config->redis->port, $this->config->redis->timeout, $this->config->redis->reserved, $this->config->redis->interval);
     Yaf_Registry::set('Redis', $redis);
     //auto load mysql
     Yaf_Registry::set('DbRead', new Db('mysql:host=' . $this->config->mysql->read->host . ';dbname=' . $this->config->mysql->read->dbname . ';charset=' . $this->config->mysql->read->charset . ';port=' . $this->config->mysql->read->port . '', $this->config->mysql->read->username, $this->config->mysql->read->password));
     Yaf_Registry::set('DbWrite', new Db('mysql:host=' . $this->config->mysql->write->host . ';dbname=' . $this->config->mysql->write->dbname . ';charset=' . $this->config->mysql->write->charset . ';port=' . $this->config->mysql->write->port . '', $this->config->mysql->write->username, $this->config->mysql->write->password));
     // auto load model
     Yaf_Registry::set('I18n', new I18nModel($redis, $this->config->application->name, 'cn'));
     Yaf_Registry::set('Cache', new CacheModel($redis, $this->config->application->name));
     // auto load plugin
     $dispatcher->registerPlugin(new GlobalPlugin());
     // auto save request
     $request = $dispatcher->getRequest();
     // auto set ajax is no render
     if ($request->isXmlHttpRequest()) {
         $dispatcher->autoRender(false);
     }
     // auto set http protocol to action except http get protocol
     if (!$request->isGet()) {
         $dispatcher->setDefaultAction($request->getMethod());
     }
 }
Example #7
0
 /**
  * @param array $config 配置参数
  * @param $driver 上传驱动 Local-本地上传驱动,FTP-FTP上传驱动
  */
 public function __construct($config = array(), $driver)
 {
     //获取上传配置
     $options = Yaf_Registry::get('uploadbase');
     /* 获取配置 */
     $this->config = array_merge($this->config, $config);
     //上传驱动名称
     $driver = $driver ? $driver : ($this->driver ? $this->driver : $options['type']);
     //生成上传驱动名
     $class = strpos($driver, '\\') ? $driver : ucfirst(strtolower($driver));
     //设置上传驱动
     $this->setDriver($class);
     /* 调整配置,把字符串配置参数转换为数组 begin */
     if (!empty($this->config['mimes'])) {
         if (is_string($this->mimes)) {
             $this->config['mimes'] = explode(',', $this->mimes);
         }
         $this->config['mimes'] = array_map('strtolower', $this->mimes);
     }
     if (!empty($this->config['exts'])) {
         if (is_string($this->exts)) {
             $this->config['exts'] = explode(',', $this->exts);
         }
         $this->config['exts'] = array_map('strtolower', $this->exts);
     }
     /* 调整配置,把字符串配置参数转换为数组 end */
 }
Example #8
0
 public function __call($func, $args)
 {
     if (false == \Yaf_Registry::has($func)) {
         return $this->loadModule($func, $args[0]);
     }
     return \Yaf_Registry::get($func);
 }
Example #9
0
 public function __construct()
 {
     $this->table = new swoole_table(1024);
     $this->table->column('serverfd', swoole_table::TYPE_INT, 8);
     $this->table->create();
     define('APPLICATION_PATH', dirname(dirname(__DIR__)) . "/application");
     define('MYPATH', dirname(APPLICATION_PATH));
     $this->application = new Yaf_Application(dirname(APPLICATION_PATH) . "/conf/application.ini");
     $this->application->bootstrap();
     $config_obj = Yaf_Registry::get("config");
     $distributed_config = $config_obj->distributed->toArray();
     $server = new swoole_server($distributed_config['ServerIp'], $distributed_config['port'], SWOOLE_PROCESS, SWOOLE_SOCK_TCP);
     if (isset($distributed_config['logfile'])) {
         $server->set(array('worker_num' => 4, 'task_worker_num' => 4, 'dispatch_mode' => 4, 'daemonize' => true, 'log_file' => $distributed_config['logfile']));
     } else {
         $server->set(array('worker_num' => 4, 'task_worker_num' => 4, 'dispatch_mode' => 4, 'daemonize' => true));
     }
     require_once __DIR__ . "/DistributedClient.php";
     $server->on('Start', array(&$this, 'onStart'));
     $server->on('WorkerStart', array(&$this, 'onWorkerStart'));
     $server->on('Connect', array(&$this, 'onConnect'));
     $server->on('Receive', array(&$this, 'onReceive'));
     $server->on('Task', array(&$this, 'onTask'));
     $server->on('Finish', array(&$this, 'onFinish'));
     $server->on('Close', array(&$this, 'onClose'));
     $server->on('ManagerStop', array(&$this, 'onManagerStop'));
     $server->on('WorkerError', array(&$this, 'onWorkerError'));
     $server->start();
 }
Example #10
0
 public function __construct()
 {
     $this->_config = Yaf_Registry::get("config");
     $this->_db = new Db_Mysql($this->_config->database->config->toArray());
     //$this->_redis = new Redis();
     //$this->_redis->connect($this->_config->redis->host);
 }
Example #11
0
 private static function getTransport()
 {
     $_config = Yaf_Registry::get("config");
     self::$_cfg = $_config->mail->smtp->toArray();
     self::$_transport = Swift_SmtpTransport::newInstance(self::$_cfg['service'], 25)->setUsername(self::$_cfg['username'])->setPassword(self::$_cfg['password']);
     self::$_mailer = Swift_Mailer::newInstance(self::$_transport);
 }
Example #12
0
 protected function loadDatabase($name)
 {
     $database = Yaf_Registry::get('_database');
     if (isset($database[$name])) {
         return $database[$name];
     }
     $config = Yaf_Registry::get('_config');
     if (isset($config->database->{$name})) {
         if (is_null($database)) {
             $database = array();
         }
         $dbConfig = $config->database->{$name};
         $pdoParams = array();
         if ($dbConfig->pconnect) {
             $pdoParams[Db::ATTR_PERSISTENT] = TRUE;
         }
         try {
             $conn = new Db($dbConfig->type . ':host=' . $dbConfig->host . '; dbname=' . $dbConfig->database, $dbConfig->username, $dbConfig->password, $pdoParams);
         } catch (PDOException $error) {
             throw new Exception($error->getMessage(), 500);
         }
         $database[$name] = $conn;
         Yaf_Registry::set('_database', $database);
         return $conn;
     } else {
         throw new Exception('Undefined database', 500);
     }
 }
Example #13
0
 /**
  * (non-PHPdoc)
  * @see Yaf_Controller_Abstract::init()
  */
 public function init()
 {
     //判断用户是否登录
     if ($this->_need_login && !Yaf_Registry::get('current_uid')) {
         throw new \Exception\Nologin('no login');
     }
 }
Example #14
0
 public function init()
 {
     parent::init();
     $this->_layout = new LayoutPlugin('layout.html');
     $this->dispatcher = Yaf_Registry::get("dispatcher");
     $this->dispatcher->registerPlugin($this->_layout);
 }
 public function _initDatabase()
 {
     $servers = array();
     $database = $this->config->database;
     $servers[] = $database->master->toArray();
     $slaves = $database->slaves;
     if (!empty($slaves)) {
         $slave_servers = explode('|', $slaves->servers);
         $slave_users = explode('|', $slaves->users);
         $slave_passwords = explode('|', $slaves->passwords);
         $slave_databases = explode('|', $slaves->databases);
         $slaves = array();
         foreach ($slave_servers as $key => $slave_server) {
             if (isset($slave_users[$key]) && isset($slave_passwords[$key]) && isset($slave_databases[$key])) {
                 $slaves[] = array('server' => $slave_server, 'user' => $slave_users[$key], 'password' => $slave_passwords[$key], 'database' => $slave_databases[$key]);
             }
         }
         $servers[] = $slaves[array_rand($slaves)];
     }
     Yaf_Registry::set('database', $servers);
     if (isset($database->mysql_cache_enable) && $database->mysql_cache_enable && !defined('MYSQL_CACHE_ENABLE')) {
         define('MYSQL_CACHE_ENABLE', true);
     }
     if (isset($database->mysql_log_error) && $database->mysql_log_error && !defined('MYSQL_LOG_ERROR')) {
         define('MYSQL_LOG_ERROR', true);
     }
     Yaf_Loader::import(APPLICATION_PATH . '/library/Db/Db.php');
     Yaf_Loader::import(APPLICATION_PATH . '/library/Db/DbQuery.php');
 }
Example #16
0
 public function indexAction()
 {
     $sNewCardID = Yaf_Registry::get('config')->newcardid;
     $sOldCardID = Yaf_Registry::get('config')->oldcardid;
     if (!empty($_GET['ccid'])) {
         $ccid = $_GET['ccid'];
     }
     if (strlen($ccid) == 20) {
         $ccid = substr($ccid, 0, 19);
     } else {
         if (strlen($ccid) != 19) {
             throw new Exception("请检查您的ICCID!");
         }
     }
     $cfArr = TZ_Loader::service('UserFlow', 'Flow')->getFlowProductId($ccid);
     if (empty($cfArr)) {
         $this->_view->display("no_info.html");
         die;
         //throw new Exception("该卡不属于747卡!");
     } else {
         $pid = $cfArr['cpid'];
     }
     if (intval($sNewCardID) != $pid && $pid != $sOldCardID) {
         $this->_view->display("no_info.html");
     } else {
         if ($pid == $sOldCardID) {
             header("location:http://app.747.cn");
         } else {
             $this->_view->display('pay.html');
         }
     }
 }
Example #17
0
 public function routerShutdown(Yaf_Request_Abstract $request, Yaf_Response_Abstract $response)
 {
     $config = \Yaf_Registry::get('configarr');
     $dispatcher = Yaf_Dispatcher::getInstance();
     $twig = '';
     // view 放在module 目录里
     if ($request->module == $config['application']['dispatcher']['defaultModule']) {
         $twig = new \Core_Twig(APP_PATH . 'views', $config['twig']);
     } else {
         $twig = new \Core_Twig(APP_PATH . 'modules/' . $request->module . '/views', $config['twig']);
     }
     // url generate
     $twig->twig->addFunction("url", new Twig_Function_Function("Tools_help::url"));
     // 语言对应
     $twig->twig->addFunction("lang", new Twig_Function_Function("Tools_help::lang"));
     // 图片路径
     $twig->twig->addFunction("fbu", new Twig_Function_Function("Tools_help::fbu"));
     // 数字验证
     $twig->twig->addFunction("is_numeric", new Twig_Function_Function("is_numeric"));
     // 处理错误提醒
     $session_key = array('ErrorMessageStop', 'ErrorMessage', 'Message');
     foreach ($session_key as $value) {
         $twig->assign($value, Tools_help::getSession($value));
         Tools_help::setSession($value, '');
     }
     $dispatcher->setView($twig);
 }
Example #18
0
 protected function init()
 {
     $this->_config = Yaf_Registry::get('_config')->toArray();
     $this->_request = $this->getRequest();
     $this->getView()->assign(array('_site' => $this->_config['site']));
     // 开始把框架改造成RESTful,并自动加上OPTIONS的返回
     $method = $this->_request->getMethod();
     $action = $this->_request->getActionName();
     if (method_exists($this, $action . 'Action')) {
         // 兼容原方法,如果已经存在xxxAction的时候直接调用,不再进行RESTful,否则ErrorController与forward的时候会出错
         return;
     }
     $allow = array();
     foreach (array('Get', 'Post', 'Put', 'Delete', 'Head', 'Patch') as $v) {
         if (method_exists($this, $action . $v . 'Action')) {
             $allow[] = $v;
         }
     }
     if (empty($allow)) {
         throw new Exception('', 404);
     }
     if ($method == 'OPTIONS') {
         header('allow: ' . strtoupper(implode(' ', $allow)));
         header('content-length: 0');
         exit;
     } else {
         $camelMethod = substr($method, 0, 1) . strtolower(substr($method, 1));
         if (!in_array($camelMethod, $allow)) {
             throw new Exception('', 405);
         }
         // 重新定位到RESTful对应的action上,比如POST方式请求index,则从indexAction变成indexPostAction
         $this->_request->setActionName($action . $camelMethod);
     }
 }
Example #19
0
 /**
  * 获取一条数据
  * 
  * @param int   $uid  用户UID,默认为当前登录用户UID
  * 
  * @return array
  */
 public static function show($uid = false)
 {
     !$uid && ($uid = \Yaf_Registry::get('current_uid'));
     $result = parent::show($uid);
     isset($result['data']) && ($result['data'] = self::decodeData($result['data']));
     return $result;
 }
Example #20
0
 public function _initDefaultDbAdapter()
 {
     //新建对象
     $dbAdapter = new Zend\Db\Adapter\Adapter(Yaf_Application::app()->getConfig()->mysql->write->toArray());
     //设为全局变量
     Yaf_Registry::set("db", $dbAdapter);
 }
Example #21
0
 public static function loadConfig()
 {
     if (self::$isLoaded) {
         return;
     }
     $globalConfig = Yaf_Registry::get('config');
     if (!isset($globalConfig->log)) {
         self::$enableLog = false;
         return;
     }
     $globalLogConfig = $globalConfig->log;
     if (isset($globalLogConfig->enable)) {
         self::$enableLog = $globalLogConfig->enable;
     }
     if (isset($globalLogConfig->log_level)) {
         self::$logLevel = self::$LOG_LEVELS[$globalLogConfig->log_level];
     }
     if (!is_string($globalLogConfig->target)) {
         $tmpTarget = [];
         foreach ($globalLogConfig->target as $k => $v) {
             $k = strtoupper($k);
             $tmpTarget[$k] = $v;
         }
         self::$target = $tmpTarget;
     } else {
         self::$target = ['DEFAULT' => $globalLogConfig->target];
     }
     self::$isLoaded = true;
 }
Example #22
0
 public function aboutAction()
 {
     $this->getView()->assign('content', 'hello yaf');
     $smarty = Yaf_Registry::get('config')->get('smarty');
     // var_dump($smarty);
     // echo APP_PATH;
 }
Example #23
0
 /**
  * Controller的init方法会被自动首先调用
  */
 public function init()
 {
     //调试mysql
     if (isset($_GET['debug6429360'])) {
         $this->debug = true;
         DB_Mysqli::$DEBUG = 1;
     }
     $this->platform = isset($_REQUEST['platform']) ? $_REQUEST['platform'] : $this->platform;
     Yaf_Registry::set("platform", $this->platform);
     $this->isMobile = $this->platform == 'ios' || $this->platform == 'android';
     $this->wap = !$this->isMobile && Common_Mobile::isMobile();
     $this->uid = $this->get('uid', $this->post('uid', false));
     $this->controllerName = $this->getRequest()->getControllerName();
     $this->actionName = $this->getRequest()->getActionName();
     $userModel = new UserModel();
     /*        if (!isset(Common_Config::$NotNeedLogin[$this->controllerName][$this->actionName])
                 && $this->isMobile 
                 && $this->needLogin 
                 && !$this->debug) 
             {
                 $token = $this->get("token", $this->post("token", false));
                 if (!$token) {
                     $this->redirect(NULL, Common_Error::ERROR_TOKEN_NOT_EXISTS);
                 }
     
                 $api = $this->getRequestApi();
                 $check = Common_Token::check($token, $this->uid, strtolower($api));
                 if (!$check) {          
                     $this->redirect(NULL, Common_Error::ERROR_TOKEN);
                 }
             }*/
     $this->uid = $this->uid ? $this->uid : $userModel->getUid();
     /**
      * 如果是Ajax请求, 则关闭HTML输出
      */
     if ($this->getRequest()->isXmlHttpRequest() || 'POST' == $this->getRequest()->getMethod()) {
         $this->ajax = true;
         Yaf_Dispatcher::getInstance()->disableView();
     } else {
         //$path = $this->getView()->getScriptPath();
         //$path[0] = $path[0] . "/" . strtolower($this->getRequest()->getControllerName());
         //$this->getView()->setScriptPath($path[0]);
     }
     //print_r($this->uid?$this->uid:"null");
     //验证登录
     /*if (
                 !isset(Common_Config::$NotNeedLogin[$this->controllerName][$this->actionName]) 
                 && $this->needLogin 
                 && !$this->uid) {
                 $this->redirect("/user/login?from=" . (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : ""), Common_Error::ERROR_USER_NOT_LOGIN);
     
                 $this->redirect("/user/verify", Common_Error::ERROR_USER_NOT_LOGIN);
             }*/
     //用户信息
     /*        if($this->uid) {
                 $user = $userModel->getUser($this->uid);
                 $this->assign("uInfo", $user);
                 Yaf_Registry::set("uid", $this->uid);
             }*/
 }
Example #24
0
 public function indexAction()
 {
     //默认Action
     //test db library
     $dbObj = new Db_Table(SAE_MYSQL_DB, 'user');
     $res = $dbObj->getCount('id=3');
     var_dump($res);
     $field = array();
     $whereArr = array('order' => 'id', 'limit' => '3');
     $res = $dbObj->getAll($field, $whereArr);
     var_dump($res);
     //test smarty library
     $this->getView()->assign("contentaa", "Hello Worldssss");
     //test zendDb library
     $db = Yaf_Registry::get('db');
     $sql = $db->quoteInto('select * from usertest where user_id <?', '3');
     $result = $db->query($sql);
     $res = $result->fetchAll();
     var_dump($res);
     /*
             $adapter = new Zend_Db_Table();
             $adapter->setDefaultAdapter($db);
             $obj = new UserTableModel();
             $data = array(
                 'id' => '1',
                 'name' => 'King',
                 'author' => 'Arthur',
                 'color' => 'blue'
             );
             $obj->insert($data);*/
 }
Example #25
0
function rpcserver_call(swoole_process $worker)
{
    define('APPLICATION_PATH', dirname(dirname(__DIR__)) . "/application");
    define('THRIFT_DIR_PATH', dirname(APPLICATION_PATH) . "/thrift");
    require_once THRIFT_DIR_PATH . "/Thrift/ClassLoader/ThriftClassLoader.php";
    $loader = new Thrift\ClassLoader\ThriftClassLoader();
    $loader->registerNamespace('Thrift', THRIFT_DIR_PATH);
    $loader->registerNamespace('swoole', THRIFT_DIR_PATH);
    $loader->registerNamespace('Bin', THRIFT_DIR_PATH);
    $loader->registerDefinition('Bin', THRIFT_DIR_PATH);
    $loader->register();
    define('MYPATH', dirname(APPLICATION_PATH));
    $application = new Yaf_Application(dirname(APPLICATION_PATH) . "/conf/application.ini");
    $application->bootstrap();
    $config_obj = Yaf_Registry::get("config");
    $rpc_config = $config_obj->rpc->toArray();
    define('SERVERIP', $rpc_config['ServerIp']);
    define('SERVERPORT', $rpc_config['port']);
    define('SERVERHOST', $rpc_config['host']);
    $service = new Bin\rpc\Handler();
    $processor = new Bin\rpc\rpcProcessor($service);
    $socket_tranport = new Thrift\Server\TServerSocket(SERVERIP, SERVERPORT);
    $out_factory = $in_factory = new Thrift\Factory\TFramedTransportFactory();
    $out_protocol = $in_protocol = new Thrift\Factory\TBinaryProtocolFactory();
    $server = new swoole\RpcServer($processor, $socket_tranport, $in_factory, $out_factory, $in_protocol, $out_protocol);
    $server->serve();
}
Example #26
0
 public function init()
 {
     $this->_config = Yaf_Registry::get('config');
     $this->_req = $this->getRequest();
     $this->_session = Yaf_Session::getInstance();
     $this->_session->start();
 }
Example #27
0
 public function _initPlugin(Yaf_Dispatcher $dispatcher)
 {
     $router = new RouterPlugin();
     $dispatcher->registerPlugin($router);
     $admin = new AdminPlugin();
     $dispatcher->registerPlugin($admin);
     Yaf_Registry::set('adminPlugin', $admin);
 }
Example #28
0
 public static function init()
 {
     $_ENV['APP_NAME'] = pathinfo(realpath(APPLICATION_PATH), PATHINFO_BASENAME);
     $configurePath = sprintf('%s/../config/config.ini', APPLICATION_PATH);
     $config = new Yaf_Config_Ini($configurePath, 'production');
     Yaf_Registry::set('dbconfig', $config);
     self::loadEssentials();
 }
Example #29
0
 public function __construct($logType)
 {
     parent::__construct($logType);
     $this->logType = $logType;
     $config = Yaf_Registry::get('monitor_config');
     $cacheName = $config['loghandle'][$this->logType]['cache'];
     $this->cacheModel = Model_Loghandle_Cache_Factory::create($this->logType, $cacheName);
 }
Example #30
0
 /**
  * @param string $which
  *
  * @return DB_Mysql
  */
 public static function db($which = 'master')
 {
     $DB_config = Yaf_Registry::get('config')->get('yaf')->get('db')->{$which};
     $cache_config = Yaf_Registry::get('config')->get('yaf')->get('cache');
     $db = DB_Mysql::getInstance($DB_config, $cache_config);
     return $db;
     //		return ($db instanceof DB_DbInterface) ? $db : false;
 }