AuditAction($cfg["constants"]["error"], "LANGUAGE VARIABLE CHANGE ATTEMPT: " . $cfg["language_file"] . " from " . $cfg["user"]); $cfg["language_file"] = $cfg["default_language"]; } if (!is_file("inc/language/" . $cfg["language_file"])) { $cfg["language_file"] = $cfg["default_language"]; } // load per user settings // activated ? if ($cfg["enable_personal_settings"] == 1) { loadUserSettingsToConfig($cfg["uid"]); } $cfg["theme"] = CheckandSetUserTheme(); // theme require_once "themes/" . $cfg["theme"] . "/index.php"; // load language loadLanguageFile($cfg["language_file"]); // set cache cacheSet($currentUser); // login-tasks if (!isset($_SESSION['login_tasks'])) { // check main-directories. checkMainDirectories(); // maintenance-run require_once "inc/classes/MaintenanceAndRepair.php"; MaintenanceAndRepair::maintenance(MAINTENANCEANDREPAIR_TYPE_STD); $_SESSION['next_int_maintenance'] = null; // set flag $_SESSION['login_tasks'] = 1; } // set transfers-cache cacheTransfersSet();
// start session @session_start(); // file-checks // check for upgrade.php if (!isset($_SESSION['check']['upgrade'])) { if (@file_exists("upgrade.php") === true) { @ob_end_clean(); @header("location: upgrade.php"); exit; } } // check for setup.php if (!isset($_SESSION['check']['setup'])) { if (@file_exists("setup.php") === true) { @ob_end_clean(); @header("location: setup.php"); exit; } } // main.core require_once 'inc/main.core.php'; // load default-language loadLanguageFile($cfg["default_language"]); // Check for valid theme $cfg["default_theme"] = CheckandSetDefaultTheme(); // default-theme require "themes/" . $cfg["default_theme"] . "/index.php"; // set admin-var $cfg['isAdmin'] = false; // vlib require_once "inc/lib/vlib/vlibTemplate.php";
loadLanguageFile('languagecore.php'); /** LOAD INTERFACE TEXT (SOME HTML INCLUDED) **/ loadLanguageFile('languageui.php'); loadLanguageFile('loginandregistration.php'); loadLanguageFile('headerandfooter.php'); loadLanguageFile('users.php'); loadLanguageFile('admin.php'); loadLanguageFile('emails.php'); loadLanguageFile('stats.php'); loadLanguageFile('core.php'); /** LOAD COUNTRIES LIST **/ loadLanguageFile('countries.php'); if (!empty($LNG->COUNTRIES_LIST)) { uasort($LNG->COUNTRIES_LIST, 'strcoll'); } /////// PAGES /////// /** LOAD ABOUT (MUCH HTML INCLUDED) **/ loadLanguageFile('pages/about.php'); /** LOAD CONDITIONS OF USE (MUCH HTML INCLUDED) **/ loadLanguageFile('pages/conditionsofuse.php'); /** LOAD COOKIES (MUCH HTML INCLUDED) **/ loadLanguageFile('pages/cookies.php'); /** LOAD PRIVACY STATEMENT (MUCH HTML INCLUDED) **/ loadLanguageFile('pages/privacy.php'); /** LOAD HELP (MUCH HTML INCLUDED) **/ loadLanguageFile('pages/help.php'); /** LOAD Compendium Import (MUCH HTML INCLUDED) **/ loadLanguageFile('pages/compendiumimport.php'); /** LOAD Bibtext import (MUCH HTML INCLUDED) **/ loadLanguageFile('pages/bibteximport.php');
function rebuild($mode, $file) { global $wgOut, $wgUser; $wgTitle = Title::newFromText("Rebuild messages script"); if ('' == $file) { $messages = false; } else { $messages = loadLanguageFile($file); } if ('' == $mode) { $dbr =& wfGetDB(DB_SLAVE); $row = $dbr->selectRow("page", array("count(*) as c"), array("page_namespace" => NS_MEDIAWIKI)); $wgOut->addWikitext("Current namespace size: {$row->c}\n"); } switch ($mode) { case 'update': wfRebuildMessagesInitialiseMessages(false, $messages, false, $mode); break; case 'rebuild': wfRebuildMessagesInitialiseMessages(true, $messages, false, $mode); break; default: break; } $sk = $wgUser->getSkin(); $titleObj = Title::makeTitle(NS_SPECIAL, 'Rebuildmessages'); $link_back = $sk->makeKnownLinkObj($titleObj, '<b>here</b>'); $wgOut->addHtml("<br/>" . wfMsg('rebuildmessages_link_back') . " " . $link_back . "."); }
require_once "commandLine.inc"; include_once "InitialiseMessages.inc"; $wgTitle = Title::newFromText("Rebuild messages script"); if (isset($args[0])) { # Retain script compatibility $response = array_shift($args); if ($response == "update") { $response = 1; } elseif ($response == "rebuild") { $response = 2; } } else { $response = 0; } if (isset($args[0])) { $messages = loadLanguageFile(array_shift($args)); } else { $messages = false; } if (isset($options['update'])) { $response = 1; } if (isset($options['rebuild'])) { $response = 2; } if ($response == 0) { $dbr =& wfGetDB(DB_SLAVE); $row = $dbr->selectRow("page", array("count(*) as c"), array("page_namespace" => NS_MEDIAWIKI)); print "Current namespace size: {$row->c}\n"; print <<<END Usage: php rebuildMessages.php <action> [filename]
function displayNewsItems($group_id = 0, $max_news_items = 10, $max_news_length = -1, $display_mode = 1, $lang_id = 'AUTO', $strip_tags = true, $allowed_tags = '<p><a><img>', $custom_placeholder = false, $sort_by = 1, $sort_order = 1, $not_older_than = 0, $group_id_type = 'group_id', $lang_filter = false) { global $wb, $database, $LANG; /** * Is the first arg an array() we're using this one! * Keep in mind, that all other args may be overwriten/ignore by * the settings inside this array! * * e.g. * $config = array( 'max_news_items' => 5 ); * displayNewsItems( $config, 23, ... * * Only 5 news-items (not 23) are shown, as the first array overwrites the following params! * */ $all_args = func_get_args(); if (isset($all_args[0]) && is_array($all_args[0])) { // param 1 is pass as an array! We're using this as our config! $defaults = array('group_id' => 0, 'max_news_items' => 10, 'max_news_length' => -1, 'display_mode' => 1, 'lang_id' => 'AUTO', 'strip_tags' => true, 'allowed_tags' => '<p><a><img>', 'custom_placeholder' => false, 'sort_by' => 1, 'sort_order' => 1, 'not_older_than' => 0, 'group_id_type' => 'group_id', 'lang_filter' => false); // overwrite the defaults within the values of the $config foreach ($all_args[0] as $key => $val) { $defaults[$key] = $val; } foreach ($defaults as $key => $val) { ${$key} = $val; } } /** * Include required Anynews files */ require_once 'code/anynews_functions.php'; require_once 'thirdparty/truncate.php'; require_once WB_PATH . '/include/phplib/template.inc'; /** * Sanitize user specified function parameters */ sanitizeUserInputs($group_id, 'i{0;0;999}'); sanitizeUserInputs($max_news_items, 'i{10;1;999}'); sanitizeUserInputs($max_news_length, 'i{-1;0;250}'); sanitizeUserInputs($display_mode, 'i{1;1;99}'); sanitizeUserInputs($strip_tags, 'b'); sanitizeUserInputs($allowed_tags, 's{TRIM}'); sanitizeUserInputs($sort_by, 'i{1;1;5}'); sanitizeUserInputs($sort_order, 'i{1;1;2}'); sanitizeUserInputs($not_older_than, 'd{0;0;999}'); sanitizeUserInputs($group_id_type, 'l{group_id;group_id;page_id;section_id;post_id}'); sanitizeUserInputs($lang_filter, 'b'); /** * Include Anynews language file depending on defined $lang_id */ $lang_id = getValidLanguageId($lang_id); loadLanguageFile($lang_id); /** * Create template object and configure it */ $tpl = new Template(dirname(__FILE__) . '/templates'); // configure handling of unknown {variables} (remove:=default, keep, comment) $tpl->set_unknowns('remove'); // configure debug mode (0:= default, 1:=variable assignments, 2:=calls to get variable, 4:=show internals) $tpl->debug = 0; // set template file depending on $display_mode if (file_exists(dirname(__FILE__) . '/templates/display_mode_' . $display_mode . '.htt')) { // set user defined template $tpl->set_file('page', 'display_mode_' . $display_mode . '.htt'); } else { // set default template $tpl->set_file('page', 'display_mode_1.htt'); } // define "read more block" used to show/hide readmore link depending on long news content $tpl->set_block('page', 'readmore_link_block', 'readmore_link_block_handle'); // define optional "custom block" which can be used in template files if needed $tpl->set_block('page', 'custom_block', 'custom_block_handle'); // define "news block" used for text outputs of individual news items (news text, links etc.) $tpl->set_block('page', 'news_block', 'news_block_handle'); // define "news wrapper block" shown if at least one news entry exists $tpl->set_block('page', 'news_available_block', 'news_available_block_handle'); // define "no news wrapper block" shown in no news entry exists $tpl->set_block('page', 'no_news_available_block', 'no_news_available_block_handle'); // replace placeholders with values from language file foreach ($LANG['ANYNEWS'][0] as $key => $value) { $tpl->set_var($key, $value); } /** * Work out SQL query for group_id, limiting news to display depedning by defined $news_filter * option 1: $group_id:=0 => '1' * option 2: $group_id:=X => `group_id_type` = 'X' * option 3: $group_id:=array(2,3) => `group_id_type` IN (2,3) */ // show all news items if 0 is contained in group_id array if (is_array($group_id) && in_array(0, $group_id)) { $group_id = 0; } // check for multiple groups or single group values if (is_array($group_id)) { // SQL query for multiple groups $sql_group_id = "t1.`{$group_id_type}` IN (" . implode(',', $group_id) . ")"; } else { // SQL query for single or empty groups $sql_group_id = $group_id ? "t1.`{$group_id_type}` = '{$group_id}'" : '1'; } /** * Work out SQL query for the not older than option * This options allows to restrict the matches to news not older than X days */ // work out current server time (also used for published_when and published_until checks) $server_time = time(); $sql_not_older_than = '1'; if ($not_older_than > 0) { $sql_not_older_than = ' (t1.`published_when` >= \'' . ($server_time - $not_older_than * 24 * 60 * 60) . '\')'; } /** * Work out SQL query to hide news added via news pages NOT matching $lang_id * Requires to organize news items via news pages with page language set to $lang_id * Returns all news entries if no news page was found matching given $lang_id **/ $sql_lang_filter = '1'; if ($lang_filter) { // get all page_ids which page language match defined $lang_id $page_ids = getPageIdsByLanguage($lang_id); if (count($page_ids) > 0) { $sql_lang_filter = 't1.`page_id` in (' . implode(',', $page_ids) . ')'; } } /** * Work out SQL sort by and sort order query string */ // creates SQL query for sort by option $order_by_options = array('t1.`position`', 't1.`posted_when`', 't1.`published_when`', 'RAND()', '`comments`'); $sql_order_by = $order_by_options[$sort_by - 1]; // creates SQL query for sort order option $sql_sort_order = $sort_order == 1 ? 'DESC' : 'ASC'; /** * Perform SQL database query for Anynews */ $news_table = TABLE_PREFIX . 'mod_news_posts'; $comments_table = TABLE_PREFIX . 'mod_news_comments'; $sql = "SELECT t1.*, COUNT(`comment_id`) as `comments`\n\t\t\tFROM `{$news_table}` as t1\n\t\t\tLEFT JOIN `{$comments_table}` as t2\n\t\t\tON t1.`post_id` = t2.`post_id`\n\t\t\tWHERE t1.`active` = '1'\n\t\t\tAND {$sql_group_id}\n\t\t\tAND {$sql_lang_filter}\n\t\t\tAND (t1.`published_when` = '0' or t1.`published_when` <= '{$server_time}')\n\t\t\tAND (t1.`published_until` = '0' OR t1.`published_until` >= '{$server_time}')\n\t\t\tAND {$sql_not_older_than}\n\t\t\tGROUP BY t1.`post_id`\n\t\t\tORDER BY {$sql_order_by} {$sql_sort_order}\n\t\t\tLIMIT 0, {$max_news_items}\n\t\t"; /** * Process database query and output the template files */ $results = $database->query($sql); if ($results && $results->numRows() > 0) { // fetch news group titles from news database table $news_group_titles = getNewsGroupTitles(); // fetch user names from users database table $user_list = getUserNames(); // loop through all news articles found $news_counter = 1; while ($row = $results->fetchRow()) { // build absolute links from [wblink] tags found in news short or long text database field $wb->preprocess($row['content_short']); $wb->preprocess($row['content_long']); // fetch custom placeholders from short/long text fields and replace template placeholders with values $custom_vars_short_text = getCustomOutputVariables($row['content_short'], $custom_placeholder, 'SHORT'); $custom_vars_long_text = getCustomOutputVariables($row['content_long'], $custom_placeholder, 'LONG'); $custom_vars = array_merge($custom_vars_short_text, $custom_vars_long_text); // replace custom placeholders in template with values foreach ($custom_vars as $key => $value) { $tpl->set_var($key, $value); } // remove tags from short and long text if defined $row['content_short'] = $strip_tags ? strip_tags($row['content_short'], $allowed_tags) : $row['content_short']; $row['content_long'] = $strip_tags ? strip_tags($row['content_long'], $allowed_tags) : $row['content_long']; // shorten news text to defined news length (-1 for full text length) if ($max_news_length != -1 && strlen($row['content_short']) > $max_news_length) { // consider start position if short content starts with <p> or <div> $start_pos = preg_match('#^(<(p|div)>)#', $row['content_short'], $match) ? strlen($match[0]) : 0; $row['content_short'] = truncate(substr($row['content_short'], $start_pos), $max_news_length, '...', false, true); } // work out group image if exists $group_id = $row['group_id']; $image = ''; if (file_exists(WB_PATH . MEDIA_DIRECTORY . '/.news/image' . $group_id . '.jpg')) { $image = '<img src="' . WB_URL . MEDIA_DIRECTORY . '/.news/image' . $group_id . '.jpg' . '" alt="" />'; } // replace news article dependend template placeholders $tpl->set_var(array('WB_URL' => WB_URL, 'GROUP_IMAGE' => $image, 'NEWS_ID' => $news_counter, 'POST_ID' => (int) $row['post_id'], 'SECTION_ID' => (int) $row['section_id'], 'PAGE_ID' => (int) $row['page_id'], 'GROUP_ID' => (int) $row['group_id'], 'GROUP_TITLE' => array_key_exists($row['group_id'], $news_group_titles) ? htmlentities($news_group_titles[$row['group_id']]) : '', 'POSTED_BY' => (int) $row['posted_by'], 'USERNAME' => array_key_exists($row['posted_by'], $user_list) ? htmlentities($user_list[$row['posted_by']]['USERNAME']) : '', 'DISPLAY_NAME' => array_key_exists($row['posted_by'], $user_list) ? htmlentities($user_list[$row['posted_by']]['DISPLAY_NAME']) : '', 'TITLE' => $strip_tags ? strip_tags($row['title']) : $row['title'], 'COMMENTS' => isset($row['comments']) ? $row['comments'] : 0, 'LINK' => WB_URL . PAGES_DIRECTORY . $row['link'] . PAGE_EXTENSION, 'CONTENT_SHORT' => $image . $row['content_short'], 'CONTENT_LONG' => $row['content_long'], 'POSTED_WHEN' => date($LANG['ANYNEWS'][0]['DATE_FORMAT'], $row['posted_when']), 'PUBLISHED_WHEN' => date($LANG['ANYNEWS'][0]['DATE_FORMAT'], $row['published_when']), 'PUBLISHED_UNTIL' => date($LANG['ANYNEWS'][0]['DATE_FORMAT'], $row['published_until']))); // remove "read more block" from template if no long content is available $tpl->parse('readmore_link_block_handle', 'readmore_link_block', false); if (!isset($row['content_long']) || !strlen($row['content_long']) > 0) { $tpl->set_var('readmore_link_block_handle', ''); } // add optional custom template block in append mode (add per loop) $tpl->parse('custom_block_handle', 'custom_block', true); // add template values in news block in append mode (add per loop) $tpl->parse('news_block_handle', 'news_block', true); // remove custom variables to start blank for the next news entry foreach ($custom_vars as $key => $value) { $tpl->set_var($key, ''); } $news_counter++; } // update the total number of news items $tpl->set_var('NEWS_ITEMS', $news_counter - 1); // remove the "no news available block" from output $tpl->set_var('no_news_available_block_handle', ''); // parse the news content block $tpl->parse('news_available_block_handle', 'news_available_block', false); } else { // update the total number of news items $tpl->set_var('NEWS_ITEMS', 0); // remove the "news available block" from output $tpl->set_var('news_available_block_handle', ''); // remove blocks not used $tpl->parse('no_news_available_block_handle', 'no_news_available_block', true); } // ouput the final template $tpl->pparse('output', 'page'); }
} /** LOAD INTERFACE TEXT (SOME HTML INCLUDED) **/ loadLanguageFile('languageui.php'); loadLanguageFile('embed.php'); loadLanguageFile('stats.php'); /////// PAGES /////// /** LOAD ABOUT (MUCH HTML INCLUDED) **/ loadLanguageFile('pages/about.php'); /** LOAD CONDITIONS OF USE (MUCH HTML INCLUDED) **/ loadLanguageFile('pages/conditionsofuse.php'); /** LOAD COOKIES (MUCH HTML INCLUDED) **/ loadLanguageFile('pages/cookies.php'); /** LOAD PRIVACY STATEMENT (MUCH HTML INCLUDED) **/ loadLanguageFile('pages/privacy.php'); /** LOAD HELP (MUCH HTML INCLUDED) **/ loadLanguageFile('pages/help.php'); /** HELPER FUNCTIONS **/ function loadLanguageFile($file) { global $CFG, $HUB_FLM, $LNG; if (file_exists($CFG->dirAddress . 'language/' . $CFG->language . '/' . $file)) { require_once $CFG->dirAddress . 'language/' . $CFG->language . '/' . $file; } else { if (file_exists($CFG->dirAddress . 'language/en/' . $file)) { require_once $CFG->dirAddress . 'language/en/' . $file; } } } function loadJsonFromURL($url) { $curl = curl_init();