function theme_style_exists($id, $themeid = THE_THEME) { if ($f = theme_exists($themeid)) { if (file_exists($f)) { return $f . '/'; } } return ''; }
} else { if ($mime_types[$extension] != $each['type']) { die('Prevented an unwanted file upload attempt!'); } } } unset($file_info, $extension); } } unset($mime_types); } } $defender = new defender(); // Set admin login procedures Authenticate::setAdminLogin(); $defender->debug_notice = FALSE; // turn this off after beta. $defender->sniff_token(); $dynamic = new dynamics(); $dynamic->boot(); $fusion_page_head_tags =& \PHPFusion\OutputHandler::$pageHeadTags; $fusion_page_footer_tags =& \PHPFusion\OutputHandler::$pageFooterTags; $fusion_jquery_tags =& \PHPFusion\OutputHandler::$jqueryTags; // Set theme using $_GET as well. // Set theme if ($userdata['user_level'] == USER_LEVEL_SUPER_ADMIN && isset($_GET['themes']) && theme_exists($_GET['themes'])) { $newUserTheme = array("user_id" => $userdata['user_id'], "user_theme" => stripinput($_GET['themes'])); dbquery_insert(DB_USERS, $newUserTheme, "update"); redirect(clean_request("", array("themes"), FALSE)); } set_theme(empty($userdata['user_theme']) ? fusion_get_settings("theme") : $userdata['user_theme']);
function set_theme($theme) { global $settings, $locale; if (!defined("THEME")) { // If the theme is valid set it if (theme_exists($theme)) { define("THEME", THEMES . ($theme == "Default" ? $settings['theme'] : $theme) . "/"); // The theme is invalid, search for a valid one inside themes folder and set it } else { $dh = opendir(THEMES); while (FALSE !== ($entry = readdir($dh))) { if ($entry != "." && $entry != ".." && is_dir(THEMES . $entry)) { if (theme_exists($entry)) { define("THEME", THEMES . $entry . "/"); break; } } } closedir($dh); } // If can't find and set any valid theme show a warning if (!defined("THEME")) { echo "<strong>" . $theme . " - " . $locale['global_300'] . ".</strong><br /><br />\n"; echo $locale['global_301']; die; } } }
} } } else { header("P3P: CP='NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM'"); setcookie(COOKIE_PREFIX . "user", "", time() - 7200, "/", "", "0"); setcookie(COOKIE_PREFIX . "lastvisit", "", time() - 7200, "/", "", "0"); redirect(BASEDIR . "index.php", true); } } else { header("P3P: CP='NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM'"); setcookie(COOKIE_PREFIX . "user", "", time() - 7200, "/", "", "0"); setcookie(COOKIE_PREFIX . "lastvisit", "", time() - 7200, "/", "", "0"); redirect(BASEDIR . "index.php", true); } } else { if (!theme_exists($settings['theme'])) { echo "<strong>" . $settings['sitename'] . " - " . $locale['global_300'] . ".</strong><br /><br />\n"; echo $locale['global_301']; die; } $userdata = ""; $userdata['user_level'] = 0; $userdata['user_rights'] = ""; $userdata['user_groups'] = ""; } // Redirect browser using header or script function function redirect($location, $script = false) { if (!$script) { header("Location: " . str_replace("&", "&", $location)); exit;
$theme_files = makefilelist(THEMES, ".|..|templates|.svn", true, "folders"); array_unshift($theme_files, "Default"); echo "<tr>\n"; echo "<td class='tbl" . $this->getErrorClass("user_theme") . "'><label for='user_theme_input'>" . $locale['uf_theme'] . $required . "</label></td>\n"; echo "<td class='tbl" . $this->getErrorClass("user_theme") . "'>"; echo "<select id='user_theme_input' name='user_theme' class='textbox' style='width:100px;'>\n" . makefileopts($theme_files, $user_theme) . "</select>"; echo "</td>\n</tr>\n"; } if ($required) { $this->setRequiredJavaScript("user_theme", $locale['uf_theme_error']); } // Display in profile } elseif ($profile_method == "display") { // Insert and update } elseif ($profile_method == "validate_insert" || $profile_method == "validate_update") { if ($settings['userthemes'] == 1 || iADMIN) { // Get input data $input_theme = isset($_POST['user_theme']) ? stripinput($_POST['user_theme']) : ""; if (theme_exists($input_theme)) { // Set update or insert user data $this->_setDBValue("user_theme", $input_theme); if (isset($this->userData['user_theme'])) { if ($input_theme != $this->userData['user_theme']) { $this->_themeChanged = true; } } } else { $this->_setError("user_theme", $locale['uf_theme_error'], true); } } }
/** * Set a valid theme * @global string[] $settings * @global array $locale * @param string $theme */ function set_theme($theme) { global $settings, $locale; if (defined("THEME")) { return; } if (theme_exists($theme)) { define("THEME", THEMES . ($theme == "Default" ? $settings['theme'] : $theme) . "/"); return; } foreach (new GlobIterator(THEMES . '*') as $dir) { if ($dir->isDir() and theme_exists($dir->getBasename())) { define("THEME", $dir->getPathname() . "/"); return; } } // Don't stop if we are in admin panel since we use different themes now $no_theme_message = str_replace("[SITE_EMAIL]", fusion_get_settings("siteemail"), $locale['global_301']); if (preg_match("/\\/administration\\//i", $_SERVER['PHP_SELF'])) { addNotice('danger', "<strong>" . $theme . " - " . $locale['global_300'] . ".</strong><br /><br />\n" . $no_theme_message); } else { echo "<strong>" . $theme . " - " . $locale['global_300'] . ".</strong><br /><br />\n"; echo $no_theme_message; die; } }
} } function dbconnect($db_host, $db_user, $db_pass, $db_name) { global $db_connect; $db_connect = @mysql_connect($db_host, $db_user, $db_pass); $db_select = @mysql_select_db($db_name); if (!$db_connect) { die("<strong>Unable to establish connection to MySQL</strong><br />" . mysql_errno() . " : " . mysql_error()); } elseif (!$db_select) { die("<strong>Unable to select MySQL database</strong><br />" . mysql_errno() . " : " . mysql_error()); } mysql_set_charset('latin1'); } // Set theme if (!theme_exists($userdata['user_theme'])) { echo "<strong>" . $userdata['user_theme'] . " - " . $locale['global_300'] . ".</strong><br /><br />\n"; echo $locale['global_301']; die; } // Check that site or user theme exists function theme_exists($theme) { global $settings; if (!preg_match('/^[a-zA-Z0-9_-]+$/', $theme)) { $theme = 'Default'; } if ($theme == "Default") { $theme = $settings['theme']; } if (!file_exists(THEMES) || !is_dir(THEMES)) {
function doselect($id) { global $fp_config; //$id = isset($_GET['select'])? $_GET['select'] : null; if ($id) { $id = sanitize_title($id); if (theme_exists($id)) { $fp_config['general']['theme'] = $id; unset($fp_config['general']['style']); //$t = theme_loadsettings(); //$fp_config['general']['style'] = $t['default_style']; $return = config_save() ? 1 : -1; } else { $return = -2; } $this->smarty->assign('success', $return); return 1; } }