/** * Конструктор * * @param Cfg $config * @param string $type */ function __construct($config, $type = 'pics') { if ($type == 'pics') { $this->pathImage = $config->getConstantPathStaticPics(); $this->urlImage = $config->getConstantUrlStaticPics(); } $this->pathWatermark = $config->getConstantPathStaticImg() . '/watermarks/'; }
public function updateGalleryConfig() { $type = $_POST['scenario']; $model = new Cfg($type); $model->attributes = $_POST['Cfg']; if ($model->validate()) { $record = GalleryConfig::model()->find(array('condition' => "type='{$type}'")); $attributes = array("config" => serialize($_POST['Cfg'])); $record->saveAttributes($attributes); Yii::app()->user->setFlash('succes', Yii::t('app', 'Configuration succesfully saved!')); } else { Yii::app()->user->setFlash('error', Yii::t('app', 'There are errors. Configuration wasn\'t saved! Old configuration is reloaded!')); } }
public function __construct() { parent::__construct(); if (!Cfg::system('delay_job', 'is_check') || !(($value = OAInput::post(Cfg::system('delay_job', 'key'))) !== null && $value == md5(Cfg::system('delay_job', 'value')))) { show_error('The delay job key or value error! Please confirm your program again.'); } }
public function arhive() { try { $zip = new Zip(); $res = array(); foreach ($this->params->files as $n) { $file = BasefileModel::createFromPath($n, false); if ($file->type == 'folder') { $this->arhiveRecursive($zip, $file, $file->name); } else { $zip->addFile($file->getContent(), Lib::convert($file->name, Cfg::get('charset'), Cfg::get('charsetZip')), $file->ctime()); } $res[] = $file; } $c = count($res); $name = 'arhive.zip'; if ($c == 1) { $name = $res[0]->filename() . '.zip'; } $zip->sendZip($name); exit; } catch (Exception $ex) { Log::exception($ex); echo gettext('Не возможно получить архив'); } exit; }
public function index($tag_id, $offset = 0) { $columns = array(); $configs = array('article-tag', $this->tag->id, 'articles', '%s'); $conditions = conditions($columns, $configs); ArticleTagMapping::addConditions($conditions, 'article_tag_id = ?', $this->tag->id); $limit = 7; $total = ArticleTagMapping::count(array('conditions' => $conditions)); $offset = $offset < $total ? $offset : 0; $this->load->library('pagination'); $pagination = $this->pagination->initialize(array_merge(array('total_rows' => $total, 'num_links' => 3, 'per_page' => $limit, 'uri_segment' => 0, 'base_url' => '', 'page_query_string' => false, 'first_link' => '第一頁', 'last_link' => '最後頁', 'prev_link' => '上一頁', 'next_link' => '下一頁', 'full_tag_open' => '<ul class="pagination">', 'full_tag_close' => '</ul>', 'first_tag_open' => '<li class="f">', 'first_tag_close' => '</li>', 'prev_tag_open' => '<li class="p">', 'prev_tag_close' => '</li>', 'num_tag_open' => '<li>', 'num_tag_close' => '</li>', 'cur_tag_open' => '<li class="active"><a href="#">', 'cur_tag_close' => '</a></li>', 'next_tag_open' => '<li class="n">', 'next_tag_close' => '</li>', 'last_tag_open' => '<li class="l">', 'last_tag_close' => '</li>'), $configs))->create_links(); $article_ids = column_array(ArticleTagMapping::find('all', array('select' => 'article_id', 'offset' => $offset, 'limit' => $limit, 'order' => 'article_id DESC', 'conditions' => $conditions)), 'article_id'); $articles = $article_ids ? Article::find('all', array('order' => 'FIELD(id,' . implode(',', $article_ids) . ')', 'conditions' => array('is_visibled = ? AND id IN (?) AND destroy_user_id IS NULL', Article::IS_VISIBLED, $article_ids))) : array(); if ($articles) { $this->add_meta(array('name' => 'keywords', 'content' => implode(',', column_array($articles, 'title')) . ',' . implode(',', Cfg::setting('site', 'site', 'keywords'))))->add_meta(array('name' => 'description', 'content' => $articles[0]->mini_content(150)))->add_meta(array('property' => 'og:title', 'content' => $this->tag->name . '文章' . ' - ' . Cfg::setting('site', 'site', 'title')))->add_meta(array('property' => 'og:description', 'content' => $articles[0]->mini_content(300)))->add_meta(array('property' => 'og:image', 'tag' => 'larger', 'content' => $img = $articles[0]->cover->url('1200x630c'), 'alt' => $this->tag->name . '文章' . ' - ' . Cfg::setting('site', 'site', 'title')))->add_meta(array('property' => 'og:image:type', 'tag' => 'larger', 'content' => 'image/' . pathinfo($img, PATHINFO_EXTENSION)))->add_meta(array('property' => 'og:image:width', 'tag' => 'larger', 'content' => '1200'))->add_meta(array('property' => 'og:image:height', 'tag' => 'larger', 'content' => '630'))->add_meta(array('property' => 'article:modified_time', 'content' => $articles[0]->updated_at->format('c')))->add_meta(array('property' => 'article:published_time', 'content' => $articles[0]->created_at->format('c'))); if (($tags = column_array($articles[0]->tags, 'name')) || ($tags = Cfg::setting('site', 'site', 'keywords'))) { foreach ($tags as $i => $tag) { if (!$i) { $this->add_meta(array('property' => 'article:section', 'content' => $tag))->add_meta(array('property' => 'article:tag', 'content' => $tag)); } else { $this->add_meta(array('property' => 'article:tag', 'content' => $tag)); } } } } return $this->set_title($this->tag->name . '文章' . ' - ' . Cfg::setting('site', 'site', 'title'))->set_class('articles')->set_method('index')->load_view(array('tag' => $this->tag, 'articles' => $articles, 'pagination' => $pagination, 'columns' => $columns)); }
public static function i() { if (self::$i == NULL) { self::$i = new Cfg(); } return self::$i; }
private function __construct() { $this->smarty = new Smarty(); $this->smarty->setTemplateDir(Cfg::i()->tplroot); $this->smarty->setCompileDir(Cfg::i()->dirroot . DIRECTORY_SEPARATOR . 'cache'); $this->tpl = new StdClass(); }
/** * Constructor */ public function __construct() { $CI =& get_instance(); $CI->load->helper('file'); !isset($CI->cfg) && $CI->load->library('cfg'); $path = implode(DIRECTORY_SEPARATOR, Cfg::_system('cache', 'file')) . DIRECTORY_SEPARATOR; $this->set_cache_path($path == '' ? APPPATH . 'cache/' : $path); }
public function __construct($orm = null, $column_name = null) { if (!($orm && $column_name && in_array($column_name, array_keys($orm->attributes())))) { return $this->error = array('OrmUploader 錯誤!', '初始化失敗!', '請檢查建構子參數!'); } parent::__construct($orm, $column_name); $this->configs = Cfg::system('orm_uploader', 'file_uploader'); }
public static function me() { if (!(self::faceBook() && self::$accessToken)) { return null; } $get_fields = implode(',', Cfg::setting('facebook', 'get_fields')); self::faceBook()->setDefaultAccessToken(self::$accessToken); return self::faceBook()->get('/me' . ($get_fields ? '?fields=' . $get_fields : ''))->getGraphUser(); }
/** * Декодировать объект согласно настройкам * @param Object $var * @return Object */ static function decode($var) { $charsetFrom = Cfg::get('charsetWeb', 'UTF-8'); $charsetTo = Cfg::get('charset', 'cp1251'); if ($charsetFrom && $charsetTo && $charsetFrom != $charsetTo) { $var = self::convert($var, $charsetFrom, $charsetTo); } return $var; }
/** * Deletes all output cache file from a given uri * * @access public * @param string * @return bool */ public function delete_all_cache($cache_append_path = null) { if (($CI =& get_instance()) && !isset($CI->cfg)) { $CI->load->library('cfg'); } $path = implode(DIRECTORY_SEPARATOR, Cfg::system('cache', 'output')) . DIRECTORY_SEPARATOR; $cache_path = $path == '' ? APPPATH . 'cache/' : $path; $CI->load->helper('directory'); return directory_clean(FCPATH . $cache_path); }
protected function assign() { $this->tpl->theme = Cfg::i()->theme_www; $this->tpl->path_forms = Cfg::i()->formroot; $this->requireJs(array("thirdparty/jquery.min", "thirdparty/preloader", "thirdparty/bootstrap.min", "thirdparty/tabcordion", "thirdparty/form", "thirdparty/bootstrap-select.min", "thirdparty/Sortable", "thirdparty/Ply.min", "app", "https://yandex.st/highlightjs/7.5/highlight.min.js")); $this->requireCss(array("https://fonts.googleapis.com/css?family=Fira+Sans", "https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css", "thirdparty/bootstrap.min", "mac", "thirdparty/bootstrap-select.min", "main")); foreach ($this->tpl as $key => $value) { Tpl::i()->assign($key, $value); } }
public function __construct() { $this->CI =& get_instance(); $this->CI->load->library('cfg'); $this->configs = \Cfg::_system('model', 'cache'); if ($this->configs['driver'] == 'redis') { $this->CI->load->library("redis"); $this->redis = new \CI_Redis(array('no_cfg_cache' => true)); $this->configs['driver'] = $this->redis->getStatus($error) ? 'redis' : 'file'; } }
private function __construct() { $cfg = Cfg::get('DB'); if ($cfg['driver'] == 'mysql') { require_once 'SQL.class.php'; self::$db = new SQL($cfg['host'], $cfg['login'], $cfg['password'], $cfg['base']); } if ($cfg['driver'] == 'pgsql') { require_once 'PgSQL.class.php'; self::$db = new SQL($cfg['host'], $cfg['login'], $cfg['password'], $cfg['base']); } }
protected function assign() { $this->tpl->USER = User::me(); $this->tpl->url = $this->requestUrl(); $this->tpl->theme = Cfg::i()->theme_www; $this->tpl->path_forms = Cfg::i()->formroot; $this->requireJs(array("thirdparty/jQuery-2.1.4.min", "https://code.jquery.com/ui/1.11.4/jquery-ui.min.js", "thirdparty/bootstrap.min", "https://cdnjs.cloudflare.com/ajax/libs/raphael/2.1.0/raphael-min.js", "https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.2/moment.min.js", "plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.min", "plugins/slimScroll/jquery.slimscroll.min", "app", "app.min", "thirdparty/form", "demo", "schedule")); $this->requireCss(array("https://fonts.googleapis.com/css?family=Fira+Sans", "https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css", "thirdparty/bootstrap.min", "thirdparty/_all-skins.min", "thirdparty/AdminLTE", "_main", "_schedule-table")); foreach ($this->tpl as $key => $value) { Tpl::i()->assign($key, $value); } }
public function __construct() { $this->CI =& get_instance(); if (!self::$config) { self::$config = Cfg::system('elastica_search'); } if (!self::$config['is_enabled']) { return; } if (self::$path === null) { array_pop(self::$path = explode(DIRECTORY_SEPARATOR, pathinfo(__FILE__, PATHINFO_DIRNAME))); } spl_autoload_register(array('Elastica_Core', '__autoload_elastica')); }
public function initInfo() { parent::initInfo(); $path = Cfg::get('baseDir') . $this->id; Log::debug($path); $this->lastmod = @filemtime($path); $this->size = sprintf("%u", filesize($path)); if ($this->type != 'folder') { $pos = strrpos($this->name, "."); if ($pos) { $this->cls = substr($this->name, $pos + 1); $this->type = $this->getTypeFromExp($this->cls); } } }
/** * @return PS */ static function getInstance() { if (empty(self::$ps)) { if (!($paysystem = Cfg::get('PAYSYSTEM'))) { $paysystem = 'robokassa'; } $rs = DB::select("SELECT * FROM sc_pay_system WHERE name='{$paysystem}'"); if ($rs->next()) { $class_name = "PS" . ucfirst($paysystem); include_once "ps/{$class_name}.class.php"; self::$ps = new $class_name($rs->get('config')); } } return self::$ps; }
private function __construct() { $levels = Cfg::get('log_level'); if ($levels) { $levels = explode('|', $levels); $values = array('error' => self::ERROR, 'warning' => self::WARNING, 'info' => self::INFO, 'debug' => self::DEBUG); $this->level = 0; foreach ($levels as $v) { $v = trim($v); $this->level |= $values[$v]; } } $this->dir = Cfg::get('log_dir', Cfg::get('log_dir')); //$this->_write(date('d.m.Y H:i')); }
private function _excel_add_image($sheet, $image, &$i) { if (!(string) $image) { return --$i ? '' : ''; } download_web_file($image->url('350x230p'), $filepath = FCPATH . implode(DIRECTORY_SEPARATOR, array_merge(Cfg::system('orm_uploader', 'uploader', 'temp_directory'), array((string) $image)))); $objDrawing = new PHPExcel_Worksheet_Drawing(); $objDrawing->setPath($filepath); $j = $j = (ceil($i / 3) - 1) * 7 + 1; $objDrawing->setCoordinates(($i % 3 < 2 ? $i % 3 < 1 ? 'G' : 'A' : 'D') . $j); $objDrawing->setOffsetX(20); $objDrawing->setOffsetY(8); $objDrawing->setWidth(175); $objDrawing->setWorksheet($sheet); return $filepath; }
function clean_cache_file($CI) { $CI->load->library('cfg'); $cache = array(); array_push($cache, Cfg::system('cache', 'file')); array_push($cache, Cfg::system('cache', 'output')); array_push($cache, Cfg::system('cache', 'config')); array_push($cache, Cfg::system('cache', 'model')); if (array_filter(array_map(function ($t) { return directory_delete(FCPATH . implode(DIRECTORY_SEPARATOR, $t), false); }, $cache))) { return '已經清除所有 file cache!'; } else { return '清除 file cache 失敗!'; } }
public function __construct() { parent::__construct(); $config = Cfg::setting('mail'); if (isset($config['host']) && isset($config['port']) && isset($config['user']) && isset($config['passwd']) && isset($config['from']) && isset($config['from_name']) && $config['host'] && $config['port'] && $config['user'] && $config['passwd'] && $config['from'] && $config['from_name']) { $this->isSMTP(); $this->SMTPAuth = true; $this->Host = $config['host']; $this->Port = $config['port']; $this->Username = $config['user']; $this->Password = $config['passwd']; $this->From = $config['from']; $this->FromName = $config['from_name']; } $this->CharSet = $config['charset']; $this->Encoding = $config['encoding']; $this->isHTML(true); $this->WordWrap = 50; if (!empty($config['secure'])) { $this->SMTPSecure = $config['secure']; } }
public function __construct() { parent::__construct(); if (!(User::current() && User::current()->is_login())) { Session::setData('_flash_message', '', true); return redirect_message(array('login'), array('_flash_message' => '請先登入,或者您沒有後台權限!')); } $class = $this->get_class(); $method = $this->get_method(); $menus_list = array_map(function ($menus) use($class, $method, &$has_active) { return array_map(function ($item) use($class, $method, &$has_active) { $has_active |= $a = isset($item['class']) && $item['class'] && $class == $item['class'] && (isset($item['method']) && $item['method']) && $method == $item['method'] || isset($item['class']) && $item['class'] && $class == $item['class'] && !(isset($item['method']) && $item['method']) || !(isset($item['class']) && $item['class']) && (isset($item['method']) && $item['method']) && $method == $item['method']; return array_merge($item, array('active' => $a)); }, $menus); }, array_filter(array_map(function ($group) { return array_filter($group, function ($item) { return User::current()->in_roles($item['roles']); }); }, Cfg::setting('menu', 'admin')))); if (!$has_active) { return redirect_message(array('admin'), array('_flash_message' => '您沒有此頁面的管理權限。')); } $this->set_componemt_path('component', 'admin')->set_frame_path('frame', 'admin')->set_content_path('content', 'admin')->set_public_path('public')->set_title(Cfg::setting('site', 'admin', 'title'))->_add_meta()->_add_css()->_add_js()->add_param('_menus_list', $menus_list); }
public function __construct($fileName, $options = array()) { parent::__construct($fileName); $this->configs = Cfg::system('image_gd_utility'); $this->_init()->_setOptions($options); }
static function findByDir($dir, $isInfo = true, $isHidden = true) { $hidden = false; if ($isHidden) { $hidden = Cfg::get('hidden', false); } $dir = ltrim($dir, '/'); $path = Lib::gpath($dir); $res = array(); $d = opendir($path); if ($d) { $files = array(); while (($e = readdir($d)) !== false) { if ($e == '.' || $e == '..') { continue; } if ($hidden == false || !preg_match($hidden, $e)) { $file = BasefileModel::createFromPath($dir . '/' . $e, $isInfo); if ($file) { if ($file->type == 'folder') { $res[] = $file; } else { $files[] = $file; } } } } $res = array_merge($res, $files); } return $res; }
public static function make_block9($files, $save) { if (!(count($files) >= 9)) { throw new ImageUtilityException('ImageUtility 錯誤!', '參數錯誤,files count:' . count($files), '參數 files 數量一定要大於 9!'); } if (!(($module = Cfg::system('image_utility', 'module')) && in_array($module, array_keys($modules = Cfg::system('image_utility', 'modules'))))) { throw new ImageUtilityException('ImageUtility 錯誤!', '預設 module 錯誤!module:' . $module, '請檢查 config/system/image_utility.php 設定檔!'); } if (!class_exists($modules[$module])) { include_once $modules[$module] . EXT; } return call_user_func_array(array($modules[$module], 'make_block9'), array($files, $save)); }
public function __construct($configs = array()) { $this->CI =& get_instance(); $this->CI->load->library("cfg"); $this->configs = array_merge(Cfg::system('cell'), $configs); $this->setUseJsList(false); $this->setUseCssList(false); }
function display($data = array(), $tpl = null, $tplContainer = null, $cache = null) { global $ST; $this->setClientId(); $this->setFirstReferer(); $this->setRefId(); if (!$tpl) { $tpl = $this->tplComponent; } if (!$tplContainer) { $tplContainer = $this->getTplContainer(); } $this->refreshContainer(); /* ceo */ $rs = $ST->select("SELECT * FROM sc_ceo_meta\r\n\t\t\t WHERE \r\n\t\t\t \t(url='" . SQL::slashes($_SERVER['REQUEST_URI']) . "' AND rule='=') \r\n\t\t\t \tOR ('" . SQL::slashes($_SERVER['REQUEST_URI']) . "' LIKE CONCAT(url,'%') AND rule!='=' ) \r\n\t\t\t ORDER BY LENGTH(url) DESC LIMIT 1"); /* ceo */ $this->setCeo(array('url' => $_SERVER['REQUEST_URI'])); if ($rs->next()) { $this->setCeo($rs->getRow()); if ($this->getCeo('title')) { $this->setTitle($this->getCeo('title')); } if ($this->getCeo('header')) { $this->setHeader($this->getCeo('header')); } if ($this->getCeo('description')) { $this->setDescription($this->getCeo('description')); } if ($this->getCeo('keywords')) { $this->setKeywords($this->getCeo('keywords')); } } if (Cfg::get('STAMP')) { Img::$stamp = true; } $rnd = $this->render($data, $tpl); $out = $this->render($data, $tplContainer, $rnd); $t = microtime(true); if (preg_match_all('/\\{%(.+)%\\}/U', $out, $res) && $res) { $vals = array(); foreach ($res[1] as $id => $key) { //07.09.2011 Возможность создавать содержимое по названию $tmp = ''; if ($this->isAdmin()) { $tmp = '<a href="/admin/content/?act=edit&name=' . trim($key) . '" class="coin-text-edit" title="Редактировать"></a>' . $res[0][$id]; } $vals[trim($key)] = $tmp; } foreach ($this->cacheSelect("SELECT * FROM sc_content WHERE c_name IN('" . implode("','", array_keys($vals)) . "')", 0) as $row) { $res = $row['c_text']; if ($this->isAdmin()) { $res = '<a href="/admin/content/?act=edit&name=' . $row['c_name'] . '" class="coin-text-edit" title="Редактировать"></a>' . $res; } $vals[$row['c_name']] = $res; } $out = preg_replace('/\\{%(.+)%\\}/Ue', '$vals[trim("\\1")]', $out); //_replace($keys[$rs->get('c_name')],$res,$out); } $this->visitLog(); //Вывод ob_start(); ob_implicit_flush(0); echo $out; global $begin_time, $query_count, $query_time, $query_report, $cache_time; $t = microtime(true) - $begin_time; ?> <!-- <?php echo $t; ?> --><!-- <?php echo $query_count; ?> <?php echo $query_time; ?> --><!-- <?php echo $t - $query_time; ?> <?php echo $cache_time; ?> --><?php ?> <!-- <?php echo isset($_GET['debug']) && $_GET['debug'] == 'true' ? $query_report : ''; ?> --><?php GzDocOut(3, isset($_GET['debug']) && $_GET['debug'] == 'true'); $this->updateAdvView(); }
public static function bind($column_name, $class_name = null) { if (!$column_name) { return error('OrmUploader 錯誤!', 'OrmUploader::bind 參數錯誤!', '請確認 OrmUploader::bind 的使用方法的正確性!'); } if (!($trace = debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT))) { return error('OrmUploader 錯誤!', '取得 debug_backtrace 發生錯誤,無法取得 debug_backtrace!', '請確認 OrmUploader::bind 的使用方法的正確性!'); } if (!(isset($trace[1]['object']) && is_object($orm = $trace[1]['object']))) { return error('OrmUploader 錯誤!', '取得 debug_backtrace 回傳結構有誤,無法取得上層物件!', '請確認 OrmUploader::bind 的使用方法的正確性!'); } if (!$class_name) { $class_name = get_class($orm) . Cfg::system('orm_uploader', 'instance', 'class_suffix'); } if (is_readable($path = FCPATH . implode(DIRECTORY_SEPARATOR, array_merge(Cfg::system('orm_uploader', 'uploader', 'instance', 'directory'), array($class_name . EXT))))) { require_once $path; } else { $class_name = get_called_class(); } return $object = new $class_name($orm, $column_name); }