function init_requests(&$options) { global $DBInfo; if (!empty($DBInfo->user_class)) { include_once 'plugin/user/' . $DBInfo->user_class . '.php'; $class = 'User_' . $DBInfo->user_class; $user = new $class(); } else { $user = new WikiUser(); } $udb = new UserDB($DBInfo); $DBInfo->udb = $udb; if (!empty($DBInfo->trail)) { // read COOKIE trailer $options['trail'] = trim($user->trail) ? $user->trail : ''; } if ($user->id != 'Anonymous') { $user->info = $udb->getInfo($user->id); // read user info $test = $udb->checkUser($user); # is it valid user ? if ($test == 1) { // fail to check ticket // check user group if ($DBInfo->login_strict > 0) { # auto logout $options['header'] = $user->unsetCookie(); } else { if ($DBInfo->login_strict < 0) { $options['msg'] = _("Someone logged in at another place !"); } } } else { // check group $user->checkGroup(); } } else { // read anonymous user IP info. $user->info = $udb->getInfo('Anonymous'); } $options['id'] = $user->id; $DBInfo->user = $user; // check is_mobile_func $is_mobile_func = !empty($DBInfo->is_mobile_func) ? $DBInfo->is_mobile_func : 'is_mobile'; if (!function_exists($is_mobile_func)) { $is_mobile_func = 'is_mobile'; } $options['is_mobile'] = $is_mobile = $is_mobile_func(); # MoniWiki theme if ((empty($DBInfo->theme) or isset($_GET['action'])) and isset($_GET['theme'])) { // check theme if (preg_match('@^[a-zA-Z0-9_-]+$@', $_GET['theme'])) { $theme = $_GET['theme']; } } else { if ($is_mobile) { if (isset($_GET['mobile'])) { if (empty($_GET['mobile'])) { setcookie('desktop', 1, time() + 60 * 60 * 24 * 30, get_scriptname()); $_COOKIE['desktop'] = 1; } else { setcookie('desktop', 0, time() - 60 * 60 * 24 * 30, get_scriptname()); unset($_COOKIE['desktop']); } } } if (isset($_COOKIE['desktop'])) { $DBInfo->metatags_extra = ''; if (!empty($DBInfo->theme_css)) { $theme = $DBInfo->theme; } } else { if ($is_mobile or !empty($DBInfo->force_mobile)) { if (!empty($DBInfo->mobile_theme)) { $theme = $DBInfo->mobile_theme; } if (!empty($DBInfo->mobile_menu)) { $DBInfo->menu = $DBInfo->mobile_menu; } $DBInfo->use_wikiwyg = 0; # disable wikiwyg } else { if ($DBInfo->theme_css) { $theme = $DBInfo->theme; } } } } if (!empty($theme)) { $options['theme'] = $theme; } if ($options['id'] != 'Anonymous') { $options['css_url'] = !empty($user->info['css_url']) ? $user->info['css_url'] : ''; $options['quicklinks'] = !empty($user->info['quicklinks']) ? $user->info['quicklinks'] : ''; $options['tz_offset'] = !empty($user->info['tz_offset']) ? $user->info['tz_offset'] : date('Z'); if (empty($theme)) { $options['theme'] = $theme = !empty($user->info['theme']) ? $user->info['theme'] : ''; } } else { $options['css_url'] = $user->css; $options['tz_offset'] = $user->tz_offset; if (empty($theme)) { $options['theme'] = $theme = $user->theme; } } if (!$options['theme']) { $options['theme'] = $theme = $DBInfo->theme; } if ($theme and ($DBInfo->theme_css or !$options['css_url'])) { $css = is_string($DBInfo->theme_css) ? $DBInfo->theme_css : 'default.css'; $timestamp = '?' . filemtime(__FILE__); $options['css_url'] = (!empty($DBInfo->themeurl) ? $DBInfo->themeurl : $DBInfo->url_prefix) . "/theme/{$theme}/css/{$css}{$timestamp}"; } $options['pagename'] = get_pagename(); // check the validity of a given page name for UTF-8 case if (strtolower($DBInfo->charset) == 'utf-8') { if (!preg_match('//u', $options['pagename'])) { $options['pagename'] = ''; } // invalid pagename } if ($user->id != 'Anonymous' and !empty($DBInfo->use_scrap)) { $pages = explode("\t", $user->info['scrapped_pages']); $tmp = array_flip($pages); if (isset($tmp[$options['pagename']])) { $options['scrapped'] = 1; } else { $options['scrapped'] = 0; } } }