Example #1
0
 static function a()
 {
     if (isset(self::$app)) {
         return self::$app;
     }
     return self::$app = new Container();
 }
Example #2
0
 public static function Create($config)
 {
     if (!self::$app) {
         self::$app = new Org_Apache_Oodt_Balance_Core_Application($config);
     }
     return self::$app;
 }
Example #3
0
 /**
  * 如果框架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;
             }
         }
     }
 }
Example #4
0
 /**
  * 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");
     }
 }
Example #5
0
 public function init()
 {
     if (isset(App::app()->config['route']['urlFormat'])) {
         $this->_urlFormat = App::app()->config['route']['urlFormat'];
     }
     $this->_pathInfo = $this->parseUrl();
     return $this->_pathInfo;
 }
Example #6
0
 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();
 }
Example #7
0
 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);
     }
 }
Example #8
0
 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";
             }
         }
     }
 }
Example #9
0
 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);
     }
 }
Example #10
0
 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);
 }
Example #11
0
 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);
 }
Example #12
0
File: index.php Project: starsep/bd
<?php

require_once './src/App.class.php';
$app = App::app();
$app->run();
Example #13
0
 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 = '" . $_POST['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();
     }
 }
Example #14
0
 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());
     }
 }
Example #15
0
 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]);
         }
     }
 }
Example #16
0
 private function log($str)
 {
     if (App::app()) {
         App::app()->log($str);
     }
 }
Example #17
0
 protected function _addFailure($attribute, $rule, $parameters)
 {
     list($id, $parameters) = $this->_transParameters($attribute, $rule, $parameters);
     $this->errors[$attribute] = App::app()->t($id, $parameters);
 }