コード例 #1
0
 private static function initViewPath()
 {
     self::$viewPath = App::getInstance()->getConfig()->app['viewsDirectory'];
     if (self::$viewPath == null) {
         self::$viewPath = realpath('../views/');
     }
 }
コード例 #2
0
 private function init()
 {
     $index = 0;
     foreach ($this->routes as $r) {
         $this->output[$index]['url'] = $r['url'];
         $this->output[$index]['method'] = $r['method'];
         $controllerData = explode('@', $r['details']['use']);
         $paramsToSerialize = array();
         $class = new \ReflectionClass(App::getInstance()->getConfig()->app['controllers_namespace'] . '\\' . $controllerData[0]);
         $method = $class->getMethod($controllerData[1]);
         $methodParams = $method->getParameters();
         foreach ($methodParams as $par) {
             if ($par->getClass()->name !== null) {
                 $paramClass = new \ReflectionClass($par->getClass()->name);
                 //$this->output[$index]['params'][$par->getClass()->name] = array();
                 $classInstance = new $paramClass->name();
                 foreach ($classInstance as $q => $e) {
                     //$paramsToSerialize['params'][$par->getClass()->name][$q] = $q;
                     $paramsToSerialize['params'][$q] = $q;
                 }
             } else {
                 $paramsToSerialize['params'][$par->name] = $par->name;
             }
         }
         $this->output[$index]['params'] = json_encode($paramsToSerialize['params'], JSON_PRETTY_PRINT);
         $index++;
     }
 }
コード例 #3
0
 private function __construct()
 {
     $this->_cookies = $_COOKIE;
     if (isset(App::getInstance()->getConfig()->app['global_input_escaping'])) {
         $this->isGlobalEscapingEnable = App::getInstance()->getConfig()->app['global_input_escaping'];
     }
     if (isset(App::getInstance()->getConfig()->app['escape_input_without']) && is_array(App::getInstance()->getConfig()->app['escape_input_without'])) {
         $this->except = App::getInstance()->getConfig()->app['escape_input_without'];
     }
 }
コード例 #4
0
 public function getDBConnection($connection = 'default')
 {
     if ($this->dbConnections[$connection]) {
         return $this->dbConnections[$connection];
     }
     $dbConfig = App::getInstance()->getConfig()->database;
     if (!$dbConfig[$connection]) {
         throw new \Exception('No valid connection identificator is provided', 500);
     }
     $dbh = new \PDO($dbConfig[$connection]['connection_uri'], $dbConfig[$connection]['username'], $dbConfig[$connection]['password'], $dbConfig[$connection]['pdo_options']);
     $this->dbConnections[$connection] = $dbh;
     return $dbh;
 }
コード例 #5
0
 public static function validateUser($username, $password)
 {
     $appInstance = App::getInstance();
     $user = new DB();
     $user = $user->prepare('Select ' . $appInstance->getConfig()->app['user_table']['id'] . ', ' . $appInstance->getConfig()->app['user_table']['password'] . ' From ' . $appInstance->getConfig()->app['user_table']['name'] . ' where ' . $appInstance->getConfig()->app['user_table']['username'] . '=?');
     $user->execute(array($username));
     $result = $user->fetchAllAssoc();
     if (count($result) > 1) {
         throw new \Exception('there are more than 1 user with this credentials', 500);
     }
     if (count($result) < 1) {
         return false;
     }
     if (!Common::verifyPassword($password, $result[0][$appInstance->getConfig()->app['user_table']['password']])) {
         return false;
     }
     $_SESSION['id'] = $result[0][$appInstance->getConfig()->app['user_table']['id']];
     return true;
 }
コード例 #6
0
 public function getDefaultMethod()
 {
     $method = App::getInstance()->getConfig()->app['default_method'];
     if ($method) {
         return strtolower($method);
     }
     return 'index';
 }
コード例 #7
0
 public function __construct()
 {
     $this->msgs = App::getInstance()->getConfig()->validation;
 }
コード例 #8
0
<?php

error_reporting(E_ALL ^ E_NOTICE);
include '../../FW/App.php';
$app = \FW\App::getInstance();
$app->run();