コード例 #1
0
ファイル: App.php プロジェクト: benallfree/encase-app
 static function a()
 {
     if (isset(self::$app)) {
         return self::$app;
     }
     return self::$app = new Container();
 }
コード例 #2
0
ファイル: bootstrap.php プロジェクト: fornava/oodt
 public static function Create($config)
 {
     if (!self::$app) {
         self::$app = new Org_Apache_Oodt_Balance_Core_Application($config);
     }
     return self::$app;
 }
コード例 #3
0
ファイル: Log.php プロジェクト: seaice/li-framework
 /**
  * 如果框架debug为true,返回true
  * 如果框架debug为false,根据日志配置的debug返回
  * if li global config debug is false, 
  * @return boolean if write return true, otherwise false 
  */
 private function _checkLevel($level)
 {
     // 框架debug开启
     if (isset(App::app()->config['debug']) && App::app()->config['debug'] === true) {
         return true;
     }
     //单日志
     if ($this->_config['multi'] == false) {
         if (isset($this->_config['debug']) && $this->_config['debug'] === true) {
             return true;
         } else {
             if ($level == 'debug') {
                 return false;
             } else {
                 return true;
             }
         }
     } else {
         if (isset($this->_config['config'][$this->_configIndex]['debug']) && $this->_config['config'][$this->_configIndex]['debug'] === true) {
             return true;
         } else {
             if ($level == 'debug') {
                 return false;
             } else {
                 return true;
             }
         }
     }
 }
コード例 #4
0
ファイル: socket-server.php プロジェクト: noccy80/cherryphp
 /**
  * onTick is called once every loop and is responsible for dispatching the
  * message to the clients as they are received.
  */
 public function onTick()
 {
     $log = App::app()->chatGetLog($this->lptr);
     foreach ($log as $msg) {
         $this->write("{$msg}\n");
     }
 }
コード例 #5
0
ファイル: Route.php プロジェクト: seaice/li-framework
 public function init()
 {
     if (isset(App::app()->config['route']['urlFormat'])) {
         $this->_urlFormat = App::app()->config['route']['urlFormat'];
     }
     $this->_pathInfo = $this->parseUrl();
     return $this->_pathInfo;
 }
コード例 #6
0
ファイル: Session.php プロジェクト: seaice/li-framework
 public static function init()
 {
     if (isset(App::app()->config['session'])) {
         if (isset(App::app()->config['session']['driver']) && (App::app()->config['session']['driver'] = 'mysql')) {
             $driver = 'Session' . ucfirst(App::app()->config['session']['driver']);
             $handler = new SessionMysql(App::app()->config['session']['config']);
             session_set_save_handler($handler, true);
         }
     }
     session_start();
 }
コード例 #7
0
ファイル: Db.php プロジェクト: seaice/li-framework
 function __get($dbName)
 {
     if (isset(App::app()->config['database'][$dbName])) {
         $driver = 'Li\\' . ucfirst(App::app()->config['database'][$dbName]['driver']);
         if (!(isset($this->{$dbName}) && $this->{$dbName} instanceof $driver)) {
             $this->{$dbName} = new $driver(App::app()->config['database'][$dbName]);
         }
         return $this->{$dbName};
     } else {
         throw new Exception("config no db " . $dbName);
     }
 }
コード例 #8
0
ファイル: databasetable.php プロジェクト: noccy80/cherryphp
 public function applySdlTag(\Cherry\Data\Ddl\SdlTag $node)
 {
     if ($node->getName() == 'table') {
         if ($node->getValue() != $this->name) {
             \App::app()->warn("Not applying SDL node to table as names differ: " . $node->getValue());
             return false;
         }
         $cur = $this->getSdlTag();
         foreach ($node->getChildren('column') as $col) {
             $curcol = $cur->getChild('column', $col->getValue());
             // Check if the node
             if ($curcol == null || $curcol != $col) {
                 echo "Column " . $col->getName() . " needs creating/applying!\n";
             }
         }
     }
 }
コード例 #9
0
ファイル: Redis.php プロジェクト: seaice/li-framework
 function __get($cacheName)
 {
     if (isset(App::app()->config['redis'][$cacheName])) {
         if (!(isset($this->{$cacheName}) && $this->{$cacheName} instanceof \Redis)) {
             $this->{$cacheName} = new \Redis();
             if (isset(App::app()->config['redis'][$cacheName]['pconnect']) && App::app()->config['redis'][$cacheName]['pconnect'] === true) {
                 $ret = $this->{$cacheName}->pconnect(App::app()->config['redis'][$cacheName]['ip'], App::app()->config['redis'][$cacheName]['port']);
             } else {
                 $ret = $this->{$cacheName}->connect(App::app()->config['redis'][$cacheName]['ip'], App::app()->config['redis'][$cacheName]['port']);
             }
             if ($ret === false) {
                 throw new Exception("Redis " . App::app()->config['redis'][$cacheName]['ip'] . ':' . App::app()->config['redis'][$cacheName]['port'] . ' can not connect');
             }
         }
         return $this->{$cacheName};
     } else {
         throw new Exception("config no redis " . $dbName);
     }
 }
