include CAT_PATH . '/framework/class.secure.php'; } else { $root = "../"; $level = 1; while ($level < 10 && !file_exists($root . '/framework/class.secure.php')) { $root .= "../"; $level += 1; } if (file_exists($root . '/framework/class.secure.php')) { include $root . '/framework/class.secure.php'; } else { trigger_error(sprintf("[ <b>%s</b> ] Can't include class.secure.php!", $_SERVER['SCRIPT_NAME']), E_USER_ERROR); } } if (!file_exists(CAT_PATH . '/modules/' . SEARCH_LIBRARY . '/library.php')) { $page_id = CAT_Helper_Validate::get('_REQUEST', 'page_id'); CAT_Object::printFatalError(CAT_Object::lang()->translate('No search library installed!'), CAT_Helper_Page::getLink($page_id)); } // Required page details $page_id = -1; $page_description = ''; $page_keywords = ''; // load search library require_once CAT_PATH . '/modules/' . SEARCH_LIBRARY . '/library.php'; $s = new CATSearch(); $page_id = $s->getSearchPageID(); // load droplets extensions $h = CAT_Helper_Droplet::getInstance(); $h->register_droplet_css('SearchBox', $page_id, '/modules/' . SEARCH_LIBRARY . '/templates/default/', 'search.box.css'); $h->register_droplet_js('SearchBox', $page_id, '/modules/' . SEARCH_LIBRARY . '/templates/default/', 'search.box.js'); if (isset($_GET['string'])) {
public function checkIDKEY($fieldname, $default = 0, $request = 'POST') { $val = CAT_Helper_Validate::get('_' . $request, $fieldname); return $val ? $val : $default; }
/** * load headers.inc.php for sections * * @access private * @param string $for - frontend | backend * @return void **/ private static function _load_sections($for = 'frontend') { global $page_id; // make sure we have a page_id if (!$page_id) { $page_id = CAT_Helper_Validate::get('_REQUEST', 'page_id', 'numeric'); } if ($page_id && is_numeric($page_id)) { $sections = self::getSections($page_id); $wysiwyg_seen = false; self::$instance->log()->logDebug('sections:', $sections); if (is_array($sections) && count($sections)) { global $current_section; global $wysiwyg_seen; foreach ($sections as $block_id => $item) { foreach ($item as $section) { $module = $section['module']; $file = CAT_Helper_Directory::sanitizePath(CAT_PATH . '/modules/' . $module . '/headers.inc.php'); // find header definition file if (file_exists($file)) { self::$instance->log()->logDebug(sprintf('loading headers.inc.php for module [%s]', $module)); $current_section = $section['section_id']; self::_load_headers_inc($file, $for, 'modules/' . $module, $current_section); } array_push(CAT_Helper_Page::$css_search_path, '/modules/' . $module, '/modules/' . $module . '/css'); array_push(CAT_Helper_Page::$js_search_path, '/modules/' . $module, '/modules/' . $module . '/js'); } // foreach ($sections as $section) } } // if (count($sections)) // always add WYSIWYG headers, some modules may use show_wysiwyg_editor() later on if (!$wysiwyg_seen) { if (file_exists(CAT_PATH . '/modules/' . WYSIWYG_EDITOR . '/headers.inc.php')) { self::$instance->log()->logDebug('adding headers.inc.php for wysiwyg'); self::_load_headers_inc(CAT_Helper_Directory::sanitizePath(CAT_PATH . '/modules/' . WYSIWYG_EDITOR . '/headers.inc.php'), $for, CAT_PATH . '/modules/' . WYSIWYG_EDITOR); } $wysiwyg_seen = true; } // search if ($for == 'frontend' && CAT_Registry::get('SHOW_SEARCH') === true) { array_push(CAT_Helper_Page::$js_search_path, '/modules/' . CAT_Registry::get('SEARCH_LIBRARY') . '/templates/custom/', '/modules/' . CAT_Registry::get('SEARCH_LIBRARY') . '/templates/default/'); } } }
} else { trigger_error(sprintf("[ <b>%s</b> ] Can't include class.secure.php!", $_SERVER['SCRIPT_NAME']), E_USER_ERROR); } } $backend = CAT_Backend::getInstance('Settings', 'settings', false); $users = CAT_Users::getInstance(); header('Content-type: application/json'); if (!$users->checkPermission('Settings', 'settings')) { $ajax = array('message' => $backend->lang()->translate("Sorry, but you don't have the permissions for this action"), 'success' => false); print json_encode($ajax); exit; } require_once dirname(__FILE__) . '/../../config.php'; require_once dirname(__FILE__) . '/functions.php'; $settings = CAT_Registry::getSettings(); $region = CAT_Helper_Validate::get('_REQUEST', 'template'); $tpl = 'backend_settings_index_' . $region . '.tpl'; $data = getSettingsTable(); $tpl_data = array('values' => $data); $tpl_data['DISPLAY_ADVANCED'] = $users->checkPermission('Settings', 'settings_advanced'); switch ($region) { case 'frontend': $tpl_data['templates'] = getTemplateList('frontend'); $tpl_data['variants'] = array(); $info = CAT_Helper_Addons::checkInfo(CAT_PATH . '/templates/' . CAT_Registry::get('DEFAULT_TEMPLATE')); if (isset($info['module_variants']) && is_array($info['module_variants']) && count($info['module_variants'])) { $tpl_data['variants'] = $info['module_variants']; } break; case 'backend': $tpl_data['backends'] = getTemplateList('backend');
/** * Print the admin header * * @access public * @return void */ public function print_header() { global $parser; $tpl_data = array(); $addons = CAT_Helper_Addons::getInstance(); $user = CAT_Users::getInstance(); // Connect to database and get website title if (!CAT_Registry::exists('WEBSITE_TITLE')) { $title = $this->db()->query("SELECT `value` FROM `:prefix:settings` WHERE `name`='website_title'")->fetchColumn(); CAT_Registry::define('WEBSITE_TITLE', $title, true); } // check current URL for page tree $uri = CAT_Helper_Validate::get('_SERVER', 'SCRIPT_NAME'); // init template search paths self::initPaths(); // ================================= // ! Add permissions to $tpl_data // ================================= $tpl_data['permission']['pages'] = $user->checkPermission('pages', 'pages', false); $tpl_data['permission']['pages_add'] = $user->checkPermission('pages', 'pages_add', false); $tpl_data['permission']['pages_add_l0'] = $user->checkPermission('pages', 'pages_add_l0', false); $tpl_data['permission']['pages_modify'] = $user->checkPermission('pages', 'pages_modify', false); $tpl_data['permission']['pages_delete'] = $user->checkPermission('pages', 'pages_delete', false); $tpl_data['permission']['pages_settings'] = $user->checkPermission('pages', 'pages_settings', false); $tpl_data['permission']['pages_intro'] = $user->checkPermission('pages', 'pages_intro', false) != true || INTRO_PAGE != 'enabled' ? false : true; if ($tpl_data['permission']['pages'] == true) { $tpl_data['DISPLAY_MENU_LIST'] = CAT_Registry::get('MULTIPLE_MENUS') != false ? true : false; $tpl_data['DISPLAY_LANGUAGE_LIST'] = CAT_Registry::get('PAGE_LANGUAGES') != false ? true : false; $tpl_data['DISPLAY_SEARCHING'] = CAT_Registry::get('SEARCH') != false ? true : false; // ========================== // ! Get info for pagesTree // ========================== $pages = CAT_Helper_Page::getPages(true); $sections = CAT_Helper_Page::getSections(); // create LI content for ListBuilder foreach ($pages as $i => $page) { if (isset($sections[$page['page_id']]) && count($sections[$page['page_id']])) { $page['page_title'] .= "\n" . count($sections[$page['page_id']]) . ' ' . $user->lang()->translate('active sections') . ':'; foreach ($sections[$page['page_id']] as $block_id => $section) { foreach ($section as $item) { $page['page_title'] .= "\n" . $item['module'] . ' (ID:' . $item['section_id'] . ')'; } } } $text = $parser->get('backend_pagetree_item', array_merge($page, array('action' => pathinfo($uri, PATHINFO_FILENAME) == 'lang_settings' ? 'lang_settings' : 'modify'))); $pages[$i]['text'] = $text; } // list of first level of pages $tpl_data['pages'] = CAT_Helper_ListBuilder::getInstance()->config(array('__li_level_css' => true, '__li_id_prefix' => 'pageid_', '__li_css_prefix' => 'fc_page_', '__li_has_child_class' => 'fc_expandable', '__is_open_key' => 'be_tree_is_open', '__li_is_open_class' => 'fc_tree_open', '__li_is_closed_class' => 'fc_tree_close', '__title_key' => 'text'))->tree($pages, 0); // number of editable pages (for current user) $tpl_data['pages_editable'] = CAT_Helper_Page::getEditable(); // ========================================== // ! Get info for the form to add new pages // ========================================== $tpl_data['templates'] = $addons->get_addons(CAT_Registry::get('DEFAULT_TEMPLATE'), 'template', 'template'); $tpl_data['languages'] = $addons->get_addons(CAT_Registry::get('DEFAULT_LANGUAGE'), 'language'); $tpl_data['modules'] = $addons->get_addons('wysiwyg', 'module', 'page'); $tpl_data['groups'] = $user->get_groups(); // =========================================== // ! Check and set permissions for templates // =========================================== foreach ($tpl_data['templates'] as $key => $template) { $tpl_data['templates'][$key]['permissions'] = $user->get_permission($template['VALUE'], 'template') ? true : false; } } // ========================= // ! Add Metadatas to Dwoo // ========================= $tpl_data['META']['CHARSET'] = true === defined('DEFAULT_CHARSET') ? DEFAULT_CHARSET : 'utf-8'; $tpl_data['META']['LANGUAGE'] = strtolower(CAT_Registry::get('LANGUAGE')); $tpl_data['META']['WEBSITE_TITLE'] = WEBSITE_TITLE; $tpl_data['CAT_VERSION'] = CAT_Registry::get('CAT_VERSION'); $tpl_data['CAT_CORE'] = CAT_Registry::get('CAT_CORE'); $tpl_data['PAGE_EXTENSION'] = CAT_Registry::get('PAGE_EXTENSION'); $date_search = array('Y', 'j', 'n', 'jS', 'l', 'F'); $date_replace = array('yy', 'y', 'm', 'd', 'DD', 'MM'); $tpl_data['DATE_FORMAT'] = str_replace($date_search, $date_replace, CAT_Registry::get('CAT_DATE_FORMAT')); $time_search = array('H', 'i', 's', 'g'); $time_replace = array('hh', 'mm', 'ss', 'h'); $tpl_data['TIME_FORMAT'] = str_replace($time_search, $time_replace, CAT_Registry::get('TIME_FORMAT')); $tpl_data['SESSION'] = session_name(); $tpl_data['HEAD']['SECTION_NAME'] = $this->lang()->translate(strtoupper(self::$instance->section_name)); $tpl_data['DISPLAY_NAME'] = $user->get_display_name(); $tpl_data['USER'] = $user->get_user_details($user->get_user_id()); // =================================================================== // ! Add arrays for main menu, options menu and the Preferences-Button // =================================================================== $tpl_data['MAIN_MENU'] = array(); $tpl_data['MAIN_MENU'][0] = array('link' => CAT_ADMIN_URL . '/start/index.php', 'title' => $this->lang()->translate('Start'), 'permission_title' => 'start', 'permission' => $user->checkPermission('start', 'start') ? true : false, 'current' => 'start' == strtolower($this->section_name) ? true : false); $tpl_data['MAIN_MENU'][1] = array('link' => CAT_ADMIN_URL . '/media/index.php', 'title' => $this->lang()->translate('Media'), 'permission_title' => 'media', 'permission' => $user->checkPermission('media', 'media') ? true : false, 'current' => 'media' == strtolower($this->section_name) ? true : false); $tpl_data['MAIN_MENU'][2] = array('link' => CAT_ADMIN_URL . '/settings/index.php', 'title' => $this->lang()->translate('Settings'), 'permission_title' => 'settings', 'permission' => $user->checkPermission('settings', 'settings') ? true : false, 'current' => 'settings' == strtolower($this->section_name) ? true : false); $tpl_data['MAIN_MENU'][3] = array('link' => CAT_ADMIN_URL . '/addons/index.php', 'title' => $this->lang()->translate('Addons'), 'permission_title' => 'addons', 'permission' => $user->checkPermission('addons', 'addons') ? true : false, 'current' => 'addons' == strtolower($this->section_name) ? true : false); $tpl_data['MAIN_MENU'][4] = array('link' => CAT_ADMIN_URL . '/admintools/index.php', 'title' => $this->lang()->translate('Admin-Tools'), 'permission_title' => 'admintools', 'permission' => $user->checkPermission('admintools', 'admintools') ? true : false, 'current' => 'admintools' == strtolower($this->section_name) ? true : false); $tpl_data['MAIN_MENU'][5] = array('link' => CAT_ADMIN_URL . '/users/index.php', 'title' => $this->lang()->translate('Access'), 'permission_title' => 'access', 'permission' => $user->checkPermission('access', 'access') ? true : false, 'current' => 'access' == strtolower($this->section_name) ? true : false); // ======================================= // ! Seperate access-link by permissions // ======================================= if ($user->get_permission('users')) { $tpl_data['MAIN_MENU'][5]['link'] = CAT_ADMIN_URL . '/users/index.php'; } elseif ($user->get_permission('groups')) { $tpl_data['MAIN_MENU'][5]['link'] = CAT_ADMIN_URL . '/groups/index.php'; } $tpl_data['PREFERENCES'] = array('link' => CAT_ADMIN_URL . '/preferences/index.php', 'title' => $this->lang()->translate('Preferences'), 'permission_title' => 'preferences', 'permission' => $this->get_link_permission('preferences') ? true : false, 'current' => 'preferences' == strtolower($this->section_name) ? true : false); $tpl_data['section_name'] = strtolower($this->section_name); $tpl_data['page_id'] = CAT_Helper_Validate::sanitizeGet('page_id', 'numeric') && CAT_Helper_Validate::sanitizeGet('page_id') != '' ? CAT_Helper_Validate::sanitizeGet('page_id') : (CAT_Helper_Validate::sanitizePost('page_id', 'numeric') && CAT_Helper_Validate::sanitizePost('page_id') != '' ? CAT_Helper_Validate::sanitizePost('page_id') : false); // ==================== // ! Parse the header // ==================== $parser->output('header', $tpl_data); }