/** * Standard modular install function. * * @param ?integer What version we're upgrading from (NULL: new install) * @param ?integer What hack version we're upgrading from (NULL: new-install/not-upgrading-from-a-hacked-version) */ function install($upgrade_from = NULL, $upgrade_from_hack = NULL) { require_code('menus'); require_all_lang(); /* Our idealised choice of installed links is built for minimalism by assuming we also have: zone menu tailored menus in non-site/welcome zones NO panel_top (if there is that's fine, it's just a supplementary source of navigation) footer menu donate/hosting/advertise linked to by banners side_personal_stats/side_search/main_newsletter_signup/main_leaderboard/main_poll/main_iotd/main_news/side_news_categories/side_calendar blocks implicit links to authors/awards/member-actions/onlinemembers (not all links defined here, various modules also install them) */ // root_website add_menu_item_simple('root_website', NULL, 'FRONT_PAGE', ':'); add_menu_item_simple('root_website', NULL, 'RULES', '_SEARCH:rules'); //add_menu_item_simple('root_website',NULL,'FEEDBACK','_SEARCH:feedback'); if (!in_array(get_forum_type(), array('ocf', 'none'))) { add_menu_item_simple('root_website', NULL, 'SECTION_FORUMS', get_forum_base_url(true)); } // main_features add_menu_item_simple('main_features', NULL, 'FRONT_PAGE', 'site:'); add_menu_item_simple('main_features', NULL, 'GUIDE', '_SEARCH:help'); add_menu_item_simple('main_features', NULL, 'RULES', '_SEARCH:rules'); // main_content // main_community if (!in_array(get_forum_type(), array('ocf', 'none'))) { add_menu_item_simple('main_community', NULL, 'SECTION_FORUMS', get_forum_base_url(true)); } if (get_forum_type() == 'ocf') { add_menu_item_simple('main_community', NULL, 'MEMBERS', '_SEARCH:members:type=misc'); } if (get_forum_type() == 'ocf') { add_menu_item_simple('main_community', NULL, 'USERGROUPS', '_SEARCH:groups:type=misc'); } // member_features add_menu_item_simple('member_features', NULL, '_JOIN', '_SEARCH:join:type=misc', 0, 1); add_menu_item_simple('member_features', NULL, 'RESET_PASSWORD', '_SEARCH:lostpassword:type=misc'); // collab_website add_menu_item_simple('collab_website', NULL, 'FRONT_PAGE', 'collaboration:'); add_menu_item_simple('collab_website', NULL, 'ABOUT', 'collaboration:about'); // forum_features add_menu_item_simple('forum_features', NULL, 'RULES', '_SEARCH:rules'); add_menu_item_simple('forum_features', NULL, 'MEMBERS', '_SEARCH:members:type=misc'); // Zones add_menu_item_simple('zone_menu', NULL, 'SITE', 'site' . ':', 0, 1); if (get_forum_type() == 'ocf') { add_menu_item_simple('zone_menu', NULL, 'SECTION_FORUMS', 'forum' . ':', 0, 1); } else { add_menu_item_simple('zone_menu', NULL, 'SECTION_FORUMS', get_forum_base_url(), 0, 1); } if (file_exists(get_file_base() . '/collaboration')) { add_menu_item_simple('zone_menu', NULL, 'COLLABORATION', 'collaboration' . ':', 0, 1); } add_menu_item_simple('zone_menu', NULL, 'CMS', 'cms' . ':', 0, 1); add_menu_item_simple('zone_menu', NULL, 'ADMIN_ZONE', 'adminzone' . ':', 0, 1); //add_menu_item_simple('zone_menu',NULL,'GUIDES','docs'.':userguide',0,1); }
/** * Standard modular run function. * * @return tempcode The result of execution. */ function run() { require_all_lang(); $type = get_param('type', 'misc'); if ($type == 'misc') { return $this->search(); } if ($type == 'list') { return $this->choose_action(); } if ($type == 'view') { return $this->view_action(); } if (addon_installed('securitylogging')) { if ($type == 'toggle_ip_ban') { return $this->toggle_ip_ban(); } if ($type == 'toggle_submitter_ban') { return $this->toggle_submitter_ban(); } if ($type == 'toggle_member_ban') { return $this->toggle_member_ban(); } if ($type == 'multi_ban') { return $this->multi_ban(); } } return new ocp_tempcode(); }
/** * Log permission checks to the permission_checks.log file * * @param MEMBER The user checking against * @param ID_TEXT The function that was called to check a permission * @param array Parameters to this permission-checking function * @param boolean Whether the permission was held */ function _handle_permission_check_logging($member, $op, $params, $result) { global $PERMISSION_CHECK_LOGGER; if ($op == 'has_specific_permission') { require_all_lang(); $params[0] = $params[0] . ' ("' . do_lang('PT_' . $params[0]) . '")'; } $str = $op; if (count($params) != 0) { $str .= ': '; foreach ($params as $i => $p) { if ($i != 0) { $str .= ','; } $str .= is_string($p) ? $p : (is_null($p) ? '' : strval($p)); } } if ($PERMISSION_CHECK_LOGGER !== false && !$result) { fwrite($PERMISSION_CHECK_LOGGER, "\t" . $str); $username = $GLOBALS['FORUM_DRIVER']->get_username($member); if (is_null($username)) { $username = do_lang('UNKNOWN'); } if ($member != get_member()) { fwrite($PERMISSION_CHECK_LOGGER, ' -- ' . $username); } // fwrite($PERMISSION_CHECK_LOGGER,' --> '.($result?do_lang('YES'):do_lang('NO')).chr(10)); fwrite($PERMISSION_CHECK_LOGGER, chr(10)); sync_file(get_custom_file_base() . '/data_custom/permissioncheckslog.php'); } if (function_exists('fb') && get_param_integer('keep_firephp', 0) == 1 && !headers_sent()) { fb('Permission check ' . ($result ? 'PASSED' : 'FAILED') . ': ' . $str); } }
/** * Standard modular run function. * * @param array A map of parameters. * @return tempcode The result of execution. */ function run($map) { unset($map); require_all_lang(); $blocks = new ocp_tempcode(); require_code('zones2'); require_code('zones3'); $_blocks = find_all_blocks(); foreach (array_keys($_blocks) as $block) { $description = do_lang('BLOCK_' . $block . '_DESCRIPTION', NULL, NULL, NULL, NULL, false); if (is_null($description)) { continue; } $use = do_lang('BLOCK_' . $block . '_USE'); $_parameters = get_block_parameters($block); if (!is_array($_parameters)) { continue; } $parameters = new ocp_tempcode(); foreach ($_parameters as $parameter) { $_description = do_lang('BLOCK_' . $block . '_PARAM_' . $parameter, NULL, NULL, NULL, NULL, false); if (is_null($_description)) { continue; } $parameters->attach(do_template('BLOCK_MAIN_BLOCK_HELP_PARAMETER', array('_GUID' => 'f23db88061922a68cc2401256cf69ad3', 'NAME' => $parameter, 'DESCRIPTION' => $_description))); } $blocks->attach(do_template('BLOCK_MAIN_BLOCK_HELP', array('_GUID' => '00652313faa72feac0a07d77e2dddd84', 'NAME' => $block, 'DESCRIPTION' => $description, 'USE' => $use, 'PARAMETERS' => $parameters))); } return $blocks; }
/** * Standard modular run function. * * @return tempcode The result of execution. */ function run() { require_all_lang(); $type = get_param('type', 'misc'); if ($type == 'misc') { return $this->banner_statistics(); } return new ocp_tempcode(); }
/** * Standard modular run function. * * @param array A map of parameters. * @return tempcode The result of execution. */ function run($map) { unset($map); require_all_lang(); require_css('adminzone'); require_code('actionlog'); $start = get_param_integer('sa_start', 0); $max = get_param_integer('sa_max', 10); $sortables = array('date_and_time' => do_lang_tempcode('DATE_TIME'), 'the_type' => do_lang_tempcode('ACTION')); $test = explode(' ', get_param('sa_sort', 'date_and_time DESC'), 2); if (count($test) == 1) { $test[1] = 'DESC'; } list($sortable, $sort_order) = $test; if (strtoupper($sort_order) != 'ASC' && strtoupper($sort_order) != 'DESC' || !array_key_exists($sortable, $sortables)) { log_hack_attack_and_exit('ORDERBY_HACK'); } global $NON_CANONICAL_PARAMS; $NON_CANONICAL_PARAMS[] = 'sa_sort'; require_code('templates_results_table'); $fields_title = results_field_title(array(do_lang_tempcode('USERNAME'), do_lang_tempcode('DATE_TIME'), do_lang_tempcode('ACTION'), do_lang_tempcode('PARAMETER_A'), do_lang_tempcode('PARAMETER_B')), $sortables, 'sa_sort', $sortable . ' ' . $sort_order); $max_rows = $max; //Don't want to encourage pagination (there's a better module they can go to) $GLOBALS['SITE_DB']->query_value('adminlogs','COUNT(*)'); $rows = $GLOBALS['SITE_DB']->query_select('adminlogs', array('the_type', 'param_a', 'param_b', 'the_user', 'ip', 'date_and_time'), NULL, 'ORDER BY ' . $sortable . ' ' . $sort_order, $max, $start); $fields = new ocp_tempcode(); foreach ($rows as $myrow) { $username = $GLOBALS['FORUM_DRIVER']->get_username($myrow['the_user']); if (is_null($username)) { $username = do_lang('UNKNOWN'); } $date = get_timezoned_date($myrow['date_and_time']); if (!is_null($myrow['param_a'])) { $a = $myrow['param_a']; } else { $a = ''; } if (!is_null($myrow['param_b'])) { $b = $myrow['param_b']; } else { $b = ''; } require_code('templates_interfaces'); $_a = tpl_crop_text_mouse_over($a, 8); $_b = tpl_crop_text_mouse_over($b, 15); $type_str = do_lang($myrow['the_type'], $_a, $_b, NULL, NULL, false); if (is_null($type_str)) { $type_str = $myrow['the_type']; } $test = actionlog_linkage($myrow['the_type'], $a, $b, $_a, $_b); if (!is_null($test)) { list($_a, $_b) = $test; } $ip = tpl_crop_text_mouse_over($myrow['ip'], 12); $fields->attach(results_entry(array(escape_html($username), escape_html($date), $type_str, $_a, $_b))); } return results_table(do_lang_tempcode('ACTIONS'), $start, 'sa_start', $max, 'sa_max', $max_rows, $fields_title, $fields, $sortables, $sortable, $sort_order, 'sa_sort', new ocp_tempcode(), NULL, NULL, 5); }
/** * Standard modular run function. * * @return tempcode The result of execution. */ function run() { require_code('templates_donext'); require_code('menus'); require_all_lang(); if ((!has_specific_permission(get_member(), 'avoid_simplified_adminzone_look') || $GLOBALS['FORUM_DRIVER']->is_super_admin(get_member())) && num_staff_icons() < MIN_STAFF_ICONS_BEFORE_COLLAPSE) { return do_next_manager_admin_simplified(); } return do_next_manager_hooked('CMS_ZONE', 'DOC_CMS', 'cms', 'MODULE_TRANS_NAME_cms'); }
/** * Standard modular run function. * * @return tempcode The result of execution. */ function run() { require_lang('security'); require_code('lookup'); require_all_lang(); $GLOBALS['HELPER_PANEL_PIC'] = 'pagepics/securitylog'; $GLOBALS['HELPER_PANEL_TUTORIAL'] = 'tut_security'; $type = get_param('type', 'misc'); if ($type == 'misc') { return $this->security_interface(); } if ($type == 'clean') { return $this->clean_alerts(); } if ($type == 'view') { return $this->alert_view(); } return new ocp_tempcode(); }
/** * Standard function to create the standardised category tree * * @param ID_TEXT Notification code * @param ?ID_TEXT The ID of where we're looking under (NULL: N/A) * @return array Tree structure */ function create_category_tree($notification_code, $id) { $pagelinks = array(); require_all_lang(); $types = $GLOBALS['SITE_DB']->query_select('adminlogs', array('DISTINCT the_type')); if (get_forum_type() == 'ocf') { $types = array_merge($types, $GLOBALS['FORUM_DB']->query_select('f_moderator_logs', array('DISTINCT l_the_type AS the_type'))); } foreach ($types as $type) { $lang = do_lang($type['the_type'], NULL, NULL, NULL, NULL, false); if (is_null($lang)) { continue; } $pagelinks[] = array('id' => $type['the_type'], 'title' => $lang); } global $M_SORT_KEY; $M_SORT_KEY = 'title'; usort($pagelinks, 'multi_sort'); return $pagelinks; }
/** * Standard modular run function for realtime-rain hooks. * * @param TIME Start of time range. * @param TIME End of time range. * @return array A list of template parameter sets for rendering a 'drop'. */ function run($from, $to) { $drops = array(); $rows = $GLOBALS['SITE_DB']->query('SELECT ip,the_type,the_user AS member_id,date_and_time AS timestamp FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'adminlogs WHERE date_and_time BETWEEN ' . strval($from) . ' AND ' . strval($to)); if (has_actual_page_access(get_member(), 'admin_actionlog')) { require_all_lang(); foreach ($rows as $row) { // Events considered elsewhere anyway if ($row['the_type'] == 'ADD_NEWS') { continue; } if ($row['the_type'] == 'CHOOSE_POLL') { continue; } $timestamp = $row['timestamp']; $member_id = $row['member_id']; $drops[] = rain_get_special_icons($row['ip'], $timestamp) + array('TYPE' => 'actionlog', 'FROM_MEMBER_ID' => strval($member_id), 'TO_MEMBER_ID' => NULL, 'TITLE' => do_lang($row['the_type']), 'IMAGE' => is_guest($member_id) ? rain_get_country_image($row['ip']) : $GLOBALS['FORUM_DRIVER']->get_member_avatar_url($member_id), 'TIMESTAMP' => strval($timestamp), 'RELATIVE_TIMESTAMP' => strval($timestamp - $from), 'TICKER_TEXT' => NULL, 'URL' => NULL, 'IS_POSITIVE' => false, 'IS_NEGATIVE' => false, 'FROM_ID' => 'member_' . strval($member_id), 'TO_ID' => NULL, 'GROUP_ID' => NULL); } } return $drops; }
/** * Standard modular run function for OcCLE hooks. * * @param array The options with which the command was called * @param array The parameters with which the command was called * @param array A reference to the OcCLE filesystem object * @return array Array of stdcommand, stdhtml, stdout, and stderr responses */ function run($options, $parameters, &$occle_fs) { if (array_key_exists('h', $options) || array_key_exists('help', $options)) { return array('', do_command_help('find_entry_points', array('h'), array(true)), '', ''); } else { if (!array_key_exists(0, $parameters)) { return array('', '', '', do_lang('MISSING_PARAM', '1', 'find_entry_points')); } // NOTE: this code assumes the search-string is contained within the zone:page portion of the entry point, not any part of the parameterisation $entry_points = array(); $zones = find_all_zones(); require_all_lang(); foreach ($zones as $zone) { $pages = find_all_pages_wrap($zone); foreach ($pages as $page => $type) { if (strpos($zone . ':' . $page, $parameters[0]) !== false) { if ($type == 'modules' || $type == 'modules_custom') { require_code(zone_black_magic_filterer(filter_naughty_harsh($zone) . '/pages/' . filter_naughty_harsh($type) . '/' . filter_naughty_harsh($page) . '.php')); if (class_exists('Mx_' . filter_naughty_harsh($page))) { $object = object_factory('Mx_' . filter_naughty_harsh($page), true); } else { $object = object_factory('Module_' . filter_naughty_harsh($page), true); } if (!is_null($object) && method_exists($object, 'get_entry_points')) { $_entry_points = $object->get_entry_points(); foreach ($_entry_points as $key => $val) { $entry_points[$zone . ':' . $page . ':' . $key] = do_lang($val); } } } else { $entry_points[$zone . ':' . $page] = $page; } } } } return array('', do_template('OCCLE_ENTRY_POINTS', array('_GUID' => 'afaf0b0451ccbdae399dd56e39359c0e', 'ENTRY_POINTS' => $entry_points)), '', ''); } }
/** * Standard modular run function for RSS hooks. * * @param string A list of categories we accept from * @param TIME Cutoff time, before which we do not show results from * @param string Prefix that represents the template set we use * @set RSS_ ATOM_ * @param string The standard format of date to use for the syndication type represented in the prefix * @param integer The maximum number of entries to return, ordering by date * @return ?array A pair: The main syndication section, and a title (NULL: error) */ function run($_filters, $cutoff, $prefix, $date_string, $max) { if (!has_actual_page_access(get_member(), 'admin_actionlog')) { return NULL; } $filters = ocfilter_to_sqlfragment($_filters, 'the_user', 'f_members', NULL, 'the_user', 'id'); $rows = $GLOBALS['SITE_DB']->query('SELECT * FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'adminlogs WHERE date_and_time>' . strval($cutoff) . ' AND ' . $filters . ' ORDER BY date_and_time DESC', $max); require_all_lang(); $content = new ocp_tempcode(); foreach ($rows as $row) { $id = strval($row['id']); $author = $GLOBALS['FORUM_DRIVER']->get_username($row['the_user']); if (is_null($author)) { $author = do_lang('UNKNOWN'); } $author .= ' / ' . $row['ip']; $news_date = date($date_string, $row['date_and_time']); $edit_date = escape_html(''); $type = do_lang($row['the_type'], NULL, NULL, NULL, NULL, false); if (is_null($type)) { $type = $row['the_type']; } $news_title = xmlentities($type); $_summary = $row['param_a'] . ($row['param_b'] == '' ? '' : ' / ') . $row['param_b']; $summary = xmlentities($_summary); $news = escape_html(''); $category = $type; $category_raw = $type; $view_url = build_url(array('page' => 'admin_actionlog', 'type' => 'view', 'mode' => 'ocp', 'id' => $row['id']), 'adminzone'); if ($prefix == 'RSS_') { $if_comments = do_template('RSS_ENTRY_COMMENTS', array('COMMENT_URL' => $view_url, 'ID' => strval($row['id']))); } else { $if_comments = new ocp_tempcode(); } $content->attach(do_template($prefix . 'ENTRY', array('VIEW_URL' => $view_url, 'SUMMARY' => $summary, 'EDIT_DATE' => $edit_date, 'IF_COMMENTS' => $if_comments, 'TITLE' => $news_title, 'CATEGORY_RAW' => $category_raw, 'CATEGORY' => $category, 'AUTHOR' => $author, 'ID' => $id, 'NEWS' => $news, 'DATE' => $news_date))); } return array($content, do_lang('VIEW_ACTION_LOGS')); }
/** * Find the notification object for a particular notification code. * * @param ID_TEXT The notification code to use * @return ?object Notification object (NULL: could not find) */ function _get_notification_ob_for_code($notification_code) { $path = 'hooks/systems/notifications/' . filter_naughty($notification_code); if (!is_file(get_file_base() . '/sources/' . $path . '.php') && !is_file(get_file_base() . '/sources_custom/' . $path . '.php')) { require_all_lang(); $hooks = find_all_hooks('systems', 'notifications'); foreach (array_keys($hooks) as $hook) { $path = 'hooks/systems/notifications/' . filter_naughty($hook); require_code($path); $ob = object_factory('Hook_Notification_' . filter_naughty($hook)); if (method_exists($ob, 'list_handled_codes')) { if (array_key_exists($notification_code, $ob->list_handled_codes())) { return $ob; } } } } else { require_code($path); return object_factory('Hook_Notification_' . filter_naughty($notification_code)); } return NULL; //return object_factory('Hook_Notification'); // default }
$site_name = escape_html(get_site_name()); @ini_set('ocproducts.xss_detect', '0'); echo <<<END <!DOCTYPE NETSCAPE-Bookmark-file-1> <!-- This is an automatically generated file. It will be read and overwritten. DO NOT EDIT! --> <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8"> <TITLE>Bookmarks</TITLE> <H1>Bookmarks Menu</H1> <DL><p> <DT><H3>{$site_name}</H3> <DL><p> END; $comcode_page_rows = $GLOBALS['SITE_DB']->query_select('comcode_pages', array('*')); require_all_lang(); $_zones = array(); $zones = find_all_zones(false, true); // Reorder a bit $zones2 = array(); foreach (array('', 'site') as $zone_match) { foreach ($zones as $i => $zone) { if ($zone[0] == $zone_match) { $zones2[] = $zone; unset($zones[$i]); } } } $zones2 = array_merge($zones2, $zones); require_code('zones2'); foreach ($zones2 as $z) {
/** * Log an action * * @param ID_TEXT The type of activity just carried out (a lang string) * @param ?SHORT_TEXT The most important parameter of the activity (e.g. id) (NULL: none) * @param ?SHORT_TEXT A secondary (perhaps, human readable) parameter of the activity (e.g. caption) (NULL: none) */ function _log_it($type, $a = NULL, $b = NULL) { if (!function_exists('get_member')) { return; } // If this is during installation if (get_option('site_closed') == '1' && get_option('no_stats_when_closed', true) === '1') { return; } // Run hooks, if any exist $hooks = find_all_hooks('systems', 'upon_action_logging'); foreach (array_keys($hooks) as $hook) { require_code('hooks/systems/upon_action_logging/' . filter_naughty($hook)); $ob = object_factory('upon_action_logging' . filter_naughty($hook), true); if (is_null($ob)) { continue; } $ob->run($type, $a, $b); } $ip = get_ip_address(); $GLOBALS['SITE_DB']->query_insert('adminlogs', array('the_type' => $type, 'param_a' => is_null($a) ? '' : substr($a, 0, 80), 'param_b' => is_null($b) ? '' : substr($b, 0, 80), 'date_and_time' => time(), 'the_user' => get_member(), 'ip' => $ip)); decache('side_tag_cloud'); decache('main_staff_actions'); decache('main_staff_checklist'); decache('main_awards'); decache('main_multi_content'); decache('side_stored_menu'); // Due to the content counts in the CMS/Admin Zones if (get_page_name() != 'admin_themewizard' && get_page_name() != 'admin_import') { require_all_lang(); static $logged = 0; $logged++; if ($logged < 10) { require_all_lang(); if (is_null($a)) { $a = do_lang('NA'); } if (is_null($a)) { $a = do_lang('NA'); } require_code('notifications'); $subject = do_lang('ACTIONLOG_NOTIFICATION_MAIL_SUBJECT', get_site_name(), do_lang($type), array($a, $b)); $mail = do_lang('ACTIONLOG_NOTIFICATION_MAIL', comcode_escape(get_site_name()), comcode_escape(do_lang($type)), array(is_null($a) ? '' : comcode_escape($a), is_null($b) ? '' : comcode_escape($b))); if (addon_installed('actionlog')) { dispatch_notification('actionlog', $type, $subject, $mail); } } } }
/** * Standard modular run function. * * @param array A map of parameters. * @return tempcode The result of execution. */ function run($map) { require_all_lang(); require_code('zones2'); $skip_pages = array_key_exists('skip', $map) ? explode(',', $map['skip']) : array(); $comcode_page_rows = $GLOBALS['SITE_DB']->query_select('comcode_pages', array('*')); $_zones = array(); $zones = find_all_zones(false, true); $GLOBALS['MEMORY_OVER_SPEED'] = true; $low_memory = ini_get('memory_limit') != '-1' && ini_get('memory_limit') != '0' && ini_get('memory_limit') != '' && intval(preg_replace('#M$#', '', ini_get('memory_limit'))) < 26 || get_option('has_low_memory_limit') === '1'; // Reorder a bit $zones2 = array(); foreach (array('', 'site') as $zone_match) { foreach ($zones as $i => $zone) { if ($zone[0] == $zone_match) { $zones2[] = $zone; unset($zones[$i]); } } } $zones2 = array_merge($zones2, $zones); foreach ($zones2 as $z) { list($zone, $zone_title, , $zone_default_page) = $z; if (has_zone_access(get_member(), $zone)) { $_pages = array(); $pages = find_all_pages_wrap($zone); if (isset($pages[$zone_default_page])) { $default = $pages[$zone_default_page]; $pages = array($zone_default_page => $default) + $pages; } foreach ($pages as $page => $page_type) { if (is_integer($page)) { $page = strval($page); } if (substr($page, 0, 6) == 'panel_') { continue; } if (substr($page, 0, 1) == '_') { continue; } if (in_array($page, $skip_pages)) { continue; } if (in_array($zone . ':' . $page, $skip_pages)) { continue; } if ($page == '404') { continue; } if (strpos($page, '_tree_made') !== false) { continue; } if ($page == 'sitemap') { continue; } if ($page == 'forums' && substr($page_type, 0, 7) == 'modules' && (get_forum_type() == 'ocf' || get_forum_type() == 'none')) { continue; } if ($page == 'join' && substr($page_type, 0, 7) == 'modules' && !is_guest()) { continue; } if (has_page_access(get_member(), $page, $zone)) { $_entrypoints = array(); $__entrypoints = $low_memory ? array(NULL) : extract_module_functions_page($zone, $page, array('get_entry_points')); if (!is_null($__entrypoints[0])) { $entrypoints = is_array($__entrypoints[0]) ? call_user_func_array($__entrypoints[0][0], $__entrypoints[0][1]) : (strpos($__entrypoints[0], '::') !== false ? NULL : eval($__entrypoints[0])); // The strpos thing is a little hack that allows it to work for base-class derived modules if (is_null($entrypoints)) { $path = zone_black_magic_filterer($zone . ($zone == '' ? '' : '/') . 'pages/' . $page_type . '/' . $page . '.php', true); if ($low_memory && !defined('HIPHOP_PHP') && strpos(file_get_contents(get_file_base() . '/' . $path), ' extends standard_aed_module') !== false) { $new_code = str_replace(',parent::get_entry_points()', '', str_replace('parent::get_entry_points(),', '', $__entrypoints[0])); if (strpos($new_code, 'parent::') !== false) { continue; } $entrypoints = eval($new_code); } else { require_code($path); if (class_exists('Mx_' . filter_naughty_harsh($page))) { $object = object_factory('Mx_' . filter_naughty_harsh($page)); } else { $object = object_factory('Module_' . filter_naughty_harsh($page)); } $entrypoints = $object->get_entry_points(); } } } else { $entrypoints = array('!'); } if (!is_array($entrypoints)) { $entrypoints = array('!'); } if ($entrypoints == array('!')) { $url = build_url(array('page' => $page), $zone, NULL, false, false, true); $title = ucwords(str_replace('_', ' ', $page)); if (substr($page_type, 0, 7) == 'comcode') { foreach ($comcode_page_rows as $page_row) { if ($page_row['p_validated'] == 0 && $page_row['the_page'] == $page && $page_row['the_zone'] == $zone) { continue 2; } } $path = zone_black_magic_filterer((strpos($page_type, '_custom') !== false ? get_custom_file_base() : get_file_base()) . '/' . filter_naughty($zone) . '/pages/' . filter_naughty($page_type) . '/' . $page . '.txt'); if (!is_file($path)) { $path = zone_black_magic_filterer(get_file_base() . '/' . filter_naughty($zone) . '/pages/' . filter_naughty($page_type) . '/' . $page . '.txt'); } $page_contents = file_get_contents($path); $matches = array(); if (preg_match('#\\[title[^\\]]*\\]#', $page_contents, $matches) != 0) { $start = strpos($page_contents, $matches[0]) + strlen($matches[0]); $end = strpos($page_contents, '[/title]', $start); $matches = array(); $title_portion = str_replace('{$SITE_NAME}', get_site_name(), substr($page_contents, $start, $end - $start)); if (preg_match('#\\{\\!([\\w:]+)\\}#', $title_portion, $matches) != 0) { $title_portion = str_replace($matches[0], do_lang($matches[1]), $title_portion); } if (preg_match('#^[^<>\\[\\{\\&]*$#', $title_portion, $matches) != 0) { $title = $matches[0]; } elseif (!$low_memory) { $_title = comcode_to_tempcode($title_portion); $title = strip_tags(@html_entity_decode($_title->evaluate(), ENT_QUOTES, get_charset())); } } } elseif (substr($page_type, 0, 4) == 'html') { $path = zone_black_magic_filterer((strpos($page_type, '_custom') !== false ? get_custom_file_base() : get_file_base()) . '/' . filter_naughty($zone) . '/pages/' . filter_naughty($page_type) . '/' . $page . '.htm'); $page_contents = file_get_contents($path); $matches = array(); if (preg_match('#\\<title[^\\>]*\\>#', $page_contents, $matches) != 0) { $start = strpos($page_contents, $matches[0]) + strlen($matches[0]); $end = strpos($page_contents, '</title>', $start); $title = strip_tags(@html_entity_decode(substr($page_contents, $start, $end - $start), ENT_QUOTES, get_charset())); } } $temp = do_template('BLOCK_MAIN_SITEMAP_NEST', array('_GUID' => '92e657f8b9a3642df053f54e724e66f6', 'URL' => $url, 'NAME' => $title, 'CHILDREN' => array())); $_pages[$title] = $temp->evaluate(); // FUDGEFUDGE } elseif (count($entrypoints) != 0) { foreach ($entrypoints as $entrypoint => $title) { if (($entrypoint == 'concede' || $entrypoint == 'invisible' || $entrypoint == 'logout') && is_guest()) { continue; } if ($entrypoint == '!') { $url = build_url(array('page' => $page), $zone, NULL, false, false, true); } else { $url = build_url(array('page' => $page, 'type' => $entrypoint), $zone, NULL, false, false, true); } $_entrypoints[$title] = do_template('BLOCK_MAIN_SITEMAP_NEST', array('_GUID' => 'ae2ed2549644a8e699e0938b3ab98ddb', 'URL' => $url, 'NAME' => do_lang_tempcode($title), 'CHILDREN' => array())); } //ksort($_entrypoints); $title = do_lang('MODULE_TRANS_NAME_' . $page, NULL, NULL, NULL, NULL, false); if (is_null($title)) { $title = ucwords(str_replace('_', ' ', preg_replace('#^ocf\\_#', '', preg_replace('#^' . str_replace('#', '\\#', preg_quote($zone)) . '_#', '', preg_replace('#^' . str_replace('#', '\\#', preg_quote(str_replace('zone', '', $zone))) . '_#', '', $page))))); } if (count($_entrypoints) == 1) { $temp_keys = array_keys($_entrypoints); $temp = $_entrypoints[$temp_keys[0]]; } else { $temp = do_template('BLOCK_MAIN_SITEMAP_NEST', array('_GUID' => 'dfc5cc7db0301acd938d3b2e3fceaab8', 'URL' => new ocp_tempcode(), 'NAME' => $title, 'CHILDREN' => $_entrypoints)); } $_pages[$title] = $temp->evaluate(); // FUDGEFUDGE } } } $url = new ocp_tempcode(); if ($_pages != array()) { $keys = array_keys($_pages); $first = $_pages[$keys[0]]; ksort($_pages); $_pages = array($keys[0] => $first) + $_pages; } $temp = do_template('BLOCK_MAIN_SITEMAP_NEST', array('_GUID' => '38abb0a0e5bec968b28b4791320dd0dc', 'URL' => $url, 'NAME' => $zone_title, 'CHILDREN' => $_pages)); $_zones[] = $temp->evaluate(); // FUDGEFUDGE } } // To avoid running out of memory $out = do_template('BLOCK_MAIN_SITEMAP', array('_GUID' => 'd0807b30925e47d10cdb2c36231436ab', 'CHILDREN' => $_zones)); $e = $out->evaluate(); $explode = explode('__keep__', $e); // the URLs are build without keep and the templates tack it on the end if (strpos($e, '__keep__') !== false) { $out = new ocp_tempcode(); foreach ($explode as $i => $bit) { if ($i != 0) { $out->attach(symbol_tempcode('KEEP', NULL, array(ENTITY_ESCAPED))); } if ($GLOBALS['XSS_DETECT']) { ocp_mark_as_escaped($bit); } $out->attach($bit); } } $e = $out->evaluate(); if (strpos($e, '__keep1__') !== false) { $explode = explode('__keep1__', $e); $out = new ocp_tempcode(); foreach ($explode as $i => $bit) { if ($i != 0) { $out->attach(symbol_tempcode('KEEP', array('1'), array(ENTITY_ESCAPED))); } if ($GLOBALS['XSS_DETECT']) { ocp_mark_as_escaped($bit); } $out->attach($bit); } } return $out; }
/** * AJAX script for dynamically extended sitetree. */ function site_tree_script() { header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past $root_perms = array('submit_cat_highrange_content' => 0, 'edit_cat_highrange_content' => 0, 'edit_own_cat_highrange_content' => 0, 'delete_cat_highrange_content' => 0, 'delete_own_cat_highrange_content' => 0, 'submit_highrange_content' => 1, 'bypass_validation_highrange_content' => 1, 'edit_own_highrange_content' => 1, 'edit_highrange_content' => 1, 'delete_own_highrange_content' => 1, 'delete_highrange_content' => 1, 'submit_cat_midrange_content' => 0, 'edit_cat_midrange_content' => 0, 'edit_own_cat_midrange_content' => 0, 'delete_cat_midrange_content' => 0, 'delete_own_cat_midrange_content' => 0, 'submit_midrange_content' => 1, 'bypass_validation_midrange_content' => 1, 'edit_own_midrange_content' => 1, 'edit_midrange_content' => 1, 'delete_own_midrange_content' => 1, 'delete_midrange_content' => 1, 'submit_cat_lowrange_content' => 0, 'edit_cat_lowrange_content' => 0, 'edit_own_cat_lowrange_content' => 0, 'delete_cat_lowrange_content' => 0, 'delete_own_cat_lowrange_content' => 0, 'submit_lowrange_content' => 1, 'bypass_validation_lowrange_content' => 1, 'edit_own_lowrange_content' => 1, 'edit_lowrange_content' => 1, 'delete_own_lowrange_content' => 1, 'delete_lowrange_content' => 1); require_code('zones2'); require_code('zones3'); // Usergroups we have $admin_groups = $GLOBALS['FORUM_DRIVER']->get_super_admin_groups(); $groups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(false, true); if (!has_actual_page_access(get_member(), 'admin_site_tree', 'adminzone')) { exit; } if (function_exists('set_time_limit')) { @set_time_limit(30); } disable_php_memory_limit(); // Needed for loading large amount of permissions (potentially) // ====== // Saving // ====== if (get_param_integer('set_perms', 0) == 1) { if (!has_actual_page_access(get_member(), 'admin_permissions', 'adminzone')) { exit; } // Build a map of every page link we are setting permissions for $map = array(); foreach (array_merge($_GET, $_POST) as $i => $page_link) { if (get_magic_quotes_gpc()) { $page_link = stripslashes($page_link); } if (substr($i, 0, 4) == 'map_') { $map[intval(substr($i, 4))] = $page_link; } } // Read it all in foreach ($map as $i => $page_link) { // Decode page link $matches = array(); $type = ''; if ($page_link == '_root') { $type = 'root'; } elseif (preg_match('#^([^:]*):([^:]+):.+$#', $page_link, $matches) != 0) { $type = 'cat'; } elseif (preg_match('#^([^:]*):([^:]+)$#', $page_link, $matches) != 0) { $type = 'page'; } elseif (preg_match('#^([^:]*):?$#', $page_link, $matches) != 0) { $type = 'zone'; } else { $type = 'root'; } // Working out what we're doing with privilege overrides if ($type == 'page' || $type == 'cat') { $zone = $matches[1]; $page = $matches[2]; list($overridables, $sp_page) = get_module_overridables($zone, $page); } if ($type == 'root') { // Insertion foreach ($groups as $group => $group_name) { if (!in_array($group, $admin_groups)) { // SP's foreach (array_keys($root_perms) as $overide) { $val = post_param_integer(strval($i) . 'gsp_' . $overide . '_' . strval($group), -2); if ($val != -2) { $GLOBALS['SITE_DB']->query_delete('gsp', array('specific_permission' => $overide, 'group_id' => $group, 'the_page' => '', 'module_the_name' => '', 'category_name' => '')); if ($val != -1) { $GLOBALS['SITE_DB']->query_insert('gsp', array('specific_permission' => $overide, 'group_id' => $group, 'module_the_name' => '', 'category_name' => '', 'the_page' => '', 'the_value' => $val)); } } } } } } elseif ($type == 'zone') { $zone = $matches[1]; // Insertion foreach ($groups as $group => $group_name) { if (!in_array($group, $admin_groups)) { // View access $view = post_param_integer(strval($i) . 'g_view_' . strval($group), -1); if ($view != -1) { $GLOBALS['SITE_DB']->query_delete('group_zone_access', array('zone_name' => $zone, 'group_id' => $group)); if ($view == 1) { $GLOBALS['SITE_DB']->query_insert('group_zone_access', array('zone_name' => $zone, 'group_id' => $group)); } } } } } elseif ($type == 'page') { // Insertion foreach ($groups as $group => $group_name) { if (!in_array($group, $admin_groups)) { // View access $view = post_param_integer(strval($i) . 'g_view_' . strval($group), -1); if ($view != -1) { $GLOBALS['SITE_DB']->query_delete('group_page_access', array('zone_name' => $zone, 'page_name' => $page, 'group_id' => $group)); if ($view == 0) { // Pages have access by row non-presence, for good reason $GLOBALS['SITE_DB']->query_insert('group_page_access', array('zone_name' => $zone, 'page_name' => $page, 'group_id' => $group)); } } // SP's foreach (array_keys($overridables) as $overide) { $val = post_param_integer(strval($i) . 'gsp_' . $overide . '_' . strval($group), -2); if ($val != -2) { $GLOBALS['SITE_DB']->query_delete('gsp', array('specific_permission' => $overide, 'group_id' => $group, 'the_page' => $sp_page)); if ($val != -1) { $GLOBALS['SITE_DB']->query_insert('gsp', array('specific_permission' => $overide, 'group_id' => $group, 'module_the_name' => '', 'category_name' => '', 'the_page' => $sp_page, 'the_value' => $val)); } } } } } } elseif ($type == 'cat') { $_pagelinks = extract_module_functions_page($zone, $page, array('extract_page_link_permissions'), array($page_link)); list($category, $module) = is_array($_pagelinks[0]) ? call_user_func_array($_pagelinks[0][0], $_pagelinks[0][1]) : eval($_pagelinks[0]); // If $_pagelinks[0] is NULL then it's an error: extract_page_link_permissions is always there when there are cat permissions // Insertion foreach ($groups as $group => $group_name) { if (!in_array($group, $admin_groups)) { // View access $view = post_param_integer(strval($i) . 'g_view_' . strval($group), -1); if ($view != -1) { $GLOBALS['SITE_DB']->query_delete('group_category_access', array('module_the_name' => $module, 'category_name' => $category, 'group_id' => $group)); if ($view == 1) { $GLOBALS['SITE_DB']->query_insert('group_category_access', array('module_the_name' => $module, 'category_name' => $category, 'group_id' => $group)); } } // SP's foreach ($overridables as $overide => $cat_support) { if (is_array($cat_support)) { $cat_support = $cat_support[0]; } if ($cat_support == 0) { continue; } $val = post_param_integer(strval($i) . 'gsp_' . $overide . '_' . strval($group), -2); if ($val != -2) { $GLOBALS['SITE_DB']->query_delete('gsp', array('specific_permission' => $overide, 'group_id' => $group, 'module_the_name' => $module, 'category_name' => $category, 'the_page' => '')); if ($val != -1) { $new_settings = array('specific_permission' => $overide, 'group_id' => $group, 'module_the_name' => $module, 'category_name' => $category, 'the_page' => '', 'the_value' => $val); $GLOBALS['SITE_DB']->query_insert('gsp', $new_settings); } } } } } } } decache('main_sitemap'); $GLOBALS['SITE_DB']->query_delete('cache'); if (function_exists('persistant_cache_empty')) { persistant_cache_empty(); } // Tra la la tada return; } // ======= // Loading // ======= $default = get_param('default', NULL, true); header('Content-Type: text/xml'); $permissions_needed = get_param_integer('get_perms', 0) == 1; // Whether we are limiting our tree to permission-supporting @ini_set('ocproducts.xss_detect', '0'); echo '<' . '?xml version="1.0" encoding="' . get_charset() . '"?' . '>'; echo '<request><result>'; require_lang('permissions'); require_lang('zones'); $page_link = get_param('id', NULL, true); $_sp_access = $GLOBALS['SITE_DB']->query_select('gsp', array('*')); $sp_access = array(); foreach ($_sp_access as $a) { if (!isset($sp_access[$a['group_id']])) { $sp_access[$a['group_id']] = array(); } $sp_access[$a['group_id']][] = $a; } if (!is_null($page_link) && $page_link != '' && (strpos($page_link, ':') === false || strpos($page_link, ':') === strlen($page_link) - 1)) { if (strpos($page_link, ':') === strlen($page_link) - 1) { $page_link = substr($page_link, 0, strlen($page_link) - 1); } // Pages in the zone $zone = $page_link; $page_type = get_param('page_type', NULL); $pages = find_all_pages_wrap($zone, false, true, FIND_ALL_PAGES__NEWEST, $page_type); ksort($pages); if ($permissions_needed) { $zone_access = $GLOBALS['SITE_DB']->query_select('group_zone_access', array('*'), array('zone_name' => $zone)); $page_access = $GLOBALS['SITE_DB']->query_select('group_page_access', array('*'), array('zone_name' => $zone)); } foreach ($pages as $page => $page_type) { if (!is_string($page)) { $page = strval($page); } $full_page_type = $page_type; $description = ''; if (strpos($full_page_type, '/') !== false) { $full_page_type = substr($full_page_type, 0, strpos($full_page_type, '/')); } if (strpos($full_page_type, ':') !== false) { $full_page_type = substr($full_page_type, 0, strpos($full_page_type, ':')); } switch ($full_page_type) { case 'redirect': list(, $redir_zone, $redir_page) = explode(':', $page_type); $page_title = html_entity_decode(strip_tags(str_replace(array('<kbd>', '</kbd>'), array('"', '"'), do_lang('REDIRECT_PAGE_TO', xmlentities($redir_zone), xmlentities($redir_page)))), ENT_QUOTES) . ': ' . (is_string($page) ? $page : strval($page)); break; case 'comcode': case 'comcode_custom': $page_title = do_lang('COMCODE_PAGE') . ': ' . (is_string($page) ? $page : strval($page)); break; case 'html': case 'html_custom': $page_title = 'HTML: ' . $page; break; case 'modules': case 'modules_custom': $page_title = do_lang('MODULE') . ': ' . $page; $matches = array(); if (preg_match('#@package\\s+(\\w+)#', file_get_contents(zone_black_magic_filterer(get_file_base() . '/' . $zone . '/pages/' . $page_type . '/' . $page . '.php')), $matches) != 0) { $package = $matches[1]; $path = get_file_base() . '/sources_custom/hooks/systems/addon_registry/' . $package . '.php'; if (!file_exists($path)) { $path = get_file_base() . '/sources/hooks/systems/addon_registry/' . $package . '.php'; } if (file_exists($path)) { require_lang('zones'); require_code('zones2'); $functions = extract_module_functions($path, array('get_description')); $description = is_array($functions[0]) ? call_user_func_array($functions[0][0], $functions[0][1]) : eval($functions[0]); $description = do_lang('FROM_ADDON', $package, $description); } } break; case 'minimodules': case 'minimodules_custom': $page_title = do_lang('MINIMODULE') . ': ' . $page; break; default: $page_title = do_lang('PAGE') . ': ' . $page; break; } if ($permissions_needed) { $view_perms = ''; foreach ($groups as $group => $group_name) { if (!in_array($group, $admin_groups)) { $view_perms .= 'g_view_' . strval($group) . '="' . (!in_array(array('zone_name' => $zone, 'page_name' => is_string($page) ? $page : strval($page), 'group_id' => $group), $page_access) ? 'true' : 'false') . '" '; } } $pagelinks = NULL; if (substr($page_type, 0, 7) != 'modules') { $overridables = array(); } else { list($overridables, $sp_page) = get_module_overridables($zone, $page); } $sp_perms = ''; foreach ($overridables as $overridable => $cat_support) { $lang_string = do_lang('PT_' . $overridable); if (is_array($cat_support)) { $lang_string = do_lang($cat_support[1]); } if (strlen($lang_string) > 20 && strpos($lang_string, '(') !== false) { $lang_string = preg_replace('# \\([^\\)]*\\)#', '', $lang_string); } $sp_perms .= 'sp_' . $overridable . '="' . xmlentities($lang_string) . '" '; foreach ($groups as $group => $group_name) { if (!in_array($group, $admin_groups)) { $override_value = -1; foreach ($sp_access[$group] as $test) { if ($test['specific_permission'] == $overridable && $test['the_page'] == $sp_page) { $override_value = $test['the_value']; } } if ($override_value != -1) { $sp_perms .= 'gsp_' . $overridable . '_' . strval($group) . '="' . strval($override_value) . '" '; } } } } if (count($overridables) == 0) { $sp_perms = 'no_sps="1" '; } $has_children = $sp_perms != ''; if (count(array_diff(array_keys($overridables), array('submit_highrange_content', 'submit_midrange_content', 'submit_lowrange_content'))) != 0) { $sp_perms .= 'inherits_something="1" '; } $serverid = $zone . ':' . (is_string($page) ? $page : strval($page)); echo '<category ' . ($serverid == $default ? 'selected="yes" ' : '') . 'description="' . xmlentities($description) . '" img_func_1="permissions_img_func_1" img_func_2="permissions_img_func_2" highlighted="true" ' . $view_perms . $sp_perms . ' id="' . uniqid('', true) . '" serverid="' . xmlentities($serverid) . '" title="' . xmlentities($page_title) . '" has_children="' . ($has_children ? 'true' : 'false') . '" selectable="true">'; } else { $extra = ''; if (strpos($page_type, 'modules') === 0) { $info = extract_module_info(zone_black_magic_filterer(get_file_base() . '/' . $zone . ($zone == '' ? '' : '/') . 'pages/' . $page_type . '/' . $page . '.php')); if (!is_null($info) && array_key_exists('author', $info)) { $extra = 'author="' . xmlentities($info['author']) . '" organisation="' . xmlentities($info['organisation']) . '" version="' . xmlentities(integer_format($info['version'])) . '" '; } } $has_children = false; // For a normal tree, we have children if we have entry points. We have children if we have categories also - but where there are categories there are also entry points if (strpos($page_type, 'modules') === 0) { $_entrypoints = extract_module_functions_page($zone, $page, array('get_entry_points')); if (!is_null($_entrypoints[0])) { $entrypoints = is_string($_entrypoints[0]) && strpos($_entrypoints[0], '::') !== false ? array('whatever' => 1) : (is_array($_entrypoints[0]) ? call_user_func_array($_entrypoints[0][0], $_entrypoints[0][1]) : eval($_entrypoints[0])); // The strpos thing is a little hack that allows it to work for base-class derived modules if (!is_array($entrypoints)) { $entrypoints = array('whatever' => 1); } $has_children = array_keys($entrypoints) != array('!'); } } global $MODULES_ZONES; $not_draggable = array_key_exists($page, $MODULES_ZONES) || $zone == 'adminzone' && substr($page, 0, 6) == 'admin_' && substr($page_type, 0, 6) == 'module'; $serverid = $zone . ':' . $page; echo '<category ' . ($serverid == $default ? 'selected="yes" ' : '') . '' . $extra . 'type="' . xmlentities($page_type) . '" description="' . xmlentities($description) . '" draggable="' . ($not_draggable ? 'false' : 'page') . '" droppable="' . ($page_type == 'zone' ? 'page' : 'false') . '" id="' . uniqid('', true) . '" serverid="' . xmlentities($serverid) . '" title="' . xmlentities($page_title) . '" has_children="' . ($has_children ? 'true' : 'false') . '" selectable="true">'; } echo '</category>'; } } elseif (!is_null($page_link) && $page_link != '') { $matches = array(); preg_match('#^([^:]*):([^:]*)#', $page_link, $matches); $zone = $matches[1]; $page = $matches[2]; if ($permissions_needed) { $category_access = $GLOBALS['SITE_DB']->query_select('group_category_access', array('*')); } $_pagelinks = extract_module_functions_page($zone, $page, array('get_page_links'), array(1, true, $page_link)); if (!is_null($_pagelinks[0])) { $pagelinks = is_array($_pagelinks[0]) ? call_user_func_array($_pagelinks[0][0], $_pagelinks[0][1]) : eval($_pagelinks[0]); if (!is_null($pagelinks[0]) && !is_null($pagelinks[1])) { $_overridables = extract_module_functions_page(get_module_zone($pagelinks[1]), $pagelinks[1], array('get_sp_overrides')); if (!is_null($_overridables[0])) { $overridables = is_array($_overridables[0]) ? call_user_func_array($_overridables[0][0], $_overridables[0][1]) : eval($_overridables[0]); } else { $overridables = array(); } } else { $overridables = array(); } } else { $pagelinks = NULL; } $_pagelinks = extract_module_functions_page($zone, $page, array('extract_page_link_permissions'), array($page_link)); list($category, $module) = is_null($_pagelinks[0]) || strlen($matches[0]) == strlen($page_link) ? array('!', '') : (is_array($_pagelinks[0]) ? call_user_func_array($_pagelinks[0][0], $_pagelinks[0][1]) : eval($_pagelinks[0])); // If $_pagelinks[0] is NULL then it's an error: extract_page_link_permissions is always there when there are cat permissions // Entry points under here if (!$permissions_needed && $zone . ':' . $page == $page_link) { $path = zone_black_magic_filterer(filter_naughty($zone) . ($zone == '' ? '' : '/') . 'pages/modules_custom/' . filter_naughty($page) . '.php', true); if (!file_exists(get_file_base() . '/' . $path)) { $path = zone_black_magic_filterer(filter_naughty($zone) . '/pages/modules/' . filter_naughty($page) . '.php', true); } require_code($path); if (class_exists('Mx_' . filter_naughty_harsh($page))) { $object = object_factory('Mx_' . filter_naughty_harsh($page)); } else { $object = object_factory('Module_' . filter_naughty_harsh($page)); } require_all_lang(); $entrypoints = $object->get_entry_points(); foreach ($entrypoints as $entry_point => $lang_string) { $serverid = $zone . ':' . $page; echo '<category ' . ($serverid == $default ? 'selected="yes" ' : '') . 'type="entry_point" id="' . uniqid('', true) . '" serverid="' . xmlentities($serverid) . ':type=' . $entry_point . '" title="' . xmlentities(do_lang('ENTRY_POINT') . ': ' . do_lang($lang_string)) . '" has_children="false" selectable="true">'; echo '</category>'; } } // Categories under here if (!is_null($pagelinks)) { foreach ($pagelinks[0] as $pagelink) { $keys = array_keys($pagelink); if (is_string($keys[0])) { $module_the_name = array_key_exists(3, $pagelinks) ? $pagelinks[3] : NULL; $category_name = is_string($pagelink['id']) ? $pagelink['id'] : strval($pagelink['id']); $actual_page_link = str_replace('!', $category_name, $pagelinks[2]); $title = $pagelink['title']; $has_children = $pagelink['child_count'] != 0; } else { $cms_module_name = NULL; $module_the_name = $pagelink[1]; $category_name = is_null($pagelink[2]) ? '' : (is_string($pagelink[2]) ? $pagelink[2] : strval($pagelink[2])); $actual_page_link = $pagelink[0]; $title = $pagelink[3]; $has_children = array_key_exists(7, $pagelink) ? $pagelink[7] : NULL; } $cms_module_name = $pagelinks[1]; if ($category_name == $category) { continue; } if ($module_the_name == 'catalogues_category' && $category_name == '') { continue; } if (!is_null($cms_module_name)) { $edit_type = '_ec'; if ($module_the_name == 'catalogues_catalogue') { $edit_type = '_ev'; } $actual_edit_link = preg_replace('#^[\\w\\_]+:[\\w\\_]+:type=[\\w\\_]+:(id|catalogue\\_name)=#', get_module_zone($cms_module_name) . ':' . $cms_module_name . ':' . $edit_type . ':', $actual_page_link); } else { $actual_edit_link = ''; } $actual_page_link = str_replace('_SELF:_SELF', $zone . ':' . $page, $actual_page_link); // Support for lazy notation if ($permissions_needed) { $highlight = $module_the_name == 'catalogues_catalogue' ? 'true' : 'false'; $view_perms = ''; $sp_perms = ''; if (!is_null($module_the_name)) { foreach ($groups as $group => $group_name) { if (!in_array($group, $admin_groups)) { $view_perms .= 'g_view_' . strval($group) . '="' . (in_array(array('module_the_name' => $module_the_name, 'category_name' => $category_name, 'group_id' => $group), $category_access) ? 'true' : 'false') . '" '; } } foreach ($overridables as $overridable => $cat_support) { $lang_string = do_lang('PT_' . $overridable); if (is_array($cat_support)) { $lang_string = do_lang($cat_support[1]); } if (strlen($lang_string) > 20 && strpos($lang_string, '(') !== false) { $lang_string = preg_replace('# \\([^\\)]*\\)#', '', $lang_string); } if (is_array($cat_support)) { $cat_support = $cat_support[0]; } if ($cat_support == 0) { continue; } $sp_perms .= 'sp_' . $overridable . '="' . xmlentities($lang_string) . '" '; foreach ($groups as $group => $group_name) { if (!in_array($group, $admin_groups)) { $override_value = -1; foreach ($sp_access[$group] as $test) { if ($test['specific_permission'] == $overridable && $test['the_page'] == '' && $test['category_name'] == $category_name && $test['module_the_name'] == $module_the_name) { $override_value = $test['the_value']; } } if ($override_value != -1) { $sp_perms .= 'gsp_' . $overridable . '_' . strval($group) . '="' . strval($override_value) . '" '; } } } } } if (count(array_diff(array_keys($overridables), array('submit_highrange_content', 'submit_midrange_content', 'submit_lowrange_content'))) != 0) { $sp_perms .= 'inherits_something="1" '; } $serverid = $actual_page_link; echo '<category ' . ($serverid == $default ? 'selected="yes" ' : '') . 'img_func_1="permissions_img_func_1" img_func_2="permissions_img_func_2" highlighted="' . $highlight . '" ' . $view_perms . $sp_perms . ' id="' . uniqid('', true) . '" serverid="' . xmlentities($serverid) . '" title="' . xmlentities($title) . '" has_children="' . ($has_children ? 'true' : 'false') . '" selectable="' . (!is_null($module_the_name) ? 'true' : 'false') . '">'; } else { $serverid = $actual_page_link; echo '<category ' . ($serverid == $default ? 'selected="yes" ' : '') . 'type="category" id="' . uniqid('', true) . '" edit="' . xmlentities($actual_edit_link) . '" serverid="' . xmlentities($serverid) . '" title="' . xmlentities($title) . '" has_children="' . ($has_children ? 'true' : 'false') . '" selectable="true">'; } echo '</category>'; } } } else { // Start of tree if ($permissions_needed) { $view_perms = ''; foreach ($groups as $group => $group_name) { if (!in_array($group, $admin_groups)) { $view_perms .= 'g_view_' . strval($group) . '="true" '; } // This isn't actually displayed in the editor } $sp_perms = ''; $sp_perms_opera_hack = ''; foreach (array_keys($root_perms) as $overridable) { $sp_perms .= 'sp_' . $overridable . '="' . xmlentities(do_lang('PT_' . $overridable)) . '" '; $sp_perms_opera_hack .= '<attribute key="' . 'sp_' . $overridable . '" value="' . xmlentities(do_lang('PT_' . $overridable)) . '" />'; foreach ($groups as $group => $group_name) { if (!in_array($group, $admin_groups)) { $override_value = 0; foreach ($sp_access[$group] as $test) { if ($test['specific_permission'] == $overridable && $test['the_page'] == '' && $test['module_the_name'] == '' && $test['category_name'] == '') { $override_value = $test['the_value']; } } $sp_perms .= 'gsp_' . $overridable . '_' . strval($group) . '="' . strval($override_value) . '" '; $sp_perms_opera_hack .= '<attribute key="' . 'gsp_' . $overridable . '_' . strval($group) . '" value="' . strval($override_value) . '" />'; } } } echo '<category serverid="_root" expanded="true" title="' . do_lang('ROOT') . '" has_children="true" selectable="true" img_func_1="permissions_img_func_1" img_func_2="permissions_img_func_2" id="' . uniqid('', true) . '" ' . $view_perms . '>'; echo $sp_perms_opera_hack; } else { echo '<category serverid="_root" expanded="true" title="' . do_lang('ROOT') . '" has_children="true" selectable="false" type="root" id="' . uniqid('', true) . '">'; } // Zones $zones = $GLOBALS['SITE_DB']->query_select('zones', array('zone_title', 'zone_name', 'zone_default_page'), NULL, 'ORDER BY zone_title', 50); if ($permissions_needed) { $zone_access = $GLOBALS['SITE_DB']->query_select('group_zone_access', array('*')); $page_access = $GLOBALS['SITE_DB']->query_select('group_page_access', array('*')); } $start_links = get_param_integer('start_links', 0) == 1; foreach ($zones as $_zone) { if (get_option('collapse_user_zones') == '1' && $_zone['zone_name'] == 'site') { continue; } $_zone['text_original'] = get_translated_text($_zone['zone_title']); $zone = $_zone['zone_name']; $zone_title = $_zone['text_original']; $serverid = $zone; if ($start_links) { $serverid = $zone . ':'; } $pages = find_all_pages_wrap($zone, false, true, FIND_ALL_PAGES__NEWEST); if ($permissions_needed) { $view_perms = ''; foreach ($groups as $group => $group_name) { if (!in_array($group, $admin_groups)) { $view_perms .= 'g_view_' . strval($group) . '="' . (in_array(array('zone_name' => $zone, 'group_id' => $group), $zone_access) ? 'true' : 'false') . '" '; } } echo '<category ' . ($serverid == $default ? 'selected="yes" ' : '') . 'img_func_1="permissions_img_func_1" img_func_2="permissions_img_func_2" no_sps="1" highlighted="true" ' . $view_perms . ' id="' . uniqid('', true) . '" serverid="' . xmlentities($serverid) . '" title="' . xmlentities(do_lang('ZONE') . ': ' . $zone_title) . '" has_children="' . (count($pages) != 0 ? 'true' : 'false') . '" selectable="true">'; } else { echo '<category ' . ($serverid == $default ? 'selected="yes" ' : '') . 'type="zone" droppable="page" id="' . uniqid('', true) . '" serverid="' . xmlentities($serverid) . '" title="' . xmlentities(do_lang('ZONE') . ': ' . $zone_title) . '" has_children="' . (count($pages) != 0 ? 'true' : 'false') . '" selectable="true">'; } echo '</category>'; } echo '</category>'; } // Mark parent cats for pre-expansion if (!is_null($default) && $default != '' && strpos($default, ':') !== false) { list($zone, $page) = explode(':', $default, 2); echo "\n" . '<expand>' . $zone . '</expand>'; echo "\n" . '<expand>' . $zone . ':</expand>'; echo "\n" . '<expand>' . $zone . ':' . $page . '</expand>'; } echo '</result></request>'; }
/** * The UI to translate content. * * @return tempcode The UI */ function interface_content() { $title = get_page_title('TRANSLATE_CONTENT'); if (!multi_lang()) { warn_exit(do_lang_tempcode('MULTILANG_OFF')); } $max = get_param_integer('max', 100); $lang = choose_language($title); if (is_object($lang)) { return $lang; } // Fiddle around in order to find what we haven't translated. Subqueries and self joins don't work well enough across different db's if (!db_has_subqueries($GLOBALS['SITE_DB']->connection_read)) { $_done_id_list = collapse_2d_complexity('id', 'text_original', $GLOBALS['SITE_DB']->query_select('translate', array('id', 'text_original'), array('language' => $lang, 'broken' => 0))); $done_id_list = ''; foreach (array_keys($_done_id_list) as $done_id) { if ($done_id_list != '') { $done_id_list .= ','; } $done_id_list .= strval($done_id); } $and_clause = $done_id_list == '' ? '' : 'AND id NOT IN (' . $done_id_list . ')'; $query = 'FROM ' . get_table_prefix() . 'translate WHERE ' . db_string_not_equal_to('language', $lang) . ' ' . $and_clause . ' AND ' . db_string_not_equal_to('text_original', '') . ' ORDER BY importance_level'; $to_translate = $GLOBALS['SITE_DB']->query('SELECT * ' . $query, $max); } else { $query = 'FROM ' . get_table_prefix() . 'translate a LEFT JOIN ' . get_table_prefix() . 'translate b ON a.id=b.id AND b.broken=0 AND ' . db_string_equal_to('b.language', $lang) . ' WHERE b.id IS NULL AND ' . db_string_not_equal_to('a.language', $lang) . ' AND ' . db_string_not_equal_to('a.text_original', ''); $to_translate = $GLOBALS['SITE_DB']->query('SELECT a.* ' . $query . (can_arbitrary_groupby() ? ' GROUP BY a.id' : '') . ' ORDER BY a.importance_level', $max); } $total = $GLOBALS['SITE_DB']->query_value_null_ok_full('SELECT COUNT(*) ' . $query); if (count($to_translate) == 0) { inform_exit(do_lang_tempcode('NOTHING_TO_TRANSLATE')); } require_all_lang($lang, true); require_all_open_lang_files($lang); // Make our translation page require_code('lang2'); $lines = ''; $intertrans = $this->get_intertran_conv($lang); $actions = make_string_tempcode(' '); $last_level = NULL; $too_many = count($to_translate) == $max; $ids_to_lookup = array(); foreach ($to_translate as $it) { $ids_to_lookup[] = $it['id']; } $names = find_lang_content_names($ids_to_lookup); foreach ($to_translate as $i => $it) { if ($it['importance_level'] == 0) { continue; } // Corrupt data $id = $it['id']; $old = $it['text_original']; $current = $this->find_lang_matches($old, $lang); $priority = $last_level === $it['importance_level'] ? NULL : do_lang('PRIORITY_' . strval($it['importance_level'])); $name = $names[$id]; if (is_null($name)) { continue; } // Orphaned string if ($intertrans != '') { $actions = do_template('TRANSLATE_ACTION', array('_GUID' => 'f625cf15c9db5e5af30fc772a7f0d5ff', 'LANG_FROM' => $it['language'], 'LANG_TO' => $lang, 'NAME' => 'trans_' . strval($id), 'OLD' => $old)); } $line = do_template('TRANSLATE_LINE_CONTENT', array('_GUID' => '87a0f5298ce9532839f3206cd0e06051', 'NAME' => $name, 'ID' => strval($id), 'OLD' => $old, 'CURRENT' => $current, 'ACTIONS' => $actions, 'PRIORITY' => $priority)); $lines .= $line->evaluate(); /*XHTMLXHTML*/ $last_level = $it['importance_level']; } $url = build_url(array('page' => '_SELF', 'type' => '_content', 'lang' => $lang), '_SELF'); require_code('lang2'); return do_template('TRANSLATE_SCREEN_CONTENT_SCREEN', array('_GUID' => 'af732c5e595816db1c6f025c4b8fa6a2', 'MAX' => integer_format($max), 'TOTAL' => integer_format($total - $max), 'LANG_ORIGINAL_NAME' => get_site_default_lang(), 'LANG_NICE_ORIGINAL_NAME' => lookup_language_full_name(get_site_default_lang()), 'LANG_NICE_NAME' => lookup_language_full_name($lang), 'TOO_MANY' => $too_many, 'INTERTRANS' => $intertrans, 'LANG' => $lang, 'LINES' => $lines, 'TITLE' => $title, 'URL' => $url)); }
/** * Find the number of icons the member of staff has. * * @return integer The count */ function num_staff_icons() { $allowed_icons = 0; require_all_lang(); load_up_all_self_page_permissions(get_member()); $hooks = find_all_hooks('systems', 'do_next_menus'); foreach ($hooks as $hook => $sources_dir) { $run_function = extract_module_functions(get_file_base() . '/' . $sources_dir . '/hooks/systems/do_next_menus/' . $hook . '.php', array('run')); if (!is_null($run_function[0])) { $info = is_array($run_function[0]) ? call_user_func_array($run_function[0][0], $run_function[0][1]) : eval($run_function[0]); foreach ($info as $i) { if (is_null($i)) { continue; } if ($i[0] == '') { continue; } if (has_actual_page_access(get_member(), $i[2][0], $i[2][2])) { $allowed_icons++; } } } } return $allowed_icons; }
/** * Standard modular run function. * * @return tempcode The result of execution. */ function run() { $GLOBALS['HELPER_PANEL_PIC'] = 'pagepics/errorlog'; $GLOBALS['HELPER_PANEL_TUTORIAL'] = 'tut_disaster'; require_lang('errorlog'); $title = get_page_title('ERROR_LOG'); require_code('templates_internalise_screen'); $test_tpl = internalise_own_screen($title); if (is_object($test_tpl)) { return $test_tpl; } // Read in errors if (is_readable(get_custom_file_base() . '/data_custom/errorlog.php')) { if (filesize(get_custom_file_base() . '/data_custom/errorlog.php') > 1024 * 1024) { $myfile = fopen(get_custom_file_base() . '/data_custom/errorlog.php', 'rt'); fseek($myfile, -1024 * 500, SEEK_END); $lines = explode(chr(10), fread($myfile, 1024 * 500)); fclose($myfile); unset($lines[0]); $lines[] = '...'; } else { $lines = file(get_custom_file_base() . '/data_custom/errorlog.php'); } } else { $lines = array(); } $stuff = array(); foreach ($lines as $line) { $_line = trim($line); if ($_line != '' && strpos($_line, '<?php') === false) { $matches = array(); if (preg_match('#\\[(.+?) (.+?)\\] (.+?): ?(.*)#', $_line, $matches) != 0) { $stuff[] = $matches; } } } // Put errors into table $start = get_param_integer('start', 0); $max = get_param_integer('max', 50); $sortables = array('date_and_time' => do_lang_tempcode('DATE_TIME')); $test = explode(' ', get_param('sort', 'date_and_time DESC'), 2); if (count($test) == 1) { $test[1] = 'DESC'; } list($sortable, $sort_order) = $test; if (strtoupper($sort_order) != 'ASC' && strtoupper($sort_order) != 'DESC' || !array_key_exists($sortable, $sortables)) { log_hack_attack_and_exit('ORDERBY_HACK'); } global $NON_CANONICAL_PARAMS; $NON_CANONICAL_PARAMS[] = 'sort'; if ($sort_order == 'DESC') { $stuff = array_reverse($stuff); } require_code('templates_results_table'); $fields_title = results_field_title(array(do_lang_tempcode('DATE_TIME'), do_lang_tempcode('TYPE'), do_lang_tempcode('MESSAGE')), $sortables, 'sort', $sortable . ' ' . $sort_order); $fields = new ocp_tempcode(); for ($i = $start; $i < $start + $max; $i++) { if (!array_key_exists($i, $stuff)) { break; } $message = str_replace(get_file_base(), '', $stuff[$i][4]); $fields->attach(results_entry(array(escape_html($stuff[$i][1] . ' ' . $stuff[$i][2]), escape_html($stuff[$i][3]), escape_html($message)))); } $error = results_table(do_lang_tempcode('ERROR_LOG'), $start, 'start', $max, 'max', $i, $fields_title, $fields, $sortables, $sortable, $sort_order, 'sort', new ocp_tempcode()); // Read in end of permissions file require_all_lang(); if (is_readable(get_custom_file_base() . '/data_custom/permissioncheckslog.php')) { $myfile = @fopen(get_custom_file_base() . '/data_custom/permissioncheckslog.php', 'rt'); if ($myfile !== false) { fseek($myfile, -40000, SEEK_END); $data = ''; while (!feof($myfile)) { $data .= fread($myfile, 8192); } fclose($myfile); $lines = explode(chr(10), $data); if (count($lines) != 0) { if (strpos($lines[0], '<' . '?php') !== false) { array_shift($lines); } else { if (strlen($data) == 40000) { $lines[0] = '...'; } } } foreach ($lines as $i => $line) { $matches = array(); if (preg_match('#^\\s+has\\_specific\\_permission: (\\w+)#', $line, $matches) != 0) { $looked_up = do_lang('PT_' . $matches[1], NULL, NULL, NULL, NULL, false); if (!is_null($looked_up)) { $line = str_replace($matches[1], $looked_up, $line); $lines[$i] = $line; } } } } } // Put permssions into table $permission = implode(chr(10), $lines); return do_template('ERRORLOG_SCREEN', array('_GUID' => '9186c7beb6b722a52f39e2cbe16aded6', 'TITLE' => $title, 'ERROR' => $error, 'PERMISSION' => $permission)); }
/** * AJAX script for allowing username/author/search-terms home-in. */ function namelike_script() { header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past convert_data_encodings(true); $id = str_replace('*', '%', get_param('id', false, true)); $special = get_param('special', ''); if ($special == 'admin_search') { $names = array(); if ($id != '') { require_all_lang(); $hooks = find_all_hooks('systems', 'do_next_menus'); foreach (array_keys($hooks) as $hook) { require_code('hooks/systems/do_next_menus/' . filter_naughty_harsh($hook)); $object = object_factory('Hook_do_next_menus_' . filter_naughty_harsh($hook), true); if (is_null($object)) { continue; } $info = $object->run(true); foreach ($info as $i) { if (is_null($i)) { continue; } $n = $i[3]; $n_eval = is_object($n) ? $n->evaluate() : $n; if ($n_eval == '') { continue; } if (strpos(strtolower($n_eval), strtolower($id)) !== false && has_actual_page_access(get_member(), $i[2][0], $i[2][2])) { $names[] = '"' . $n_eval . '"'; } } } if (count($names) > 10) { $names = array(); } sort($names); } } elseif ($special == 'search') { $names = array(); $q = 'SELECT s_primary,COUNT(*) as cnt,MAX(s_num_results) AS s_num_results FROM ' . get_table_prefix() . 'searches_logged WHERE '; if (db_has_full_text($GLOBALS['SITE_DB']->connection_read) && method_exists($GLOBALS['SITE_DB']->static_ob, 'db_has_full_text_boolean') && $GLOBALS['SITE_DB']->static_ob->db_has_full_text_boolean()) { $q .= preg_replace('#\\?#', 's_primary', db_full_text_assemble($id, false)); } else { $q .= 's_primary LIKE \'' . db_encode_like($id) . '%\''; } $q .= ' AND s_primary NOT LIKE \'%<%\' AND ' . db_string_not_equal_to('s_primary', '') . ' GROUP BY s_primary ORDER BY cnt DESC'; $past_searches = $GLOBALS['SITE_DB']->query($q, 20); foreach ($past_searches as $search) { if ($search['cnt'] > 5) { $names[] = $search['s_primary']; } } } else { if (strlen($id) == 0 && addon_installed('chat')) { $rows = $GLOBALS['SITE_DB']->query_select('chat_buddies', array('member_liked'), array('member_likes' => get_member()), 'ORDER BY date_and_time', 100); $names = array(); foreach ($rows as $row) { $names[] = $GLOBALS['FORUM_DRIVER']->get_username($row['member_liked']); } } else { $names = array(); if (addon_installed('authors')) { if ($special == 'author') { $num_authors = $GLOBALS['SITE_DB']->query_value('authors', 'COUNT(*)'); $like = $num_authors < 1000 ? db_encode_like('%' . $id . '%') : db_encode_like($id . '%'); // performance issue $rows = $GLOBALS['SITE_DB']->query('SELECT author FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'authors WHERE author LIKE \'' . $like . '\' ORDER BY author', 15); $names = collapse_1d_complexity('author', $rows); } } $likea = $GLOBALS['FORUM_DRIVER']->get_matching_members($id . '%', 15); foreach ($likea as $l) { if (count($names) < 15) { $names[] = $GLOBALS['FORUM_DRIVER']->pname_name($l); } } } sort($names); $names = array_unique($names); } @ini_set('ocproducts.xss_detect', '0'); header('Content-Type: text/xml'); echo '<?xml version="1.0" encoding="' . get_charset() . '"?' . '>'; echo '<request><result>'; foreach ($names as $name) { echo '<option value="' . escape_html($name) . '" />'; } echo '</result></request>'; }
/** * The actualiser to set privileges. * * @return tempcode The UI */ function set_specific_permissions() { require_all_lang(); $GLOBALS['HELPER_PANEL_PIC'] = 'pagepics/privileges'; $GLOBALS['HELPER_PANEL_TUTORIAL'] = 'tut_permissions'; if (count($_POST) == 0 && strtolower(ocp_srv('REQUEST_METHOD')) != 'post') { warn_exit(do_lang_tempcode('PERMISSION_TRAGEDY_PREVENTED')); } $title = get_page_title('SPECIFIC_PERMISSIONS'); $p_section = get_param('id'); $_sections = $this->_get_ordered_sections(); $array_keys = array_keys($_sections); $next_section = $array_keys[0]; $counter = 0; foreach ($_sections as $s) { if (is_null($s)) { continue; } if ($counter > array_search($p_section, $array_keys)) { $next_section = $s['p_section']; break; } $counter++; } $groups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(false, true); $permissions = collapse_1d_complexity('the_name', $GLOBALS['SITE_DB']->query_select('sp_list', array('the_name'), array('p_section' => $p_section))); $admin_groups = $GLOBALS['FORUM_DRIVER']->get_super_admin_groups(); foreach ($permissions as $permission) { foreach (array_keys($groups) as $id) { if (in_array($id, $admin_groups)) { continue; } $val = post_param_integer($permission . '__' . strval($id), 0); // Delete to cleanup $GLOBALS['SITE_DB']->query_delete('gsp', array('specific_permission' => $permission, 'group_id' => $id, 'the_page' => '', 'module_the_name' => '', 'category_name' => ''), '', 1); if ($val == 1) { $GLOBALS['SITE_DB']->query_insert('gsp', array('specific_permission' => $permission, 'group_id' => $id, 'the_page' => '', 'module_the_name' => '', 'category_name' => '', 'the_value' => 1)); } } } breadcrumb_set_parents(array(array('_SELF:_SELF:specific', do_lang_tempcode('CHOOSE')))); decache('main_sitemap'); $GLOBALS['SITE_DB']->query_delete('cache'); if (function_exists('persistant_cache_empty')) { persistant_cache_empty(); } // Show it worked / Refresh $url = build_url(array('page' => '_SELF', 'type' => 'specific', 'id' => $next_section), '_SELF'); return redirect_screen($title, $url, do_lang_tempcode('SUCCESS_NOW_NEXT_SCREEN')); }
/** * Actualiser to perform Admin Zone search. * * @return tempcode Interface. */ function search() { require_all_lang(); require_code('zones2'); disable_php_memory_limit(); if (function_exists('set_time_limit')) { @set_time_limit(100); } $n = mixed(); $default_theme = $GLOBALS['FORUM_DRIVER']->get_theme(''); // Mess around to find our search keywords (takes synonyms into account, and generally tidies up) $raw_search_string = get_param('search_content', false, true); // Work out our keywords $keyword_string = $raw_search_string; $_keywords = array(); $current_word = ''; $in_quotes = false; for ($xi = 0; $xi < strlen($keyword_string); $xi++) { if ($in_quotes || trim($keyword_string[$xi]) != '') { if ($keyword_string[$xi] == '"') { $in_quotes = !$in_quotes; } else { $current_word .= $keyword_string[$xi]; } } else { if ($current_word != '') { $_keywords[] = $current_word; } $current_word = ''; } } if ($current_word != '') { $_keywords[] = $current_word; } $_keywords = $this->_strip_junk_words($_keywords); if (count($_keywords) == 0) { return do_template('INDEX_SCREEN_FANCIER_SCREEN', array('TITLE' => get_page_title('ADMIN_ZONE_SEARCH_RESULTS'), 'EMPTY' => true, 'ARRAY' => true, 'CONTENT' => '', 'PRE' => '', 'POST' => '')); } $keywords = array(); $synonym_rows = $this->_synonyms(); // Only in English by default. To do for another language, override this file using inheritance $section_limitations = array(); foreach ($_keywords as $xi => $keyword) { $_keywords = array(); $keyword = trim($keyword); if ($keyword == '') { continue; } if (substr($keyword, 0, 1) == '@') { $section_limitations[] = substr($keyword, 1); continue; } foreach ($synonym_rows as $synonyms) { if (in_array(strtolower($keyword), $synonyms) || array_key_exists($xi + 1, $_keywords) && in_array(strtolower($_keywords[$xi] . ' ' . $_keywords[$xi + 1]), $synonyms)) { $_keywords = array_merge($_keywords, $synonyms); } } $_keywords[] = $keyword; $keywords[] = $_keywords; } // Stemming, if available (needs Stemmer class like http://www.chuggnutt.com/stemmer-source.php which we can't redistribute due to it being GPL not LGPL) if (file_exists(get_file_base() . '/sources_custom/stemmer_' . user_lang() . '.php') && !in_safe_mode()) { require_code('stemmer_' . user_lang()); $stemmer = object_factory('Stemmer_' . user_lang()); foreach ($keywords as $i => $keyword_group) { $_keyword_group = $keyword_group; foreach ($keyword_group as $keyword) { // Special stemmer exceptions if ($keyword == 'news') { continue; } if ($keyword == 'defaultness') { continue; } $_keyword_group[] = $stemmer->stem($keyword); } $keywords[$i] = array_unique($_keyword_group); } } else { foreach ($keywords as $i => $keyword_group) { $_keyword_group = $keyword_group; foreach ($keyword_group as $keyword) { if (strlen($keyword) > 3 && substr($keyword, -1) == 's') { $_keyword_group[] = substr($keyword, 0, strlen($keyword) - 1); } else { $_keyword_group[] = $keyword . 's'; } } $keywords[$i] = array_unique($_keyword_group); } } $this->keywords = $keywords; $content = array(); // Admin/CMS menu icons $current_results_type = do_lang('ADMIN_MODULES'); if ($this->_section_match($section_limitations, $current_results_type)) { $content[$current_results_type] = new ocp_tempcode(); $hooks = find_all_hooks('systems', 'do_next_menus'); foreach (array_keys($hooks) as $hook) { require_code('hooks/systems/do_next_menus/' . filter_naughty_harsh($hook)); $object = object_factory('Hook_do_next_menus_' . filter_naughty_harsh($hook), true); if (is_null($object)) { continue; } $info = $object->run(true); foreach ($info as $i) { if (is_null($i)) { continue; } $n = $i[3]; if ($i[0] != '' && $this->_keyword_match(is_object($n) ? $n->evaluate() : $n) && has_actual_page_access(get_member(), $i[2][0], $i[2][2])) { $_url = build_url(array('page' => $i[2][0]) + $i[2][1], $i[2][2]); $tree = new ocp_tempcode(); $tree->attach(hyperlink(build_url(array('page' => 'admin', 'type' => $i[0]), 'adminzone'), do_lang(strtoupper($i[0])))); $sup = do_lang_tempcode('LOCATED_IN', $tree); $content[$current_results_type]->attach(do_template('INDEX_SCREEN_FANCIER_ENTRY', array('NAME' => $n, 'URL' => $_url, 'TITLE' => '', 'DESCRIPTION' => '', 'SUP' => $sup))); } } } } // Module entry points $current_results_type = do_lang('SCREENS'); if ($this->_section_match($section_limitations, $current_results_type)) { $content[$current_results_type] = new ocp_tempcode(); foreach (find_all_zones(false, true) as $zone => $zone_details) { $modules = find_all_modules($zone); foreach (array_keys($modules) as $page) { $_entrypoints = extract_module_functions_page($zone, $page, array('get_entry_points')); if (!is_null($_entrypoints[0])) { if (is_array($_entrypoints[0]) || strpos($_entrypoints[0], '::') === false) { $entry_points = is_array($_entrypoints[0]) ? call_user_func_array($_entrypoints[0][0], $_entrypoints[0][1]) : eval($_entrypoints[0]); } else { $path = zone_black_magic_filterer(filter_naughty($zone) . ($zone == '' ? '' : '/') . 'pages/modules_custom/' . filter_naughty($page) . '.php', true); if (!file_exists(get_file_base() . '/' . $path)) { $path = zone_black_magic_filterer(filter_naughty($zone) . '/pages/modules/' . filter_naughty($page) . '.php', true); } if (!defined('HIPHOP_PHP') && (ini_get('memory_limit') != '-1' && ini_get('memory_limit') != '0' || get_option('has_low_memory_limit') === '1') && strpos(file_get_contents(get_file_base() . '/' . $path), ' extends standard_aed_module') !== false) { $new_code = str_replace(',parent::get_entry_points()', '', str_replace('parent::get_entry_points(),', '', $_entrypoints[0])); if (strpos($new_code, 'parent::') !== false) { continue; } $entry_points = eval($new_code); } else { require_code($path); if (class_exists('Mx_' . filter_naughty_harsh($page))) { $object = object_factory('Mx_' . filter_naughty_harsh($page)); } else { $object = object_factory('Module_' . filter_naughty_harsh($page)); } $entry_points = $object->get_entry_points(); } } if ($page == 'admin_themes') { $entry_points['!themes'] = 'EDIT_CSS'; $entry_points['!!themes'] = 'EDIT_TEMPLATES'; $entry_points['!!!themes'] = 'MANAGE_THEME_IMAGES'; } if (is_null($entry_points)) { $entry_points = array(); } foreach ($entry_points as $type => $lang) { $type = str_replace('!', '', $type); // The ! was a hackerish thing just to multiply-up possibilities for the single entry-point $n = do_lang_tempcode($lang); if ($this->_keyword_match($n->evaluate()) && has_actual_page_access(get_member(), $page, $zone)) { $tree = new ocp_tempcode(); $tree->attach(hyperlink(build_url(array('page' => ''), $zone), $zone_details[1])); if ($zone == 'cms' || $zone == 'adminzone') { if ($page != 'admin' && $page != 'cms') { $hooks = find_all_hooks('systems', 'do_next_menus'); foreach (array_keys($hooks) as $hook) { require_code('hooks/systems/do_next_menus/' . filter_naughty_harsh($hook)); $object = object_factory('Hook_do_next_menus_' . filter_naughty_harsh($hook), true); if (is_null($object)) { continue; } $info = $object->run(); foreach ($info as $i) { if (is_null($i)) { continue; } if ($page == $i[2][0] && (!array_key_exists('type', $i[2][1]) && $type == 'misc' || array_key_exists('type', $i[2][1]) && $type == $i[2][1]['type']) && $zone == $i[2][2]) { if ($i[0] == 'cms') { $_url = build_url(array('page' => 'cms', 'type' => $i[0]), 'cms'); } else { $_url = build_url(array('page' => 'admin', 'type' => $i[0]), 'adminzone'); } require_lang('menus'); require_lang('security'); $tree->attach(do_template('BREADCRUMB_ESCAPED')); $tree->attach(hyperlink($_url, do_lang_tempcode(strtoupper($i[0])))); if ($type != 'misc') { $tree->attach(do_template('BREADCRUMB_ESCAPED')); $tree->attach(hyperlink(build_url(array('page' => $page, 'type' => 'misc'), $zone), $i[3])); } break 2; } } } } else { $tree->attach(do_template('BREADCRUMB_ESCAPED')); $tree->attach(hyperlink(build_url(array('page' => $page), $zone), $page)); } } $_url = build_url(array('page' => $page, 'type' => $type), $zone); $sup = $tree->is_empty() ? NULL : do_lang_tempcode('LOCATED_IN', $tree); $site_tree_editor_url = build_url(array('page' => 'admin_sitetree', 'type' => 'site_tree', 'id' => $zone . ':' . $page), 'adminzone'); $permission_tree_editor_url = build_url(array('page' => 'admin_permissions', 'id' => $zone . ':' . $page), 'adminzone'); $content[$current_results_type]->attach(do_template('INDEX_SCREEN_FANCIER_ENTRY', array('NAME' => $n, 'URL' => $_url, 'TITLE' => '', 'DESCRIPTION' => do_lang_tempcode('FIND_IN_SITE_TREE_EDITOR', escape_html($site_tree_editor_url->evaluate()), escape_html($permission_tree_editor_url->evaluate())), 'SUP' => $sup))); } } } } } } $current_results_type = do_lang('IMPORT'); if ($this->_section_match($section_limitations, $current_results_type) && has_actual_page_access(get_member(), 'admin_import')) { // Importers $content[$current_results_type] = new ocp_tempcode(); $hooks = find_all_hooks('modules', 'admin_import'); foreach (array_keys($hooks) as $hook) { if ($this->_keyword_match($hook)) { require_code('hooks/modules/admin_import/' . filter_naughty_harsh($hook)); $_hook = object_factory('Hook_' . filter_naughty_harsh($hook)); $info = $_hook->info(); $name = $info['product']; $_url = build_url(array('page' => 'admin_import', 'type' => 'session', 'importer' => $hook), get_module_zone('admin_import')); $content[$current_results_type]->attach(do_template('INDEX_SCREEN_FANCIER_ENTRY', array('NAME' => $name, 'URL' => $_url, 'TITLE' => '', 'DESCRIPTION' => '', 'SUP' => ''))); } } } $current_results_type = do_lang('CONFIGURATION'); if (($this->_section_match($section_limitations, $current_results_type) || $this->_section_match($section_limitations, do_lang('OPTION_CATEGORIES')) || $this->_section_match($section_limitations, do_lang('OPTION_GROUPS'))) && has_actual_page_access(get_member(), 'admin_config')) { // Config options- names, descriptions, groups, categories $content[$current_results_type] = new ocp_tempcode(); $map = array(); if (!is_null($GLOBALS['CURRENT_SHARE_USER'])) { $map['shared_hosting_restricted'] = 0; } $all_options = $GLOBALS['SITE_DB']->query_select('config', array('the_name', 'human_name', 'the_page', 'section', 'explanation', 'eval'), $map); $all_options[] = array('the_name' => 'timezone', 'human_name' => 'TIME_ZONE', 'config_value' => '', 'the_type' => 'special', 'eval' => '', 'the_page' => 'SITE', 'section' => 'GENERAL', 'explanation' => '', 'shared_hosting_restricted' => 0); $config_categories = array(); $conf_found_count = 0; foreach ($all_options as $p) { if (defined('HIPHOP_PHP')) { require_code('hooks/systems/config_default/' . $p['the_name']); $hook = object_factory('Hook_config_default_' . $p['the_name']); $null_test = $hook->get_default(); } else { $GLOBALS['REQUIRE_LANG_LOOP'] = 10; // LEGACY Workaround for corrupt webhost installers $null_test = eval($p['eval']); $GLOBALS['REQUIRE_LANG_LOOP'] = 0; // LEGACY } if (!is_null($null_test)) { $n = do_lang_tempcode($p['human_name']); switch ($p['the_name']) { case 'timezone': $t = do_lang('DESCRIPTION_TIMEZONE_SITE'); break; default: $t = do_lang($p['explanation'], NULL, NULL, NULL, NULL, false); break; } if (is_null($n)) { continue; } $config_value = array_key_exists('config_value', $p) ? $p['config_value'] : get_option($p['the_name']); if ($config_value === false) { continue; } if ($this->_keyword_match($p['the_name']) || $this->_keyword_match($n->evaluate()) || $this->_keyword_match($t) || $this->_keyword_match($config_value)) { $_url = build_url(array('page' => 'admin_config', 'type' => 'category', 'id' => $p['the_page']), 'adminzone'); $url = $_url->evaluate(); $url .= '#group_' . $p['section']; if (is_null($t)) { $t = ''; } $tree = new ocp_tempcode(); $tree->attach(hyperlink(build_url(array('page' => 'admin', 'type' => 'setup'), 'adminzone'), do_lang_tempcode('SETUP'))); $tree->attach(do_template('BREADCRUMB_ESCAPED')); $tree->attach(hyperlink(build_url(array('page' => 'admin_config', 'type' => 'misc'), 'adminzone'), do_lang_tempcode('CONFIGURATION'))); $tree->attach(do_template('BREADCRUMB_ESCAPED')); $tree->attach(hyperlink(build_url(array('page' => 'admin_config', 'type' => 'category', 'id' => $p['the_page']), 'adminzone'), do_lang('CONFIG_CATEGORY_' . $p['the_page']))); $tree->attach(do_template('BREADCRUMB_ESCAPED')); $tree->attach(hyperlink($url, do_lang($p['section']))); $sup = do_lang_tempcode('LOCATED_IN', $tree); $content[$current_results_type]->attach(do_template('INDEX_SCREEN_FANCIER_ENTRY', array('NAME' => $n, 'URL' => $url, 'TITLE' => '', 'DESCRIPTION' => protect_from_escaping($t), 'SUP' => $sup))); if ($conf_found_count > 100) { $content[$current_results_type] = do_template('INDEX_SCREEN_FANCIER_ENTRY', array('NAME' => do_lang_tempcode('TOO_MANY_TO_CHOOSE_FROM'), 'URL' => '', 'TITLE' => '', 'DESCRIPTION' => '', 'SUP' => '')); break; } $conf_found_count++; if (!array_key_exists($p['the_page'], $config_categories)) { $config_categories[$p['the_page']] = array(); } $config_categories[$p['the_page']][$p['section']] = 1; } } } $current_results_type = do_lang('OPTION_CATEGORIES'); $content[$current_results_type] = new ocp_tempcode(); $current_results_type_2 = do_lang('OPTION_GROUPS'); $content[$current_results_type_2] = new ocp_tempcode(); foreach ($config_categories as $p => $groups) { $_n = do_lang('CONFIG_CATEGORY_' . $p, NULL, NULL, NULL, NULL, false); if (is_null($_n)) { continue; } $n = do_lang_tempcode('CONFIG_CATEGORY_' . $p); if ($this->_keyword_match($n->evaluate())) { $_url = build_url(array('page' => 'admin_config', 'type' => 'category', 'id' => $p), 'adminzone'); $description = do_lang_tempcode('CONFIG_CATEGORY_DESCRIPTION__' . $p); $tree = new ocp_tempcode(); $tree->attach(hyperlink(build_url(array('page' => 'admin', 'type' => 'setup'), 'adminzone'), do_lang_tempcode('SETUP'))); $tree->attach(do_template('BREADCRUMB_ESCAPED')); $tree->attach(hyperlink(build_url(array('page' => 'admin_config', 'type' => 'misc'), 'adminzone'), do_lang_tempcode('CONFIGURATION'))); $sup = do_lang_tempcode('LOCATED_IN', $tree); $content[$current_results_type]->attach(do_template('INDEX_SCREEN_FANCIER_ENTRY', array('NAME' => $n, 'URL' => $_url, 'TITLE' => '', 'DESCRIPTION' => $description, 'SUP' => $sup))); } foreach (array_keys($groups) as $group) { $n2 = do_lang($group, NULL, NULL, NULL, NULL, false); if (is_null($n2)) { continue; } if ($this->_keyword_match($n2)) { $upload_max_filesize = ini_get('upload_max_filesize') == '0' ? do_lang('NA') : clean_file_size(php_return_bytes(ini_get('upload_max_filesize'))); $post_max_size = ini_get('post_max_size') == '0' ? do_lang('NA') : clean_file_size(php_return_bytes(ini_get('post_max_size'))); $_group_description = do_lang('CONFIG_GROUP_DESCRIP_' . $group, escape_html($post_max_size), escape_html($upload_max_filesize), NULL, NULL, false); if (is_null($_group_description)) { $group_description = new ocp_tempcode(); } else { $group_description = do_lang_tempcode('CONFIG_GROUP_DESCRIP_' . $group, escape_html($post_max_size), escape_html($upload_max_filesize), false); } $_url = build_url(array('page' => 'admin_config', 'type' => 'category', 'id' => $p), 'adminzone'); $url = $_url->evaluate(); $url .= '#group_' . $group; $tree = new ocp_tempcode(); $tree->attach(hyperlink(build_url(array('page' => 'admin', 'type' => 'setup'), 'adminzone'), do_lang_tempcode('SETUP'))); $tree->attach(do_template('BREADCRUMB_ESCAPED')); $tree->attach(hyperlink(build_url(array('page' => 'admin_config', 'type' => 'misc'), 'adminzone'), do_lang_tempcode('CONFIGURATION'))); $tree->attach(do_template('BREADCRUMB_ESCAPED')); $tree->attach(hyperlink(build_url(array('page' => 'admin_config', 'type' => 'category', 'id' => $p), 'adminzone'), do_lang('CONFIG_CATEGORY_' . $p))); $sup = do_lang_tempcode('LOCATED_IN', $tree); $content[$current_results_type_2]->attach(do_template('INDEX_SCREEN_FANCIER_ENTRY', array('NAME' => $n2, 'URL' => $url, 'TITLE' => '', 'DESCRIPTION' => $group_description, 'SUP' => $sup))); } } } } $current_results_type = do_lang('USERGROUPS'); if ($this->_section_match($section_limitations, $current_results_type) && has_actual_page_access(get_member(), 'admin_ocf_groups') && get_forum_type() == 'ocf') { // Usergroups $content[$current_results_type] = new ocp_tempcode(); $map = array('g_is_private_club' => 0); $all_groups = $GLOBALS['FORUM_DB']->query_select('f_groups', array('id', 'g_name'), $map); foreach ($all_groups as $p) { $n = get_translated_text($p['g_name']); if ($this->_keyword_match($n)) { $_url = build_url(array('page' => 'admin_ocf_groups', 'type' => '_ed', 'id' => $p['id']), 'adminzone'); $url = $_url->evaluate(); $tree = new ocp_tempcode(); $tree->attach(hyperlink(build_url(array('page' => 'admin', 'type' => 'security'), 'adminzone'), do_lang_tempcode('SECURITY'))); $tree->attach(do_template('BREADCRUMB_ESCAPED')); $tree->attach(hyperlink(build_url(array('page' => 'admin_ocf_groups', 'type' => 'misc'), 'adminzone'), do_lang_tempcode('USERGROUPS'))); $tree->attach(do_template('BREADCRUMB_ESCAPED')); $tree->attach(hyperlink(build_url(array('page' => 'admin_ocf_groups', 'type' => 'ed'), 'adminzone'), do_lang_tempcode('EDIT_GROUP'))); $sup = do_lang_tempcode('LOCATED_IN', $tree); $content[$current_results_type]->attach(do_template('INDEX_SCREEN_FANCIER_ENTRY', array('NAME' => $n, 'URL' => $url, 'TITLE' => '', 'DESCRIPTION' => '', 'SUP' => $sup))); } } } $current_results_type = do_lang('THEMES'); if ($this->_section_match($section_limitations, $current_results_type) && has_actual_page_access(get_member(), 'admin_themes')) { // Themes $content[$current_results_type] = new ocp_tempcode(); $map = array(); foreach (array(do_lang('SUPPORTS_WIDE'), do_lang('MOBILE_PAGES')) as $n) { if ($this->_keyword_match($n)) { $_url = build_url(array('page' => 'admin_themes', 'type' => 'edit_theme', 'theme' => $GLOBALS['FORUM_DRIVER']->get_theme('')), 'adminzone'); $url = $_url->evaluate(); $tree = new ocp_tempcode(); $tree->attach(hyperlink(build_url(array('page' => 'admin', 'type' => 'style'), 'adminzone'), do_lang_tempcode('STYLE'))); $tree->attach(do_template('BREADCRUMB_ESCAPED')); $tree->attach(hyperlink(build_url(array('page' => 'admin_themes', 'type' => 'misc'), 'adminzone'), do_lang_tempcode('THEMES'))); $sup = do_lang_tempcode('LOCATED_IN', $tree); $content[$current_results_type]->attach(do_template('INDEX_SCREEN_FANCIER_ENTRY', array('NAME' => $n, 'URL' => $url, 'TITLE' => '', 'DESCRIPTION' => '', 'SUP' => $sup))); break; } } } $current_results_type = do_lang('ZONES'); if ($this->_section_match($section_limitations, $current_results_type) && has_actual_page_access(get_member(), 'admin_zones')) { // Zones $content[$current_results_type] = new ocp_tempcode(); $map = array(); $all_groups = $GLOBALS['SITE_DB']->query_select('zones', array('zone_name', 'zone_title', 'zone_header_text'), $map, 'ORDER BY zone_title', 50); foreach ($all_groups as $p) { $n = $p['zone_name']; $t = get_translated_text($p['zone_title']); $ht = get_translated_text($p['zone_header_text']); if ($this->_keyword_match($n) || $this->_keyword_match($t) || $this->_keyword_match($ht)) { $_url = build_url(array('page' => 'admin_zones', 'type' => '_edit', 'id' => $p['zone_name']), 'adminzone'); $url = $_url->evaluate(); $tree = new ocp_tempcode(); $tree->attach(hyperlink(build_url(array('page' => 'admin', 'type' => 'setup'), 'adminzone'), do_lang_tempcode('STRUCTURE'))); $tree->attach(do_template('BREADCRUMB_ESCAPED')); $tree->attach(hyperlink(build_url(array('page' => 'admin_zones', 'type' => 'misc'), 'adminzone'), do_lang_tempcode('ZONES'))); $tree->attach(do_template('BREADCRUMB_ESCAPED')); $tree->attach(hyperlink(build_url(array('page' => 'admin_zones', 'type' => 'edit'), 'adminzone'), do_lang_tempcode('EDIT_ZONE'))); $sup = do_lang_tempcode('LOCATED_IN', $tree); $content[$current_results_type]->attach(do_template('INDEX_SCREEN_FANCIER_ENTRY', array('NAME' => $n, 'URL' => $url, 'TITLE' => '', 'DESCRIPTION' => escape_html($t), 'SUP' => $sup))); } } } // Blocks $current_results_type = do_lang('_BLOCKS'); if ($this->_section_match($section_limitations, $current_results_type)) { $content[$current_results_type] = new ocp_tempcode(); $map = array(); require_code('zones2'); $all_blocks = find_all_blocks(); foreach (array_keys($all_blocks) as $p) { $t = do_lang('BLOCK_' . $p . '_DESCRIPTION'); if ($this->_keyword_match($p) || $this->_keyword_match($t)) { $url = ''; $content[$current_results_type]->attach(do_template('INDEX_SCREEN_FANCIER_ENTRY', array('NAME' => $p, 'URL' => $url, 'TITLE' => '', 'DESCRIPTION' => escape_html($t)))); } } } $current_results_type = do_lang('SPECIFIC_PERMISSIONS'); if ($this->_section_match($section_limitations, $current_results_type) && has_actual_page_access(get_member(), 'admin_permissions')) { // Privileges- sections/names/descriptions $content[$current_results_type] = new ocp_tempcode(); $all_permissions = $GLOBALS['SITE_DB']->query_select('sp_list', array('the_name', 'p_section')); $pt_sections = array(); foreach ($all_permissions as $p) { $n = do_lang('PT_' . $p['the_name'], NULL, NULL, NULL, NULL, false); if (is_null($n)) { continue; } if ($this->_keyword_match($n) || $this->_keyword_match($p['the_name'])) { $_url = build_url(array('page' => 'admin_permissions', 'type' => 'specific', 'id' => $p['p_section']), 'adminzone'); $tree = new ocp_tempcode(); $tree->attach(hyperlink(build_url(array('page' => 'admin', 'type' => 'security'), 'adminzone'), do_lang_tempcode('SECURITY'))); $tree->attach(do_template('BREADCRUMB_ESCAPED')); $tree->attach(hyperlink(build_url(array('page' => 'admin_permissions', 'type' => 'specific'), 'adminzone'), do_lang_tempcode('SPECIFIC_PERMISSIONS'))); $tree->attach(do_template('BREADCRUMB_ESCAPED')); $tree->attach(hyperlink($_url, do_lang($p['p_section']))); $sup = do_lang_tempcode('LOCATED_IN', $tree); $content[$current_results_type]->attach(do_template('INDEX_SCREEN_FANCIER_ENTRY', array('NAME' => $n, 'URL' => $_url, 'TITLE' => '', 'DESCRIPTION' => '', 'SUP' => $sup))); } $pt_sections[$p['p_section']] = 1; } $current_results_type = do_lang('SPECIFIC_PERMISSION_SECTIONS'); $content[$current_results_type] = new ocp_tempcode(); foreach (array_keys($pt_sections) as $p) { $n = do_lang($p, NULL, NULL, NULL, NULL, false); if (is_null($n)) { continue; } if ($this->_keyword_match($n) || $this->_keyword_match($p)) { $_url = build_url(array('page' => 'admin_permissions', 'type' => 'specific', 'id' => $p), 'adminzone'); $tree = new ocp_tempcode(); $tree->attach(hyperlink(build_url(array('page' => 'admin', 'type' => 'security'), 'adminzone'), do_lang_tempcode('SECURITY'))); $tree->attach(do_template('BREADCRUMB_ESCAPED')); $tree->attach(hyperlink(build_url(array('page' => 'admin_permissions', 'type' => 'specific'), 'adminzone'), do_lang_tempcode('SPECIFIC_PERMISSIONS'))); $sup = do_lang_tempcode('LOCATED_IN', $tree); $content[$current_results_type]->attach(do_template('INDEX_SCREEN_FANCIER_ENTRY', array('NAME' => $n, 'URL' => $_url, 'TITLE' => '', 'DESCRIPTION' => '', 'SUP' => $sup))); } } } $current_results_type = do_lang('USERGROUP_SETTINGS'); if ($this->_section_match($section_limitations, $current_results_type) && get_forum_type() == 'ocf' && has_actual_page_access(get_member(), 'admin_ocf_groups', 'adminzone')) { // Usergroup settings $content[$current_results_type] = new ocp_tempcode(); $applicable_langstrings = array(array('ENQUIRE_ON_NEW_IPS', 'DESCRIPTION_ENQUIRE_ON_NEW_IPS'), array('FLOOD_CONTROL_ACCESS_SECS', 'DESCRIPTION_FLOOD_CONTROL_ACCESS_SECS'), array('FLOOD_CONTROL_SUBMIT_SECS', 'DESCRIPTION_FLOOD_CONTROL_SUBMIT_SECS'), array('MAX_ATTACHMENTS_PER_POST', 'DESCRIPTION_MAX_ATTACHMENTS_PER_POST'), array('MAX_DAILY_UPLOAD_MB', 'DESCRIPTION_MAX_DAILY_UPLOAD_MB'), array('MAX_AVATAR_WIDTH', 'DESCRIPTION_MAX_AVATAR_WIDTH'), array('MAX_AVATAR_HEIGHT', 'DESCRIPTION_MAX_AVATAR_HEIGHT'), array('MAX_POST_LENGTH_COMCODE', 'DESCRIPTION_MAX_POST_LENGTH_COMCODE'), array('MAX_SIG_LENGTH_COMCODE', 'DESCRIPTION_MAX_SIG_LENGTH_COMCODE')); if (addon_installed('points')) { $applicable_langstrings = array_merge($applicable_langstrings, array(array('GIFT_POINTS_BASE', 'DESCRIPTION_GIFT_POINTS_BASE'), array('GIFT_POINTS_PER_DAY', 'DESCRIPTION_GIFT_POINTS_PER_DAY'))); } foreach ($applicable_langstrings as $_langstring) { $array = is_array($_langstring) ? $_langstring : array($_langstring); foreach ($array as $langstring) { $n = do_lang($langstring); if ($this->_keyword_match($n)) { $n = do_lang_tempcode($array[0]); $_url = build_url(array('page' => 'admin_ocf_groups', 'type' => 'ed'), 'adminzone'); $descrip = array_key_exists(1, $array) ? do_lang_tempcode($array[1]) : new ocp_tempcode(); $tree = new ocp_tempcode(); $tree->attach(hyperlink(build_url(array('page' => 'admin', 'type' => 'security'), 'adminzone'), do_lang_tempcode('SECURITY'))); $tree->attach(do_template('BREADCRUMB_ESCAPED')); $tree->attach(hyperlink(build_url(array('page' => 'admin_ocf_groups', 'type' => 'misc'), 'adminzone'), do_lang_tempcode('USERGROUPS'))); $sup = do_lang_tempcode('LOCATED_IN', $tree); $content[$current_results_type]->attach(do_template('INDEX_SCREEN_FANCIER_ENTRY', array('NAME' => $n, 'URL' => $_url, 'TITLE' => '', 'DESCRIPTION' => $descrip, 'SUP' => $sup))); continue 2; } } } } $current_results_type = do_lang('MEMBER_SETTINGS'); if ($this->_section_match($section_limitations, $current_results_type) && get_forum_type() == 'ocf' && has_actual_page_access(get_member(), 'members')) { // Member settings $content[$current_results_type] = new ocp_tempcode(); $applicable_langstrings = array(array('WIDE', 'DESCRIPTION_WIDE'), array('REVEAL_AGE', 'DESCRIPTION_REVEAL_AGE'), array('PREVIEW_POSTS', 'DESCRIPTION_PREVIEW_POSTS'), array('AUTO_NOTIFICATION_CONTRIB_CONTENT', 'DESCRIPTION_AUTO_NOTIFICATION_CONTRIB_CONTENT'), array('PT_RULES_TEXT', 'PT_RULES_TEXT_DESCRIPTION')); foreach ($applicable_langstrings as $_langstring) { $array = is_array($_langstring) ? $_langstring : array($_langstring); foreach ($array as $langstring) { $n = do_lang($langstring); if ($this->_keyword_match($n)) { $n = do_lang_tempcode($array[0]); $descrip = array_key_exists(1, $array) ? do_lang_tempcode($array[1]) : new ocp_tempcode(); $_url = build_url(array('page' => 'members', 'type' => 'view'), get_module_zone('members'), NULL, false, false, false, 'tab__edit'); $url = $_url->evaluate(); $content[$current_results_type]->attach(do_template('INDEX_SCREEN_FANCIER_ENTRY', array('NAME' => $n, 'URL' => $url, 'TITLE' => '', 'DESCRIPTION' => $descrip))); continue 2; } } } } // Zone options $current_results_type = do_lang('ZONE_OPTIONS'); if ($this->_section_match($section_limitations, $current_results_type) && has_actual_page_access(get_member(), 'admin_zones', 'adminzone')) { $content[$current_results_type] = new ocp_tempcode(); $applicable_langstrings = array(array('DEFAULT_PAGE', 'DESCRIPTION_DEFAULT_PAGE'), array('HEADER_TEXT', 'DESCRIPTION_HEADER_TEXT'), array('WIDE', 'DESCRIPTION_WIDE'), array('REQUIRE_SESSION', 'DESCRIPTION_REQUIRE_SESSION'), array('DISPLAYED_IN_MENU', 'DESCRIPTION_DISPLAYED_IN_MENU'), array('THEME', get_forum_type() == 'ocf' ? '_DESCRIPTION_THEME_OCF' : '_DESCRIPTION_THEME')); foreach ($applicable_langstrings as $_langstring) { $array = is_array($_langstring) ? $_langstring : array($_langstring); foreach ($array as $langstring) { $n = do_lang($langstring); if ($this->_keyword_match($n)) { $n = do_lang_tempcode($array[0]); $_url = build_url(array('page' => 'admin_zones', 'type' => 'edit'), 'adminzone'); $descrip = array_key_exists(1, $array) ? do_lang_tempcode($array[1]) : new ocp_tempcode(); $tree = new ocp_tempcode(); $tree->attach(hyperlink(build_url(array('page' => 'admin', 'type' => 'structure'), 'adminzone'), do_lang_tempcode('STRUCTURE'))); $tree->attach(do_template('BREADCRUMB_ESCAPED')); $tree->attach(hyperlink(build_url(array('page' => 'admin_zones', 'type' => 'misc'), 'adminzone'), do_lang_tempcode('ZONES'))); $sup = do_lang_tempcode('LOCATED_IN', $tree); $content[$current_results_type]->attach(do_template('INDEX_SCREEN_FANCIER_ENTRY', array('NAME' => $n, 'URL' => $_url, 'TITLE' => '', 'DESCRIPTION' => $descrip, 'SUP' => $sup))); continue 2; } } } } // Install options $current_results_type = do_lang('BASE_CONFIGURATION'); if ($this->_section_match($section_limitations, $current_results_type) && $GLOBALS['FORUM_DRIVER']->is_super_admin(get_member())) { $content[$current_results_type] = new ocp_tempcode(); if (file_exists(get_file_base() . '/config_editor.php')) { $file_contents = file_get_contents(get_file_base() . '/config_editor.php'); $matches = array(); $num_matches = preg_match_all('#case \'([^\']+)\':\\n\\s*\\$notes=\'([^\']+)\';#', $file_contents, $matches); for ($i = 0; $i < $num_matches; $i++) { $n = stripslashes($matches[2][$i]); if ($this->_keyword_match($n)) { $url = get_base_url() . '/config_editor.php'; $content[$current_results_type]->attach(do_template('INDEX_SCREEN_FANCIER_ENTRY', array('NAME' => stripslashes($matches[1][$i]), 'URL' => $url, 'TITLE' => '', 'DESCRIPTION' => $n))); } } } } // Language string names and contents $current_results_type = do_lang('MODULE_TRANS_NAME_admin_lang'); if ($this->_section_match($section_limitations, $current_results_type) && has_actual_page_access(get_member(), 'admin_lang', 'adminzone')) { $content[$current_results_type] = new ocp_tempcode(); if (user_lang() != fallback_lang()) { $content[$current_results_type]->attach(paragraph(do_lang_tempcode('SEARCH_LAUNCHPAD', escape_html(urlencode($raw_search_string)), escape_html(urlencode(user_lang()))))); } global $LANGUAGE; $lang_file_contents = array(); $lang_found = array(); foreach ($LANGUAGE[user_lang()] as $n => $n_value) { if ($this->_keyword_match($n) || $this->_keyword_match($n_value)) { $lang_found[$n] = $n_value; if (count($lang_found) > 100) { $content[$current_results_type]->attach(do_template('INDEX_SCREEN_FANCIER_ENTRY', array('NAME' => do_lang_tempcode('TOO_MANY_TO_CHOOSE_FROM'), 'URL' => '', 'TITLE' => '', 'DESCRIPTION' => '', 'SUP' => ''))); $lang_found = array(); break; } } } foreach ($lang_found as $n => $n_value) { // Try and find what lang file it came from $lang_file = 'global'; foreach (array('lang', 'lang_custom') as $lang_dir) { $dh = @opendir(get_file_base() . '/' . $lang_dir . '/' . fallback_lang() . '/'); if ($dh !== false) { while (($file = readdir($dh)) !== false) { if (substr(strtolower($file), -4) == '.ini') { if (!array_key_exists($file, $lang_file_contents)) { $lang_file_contents[$file] = file_get_contents(get_file_base() . '/' . $lang_dir . '/' . fallback_lang() . '/' . $file); } if (preg_match('#^' . str_replace('#', '\\#', preg_quote($n)) . '=#m', $lang_file_contents[$file]) != 0 || file_exists(get_custom_file_base() . '/lang_custom/' . user_lang() . '/' . $file) && preg_match('#^' . str_replace('#', '\\#', preg_quote($n)) . '=#m', file_get_contents(get_custom_file_base() . '/lang_custom/' . user_lang() . '/' . $file)) != 0) { $lang_file = basename($file, '.ini'); break; } } } } } $_url = build_url(array('page' => 'admin_lang', 'type' => 'misc', 'lang' => user_lang(), 'lang_file' => $lang_file), 'adminzone'); $url = $_url->evaluate(); $url .= '#jmp_' . $n; $tree = new ocp_tempcode(); $tree->attach(hyperlink(build_url(array('page' => 'admin', 'type' => 'style'), 'adminzone'), do_lang_tempcode('STYLE'))); $tree->attach(do_template('BREADCRUMB_ESCAPED')); $tree->attach(hyperlink(build_url(array('page' => 'admin_lang', 'type' => 'misc'), 'adminzone'), do_lang_tempcode('TRANSLATE_CONTENT'))); $tree->attach(do_template('BREADCRUMB_ESCAPED')); $tree->attach(hyperlink(build_url(array('page' => 'admin_lang', 'type' => 'misc', 'lang' => user_lang(), 'lang_file' => $lang_file), 'adminzone'), $lang_file)); $sup = do_lang_tempcode('LOCATED_IN', $tree); $content[$current_results_type]->attach(do_template('INDEX_SCREEN_FANCIER_ENTRY', array('NAME' => $n, 'URL' => $url, 'TITLE' => '', 'DESCRIPTION' => escape_html($n_value), 'SUP' => $sup))); } $lang_file_contents = array(); } // Theme images $current_results_type = do_lang('MANAGE_THEME_IMAGES'); if ($this->_section_match($section_limitations, $current_results_type) && has_actual_page_access(get_member(), 'admin_themes', 'adminzone')) { $content[$current_results_type] = new ocp_tempcode(); $images = $GLOBALS['SITE_DB']->query_select('theme_images', array('id', 'theme', 'lang')); foreach ($images as $image) { $n = $image['id']; if ($this->_keyword_match($n)) { $_url = build_url(array('page' => 'admin_themes', 'type' => 'edit_image', 'theme' => $image['theme'], 'lang' => $image['lang'], 'id' => $n), 'adminzone'); $tree = new ocp_tempcode(); $tree->attach(hyperlink(build_url(array('page' => 'admin', 'type' => 'style'), 'adminzone'), do_lang_tempcode('STYLE'))); $tree->attach(do_template('BREADCRUMB_ESCAPED')); $tree->attach(hyperlink(build_url(array('page' => 'admin_themes', 'type' => 'misc'), 'adminzone'), do_lang_tempcode('THEMES'))); $tree->attach(do_template('BREADCRUMB_ESCAPED')); $tree->attach(hyperlink(build_url(array('page' => 'admin_themes', 'type' => 'edit_css', 'theme' => $image['theme']), 'adminzone'), do_lang_tempcode('EDIT_THEME_IMAGE'))); $tree->attach(do_template('BREADCRUMB_ESCAPED')); $tree->attach(escape_html($image['theme'])); $sup = do_lang_tempcode('LOCATED_IN', $tree); $lang = $image['lang']; $lang_map = better_parse_ini_file(file_exists(get_file_base() . '/lang_custom/langs.ini') ? get_file_base() . '/lang_custom/langs.ini' : get_file_base() . '/lang/langs.ini'); $lang = array_key_exists($lang, $lang_map) ? $lang_map[$lang] : $lang; $content[$current_results_type]->attach(do_template('INDEX_SCREEN_FANCIER_ENTRY', array('NAME' => $n, 'URL' => $_url, 'TITLE' => '', 'DESCRIPTION' => $lang, 'SUP' => $sup))); } } } // Template names $current_results_type = do_lang('TEMPLATES'); if ($this->_section_match($section_limitations, $current_results_type) && has_actual_page_access(get_member(), 'admin_themes', 'adminzone')) { $content[$current_results_type] = new ocp_tempcode(); $tpl_found = array(); foreach (array('templates_custom', 'templates') as $template_dir) { $dh = opendir(get_file_base() . '/themes/default/' . $template_dir . '/'); while (($file = readdir($dh)) !== false) { if (substr(strtolower($file), -4) == '.tpl' && !array_key_exists($file, $tpl_found)) { $n = $file; if ($this->_keyword_match(basename($n, '.tpl')) || $this->_keyword_match($n) || $template_dir == 'templates_custom' && $this->_keyword_match(file_get_contents(get_file_base() . '/themes/default/' . $template_dir . '/' . $n))) { $_url = build_url(array('page' => 'admin_themes', 'type' => '_edit_templates', 'theme' => $default_theme, 'f0file' => $file), 'adminzone'); $tree = new ocp_tempcode(); $tree->attach(hyperlink(build_url(array('page' => 'admin', 'type' => 'style'), 'adminzone'), do_lang_tempcode('STYLE'))); $tree->attach(do_template('BREADCRUMB_ESCAPED')); $tree->attach(hyperlink(build_url(array('page' => 'admin_themes', 'type' => 'misc'), 'adminzone'), do_lang_tempcode('THEMES'))); $tree->attach(do_template('BREADCRUMB_ESCAPED')); $tree->attach(hyperlink(build_url(array('page' => 'admin_themes', 'type' => 'edit_templates', 'theme' => $default_theme), 'adminzone'), do_lang_tempcode('EDIT_TEMPLATES'))); $sup = do_lang_tempcode('LOCATED_IN', $tree); $content[$current_results_type]->attach(do_template('INDEX_SCREEN_FANCIER_ENTRY', array('NAME' => $n, 'URL' => $_url, 'TITLE' => '', 'DESCRIPTION' => '', 'SUP' => $sup))); $tpl_found[$file] = 1; } } } } } // CSS file contents $current_results_type = 'CSS'; if ($this->_section_match($section_limitations, $current_results_type) && has_actual_page_access(get_member(), 'admin_themes', 'adminzone')) { $content[$current_results_type] = new ocp_tempcode(); $dh = opendir(get_file_base() . '/themes/default/css/'); while (($file = readdir($dh)) !== false) { if (substr(strtolower($file), -4) == '.css') { $n = $file; if ($this->_keyword_match(file_get_contents(get_file_base() . '/themes/default/css/' . $n))) { $_url = build_url(array('page' => 'admin_themes', 'type' => 'edit_css', 'theme' => $default_theme, 'file' => $file), 'adminzone'); $url = $_url->evaluate(); if (isset($keywords[0])) { $url .= '#' . $keywords[0][0]; } $tree = new ocp_tempcode(); $tree->attach(hyperlink(build_url(array('page' => 'admin', 'type' => 'style'), 'adminzone'), do_lang_tempcode('STYLE'))); $tree->attach(do_template('BREADCRUMB_ESCAPED')); $tree->attach(hyperlink(build_url(array('page' => 'admin_themes', 'type' => 'misc'), 'adminzone'), do_lang_tempcode('THEMES'))); $tree->attach(do_template('BREADCRUMB_ESCAPED')); $tree->attach(hyperlink(build_url(array('page' => 'admin_themes', 'type' => 'choose_css', 'theme' => $default_theme), 'adminzone'), do_lang_tempcode('EDIT_CSS'))); $sup = do_lang_tempcode('LOCATED_IN', $tree); $content[$current_results_type]->attach(do_template('INDEX_SCREEN_FANCIER_ENTRY', array('NAME' => $n, 'URL' => $url, 'TITLE' => '', 'DESCRIPTION' => '', 'SUP' => $sup))); } } } } //ksort($content); Don't sort, we have an implicit good order in this code file // And show results... if (addon_installed('search')) { $_search_url = build_url(array('page' => 'search', 'type' => 'results', 'content' => $raw_search_string, 'days' => '-1', 'search_comcode_pages' => 1, 'all_defaults' => 1), get_module_zone('search')); $search_url = $_search_url->evaluate(); $software_search_url = brand_base_url() . '/site/index.php?page=search&type=results&search_under=docs&search_comcode_pages=1&days=-1&content=' . urlencode($raw_search_string); $software_search_url_2 = brand_base_url() . '/site/index.php?page=search&type=results&search_ocf_posts=1&days=-1&content=' . urlencode($raw_search_string); $pre = do_lang_tempcode('ADMINZONE_SEARCH_RESULTS', escape_html($raw_search_string), escape_html($search_url), array(escape_html($software_search_url), escape_html($software_search_url_2))); } else { $pre = new ocp_tempcode(); } $found_some = false; foreach ($content as $c) { if (!$c->is_empty()) { $found_some = true; break; } } $post = strpos($raw_search_string, '"') !== false || !$found_some ? new ocp_tempcode() : do_lang_tempcode('ADMINZONE_SEARCH_TIP', escape_html(preg_replace('#\\s@\\w+#', '', $raw_search_string))); if (!$found_some && $this->and_query) { $this->and_query = false; return $this->search(); } return do_template('INDEX_SCREEN_FANCIER_SCREEN', array('TITLE' => get_page_title('ADMIN_ZONE_SEARCH_RESULTS'), 'EMPTY' => $found_some ? NULL : true, 'ARRAY' => true, 'CONTENT' => $content, 'PRE' => $pre, 'POST' => $post)); }
/** * UI for a setup wizard step (block choice). * * @return tempcode The UI */ function step6() { $title = get_page_title('SETUP_WIZARD_STEP', true, array(integer_format(6), integer_format(10))); require_all_lang(); $installprofile = post_param('installprofile', ''); if ($installprofile != '') { require_code('hooks/modules/admin_setupwizard_installprofiles/' . $installprofile); $object = object_factory('Hook_admin_setupwizard_installprofiles_' . $installprofile); $default_blocks = $object->default_blocks(); } else { $default_blocks = NULL; } $main_blocks = array(); $side_blocks = array(); if ($installprofile != '') { $side_blocks['side_personal_stats'] = 'PANEL_LEFT'; } $hooks = find_all_hooks('modules', 'admin_setupwizard'); foreach (array_keys($hooks) as $hook) { if (post_param_integer('addon_' . $hook, 0) == 1) { require_code('hooks/modules/admin_setupwizard/' . filter_naughty_harsh($hook)); $ob = object_factory('Hook_sw_' . filter_naughty_harsh($hook), true); if (is_null($ob)) { continue; } if (method_exists($ob, 'get_blocks')) { $ret = $ob->get_blocks(); if (count($ret) != 0) { list($a, $b) = $ret; $main_blocks = array_merge($main_blocks, $a); $side_blocks = array_merge($side_blocks, $b); } } } } ksort($main_blocks); ksort($side_blocks); $post_url = build_url(array('page' => '_SELF', 'type' => 'step7'), '_SELF'); $text = do_lang_tempcode('SETUP_WIZARD_6_DESCRIBE'); $submit_name = do_lang_tempcode('PROCEED'); require_code('form_templates'); $fields = ''; require_lang('blocks'); require_lang('zones'); require_code('zones2'); $tmp = do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('FRONT_PAGE'))); $fields .= $tmp->evaluate(); /*XHTMLXHTML*/ foreach ($main_blocks as $block => $position_bits) { if (!file_exists(get_file_base() . '/sources/blocks/' . $block . '.php')) { continue; } $description = paragraph(do_lang_tempcode('BLOCK_' . $block . '_DESCRIPTION')); $description->attach(paragraph(do_lang_tempcode('BLOCK_' . $block . '_USE'))); $block_nice = cleanup_block_name($block); if (is_null($default_blocks)) { $position = $position_bits[1]; } else { $position = 'NO'; foreach (array('YES', 'YES_CELL', 'PANEL_LEFT', 'PANEL_RIGHT') as $p) { if (in_array($block, $default_blocks[$p])) { $position = $p; } } } $main_list = new ocp_tempcode(); $main_list->attach(form_input_list_entry('NO', $position == 'NO', do_lang_tempcode('BLOCK_CONFIGURATION__PANEL_NO'))); $main_list->attach(form_input_list_entry('YES', $position == 'YES', do_lang_tempcode('BLOCK_CONFIGURATION__PANEL_YES'))); $main_list->attach(form_input_list_entry('YES_CELL', $position == 'YES_CELL', do_lang_tempcode('BLOCK_CONFIGURATION__PANEL_YES_CELL'))); $main_list->attach(form_input_list_entry('PANEL_LEFT', $position == 'PANEL_LEFT', do_lang_tempcode('BLOCK_CONFIGURATION__PANEL_LEFT'))); $main_list->attach(form_input_list_entry('PANEL_RIGHT', $position == 'PANEL_RIGHT', do_lang_tempcode('BLOCK_CONFIGURATION__PANEL_RIGHT'))); $tmp = form_input_list($block_nice, $description, 'block_SITE_' . $block, $main_list); $fields .= $tmp->evaluate(); /*XHTMLXHTML*/ } $tmp = do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('PANELS'))); $fields .= $tmp->evaluate(); /*XHTMLXHTML*/ foreach ($side_blocks as $block => $position_bits) { if (!file_exists(get_file_base() . '/sources/blocks/' . $block . '.php')) { continue; } $description = paragraph(do_lang_tempcode('BLOCK_' . $block . '_DESCRIPTION')); $description->attach(paragraph(do_lang_tempcode('BLOCK_' . $block . '_USE'))); $block_nice = cleanup_block_name($block); if (is_null($default_blocks)) { $position = $position_bits[1]; } else { $position = 'NO'; foreach (array('YES', 'YES_CELL', 'PANEL_LEFT', 'PANEL_RIGHT') as $p) { if (in_array($block, $default_blocks[$p])) { $position = $p; } } } $side_list = new ocp_tempcode(); $side_list->attach(form_input_list_entry('PANEL_NONE', $position == 'PANEL_NONE', do_lang_tempcode('BLOCK_CONFIGURATION__PANEL_NONE'))); $side_list->attach(form_input_list_entry('PANEL_LEFT', $position == 'PANEL_LEFT', do_lang_tempcode('BLOCK_CONFIGURATION__PANEL_LEFT'))); $side_list->attach(form_input_list_entry('PANEL_RIGHT', $position == 'PANEL_RIGHT', do_lang_tempcode('BLOCK_CONFIGURATION__PANEL_RIGHT'))); $tmp = form_input_list($block_nice, $description, 'block_SITE_' . $block, $side_list); $fields .= $tmp->evaluate(); /*XHTMLXHTML*/ } //breadcrumb_set_parents(array(array('_SELF:_SELF:misc',do_lang_tempcode('START')))); return do_template('FORM_SCREEN', array('_GUID' => 'd463906b9e2cd8c37577d64783aa844c', 'SKIP_VALIDATION' => true, 'TITLE' => $title, 'SKIPPABLE' => 'skip_6', 'FIELDS' => $fields, 'URL' => $post_url, 'TEXT' => $text, 'PREVIEW' => true, 'SUBMIT_NAME' => $submit_name, 'HIDDEN' => static_evaluate_tempcode(build_keep_post_fields()))); }
/** * Standard modular run function. * * @return tempcode The result of execution. */ function run() { require_all_lang(); require_code('config2'); $val = ini_get('suhosin.post.max_vars'); if (is_string($val) && $val != '' && intval($val) < 400) { attach_message(do_lang_tempcode('LOW_SUHOSIN_SETTING'), 'warn'); } $type = get_param('type', 'misc'); if ($type == 'base') { return $this->base(); } if ($type == 'misc') { return $this->config_choose(); } if ($type == 'category') { return $this->config_category(); } if ($type == 'set') { return $this->config_set(); } if (addon_installed('xml_fields')) { if ($type == 'xml_fields') { return $this->xml_fields(); } if ($type == '_xml_fields') { return $this->_xml_fields(); } } if (addon_installed('breadcrumbs')) { if ($type == 'xml_breadcrumbs') { return $this->xml_breadcrumbs(); } if ($type == '_xml_breadcrumbs') { return $this->_xml_breadcrumbs(); } } if (is_null(get_value('brand_base_url'))) { if ($type == 'upgrader') { return $this->upgrader(); } } if (addon_installed('syndication')) { if ($type == 'backend') { return $this->backend(); } } if (addon_installed('code_editor')) { if ($type == 'code_editor') { return $this->code_editor(); } } return new ocp_tempcode(); }
/** * Shows an HTML page for making block Comcode. */ function block_helper_script() { require_lang('comcode'); require_lang('blocks'); require_code('zones2'); require_code('zones3'); check_specific_permission('comcode_dangerous'); $title = get_page_title('BLOCK_HELPER'); require_code('form_templates'); require_all_lang(); $type_wanted = get_param('block_type', 'main'); $type = get_param('type', 'step1'); $content = new ocp_tempcode(); if ($type == 'step1') { // Find what addons all our block files are in, and icons if possible $hooks = find_all_hooks('systems', 'addon_registry'); $hook_keys = array_keys($hooks); $hook_files = array(); foreach ($hook_keys as $hook) { $path = get_file_base() . '/sources_custom/hooks/systems/addon_registry/' . filter_naughty_harsh($hook) . '.php'; if (!file_exists($path)) { $path = get_file_base() . '/sources/hooks/systems/addon_registry/' . filter_naughty_harsh($hook) . '.php'; } $hook_files[$hook] = file_get_contents($path); } unset($hook_keys); $addon_icons = array(); $addons_blocks = array(); foreach ($hook_files as $addon_name => $hook_file) { $matches = array(); if (preg_match('#function get_file_list\\(\\)\\s*\\{([^\\}]*)\\}#', $hook_file, $matches) != 0) { if (!defined('HIPHOP_PHP')) { $addon_files = eval($matches[1]); } else { require_code('hooks/systems/addon_registry/' . $addon_name); $hook_ob = object_factory('Hook_addon_registry_' . $addon_name); $addon_files = $hook_ob->get_file_list(); } foreach ($addon_files as $file) { if (substr($file, 0, 31) == 'themes/default/images/bigicons/' && !array_key_exists($addon_name, $addon_icons)) { $addon_icons[$addon_name] = find_theme_image('bigicons/' . basename($file, '.png'), false, true); } if (substr($file, 0, 21) == 'sources_custom/blocks/' || substr($file, 0, 15) == 'sources/blocks/') { if ($addon_name == 'staff_messaging') { $addon_name = 'core_feedback_features'; } $addons_blocks[basename($file, '.php')] = $addon_name; } } } } // Find where blocks have been used $block_usage = array(); $zones = find_all_zones(false, true); foreach ($zones as $_zone) { $zone = $_zone[0]; $pages = find_all_pages_wrap($zone, true); foreach ($pages as $filename => $type) { if (substr(strtolower($filename), -4) == '.txt') { $matches = array(); $contents = file_get_contents(zone_black_magic_filterer((substr($type, 0, 15) == 'comcode_custom/' ? get_custom_file_base() : get_file_base()) . '/' . ($zone == '' ? '' : $zone . '/') . 'pages/' . $type . '/' . $filename)); //$fallback=get_file_base().'/'.(($zone=='')?'':($zone.'/')).'pages/comcode/'.fallback_lang().'/'.$filename; //if (file_exists($fallback)) $contents.=file_get_contents($fallback); $num_matches = preg_match_all('#\\[block[^\\]]*\\](.*)\\[/block\\]#U', $contents, $matches); for ($i = 0; $i < $num_matches; $i++) { $block_used = $matches[1][$i]; if (!array_key_exists($block_used, $block_usage)) { $block_usage[$block_used] = array(); } $block_usage[$block_used][] = $zone . ':' . basename($filename, '.txt'); } } } } // Show block list $links = new ocp_tempcode(); $blocks = find_all_blocks(); $dh = @opendir(get_file_base() . '/sources_custom/miniblocks'); if ($dh !== false) { while (($file = readdir($dh)) !== false) { if (substr($file, -4) == '.php' && preg_match('#^[\\w\\-]*$#', substr($file, 0, strlen($file) - 4)) != 0) { $blocks[substr($file, 0, strlen($file) - 4)] = 'sources_custom'; } } closedir($dh); } $block_types = array(); $block_types_icon = array(); $keep = symbol_tempcode('KEEP'); foreach (array_keys($blocks) as $block) { if (array_key_exists($block, $addons_blocks)) { $addon_name = $addons_blocks[$block]; $addon_icon = array_key_exists($addon_name, $addon_icons) ? $addon_icons[$addon_name] : NULL; $addon_name = preg_replace('#^core\\_#', '', $addon_name); } else { $addon_name = NULL; $addon_icon = NULL; } $this_block_type = is_null($addon_name) || strpos($addon_name, 'block') !== false || $addon_name == 'core' ? substr($block, 0, strpos($block, '_') === false ? strlen($block) : strpos($block, '_')) : $addon_name; if (!array_key_exists($this_block_type, $block_types)) { $block_types[$this_block_type] = new ocp_tempcode(); } if (!is_null($addon_icon)) { $block_types_icon[$this_block_type] = $addon_icon; } $block_description = do_lang('BLOCK_' . $block . '_DESCRIPTION', NULL, NULL, NULL, NULL, false); $block_use = do_lang('BLOCK_' . $block . '_USE', NULL, NULL, NULL, NULL, false); if (is_null($block_description)) { $block_description = ''; } if (is_null($block_use)) { $block_use = ''; } $descriptiont = $block_description == '' && $block_use == '' ? new ocp_tempcode() : do_lang_tempcode('BLOCK_HELPER_1X', $block_description, $block_use); $url = find_script('block_helper') . '?type=step2&block=' . urlencode($block) . '&field_name=' . get_param('field_name') . $keep->evaluate(); if (get_param('utheme', '') != '') { $url .= '&utheme=' . get_param('utheme'); } $url .= '&block_type=' . $type_wanted; $link_caption = do_lang_tempcode('NICE_BLOCK_NAME', escape_html(cleanup_block_name($block)), $block); $usage = array_key_exists($block, $block_usage) ? $block_usage[$block] : array(); $block_types[$this_block_type]->attach(do_template('BLOCK_HELPER_BLOCK_CHOICE', array('USAGE' => $usage, 'DESCRIPTION' => $descriptiont, 'URL' => $url, 'LINK_CAPTION' => $link_caption))); } /*if (array_key_exists($type_wanted,$block_types)) We don't do this now, as we structure by addon name { $x=$block_types[$type_wanted]; unset($block_types[$type_wanted]); $block_types=array_merge(array($type_wanted=>$x),$block_types); }*/ ksort($block_types); // We sort now instead $move_after = $block_types['adminzone_frontpage']; unset($block_types['adminzone_frontpage']); $block_types['adminzone_frontpage'] = $move_after; foreach ($block_types as $block_type => $_links) { switch ($block_type) { case 'side': case 'main': case 'bottom': $type_title = do_lang_tempcode('BLOCKS_TYPE_' . $block_type); $img = NULL; break; default: $type_title = do_lang_tempcode('BLOCKS_TYPE_ADDON', escape_html(cleanup_block_name($block_type))); $img = array_key_exists($block_type, $block_types_icon) ? $block_types_icon[$block_type] : NULL; break; } $links->attach(do_template('BLOCK_HELPER_BLOCK_GROUP', array('IMG' => $img, 'TITLE' => $type_title, 'LINKS' => $_links))); } $content = do_template('BLOCK_HELPER_START', array('_GUID' => 'd2d6837cdd8b19d80ea95ab9f5d09c9a', 'GET' => true, 'TITLE' => $title, 'LINKS' => $links)); } elseif ($type == 'step2') { require_code('comcode_text'); $defaults = parse_single_comcode_tag(get_param('parse_defaults', '', true), 'block'); $block = trim(get_param('block')); $title = get_page_title('_BLOCK_HELPER', true, array(escape_html($block))); $fields = new ocp_tempcode(); $parameters = get_block_parameters($block); $parameters[] = 'failsafe'; $parameters[] = 'cache'; $parameters[] = 'quick_cache'; if (!isset($defaults['cache'])) { $defaults['cache'] = block_cache_default($block); } if (is_null($parameters)) { $parameters = array(); } $advanced_ind = do_lang('BLOCK_IND_ADVANCED'); $param_classes = array('normal' => array(), 'advanced' => array()); foreach ($parameters as $parameter) { $param_class = 'normal'; if ($parameter == 'cache' || $parameter == 'quick_cache' || $parameter == 'failsafe' || strpos(do_lang('BLOCK_' . $block . '_PARAM_' . $parameter), $advanced_ind) !== false) { $param_class = 'advanced'; } $param_classes[$param_class][] = $parameter; } foreach ($param_classes as $param_class => $parameters) { if (count($parameters) == 0) { if ($param_class == 'normal') { $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('SECTION_HIDDEN' => false, 'TITLE' => do_lang_tempcode('PARAMETERS'), 'HELP' => protect_from_escaping(paragraph(do_lang_tempcode('BLOCK_HELPER_NO_PARAMETERS'), '', 'nothing_here'))))); } continue; } if ($param_class == 'advanced') { $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('SECTION_HIDDEN' => true, 'TITLE' => do_lang_tempcode('ADVANCED')))); } foreach ($parameters as $parameter) { $matches = array(); switch ($parameter) { case 'quick_cache': case 'cache': case 'failsafe': $description = do_lang('BLOCK_PARAM_' . $parameter); break; default: $description = do_lang('BLOCK_' . $block . '_PARAM_' . $parameter); break; } $description = str_replace(do_lang('BLOCK_IND_STRIPPABLE_1'), '', $description); $description = trim(str_replace(do_lang('BLOCK_IND_ADVANCED'), '', $description)); // Work out default value for field $default = ''; if (preg_match('#' . do_lang('BLOCK_IND_DEFAULT') . ': ["\']([^"]*)["\']#Ui', $description, $matches) != 0) { $default = $matches[1]; $has_default = true; $description = preg_replace('#\\s*' . do_lang('BLOCK_IND_DEFAULT') . ': ["\']([^"]*)["\'](?-U)\\.?(?U)#Ui', '', $description); } else { $has_default = false; } if (isset($defaults[$parameter])) { $default = $defaults[$parameter]; $has_default = true; } // Show field if ($block . ':' . $parameter == 'side_stored_menu:type') { $matches = array(); $dh = opendir(get_file_base() . '/themes/default/templates/'); $options = array(); while (($file = readdir($dh)) !== false) { if (preg_match('^MENU\\_([a-z]+)\\.tpl$^', $file, $matches) != 0) { $options[] = $matches[1]; } } closedir($dh); $dh = opendir(get_custom_file_base() . '/themes/default/templates_custom/'); while (($file = readdir($dh)) !== false) { if (preg_match('^MENU\\_([a-z]+)\\.tpl$^', $file, $matches) != 0 && !file_exists(get_file_base() . '/themes/default/templates/' . $file)) { $options[] = $matches[1]; } } closedir($dh); sort($options); $list = new ocp_tempcode(); foreach ($options as $option) { $list->attach(form_input_list_entry($option, $has_default && $option == $default)); } $fields->attach(form_input_list(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $list, NULL, false, false)); } elseif ($block . ':' . $parameter == 'side_stored_menu:param') { $list = new ocp_tempcode(); $rows = $GLOBALS['SITE_DB']->query_select('menu_items', array('DISTINCT i_menu'), NULL, 'ORDER BY i_menu'); foreach ($rows as $row) { $list->attach(form_input_list_entry($row['i_menu'], $has_default && $row['i_menu'] == $default)); } $fields->attach(form_input_list(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $list, NULL, false, false)); } elseif ($block . ':' . $parameter == 'side_shoutbox:param') { $list = new ocp_tempcode(); $rows = $GLOBALS['SITE_DB']->query_select('chat_rooms', array('id', 'room_name'), array('is_im' => 0), '', 100); foreach ($rows as $row) { $list->attach(form_input_list_entry(strval($row['id']), $has_default && strval($row['id']) == $default, $row['room_name'])); } $fields->attach(form_input_list(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $list, NULL, false, false)); } elseif ($block . ':' . $parameter == 'main_poll:param') { $list = new ocp_tempcode(); $rows = $GLOBALS['SITE_DB']->query_select('poll', array('id', 'question'), NULL, 'ORDER BY id DESC', 100); $list->attach(form_input_list_entry('', false, do_lang('NA'))); foreach ($rows as $row) { $list->attach(form_input_list_entry(strval($row['id']), $has_default && strval($row['id']) == $default, get_translated_text($row['question']))); } $fields->attach(form_input_list(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $list, NULL, false, false)); } elseif ($block . ':' . $parameter == 'main_awards:param') { $list = new ocp_tempcode(); $rows = $GLOBALS['SITE_DB']->query_select('award_types', array('id', 'a_title')); foreach ($rows as $row) { $list->attach(form_input_list_entry(strval($row['id']), $has_default && strval($row['id']) == $default, get_translated_text($row['a_title']))); } $fields->attach(form_input_list(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $list, NULL, false, false)); } elseif ($parameter == 'zone' || $parameter == 'param' && $block == 'main_as_zone_access') { $list = new ocp_tempcode(); $list->attach(form_input_list_entry('_SEARCH', $default == '')); $list->attach(nice_get_zones($default == '' ? NULL : $default)); $fields->attach(form_input_list(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $list, NULL, false, false)); } elseif (($parameter == 'forum' || $parameter == 'param' && in_array($block, array('main_forum_topics'))) && get_forum_type() == 'ocf') { require_code('ocf_forums'); require_code('ocf_forums2'); if (!addon_installed('ocf_forum')) { warn_exit(do_lang_tempcode('NO_FORUM_INSTALLED')); } $list = ocf_get_forum_tree_secure(NULL, NULL, true, explode(',', $default)); $fields->attach(form_input_multi_list(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $list)); } elseif ($parameter == 'param' && in_array($block, array('side_root_galleries', 'main_gallery_tease', 'main_gallery_embed', 'main_image_fader'))) { require_code('galleries'); $list = nice_get_gallery_tree($default); $fields->attach(form_input_list(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $list, NULL, false, false)); } elseif ($parameter == 'param' && in_array($block, array('main_download_category'))) { require_code('downloads'); $list = nice_get_download_category_tree($default == '' ? NULL : intval($default)); $fields->attach(form_input_list(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $list, NULL, false, false)); } elseif ($parameter == 'param' && in_array($block, array('main_contact_catalogues')) || $parameter == 'catalogue' && in_array($block, array('main_recent_cc_entries'))) { require_code('catalogues'); $list = nice_get_catalogues($default, false); $fields->attach(form_input_list(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $list, NULL, false, false)); } elseif ($parameter == 'param' && in_array($block, array('main_cc_embed')) && $GLOBALS['SITE_DB']->query_value('catalogue_categories', 'COUNT(*)') < 500) { $list = new ocp_tempcode(); $categories = $GLOBALS['SITE_DB']->query_select('catalogue_categories', array('id', 'cc_title', 'c_name'), NULL, 'ORDER BY c_name,id'); $last_cat = mixed(); foreach ($categories as $cat) { if (is_null($last_cat) || $cat['c_name'] != $last_cat) { $list->attach(form_input_list_entry($cat['c_name'], $has_default && $cat['c_name'] == $default, $cat['c_name'], false, true)); $last_cat = $cat['c_name']; } $list->attach(form_input_list_entry(strval($cat['id']), $has_default && strval($cat['id']) == $default, get_translated_text($cat['cc_title']))); } $fields->attach(form_input_list(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $list, NULL, false, false)); } elseif ($parameter == 'param' && in_array($block, array('main_banner_wave', 'main_topsites'))) { require_code('banners'); $list = nice_get_banner_types($default); $fields->attach(form_input_list(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $list, NULL, false, false)); } elseif ($parameter == 'param' && in_array($block, array('main_newsletter_signup'))) { $list = new ocp_tempcode(); $rows = $GLOBALS['SITE_DB']->query_select('newsletters', array('id', 'title')); foreach ($rows as $newsletter) { $list->attach(form_input_list_entry(strval($newsletter['id']), $has_default && strval($newsletter['id']) == $default, get_translated_text($newsletter['title']))); } $fields->attach(form_input_list(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $list, NULL, false, false)); } elseif ($parameter == 'filter' && in_array($block, array('bottom_news', 'main_news', 'side_news', 'side_news_archive'))) { require_code('news'); $list = nice_get_news_categories($default == '' ? -1 : intval($default)); $fields->attach(form_input_multi_list(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $list)); } elseif ($parameter == 'font') { $fonts = array(); $dh = opendir(get_file_base() . '/data/fonts'); while ($f = readdir($dh)) { if (substr($f, -4) == '.ttf') { $fonts[] = substr($f, 0, strlen($f) - 4); } } closedir($dh); $dh = opendir(get_custom_file_base() . '/data_custom/fonts'); while ($f = readdir($dh)) { if (substr($f, -4) == '.ttf') { $fonts[] = substr($f, 0, strlen($f) - 4); } } closedir($dh); $fonts = array_unique($fonts); sort($fonts); $list = new ocp_tempcode(); foreach ($fonts as $font) { $list->attach(form_input_list_entry($font, $font == $default)); } $fields->attach(form_input_list(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $list, NULL, false, false)); } elseif (preg_match('#' . do_lang('BLOCK_IND_EITHER') . ' (.+)#i', $description, $matches) != 0) { $description = preg_replace('# \\(' . do_lang('BLOCK_IND_EITHER') . '.*\\)#U', '', $description); $list = new ocp_tempcode(); $matches2 = array(); $num_matches = preg_match_all('#\'([^\']*)\'="([^"]*)"#', $matches[1], $matches2); if ($num_matches != 0) { for ($i = 0; $i < $num_matches; $i++) { $list->attach(form_input_list_entry($matches2[1][$i], $matches2[1][$i] == $default, $matches2[2][$i])); } } else { $num_matches = preg_match_all('#\'([^\']*)\'#', $matches[1], $matches2); for ($i = 0; $i < $num_matches; $i++) { $list->attach(form_input_list_entry($matches2[1][$i], $matches2[1][$i] == $default)); } } $fields->attach(form_input_list(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $list, NULL, false, false)); } elseif (preg_match('#\\(' . do_lang('BLOCK_IND_HOOKTYPE') . ': \'([^\'/]*)/([^\'/]*)\'\\)#i', $description, $matches) != 0) { $description = preg_replace('#\\s*\\(' . do_lang('BLOCK_IND_HOOKTYPE') . ': \'([^\'/]*)/([^\'/]*)\'\\)#i', '', $description); $list = new ocp_tempcode(); $hooks = find_all_hooks($matches[1], $matches[2]); ksort($hooks); if ($default == '' && $has_default) { $list->attach(form_input_list_entry('', true)); } foreach (array_keys($hooks) as $hook) { if ($block == 'side_tag_cloud') { if (substr($hook, -1) == 'y') { $hook .= ',' . substr($hook, 0, strlen($hook) - 1) . 'ies'; } elseif (substr($hook, -1) != 's' && $hook != 'quiz') { $hook .= ',' . $hook . 's'; } } $list->attach(form_input_list_entry($hook, $hook == $default)); } if ($block == 'main_search' && $parameter == 'limit_to' || $block == 'side_tag_cloud') { $fields->attach(form_input_multi_list(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $list, NULL, 0)); } else { $fields->attach(form_input_list(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $list, NULL, false, false)); } } elseif (($default == '0' || $default == '1' || strpos($description, '\'0\'') !== false || strpos($description, '\'1\'') !== false) && do_lang('BLOCK_IND_WHETHER') != '' && strpos(strtolower($description), do_lang('BLOCK_IND_WHETHER')) !== false) { $fields->attach(form_input_tick(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $default == '1')); } elseif (do_lang('BLOCK_IND_NUMERIC') != '' && strpos($description, do_lang('BLOCK_IND_NUMERIC')) !== false) { $fields->attach(form_input_integer(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $default == '' ? NULL : intval($default), false)); } else { $fields->attach(form_input_line(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $default, false)); } } } $keep = symbol_tempcode('KEEP'); $post_url = find_script('block_helper') . '?type=step3&field_name=' . get_param('field_name') . $keep->evaluate(); if (get_param('utheme', '') != '') { $post_url .= '&utheme=' . get_param('utheme'); } $post_url .= '&block_type=' . $type_wanted; if (get_param('save_to_id', '') != '') { $post_url .= '&save_to_id=' . urlencode(get_param('save_to_id')); $submit_name = do_lang_tempcode('SAVE'); // Allow remove option $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('SECTION_HIDDEN' => false, 'TITLE' => do_lang_tempcode('ACTIONS'), 'HELP' => ''))); $fields->attach(form_input_tick(do_lang_tempcode('REMOVE'), '', '_delete', false)); } else { $submit_name = do_lang_tempcode('USE'); } $block_description = do_lang('BLOCK_' . $block . '_DESCRIPTION', NULL, NULL, NULL, NULL, false); if (is_null($block_description)) { $block_description = ''; } $block_use = do_lang('BLOCK_' . $block . '_USE', NULL, NULL, NULL, NULL, false); if (is_null($block_use)) { $block_use = ''; } if ($block_description == '' && $block_use == '') { $text = new ocp_tempcode(); } else { $text = do_lang_tempcode('BLOCK_HELPER_2', escape_html(cleanup_block_name($block)), escape_html($block_description), escape_html($block_use)); } $hidden = form_input_hidden('block', $block); $content = do_template('FORM_SCREEN', array('_GUID' => '270058349d048a8be6570bba97c81fa2', 'TITLE' => $title, 'TARGET' => '_self', 'SKIP_VALIDATION' => true, 'FIELDS' => $fields, 'URL' => $post_url, 'TEXT' => $text, 'SUBMIT_NAME' => $submit_name, 'HIDDEN' => $hidden, 'PREVIEW' => true, 'THEME' => $GLOBALS['FORUM_DRIVER']->get_theme())); if ($fields->is_empty()) { $type = 'step3'; } } if ($type == 'step3') { require_javascript('javascript_posting'); require_javascript('javascript_editing'); $field_name = get_param('field_name'); $bparameters = ''; $bparameters_xml = ''; $bparameters_tempcode = ''; $block = trim(either_param('block')); $parameters = get_block_parameters($block); $parameters[] = 'failsafe'; $parameters[] = 'cache'; $parameters[] = 'quick_cache'; if (in_array('param', $parameters)) { $_parameters = array('param'); unset($parameters[array_search('param', $parameters)]); $parameters = array_merge($_parameters, $parameters); } foreach ($parameters as $parameter) { $value = post_param($parameter, NULL); if (is_null($value)) { if (post_param_integer('tick_on_form__' . $parameter, NULL) === NULL) { continue; } // If not on form, continue, otherwise must be 0 $value = '0'; } if ($value != '' && ($parameter != 'failsafe' || $value == '1') && ($parameter != 'cache' || $value != block_cache_default($block)) && ($parameter != 'quick_cache' || $value == '1')) { if ($parameter == 'param') { $bparameters .= '="' . str_replace('"', '\\"', $value) . '"'; } else { $bparameters .= ' ' . $parameter . '="' . str_replace('"', '\\"', $value) . '"'; } $bparameters_xml = '<blockParam key="' . escape_html($parameter) . '" val="' . escape_html($value) . '" />'; $bparameters_tempcode .= ',' . $parameter . '=' . str_replace(',', '\\,', $value); } } $comcode = '[block' . $bparameters . ']' . $block . '[/block]'; $comcode_xml = '<block>' . $bparameters_xml . $block . '</block>'; $tempcode = '{$BLOCK,block=' . $block . $bparameters_tempcode . '}'; if ($type_wanted == 'template') { $comcode = $tempcode; } // This is what will be written in $comcode_semihtml = comcode_to_tempcode($comcode, NULL, false, 60, NULL, NULL, true, false, false); $content = do_template('BLOCK_HELPER_DONE', array('_GUID' => '575d6c8120d6001c8156560be518f296', 'TITLE' => $title, 'FIELD_NAME' => $field_name, 'BLOCK' => $block, 'COMCODE_XML' => $comcode_xml, 'COMCODE' => $comcode, 'COMCODE_SEMIHTML' => $comcode_semihtml)); } global $EXTRA_HEAD; if (!isset($EXTRA_HEAD)) { $EXTRA_HEAD = new ocp_tempcode(); } $EXTRA_HEAD->attach('<meta name="robots" content="noindex" />'); // XHTMLXHTML $echo = do_template('POPUP_HTML_WRAP', array('TITLE' => do_lang_tempcode('BLOCK_HELPER'), 'CONTENT' => $content)); $echo->handle_symbol_preprocessing(); $echo->evaluate_echo(); }
/** * Start up a search for page-links, writing results into the callback. Usually we pass a callback that builds a Sitemap XML file, but we don't need to- it can be anything. * * @param string Callback function to send discovered page-links to. * @param MEMBER The member we are finding stuff for (we only find what the member can view). * @param ?array Page-links to skip (NULL: none). Currently this only works on pages, but may be expanded in the future. * @param integer Code for how deep we are tunnelling down, in terms of what kinds of things we'll go so far as to collect. Use DEPTH__* constants for the values. */ function spawn_page_crawl($callback, $member_id, $extra_filters = NULL, $depth = 1) { require_all_lang(); require_code('zones2'); if (is_null($extra_filters)) { $extra_filters = array(); } $comcode_page_rows = $GLOBALS['SITE_DB']->query_select('comcode_pages', array('*')); $_zones = array(); $zones = find_all_zones(false, true, true); // Reorder a bit $zones2 = array(); foreach (array('', 'site') as $zone_match) { foreach ($zones as $i => $zone) { if ($zone[0] == $zone_match) { $zones2[] = $zone; unset($zones[$i]); } } } $zones2 = array_merge($zones2, $zones); if (function_exists('set_time_limit')) { @set_time_limit(0); } disable_php_memory_limit(); $GLOBALS['MEMORY_OVER_SPEED'] = true; foreach ($zones2 as $z) { list($zone, $zone_title, , $zone_default_page) = $z; if (has_zone_access($member_id, $zone)) { $done_zone_level = false; $_pages = array(); $pages = find_all_pages_wrap($zone, false, false, FIND_ALL_PAGES__ALL); foreach ($pages as $page => $page_type) { if (is_integer($page)) { $page = strval($page); } if (substr($page, 0, 6) == 'panel_') { continue; } if (substr($page, 0, 1) == '_') { continue; } if (in_array($zone . ':' . $page, $extra_filters)) { continue; } if ($page == '404') { continue; } if ($page == 'forums' && substr($page_type, 0, 7) == 'modules' && (get_forum_type() == 'ocf' || get_forum_type() == 'none')) { continue; } if ($page == 'join' && substr($page_type, 0, 7) == 'modules' && !is_guest($member_id)) { continue; } if (has_page_access($member_id, $page, $zone)) { // Page level $_entrypoints = array(); $__entrypoints = extract_module_functions_page($zone, $page, array('get_entry_points')); if (!is_null($__entrypoints[0])) { $entrypoints = is_array($__entrypoints[0]) ? call_user_func_array($__entrypoints[0][0], $__entrypoints[0][1]) : (strpos($__entrypoints[0], '::') !== false ? NULL : eval($__entrypoints[0])); // The strpos thing is a little hack that allows it to work for base-class derived modules if (is_null($entrypoints)) { $path = zone_black_magic_filterer($zone . ($zone == '' ? '' : '/') . 'pages/' . $page_type . '/' . $page . '.php', true); if (!defined('HIPHOP_PHP') && (ini_get('memory_limit') != '-1' && ini_get('memory_limit') != '0' || get_option('has_low_memory_limit') === '1') && strpos(file_get_contents(get_file_base() . '/' . $path), ' extends standard_aed_module') !== false) { $new_code = str_replace(',parent::get_entry_points()', '', str_replace('parent::get_entry_points(),', '', $__entrypoints[0])); if (strpos($new_code, 'parent::') !== false) { continue; } $entrypoints = eval($new_code); } else { require_code($path); if (class_exists('Mx_' . filter_naughty_harsh($page))) { $object = object_factory('Mx_' . filter_naughty_harsh($page)); } else { $object = object_factory('Module_' . filter_naughty_harsh($page)); } $entrypoints = $object->get_entry_points(); } } } else { $entrypoints = array('!'); } if (!is_array($entrypoints)) { $entrypoints = array('!'); } if ($entrypoints == array('!')) { if ($zone_default_page == $page) { $done_zone_level = true; } $add_date = NULL; $edit_date = NULL; $pagelink = $zone_default_page == $page ? $zone : $zone . ':' . $page; $title = ucwords(str_replace('_', ' ', $page)); if (substr($page_type, 0, 7) == 'comcode') { foreach ($comcode_page_rows as $page_row) { if ($page_row['p_validated'] == 0 && $page_row['the_page'] == $page && $page_row['the_zone'] == $zone) { continue 2; } } $path = zone_black_magic_filterer((strpos($page_type, '_custom') !== false ? get_custom_file_base() : get_file_base()) . '/' . filter_naughty($zone) . '/pages/' . filter_naughty($page_type) . '/' . $page . '.txt'); $add_date = filectime($path); $edit_date = filemtime($path); $page_contents = file_get_contents($path); $matches = array(); if (preg_match('#\\[title[^\\]]*\\]#', $page_contents, $matches) != 0) { $start = strpos($page_contents, $matches[0]) + strlen($matches[0]); $end = strpos($page_contents, '[/title]', $start); $matches = array(); if (preg_match('#^[^\\[\\{\\&]*$#', substr($page_contents, $start, $end - $start), $matches) != 0) { $title = $matches[0]; } else { $_title = comcode_to_tempcode(substr($page_contents, $start, $end - $start), NULL, true); $title = strip_tags(@html_entity_decode($_title->evaluate(), ENT_QUOTES, get_charset())); } } } elseif (substr($page_type, 0, 4) == 'html') { $path = zone_black_magic_filterer((strpos($page_type, '_custom') !== false ? get_custom_file_base() : get_file_base()) . '/' . filter_naughty($zone) . '/pages/' . filter_naughty($page_type) . '/' . $page . '.htm'); $add_date = filectime($path); $edit_date = filemtime($path); $page_contents = file_get_contents($path); $matches = array(); if (preg_match('#\\<title[^\\>]*\\>#', $page_contents, $matches) != 0) { $start = strpos($page_contents, $matches[0]) + strlen($matches[0]); $end = strpos($page_contents, '</title>', $start); $title = strip_tags(@html_entity_decode(substr($page_contents, $start, $end - $start), ENT_QUOTES, get_charset())); } } // Callback call_user_func_array($callback, array($pagelink, $zone, $add_date, $edit_date, $zone_default_page == $page ? 1.0 : 0.8, $title)); } elseif (count($entrypoints) != 0) { // Entry point level $done_top = false; if ($depth >= DEPTH__ENTRY_POINTS) { foreach ($entrypoints as $entrypoint => $title) { if ($entrypoint == '!') { $pagelink = $zone . ':' . $page; $done_top = true; if ($zone_default_page == $page) { $done_zone_level = true; } } else { $pagelink = $zone . ':' . $page . ':' . $entrypoint; if ($zone_default_page == $page && $entrypoint == 'misc') { $done_zone_level = true; } } // Callback call_user_func_array($callback, array($pagelink, count($_entrypoints) > 1 && $entrypoint != '!' ? $zone . ':' . $page : $zone, NULL, NULL, $entrypoint == '!' || $entrypoint == 'misc' ? 0.8 : 0.7, $title)); } } //ksort($_entrypoints); $title = do_lang('MODULE_TRANS_NAME_' . $page, NULL, NULL, NULL, NULL, false); if (is_null($title)) { $title = ucwords(str_replace('_', ' ', preg_replace('#^ocf\\_#', '', preg_replace('#^' . str_replace('#', '\\#', preg_quote($zone)) . '_#', '', preg_replace('#^' . str_replace('#', '\\#', preg_quote(str_replace('zone', '', $zone))) . '_#', '', $page))))); } if (count($_entrypoints) > 1 && !$done_top) { // Callback call_user_func_array($callback, array($zone . ':' . $page, $zone, NULL, NULL, 0.8, $title, false)); } } // Categories if ($depth >= DEPTH__CATEGORIES) { $__sitemap_pagelinks = extract_module_functions_page($zone, $page, array('get_sitemap_pagelinks'), array($callback, $member_id, $depth, $zone . ':' . $page . ':')); if (!is_null($__sitemap_pagelinks[0])) { if (is_array($__sitemap_pagelinks[0])) { call_user_func_array($__sitemap_pagelinks[0][0], $__sitemap_pagelinks[0][1]); } else { eval($__sitemap_pagelinks[0]); } } } } } // Zone level if (!$done_zone_level) { // Callback call_user_func_array($callback, array($zone, '', filectime(get_file_base() . '/' . $zone), NULL, 1.0, $zone_title)); } } } }
/** * Put out a user interface for managing notifications for a notification-category supporting content type. Also toggle notifications if an ID is passed. * * @param ID_TEXT The notification code to work with * @param ?tempcode Special message to output if we have toggled to enable (NULL: use standard) * @param ?tempcode Special message to output if we have toggled to disable (NULL: use standard) * @return tempcode UI */ function notifications_ui_advanced($notification_code, $enable_message = NULL, $disable_message = NULL) { require_css('notifications'); require_code('notifications'); require_lang('notifications'); require_javascript('javascript_notifications'); require_javascript('javascript_notifications'); require_all_lang(); $test = $GLOBALS['SITE_DB']->query_value_null_ok('notification_lockdown', 'l_setting', array('l_notification_code' => substr($notification_code, 0, 80))); if (!is_null($test)) { warn_exit(do_lang_tempcode('NOTIFICATION_CODE_LOCKED_DOWN')); } $ob = _get_notification_ob_for_code($notification_code); $info_details = $ob->list_handled_codes(); $title = get_page_title('NOTIFICATION_MANAGEMENT_FOR', true, array(escape_html($info_details[$notification_code][1]))); if (is_guest()) { access_denied('NOT_AS_GUEST'); } $db = substr($notification_code, 0, 4) == 'ocf_' ? $GLOBALS['FORUM_DB'] : $GLOBALS['SITE_DB']; if (is_null($enable_message)) { $enable_message = do_lang_tempcode('NOW_ENABLED_NOTIFICATIONS'); } if (is_null($disable_message)) { $disable_message = do_lang_tempcode('NOW_DISABLED_NOTIFICATIONS'); } $_notification_types = _get_available_notification_types(get_member()); $notification_category = get_param('id', NULL); if (!is_null($notification_category)) { if (notifications_enabled($notification_code, $notification_category)) { enable_notifications($notification_code, $notification_category, NULL, A_NA); attach_message($disable_message, 'inform'); } else { enable_notifications($notification_code, $notification_category); attach_message($enable_message, 'inform'); } } else { if (count($_POST) != 0) { enable_notifications($notification_code, NULL, NULL, A_NA); // Make it clear we've overridden the general value by doing this foreach (array_keys($_POST) as $key) { $matches = array(); if (preg_match('#^notification\\_' . preg_quote($notification_code) . '\\_category\\_(.*)#', $key, $matches) != 0) { $notification_category = $matches[1]; $new_setting = A_NA; foreach ($_notification_types as $possible => $ntype) { if (post_param_integer('notification_' . $notification_category . '_' . $ntype, 0) == 1) { $new_setting = $new_setting | $possible; } } enable_notifications($notification_code, $notification_category, NULL, $new_setting); } } attach_message(do_lang_tempcode('SUCCESS'), 'inform'); // Redirect them back $redirect = get_param('redirect', NULL); if (!is_null($redirect)) { return redirect_screen($title, $redirect, do_lang_tempcode('SUCCESS')); } } } $tree = _notifications_build_category_tree($_notification_types, $notification_code, $ob, NULL); $notification_types_titles = array(); foreach ($_notification_types as $possible => $ntype) { $notification_types_titles[] = array('NTYPE' => $ntype, 'LABEL' => do_lang_tempcode('ENABLE_NOTIFICATIONS_' . $ntype), 'RAW' => strval($possible)); } $css_path = get_custom_file_base() . '/themes/' . $GLOBALS['FORUM_DRIVER']->get_theme() . '/templates_cached/' . user_lang() . '/global.css'; $color = 'FF00FF'; if (file_exists($css_path)) { $tmp_file = file_get_contents($css_path); $matches = array(); if (preg_match('#\\nth[\\s,][^\\}]*\\sbackground-color:\\s*\\#([\\dA-Fa-f]*);#sU', $tmp_file, $matches) != 0) { $color = $matches[1]; } } return do_template('NOTIFICATIONS_MANAGE_ADVANCED_SCREEN', array('TITLE' => $title, 'COLOR' => $color, 'ACTION_URL' => get_self_url(false, false, array('id' => NULL)), 'NOTIFICATION_TYPES_TITLES' => $notification_types_titles, 'TREE' => $tree, 'NOTIFICATION_CODE' => $notification_code)); }
/** * Standard modular run function. * * @return tempcode The result of execution. */ function run() { $GLOBALS['HELPER_PANEL_PIC'] = 'pagepics/importdata'; $GLOBALS['HELPER_PANEL_TUTORIAL'] = 'tut_importer'; if (defined('HIPHOP_PHP')) { warn_exit(do_lang_tempcode('NO_HIPHOP')); } if (get_file_base() != get_custom_file_base()) { warn_exit(do_lang_tempcode('SHARED_INSTALL_PROHIBIT')); } disable_php_memory_limit(); require_all_lang(); require_code('import'); require_code('config2'); require_code('ocf_moderation_action'); require_code('ocf_posts_action'); require_code('ocf_polls_action'); require_code('ocf_members_action'); require_code('ocf_groups_action'); require_code('ocf_general_action'); require_code('ocf_forums_action'); require_code('ocf_topics_action'); require_code('ocf_moderation_action2'); require_code('ocf_posts_action2'); require_code('ocf_polls_action2'); require_code('ocf_members_action2'); require_code('ocf_groups_action2'); require_code('ocf_general_action2'); require_code('ocf_forums_action2'); require_code('ocf_topics_action2'); // Decide what we're doing $type = get_param('type', 'misc'); $GLOBALS['LAX_COMCODE'] = true; if ($type == 'misc') { return $this->choose_importer(); } if ($type == 'session') { return $this->choose_session(); } if ($type == 'session2') { return $this->choose_session2(); } if ($type == 'hook') { return $this->choose_actions(); } if ($type == 'import') { return $this->do_import(); } /*if ($type=='advanced_hook') return $this->advanced_choose_actions(); if ($type=='advanced_import') return $this->advanced_do_import();*/ return new ocp_tempcode(); }
/** * Standard modular run function. * * @return tempcode The result of execution. */ function run() { require_lang('notifications'); $title = get_page_title('NOTIFICATIONS_LOCKDOWN'); require_css('notifications'); require_javascript('javascript_notifications'); require_code('notifications'); require_code('notifications2'); require_all_lang(); $_notification_types = array(A__CHOICE => '_CHOICE', A__STATISTICAL => '_STATISTICAL'); $_notification_types = $_notification_types + _get_available_notification_types(); $lockdown = collapse_2d_complexity('l_notification_code', 'l_setting', $GLOBALS['SITE_DB']->query_select('notification_lockdown', array('*'))); $current_setting = mixed(); $notification_sections = array(); $hooks = find_all_hooks('systems', 'notifications'); foreach (array_keys($hooks) as $hook) { if (substr($hook, 0, 4) == 'ocf_' && get_forum_type() != 'ocf') { continue; } require_code('hooks/systems/notifications/' . $hook); $ob = object_factory('Hook_Notification_' . $hook); $_notification_codes = $ob->list_handled_codes(); foreach ($_notification_codes as $notification_code => $notification_details) { $allowed_setting = $ob->allowed_settings($notification_code); $current_setting = array_key_exists($notification_code, $lockdown) ? $lockdown[$notification_code] : NULL; $notification_types = array(); $save_query = false; foreach ($_notification_types as $possible => $ntype) { $save_query = $save_query || post_param_integer('notification_' . $notification_code . '_' . $ntype, 0) == 1; } foreach ($_notification_types as $possible => $ntype) { $available = $possible == A__CHOICE || $possible == A__STATISTICAL || ($possible & $allowed_setting) != 0; if ($save_query) { $checked = false; // Will strictly read from POST } else { if (is_null($current_setting)) { $checked = $possible == A__CHOICE; } else { if ($possible == A__STATISTICAL) { $checked = $current_setting == A__STATISTICAL; } elseif ($possible == A__CHOICE) { $checked = false; } elseif ($current_setting == -1) { $checked = false; } else { $checked = ($possible & $current_setting) != 0; } } } $_checked = post_param_integer('notification_' . $notification_code . '_' . $ntype, strtoupper(ocp_srv('REQUEST_METHOD')) != 'POST' && $checked ? 1 : 0); $notification_types[] = array('NTYPE' => $ntype, 'LABEL' => do_lang_tempcode('ENABLE_NOTIFICATIONS_' . $ntype), 'CHECKED' => $_checked == 1, 'RAW' => strval($possible), 'AVAILABLE' => $available, 'SCOPE' => $notification_code); } if (!isset($notification_sections[$notification_details[0]])) { $notification_sections[$notification_details[0]] = array('NOTIFICATION_SECTION' => $notification_details[0], 'NOTIFICATION_CODES' => array()); } $notification_sections[$notification_details[0]]['NOTIFICATION_CODES'][] = array('NOTIFICATION_CODE' => $notification_code, 'NOTIFICATION_LABEL' => $notification_details[1], 'NOTIFICATION_TYPES' => $notification_types, 'SUPPORTS_CATEGORIES' => false, 'PRIVILEGED' => !$ob->member_could_potentially_enable($ntype, $GLOBALS['FORUM_DRIVER']->get_guest_id())); } } // Save if (strtoupper(ocp_srv('REQUEST_METHOD')) == 'POST') { $GLOBALS['SITE_DB']->query_delete('notification_lockdown'); foreach ($notification_sections as $notification_section) { foreach ($notification_section['NOTIFICATION_CODES'] as $notification_code) { $new_setting = A_NA; foreach ($notification_code['NOTIFICATION_TYPES'] as $notification_type) { $ntype = $notification_type['NTYPE']; if (post_param_integer('notification_' . $notification_code['NOTIFICATION_CODE'] . '_' . $ntype, 0) == 1) { $new_setting = $new_setting | intval($notification_type['RAW']); } } if ($new_setting != A__CHOICE) { $GLOBALS['SITE_DB']->query_insert('notification_lockdown', array('l_notification_code' => substr($notification_code['NOTIFICATION_CODE'], 0, 80), 'l_setting' => $new_setting)); } } } attach_message(do_lang_tempcode('SUCCESS')); } // Sort labels global $M_SORT_KEY; $M_SORT_KEY = 'NOTIFICATION_LABEL'; ksort($notification_sections); foreach (array_keys($notification_sections) as $i) { usort($notification_sections[$i]['NOTIFICATION_CODES'], 'multi_sort'); } $css_path = get_custom_file_base() . '/themes/' . $GLOBALS['FORUM_DRIVER']->get_theme() . '/templates_cached/' . user_lang() . '/global.css'; $color = 'FF00FF'; if (file_exists($css_path)) { $tmp_file = file_get_contents($css_path); $matches = array(); if (preg_match('#\\nth[\\s,][^\\}]*\\sbackground-color:\\s*\\#([\\dA-Fa-f]*);#sU', $tmp_file, $matches) != 0) { $color = $matches[1]; } } $notification_types_titles = array(); foreach ($_notification_types as $possible => $ntype) { $notification_types_titles[] = array('NTYPE' => $ntype, 'LABEL' => do_lang_tempcode('ENABLE_NOTIFICATIONS_' . $ntype), 'RAW' => strval($possible)); } $interface = do_template('NOTIFICATIONS_MANAGE', array('SHOW_PRIVILEGES' => true, 'COLOR' => $color, 'NOTIFICATION_TYPES_TITLES' => $notification_types_titles, 'NOTIFICATION_SECTIONS' => $notification_sections)); return do_template('NOTIFICATIONS_MANAGE_SCREEN', array('TITLE' => $title, 'INTERFACE' => $interface, 'ACTION_URL' => get_self_url())); }