/** * Get plugin list from the database, and attempt to load them in * * @version 1.1 * @since 1.0.0 * @author Dan Aldridge * * @param array $plugins * * @return bool */ public function load($plugins = array()) { if ($this->dontExec == true) { return false; } $objSQL = Core_Classes_coreObj::getDBO(); // make sure we didn't get an empty var... if (!is_array($plugins) || is_empty($plugins)) { // if we did try and get a fresh copy from the db $objCache = Core_Classes_coreObj::getCache(); $plugins = $objCache->load('plugins'); if (!is_array($plugins) || is_empty($plugins)) { $this->dontExec = true; return false; // no luck this time so just return quietly } } // loop though each plugin foreach ($plugins as $hook) { $hookStr = $hook['path']; // make sure its actually a file and is readable if (!is_file($hookStr) && !is_readable($hookStr)) { continue; } // also make sure its enabled.. if ($hook['enabled'] === false) { continue; } // and then include it :D include_once str_replace('./', cmsROOT . '', $hookStr); } // everything worked as expected so just return true; return true; }
/** * Outputs a table with the currently detected set of modules on * * @version 1.0 * @since 1.0.0 * @author Dan Aldridge * * @return void */ public function modules() { $objSQL = Core_Classes_coreObj::getDBO(); $objTPL = Core_Classes_coreObj::getTPL(); $objModule = Core_Classes_coreObj::getModule(); $objTPL->set_filenames(array('body' => cmsROOT . Core_Classes_Page::$THEME_ROOT . 'block.tpl', 'panel' => cmsROOT . 'modules/core/views/admin/modules/default/module_list.tpl')); $files = glob(sprintf('%smodules/*', cmsROOT)); foreach ($files as $file) { $moduleName = str_replace('modules/', '', $file); // Determine the status of the module if (parent::moduleExists($moduleName) === false) { continue; } $query = $objSQL->queryBuilder()->select('*')->from('#__modules')->where('name', '=', $moduleName)->build(); $row = $objSQL->fetchLine($query); $moduleInstalled = parent::moduleInstalled($moduleName); if (empty($row) || $moduleInstalled === false) { $details = $objModule->getModuleDetails($moduleName); if (!empty($details)) { $version = $details['version']; $hash = $details['hash']; } } $objTPL->assign_block_vars('module', array('NAME' => $moduleName, 'VERSION' => $version, 'HASH' => $hash, 'STATUS' => $moduleInstalled === false ? 'Not Installed' : 'Installed', 'STATUS_ICON' => $moduleInstalled === false ? 'default' : 'success')); } $objTPL->parse('panel', false); Core_Classes_coreObj::getAdminCP()->setupBlock('body', array('cols' => 3, 'vars' => array('TITLE' => 'Module List', 'CONTENT' => $objTPL->get_html('panel', false), 'ICON' => 'icon-th-list'))); }
/** * Loops through the blocks and displays them nicely using the theme template * * @version 1.0 * @since 1.0 * @author Daniel Noel-Davies * * @param array $blocks Collection of blocks * */ private function displayPortlets($blocks) { $objTPL = Core_Classes_coreObj::getTPL(); $objTPL->set_filenames(array('block_notices' => cmsROOT . Core_Classes_Page::$THEME_ROOT . 'block.tpl')); $rowCount = 12; foreach ($blocks as $title => $block) { $block['COL'] = (int) doArgs('COL', 12, $block); $objTPL->assign_block_vars('block', array('TITLE' => $title, 'CONTENT' => dump($rowCount, 'RowCount') . dump($block, 'block'), 'ICON' => 'icon-' . doArgs('ICON', null, $block))); // If there are no blocks in the row, Start new row if ($rowCount === 12) { $objTPL->assign_block_vars('block.start_row', array()); // If there is no space for the current block, end the current div above everything, and start a new one } else { if ($rowCount - $block['COL'] < 0) { $objTPL->assign_block_vars('block.start_row', array()); $objTPL->assign_block_vars('block.pre_end_row', array()); } } // If, after everything, we are at 0, end the current block, and reset the row count $rowCount -= $block['COL']; if ($rowCount <= 0) { $objTPL->assign_block_vars('block.end_row', array()); $rowCount = 12; } $objTPL->assign_block_vars('block.' . doArgs('COL', '12', $block) / 4 . 'col', array()); $objTPL->assign_vars(array('BLOCKS' => $objTPL->get_html('block_notices'))); } }
/** * Generate a date string from a timestamp * * @version 1.0 * @since 1.0.0 * @author Dan Aldridge * * @param int $timestamp * @param string $format * @param bool $format * * @return string */ public function mk_time($timestamp, $format = 'db', $return = 0) { // Get the instances we need $objUser = Core_Classes_coreObj::getUser(); $translate = array(); $format = $format == 'db' ? $this->config('site', 'time', 'jS F h:ia') : $format; $timestamp = isset($timestamp) ? $timestamp : time(); $timestamp = date('I') == 0 ? $this->mod_time($timestamp, 0, 0, 1) : $timestamp; // If User is logged in, Use his/her timezone if (Core_Classes_User::$IS_ONLINE && $objUser->grab('timezone')) { $this->mod_time($timestamp, 0, 0, $objUser->grab('timezone')); } // Translate the date if it's possible if (empty($translate) && $this->currentLanguage != 'en') { $lang_date = langVar('DATETIME'); reset($lang_date); while (list($match, $replace) = each($lang_date)) { $translate[$match] = $replace; } } // If we're not meant to return anything, if ($return === 0) { $return = gmdate($format, $timestamp); // Execute translation if there is a translation if (!empty($translate)) { $return = strtr($return, $translate); } } else { $return = $timestamp; } // Tidy up unset($objUser, $translate, $format, $timestamp, $lang_date, $match, $replace, $format); return $return; }
/** * Simple Debug info * * @version 1.0 * @since 1.0.0 * @author Dan Aldridge * * @return void */ public function systeminfo() { $objSQL = Core_Classes_coreObj::getDBO(); $objTPL = Core_Classes_coreObj::getTPL(); $objTime = Core_Classes_coreObj::getTime(); $objForm = Core_Classes_coreObj::getForm(); $objTPL->set_filenames(array('body' => cmsROOT . Core_Classes_Page::$THEME_ROOT . 'block.tpl')); // checkers // grab some info about GD if (function_exists('gd_info')) { $a = gd_info(); $gdVer = preg_replace('/[[:alpha:][:space:]()]+/', '', $a['GD Version']); } else { $gdVer = 'Not Installed.'; } $info = '<div class="alert alert-info"><strong>Important!</strong> This panel needs more updating to output more useful data that has been made avaliable during the last overhaul</div>'; $content = 'This panel gives the CMS dev team some information about your setup. ;--System Setup CMS Version: ' . CMS_VERSION . ' PHP Version: ' . PHP_VERSION . ' (' . (@ini_get('safe_mode') == '1' || strtolower(@ini_get('safe_mode')) == 'on' ? 'Safe Mode Enabled' : 'Safe Mode Disabled') . ') MySQL Version: ' . mysql_get_server_info() . ' GD Version: ' . $gdVer . ' ;--CMS Setup Install Path: /' . root() . ' ' . json_encode($objSQL->fetchAll('SELECT * FROM `#__config`')) . ''; Core_Classes_coreObj::getAdminCP()->setupBlock('body', array('cols' => 3, 'vars' => array('TITLE' => 'System Info', 'CONTENT' => $info . $objForm->textarea('sysInfo', $content, array('style' => 'width: 99%', 'rows' => 20)), 'ICON' => 'fa-icon-user'))); }
/** * Generates a form for the site configuration * * @version 1.0 * @since 1.0.0 * @author Dan Aldridge * * @return void */ public function siteConfig() { Core_Classes_coreObj::getPage()->addBreadcrumbs(array(array('url' => doArgs('REQUEST_URI', '', $_SERVER), 'name' => 'Site Config'))); $objForm = Core_Classes_coreObj::getForm(); $objTPL = Core_Classes_coreObj::getTPL(); $yn = array(1 => langVar('L_YES'), 0 => langVar('L_NO')); $fields = array(langVar('L_SITE_CONFIG') => '_header_', langVar('L_SITE_TITLE') => $objForm->inputbox('title', 'text', $this->config('site', 'title')), langVar('L_SITE_SLOGAN') => $objForm->inputbox('slogan', 'text', $this->config('site', 'slogan')), langVar('L_ADMIN_EMAIL') => $objForm->inputbox('admin_email', 'text', $this->config('site', 'admin_email')), langVar('L_GANALYTICS') => $objForm->inputbox('google_analytics', 'input', $this->config('site', 'google_analytics')), langVar('L_CUSTOMIZE') => '_header_', langVar('L_THEME_OVERRIDE') => $objForm->radio('theme_override', $yn, $this->config('site', 'theme_override')), langVar('L_SITE_TZ') => $timezone, langVar('L_DST') => $objForm->radio('dst', $yn, $this->config('time', 'dst')), langVar('L_DEF_DATE_FORMAT') => $objForm->inputbox('default_format', 'input', $this->config('time', 'default_format'))); $form = $objForm->outputForm(array('FORM_START' => $objForm->start('panel', array('method' => 'POST', 'action' => $saveUrl, 'class' => 'form-horizontal')), 'FORM_END' => $objForm->finish(), 'FORM_TITLE' => $mod_name, 'FORM_SUBMIT' => $objForm->button('submit', 'Submit', array('class' => 'btn-primary')), 'FORM_RESET' => $objForm->button('reset', 'Reset'), 'HIDDEN' => $objForm->inputbox('sessid', 'hidden', $sessid) . $objForm->inputbox('id', 'hidden', $uid)), array('field' => $fields, 'desc' => array(langVar('L_INDEX_MODULE') => langVar('L_DESC_IMODULE'), langVar('L_SITE_TZ') => langVar('L_DESC_SITE_TZ'), langVar('L_DEF_DATE_FORMAT') => langVar('L_DESC_DEF_DATE'), langVar('L_DEF_THEME') => langVar('L_DESC_DEF_THEME'), langVar('L_THEME_OVERRIDE') => langVar('L_DESC_THEME_OVERRIDE'), langVar('L_ALLOW_REGISTER') => langVar('L_DESC_ALLOW_REGISTER'), langVar('L_EMAIL_ACTIVATE') => langVar('L_DESC_EMAIL_ACTIVATE'), langVar('L_MAX_LOGIN_TRIES') => langVar('L_DESC_MAX_LOGIN'), langVar('L_REMME') => langVar('L_DESC_REMME'), langVar('L_GANALYTICS') => langVar('L_DESC_GANALYTICS')), 'errors' => $_SESSION['site']['panel']['error']), array('header' => '<h4>%s</h4>', 'dedicatedHeader' => true, 'parseDesc' => true)); Core_Classes_coreObj::getAdminCP()->setupBlock('body', array('cols' => 3, 'vars' => array('TITLE' => 'Site Configuration', 'CONTENT' => $form, 'ICON' => 'fa-icon-user'))); }
function recache() { if (isset($_GET['_recache'])) { echo dump($_GET, 'RECACHE BOOM!'); $objCache = Core_Classes_coreObj::getCache(); $objCache->remove('stores'); $objCache->remove('media'); $objCache->remove('template'); } }
/** * Add a new user to the system * * @version 1.0 * @since 1.0.0 * @author Dan Aldridge * * @return void */ public function add() { $objSQL = Core_Classes_coreObj::getDBO(); $objTPL = Core_Classes_coreObj::getTPL(); $objTime = Core_Classes_coreObj::getTime(); Core_Classes_coreObj::getPage()->addBreadcrumbs(array(array('url' => doArgs('REQUEST_URI', '', $_SERVER), 'name' => 'Add User'))); $objTPL->set_filenames(array('body' => cmsROOT . Core_Classes_Page::$THEME_ROOT . 'block.tpl', 'panel' => cmsROOT . 'modules/core/views/admin/users/add.tpl')); $objTPL->parse('panel', false); Core_Classes_coreObj::getAdminCP()->setupBlock('body', array('cols' => 3, 'vars' => array('TITLE' => 'Add User', 'CONTENT' => $objTPL->get_html('panel', false), 'ICON' => 'faicon-user'))); }
function _codemirrorHighlight($content, $language = '') { $objPage = Core_Classes_coreObj::getPage(); if (is_empty($content)) { return false; } $objPage->addCSSFile(array('href' => '/' . root() . 'assets/styles/codemirror-min.css', 'priority' => LOW)); $objPage->addJSFile(array('src' => '/' . root() . 'assets/javascript/codemirror-min.js', 'priority' => LOW), 'footer'); $objPage->addJSFile(array('src' => '/' . root() . 'assets/javascript/codemirror-langs-min.js', 'priority' => LOW), 'footer'); $objPage->addJSFile(array('src' => '/' . root() . 'assets/javascript/codemirror/highlighter.js', 'priority' => LOW), 'footer'); $language = grabLangInfo($language, 'mime'); $content = trim($content); $content = html_entity_decode($content, ENT_NOQUOTES); $content = str_replace('<?php', '<?php', $content); //return $content; return dump($content) . "\n<pre><span data-lang=\"" . $language . "\" data-codemir3ror=\"true\">" . $content . "</span></pre>\n"; }
/** * Outputs a table with currently detected themes in * * @version 1.0 * @since 1.0.0 * @author Dan Aldridge * * @return void */ public function themes() { $objForm = Core_Classes_coreObj::getForm(); $objTPL = Core_Classes_coreObj::getTPL(); $objTPL->set_filenames(array('body' => cmsROOT . Core_Classes_Page::$THEME_ROOT . 'block.tpl', 'table' => cmsROOT . 'modules/core/views/admin/themes/manageTable.tpl')); $dir = cmsROOT . 'themes'; $tpls = getFiles($dir); //echo dump($tpls); foreach ($tpls as $tpl) { if ($tpl['type'] !== 'dir') { continue; } $tplName = secureMe($tpl['name'], 'alphanum'); $details = $this->getDetails($tplName); //echo dump($details, $tplName); $objTPL->assign_block_vars('theme', array('NAME' => doArgs('name', 'N/A', $details), 'VERSION' => doArgs('version', '0.0', $details), 'ENABLED' => 'true', 'COUNT' => '9001', 'MODE' => doArgs('mode', 'N/A', $details), 'AUTHOR' => doArgs('author', 'N/A', $details))); } $objTPL->parse('table', false); Core_Classes_coreObj::getAdminCP()->setupBlock('body', array('cols' => 3, 'vars' => array('TITLE' => 'Theme Management', 'CONTENT' => $objTPL->get_html('table', false), 'ICON' => 'fa-icon-user'))); }
/** * Install a block from a Module method * * @version 1.0 * @since 1.0 * @author Daniel Noel-Davies * * @param string $var Parameter Description * */ public function installFromModule($module, $method) { $objModule = Core_Classes_coreObj::getModule(); $objSQL = Core_Classes_coreObj::getDBO(); $details = $objModule->getDetails($module); // Check method is callable and the module is enabled // Not okay if ($details === false || $objModule->moduleInstalled() === false) { // Error + return false trigger_error('Module x is not installed, No block was created'); return false; } $data = array('uniqueid' => randcode(8), 'label' => '', 'title' => '', 'region_name' => '', 'order' => '', 'enabled' => '', 'info' => json_encode(), 'args' => json_encode(), 'whitelist' => '', 'content' => ''); // Add into db + display status $query = $objSQL->queryBuilder()->insertInto('#__blocks')->set($data)->build(); $result = $objSQL->insert($query); if ($result) { return true; } return false; }
<?php /*======================================================================*\ || Cybershade CMS - Your CMS, Your Way || \*======================================================================*/ define('INDEX_CHECK', true); define('cmsDEBUG', true); $GET = $_GET; require_once 'core/core.php'; $objRoute = Core_Classes_coreObj::getRoute(); $objPage = Core_Classes_coreObj::getPage(); $objTPL = Core_Classes_coreObj::getTPL(); $objAdmin = Core_Classes_coreObj::getAdminCP('', $GET); $objUser = Core_Classes_coreObj::getUser(); $objRoute->modifyGET($GET); if (!Core_Classes_User::$IS_ONLINE || !Core_Classes_User::$IS_ADMIN) { // Need to sort out login // $objRoute->throwHTTP(404); $objPage->redirect('/' . root() . 'login'); exit; } $objPage->setTheme('perfectum-mootools'); $objPage->addBreadcrumbs(array(array('url' => '/' . root() . $objAdmin->mode . '/', 'name' => ucwords($objAdmin->mode) . ' Control Panel'))); $objPage->setTitle('Cybershade CMS Administration Panel'); // grab the nav and throw the baSic tpl setups together $objAdmin->getNav(); $objPage->tplGlobals(); // sort the route out, see what we need to do $objAdmin->invokeRoute(); // and then output..something $objPage->showHeader();
/** * Check if a module is installed in the database and enabled * * @version 1.0.0 * @since 1.0.0 * @author Richard Clifford * * @param string $moduleName * * @return bool */ public static function moduleInstalled($moduleName) { return true; // Temp Fix if (is_empty($moduleName)) { return false; } // return true here, apparently the module table isnt complete // return true; $objSQL = Core_Classes_coreObj::getDBO(); $query = $objSQL->queryBuilder()->select('enabled')->from('#__modules')->where('name', '=', $moduleName)->build(); $result = $objSQL->fetchLine($query); if ($result && isset($result['enabled']) && $result['enabled'] === 1) { return true; } return false; }
/** * Returns the html for the pagination * * @version 1.0 * @since 1.0.0 * @author Dan Aldridge * * @param array $options * * @return int */ public function getPagination($options = array()) { $options = array('url' => doArgs('url', '', $options), 'controls' => doArgs('controls', false, $options), 'type' => doArgs('type', 'pagination-mini', $options), 'showOne' => doArgs('showOne', false, $options)); $objTPL = Core_Classes_coreObj::getTPL(); $objUser = Core_Classes_coreObj::getUser(); // if we have 1 or less pages, then unless we specifically want to see it, hide the pagination if ($this->getTotalPages() <= 1) { if ($options['showOne'] === false) { return ''; } } // generate the pagination handle - each one has to be diff, to support > 1 on a page $handle = 'pagination_' . randCode(6); $objTPL->set_filenames(array($handle => cmsROOT . 'modules/core/views/markup.tpl')); // figure out which one we want to use $switch = IS_ONLINE ? $objUser->get('paginationStyle') : '1'; if (!method_exists($this, 'paginationStyle' . $switch)) { $switch = '1'; } $pages = $this->{'paginationStyle' . $switch}($options['controls']); $pages = isset($pages) ? $pages : array(); // setup the output $objTPL->assign_block_vars('pagination', array('TYPE' => $options['type'])); foreach ($pages as $page) { $objTPL->assign_block_vars('pagination.page', array('NUM' => doArgs('label', doArgs('count', '0', $page), $page), 'STATE' => doArgs('state', '', $page))); if (doArgs('url', true, $page)) { $objTPL->assign_block_vars('pagination.page.url', array('URL' => doArgs('url', true, $page) ? $this->url . $this->instance . '=' . doArgs('count', '0', $page) : '')); } else { $objTPL->assign_block_vars('pagination.page.span', array()); } } // and output $objTPL->parse($handle, false); return $objTPL->get_html($handle); }
/** * Verifies a Users Credentials to ensure they are valid * * @version 1.0 * @since 1.0.0 * @author Dan Aldridge * * @param string $username * @param string $password * * @return bool */ public function verifyUserCredentials($username, $password) { $objSQL = Core_Classes_coreObj::getDBO(); // Grab the user's id $uid = $this->getIDByUsername($username); // if the username doesn't exist, return false; if ($uid === 0) { return false; } // Grab the phpass library $objPass = Core_classes_coreObj::getLib('phpass', array(8, true)); // Fetch the hashed password from the database $hash = $this->get('password', $uid); if ($objPass->CheckPassword($password, $hash)) { return true; } return false; }
/** * Outputs a block with content in for the ACP * * @version 1.0 * @since 1.0.0 * @author Dan Aldridge * * @return void */ public static function setupBlock($handle, $options = array()) { $options = array('cols' => doArgs('cols', 3, $options), 'vars' => isset($options['vars']) && is_array($options['vars']) ? $options['vars'] : array(), 'custom' => isset($options['custom']) && is_array($options['custom']) ? $options['custom'] : array(), 'custom_html' => isset($options['custom_html']) && is_array($options['custom_html']) ? $options['custom_html'] : array()); if (is_empty($options['vars'])) { trigger_error('No vars passed to setupBlock()'); return; } if (!in_array($options['cols'], array(1, 2, 3))) { trigger_error('Columns option needs to be 1 2 or 3'); return; } $objTPL = Core_Classes_coreObj::getTPL(); $objTPL->set_filenames(array($handle => cmsROOT . Core_Classes_Page::$THEME_ROOT . 'block.tpl')); $objTPL->assign_block_vars('block', $options['vars']); $objTPL->assign_block_vars('block.start_row', array()); $objTPL->assign_block_vars('block.' . $options['cols'] . 'col', array()); if (!is_empty($options['custom'])) { $objTPL->assign_block_vars('block.custom', $options['custom']); } if (!is_empty($options['custom_html'])) { $objTPL->assign_block_vars('block.custom_html', $options['custom_html']); } $objTPL->assign_block_vars('block.end_row', array()); $objTPL->parse($handle, false); }
/** * Checks whether the user has exceeded the login quota * * @version 1.0 * @since 1.0.0 * @author Daniel Noel-Davies * * @param bool $dontUpdate * * @return bool */ public function attemptsCheck($dontUpdate = false) { if ($this->onlineData['login_time'] >= time()) { return false; } elseif ($this->onlineData['login_attempts'] > $this->config('login', 'max_login_tries')) { if ($this->onlineData['login_time'] == '0') { $objSQL = Core_Classes_coreObj::getDBO(); $objTime = Core_Classes_coreObj::getTime(); $objUser = Core_Classes_coreObj::getUser(); $query = $objSQL->queryBuilder()->update('#__sessions')->set(array('login_time' => $objTime->mod_time(time(), 0, 15), 'login_attempts' => '0'))->where('sid', '=', $objUser->grab('userkey'))->build(); $objSQL->query($query); } return false; } if ($dontUpdate === true) { return true; } if ($this->userData['login_attempts'] >= $this->config('login', 'max_login_tries')) { if ($this->userData['login_attempts'] === $this->config('login', 'max_login_tries')) { //deactivate the users account Core_Classes_coreObj::getUser()->toggle($this->userData['id'], 'active', false); } return false; } return true; }
/** * Throws a HTTP Error Code and a pretty CMS Page * * @version 1.0 * @since 1.0.0 * @author Dan Aldridge * * @param int $error * * @return bool */ public function throwHTTP($error = 00, $val = null) { if (headers_sent()) { return false; } $msg = NULL; $objPage = Core_Classes_coreObj::getPage(); switch ($error) { default: case 00: header('HTTP/1.0 ' . $error . ''); $msg = 'Something went wrong, we cannot determine what. HTTP Error: ' . $error; break; case 301: header('HTTP/1.0 301 Moved Permanently'); header('Location: ' . $val); break; case 400: header('HTTP/1.0 400 Bad Request'); $objPage->setTitle('Error 400 - Bad Request'); $msg = 'Error 400 - The server did not understand your request.' . ' If the error persists contact an administrator with details on how to replicate the error.'; break; case 401: header('HTTP/1.0 401 Unauthorized'); $objPage->setTitle('Error 401 Unauthorized'); $msg = 'Error 401 - You do not have authorization to access esource.'; break; case 403: header('HTTP/1.0 403 Forbidden'); $objPage->setTitle('Error 403 - Forbidden'); $msg = 'Error 403 - You have been denied access to the requested page.'; break; case 404: header('HTTP/1.0 404 Not Found'); $objPage->setTitle('Error 404 - Page Not Found'); $msg = 'Error 404 - The file you were looking for cannot be found.'; break; case 500: header('HTTP/1.0 500 Internal Server Error'); $objPage->setTitle('Error 500 - Internal Server Error'); $msg = 'Error 500 - Oops it seems we have broken something.. '; break; } //hmsgDie('FAIL', $msg); }
/** * Retrieves one uploaded image, or set of them * * @version 1.0 * @since 1.0 * @author Daniel Noel-Davies * * @param int|array $id Single Upload ID, or array of Upload IDs * */ public function getInfo($id, $onlyPublic = true) { // Check we've got what we need if (!is_int($id) && !is_numeric($id) && !is_array($id)) { trigger_error('Invalid arguments supplied for ' . __FUNCTION__); return array(); } $objSQL = Core_Classes_coreObj::getDBO(); $where = false; $query = $objSQL->queryBuilder()->select('*')->from('#__uploads'); if (is_array($id)) { foreach ($id as $i) { if (is_int($i)) { if ($where == true) { $query->orWhere('id', '=', $i); } else { $query->where('id', '=', $i); } } } } else { $query->where('id', '=', $id); } $query = $query->build(); $info = $objSQL->fetchAll($query, 'id'); if (sizeOf($info) == 1) { return $info[$id]; } return $info; }
/** * Saves the data from the menu editor * * @version 1.0 * @since 1.0.0 * @author Dan Aldridge * @data-access AJAX Only * * @return string */ public function editSave($args = array()) { if (!HTTP_POST) { die('Error: Could not get post data.'); } $data = array('menu_name' => doArgs('1', false, $args), 'menu_data' => doArgs('menu', false, $_POST)); if (in_array($data, false)) { die('Error: could not retrieve proper data.'); } $data['menu_data'] = json_decode($data['menu_data'], true); $data['menu_data'] = $this->generateFlatTable($data['menu_data']); if (!is_array($data['menu_data']) || is_empty($data['menu_data'])) { die('Error: Could not process array.'); } $parents = null; $orders = null; foreach ($data['menu_data'] as $id => $row) { $parents .= sprintf(' WHEN `id`="%s" THEN "%s"' . "\n", $id, $row['parent']); $orders .= sprintf(' WHEN `id`="%s" THEN "%s"' . "\n", $id, $row['order']); } // raw query, but honestly wouldnt know where to start with the query builder & this baby XD $objSQL = Core_Classes_coreObj::getDBO(); $query = ' UPDATE #__menus SET `parent_id` = CASE ' . $parents . ' ELSE `parent_id` END, `order` = CASE ' . $orders . ' ELSE `order` END WHERE id IN("' . implode('", "', array_keys($data['menu_data'])) . '") '; $query = $objSQL->query($query); if ($query === false) { die('Error: Could not run update query. SQL Said: ' . $objSQL->getError()); } die('Info: Updated Successfully.'); exit; }
/** * Generates the config cache * * @version 2.0 * @since 1.0.0 * @author Dan Aldridge * * */ public function generate_config_cache() { $objSQL = Core_Classes_coreObj::getDBO(); $query = $objSQL->queryBuilder()->select('key', 'var', 'value', 'default')->from('#__config')->orderBy('key', 'DESC')->build(); $results = $objSQL->fetchAll($query); if (!count($results)) { echo $objSQL->getError(); return false; } $return = array(); foreach ($results as $row) { $return[$row['key']][$row['var']] = isset($row['value']) && !is_empty($row['value']) ? $row['value'] : $row['default']; } return $return; }
//Added BBcode Rules $objBBCode->CloneBB('url', 'link'); $objBBCode->CloneBB('url', 'linkit'); $objBBCode->AddRule('user', array('mode' => BBCODE_MODE_CALLBACK, 'method' => 'bbcode_user_profile', 'class' => 'link', 'allow_in' => array('listitem', 'block', 'columns', 'inline', 'link'), 'content' => BBCODE_VERBATIM, 'end_tag' => BBCODE_REQUIRED)); $objBBCode->AddRule('noparse', array('mode' => BBCODE_MODE_SIMPLE, 'class' => 'inline', 'allow_in' => array('listitem', 'block', 'columns', 'inline', 'link'), 'content' => BBCODE_VERBATIM, 'end_tag' => BBCODE_REQUIRED)); $objBBCode->AddRule('nosmilies', array('mode' => BBCODE_MODE_SIMPLE, 'class' => 'inline', 'allow_in' => array('listitem', 'block', 'columns', 'inline', 'link'), 'content' => BBCODE_VERBATIM, 'end_tag' => BBCODE_REQUIRED)); $objBBCode->AddRule('small', array('simple_start' => '<small>', 'simple_end' => '</small>', 'class' => 'inline', 'allow_in' => array('listitem', 'block', 'columns', 'inline', 'link'), 'plain_start' => '<small>', 'plain_end' => '</small>')); $objBBCode->AddRule('pre', array('mode' => BBCODE_MODE_SIMPLE, 'end_tag' => BBCODE_REQUIRED, 'simple_start' => '<pre>', 'simple_end' => '</pre>', 'allow_in' => array('listitem', 'block', 'columns', 'inline'))); $objBBCode->AddRule('quote', array('mode' => BBCODE_MODE_CALLBACK, 'method' => "bbcode_quote", 'allow_in' => array('listitem', 'block', 'columns'), 'before_tag' => "sns", 'after_tag' => "sns", 'before_endtag' => "sns", 'after_endtag' => "sns", 'plain_start' => "\n<b>Quote:</b>\n", 'plain_end' => "\n")); $objBBCode->AddRule('you', array('mode' => BBCODE_MODE_CALLBACK, 'end_tag' => BBCODE_PROHIBIT, 'content' => BBCODE_PROHIBIT, 'method' => 'bbcode_you', 'class' => 'link', 'allow_in' => array('listitem', 'block', 'columns', 'inline', 'link'))); $x = 0; while ($x <= 6) { $objBBCode->AddRule('h' . $x, array('simple_start' => '<h' . $x . '>', 'simple_end' => '</h' . $x . '>', 'class' => 'inline', 'allow_in' => array('listitem', 'block', 'columns', 'inline', 'link'))); $x++; } //load smilies in $objPage = Core_Classes_coreObj::getPage(); $pack = is_empty($objPage->config('site', 'smilie_pack')) ? $objPage->config('site', 'smilie_pack') : 'default'; $smilieDir = cmsROOT . 'images/smilies/' . $pack . '/'; if (is_dir($smilieDir) && is_readable($smilieDir . 'smilies.txt')) { $smilies = file($smilieDir . 'smilies.txt'); if (count($smilies)) { foreach ($smilies as $line) { $s = explode(' ', $line); if (!isset($s[0]) || !isset($s[1])) { continue; } $objBBCode->AddSmiley($s[0], $pack . '/' . $s[1]); } } }
public function logout() { $objLogin = Core_Classes_coreObj::getLogin(); $objLogin->logout($_GET['check']); }
/** * Returns an array of user id in said group according to whether they are $pending * * @version 1.0 * @since 1.0.0 * @author Dan Aldridge * * @param int $uid User's ID * @param int $pending * * @return array */ function usersInGroup($gid, $pending = 0) { if (!is_number($gid)) { trigger_error('$gid is not valid'); return false; } if (!is_number($pending)) { trigger_error('$pending is not valid'); return false; } $objSQL = Core_Classes_coreObj::getDBO(); // Get Group /*$query = $objSQL->query(vsprintf('SELECT ug.uid, ug.pending, g.type, g.moderator FROM `#__groups` g, `#__group_subs` ug WHERE g.id = "%s" AND ug.gid = g.id', array($gid)));*/ $query = $objSQL->queryBuilder()->select('ug.uid', 'ug.pending', 'g.type', 'g.moderator')->from(array('g' => '#__groups'))->leftJoin(array('ug' => '#__group_subs'))->on('ug.gid', '=', 'g.id')->where(sprintf('g.id = %d', $gid))->build(); $result = $objSQL->fetchAll($query); if (is_empty($result)) { trigger_error('No group for ID: ' . $gid); return false; } // create an array of uid's in group according to $pending $users = array(); foreach ($result as $row) { if ($row['pending'] == $pending) { $users[] = $row['uid']; } } return $users; }
/** * Global func to log data * * @version 1.0 * @since 1.0.0 * @author Richard Clifford * * @param mixed $var * @param mixed $message * @param string $info * * @return mixed */ function debugLog($var, $message = '', $type = 'info') { $objDebug = Core_Classes_coreObj::getDebug(); return $objDebug->log($var, $message, $type); }
public function showFooter() { if (!$this->getOptions('completed')) { return; } $objTPL = self::getTPL(); // run a check on simple $simple = $this->getOptions('mode') ? true : false; // see if we are gonna get the simple one or the full blown one $footer = $simple ? 'simple_footer.tpl' : 'site_footer.tpl'; $objTPL->set_filenames(array('siteFooter' => self::$THEME_ROOT . $footer)); $this->buildBlocks(); cmsDEBUG ? memoryUsage('System: Finished Loading.') : ''; if (defined('cmsDEBUG') && cmsDEBUG === true && (LOCALHOST || Core_Classes_User::$IS_ADMIN)) { $objDebug = Core_Classes_coreObj::getDebug(); $objTPL->assign_block_vars('debug', array('DEBUG' => $objDebug->output())); } $objTPL->parse('siteFooter'); }
function doCode($content, $name = NULL, $lineNumbers = false, $killWS = true) { $lang = isset($name) && $name !== NULL ? strtolower($name) : 'text'; $extInfo = grabLangInfo($lang); $ext = doArgs('ext', null, $extInfo); $lang = doArgs('lang', null, $extInfo); $geshiExt = doArgs('geshi', null, $extInfo); if (is_empty($content)) { $lang = isset($lang) ? '=' . $params . '' : ''; return "[code{$lang}][/code]"; } $content = html_entity_decode(trim($content)); $content = str_replace(array("<br />", "\t", ' '), array('', ' ', "\t"), $content); if ($killWS) { $content = preg_replace('/[\\n\\r]+/', "\n", $content); } if (!$lineNumbers) { if ($ext != 'php') { $geshi = Core_Classes_coreObj::getLib('GeSHi', array($content, $geshiExt)); $geshi->set_header_type(GESHI_HEADER_PRE); $content = $geshi->parse_code(); } if ($ext == 'php') { /* if(preg_match("#<\?[^php]#", $content)) $content = str_replace("<?", "<?php", $content); if(!preg_match("#<(\?php|\?)#", $content)) $content = "<?php".$content; if(!preg_match("#\?>#", $content)) $content = $content."?>"; */ } } else { $geshi = Core_Classes_coreObj::getLib('GeSHi', array($content, $geshiExt)); $geshi->set_header_type(GESHI_HEADER_PRE); $geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS, 5); $content = $geshi->parse_code(); } return "\n<div class=\"bbcode_code\">\n<div class=\"bbcode_code_head\">" . $lang . " Code: </div>\n<div class=\"bbcode_code_body\">" . ($ext == 'php' ? !$lineNumbers ? highlight_string($content, true) : $content : $content) . "</div>\n</div>\n"; }
function loadCaptcha($var) { $objPlugins = Core_Classes_coreObj::getPlugins(); return $objPlugins->hook('CMSForm_Captcha', $var); }
/** * Outputs the debug onto the page * * @version 1.0 * @since 1.0.0 * @author Daniel Noel-Davies * * @return string */ public function output() { $tabs = ''; $content = ''; $output = ''; $debugTabs = array(); $objPlugin = Core_Classes_coreObj::getPlugins(); $objPage = Core_Classes_coreObj::getPage(); $objPage->addJSFile(array('src' => '/' . root() . 'assets/javascript/tabs.js'), 'footer'); $objPage->addJSFile(array('src' => '/' . root() . 'assets/javascript/debug.js'), 'footer'); // Setup the tabs $tab = $this->getGlobals(true); $debugTabs['globals'] = array('title' => 'Globals', 'content' => $tab['content']); // Setup the tabs $tab = $this->getDumpOutput(true); $debugTabs['debuglog'] = array('title' => 'Dev Debug', 'content' => $tab['content']); // Setup the tabs $tab = $this->getConfig(true); $debugTabs['config'] = array('title' => 'Config', 'content' => $tab['content']); $tab = $this->getPHPErrors(true); $debugTabs['errors'] = array('title' => sprintf('PHP / CMS Errors <div class="label label-info">%s</div>', $tab['count']), 'content' => $tab['content']); $tab = $this->getMemoryUse(true); $debugTabs['memory'] = array('title' => sprintf('Memory Usage <div class="label label-info">%s</div>', $tab['count']), 'content' => $tab['content']); $tab = $this->getSQLQueries(true); $debugTabs['queries'] = array('title' => sprintf('SQL Queries <div class="label label-info">%s</div>', $tab['count']), 'content' => $tab['content']); $tab = $this->getIncludedFiles(true); $debugTabs['included'] = array('title' => sprintf('Included Files <div class="label label-info">%s</div>', $tab['count']), 'content' => $tab['content']); $tab = $this->getTemplateInfo(true); $debugTabs['templateFiles'] = array('title' => sprintf('Template Info'), 'content' => $tab['content']); $tab = $this->getOtherTab(true); $debugTabs['other'] = array('title' => sprintf('Others', $tab['count']), 'content' => $tab['content']); // Allow developers to hook into the debug bar $extraTabs = $objPlugin->hook('CMS_DEBUGBAR_TABS'); if (is_array($extraTabs) && count($extraTabs) > 1) { foreach ($extraTabs as $tab) { $debugTabs = array_merge($debugTabs, $tab); } } $counter = 0; foreach ($debugTabs as $k => $tab) { $tabs .= sprintf('<li class="tab"><a href="javascript:;" data-toggle="tab" data-target="#%1$s">%2$s</a></li>' . "\n", $k, $tab['title']); $content .= sprintf('<div class="tab-pane content fade" id="%1$s">%2$s</div>' . "\n", $k, $tab['content']); } return sprintf('<div id="debug-tabs" data-tabs="true"><ul class="nav nav-tabs">%s</ul><div class="tab-content well">%s</div></div>' . "\n", $tabs, $content); }
**/ require_once cmsROOT . 'core/classes/class.coreobj.php'; // AUTOLOADER, I Choose You! // directories to use for the autoloading, these get glob'd over after // $dirs = Core_Classes_coreObj::addClassDirs(array( // 'classes' => cmsROOT.'core/classes/*.php', // 'libs' => cmsROOT.'core/libs/*/class.*.php', // 'drivers' => cmsROOT.'core/drivers/driver.*.php', // 'admin_panels' => cmsROOT.'modules/*/admin.*.php', // 'modules' => cmsROOT.'modules/*/class.*.php', // 'module_overrides' => cmsROOT.'themes/*/override/*/*.php', // )); spl_autoload_extensions('.php'); spl_autoload_register(array('Core_Classes_coreObj', 'loadClass')); // echo dump($dirs, 'Loading Classes From', 'orange');exit; $objCore = new Core_Classes_coreObj(); $objCore->addConfig($config); // Instance plugins so we can add hooks as early as possible. $objPlugin = Core_Classes_coreObj::getPlugins(); $objPlugin->hook('CMS_PRE_SETUP_COMPLETE'); $objCache = Core_Classes_coreObj::getCache(); $confCache = $objCache->load('config'); $objCore->addConfig($confCache); $objSession = Core_Classes_coreObj::getSession(); $objSession->trackerInit(); $objDebug = Core_Classes_coreObj::getDebug(); $objRoute = Core_Classes_coreObj::getRoute(); $objRoute->modifyGET(); if (is_object($objDebug)) { set_error_handler(array($objDebug, 'errorHandler')); }