/** Class constructor @public **/ function __construct($page, $num_results, $total_items, $limit = 0, $baseURL = null, $automakeSEF = false, $detect_formatting = true) { // bind $this->_total = $total_items; $this->_num_results = $num_results; $this->_limit = $limit; $this->_limitstart = $this->_curpage > 1 ? $this->_curpage * $limit - $limit : 0; if ($this->_limit) { $this->_num_pages = $this->_total > $this->_limit ? ceil($this->_total / $this->_limit) : 0; } $this->_single_page = $this->_num_pages < 1; // check out-of-range page index $this->_curpage = $page > $this->_num_pages ? 1 : $page; // set base URL if don't exists $this->_baseURL = $baseURL; if (empty($baseURL)) { $config =& Factory::getConfig(); $uri = URL::getURI(); $this->_baseURL = $config->baseURL . $uri->_url; } // if true, URL::_ will be used $this->_automakeSEF = $automakeSEF; $this->_detect_formatting = $detect_formatting; // get component format if ($detect_formatting) { $component_format = Request::getVar('format'); if ($component_format) { $this->__component_format = 'format=' . Request::getVar('format'); } else { // turn it off if no special formatting found $this->_detect_formatting = false; } } }
/** Class constructor @public **/ function __construct() { // set global session identification $config =& Factory::getConfig(); switch (@$config->session_type) { case 'db': $sess_db = new SessionDBHandler(); $sess_db->init(); break; } session_start(); self::$global['SESSION_ID'] = session_id(); // init content buffer self::$global['RESPONSE'] = null; }
private function getJson() { switch ($_GET['json']) { case 'peel_log': $log = Factory::getLogger(); $data = $log->getContent(); break; case 'peel_ctrl': $conf = Factory::getConfig(); $data = array_map(function ($e) { return $e['peeler']; }, $conf['peelers']); break; default: $data = array(); } return json_encode($data); }
public function __construct() { $this->mConfig = Factory::getConfig(); date_default_timezone_set($this->mConfig['system']['timezone']); $this->mLogFile = isset($this->mConfig['logging']['log_file']) ? $this->mConfig['logging']['log_file'] : DIR_BASE . '/log/peel.log'; if (substr($this->mLogFile, 0, 1) !== '/') { $this->mLogFile = DIR_BASE . '/' . $this->mLogFile; } $logDir = dirname($this->mLogFile); if (!file_exists($logDir)) { $prevUmask = umask(0); mkdir($logDir, 0775, true); umask($prevUmask); } $this->mMaxSize = $this->mConfig['logging']['max_size']; $this->mMaxSize = str_replace(' ', '', $this->mMaxSize); if (preg_match('/^[0-9]+[0-9KMG]$/i', $this->mMaxSize) !== false) { $this->mMaxSize = str_replace('K', '000', $this->mMaxSize); $this->mMaxSize = str_replace('M', '000000', $this->mMaxSize); $this->mMaxSize = str_replace('G', '000000000', $this->mMaxSize); } else { $this->mMaxSize = '1000000'; } }
/** Set application-wide messaging (setter/getter) @public @param $text string **/ private function __message($token = '', $id = null) { $config =& Factory::getConfig(); @session_start(); if (empty($id)) { $id = '__info'; } // additional hash helper strings $app = Request::getVar('app'); $view = Request::getVar('view'); $id .= '.' . md5($config->salt . $config->template . $app . $view); if ($token === 'GET') { // getter if (isset($_SESSION[$id]['_app-notification'])) { $notification = $_SESSION[$id]['_app-notification']; // clear on last fetch $_SESSION[$id]['_app-notification'] = null; unset($_SESSION[$id]['_app-notification']); return $notification; } return null; } else { // setter $_SESSION[$id]['_app-notification'] = $token; } }
/** * @param string $name * @return Collection $this */ public function load($name) { $this->configs[$name] = $this->factory->getConfig($name); return $this; }
/** Load view template @param $layout string @public **/ public function loadTemplate($layout = 'default') { $config =& Factory::getConfig(); $html = ''; if (is_subclass_of($this, 'View')) { $paths = array($this->_custom_path . DS . $layout . '.php', PATH_TEMPLATES . DS . @$config->template . DS . 'html' . DS . $this->_appName . DS . $this->_name . DS . $layout . '.php', PATH_APPLICATIONS . DS . $this->_appName . DS . 'views' . DS . $this->_name . DS . 'tmpl' . DS . $layout . '.php'); foreach ($paths as $tpl_path) { if (is_file($tpl_path)) { break; } } // load layout if (file_exists($tpl_path) && is_file($tpl_path)) { ob_start(); include $tpl_path; $html = ob_get_clean(); } } return $html; }
/** * Run application. * * Starts application execution. * * @return void */ public function run() { $c = Factory::getConfig(); $z = isset($c['system']['timezone']) ? $c['system']['timezone'] : 'Europe/London'; date_default_timezone_set($z); }
function tinymce($name, $value = '', $required = false, $rows = 10, $cols = 50, $params = null) { $app =& Factory::getApplication(); $config =& Factory::getConfig(); // set script source path $baseURL = $config->baseURL; $baseURL = str_replace(@$config->admin_path, '', $baseURL); $app->set('js', $baseURL . 'assets/editors/tinymce/tiny_mce.js'); $show_format_1 = isset($params['buttons1_format']) && $params['buttons1_format'] ? true : false; $show_buttons_2 = isset($params['buttons2']) && $params['buttons2'] ? true : false; ob_start(); ?> <script> tinyMCE.init({ // General options mode : "exact", elements : "<?php echo $name; ?> ", theme : "advanced", skin : "o2k7", skin_variant : "silver", relative_urls : false, remove_script_host : false, invalid_elements: "script", plugins : "safari,table,style,advimage,paste,advlink,inlinepopups,media,directionality", // Theme options content_css : "<?php echo $baseURL; ?> templates/<?php echo $config->__raw->template; ?> /assets/css/editor.css", theme_advanced_buttons1 : "<?php echo $show_format_1 ? 'formatselect,' : ''; ?> bold,italic,underline,|,justifyleft,justifycenter,justifyright,justifyfull,|,bullist,numlist,|,outdent,indent,|undo,redo,|,pastetext,pasteword,|,link,unlink,image,|,code", theme_advanced_buttons2 : "<?php echo $show_buttons_2 ? 'tablecontrols,|,hr,removeformat' : ''; ?> ", theme_advanced_buttons3 : "<?php echo $show_buttons_2 ? 'formatselect,fontselect,fontsizeselect' : ''; ?> ", theme_advanced_toolbar_location : "top", theme_advanced_toolbar_align : "left", theme_advanced_statusbar_location : "none" <?php if (isset($params['width'])) { ?> ,width: <?php echo $params['width']; ?> <?php } ?> <?php if (isset($params['height'])) { ?> ,height: <?php echo $params['height']; ?> <?php } ?> // File manager (MFM) ,file_browser_callback : _loadMFM }); function _loadMFM(field_name, url, type, win) { tinyMCE.activeEditor.windowManager.open({ <?php // build params for this plugin $fm_params = array('base_path' => BASE_PATH, 'root_path' => $baseURL, 'editor_path' => $baseURL . 'assets/editors/tinymce', 'file_root' => 'uploads'); $fm_params = base64_encode(serialize($fm_params)); ?> file : "<?php echo $baseURL; ?> assets/editors/editor_plugins/mfm.php?field=" + field_name + "&url=" + url + "¶ms=<?php echo $fm_params; ?> ", title : 'File Manager', width : 640, height : 450, resizable : "no", inline : "yes", close_previous : "no" }, { window : win, input : field_name }); return false; } </script> <?php $js_script = ob_get_clean(); $app->set('js', $js_script, false, true); $attributes = array('mce_editable="true"'); // attach script tag if (isset($params['attach_script']) && $params['attach_script']) { $script_tag = str_replace(array('<script>', '</script>'), array('', ''), $js_script); $attributes[] = '_script_tag="' . base64_encode($script_tag) . '"'; } // load generic return HTMLHelper::_('editor.generic', $name, $value, $required, $rows, $cols, implode(' ', $attributes)); }
/** Convert URL fragments to SEF @private **/ private function __getSEFURL(&$buffer) { $config =& Factory::getConfig(); $basepath = $config->baseURL; $basepath = str_replace('/', '\\/', $basepath); $regex = "/\\<a.+?href=[\"|']{$basepath}(.+?)[\"|']/i"; $callback_func = ' if (!empty($matches[1])) { return \'<a href="\'. URL::_($matches[1]).\'"\'; } return $matches[1]; '; $buffer = preg_replace_callback($regex, create_function('$matches', $callback_func), $buffer); }
/** Simple XSS fix @param $var string @param $convert_to_html boolean @public **/ function cleanVar($var, $convert_to_html = true) { // init db $db =& Factory::getDBO(); if (get_magic_quotes_gpc()) { $var = stripslashes($var); } // utilize mysql string escape function $config =& Factory::getConfig(); if (strpos($config->dsn, 'mysql') !== false) { $var = @mysql_real_escape_string($var); } if ($convert_to_html) { $var = htmlentities($var); } return $var; }
/** Get Logging system @param $unique_id string @public **/ static function &getLogging($unique_id = null) { static $logging; // create if don't exists if (!is_object($logging)) { // get logging type $config =& Factory::getConfig(); switch (@$config->log_type) { default: // file $logging = new FileLogging($unique_id); } } return $logging; }
public function __construct() { $this->mConfig = Factory::getConfig(); }