/** * 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'))); }
public function __construct() { $guest['user'] = array('id' => 0, 'username' => 'Guest', 'theme' => $this->config('site', 'theme'), 'timezone' => isset($_SESSION['user']) ? doArgs('timezone', $this->config('time', 'timezone'), $_SESSION['user']) : $this->config('time', 'timezone'), 'userkey' => doArgs('userkey', null, $_SESSION['user'])); // Get the Page Object $objPage = Core_Classes_coreObj::getPage(); self::addConfig(array('global' => array('user' => isset($_SESSION['user']['id']) ? $_SESSION['user'] : $guest['user'], 'ip' => Core_Classes_User::getIP(), 'useragent' => doArgs('HTTP_USER_AGENT', null, $_SERVER), 'browser' => getBrowser($_SERVER['HTTP_USER_AGENT']), 'platform' => $objPage->getCSSSelectors($_SERVER['HTTP_USER_AGENT']), 'language' => 'en', 'secure' => isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === true ? true : false, 'referer' => doArgs('HTTP_REFERER', null, $_SERVER), 'realPath' => realpath('') . '/', 'rootPath' => '/' . root(), 'fullPath' => $_SERVER['REQUEST_URI'], 'rootUrl' => (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === true ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . '/' . root(), 'url' => (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === true ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'])), 'user'); $user = $this->config('global', 'user'); $this->setIsOnline(!($user['id'] == 0 ? true : false)); $this->initPerms(); }
/** * 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'))); }
public function login_process() { $objUser = Core_Classes_coreObj::getUser(); $objLogin = Core_Classes_coreObj::getLogin(); $objPage = Core_Classes_coreObj::getPage(); if ($objLogin->process() !== true) { $this->login_form(); return; } $objPage->redirect(doArgs('referer', '/' . root(), $_SESSION['login']), 0); }
/** * Pretty wrapper to print_r() * * @version 3.0 * @since 1.0.0 * @author Dan Aldridge * * @param variable $var * @param string $info * @param string $color Changes the debug header color * @param bool $specialFX * * @return string */ function dump(&$var, $info = false, $color = '', $specialFX = true) { if (file_exists('debug')) { return; } $objPage = Core_Classes_coreObj::getPage(); $scope = false; $prefix = 'unique'; $suffix = 'value'; $return = null; $specialFX = $specialFX !== false ? true : false; if (is_object($objPage)) { if ($specialFX) { /*$objPage->addJSFile(array( 'src' => '/'.root().'assets/javascript/tree.js', 'priority' => LOW, ));*/ } } else { static $run; if (!isset($run) || $run != true) { echo '<link rel="stylesheet" type="text/css" href="/' . root() . 'assets/styles/debug.css" />' . "\n"; } $run = true; } $vals = $scope ? $scope : $GLOBALS; $old = $var; $var = $new = $prefix . rand() . $suffix; $vname = false; foreach ($vals as $key => $val) { if ($val === $new) { $vname = $key; } } $var = $old; $debug = debug_backtrace(); $call_info = array_shift($debug); $code_line = $call_info['line']; $file = explode(stristr(PHP_OS, 'WIN') ? '\\' : '/', $call_info['file']); $file = array_pop($file); $id = substr(md5(microtime()), 0, 6); $return .= sprintf('<div class="debug"><div><div class="header" style="background-color: ' . $color . ';"></div>DEBUG! (<strong>%s : %s</strong>)', $file, $code_line); if ($info != false) { $return .= ' | <strong style="color: red;">' . $info . ':</strong>'; } $return .= '</div><ul id="debug_' . $id . '"' . ($specialFX ? ' data-switch="true"' : '') . '>' . doDump($var, '$' . $vname) . '</ul>'; $return .= '</div>'; return $return; }
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 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); }
//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]); } } }
/** * Displays the header with an error. * * @version 1.0 * @since 0.8.0 */ function hmsgDie($type, $msg) { $objPage = Core_Classes_coreObj::getPage(); // $doSimple = false; // if(HTTP_AJAX || isset($_GET['ajax']) || $objPage->getVar('simpleTpl')){ // $doSimple = true; // } $header = $objPage->getOptions('completed'); if (!$header) { $objPage->showHeader(); } msgDie($type, $msg, '', '', ''); }
/** * Generates a menu from an array * * @version 1.0 * @since 1.0.0 * @author Dan Aldridge * * @return void */ protected function generateNav($links = array()) { $objSQL = Core_Classes_coreObj::getDBO(); $objTPL = Core_Classes_coreObj::getTPL(); $objPage = Core_Classes_coreObj::getPage(); // Loop through the links foreach ($links as $link) { $objTPL->assign_block_vars('menu', array()); // If this navigational piece has subnavigation, deal with it. if (isset($link['subs']) && !empty($link['subs'])) { // Setup our dropdown parent item $objTPL->assign_block_vars('menu.dropdown', array('TITLE' => $link['link_title'])); // Loop through our subnavigational items foreach ($link['subs'] as $subLink) { // If the title and / or url isn't set, ignore it if (!isset($subLink['link_title']) || !isset($subLink['link_url'])) { continue; } $objTPL->assign_block_vars('menu.dropdown.subnav', array('URL' => $subLink['link_url'], 'TITLE' => $subLink['link_title'])); } // Looks like a normal link, sweet. } else { if (isset($link['link_url'])) { $objTPL->assign_block_vars('menu.normal', array('URL' => $link['link_url'], 'TITLE' => $link['link_title'])); } } } }
/** * Panel Constructor * * @version 1.0 * @since 1.0.0 * @author Dan Aldridge * * @return void */ public function __construct() { Core_Classes_coreObj::getPage()->addBreadcrumbs(array(array('url' => '/' . root() . 'admin/core/themes/', 'name' => 'Themes'))); }
/** * Tests to see if we have a body handle in the template system, if so output it * * @version 1.0 * @since 1.0.0 * @author Dan Aldridge */ public function output() { $objTPL = Core_Classes_coreObj::getTPL(); $page = Core_Classes_coreObj::getPage()->getVar('contents'); if (!$objTPL->isHandle('body')) { if ($page === null) { msgDie('FAIL', 'No output received from module.'); } else { echo $page; } } else { if (!is_empty($page)) { echo $page; } echo $objTPL->get_html('body'); } }
/** * Logs the user out * * @version 1.0 * @since 1.0.0 * @author Daniel Noel-Davies * * @param string $check The user code to verify */ public function logout($check) { $objSQL = Core_Classes_coreObj::getDBO(); $objUser = Core_Classes_coreObj::getUser(); $objTime = Core_Classes_coreObj::getTime(); $objPage = Core_Classes_coreObj::getPage(); if (!is_empty($check) && $check == $objUser->grab('usercode')) { $objUser->update($objUser->grab('id'), array('autologin' => '0')); $objSQL->deleteRow('online', array('userkey = "%s"', $_SESSION['user']['userkey'])); unset($_SESSION['user']); if (isset($_COOKIE['login'])) { setCookie('login', '', $objTime->mod_time(time(), 0, 0, 24 * 365 * 10 * 1000 * 1000, 'MINUS')); unset($_COOKIE['login']); } session_destroy(); if (isset($_COOKIE[session_name()])) { setCookie(session_name(), '', time() - 42000); } $objPage->redirect(doArgs('HTTP_REFERER', '/' . root(), $_SERVER), 0); } else { $objPage->redirect('/' . root(), 0); msgDie('FAIL', 'You\'ve Unsuccessfully attempted to logout.<br />Please use the correct procedures.'); } }
/** * 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); }
/** * Editor for the menu system * * @version 1.0 * @since 1.0.0 * @author Dan Aldridge * * @return void */ public function edit($args = array()) { $objTPL = Core_Classes_coreObj::getTPL(); $objSQL = Core_Classes_coreObj::getDBO(); $objPage = Core_Classes_coreObj::getPage(); // Check we have the menu name if (!is_array($args) || !is_string($args[1]) || strlen($args[1]) == 0) { // error trigger_error('Error: Could not get menu name.'); $this->menus(); return; } /** Menu JS **/ $objPage->addCSSFile(array('href' => '/' . root() . 'modules/core/assets/styles/admin/menus/Tree.css', 'type' => 'text/css')); $objPage->addCSSFile(array('href' => '/' . root() . 'modules/core/assets/styles/admin/menus/Collapse.css', 'type' => 'text/css')); $objPage->addJSFile(array('src' => '/' . root() . 'modules/core/assets/javascript/admin/menus/Tree.js'), 'footer'); $objPage->addJSFile(array('src' => '/' . root() . 'modules/core/assets/javascript/admin/menus/custom.js'), 'footer'); $menuName = $args[1]; $objTPL->set_filenames(array('panel' => cmsROOT . 'modules/core/views/admin/menus/menu_link_list.tpl')); $queryList = $objSQL->queryBuilder()->select('*')->from('#__menus')->where('menu_name', '=', $menuName)->orderBy('`parent_id`, `order`', 'ASC'); $links = $objSQL->fetchAll($queryList->build()); if (!is_array($links)) { trigger_error('Error: Menu does not exist.'); $this->menus(); return false; } $args = array('title' => 'link_title', 'id' => 'id', 'parent' => 'parent_id'); $tree = $this->generateTree($links, $args); $objTPL->assign_var('tree_menu', $tree); $objTPL->parse('panel', false); Core_Classes_coreObj::getAdminCP()->setupBlock('body', array('cols' => 3, 'vars' => array('TITLE' => 'Edit Menu - <strong>' . secureMe($menuName) . '</strong>', 'CONTENT' => $objTPL->get_html('panel', false), 'ICON' => 'icon-th-list'), 'custom' => array('ICON' => 'icon-save', 'URL' => '#', 'TITLE' => 'Save', 'LINK' => '', 'CLASS' => '', 'EXTRA' => 'data-toggle="tooltip" data-placement="top"'))); }