/** * 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); }
// 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')); } cmsDEBUG ? memoryUsage('Core: Loaded..') : ''; $objPlugin->hook('CMS_SETUP_COMPLETE');
public function tplGlobals() { $objUser = Core_Classes_coreObj::getUser(); $tplGlobals = array('ROOT' => root(), 'THEME_ROOT' => root() . self::$THEME_ROOT, 'SITE_TITLE' => $this->config('site', 'title'), 'USERNAME' => $objUser->grab('username'), 'U_UCP' => '/' . root() . 'user/', 'L_UCP' => langVar('L_UCP')); if (!Core_Classes_User::$IS_ONLINE) { $tplGlobals += array('U_LOGIN' => '/' . root() . 'login', 'L_LOGIN' => 'Login'); } else { $tplGlobals += array('U_LOGIN' => '/' . root() . 'logout?check=' . $objUser->grab('usercode'), 'L_LOGIN' => 'Logout'); } $moreTPL = Core_Classes_coreObj::getPlugins()->hook('CMS_PAGE_TPL_GLOBALS'); if (is_array($moreTPL) && count($moreTPL) > 1) { foreach ($moreTPL as $vars) { $tplGlobals = array_merge($tplGlobals, $vars); } } Core_Classes_coreObj::getTPL()->assign_vars($tplGlobals); }
/** * Makes sure all information is valid and logs the user in if needed * * @version 2.0 * @since 1.0.0 * @author Dan Aldridge * * @return bool */ public function process() { if (!HTTP_POST) { trigger_error('No POST action detected'); return false; } $objUser = Core_Classes_coreObj::getUser(); $objPlugins = Core_Classes_coreObj::getPlugins(); $objSession = Core_Classes_coreObj::getSession(); if (!$objSession->checkToken('hash')) { $this->addError(1); return false; } // verify username and password are set and not empty $username = doArgs('username', null, $_POST); $password = doArgs('password', null, $_POST); if (is_empty($username) || is_empty($password)) { $this->addError(2); return false; } // make sure the user hasnt already exceeded their login attempt quota if ($this->attemptsCheck(true) === false) { $this->addError(3); return false; } $this->userData = $objUser->get('*', $username); if (!$this->userData) { $this->addError(2); return false; } $this->postData = array('username' => $username, 'password' => $password); //no need to run these if we are in acp mode if ($acpCheck !== true) { if ($this->whiteListCheck() === false) { $this->addError(4); } if ($this->activeCheck() === false) { $this->addError(5); } if ($this->banCheck() === false) { $this->addError(6); } } // update their quota if ($this->attemptsCheck() === false) { $this->addError(3); return false; } // make sure the password is valid if ($objUser->verifyUserCredentials($username, $password) === false) { $this->addError(7); return false; } $uniqueKey = substr(md5($this->userData['id'] . time()), 0, 5); // Add Hooks for Login Data $this->userData['password_plaintext'] = $this->postData['password']; $objPlugins->hook('CMS_LOGIN_SUCCESS', $this->userData); unset($this->userData['password_plaintext']); $objSQL = Core_Classes_coreObj::getDBO(); $objTime = Core_Classes_coreObj::getTime(); $query = $objSQL->queryBuilder()->update('#__sessions')->set(array('uid' => $objUser->grab('id')))->where('admin', '=', Core_Classes_User::$IS_ADMIN ? '1' : '0')->andWhere('sid', '=', md5(session_id()))->andWhere('hostname', '=', Core_Classes_User::getIP())->build(); $results = $objSQL->query($query); $user = $this->userData; $user['last_active'] = time(); $_SESSION['user'] = is_array($_SESSION['user']) && !is_empty($_SESSION['user']) ? array_merge($_SESSION['user'], $user) : $user; //make sure we want em to be able to auto login first if ($this->config('login', 'remember_me', 'false')) { if (doArgs('remember', false, $_POST) === '1') { $objUser->update($this->userData['id'], array('autologin' => '1')); $cookieArray = array('uData' => $uniqueKey, 'uIP' => Core_Classes_User::getIP(), 'uAgent' => md5($_SERVER['HTTP_USER_AGENT'] . $this->config('db', 'ckeauth'))); set_cookie('login', serialize($cookieArray), $objTime->mod_time(time(), 0, 0, 24 * 365 * 10)); $cookieArray['uData'] .= ':' . $this->userData['id']; //add the uid into the db $query = $objSQL->queryBuilder()->insertInto('#__userkeys')->set($cookieArray)->build(); $results = $objSQL->query($query); unset($cookieArray); } } return true; }
/** * * * @version 1.0 * @since 1.0.0 * @author Dan Aldridge & Daniel Noel-Davies * * @param $route array * * @return array */ public function testRoute($url, $pattern, $route) { if ($pattern === false) { trigger_error('$pattern is false, stopping processing.'); return false; } if (is_empty($pattern)) { trigger_error('$pattern is empty, stopping processing.'); return false; } if (is_empty($url)) { trigger_error('$url is empty, stopping processing.'); return false; } if (!is_array($route) || is_empty($route)) { trigger_error('$route is empty, stopping processing.'); return false; } $objPlugin = Core_Classes_coreObj::getPlugins(); // If the route matches the URL, we've got a winner! if (preg_match('#^' . $pattern . '$#', $url, $matches)) { // Remove the URL from the parameters unset($matches[0]); $matches = array_values($matches); $params = array(); // Make sure our key/index array is sorted properly foreach ($matches as $index => $value) { $params[$this->replacements[$index]] = $value; } // make sure we got all our required values foreach ($route['requirements'] as $key => $value) { if (!isset($params[$key])) { trigger_error(sprintf('The Requirement on the route `%s` wasn\'t matched for param `%s`', $route['label'], $key)); return false; } } // replace get params with what we have here & whats in the URL... // we dont want them to see what we are playing with internally tbh $this->modifyGET($params); // add some extras here... $params['_all'] = $params; // Add a hook for the params $pluginExtras = $objPlugin->hook('CMS_ROUTE_PARAMS', $params); if (is_array($pluginExtras) && count($pluginExtras) > 1) { foreach ($pluginExtras as $extra) { $params = array_merge($params, $extra); } } // merge the arguments & the params and then invoke the route $route['arguments'] = array_merge((array) $route['arguments'], $params); $this->route = $route; unset($route, $matches, $params, $replacements, $parts_u, $parts_p, $ourRoute, $replaceWith, $objCache); return true; } return false; }
/** * Makes the content public * * @version 1.0 * @since 1.0.0 * @author Richard Clifford * * @param int $fid The file ID * * @return bool */ public function makePublic($fid) { if (is_empty($fid)) { return false; } $objPlugins = Core_Classes_coreObj::getPlugins(); $objSQL = Core_Classes_coreObj::getDBO(); // Check if the file is already public $check = $objSQL->queryBuilder()->select('public')->from('#__uploads')->where('id', '=', $fid)->build(); $fileCheck = $objSQL->fetchLine($check); $objPlugins->hook('CMS_PUBLICIZE_UPLOAD'); // return true if the file is already public if ($fileCheck['public'] == '1') { return true; } // Update the uploads content to be public $query = $objSQL->queryBuilder()->update('#__uploads')->set(array('public' => 1))->where('id', '=', $fid)->build(); $result = $objSQL->query($query); if ($result) { return true; } return false; }
function loadCaptcha($var) { $objPlugins = Core_Classes_coreObj::getPlugins(); return $objPlugins->hook('CMSForm_Captcha', $var); }
/** * Assign a user Moderator status over a group * * @version 1.0 * @since 1.0.0 * @author Dan Aldridge * * @param int $uid User's ID * @param int $gid Group ID * * @return bool */ function makeModerator($uid, $gid) { if (!is_number($uid)) { trigger_error('$uid is not valid'); return false; } if (!is_number($gid)) { trigger_error('$gid is not valid'); return false; } $group = $this->getGroup($gid); // test to make sure group isnt a single user group if ($group['single_user_group']) { trigger_error('Group is user specific, Cannot reassign Moderator'); return false; } $objSQL = Core_Classes_coreObj::getDBO(); $objUser = Core_Classes_coreObj::getUser(); // make sure old moderator is a subscriber $oldModQuery = $objSQL->queryBuilder()->select('*')->from('#__group_subs')->where(sprintf('gid = "%s" AND uid = "%s"', $gid, $group['moderator']))->limit(1)->build(); $oldModerator = $objSQL->fetchLine($oldModQuery); if (is_empty($oldModerator)) { $this->joinGroup($group['moderator'], $gid, 0); } // make $uid new moderator if ($group['moderator'] != $uid) { unset($update); $update['moderator'] = $uid; $update = $objSQL->queryBuilder()->update('#__group_subs')->set($update)->where(sprintf('id = "%s"', $gid))->build(); $log = 'User Groups: ' . $objUser->profile($uid, RAW) . ' has been made group Moderator of ' . $group['name']; Core_Classes_coreObj::getPlugins()->hook('CMSGroups_changeModerator', array($uid, $gid)); } // make the moderator a subscriber too $this->joinGroup($uid, $gid, 0); return true; }