trigger_error(sprintf("[ <b>%s</b> ] Can't include class.secure.php!", $_SERVER['SCRIPT_NAME']), E_USER_ERROR); } } $backend = CAT_Backend::getInstance('Pages', 'pages_add', false); $users = CAT_Users::getInstance(); header('Content-type: application/json'); if (!$users->checkPermission('Pages', 'pages_add')) { $ajax = array('message' => $backend->lang()->translate('You do not have the permission to add a page.'), 'success' => false); print json_encode($ajax); exit; } // note: all pages are listed in the dropdown, even hidden / private AND deleted! $dropdown_list = CAT_Helper_ListBuilder::sort(CAT_Helper_Page::getPages(1), 0); // template / variant $template = CAT_Helper_Page::properties($val->sanitizePost('parent_id', 'numeric'), 'template'); $variant = CAT_Helper_Page::getPageSettings($val->sanitizePost('parent_id', 'numeric'), 'internal', 'template_variant'); $variants = array(); $info = CAT_Helper_Addons::checkInfo(CAT_PATH . '/templates/' . CAT_Helper_Page::getPageTemplate($val->sanitizePost('parent_id', 'numeric'))); if (isset($info['module_variants']) && is_array($info['module_variants']) && count($info['module_variants'])) { $variants = $info['module_variants']; array_unshift($variants, ''); } // ============================================= // ! Add result_array to the template variable // ============================================= $ajax = array('parent_id' => $val->sanitizePost('parent_id', 'numeric'), 'parent_list' => $dropdown_list, 'template' => $template, 'template_variant' => $variant, 'variants' => $variants, 'target' => '_self', 'success' => true); // ==================== // ! Return values // ==================== print json_encode($ajax); exit;
$backend = CAT_Backend::getInstance('Addons', 'modules_install'); $user = CAT_Users::getInstance(); $val = CAT_Helper_Validate::getInstance(); $action = $val->sanitizePost('action'); $module = $val->sanitizePost('file'); $type = $val->sanitizePost('type') . 's'; $js_back = CAT_ADMIN_URL . '/addons/index.php'; if (!in_array($action, array('install', 'upgrade'))) { die(header('Location: ' . CAT_ADMIN_URL . '/' . CAT_BACKEND_PATH . '/addons/index.php')); } if ($module == '' || !(strpos($module, '..') === false)) { die(header('Location: ' . CAT_ADMIN_URL . '/' . CAT_BACKEND_PATH . '/addons/index.php')); } // validate $path = CAT_Helper_Directory::sanitizePath(CAT_PATH . '/' . $type . '/' . $module . ($type == 'languages' ? '.php' : '')); $info = CAT_Helper_Addons::checkInfo($path); if (!is_array($info) || !count($info)) { $backend->print_error($backend->lang()->translate('Unable to {{ action }} {{ type }} {{ module }}!', array('action' => $action, 'type' => substr($type, 0, -1), 'module' => $path)) . ': <tt>"' . htmlentities(basename($path)) . '/' . $action . '.php"</tt> ' . $backend->lang()->translate('does not exist'), $js_back); } if ($type != 'languages') { // this prints an error page if prerequisites are not met $precheck_errors = CAT_Helper_Addons::preCheckAddon(NULL, $path, false); if ($precheck_errors != '' && !is_bool($precheck_errors)) { $backend->print_error($backend->lang()->translate('Invalid installation file. {{error}}', array('error' => $precheck_errors))); return false; } $admin =& $backend; // Run the modules install // upgrade script if there is one if (file_exists($path . '/' . $action . '.php')) { require $path . '/' . $action . '.php'; }
$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'); $tpl_data['wysiwyg'] = CAT_Helper_Addons::get_addons(CAT_Registry::get('WYSIWYG_EDITOR'), 'module', 'wysiwyg'); $tpl_data['variants'] = array(); $info = CAT_Helper_Addons::checkInfo(CAT_PATH . '/templates/' . CAT_Registry::get('DEFAULT_THEME')); if (isset($info['module_variants']) && is_array($info['module_variants']) && count($info['module_variants'])) { $tpl_data['variants'] = $info['module_variants']; } break; case 'system': $tpl_data['er_levels'] = getErrorLevels(); $tpl_data['PAGES_LIST'] = getPagesList('maintenance_page', CAT_Registry::get('MAINTENANCE_PAGE')); $tpl_data['ERR_PAGES_LIST'] = getPagesList('err_page_404', CAT_Registry::get('ERR_PAGE_404')); break; case 'users': $tpl_data['groups'] = $users->get_groups(CAT_Registry::get('FRONTEND_SIGNUP'), '', false); break; case 'datetime': $tpl_data['languages'] = getLanguages(); $tpl_data['timezones'] = getTimezones();
$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); } } $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; } $tpl = CAT_Helper_Validate::get('_REQUEST', 'template'); // get template info $info = CAT_Helper_Addons::checkInfo(CAT_PATH . '/templates/' . $tpl); if (!$info || !count($info)) { $ajax = array('message' => CAT_Helper_Addons::getError(), 'success' => false); print json_encode($ajax); exit; } $ajax = array('message' => NULL, 'variants' => isset($info['module_variants']) ? $info['module_variants'] : array(), 'success' => true); print json_encode($ajax); exit;
// ! Get display name of person who last modified the page // ========================================================= $user = $users->get_user_details($results_array['modified_by']); // ================================= // ! Add permissions to $data_dwoo // ================================= $permission['pages'] = $users->checkPermission('Pages', 'pages') ? true : false; $permission['pages_add'] = $users->checkPermission('Pages', 'pages_add') ? true : false; $permission['pages_add_l0'] = $users->checkPermission('Pages', 'pages_add_l0') ? true : false; $permission['pages_modify'] = $users->checkPermission('Pages', 'pages_modify') ? true : false; $permission['pages_delete'] = $users->checkPermission('Pages', 'pages_delete') ? true : false; $permission['pages_settings'] = $users->checkPermission('Pages', 'pages_settings') ? true : false; $permission['pages_intro'] = $users->checkPermission('Pages', 'pages_intro') != true || INTRO_PAGE != 'enabled' ? false : true; // list of all pages for dropdown, sorted by parent->child $pages = CAT_Helper_ListBuilder::sort(CAT_Helper_Page::getPages(CAT_Backend::isBackend()), 0); // ============================================= // ! Add result_array to the template variable // ============================================= $ajax = array('description' => $results_array['description'], 'keywords' => $results_array['keywords'], 'language' => $results_array['language'], 'level' => $results_array['level'], 'menu' => $results_array['menu'], 'menu_title' => htmlspecialchars_decode($results_array['menu_title'], ENT_QUOTES), 'modified_when' => $results_array['modified_when'] != 0 ? CAT_Helper_DateTime::getDate($results_array['modified_when']) : 'Unknown', 'page_id' => $results_array['page_id'], 'page_title' => htmlspecialchars_decode($results_array['page_title'], ENT_QUOTES), 'parent' => $results_array['parent'], 'searching' => $results_array['searching'] == 0 ? false : true, 'short_link' => substr($results_array['link'], strripos($results_array['link'], '/') + 1), 'target' => $results_array['target'], 'template' => $results_array['template'], 'visibility' => $results_array['visibility'], 'display_name' => $user['display_name'], 'username' => $user['username'], 'DISPLAY_MENU_LIST' => MULTIPLE_MENUS != false ? true : false, 'DISPLAY_LANGUAGE_LIST' => PAGE_LANGUAGES != false ? true : false, 'DISPLAY_SEARCHING' => SEARCH != false ? true : false, 'admin_groups' => explode(',', str_replace('_', '', $results_array['admin_groups'])), 'viewing_groups' => explode(',', str_replace('_', '', $results_array['viewing_groups'])), 'parent_list' => $pages, 'PAGE_EXTENSION' => $backend->db()->query("SELECT `value` FROM `:prefix:settings` WHERE name = 'page_extension'")->fetchColumn()); $ajax['variants'] = array(); $info = CAT_Helper_Addons::checkInfo(CAT_PATH . '/templates/' . CAT_Helper_Page::getPageTemplate($results_array['page_id'])); if (isset($info['module_variants']) && is_array($info['module_variants']) && count($info['module_variants'])) { $ajax['variants'] = $info['module_variants']; array_unshift($ajax['variants'], ''); } $ajax['template_variant'] = CAT_Helper_Page::getPageSettings($results_array['page_id'], 'internal', 'template_variant'); // ==================== // ! Return values // ==================== print json_encode($ajax); exit;
/** * installs all modules, templates, and languages **/ function install_modules($cat_path, $database) { global $admin, $bundled, $mandatory; write2log('> [install_modules()]'); $errors = array(); require $cat_path . '/framework/initialize.php'; // Load addons into DB $dirs = array('modules' => $cat_path . '/modules/', 'templates' => $cat_path . '/templates/', 'languages' => $cat_path . '/languages/'); $ignore_files = array('admin.php', 'index.php', 'edit_module_files.php'); write2log('------------------------------------'); write2log('----- installing addons -----'); write2log('------------------------------------'); foreach ($dirs as $type => $dir) { $subs = $type == 'languages' ? CAT_Helper_Directory::getInstance()->setRecursion(false)->getPHPFiles($dir, $dir . '/') : CAT_Helper_Directory::getInstance()->setRecursion(false)->getDirectories($dir, $dir . '/'); natsort($subs); foreach ($subs as $item) { if (in_array($item, $ignore_files)) { continue; } if ($type == 'languages') { write2log('installing language [' . $item . ']'); $info = CAT_Helper_Addons::checkInfo($dir . '/' . $item); if (!CAT_Helper_Addons::loadModuleIntoDB($dir . '/' . $item, 'install', $info)) { $errors[$dir] = sprintf('Unable to add language [%s] to database!', $item); write2log(sprintf('Unable to add language [%s] to database!', $item)); } else { write2log(sprintf('%s [%s] sucessfully installed', ucfirst(substr($type, 0, -1)), $item)); } } else { write2log('installing module/template [' . $item . ']'); $addon_info = CAT_Helper_Addons::checkInfo($dir . '/' . $item); // load the module info into the database if (!CAT_Helper_Addons::loadModuleIntoDB($dir . '/' . $item, 'install', $addon_info)) { $errors[$dir] = sprintf('Unable to add %s [%s] to database!', $type, $item); write2log(sprintf('Unable to add %s [%s] to database!', $type, $item)); } else { write2log('running ' . $item . '/install.php'); // Run the install script if there is one if (file_exists($dir . '/' . $item . '/install.php')) { require $dir . '/' . $item . '/install.php'; } write2log(sprintf('%s [%s] sucessfully installed', ucfirst(substr($type, 0, -1)), $item)); } } } } // mark bundled modules foreach ($bundled as $module) { $database->query(sprintf('UPDATE `%saddons` SET bundled="Y" WHERE directory="%s"', CAT_TABLE_PREFIX, $module)); } // mark mandatory modules foreach ($mandatory as $module) { $database->query(sprintf('UPDATE `%saddons` SET removable="N" WHERE directory="%s"', CAT_TABLE_PREFIX, $module)); } write2log('< [install_modules()]'); return array(count($errors) ? false : true, $errors); }