Exemple #1
0
 public static function instance($resource)
 {
     $key = sha1(serialize(func_get_args()));
     $has = Instance::has('Api', $key);
     if (true === $has) {
         return Instance::get('Api', $key);
     } else {
         return Instance::make('Api', $key, with(new self($resource)));
     }
 }
Exemple #2
0
 public static function instance($entity, $ns = 'core')
 {
     $key = sha1(serialize(func_get_args()));
     $has = Instance::has('Fastdata', $key);
     if (true === $has) {
         return Instance::get('Fastdata', $key);
     } else {
         return Instance::make('Fastdata', $key, with(new self($entity, $ns)));
     }
 }
Exemple #3
0
 public static function instance($db = null)
 {
     $key = sha1('Cron' . date('dmY'));
     $has = Instance::has('Cron', $key);
     if (true === $has) {
         return Instance::get('Cron', $key);
     } else {
         return Instance::make('Cron', $key, with(new self($db)));
     }
 }
Exemple #4
0
 public static function instance($model)
 {
     $key = sha1($model->collection);
     $has = Instance::has('BoxObserver', $key);
     if (true === $has) {
         return Instance::get('BoxObserver', $key);
     } else {
         return Instance::make('BoxObserver', $key, new self($model));
     }
 }
Exemple #5
0
 public function motor()
 {
     $has = Instance::has('fastDbMotor', sha1($this->collection));
     if (true === $has) {
         return Instance::get('fastDbMotor', sha1($this->collection));
     } else {
         $instance = new Client(['host' => 'localhost', 'port' => 6379, 'database' => 2]);
         return Instance::make('fastDbMotor', sha1($this->collection), $instance);
     }
 }
Exemple #6
0
 public static function instance($tpl)
 {
     $key = sha1($tpl);
     $has = Instance::has('libView', $key);
     if (true === $has) {
         return Instance::get('libView', $key);
     } else {
         return Instance::make('libView', $key, new self($tpl));
     }
 }
Exemple #7
0
 public static function instance($route)
 {
     $key = sha1($route->controller . $route->action);
     $has = Instance::has('libMVC', $key);
     if (true === $has) {
         return Instance::get('libMVC', $key);
     } else {
         return Instance::make('libMVC', $key, new self($route));
     }
 }
Exemple #8
0
 public static function instance(Eventable $container = null)
 {
     $key = sha1('Dispatcher');
     $has = Instance::has('Dispatcher', $key);
     if (true === $has) {
         return Instance::get('Dispatcher', $key);
     } else {
         return Instance::make('Dispatcher', $key, with(new self($container)));
     }
 }
Exemple #9
0
 public static function instance($tolerance = 0.2, $sort = true)
 {
     $key = sha1(serialize(func_get_args()));
     $has = Instance::has('Phonetic', $key);
     if (true === $has) {
         return Instance::get('Phonetic', $key);
     } else {
         return Instance::make('Phonetic', $key, new self($tolerance, $sort));
     }
 }
Exemple #10
0
 public static function instance($locale = 'fr')
 {
     $key = sha1(serialize(func_get_args()));
     $has = Instance::has('Lang', $key);
     if (true === $has) {
         return Instance::get('Lang', $key);
     } else {
         return Instance::make('Lang', $key, with(new self($app)));
     }
 }
Exemple #11
0
 public static function instance($db, $table)
 {
     $args = func_get_args();
     $key = sha1(serialize($args));
     $has = Instance::has('ArDb', $key);
     if (true === $has) {
         return Instance::get('ArDb', $key);
     } else {
         return Instance::make('ArDb', $key, new self($db, $table));
     }
 }
Exemple #12
0
 public static function instance($context = null)
 {
     $context = is_null($context) ? 'core' : $context;
     $has = Instance::has('ioc', $context);
     if (true === $has) {
         return Instance::get('ioc', $context);
     } else {
         $instance = lib('container');
         return Instance::make('ioc', $context, $instance);
     }
 }
Exemple #13
0
 public static function instance($name, $duration = 3600)
 {
     $args = func_get_args();
     $key = sha1(serialize($args));
     $has = Instance::has('Session', $key);
     if (true === $has) {
         return Instance::get('Session', $key);
     } else {
         return Instance::make('Session', $key, new self($name, $duration));
     }
 }
Exemple #14
0
 public static function instance($db, $table)
 {
     $db = is_null($db) ? 'global' : $db;
     $table = is_null($table) ? 'store' : $table;
     $key = sha1($db . $table);
     $has = Instance::has('GlobalStore', $key);
     if (true === $has) {
         return Instance::get('GlobalStore', $key);
     } else {
         return Instance::make('GlobalStore', $key, new self($db, $table));
     }
 }
