function cmsplink(&$content) { $regexp = array('/\\[cmsplink([0-9]+)\\]/isU'); // for backward compatibility with WB if (defined('WB_PREPROCESS_PREG')) { $regexp[] = WB_PREPROCESS_PREG; } foreach ($regexp as $preg) { if (preg_match_all($preg, $content, $ids)) { $new_ids = array_unique($ids[1]); foreach ($new_ids as $key => &$page_id) { $link = CAT_Helper_Page::properties($page_id, 'link'); if (!is_null($link)) { $content = str_replace($ids[0][$key], CAT_Helper_Page::getLink($link), $content); } } } } }
if (MANAGE_SECTIONS != 'enabled') { header('Location: ' . CAT_ADMIN_URL); exit(0); } $backend = CAT_Backend::getInstance('Pages', 'pages_modify'); $addons = CAT_Helper_Addons::getInstance(); $val = CAT_Helper_Validate::getInstance(); $page_id = $val->get('_REQUEST', 'page_id', 'numeric'); if (!$page_id) { header("Location: index.php"); exit(0); } if (!CAT_Helper_Page::getPagePermission($page_id, 'admin')) { $backend->print_error('You do not have permissions to modify this page'); } $page_details = CAT_Helper_Page::properties($page_id); if (!count($page_details)) { $backend->print_error('Page not found'); } // ========================== // ! Set module permissions // ========================== $module_permissions = $_SESSION['MODULE_PERMISSIONS']; // ========================= // ! Get delete_section_id // ========================= $delete_section_id = $val->sanitizeGet('delete_section_id', 'numeric'); $update_section_id = $val->sanitizeGet('update_section_id', 'numeric'); $add_module = $val->sanitizePost('add_module', NULL, true); $add_to_block = $val->sanitizePost('add_to_block', 'numeric'); // add section
/** * * @access public * @return **/ public static function uninstallModule($type, $addon_name) { // keep old modules happy global $wb, $admin, $database; switch ($type) { case 'languages': // is default or used by current user if ($addon_name == DEFAULT_LANGUAGE || $addon_name == LANGUAGE) { $temp = array('name' => $addon_name, 'type' => $addon_name == DEFAULT_LANGUAGE ? self::getInstance()->lang()->translate('standard language') : self::getInstance()->lang()->translate('current language')); return self::getInstance()->lang()->translate('Cannot uninstall this language <span class="highlight_text">{{name}}</span> because it is the {{type}}!', $temp); } // used by other users $query_users = self::getInstance()->db()->query("SELECT `user_id` FROM `:prefix:users` WHERE language=:lang LIMIT 1", array('lang' => $addon_name)); if ($query_users->rowCount() > 0) { return self::getInstance()->lang()->translate('Cannot uninstall this language <span class="highlight_text">{{name}}</span> because it is in use!', array('name' => $addon_name)); } break; case 'modules': // check if the module is still in use $info = self::getInstance()->db()->query("SELECT `section_id`, `page_id` FROM `:prefix:sections` WHERE module=:mod", array('mod' => $addon_name)); if ($info->rowCount() > 0) { $temp = explode(";", self::getInstance()->lang()->translate('this page;these pages')); $add = $info->rowCount() == 1 ? $temp[0] : $temp[1]; $values = array('type' => self::getInstance()->lang()->translate('Module'), 'type_name' => $type, 'pages_string' => $add, 'count' => $info->rowCount(), 'name' => $addon_name); $pages = array(); while (false != ($data = $info->fetchRow(MYSQL_ASSOC))) { // skip negative page id's if (substr($data['page_id'], 0, 1) == '-') { continue; } $pages[] = sprintf('<a href="%s">%s</a>', CAT_Helper_Page::getLink($data['page_id']), CAT_Helper_Page::properties($data['page_id'], 'menu_title')); } $values['pages'] = implode('<br />', $pages); return self::getInstance()->lang()->translate('Cannot uninstall module <span class="highlight_text">{{name}}</span> because it is in use on {{pages_string}}:<br /><br />{{pages}}', $values); } // some modules cannot be removed (used by system) if (!self::isRemovable($addon_name)) { return self::getInstance()->lang()->translate('Cannot uninstall module <span class="highlight_text">{{name}}</span> because it is marked as mandatory!', array('name' => $addon_name)); } if (defined('WYSIWYG_EDITOR') && $addon_name == WYSIWYG_EDITOR) { return self::getInstance()->lang()->translate('Cannot uninstall module <span class="highlight_text">{{name}}</span> because it is the standard WYSWIWYG editor!', array('name' => $addon_name)); } break; case 'templates': if ($addon_name == DEFAULT_THEME || $addon_name == DEFAULT_TEMPLATE) { $temp = array('name' => $addon_name, 'type' => $addon_name == DEFAULT_TEMPLATE ? self::getInstance()->lang()->translate('default template') : self::getInstance()->lang()->translate('default backend theme')); return self::getInstance()->lang()->translate('Cannot uninstall template <span class="highlight_text">{{name}}</span> because it is the {{type}}!', $temp); } $info = self::getInstance()->db()->query("SELECT `page_id`, `page_title` FROM `:prefix:pages` WHERE template=:name order by page_title", array('name' => $addon_name)); if ($info->rowCount() > 0) { $msg_template_str = 'Cannot uninstall template <span class="highlight_text">{{name}}</span> because it is still in use on {{pages}}:'; $temp = explode(';', self::getInstance()->lang()->translate('this page;these pages')); $add = $info->rowCount() == 1 ? $temp[0] : $temp[1]; $page_template_str = "<li><a href='../pages/settings.php?page_id={{id}}'>{{title}}</a></li>"; $values = array('pages' => $add, 'name' => $addon_name); $msg = self::getInstance()->lang()->translate($msg_template_str, $values); $page_names = '<ul>'; while ($data = $info->fetchRow()) { $page_info = array('id' => $data['page_id'], 'title' => $data['page_title']); $page_names .= self::getInstance()->lang()->translate($page_template_str, $page_info); } $page_names .= '</ul>'; return $msg . $page_names; } break; default: break; } // end switch // all checks succeeded, try to uninstall if (file_exists(CAT_PATH . '/' . $type . '/' . $addon_name . '/uninstall.php')) { require CAT_PATH . '/' . $type . '/' . $addon_name . '/uninstall.php'; } // Remove entry from DB if ($type != 'languages') { self::getInstance()->db()->query("DELETE FROM `:prefix:addons` WHERE directory=:dir AND type=:type", array('dir' => $addon_name, 'type' => substr($type, 0, -1))); if (self::getInstance()->db()->isError()) { return self::getInstance()->db()->getError(); } $stmt = self::getInstance()->db()->query('SELECT * FROM `:prefix:groups` WHERE group_id <> 1'); if ($stmt->rowCount() > 0) { while ($row = $stmt->fetchRow(MYSQL_ASSOC)) { $gid = $row['group_id']; $file = $addon_name; // get current value $permissions = explode(',', $row[substr($type, 0, -1) . '_permissions']); // remove uninstalled module if (in_array($file, $permissions)) { $i = array_search($file, $permissions); array_splice($permissions, $i, 1); $permissions = array_unique($permissions); asort($permissions); // Update the database $addon_permissions = implode(',', $permissions); self::getInstance()->db()->query(sprintf("UPDATE `:prefix:groups` SET %s_permissions=:perm WHERE group_id=:id", substr($type, 0, -1)), array('perm' => $addon_permissions, 'id' => $gid)); } } } // Try to delete the module dir if (!CAT_Helper_Directory::removeDirectory(CAT_PATH . '/' . $type . '/' . $addon_name)) { return self::getInstance()->lang()->translate('Cannot uninstall - unable to delete the directory!'); } } else { self::getInstance()->db()->query("DELETE FROM `:prefix:addons` WHERE directory=:dir AND type=:type", array('dir' => $addon_name, 'type' => substr($type, 0, -1))); if (self::getInstance()->db()->isError()) { return self::getInstance()->db()->getError(); } unlink(CAT_PATH . '/languages/' . $addon_name . '.php'); } return true; }
exit; } $page_id = $val->sanitizePost('page_id', 'numeric'); // Get page id if (!$page_id) { $ajax = array('message' => $backend->lang()->translate('You sent an invalid value'), 'success' => false); print json_encode($ajax); exit; } if (!CAT_Helper_Page::getPagePermission($page_id, 'admin')) { $ajax = array('message' => $backend->lang()->translate('You do not have the permission to restore this page.'), 'success' => false); print json_encode($ajax); exit; } // Find out more about the page $page = CAT_Helper_Page::properties($page_id); if (!$page) { $ajax = array('message' => $backend->lang()->translate('Page not found'), 'success' => false); print json_encode($ajax); exit; } $visibility = $page['visibility']; if (CAT_Registry::get('PAGE_TRASH') !== 'false') { if ($visibility == 'deleted') { // Function to change all child pages visibility to deleted function restore_subs($parent = 0) { global $backend; // Query pages $query_menu = $backend->db()->query(sprintf("SELECT page_id FROM `%spages` WHERE parent = '%d' ORDER BY position ASC", CAT_TABLE_PREFIX, $parent)); // Check if there are any pages to show
print json_encode($ajax); exit; } $visibility = $page['visibility']; $use_trash = false; // Check if we should delete it or just set the visibility to 'deleted' if (PAGE_TRASH !== false && $visibility != 'deleted') { $ajax_status = 1; // Page trash is enabled and page has not yet been deleted $result = CAT_Helper_Page::deletePage($page_id, true); $use_trash = true; } else { $ajax_status = 0; $result = CAT_Helper_Page::deletePage($page_id); } if (!$result) { $ajax = array('message' => $backend->lang()->translate('An error occured (using trash: {{trash}})', array('trash' => $use_trash ? $backend->lang()->translate('Yes') : $backend->lang()->translate('No'))) . ($backend->db()->isError() ? ' (DB error: ' . $backend->db()->getError() . ')' : ''), 'success' => false); print json_encode($ajax); exit; } else { // delete empty parent dir $directory = CAT_PATH . PAGES_DIRECTORY . CAT_Helper_Page::properties($page_id, 'link'); $directory = pathinfo($directory, PATHINFO_DIRNAME); if (is_dir($directory) && rtrim($directory, '/') != CAT_PATH . PAGES_DIRECTORY && CAT_Helper_Directory::is_empty($directory, true)) { CAT_Helper_Directory::removeDirectory($directory); } $ajax = array('message' => $backend->lang()->translate('Page(s) deleted successfully'), 'status' => $ajax_status, 'success' => true); print json_encode($ajax); exit; } exit;
function get_page_details() { global $page_id; return CAT_Helper_Page::properties($page_id); }
} else { 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);
/** * prints the top of the backend page * * @access public * @return void **/ public static function print_banner() { global $page_id, $parser; $results_array = CAT_Helper_Page::properties($page_id); $user = CAT_Users::get_user_details($results_array['modified_by']); $tpl_data = array(); foreach ($results_array as $key => $value) { $tpl_data[strtoupper($key)] = $value; } $tpl_data['MODIFIED_BY'] = $user['display_name']; $tpl_data['MODIFIED_BY_USERNAME'] = $user['username']; $tpl_data['MODIFIED_WHEN'] = $results_array['modified_when'] != 0 ? $modified_ts = CAT_Helper_DateTime::getDateTime($results_array['modified_when']) : false; $tpl_data['PAGE_HEADER'] = self::getInstance('')->lang()->translate('Modify page'); $tpl_data['CUR_TAB'] = 'modify'; $tpl_data['PAGE_LINK'] = CAT_Helper_Page::getLink($results_array['page_id']); $parser->output('backend_pages_header', $tpl_data); $parser->output('backend_pages_banner', $tpl_data); }
/** * * @access private * @return **/ private static function analyzeLevel($page_id, $max_level = 999) { $level = CAT_Helper_Page::properties($page_id, 'level'); // figure out max depth to show if ($max_level !== 999) { // handle '+X' $max_level value if (preg_match('~^\\+(\\d+)$~', $max_level, $m)) { $max_level = $level + $m[1]; } return $max_level - $level; } return 999; }
function get_page_details($page_id) { return CAT_Helper_Page::properties($page_id); }
// for old modules include CAT_PATH . '/framework/class.admin.php'; $admin = new admin('Pages', 'pages_modify'); // ============= // ! Get perms // ============= if (!CAT_Helper_Page::getPagePermission($page_id, 'admin')) { $backend->print_error('You do not have permissions to modify this page'); } $parser->setGlobals('MOD_URL', CAT_ADMIN_URL . '/pages/modify.php?page_id=' . $page_id); $wysiwyg = $val->get('_GET', 'wysiwyg', 'scalar'); $sectionId = isset($wysiwyg) ? htmlspecialchars($wysiwyg) : NULL; // ==================== // ! Get page details // ==================== $results_array = CAT_Helper_Page::properties($page_id); // ========================================================= // ! Get display name of person who last modified the page // ========================================================= $user = CAT_Users::get_user_details($results_array['modified_by']); global $parser; $tpl_data = array(); // ============================ // ! Include page info script // ============================ $tpl_data['PAGE_ID'] = $results_array['page_id']; $tpl_data['PAGE_TITLE'] = $results_array['page_title']; $tpl_data['MENU_TITLE'] = $results_array['menu_title']; $tpl_data['PAGE_LINK'] = CAT_Helper_Page::getLink($results_array['page_id']); $tpl_data['MODIFIED_BY'] = $user['display_name']; $tpl_data['MODIFIED_BY_USERNAME'] = $user['username'];
// keep SM2 quiet $wb->extra_where_sql = "visibility != 'none' AND visibility != 'hidden' AND visibility != 'deleted'"; // some modules may use $wb->page_id if (isset($page_id)) { $wb->page_id = $page_id; } include CAT_PATH . '/framework/frontend.functions.php'; // ----------------------------------------------------------------------------- // get page to show $page_id = CAT_Helper_Page::selectPage() or die; // this will show the Intro- or Default-Page if no PAGE_ID is available $page = CAT_Page::getInstance($page_id); // ----------------------------------------------------------------------------- // keep SM2 happy $wb->page = CAT_Helper_Page::properties($page_id); $wb->default_link = CAT_Helper_Page::properties($page_id, 'link'); // ----------------------------------------------------------------------------- // ----------------------------------------------------------------------------- // needed at least for droplets $admin =& $wb; // ----------------------------------------------------------------------------- // ----------------------------------------------------------------------------- // clean up log files (older than 24 hours and size 0) $files = CAT_Helper_Directory::findFiles('log_\\d{4}-\\d{2}-\\d{2}\\.txt', CAT_PATH . '/temp'); if (count($files)) { foreach ($files as $f) { if (filemtime($f) < time() - 24 * 60 * 60 && filesize($f) == 0) { unlink($f); } } }
function sm2_recurse(&$rgParent, $aStart, $aStartLevel, $aShowAllLevel, $aMaxLevel, $aFlags, &$aFormatter) { global $wb; // on entry to this function we know that there are entries for this // parent and all entries for that parent are being displayed. We also // need to check if any of the children need to be displayed too. $isListOpen = false; $currentLevel = $wb->page['level'] == '' ? 0 : $wb->page['level']; // get the number of siblings skipping the hidden pages so we can pass // this in and check if the item is first or last $sibCount = 0; foreach ($rgParent[$aStart] as $page) { if (!array_key_exists('sm2_hide', $page)) { $sibCount++; } } $currSib = 0; foreach ($rgParent[$aStart] as $page) { // skip all hidden pages if (array_key_exists('sm2_hide', $page)) { // not set if false, so existence = true continue; } $currSib++; // skip any elements that are lower than the maximum level $pageLevel = $page['level']; if ($pageLevel > $aMaxLevel) { continue; } // this affects ONLY the top level if ($aStart == 0 && $aFlags & SM2_CURRTREE) { if (!array_key_exists('sm2_on_curr_path', $page)) { // not set if false, so existence = true continue; } $sibCount = 1; } // trim the tree as appropriate if ($aFlags & SM2_SIBLING) { // parents, and siblings and children of current only if (!array_key_exists('sm2_on_curr_path', $page) && !array_key_exists('sm2_is_sibling', $page) && !array_key_exists('sm2_child_level', $page)) { // not set if false, so existence = true continue; } } else { if ($aFlags & SM2_TRIM) { // parents and siblings of parents if ($pageLevel > $aShowAllLevel && !array_key_exists('sm2_on_curr_path', $page) && !array_key_exists('sm2_path_sibling', $page)) { // not set if false, so existence = true continue; } } elseif ($aFlags & SM2_CRUMB) { // parents only if (!array_key_exists('sm2_on_curr_path', $page) || array_key_exists('sm2_child_level', $page)) { // not set if false, so existence = true continue; } } } // depth first traverse $nextParent = $page['page_id']; // display the current element if we have reached the start level if ($pageLevel >= $aStartLevel) { //echo INTRO_PAGE; // M.f.i. Aldus - it's not clear why the intro-page got another url at this point. /*if(!INTRO_PAGE && $page['link'] == $wb->default_link) { //echo $nextParent . ' - ' .$page['link'] . ' - ' . $wb->default_link; $url = CAT_URL; } else { $url = CAT_Helper_Page::getLink( CAT_Helper_Page::properties($page['page_id'],'link') ); }*/ $url = CAT_Helper_Page::getLink(CAT_Helper_Page::properties($page['page_id'], 'link')); // we open the list only when we absolutely need to if (!$isListOpen) { $aFormatter->startList($page, $url); $isListOpen = true; } $aFormatter->startItem($page, $url, $currSib, $sibCount); } // display children as appropriate if ($pageLevel + 1 <= $aMaxLevel && array_key_exists('sm2_has_child', $page)) { // not set if false, so existence = true sm2_recurse($rgParent, $nextParent, $aStartLevel, $aShowAllLevel, $aMaxLevel, $aFlags, $aFormatter); } // close the current element if appropriate if ($pageLevel >= $aStartLevel) { $aFormatter->finishItem($pageLevel, $page); } } // close the list if we opened one if ($isListOpen) { $aFormatter->finishList(); } }
$viewing_groups[] = 1; $viewing_groups = implode(',', $options['viewing_groups']); // If needed, get new order if ($options['parent'] != $old_parent) { require CAT_PATH . '/framework/class.order.php'; $order = new order(CAT_TABLE_PREFIX . 'pages', 'position', 'page_id', 'parent'); // Get new order $options['position'] = $order->get_new($options['parent']); // Clean new order $order->clean($options['parent']); } else { $options['position'] = $old_position; } // Work out level and root parent if ($options['parent'] != '0') { $options['level'] = CAT_Helper_Page::properties($options['parent'], 'level') + 1; } $options['root_parent'] = $options['level'] == 1 ? $options['parent'] : CAT_Helper_Page::getRootParent($options['parent']); // changes the values in the options array CAT_Helper_Page::sanitizeLink($options); CAT_Helper_Page::sanitizeTemplate($options); CAT_Helper_Page::sanitizeLanguage($options); // Check if page already exists; checks access file, directory, and database if ($options['link'] !== $old_link) { if (CAT_Helper_Page::exists($options['link'])) { $ajax = array('message' => $backend->lang()->translate('A page with the same or similar link exists'), 'success' => false); print json_encode($ajax); exit; } } // we use reset() to reload the page tree
public static function getURLbyPageID($page_id) { $link = CAT_Helper_Page::properties($page_id, 'link'); return $link ? CAT_URL . PAGES_DIRECTORY . $link . PAGE_EXTENSION : false; }
function get_menu_title($id) { return CAT_Helper_Page::properties($id, 'menu_title'); }
function get_page_link($page_id) { return CAT_Helper_Page::properties($page_id, 'link'); }
// check permissions $backend = CAT_Backend::getInstance('Admintools', 'admintools'); $page_id = CAT_Helper_Validate::get('_REQUEST', 'page_id', 'numeric'); $form = \wblib\wbForms::getInstance(); // configure form $form->set('wblib_url', CAT_URL . '/modules/lib_wblib/wblib'); $form->set('lang_path', CAT_PATH . '/modules/' . pathinfo(dirname(__FILE__), PATHINFO_BASENAME) . '/languages'); $form->loadFile('inc.forms.php', CAT_PATH . '/modules/' . pathinfo(dirname(__FILE__), PATHINFO_BASENAME) . '/inc'); // if we have a page_id, show the settings for this page if ($page_id) { // check permissions if (!CAT_Helper_Page::getPagePermission($page_id, 'admin')) { $backend->print_error('You do not have permissions to modify this page'); } // get page propertiees $tpl_data['page'] = CAT_Helper_Page::properties($page_id); // get the form $form->setForm('seo'); if ($form->isSent() && $form->isValid()) { $data = $form->getData(1, 1); $sql = 'INSERT INTO `:prefix:pages_settings` ( `page_id`, `set_type`, `set_name`, `set_value` ) VALUES ( ?, ?, ?, ?)'; $sql2 = 'DELETE FROM `:prefix:pages_settings` WHERE `page_id`=? AND `set_type`=?'; $sql3 = 'UPDATE `:prefix:pages` SET `%s`=:value WHERE `page_id`=:id'; $default_freq = CAT_Registry::get('SITEMAP_UPDATE_FREQ', NULL, 'weekly'); // delete old settings $database->query($sql2, array($page_id, 'seo')); // insert new settings foreach ($data as $key => $value) { if ($key == 'page_id') { continue; }