function testBotListInSync() { require_code('files'); $file_bots = better_parse_ini_file(get_file_base() . '/text/bots.txt'); ksort($file_bots); global $BOT_MAP; ksort($BOT_MAP); $this->assertTrue($BOT_MAP == $file_bots); }
/** * The UI to translate code. * * @return tempcode The UI */ function interface_code() { $lang = filter_naughty_harsh(get_param('lang', '')); $lang_new = get_param('lang_new', $lang); if ($lang_new != '') { require_code('type_validation'); if (!is_alphanumeric($lang_new, true)) { warn_exit(do_lang_tempcode('BAD_CODENAME')); } if (strlen($lang_new) > 5) { warn_exit(do_lang_tempcode('INVALID_LANG_CODE')); } $lang = $lang_new; } if ($lang == '') { $title = get_page_title('TRANSLATE_CODE'); $GLOBALS['HELPER_PANEL_TEXT'] = comcode_lang_string('DOC_FIND_LANG_STRING_TIP'); return $this->choose_lang($title, true, true, do_lang_tempcode('CHOOSE_EDIT_LIST_LANG_FILE')); } breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('CHOOSE')))); breadcrumb_set_self(do_lang_tempcode('TRANSLATE_CODE')); $base_lang = fallback_lang(); $map_a = get_file_base() . '/lang/langs.ini'; $map_b = get_custom_file_base() . '/lang_custom/langs.ini'; $search = get_param('search', '', true); if ($search != '') { $title = get_page_title('TRANSLATE_CODE'); require_code('form_templates'); $fields = new ocp_tempcode(); global $LANGUAGE; foreach ($LANGUAGE[user_lang()] as $key => $value) { if (strpos(strtolower($value), strtolower($search)) !== false) { $fields->attach(form_input_text($key, '', 'l_' . $key, str_replace('\\n', chr(10), $value), false)); } } if ($fields->is_empty()) { inform_exit(do_lang_tempcode('NO_ENTRIES')); } $post_url = build_url(array('page' => '_SELF', 'type' => '_code2'), '_SELF'); $hidden = new ocp_tempcode(); $hidden->attach(form_input_hidden('redirect', get_self_url(true))); $hidden->attach(form_input_hidden('lang', $lang)); return do_template('FORM_SCREEN', array('_GUID' => '2d7356fd2c4497ceb19450e65331c9c5', 'TITLE' => $title, 'HIDDEN' => $hidden, 'FIELDS' => $fields, 'URL' => $post_url, 'TEXT' => '', 'SUBMIT_NAME' => do_lang('TRANSLATE_CODE'))); } $lang_file = get_param('lang_file'); if (!file_exists($map_b)) { $map_b = $map_a; } $map = better_parse_ini_file($map_b); $title = get_page_title('_TRANSLATE_CODE', true, array(escape_html($lang_file), escape_html(array_key_exists($lang, $map) ? $map[$lang] : $lang))); // Upgrade to custom if not there yet (or maybe we are creating a new lang - same difference) $custom_dir = get_custom_file_base() . '/lang_custom/' . $lang; if (!file_exists($custom_dir)) { require_code('abstract_file_manager'); force_have_afm_details(); afm_make_directory('lang_custom/' . $lang, true); $cached_dir = get_custom_file_base() . '/lang_cached/' . $lang; if (!file_exists($cached_dir)) { afm_make_directory('lang_cached/' . $lang, true); } // Make comcode page dirs $zones = find_all_zones(); foreach ($zones as $zone) { $_special_dir = get_custom_file_base() . '/' . $zone . '/pages/comcode_custom/' . $lang; if (!file_exists($_special_dir)) { afm_make_directory($zone . ($zone == '' ? '' : '/') . 'pages/comcode_custom/' . $lang, true); } $_special_dir = get_custom_file_base() . '/' . $zone . '/pages/html_custom/' . $lang; if (!file_exists($_special_dir)) { afm_make_directory($zone . ($zone == '' ? '' : '/') . 'pages/html_custom/' . $lang, true); } } // Make templates_cached dirs require_code('themes2'); $themes = find_all_themes(); foreach (array_keys($themes) as $theme) { $_special_dir = get_custom_file_base() . '/themes/' . $theme . '/templates_cached/' . $lang; if (!file_exists($_special_dir)) { afm_make_directory('themes/' . $theme . '/templates_cached/' . $lang, true); } } } // Get some stuff $for_lang = get_lang_file_map($lang, $lang_file); $for_base_lang = get_lang_file_map($base_lang, $lang_file, true); $descriptions = get_lang_file_descriptions($base_lang, $lang_file); // Make our translation page $lines = ''; $intertrans = $this->get_intertran_conv($lang); $actions = new ocp_tempcode(); $next = 0; $trans_lot = ''; $delimit = chr(10) . '=-=-=-=-=-=-=-=-' . chr(10); foreach ($for_base_lang as $name => $old) { if (array_key_exists($name, $for_lang)) { $current = $for_lang[$name]; } else { $current = ''; //$this->find_lang_matches($old,$lang); Too slow / useless for code translation } if ($current == '' && strtolower($name) != $name) { $trans_lot .= str_replace('\\n', chr(10), str_replace(array('{', '}'), array('(((', ')))'), $old)) . $delimit; } } $translated_stuff = array(); if ($trans_lot != '' && $intertrans != '') { $result = http_download_file('http://translate.google.com/translate_t', NULL, false, false, 'ocPortal', array('text' => $trans_lot, 'langpair' => 'en|' . $intertrans)); if (!is_null($result)) { require_code('character_sets'); $result = convert_to_internal_encoding($result); $matches = array(); if (preg_match('#<div id=result_box dir="ltr">(.*)</div>#Us', convert_to_internal_encoding($result), $matches) != 0) { $result2 = $matches[1]; $result2 = @html_entity_decode($result2, ENT_QUOTES, get_charset()); $result2 = preg_replace('#\\s?<br>\\s?#', chr(10), $result2); $result2 = str_replace('> ', '>', str_replace(' <', ' <', str_replace('</ ', '</', str_replace(array('(((', ')))'), array('{', '}'), $result2)))); $translated_stuff = explode(trim($delimit), $result2 . chr(10)); } } } foreach ($for_base_lang + $for_lang as $name => $old) { if (array_key_exists($name, $for_lang)) { $current = $for_lang[$name]; } else { $current = ''; //$this->find_lang_matches($old,$lang); Too slow / useless for code translation } $description = array_key_exists($name, $descriptions) ? $descriptions[$name] : ''; if ($current == '' && strtolower($name) != $name && array_key_exists($next, $translated_stuff)) { $_current = ''; $translate_auto = trim($translated_stuff[$next]); $next++; } else { $_current = str_replace('\\n', chr(10), $current); $translate_auto = NULL; } if ($_current == '') { $_current = str_replace('\\n', chr(10), $old); } if ($intertrans != '' && get_value('google_translate_api_key') !== NULL) { $actions = do_template('TRANSLATE_ACTION', array('_GUID' => '9e9a68cb2c1a1e23a901b84c9af2280b', 'LANG_FROM' => get_site_default_lang(), 'LANG_TO' => $lang, 'NAME' => 'trans_' . $name, 'OLD' => $_current)); } $temp = do_template('TRANSLATE_LINE', array('_GUID' => '9cb331f5852ee043e6ad30b45aedc43b', 'TRANSLATE_AUTO' => $translate_auto, 'DESCRIPTION' => $description, 'NAME' => $name, 'OLD' => str_replace('\\n', chr(10), $old), 'CURRENT' => $_current, 'ACTIONS' => $actions)); $lines .= $temp->evaluate(); } $url = build_url(array('page' => '_SELF', 'type' => '_code', 'lang_file' => $lang_file, 'lang' => $lang), '_SELF'); return do_template('TRANSLATE_SCREEN', array('_GUID' => 'b3429f8bd0b4eb79c33709ca43e3207c', 'PAGE' => $lang_file, 'INTERTRANS' => get_value('google_translate_api_key') !== NULL ? $intertrans : '', 'LANG' => $lang, 'LINES' => $lines, 'TITLE' => $title, 'URL' => $url)); }
/** * Get an array listing all the themes present. * * @param boolean Whether to gather full details for each theme * @return array A map of all themes (name=>title) OR if requested a map of theme name to full theme details */ function find_all_themes($full_details = false) { if ($GLOBALS['IN_MINIKERNEL_VERSION'] == 1) { return $full_details ? array('default' => array()) : array('default' => do_lang('DEFAULT')); } require_code('files'); $themes = array(); $_dir = opendir(get_file_base() . '/themes/'); while (false !== ($file = readdir($_dir))) { $ini_file = get_file_base() . '/themes/' . $file . '/theme.ini'; if (strpos($file, '.') === false && is_dir(get_file_base() . '/themes/' . $file) && file_exists($ini_file)) { $details = better_parse_ini_file($ini_file); if (!array_key_exists('title', $details)) { $details['title'] = '?'; } if (!array_key_exists('description', $details)) { $details['description'] = '?'; } if (!array_key_exists('author', $details)) { $details['author'] = '?'; } $themes[$file] = $full_details ? $details : $details['title']; } } closedir($_dir); if (get_custom_file_base() != get_file_base()) { $_dir = opendir(get_custom_file_base() . '/themes/'); while (false !== ($file = readdir($_dir))) { $ini_file = get_custom_file_base() . '/themes/' . $file . '/theme.ini'; if (strpos($file, '.') === false && is_dir(get_custom_file_base() . '/themes/' . $file) && file_exists($ini_file)) { $details = better_parse_ini_file($ini_file); if (!array_key_exists('title', $details)) { $details['title'] = '?'; } if (!array_key_exists('description', $details)) { $details['description'] = '?'; } if (!array_key_exists('author', $details)) { $details['author'] = '?'; } $themes[$file] = $full_details ? $details : $details['title']; } } closedir($_dir); } if (!array_key_exists('default', $themes)) { $details = better_parse_ini_file(get_file_base() . '/themes/default/theme.ini'); if (!array_key_exists('title', $details)) { $details['title'] = '?'; } if (!array_key_exists('description', $details)) { $details['description'] = '?'; } if (!array_key_exists('author', $details)) { $details['author'] = '?'; } $themes['default'] = $full_details ? $details : $details['title']; } return $themes; }
$dh = opendir(get_custom_file_base() . '/exports/mods'); while (($file = readdir($dh)) !== false) { if (preg_match('#^theme-.*\\.tar$#', $file) != 0) { $from = get_custom_file_base() . '/exports/mods/' . $file; $new_file = basename($file, '.tar') . $version_for_name . '.tar'; $to = get_custom_file_base() . "/uploads/downloads/" . $new_file; @unlink($to); copy($from, $to); $addon_path = 'uploads/downloads/' . $new_file; $fsize = filesize($addon_path); $test = $GLOBALS['SITE_DB']->query_value_null_ok('download_downloads', 'url', array('url' => $addon_path)); if (is_null($test)) { require_code('tar'); $tar = tar_open($from, 'rb'); $info_file = tar_get_file($tar, 'mod.inf', true); $info = better_parse_ini_file(NULL, $info_file['data']); tar_close($tar); $name = $info['name']; $description = str_replace('\\n', "\n", $info['description']); $author = $info['author']; $url = "data_custom/addon_screenshots/" . preg_replace('#^theme-#', 'theme__', preg_replace('#\\d+$#', '', basename($file, '.tar'))) . ".png"; if (!file_exists(get_custom_file_base() . '/' . $url)) { $url = "data_custom/addon_screenshots/" . strtolower(preg_replace('#^theme-#', 'theme__', preg_replace('#\\d+$#', '', basename($file, '.tar')))) . ".png"; } $downid = add_download($cid, $name, $addon_path, $description, $author, '', NULL, 1, 1, 2, 1, '', $new_file, $fsize, 0, 0, NULL, NULL, 0, 0, $admin); if (file_exists(get_custom_file_base() . '/' . $url)) { add_image('', 'download_' . strval($downid), '', str_replace(' ', '%20', $url), '', 1, 0, 0, 0, '', NULL, NULL, NULL, 0); } } } }
/** * Generate a logo from the template. * * @param string The site name. * @param string The site slogan. * @param boolean Whether to output the logo to the browser, destroy then image, and exit the script (i.e. never returns) * @param ?string The theme to use the logo template from (NULL: default root zone theme). * @param string The logo img file to base upon. * @return resource The image resource. */ function generate_logo($name, $slogan, $raw = false, $theme = NULL, $use = 'logo-template') { require_code('character_sets'); if (is_null($theme)) { $theme = $GLOBALS['SITE_DB']->query_value('zones', 'zone_theme', array('zone_name' => '')); if ($theme == '' || $theme == '-1') { $theme = 'default'; } } $logo_wizard_details = array(); if ($theme != 'default') { $ini_path = get_custom_file_base() . '/themes/' . filter_naughty($theme) . '/theme.ini'; if (file_exists($ini_path)) { $logo_wizard_details += better_parse_ini_file($ini_path); } } $ini_path = get_file_base() . '/themes/default/theme.ini'; $logo_wizard_details += better_parse_ini_file($ini_path); $logo_url = $GLOBALS['SITE_DB']->query_value_null_ok('theme_images', 'path', array('theme' => $theme, 'id' => $use)); if (!is_null($logo_url)) { $file_path_stub = convert_url_to_path($logo_url); } if (is_null($logo_url) || !file_exists($file_path_stub)) { $logo_url = find_theme_image($use, false, false, $theme); } else { if (url_is_local($logo_url)) { $logo_url = (strpos($logo_url, 'themes/default/') !== false ? get_base_url() : get_custom_base_url()) . '/' . $logo_url; } } $file_path_stub = convert_url_to_path($logo_url); if (!is_null($file_path_stub)) { if (!file_exists($file_path_stub)) { $file_path_stub = get_file_base() . '/themes/default/images/trimmed-logo-template.png'; } // Exceptional situation. Maybe theme got corrupted? $data = file_get_contents($file_path_stub); } else { $data = http_download_file($logo_url); } $img = imagecreatefromstring($data); if ($img === false) { warn_exit(do_lang_tempcode('CORRUPT_FILE', escape_html($logo_url))); } $ttf_font = get_file_base() . '/data/fonts/Vera.ttf'; if (!function_exists('imagettftext') || !array_key_exists('FreeType Support', gd_info()) || !file_exists($ttf_font) || @imagettfbbox(26.0, 0.0, get_file_base() . '/data/fonts/Vera.ttf', 'test') === false) { $font = intval($logo_wizard_details['site_name_font_size_small_non_ttf']); $font_width = imagefontwidth($font) * strlen($name); $font_height = imagefontheight($font); } else { list(, , $font_width, , , , , $font_height) = imagettfbbox(26.0, 0.0, $ttf_font, foxy_utf8_to_nce($name)); $font_height = max($font_height, -$font_height); } $white = imagecolorallocate($img, hexdec(substr($logo_wizard_details['site_name_colour'], 0, 2)), hexdec(substr($logo_wizard_details['site_name_colour'], 2, 2)), hexdec(substr($logo_wizard_details['site_name_colour'], 4, 2))); $black = imagecolorallocate($img, 0, 0, 0); $matches = array(); if (file_exists(get_custom_file_base() . '/themes/' . $theme . '/css_custom/global.css')) { $css_file = file_get_contents(get_custom_file_base() . '/themes/' . $theme . '/css_custom/global.css'); } else { $css_file = file_get_contents(get_file_base() . '/themes/default/css/global.css'); } if (preg_match('/#(\\w\\w)(\\w\\w)(\\w\\w); \\/\\* \\{\\$,wizard, 100% medborder.border}/', $css_file, $matches) != 0) { $blue = imagecolorallocate($img, hexdec($matches[1]), hexdec($matches[2]), hexdec($matches[3])); } else { $blue = imagecolorallocate($img, hexdec(substr($logo_wizard_details['slogan_colour'], 0, 2)), hexdec(substr($logo_wizard_details['slogan_colour'], 2, 2)), hexdec(substr($logo_wizard_details['slogan_colour'], 4, 2))); } $do = array(array($slogan, intval($logo_wizard_details['slogan_x_offset']), intval($logo_wizard_details['slogan_y_offset']), intval($logo_wizard_details['slogan_font_size']), $ttf_font, $white)); if ($font_width > intval($logo_wizard_details['site_name_split']) && strpos($name, ' ') !== false) { if (function_exists('imagettftext') && array_key_exists('FreeType Support', gd_info()) && file_exists($ttf_font) && @imagettfbbox(26.0, 0.0, get_file_base() . '/data/fonts/Vera.ttf', 'test') !== false) { list(, , $font_width, , , , , $font_height) = imagettfbbox(floatval($logo_wizard_details['site_name_font_size_small']), 0.0, $ttf_font, foxy_utf8_to_nce($name)); $font_height = max($font_height, -$font_height); } $bits = explode(' ', $name); $a = ''; $b = ''; foreach ($bits as $bit) { if (strlen($a) < intval(round(floatval(strlen($name)) / 2.0))) { $a .= $bit . ' '; } else { $b .= $bit . ' '; } } $do[] = array($a, intval($logo_wizard_details['site_name_x_offset']), intval($logo_wizard_details['site_name_y_offset_small']) + $font_height, intval($logo_wizard_details['site_name_font_size_small']), $ttf_font, $blue); $do[] = array($b, intval($logo_wizard_details['site_name_x_offset']), intval($logo_wizard_details['site_name_y_offset_small']) + $font_height * 2 + intval($logo_wizard_details['site_name_split_gap']), intval($logo_wizard_details['site_name_font_size_small']), $ttf_font, $blue); } elseif ($font_width > intval($logo_wizard_details['site_name_split'])) { if (function_exists('imagettftext') && array_key_exists('FreeType Support', gd_info()) && file_exists($ttf_font) && @imagettfbbox(26.0, 0.0, get_file_base() . '/data/fonts/Vera.ttf', 'test') !== false) { list(, , $font_width, , , , , $font_height) = imagettfbbox(floatval($logo_wizard_details['site_name_font_size_small']), 0.0, $ttf_font, foxy_utf8_to_nce($name)); $font_height = max($font_height, -$font_height); } $do[] = array($name, intval($logo_wizard_details['site_name_x_offset']), intval($logo_wizard_details['site_name_y_offset']) + $font_height, intval($logo_wizard_details['site_name_font_size_small']), $ttf_font, $blue); } else { $do[] = array($name, intval($logo_wizard_details['site_name_x_offset']), intval($logo_wizard_details['site_name_y_offset']) + $font_height, floatval($logo_wizard_details['site_name_font_size']), $ttf_font, $blue); } foreach ($do as $i => $doing) { //if ($i==1) continue; if (function_exists('imagettftext') && array_key_exists('FreeType Support', gd_info()) && file_exists($doing[4]) && @imagettfbbox(26.0, 0.0, get_file_base() . '/data/fonts/Vera.ttf', 'test') !== false) { imagettftext($img, (double) $doing[3], 0.0, $doing[1], $doing[2], $doing[5], $doing[4], foxy_utf8_to_nce($doing[0])); } else { imagestring($img, $doing[3] == intval($logo_wizard_details['site_name_font_size_small']) ? intval($logo_wizard_details['site_name_font_size_nonttf']) : $font, $doing[1], $doing[2] - 11, $doing[0], $doing[5]); } } if ($raw) { header('Content-type: image/png'); /*if (strstr(ocp_srv('HTTP_USER_AGENT'),'MSIE')!==false) header('Content-Disposition: filename="-logo.png"'); else header('Content-Disposition: attachment; filename="-logo.png"');*/ imagepng($img); imagedestroy($img); exit; } return $img; }
/** * Try to find the theme that the logged-in/guest member is using, and map it to an ocPortal theme. * The themes/map.ini file functions to provide this mapping between forum themes, and ocPortal themes, and has a slightly different meaning for different forum drivers. For example, some drivers map the forum themes theme directory to the ocPortal theme name, whilst others made the humanly readeable name. * * @param boolean Whether to avoid member-specific lookup * @return ID_TEXT The theme */ function _get_theme($skip_member_specific = false) { $def = ''; // Load in remapper $map = file_exists(get_file_base() . '/themes/map.ini') ? better_parse_ini_file(get_file_base() . '/themes/map.ini') : array(); if (!$skip_member_specific) { // Work out $member = get_member(); if ($member != $this->get_guest_id()) { $skin = $this->connection->query_value_null_ok('users', 'user_theme', array('user_id' => $member)); } else { $skin = ''; } if (strlen($skin) > 0) { $def = array_key_exists($skin, $map) ? $map[$skin] : $skin; } } // Look for a skin according to our site name (we bother with this instead of 'default' because ocPortal itself likes to never choose a theme when forum-theme integration is on: all forum [via map] or all ocPortal seems cleaner, although it is complex) if (!(strlen($def) > 0) || !file_exists(get_custom_file_base() . '/themes/' . $def)) { if (@chdir(get_forum_base_url() . '/themes/' . get_site_name() . '/')) { $wowbb = get_site_name(); $def = array_key_exists($wowbb, $map) ? $map[$wowbb] : $wowbb; } } // Hmm, just the very-default then if (!(strlen($def) > 0) || !file_exists(get_custom_file_base() . '/themes/' . $def)) { $def = array_key_exists('default', $map) ? $map['default'] : 'default'; } return $def; }
/** * Get a nice formatted XHTML listed language selector. * * @param ?LANGUAGE_NAME The language to have selected by default (NULL: uses the current language) * @param boolean Whether to show languages that have no language details currently defined for them * @return tempcode The language selector */ function _nice_get_langs($select_lang = NULL, $show_unset = false) { global $LANGS_MAP; if ($LANGS_MAP === NULL) { $map_a = get_file_base() . '/lang/langs.ini'; $map_b = get_custom_file_base() . '/lang_custom/langs.ini'; if (!is_file($map_b)) { $map_b = $map_a; } $LANGS_MAP = better_parse_ini_file($map_b); } $langs = new ocp_tempcode(); $_langs = find_all_langs(); if (is_null($select_lang)) { $select_lang = user_lang(); } foreach (array_keys($_langs) as $lang) { $langs->attach(form_input_list_entry($lang, $lang == $select_lang, array_key_exists($lang, $LANGS_MAP) ? $LANGS_MAP[$lang] : $lang)); } if ($show_unset) { asort($LANGS_MAP); foreach ($LANGS_MAP as $lang => $full) { if (!array_key_exists($lang, $_langs)) { $_full = make_string_tempcode($full); $_full->attach(do_lang_tempcode('_UNSET')); $langs->attach(form_input_list_entry($lang, false, protect_from_escaping($_full))); } } } return $langs; }
/** * Third installation step. * * @return tempcode Progress report / UI */ function step_3() { if (count($_POST) == 0) { exit(do_lang('INST_POST_ERROR')); } global $LANG; // Call home, if they asked to $advertise_on = array_key_exists('advertise_on', $_POST) ? intval($_POST['advertise_on']) : 0; $email = $_POST['email']; if ($email == do_lang('EMAIL_ADDRESS')) { $email = ''; } if ($email != '' || $advertise_on == 1) { $call = '/join_hook.php?url=' . urlencode('http://' . ocp_srv('HTTP_HOST') . ocp_srv('REQUEST_URI')) . '&email=' . urlencode($email) . '&interest_level=' . $_POST['interest_level'] . '&advertise_on=' . strval($advertise_on) . '&lang=' . $LANG; $errno = 0; $errstr = ''; $mysock = @fsockopen('ocportal.com', 80, $errno, $errstr, 6.0); if ($mysock !== false) { $out = "GET " . $call . " HTTP/1.1\r\n"; $out .= "Host: ocportal.com\r\n"; $out .= "Connection: Close\r\n\r\n"; @fwrite($mysock, $out); @fclose($mysock); } } // Forum chooser $forums = get_dir_contents('sources/forum', true); unset($forums['none']); ksort($forums); $forums = array_merge(array('none' => 1), $forums); $forum_info = better_parse_ini_file(get_file_base() . '/sources/forum/forums.ini'); $tforums = new ocp_tempcode(); $classes = array(); foreach (array_keys($forums) as $forum) { $class = array_key_exists($forum . '_class', $forum_info) ? $forum_info[$forum . '_class'] : 'general'; $classes[$class][] = $forum; } global $DEFAULT_FORUM; if (file_exists(get_file_base() . '/info.php') && filesize(get_file_base() . '/info.php') != 0) { require_once get_file_base() . '/info.php'; global $SITE_INFO; if (array_key_exists('forum_type', $SITE_INFO)) { $DEFAULT_FORUM = $SITE_INFO['forum_type']; } } $default_version = new ocp_tempcode(); /*foreach ($classes as $class=>$forums) { foreach ($forums as $forum) { if (strpos(get_file_base(),'/'.$forum.'/')!==false) $DEFAULT_FORUM=$forum; } }*/ $simple_forums = new ocp_tempcode(); // For is JS is off, this is a simple flat list of all versions (rather than a two level list - with first level being $tforums and the second level being filtered using CSS 'display' from $versions) foreach ($classes as $class => $forums) { if (trim($class) == '') { continue; } $mapped_name = do_lang('FORUM_CLASS_' . $class, NULL, NULL, NULL, NULL, false); if (is_null($mapped_name)) { $mapped_name = ucwords($class); } $versions = new ocp_tempcode(); $first = true; $forums = array_reverse($forums); $rec = in_array($DEFAULT_FORUM, $forums); foreach ($forums as $forum) { if ($class == 'general') { $version = $forum; } else { $version = array_key_exists($forum . '_version', $forum_info) ? do_lang('VERSION_NUM', $forum_info[$forum . '_version']) : do_lang('NA'); } $extra2 = ''; //(($first && !$rec) || $rec)?'checked="checked"':''; $versions->attach(do_template('INSTALLER_FORUM_CHOICE_VERSION', array('_GUID' => '159a5a7cd1397620ef34e98c3b06cd7f', 'IS_DEFAULT' => $DEFAULT_FORUM == $forum || $first && !$rec, 'CLASS' => $class, 'NAME' => $forum, 'VERSION' => $version, 'EXTRA' => $extra2))); $first = false; $simple_forums->attach(do_template('INSTALLER_FORUM_CHOICE_VERSION', array('_GUID' => 'c4c0e7accab56ae45e8e1a4ff777c42b', 'IS_DEFAULT' => $DEFAULT_FORUM == $forum || $first && !$rec, 'CLASS' => $class, 'NAME' => $forum, 'VERSION' => $mapped_name . ' ' . $version, 'EXTRA' => ''))); } if ($rec) { $default_version = $versions; } $extra = $rec ? 'checked="checked"' : ''; $tforums->attach(do_template('INSTALLER_FORUM_CHOICE', array('_GUID' => 'a5460829e86c9da3637f8e566cfca63c', 'CLASS' => $class, 'REC' => $rec, 'TEXT' => $mapped_name, 'VERSIONS' => $versions, 'EXTRA' => $extra))); } // Database chooser $databases = array_merge(get_dir_contents('sources/database', true), get_dir_contents('sources_custom/database', true)); ksort($databases); $database_names = better_parse_ini_file(get_file_base() . '/sources/database/database.ini'); $tdatabase = new ocp_tempcode(); foreach (array_keys($databases) as $database) { if (count($databases) == 1 && $database == 'xml') { continue; } // If they only have experimental XML option, they'll choose it - we don't want that - we want them to get the error if ($database == 'mysqli' && !function_exists('mysqli_connect')) { continue; } if ($database == 'mysql_dbx' && !function_exists('dbx_connect')) { continue; } if ($database == 'mysql' && !function_exists('mysql_connect')) { continue; } if ($database == 'access' && !function_exists('odbc_connect')) { continue; } if ($database == 'ibm' && !function_exists('odbc_connect')) { continue; } if ($database == 'oracle' && !function_exists('ocilogon')) { continue; } if ($database == 'postgresql' && !function_exists('pg_connect')) { continue; } if ($database == 'sqlite' && !function_exists('sqlite_popen')) { continue; } if ($database == 'sqlserver' && !function_exists('mssql_connect') && !function_exists('sqlsrv_connect')) { continue; } if (array_key_exists($database, $database_names)) { $mapped_name = $database_names[$database]; } else { $mapped_name = $database; } $tdatabase->attach(do_template('FORM_SCREEN_INPUT_LIST_ENTRY', array('SELECTED' => $database == 'mysql', 'DISABLED' => false, 'NAME' => $database, 'CLASS' => '', 'TEXT' => $mapped_name))); } if ($tdatabase->is_empty()) { warn_exit(do_lang_tempcode('NO_PHP_DB')); } $js = do_template('JAVASCRIPT'); $js->attach(chr(10)); $js->attach(do_template('JAVASCRIPT_AJAX')); $hidden = build_keep_post_fields(); return do_template('INSTALLER_STEP_3', array('_GUID' => 'af52ecea73e9a8e2a92c12adbabbf4ab', 'JS' => $js, 'HIDDEN' => $hidden, 'SIMPLE_FORUMS' => $simple_forums, 'FORUM_PATH_DEFAULT' => get_file_base() . DIRECTORY_SEPARATOR . 'forums', 'FORUMS' => $tforums, 'DATABASES' => $tdatabase, 'VERSION' => $default_version)); }
require_code('files2'); $themes = find_all_themes(); $page_files = get_directory_contents(get_custom_file_base() . '/', ''); foreach (array_keys($themes) as $theme) { if ($only !== NULL && $only !== $theme) { continue; } if ($theme == 'default') { continue; } $name = ''; $description = ''; $author = 'ocProducts'; $ini_file = ($theme == 'default' ? get_file_base() : get_custom_file_base()) . '/themes/' . filter_naughty($theme) . '/theme.ini'; if (file_exists($ini_file)) { $details = better_parse_ini_file($ini_file); if (array_key_exists('title', $details)) { $name = $details['title']; } if (array_key_exists('description', $details)) { $description = $details['description']; } if (array_key_exists('author', $details) && $details['author'] != 'admin') { $author = $details['author']; } } $file = 'theme-' . preg_replace('#^[\\_\\.\\-]#', 'x', preg_replace('#[^\\w\\.\\-]#', '_', $theme)) . $version_for_name . '.tar'; $files2 = array(); $theme_files = get_directory_contents(get_custom_file_base() . '/themes/' . $theme, 'themes/' . $theme); foreach ($theme_files as $file2) { if (substr($file2, -4) != '.tcp' && substr($file2, -4) != '.tcd' && substr($file2, -9) != '.editfrom') {
/** * Get the full name of a language. e.g. 'EN' would become 'English' * * @param LANGUAGE_NAME The language * @return string The full name of the language */ function lookup_language_full_name($code) { global $LANGS_MAP; if ($LANGS_MAP === NULL) { $map_file_a = get_file_base() . '/lang/langs.ini'; $map_file_b = get_custom_file_base() . '/lang_custom/langs.ini'; if (!is_file($map_file_b)) { $map_file_b = $map_file_a; } $LANGS_MAP = better_parse_ini_file($map_file_b); } return isset($LANGS_MAP[$code]) ? $LANGS_MAP[$code] : $code; }
/** * Get information for the user relating to an addon that they are intending to install. * * @param string Filename of the addon TAR file * @param ?array List of addons that we're currently uninstalling (so dependencies from these are irrelevant). (NULL: none) * @param ?array List of addons that we're currently installing (so dependencies to these are irrelevant). (NULL: none) * @return array Triple: warnings, files, addon info array */ function inform_about_addon_install($file, $also_uninstalling = NULL, $also_installing = NULL) { if (is_null($also_uninstalling)) { $also_uninstalling = array(); } if (is_null($also_installing)) { $also_installing = array(); } $full = get_custom_file_base() . '/imports/mods/' . $file; // Look in the tar require_code('tar'); if (!file_exists($full)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } $tar = tar_open($full, 'rb'); $directory = tar_get_directory($tar); $info_file = tar_get_file($tar, 'mod.inf'); if (is_null($info_file)) { warn_exit(do_lang_tempcode('NOT_ADDON')); } $info = better_parse_ini_file(NULL, $info_file['data']); $addon = $info['name']; $php = false; $overwrite = new ocp_tempcode(); $dirs = array(); $files = new ocp_tempcode(); $files_warnings = new ocp_tempcode(); global $M_SORT_KEY; $M_SORT_KEY = 'path'; usort($directory, 'multi_sort'); foreach ($directory as $i => $entry) { if ($entry['path'] == 'mod.inf') { continue; } if ($entry['path'] == 'mod.php') { continue; } if (substr($entry['path'], -1) == '/') { continue; } $data = strtolower(substr($entry['path'], -4, 4)) == '.tpl' ? tar_get_file($tar, $entry['path'], true) : NULL; // .php? if (strtolower(substr($entry['path'], -4, 4)) == '.php' || !is_null($data) && (strpos($data['data'], '{+START,PHP') !== false || strpos($data['data'], '<' . '?php') !== false)) { $php = true; $this_php = true; } else { $this_php = false; } // chmod? $pos = strrpos($entry['path'], '/'); if ($pos !== false) { $dirs[substr($entry['path'], 0, $pos)] = 1; } else { $dirs[''] = 1; } // overwrite? if (file_exists(get_file_base() . '/' . $entry['path'])) { if (!$overwrite->is_empty()) { $overwrite->attach(do_lang_tempcode('LIST_SEP')); } $overwrite->attach(escape_html($entry['path'][0] == '/' ? substr($entry['path'], 1) : $entry['path'])); $this_overwrite = true; } else { $this_overwrite = false; } // Comcode? if (strtolower(substr($entry['path'], -4, 4)) == '.txt' && strpos($entry['path'], 'pages/comcode') !== false) { $this_comcode_page = true; } else { $this_comcode_page = false; } // Template if ($this_comcode_page) { $files_warnings->attach(do_template('ADDON_INSTALL_FILES_WARNING', array('_GUID' => 'd0cf99f96262296df4afe2387f4cd3e8', 'I' => strval($i), 'PATH' => $entry['path'], 'ABOUT' => do_lang_tempcode('ADDON_FILE_IS_COMCODE_PAGE')))); } elseif ($this_overwrite) { $backup = substr($entry['path'], -4) == '.txt'; $files_warnings->attach(do_template('ADDON_INSTALL_FILES_WARNING', array('_GUID' => 'c62168dee316d8f73d20a0d70d41b1a4', 'I' => strval($i), 'PATH' => $entry['path'], 'ABOUT' => do_lang_tempcode($backup ? 'ADDON_FILE_WILL_OVERWRITE_BACKUP' : 'ADDON_FILE_WILL_OVERWRITE')))); } elseif ($this_php) { $files_warnings->attach(do_template('ADDON_INSTALL_FILES_WARNING', array('_GUID' => 'c0cf99f96262296df4afe2387f4cd3e8', 'I' => strval($i), 'PATH' => $entry['path'], 'ABOUT' => do_lang_tempcode('ADDON_FILE_IS_PHP')))); } else { $files->attach(do_template('ADDON_INSTALL_FILES', array('_GUID' => '74edcf396387c842cab5cfd0ab74b8f6', 'I' => strval($i), 'PATH' => $entry['path'], 'ABOUT' => do_lang_tempcode('ADDON_FILE_NORMAL')))); } } tar_close($tar); $chmod = new ocp_tempcode(); $root_chmod = false; foreach (array_keys($dirs) as $dir) { if (is_writable_wrap(get_file_base() . '/' . $dir) && file_exists(get_file_base() . '/' . $dir)) { if ($dir == '') { $root_chmod = true; continue; } if (!$chmod->is_empty()) { $chmod->attach(do_lang_tempcode('LIST_SEP')); } $chmod->attach(escape_html(do_lang('ROOT') . ($dir[0] != '/' ? '/' : '') . $dir)); } elseif (substr_count($dir, '/') == 1 && !file_exists(get_file_base() . '/' . $dir)) { $root_chmod = true; } } if ($root_chmod) { if (!$chmod->is_empty()) { $chmod->attach(', '); } $chmod->attach(do_lang('ROOT')); } // Check incompatibilities, and show general warning // NB: It's theoretically possible that there may be incompatibilities between two addons installing together, and we can't detect this (only incompatibilities for what is already installed). However it's very unlikely as multi-install is only really going to happen with official addons which have no such problems. $warnings = new ocp_tempcode(); if ($info['author'] != 'Core Team') { $warnings->attach(do_template('ADDON_INSTALL_WARNING', array('_GUID' => 'dd66b2c540908de60753a1ced73b8ac0', 'WARNING' => do_lang_tempcode('ADDON_WARNING_GENERAL')))); } $incompatibilities = collapse_1d_complexity('addon_name', $GLOBALS['SITE_DB']->query_select('addons_dependencies', array('addon_name'), array('addon_name_dependant_upon' => $addon, 'addon_name_incompatibility' => 1))); $_incompatibilities = new ocp_tempcode(); foreach ($incompatibilities as $in) { if (!$_incompatibilities->is_empty()) { $_incompatibilities->attach(do_lang_tempcode('LIST_SEP')); } $_incompatibilities->attach(escape_html($in)); } if (count($incompatibilities) != 0) { $warnings->attach(do_template('ADDON_INSTALL_WARNING', array('WARNING' => do_lang_tempcode('ADDON_WARNING_INCOMPATIBILITIES', $_incompatibilities)))); } // Check dependencies $_dependencies = explode(',', array_key_exists('dependencies', $info) ? $info['dependencies'] : ''); $dependencies = array(); foreach ($_dependencies as $dependency) { if ($dependency == '') { continue; } if (in_array($dependency . '.tar', $also_installing)) { continue; } if (in_array($dependency . '.tar', $also_uninstalling)) { $dependencies[] = $dependency; continue; } if (!has_feature($dependency)) { $dependencies[] = $dependency; } } $_dependencies_str = new ocp_tempcode(); foreach ($dependencies as $in) { if (!$_dependencies_str->is_empty()) { $_dependencies_str->attach(do_lang_tempcode('LIST_SEP')); } if (file_exists(get_custom_file_base() . '/imports/addons/' . $in . '.tar')) { $in_tpl = hyperlink(build_url(array('page' => 'admin_addons', 'type' => 'addon_install', 'file' => $in . '.tar'), get_module_zone('admin_addons')), $in, true, true); } else { $in_tpl = make_string_tempcode(escape_html($in)); } $_dependencies_str->attach($in_tpl); } if (count($dependencies) != 0) { if ($info['author'] == 'Core Team') { $post_fields = build_keep_post_fields(); foreach ($dependencies as $in) { $post_fields->attach(form_input_hidden('install_' . $in . '.tar', $in . '.tar')); } if (get_param('type', 'misc') == 'addon_install') { $post_fields->attach(form_input_hidden('install_' . $file, $file)); $url = static_evaluate_tempcode(build_url(array('page' => '_SELF', 'type' => 'multi_action'), '_SELF')); } else { $url = get_self_url(true); } warn_exit(do_lang_tempcode('_ADDON_WARNING_MISSING_DEPENDENCIES', $_dependencies_str->evaluate(), escape_html($addon), array(escape_html($url), $post_fields))); } else { $warnings->attach(do_template('ADDON_INSTALL_WARNING', array('WARNING' => do_lang_tempcode('ADDON_WARNING_MISSING_DEPENDENCIES', $_dependencies_str)))); } } // if (!$overwrite->is_empty()) $warnings->attach(do_template('ADDON_INSTALL_WARNING',array('_GUID'=>'fe40ed8192a452a835be4c0fde64406b','WARNING'=>do_lang_tempcode('ADDON_WARNING_OVERWRITE',escape_html($overwrite))))); if ($info['author'] != 'Core Team') { if ($php) { $warnings->attach(do_template('ADDON_INSTALL_WARNING', array('_GUID' => '8cf249a119d10b2e97fc94cb9981dcea', 'WARNING' => do_lang_tempcode('ADDON_WARNING_PHP')))); } } // if ($chmod!='') $warnings->attach(do_template('ADDON_INSTALL_WARNING',array('_GUID'=>'78121e40b9a26c2f33d09f7eee7b74be','WARNING'=>do_lan g_tempcode('ADDON_WARNING_CHMOD',escape_html($chmod))))); // Now uses AFM $files_combined = new ocp_tempcode(); $files_combined->attach($files_warnings); $files_combined->attach($files); return array($warnings, $files_combined, $info); }
/** * UI to choose a language. * * @param tempcode Title for the form * @param boolean Whether to give a tip about edit order * @param boolean Whether to add an 'all' entry to the list * @return mixed The UI (tempcode) or the language to use (string/LANGUAGE_NAME) */ function choose_language($title, $tip = false, $allow_all_selection = false) { if (!multi_lang()) { return user_lang(); } $lang = either_param('lang', NULL); if (!is_null($lang)) { return filter_naughty($lang); } if (!$tip) { $text = do_lang_tempcode('CHOOSE_LANG_DESCRIP'); } else { global $LANGS_MAP; if ($LANGS_MAP === NULL) { $map_a = get_file_base() . '/lang/langs.ini'; $map_b = get_custom_file_base() . '/lang_custom/langs.ini'; if (!is_file($map_b)) { $map_b = $map_a; } $LANGS_MAP = better_parse_ini_file($map_b); } $lang_name = get_site_default_lang(); if (array_key_exists($lang_name, $LANGS_MAP)) { $lang_name = $LANGS_MAP[$lang_name]; } $text = do_lang_tempcode('CHOOSE_LANG_DESCRIP_ADD_TO_MAIN_LANG_FIRST', escape_html($lang_name)); } $langs = new ocp_tempcode(); if ($allow_all_selection) { $langs->attach(form_input_list_entry('', false, do_lang_tempcode('_ALL'))); } $langs->attach(nice_get_langs()); require_code('form_templates'); $fields = form_input_list(do_lang_tempcode('LANGUAGE'), do_lang_tempcode('DESCRIPTION_LANGUAGE'), 'lang', $langs, NULL, true); $hidden = build_keep_post_fields(); $url = get_self_url(); return do_template('FORM_SCREEN', array('_GUID' => '1a2823d450237aa299c095bf9c689a2a', 'SKIP_VALIDATION' => true, 'HIDDEN' => $hidden, 'SUBMIT_NAME' => do_lang_tempcode('PROCEED'), 'TITLE' => $title, 'FIELDS' => $fields, 'URL' => $url, 'TEXT' => $text)); }
/** * The UI to export an addon (2). * * @return tempcode The UI */ function _addon_export() { $hidden = build_keep_post_fields(); $theme = get_param('theme', NULL, true); $title = get_page_title('EXPORT_ADDON'); // Default meta data $name = ''; $author = $GLOBALS['FORUM_DRIVER']->get_username(get_member()); $organisation = get_site_name(); $description = ''; // ... but the theme might already define some of this if (!is_null($theme)) { $ini_file = ($theme == 'default' ? get_file_base() : get_custom_file_base()) . '/themes/' . filter_naughty($theme) . '/theme.ini'; if (file_exists($ini_file)) { $details = better_parse_ini_file($ini_file); if (array_key_exists('title', $details)) { $name = $details['title']; } if (array_key_exists('description', $details)) { $description = $details['description']; } if (array_key_exists('author', $details)) { $author = $details['author']; } } } if (get_param('exp', 'custom') == 'lang') { $lang = post_param('lang'); $ini_file = get_custom_file_base() . '/lang_custom/langs.ini'; if (!file_exists($ini_file)) { $ini_file = get_file_base() . '/lang/langs.ini'; } if (file_exists($ini_file)) { $details = better_parse_ini_file($ini_file); if (array_key_exists($lang, $details)) { $name = $details[$lang]; $description = $details[$lang]; } } } $fields = ''; /*XHTMLXHTML*/ require_code('form_templates'); $field = form_input_line(do_lang_tempcode('NAME'), do_lang_tempcode('DESCRIPTION_NAME'), 'name', $name, true); $fields .= $field->evaluate(); $field = form_input_line(do_lang_tempcode('AUTHOR'), do_lang_tempcode('DESCRIPTION_AUTHOR'), 'author', $author, true); $fields .= $field->evaluate(); $field = form_input_line(do_lang_tempcode('ORGANISATION'), do_lang_tempcode('DESCRIPTION_ORGANISATION'), 'organisation', $organisation, false); $fields .= $field->evaluate(); $field = form_input_line(do_lang_tempcode('_VERSION'), do_lang_tempcode('DESCRIPTION_VERSION'), 'version', '1.0', true); $fields .= $field->evaluate(); $field = form_input_text(do_lang_tempcode('DESCRIPTION'), do_lang_tempcode('DESCRIPTION_DESCRIPTION'), 'description', $description, true); $fields .= $field->evaluate(); $field = form_input_line(do_lang_tempcode('DEPENDENCIES'), do_lang_tempcode('DESCRIPTION_DEPENDENCIES'), 'dependencies', '', false); $fields .= $field->evaluate(); $field = form_input_line(do_lang_tempcode('INCOMPATIBILITIES'), do_lang_tempcode('DESCRIPTION_INCOMPATIBILITIES'), 'incompatibilities', '', false); $fields .= $field->evaluate(); if (get_param('exp', 'custom') == 'theme') { $GLOBALS['HELPER_PANEL_TUTORIAL'] = 'tut_releasing_themes'; if (!is_null($theme)) { // Option for selecting exactly what files are used $field = do_template('FORM_SCREEN_FIELD_SPACER', array('SECTION_HIDDEN' => true, 'TITLE' => do_lang_tempcode('COUNT_FILES'))); $fields .= $field->evaluate(); $files = $this->do_dir('themes/' . $theme); $i = 0; foreach (array_keys($files) as $file) { $field = form_input_tick(str_replace(array('/', '_'), array('/ ', '_ '), preg_replace('#^themes/' . str_replace('#', '\\#', preg_quote($theme)) . '/#', '', $file)), '', 'file_' . strval($i), true, NULL, $file); $fields .= $field->evaluate(); $i++; } // Option for selecting Comcode pages require_lang('themes'); $field = do_template('FORM_SCREEN_FIELD_SPACER', array('SECTION_HIDDEN' => false, 'TITLE' => do_lang_tempcode('PAGES'), 'HELP' => do_lang_tempcode('THEME_ALSO_INCLUDE_PAGES'))); $fields .= $field->evaluate(); $files = $this->do_dir(''); ksort($files); $fields_after = ''; foreach (array_keys($files) as $file) { if (substr($file, 0, strlen($theme) + 2) == $theme . '__') { $file = substr($file, strlen($theme) + 2); } if (substr($file, -4) == '.txt' && strpos($file, '/comcode_custom/') !== false) { $matches = array(); if (preg_match('#^/((\\w+)/)?pages/comcode_custom/[^/]*/(\\w+)\\.txt$#', $file, $matches) != 0 && $matches[1] != 'docs' . strval(ocp_version())) { $auto_ticked = false; if ($matches[1] == '') { $auto_ticked = $matches[3] == 'start' || substr($matches[3], 0, 6) == 'panel_'; } $field = form_input_tick($matches[1] . ': ' . $matches[3], '', 'file_' . strval($i), $auto_ticked, NULL, $file); if ($auto_ticked) { $fields .= $field->evaluate(); } else { $fields_after .= $field->evaluate(); } $i++; } } } $fields .= $fields_after; } } $submit_name = do_lang_tempcode('EXPORT_ADDON'); $map = array('page' => '_SELF', 'type' => '__addon_export'); if (!is_null($theme)) { $_redirect = build_url(array('page' => 'admin_themes', 'type' => 'misc'), 'adminzone'); $redirect = $_redirect->evaluate(); $map['redirect'] = $redirect; $map['theme'] = $theme; } $post_url = build_url($map, '_SELF'); breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('ADDONS')), array('_SELF:_SELF:misc', do_lang_tempcode('EXPORT_ADDON')))); breadcrumb_set_self(do_lang_tempcode('CONFIRM')); return do_template('FORM_SCREEN', array('_GUID' => 'dd8bea111b0dfc7df7ddc7e2246f0ef9', 'HIDDEN' => $hidden, 'TITLE' => $title, 'SUBMIT_NAME' => $submit_name, 'FIELDS' => $fields, 'TEXT' => '', 'URL' => $post_url)); }
/** * Type-check the specified parameter (giving an error if the type checking fails) [just value against type] * * @param ID_TEXT The parameter type * @param string The functions name (used in error message) * @param string The parameter name (used in error message) * @param mixed The parameters value (cannot be null) * @param boolean Whether we just echo errors instead of exiting */ function test_fail_php_type_check($type, $function_name, $name, $value, $echo = false) { $null_allowed = $type[0] == '?'; $false_allowed = $type[0] == '~'; $_type = $null_allowed || $false_allowed ? substr($type, 1) : $type; if ($value === false && !$false_allowed && !in_array($_type, array('mixed', 'boolean'))) { fatal_exit(do_lang_tempcode('UNALLOWED_NULL', escape_html($name), escape_html($function_name), array('false'))); } if (is_null($value) && !$null_allowed) { fatal_exit(do_lang_tempcode('UNALLOWED_NULL', escape_html($name), escape_html($function_name), array('NULL'))); } if ($_type == 'mixed') { return; } switch ($_type) { case 'integer': if (!is_integer($value) && (!is_float($value) || strval(intval(round($value))) != strval($value))) { _fail_php_type_check($type, $function_name, $name, $value, $echo); } break; case 'UINTEGER': if (!is_integer($value) && (!is_float($value) || strval(intval(round($value))) != strval($value)) || $value < 0) { _fail_php_type_check($type, $function_name, $name, $value, $echo); } break; case 'resource': if (!is_resource($value)) { _fail_php_type_check($type, $function_name, $name, $value, $echo); } break; case 'object': if (!is_object($value)) { _fail_php_type_check($type, $function_name, $name, $value, $echo); } break; case 'tempcode': if (!is_object($value) || !is_a($value, 'ocp_tempcode')) { _fail_php_type_check($type, $function_name, $name, $value, $echo); } break; case 'REAL': case 'float': if (!is_float($value)) { _fail_php_type_check($type, $function_name, $name, $value, $echo); } break; case 'boolean': if (!is_bool($value)) { _fail_php_type_check($type, $function_name, $name, $value, $echo); } break; case 'list': if (!is_array($value)) { _fail_php_type_check($type, $function_name, $name, $value, $echo); } break; case 'map': if (!is_array($value)) { _fail_php_type_check($type, $function_name, $name, $value, $echo); } break; case 'array': if (!is_array($value)) { _fail_php_type_check($type, $function_name, $name, $value, $echo); } break; case 'string': if (!is_string($value)) { _fail_php_type_check($type, $function_name, $name, $value, $echo); } break; case 'PATH': if (!is_string($value)) { _fail_php_type_check($type, $function_name, $name, $value, $echo); } break; case 'MD5': if (!is_string($value) || strlen($value) > 33) { _fail_php_type_check($type, $function_name, $name, $value, $echo); } break; case 'EMAIL': if (!is_string($value) || is_valid_email_address($value)) { _fail_php_type_check($type, $function_name, $name, $value, $echo); } break; case 'URLPATH': if (!is_string($value) || strlen($value) > 127) { _fail_php_type_check($type, $function_name, $name, $value, $echo); } break; case 'LONG_TEXT': if (!is_string($value)) { _fail_php_type_check($type, $function_name, $name, $value, $echo); } break; case 'MINIID_TEXT': if (!is_string($value) || strlen($value) > 40) { _fail_php_type_check($type, $function_name, $name, $value, $echo); } break; case 'ID_TEXT': if (!is_string($value) || strlen($value) > 80) { _fail_php_type_check($type, $function_name, $name, $value, $echo); } break; case 'LANGUAGE_NAME': global $LANG_TD_MAP; if (is_null($LANG_TD_MAP)) { $LANG_TD_MAP = better_parse_ini_file(get_file_base() . '/lang/langs.ini'); } if (!is_string($value) || !array_key_exists($value, $LANG_TD_MAP)) { _fail_php_type_check($type, $function_name, $name, $value, $echo); } break; case 'IP': if (!is_string($value) || strlen($value) > 40 || strlen($value) < 7 && $value != '' || count(explode('.', $value)) != 4 && $value != '' && count(explode(':', $value)) < 3) { _fail_php_type_check($type, $function_name, $name, $value, $echo); } break; case 'SHORT_TEXT': if (!is_string($value) || strlen($value) > 255) { _fail_php_type_check($type, $function_name, $name, $value, $echo); } break; case 'SHORT_INTEGER': if (!is_integer($value) || $value > 255 || $value < 0) { _fail_php_type_check($type, $function_name, $name, $value, $echo); } break; case 'AUTO_LINK': if (!is_integer($value) || $value < -1) { _fail_php_type_check($type, $function_name, $name, $value, $echo); } // -1 means something different to NULL break; case 'BINARY': if (!is_integer($value) || $value != 0 && $value != 1) { _fail_php_type_check($type, $function_name, $name, $value, $echo); } break; case 'MEMBER': if (!is_integer($value) || $value < $GLOBALS['FORUM_DRIVER']->get_guest_id()) { _fail_php_type_check($type, $function_name, $name, $value, $echo); } break; case 'TIME': if (!is_integer($value) || $value > time() + 500000000 || $value < 1000) { _fail_php_type_check($type, $function_name, $name, $value, $echo); } break; } }
/** * Get the name of a webcrawler bot, or NULL if no bot detected * * @return ?string Webcrawling bot name (NULL: not a bot) */ function get_bot_type() { global $CACHE_BOT_TYPE; if ($CACHE_BOT_TYPE !== false) { return $CACHE_BOT_TYPE; } $agent = strtolower(ocp_srv('HTTP_USER_AGENT')); global $BOT_MAP, $SITE_INFO; if ($BOT_MAP === NULL) { if ((!isset($SITE_INFO['no_extra_bots']) || $SITE_INFO['no_extra_bots'] == '0') && is_file(get_file_base() . '/text_custom/bots.txt')) { require_code('files'); $BOT_MAP = better_parse_ini_file(get_file_base() . '/text_custom/bots.txt'); } else { $BOT_MAP = array('zyborg' => 'Looksmart', 'googlebot' => 'Google', 'teoma' => 'Teoma', 'scooter' => 'Altavista', 'jeeves' => 'Ask Jeeves', 'infoseek' => 'Infoseek', 'ultraseek' => 'Infoseek', 'ia_archiver' => 'Alexa/Archive.org', 'slurp' => 'Inktomi/Yahoo/Hot Bot', 'yahoo' => 'Yahoo/Overture', 'msnbot' => 'Bing', 'bingbot' => 'Bing', 'architextspider' => 'Excite', 'lycos' => 'Lycos', 'mercator' => 'Altavista', 'mantraagent' => 'LookSmart', 'wisenutbot' => 'Looksmart', 'paros' => 'Paros', 'sqworm' => 'Aol.com'); } } foreach ($BOT_MAP as $id => $name) { if ($name == '') { continue; } if (strpos($agent, $id) !== false) { $CACHE_BOT_TYPE = $name; return $name; } } if (strpos($agent, 'bot') !== false || strpos($agent, 'spider') !== false) { $to_a = strpos($agent, ' '); if ($to_a === false) { $to_a = strlen($agent); } $to_b = strpos($agent, '/'); if ($to_b === false) { $to_b = strlen($agent); } $CACHE_BOT_TYPE = substr($agent, 0, min($to_a, $to_b)); return $agent; } $CACHE_BOT_TYPE = NULL; return NULL; }
/** * The UI to edit/rename a theme. * * @return tempcode The UI */ function edit_theme() { $title = get_page_title('EDIT_THEME'); $theme = get_param('theme', false, true); $ini_file = ($theme == 'default' ? get_file_base() : get_custom_file_base()) . '/themes/' . $theme . '/theme.ini'; if (!file_exists($ini_file)) { warn_exit(do_lang('MISSING_RESOURCE') . ' [theme.ini]'); } $details = better_parse_ini_file($ini_file); if (!array_key_exists('title', $details)) { $details['title'] = '?'; } if (!array_key_exists('description', $details)) { $details['description'] = '?'; } if (!array_key_exists('author', $details)) { $details['author'] = '?'; } if (!array_key_exists('mobile_pages', $details)) { $details['mobile_pages'] = ''; } if (!array_key_exists('supports_wide', $details)) { $details['supports_wide'] = '1'; } $fields = $this->get_theme_fields($theme, $details['title'], $details['description'], $details['author'], $details['mobile_pages'], intval($details['supports_wide']), false); if ($theme != 'default') { $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('ACTIONS')))); $fields->attach(form_input_tick(do_lang_tempcode('COPY_THEME'), do_lang_tempcode('DESCRIPTION_COPY_THEME', escape_html($theme)), 'copy', false)); $fields->attach(form_input_tick(do_lang_tempcode('DELETE'), do_lang_tempcode('DESCRIPTION_DELETE'), 'delete', false)); } $post_url = build_url(array('page' => '_SELF', 'type' => '_edit_theme', 'old_theme' => $theme), '_SELF'); $submit_name = do_lang_tempcode('EDIT_THEME'); breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('THEMES')))); $javascript = 'var themee=document.getElementById(\'theme\'), themet=document.getElementById(\'title\'), copy=document.getElementById(\'copy\'); if (copy) copy.onchange=function() { if (copy.checked && themee.value.indexOf(\'-copy\')==-1) { themee.value+=\'-copy\'; themet.value+=\' copy\'; } };'; return do_template('FORM_SCREEN', array('_GUID' => '2734c55cd4d7cfa785d307d932ce8af1', 'JAVASCRIPT' => $javascript, 'HIDDEN' => '', 'TITLE' => $title, 'TEXT' => '', 'URL' => $post_url, 'FIELDS' => $fields, 'SUBMIT_NAME' => $submit_name)); }
/** * Try to find the theme that the logged-in/guest member is using, and map it to an ocPortal theme. * The themes/map.ini file functions to provide this mapping between forum themes, and ocPortal themes, and has a slightly different meaning for different forum drivers. For example, some drivers map the forum themes theme directory to the ocPortal theme name, whilst others made the humanly readeable name. * * @param boolean Whether to avoid member-specific lookup * @return ID_TEXT The theme */ function _get_theme($skip_member_specific = false) { $def = ''; // Load in remapper $map = file_exists(get_file_base() . '/themes/map.ini') ? better_parse_ini_file(get_file_base() . '/themes/map.ini') : array(); // Work out if (!$skip_member_specific) { $member = get_member(); if ($member > 0) { $skin = $this->get_member_row_field($member, 'user_theme'); } else { $skin = 0; } if ($skin > 0) { $user_theme = $this->connection->query("SELECT * FROM " . $this->connection->get_table_prefix() . "themes t LEFT JOIN " . $this->connection->get_table_prefix() . "theme_registry tr ON tr.thid =t.thid WHERE t.thid = " . strval($skin)); $user_theme = !empty($user_theme[0]) ? $user_theme[0] : ''; $user_theme = !empty($user_theme['user_theme']) ? $user_theme['user_theme'] : ''; if (!is_null($user_theme)) { $def = array_key_exists($user_theme, $map) ? $map[$user_theme] : $user_theme; } } } // Look for a skin according to our site name (we bother with this instead of 'default' because ocPortal itself likes to never choose a theme when forum-theme integration is on: all forum [via map] or all ocPortal seems cleaner, although it is complex) if (!(strlen($def) > 0) || !file_exists(get_custom_file_base() . '/themes/' . $def)) { $aeftheme = $this->connection->query_value_null_ok('themes', 'th_name', array('th_name' => get_site_name())); if (!is_null($aeftheme)) { $def = array_key_exists($aeftheme, $map) ? $map[$aeftheme] : $aeftheme; } } // Default then! if (!(strlen($def) > 0) || !file_exists(get_custom_file_base() . '/themes/' . $def)) { $def = array_key_exists('default', $map) ? $map['default'] : 'default'; } return $def; }
/** * 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)); }
/** * Try to find the theme that the logged-in/guest member is using, and map it to an ocPortal theme. * The themes/map.ini file functions to provide this mapping between forum themes, and ocPortal themes, and has a slightly different meaning for different forum drivers. For example, some drivers map the forum themes theme directory to the ocPortal theme name, whilst others made the humanly readeable name. * * @param boolean Whether to avoid member-specific lookup * @return ID_TEXT The theme */ function _get_theme($skip_member_specific = false) { $def = ''; // Load in remapper $map = file_exists(get_file_base() . '/themes/map.ini') ? better_parse_ini_file(get_file_base() . '/themes/map.ini') : array(); if (!$skip_member_specific) { // Work out $member = get_member(); if ($member > 0) { $skin = $this->get_member_row_field($member, 'skin'); } else { $skin = 0; } if ($skin > 0) { $ipb = $this->connection->query_value('skins', 'img_dir', array('sid' => $skin)); $def = array_key_exists($ipb, $map) ? $map[$ipb] : $ipb; } } // Look for a skin according to our site name (we bother with this instead of 'default' because ocPortal itself likes to never choose a theme when forum-theme integration is on: all forum [via map] or all ocPortal seems cleaner, although it is complex) if (!(strlen($def) > 0) || !file_exists(get_custom_file_base() . '/themes/' . $def)) { $ipb = $this->connection->query_value_null_ok('skins', 'img_dir', array('img_dir' => get_site_name())); if (!is_null($ipb)) { $def = array_key_exists($ipb, $map) ? $map[$ipb] : $ipb; } } // Hmm, just the very-default then if (!(strlen($def) > 0) || !file_exists(get_custom_file_base() . '/themes/' . $def)) { $ipb = $this->connection->query_value('skins', 'img_dir', array('default_set' => 1)); $def = array_key_exists($ipb, $map) ? $map[$ipb] : $ipb; } // Default then! if (!(strlen($def) > 0) || !file_exists(get_custom_file_base() . '/themes/' . $def)) { $def = array_key_exists('default', $map) ? $map['default'] : 'default'; } return $def; }
/** * Handle special page type output. * * @param ID_TEXT The special page type. * @set query templates tree lang * @param tempcode The normal script tempcode output * @param string The normal script evaluated output */ function special_page_types($special_page_type, &$out, $out_evaluated) { global $RECORDED_TEMPLATES_USED; if (function_exists('set_time_limit')) { @set_time_limit(280); } $echo = do_header(); //$echo->evaluate_echo(); $echo2 = new ocp_tempcode(); if (is_null($out_evaluated)) { ob_start(); $out->evaluate_echo(); // False evaluation ob_end_clean(); } // HACKHACK: Yuck. we have to after-the-fact make it wide, and empty lots of internal caching to reset the state. $_GET['wide_high'] = '1'; $_GET['wide'] = '1'; $GLOBALS['LOADED_PANELS'] = array(); $GLOBALS['IS_WIDE_HIGH'] = 1; $GLOBALS['IS_WIDE'] = 1; $GLOBALS['TEMPCODE_SETGET'] = array(); $GLOBALS['LOADED_TPL_CACHE'] = array(); $GLOBALS['HELPER_PANEL_PIC'] = NULL; $GLOBALS['HELPER_PANEL_TEXT'] = NULL; $GLOBALS['HELPER_PANEL_TUTORIAL'] = NULL; $GLOBALS['HELPER_PANEL_HTML'] = NULL; // CSS if (substr($special_page_type, -4) == '.css') { $url = build_url(array('page' => 'admin_themes', 'type' => 'edit_css', 'theme' => $GLOBALS['FORUM_DRIVER']->get_theme(), 'file' => $special_page_type, 'keep_wide_high' => 1), get_module_zone('admin_themes')); header('Location: ' . $url->evaluate()); exit; } // Site Tree Editor if ($special_page_type == 'site_tree') { $url = build_url(array('page' => 'admin_sitetree', 'type' => 'site_tree', 'id' => get_zone_name() . ':' . get_page_name()), get_module_zone('admin_sitetree')); header('Location: ' . $url->evaluate()); exit; } // IDE linkage if ($special_page_type == 'ide_linkage') { $title = get_page_title('IDE_LINKAGE'); $file_links = new ocp_tempcode(); global $JAVASCRIPTS, $CSSS, $_REQUIRED_CODE, $LANGS_REQUESTED; /*foreach (array_keys($JAVASCRIPTS) as $name) Already in list of templates { $txtmte_url='txmt://open?url=file://'.$name; $file_links->attach(do_template('INDEX_SCREEN_ENTRY',array('URL'=>$txtmte_url,'NAME'=>$name))); }*/ foreach (array_keys($CSSS) as $name) { $search = find_template_place($name, get_site_default_lang(), $GLOBALS['FORUM_DRIVER']->get_theme(), '.css', 'css'); if (!is_null($search)) { list($theme, $type) = $search; $txtmte_url = 'txmt://open?url=file://' . get_file_base() . '/themes/' . $theme . '/' . $type . '/' . $name . '.css'; $file_links->attach(do_template('INDEX_SCREEN_ENTRY', array('DISPLAY_STRING' => '(CSS)', 'URL' => $txtmte_url, 'NAME' => $name . '.css'))); } } foreach (array_keys($_REQUIRED_CODE) as $name) { $path_a = get_file_base() . '/' . (strpos($name, '.php') === false ? '/sources_custom/' . $name . '.php' : $name); $path_b = get_file_base() . '/' . (strpos($name, '.php') === false ? '/sources/' . $name . '.php' : str_replace('_custom', '', $name)); if (file_exists($path_a)) { $txtmte_url = 'txmt://open?url=file://' . $path_a; $file_links->attach(do_template('INDEX_SCREEN_ENTRY', array('DISPLAY_STRING' => '(PHP)', 'URL' => $txtmte_url, 'NAME' => $name . (strpos($name, '.php') === false ? '.php' : '')))); } if (file_exists($path_b)) { $txtmte_url = 'txmt://open?url=file://' . $path_b; $file_links->attach(do_template('INDEX_SCREEN_ENTRY', array('DISPLAY_STRING' => '(PHP)', 'URL' => $txtmte_url, 'NAME' => $name . (strpos($name, '.php') === false ? '.php' : '')))); } } foreach (array_keys($LANGS_REQUESTED) as $name) { if (file_exists(get_file_base() . '/lang_custom/' . fallback_lang() . '/' . $name . '.ini')) { $txtmte_url = 'txmt://open?url=file://' . get_file_base() . '/lang_custom/' . fallback_lang() . '/' . $name . '.ini'; $file_links->attach(do_template('INDEX_SCREEN_ENTRY', array('DISPLAY_STRING' => '(Language)', 'URL' => $txtmte_url, 'NAME' => $name . '.ini'))); } if (file_exists(get_file_base() . '/lang/' . fallback_lang() . '/' . $name . '.ini')) { $txtmte_url = 'txmt://open?url=file://' . get_file_base() . '/lang/' . fallback_lang() . '/' . $name . '.ini'; $file_links->attach(do_template('INDEX_SCREEN_ENTRY', array('DISPLAY_STRING' => '(Language)', 'URL' => $txtmte_url, 'NAME' => $name . '.ini'))); } } foreach (array_unique($RECORDED_TEMPLATES_USED) as $name) { $search = find_template_place($name, get_site_default_lang(), $GLOBALS['FORUM_DRIVER']->get_theme(), '.tpl', 'templates'); if (!is_null($search)) { list($theme, $type) = $search; $txtmte_url = 'txmt://open?url=file://' . get_file_base() . '/themes/' . $theme . '/' . $type . '/' . $name . '.tpl'; $file_links->attach(do_template('INDEX_SCREEN_ENTRY', array('DISPLAY_STRING' => '(Templates)', 'URL' => $txtmte_url, 'NAME' => $name . '.tpl'))); } } $echo2 = do_template('INDEX_SCREEN', array('TITLE' => $title, 'CONTENT' => $file_links, 'PRE' => do_lang_tempcode('TXMT_PROTOCOL_EXPLAIN'), 'POST' => '')); } // Theme images mode if ($special_page_type == 'theme_images') { $title = get_page_title('THEME_IMAGE_EDITING'); $theme_images = new ocp_tempcode(); global $RECORDED_IMG_CODES; foreach (array_keys($RECORDED_IMG_CODES) as $theme_image_details) { list($id, $theme, $lang) = unserialize($theme_image_details); $url = build_url(array('page' => 'admin_themes', 'type' => 'edit_image', 'theme' => is_null($theme) ? $GLOBALS['FORUM_DRIVER']->get_theme() : $theme, 'lang' => $lang, 'id' => $id), 'adminzone'); $image = find_theme_image($id, false, false, $theme, $lang); if ($image == '') { continue; } $theme_images->attach(do_template('INDEX_SCREEN_FANCIER_ENTRY', array('IMG' => $image, 'DESCRIPTION' => '', 'URL' => $url, 'NAME' => $id))); } $echo2 = do_template('INDEX_SCREEN_FANCIER_SCREEN', array('TITLE' => $title, 'CONTENT' => $theme_images, 'PRE' => do_lang_tempcode('CONTEXTUAL_EDITING_SCREEN'), 'POST' => '')); } // Profile mode? if ($special_page_type == 'profile') { if (function_exists('xdebug_dump_function_profile')) { $type = XDEBUG_PROFILER_FS_SUM; xdebug_dump_function_profile($type); } else { $echo2 = make_string_tempcode('Check out the dump using KCacheGrind.'); } } elseif (substr($special_page_type, 0, 12) == 'lang_content') { $map_a = get_file_base() . '/lang/langs.ini'; $map_b = get_custom_file_base() . '/lang_custom/langs.ini'; if (!file_exists($map_b)) { $map_b = $map_a; } $map = better_parse_ini_file($map_b); $lang_name = user_lang(); if (array_key_exists($lang_name, $map)) { $lang_name = $map[$lang_name]; } global $RECORDED_LANG_STRINGS_CONTENT; require_lang('lang'); require_code('form_templates'); $fields = new ocp_tempcode(); require_code('lang2'); $names = find_lang_content_names(array_keys($RECORDED_LANG_STRINGS_CONTENT)); foreach ($RECORDED_LANG_STRINGS_CONTENT as $key => $forum_db) { $value_found = get_translated_text($key, $forum_db ? $GLOBALS['FORUM_DB'] : $GLOBALS['SITE_DB']); if ($value_found != '') { $description = make_string_tempcode(escape_html($value_found)); if (get_value('google_translate_api_key') === NULL || user_lang() == get_site_default_lang()) { $actions = new ocp_tempcode(); } else { require_javascript('javascript_translate'); $actions = do_template('TRANSLATE_ACTION', array('LANG_FROM' => get_site_default_lang(), 'LANG_TO' => user_lang(), 'NAME' => 'trans_' . strval($key), 'OLD' => $value_found)); } $description->attach($actions); $fields->attach(form_input_text(is_null($names[$key]) ? '#' . strval($key) : $names[$key], $description, 'trans_' . strval($key), $value_found, false)); } } if ($fields->is_empty()) { inform_exit(do_lang_tempcode('NOTHING_TO_TRANSLATE')); } $title = get_page_title('__TRANSLATE_CONTENT', true, array($lang_name)); $post_url = build_url(array('page' => 'admin_lang', 'type' => '_content', 'contextual' => 1), 'adminzone'); $hidden = form_input_hidden('redirect', get_self_url(true, true)); $hidden = form_input_hidden('lang', user_lang()); $echo2 = do_template('FORM_SCREEN', array('_GUID' => '0d4dd16b023d0a7960f3eac85f54ddc4', 'SKIP_VALIDATION' => true, 'TITLE' => $title, 'HIDDEN' => $hidden, 'FIELDS' => $fields, 'URL' => $post_url, 'TEXT' => do_lang_tempcode('CONTEXTUAL_EDITING_SCREEN'), 'SUBMIT_NAME' => do_lang_tempcode('SAVE'))); } elseif (substr($special_page_type, 0, 4) == 'lang') { $map_a = get_file_base() . '/lang/langs.ini'; $map_b = get_custom_file_base() . '/lang_custom/langs.ini'; if (!file_exists($map_b)) { $map_b = $map_a; } $map = better_parse_ini_file($map_b); $lang_name = user_lang(); if (array_key_exists($lang_name, $map)) { $lang_name = $map[$lang_name]; } global $RECORDED_LANG_STRINGS; require_lang('lang'); require_code('form_templates'); require_code('lang2'); $fields = new ocp_tempcode(); $descriptions = get_lang_file_descriptions(fallback_lang()); foreach (array_keys($RECORDED_LANG_STRINGS) as $key) { $value_found = do_lang($key, NULL, NULL, NULL, NULL, false); $description = array_key_exists($key, $descriptions) ? make_string_tempcode($descriptions[$key]) : new ocp_tempcode(); if (!is_null($value_found)) { if (get_value('google_translate_api_key') === NULL || user_lang() == get_site_default_lang()) { $actions = new ocp_tempcode(); } else { require_javascript('javascript_translate'); $actions = do_template('TRANSLATE_ACTION', array('LANG_FROM' => get_site_default_lang(), 'LANG_TO' => user_lang(), 'NAME' => 'l_' . $key, 'OLD' => str_replace('\\n', chr(10), $value_found))); } $description->attach($actions); $fields->attach(form_input_text($key, $description, 'l_' . $key, str_replace('\\n', chr(10), $value_found), false)); } } $title = get_page_title('__TRANSLATE_CODE', true, array($lang_name)); $post_url = build_url(array('page' => 'admin_lang', 'type' => '_code2'), 'adminzone'); $hidden = form_input_hidden('redirect', get_self_url(true, true)); $hidden = form_input_hidden('lang', user_lang()); $echo2 = do_template('FORM_SCREEN', array('_GUID' => '0d4dd16b023d0a7960f3eac85f54ddc4', 'SKIP_VALIDATION' => true, 'TITLE' => $title, 'HIDDEN' => $hidden, 'FIELDS' => $fields, 'URL' => $post_url, 'TEXT' => do_lang_tempcode('CONTEXTUAL_EDITING_SCREEN'), 'SUBMIT_NAME' => do_lang_tempcode('SAVE'))); } // Template mode? if ($special_page_type == 'templates' || $special_page_type == 'tree') { require_lang('themes'); global $RECORD_TEMPLATES_USED; $RECORD_TEMPLATES_USED = false; $templates = new ocp_tempcode(); if ($special_page_type == 'templates') { $title = get_page_title('TEMPLATES'); $_RECORDED_TEMPLATES_USED = array_count_values($RECORDED_TEMPLATES_USED); ksort($_RECORDED_TEMPLATES_USED); foreach ($_RECORDED_TEMPLATES_USED as $name => $count) { //$restore_from=find_template_path($name); $file = $name . '.tpl'; $edit_url = build_url(array('page' => 'admin_themes', 'type' => '_edit_templates', 'theme' => $GLOBALS['FORUM_DRIVER']->get_theme(), 'f0file' => $file), 'adminzone', NULL, false, true); $templates->attach(do_template('TEMPLATE_LIST_ENTRY', array('COUNT' => integer_format($count), 'NAME' => $name, 'EDIT_URL' => $edit_url))); } } else { $title = get_page_title('TEMPLATE_TREE'); $hidden = new ocp_tempcode(); global $CSSS, $JAVASCRIPTS; foreach (array_keys($CSSS) as $c) { $hidden->attach(form_input_hidden('f' . strval(mt_rand(0, 100000)) . 'file', $c . '.css')); } foreach (array_keys($JAVASCRIPTS) as $c) { $hidden->attach(form_input_hidden('f' . strval(mt_rand(0, 100000)) . 'file', strtoupper($c) . '.tpl')); } $edit_url = build_url(array('page' => 'admin_themes', 'type' => '_edit_templates', 'preview_url' => get_self_url(true, false, array('special_page_type' => NULL)), 'theme' => $GLOBALS['FORUM_DRIVER']->get_theme()), 'adminzone', NULL, false, true); $tree = find_template_tree_nice($out->codename, $out->children, $out->fresh); $templates = do_template('TEMPLATE_TREE', array('_GUID' => 'ff2a2233b8b4045ba4d8777595ef64c7', 'HIDDEN' => $hidden, 'EDIT_URL' => $edit_url, 'TREE' => $tree)); } $echo2 = do_template('TEMPLATE_LIST_SCREEN', array('_GUID' => 'ab859f67dcb635fcb4d1747d3c6a2c17', 'TITLE' => $title, 'TEMPLATES' => $templates)); } // Query mode? if ($special_page_type == 'query') { require_lang("profiling"); global $QUERY_LIST; $queries = new ocp_tempcode(); $total_time = 0.0; global $M_SORT_KEY; $M_SORT_KEY = 'time'; usort($QUERY_LIST, 'multi_sort'); $QUERY_LIST = array_reverse($QUERY_LIST); foreach ($QUERY_LIST as $query) { $queries->attach(do_template('QUERY_LOG', array('_GUID' => 'ab88e1e92609136229ad920c30647647', 'TIME' => float_format($query['time'], 3), 'TEXT' => $query['text']))); $total_time += $query['time']; } $title = get_page_title("VIEW_PAGE_QUERIES"); $total = count($QUERY_LIST); $echo2 = do_template('QUERY_SCREEN', array('_GUID' => '5f679c8f657b4e4ae94ae2d0ed4843fa', 'TITLE' => $title, 'TOTAL' => integer_format($total), 'TOTAL_TIME' => float_format($total_time, 3), 'QUERIES' => $queries)); } $echo->attach(globalise($echo2)); $echo->attach(do_footer()); $echo->handle_symbol_preprocessing(); $echo->evaluate_echo(); exit; }