コード例 #10
0
ファイル: Captcha.php プロジェクト: seaice/li-framework
 public function generate($key = null)
 {
     if (isset(App::app()->config['captcha']) && is_array(App::app()->config['captcha'])) {
         $this->_config = array_merge($this->_config, App::app()->config['captcha']);
     }
     $this->_create();
     $text = $this->_getText($key);
     // 随机字体
     $font = $this->_config['fonts'][array_rand($this->_config['fonts'])];
     $this->_text($text, $font);
     if ($this->_config['type'] !== 'math') {
         // 随机干扰
         if ($this->_config['lineNumber'] > 0) {
             $i = 0;
             for (; $i < $this->_config['lineNumber']; $i++) {
                 $this->_line();
             }
         }
     }
     header("Content-type: image/png");
     imagepng($this->_im);
     imagedestroy($this->_im);
 }
コード例 #11
0
ファイル: Controller.php プロジェクト: seaice/li-framework
 public function redirect($uri, $params = [])
 {
     foreach ($params as $key => $value) {
         $urlParam[] = $key;
         $urlParam[] = $value;
     }
     $url = $uri . '/' . implode('/', $urlParam);
     redirect(App::app()->config['domain'] . url() . '/' . $url);
     // debug(implode('/', $params));
     // debug(\http_build_query($argv[0], '','/'));
     // debug(func_get_args());
     // debug(url().$uri);
     // redirect(url().$uri);
 }
コード例 #12
0
ファイル: index.php プロジェクト: starsep/bd
<?php

require_once './src/App.class.php';
$app = App::app();
$app->run();
コード例 #13
0
ファイル: DbMan.class.php プロジェクト: starsep/bd
 public function register($required)
 {
     foreach ($required as $name) {
         $_POST[$name] = pg_escape_string($_POST[$name]);
     }
     $same_login = $this->make_query("SELECT * FROM Konto WHERE login = '******'login'] . "';");
     if ($same_login != null) {
         App::app()->add_info('Już jest użytkownik z takim loginem', 'danger');
         App::app()->register_error();
     }
     $this->make_query("INSERT INTO Konto (id, login, password, nazwa, typ) VALUES (default, '" . $_POST['login'] . "', '" . $_POST['password'] . "', '" . $_POST['name'] . "', '" . $_POST['type'] . "');");
     if ($this->login()) {
         $_SESSION['success'] = 'Rejestracja się powiodła!';
         App::app()->refresh_home();
     } else {
         App::app()->add_info("Rejestracja się nie powiodła", 'danger');
         App::app()->register_error();
     }
 }
コード例 #14
0
ファイル: App.php プロジェクト: seaice/li-framework
 public static function exception_handler($exception)
 {
     if (App::app()->config['debug']) {
         echo "Exception: " . $exception->getMessage() . ' in ' . $exception->getFile() . ' on ' . $exception->getLine() . "<br />";
         echo 'trace    :' . '<br />';
         $trace = $exception->getTrace();
         foreach ($trace as $v) {
             echo '<b>' . $v['file'] . '</b>  in  <b>' . $v['function'] . '</b>  on  <b>' . $v['line'] . "</b><br />";
         }
     } else {
         Log::log()->error("Exception: " . $exception->getMessage() . ' in ' . $exception->getFile() . ' on ' . $exception->getLine());
     }
 }
コード例 #15
0
ファイル: App.class.php プロジェクト: starsep/bd
 public function make_notifications()
 {
     $types = array('success', 'info', 'danger', 'warning');
     foreach ($types as $type) {
         if (isset($_SESSION[$type])) {
             App::app()->add_info($_SESSION[$type], $type);
             unset($_SESSION[$type]);
         }
     }
 }
コード例 #16
0
 private function log($str)
 {
     if (App::app()) {
         App::app()->log($str);
     }
 }
コード例 #17
0
ファイル: Validator.php プロジェクト: seaice/li-framework
 protected function _addFailure($attribute, $rule, $parameters)
 {
     list($id, $parameters) = $this->_transParameters($attribute, $rule, $parameters);
     $this->errors[$attribute] = App::app()->t($id, $parameters);
 }