Exemple #15
0
 public static function verify()
 {
     require_once 'password.php';
     $args = func_get_args();
     if (isset($args[0])) {
         $username = strtolower($args[0]);
     } elseif (isset($_COOKIE["username"])) {
         $username = $_COOKIE["username"];
     }
     $DBI = Instance::get('DBI');
     $result["success"] = 0;
     if (isset($username) && !empty($username)) {
         $DBI->execute('SELECT * FROM user WHERE lower(username) = "' . strtolower($username) . '";', MYSQL_ASSOC);
         if ($data = Log::$statusLast["data"]["result"][0]) {
             if (isset($args[1])) {
                 $verify = password_verify($args[1], $data["password"]);
             } elseif (isset($_COOKIE["password"])) {
                 $verify = $data["password"] == $_COOKIE["password"];
             }
             if (isset($verify) && $verify) {
                 $result["data"] = $data;
                 $DBI->execute('(SELECT DISTINCT permissions.* FROM permissions JOIN user_permissions ON permissions.id = user_permissions.permissions_id WHERE user_id = "' . $user['id'] . '") UNION (SELECT DISTINCT permissions.* FROM permissions JOIN user_group_permissions ON permissions.id = user_group_permissions.permissions_id JOIN user_group ON user_group_permissions.user_group_id = user_group.id JOIN user_group_member ON user_group.id = user_group_member.user_group_id WHERE user_id = "' . $user['id'] . '");', MYSQL_ASSOC);
                 $result["permissions"] = Log::$statusLast["data"]["result"];
                 $result["message"] = "Account verified";
                 $result["success"] = 1;
             } else {
                 $result["message"] = "Bad Credentials";
             }
         } else {
             $result["message"] = "User Not Found";
         }
     } else {
         $result["message"] = "Insufficient Data";
     }
     return $result;
 }
Exemple #16
0
 protected function backup()
 {
     return Instance::get(Util::$config['fallback']);
 }
Exemple #17
0
$FTP->connect();
// Pull in CMS variables
$_VARS["WEBSITE"] = Module::getInfo('');
$_VARS["WEBSITE"] = $_VARS["WEBSITE"]["values"];
$_VARS['PHP']['version'] = phpversion();
if ($_VARS["WEBSITE"]['mode'] == "DEV") {
    $_VARS['PHP']['extensions'] = get_loaded_extensions();
}
$_VARS['PAGE']['request']['get'] = $_GET;
$_VARS['PAGE']['request']['post'] = $_POST;
$_VARS['PAGE']['request']['all'] = $_REQUEST;
// Unset rewrite variables
unset($_VARS['PAGE']['request']['get']["TYPE"]);
unset($_VARS['PAGE']['request']['post']["TYPE"]);
unset($_VARS['PAGE']['request']['both']["TYPE"]);
unset($_VARS['PAGE']['request']['get']["PATH"]);
unset($_VARS['PAGE']['request']['post']["PATH"]);
unset($_VARS['PAGE']['request']['both']["PATH"]);
$_VARS["TYPE"] = $_REQUEST["TYPE"];
$_VARS["PATH"] = $_REQUEST["PATH"];
unset($_GET["TYPE"]);
unset($_POST["TYPE"]);
unset($_REQUEST["TYPE"]);
unset($_GET["PATH"]);
unset($_POST["PATH"]);
unset($_REQUEST["PATH"]);
date_default_timezone_set($_VARS["WEBSITE"]['time_zone']);
Instance::get('Session');
$_VARS['WEBSITE']['account'] = Account::verify();
$_VARS["WEBSITE"]['cookies'] = Session::getCookies();
$_VARS["WEBSITE"]['cookies'] = $_VARS["WEBSITE"]['cookies']['data'];
Exemple #18
0
 public static function instance($ns, $entity)
 {
     $key = sha1(serialize(func_get_args()));
     $has = Instance::has('Fastdb', $key);
     if (true === $has) {
         return Instance::get('Fastdb', $key);
     } else {
         return Instance::make('Fastdb', $key, new self($ns, $entity));
     }
 }
Exemple #19
0
 public function __construct()
 {
     foreach (Instance::get('validation_message') ?: array() as $key => $value) {
         self::addMessage($key, $value);
     }
 }
Exemple #20
0
 /**
  * 获取实例|简单工厂
  * @param string $storage
  * @param array $config
  * @return mixed
  */
 public static function instance($storage = "", $config = array())
 {
     return Instance::get($storage, $config);
 }