public function __construct($db) { $this->orm = $db; $this->db = $db->db(); $this->table = $db->table(); $dir = Config::get('dir.blizz.store', session_save_path()); if (!is_dir($dir)) { File::mkdir($dir); } $dir .= DS . Inflector::urlize(Inflector::uncamelize($this->db)); if (!is_dir($dir)) { File::mkdir($dir); } $this->dir = $dir . DS . Inflector::urlize(Inflector::uncamelize($this->table)); if (!is_dir($this->dir)) { File::mkdir($this->dir); } $file = $this->dir . DS . 'data.db'; $new = false; if (!is_file($file)) { File::create($file); $new = true; File::put($this->dir . DS . 'age.blizz', ''); } $link = new SQLite3($file); Now::set("blizz.link.{$this->db}.{$this->table}", $link); if ($new) { $this->init(); } }
public function __construct($db, $table) { $file = Config::get('mlite.dir.' . $db, STORAGE_PATH . DS . $db . '.db'); $new = !is_file($file); if (!is_file($file)) { File::create($file); } $link = new SQLite3($file); Now::set("lite.link.{$db}.{$table}", $link); if ($new) { $q = "CREATE TABLE IF NOT EXISTS infosdb (data_key VARCHAR PRIMARY KEY, data_value);"; $res = $link->exec($q); } $this->table = $table; $this->database = $db; }
/** * * @method __construct * * @param string * @param array */ public function __construct(array $data = []) { $ns = $this->ns = $this->forever(); $file = Config::get('cachemelite.dir.' . $ns, STORAGE_PATH . DS . $ns . '_cache.db'); $new = !is_file($file); if (!is_file($file)) { File::create($file); } $db = new SQLite3($file); Now::set("cachemelite.link.{$ns}", $db); $q = "CREATE TABLE IF NOT EXISTS cachedb (data_key VARCHAR PRIMARY KEY, data_value);"; $res = $this->db->exec($q); if (!empty($data)) { foreach ($data as $k => $v) { $this->set($k, $v); } } }
public function __construct($viewFile = null) { if (null !== $viewFile) { $this->_module = 'www'; if (strstr($viewFile, DS)) { $this->_viewFile = $viewFile; } else { $file = CACHE_PATH . DS . md5($this->_viewFile . time() . Utils::UUID()) . '.fake'; File::create($file); $fp = fopen($file, 'a'); fwrite($fp, '<?php echo $this->content; ?>'); $this->_viewFile = $file; } } else { $route = Utils::get('appDispatch'); /* polymorphism */ $route = !$route instanceof Container ? container()->getRoute() : $route; if ($route instanceof Container) { $module = $route->getModule(); $controller = $route->getController(); $action = $route->getAction(); $this->_module = $module; $isTranslate = Utils::get('isTranslate'); if (true === $isTranslate) { $lng = getLanguage(); if (true === container()->getMultiSite()) { $this->_viewFile = APPLICATION_PATH . DS . SITE_NAME . DS . 'modules' . DS . $module . DS . 'views' . DS . 'scripts' . DS . Inflector::lower($controller) . DS . Inflector::lower($lng) . DS . Inflector::lower($action) . '.phtml'; } else { $this->_viewFile = APPLICATION_PATH . DS . 'modules' . DS . SITE_NAME . DS . $module . DS . 'views' . DS . 'scripts' . DS . Inflector::lower($controller) . DS . Inflector::lower($lng) . DS . Inflector::lower($action) . '.phtml'; } } else { if (true === container()->getMultiSite()) { $this->_viewFile = APPLICATION_PATH . DS . SITE_NAME . DS . 'modules' . DS . $module . DS . 'views' . DS . 'scripts' . DS . Inflector::lower($controller) . DS . Inflector::lower($action) . '.phtml'; } else { $this->_viewFile = APPLICATION_PATH . DS . 'modules' . DS . SITE_NAME . DS . $module . DS . 'views' . DS . 'scripts' . DS . Inflector::lower($controller) . DS . Inflector::lower($action) . '.phtml'; } } } } Utils::set('appView', $this); Utils::set('showStats', true); }
function ThinLog($message, $logFile = null, $type = 'info') { if (null === $logFile) { $logFile = LOGS_PATH . DS . date('Y-m-d') . '.log'; } else { if (false === File::exists($logFile)) { File::create($logFile); } } File::append($logFile, date('Y-m-d H:i:s') . "\t" . Inflector::upper($type) . "\t{$message}\n"); }