Contributions by Keith Gable This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. In addition to being restricted by the GNU General Public License, Essence Engine may not be sold, rented, sublicensed, or leased; you are not permitted to generate revenue with the Essence Engine source code. You may, however, use Essence Engine to run a website that generates revenue via other means. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA $Id$ */ // Theme constants // !DOCTYPE references (yes, I know, they do not increase by one, it's for revisions) -Zg // <4.01 included for completeness. define("DT_NONE" , 0x00); define("DT_HTML2" , 0x20); define("DT_HTML3" , 0x30); define("DT_HTML32" , 0x32); define("DT_HTML401_STRICT" , 0x40); define("DT_HTML401_TRANS" , 0x41); define("DT_HTML401_FRAMES" , 0x42); define("DT_XHTML1_STRICT" , 0xA0); define("DT_XHTML1_TRANS" , 0xA1); define("DT_XHTML1_FRAMES" , 0xA2); define("DT_XHTML11" , 0xB0); // !DOCTYPE strings define("DTSTR_HTML2" , "HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\""); define("DTSTR_HTML3" , "HTML PUBLIC \"-//IETF//DTD HTML 3.0//EN\""); define("DTSTR_HTML32" , "HTML PUBLIC \"-//W3C//DTD HTML 3.2 Final//EN\""); define("DTSTR_HTML401_STRICT" , "HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\""); define("DTSTR_HTML401_TRANS" , "HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\""); define("DTSTR_HTML401_FRAMES" , "HTML PUBLIC \"-//W3C//DTD HTML 4.01 Frameset//EN\" \"http://www.w3.org/TR/html4/frameset.dtd\""); define("DTSTR_XHTML1_STRICT" , "html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\""); define("DTSTR_XHTML1_TRANS" , "html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\""); define("DTSTR_XHTML1_FRAMES" , "html PUBLIC \"-//W3C//DTD XHTML 1.0 Frameset//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd\""); define("DTSTR_XHTML11" , "html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\""); // Theme functions // Obsolete functions begin with obs_ function obs_theme_getThemeDirectory($themeName, $language, $locale) { // match full locale (en_US) if (file_exists("./themes/" . $themeName . "." . $language . "_" . $locale)) { return "themes/" . $themeName . "." . $language . "_" . $locale; // match language only (en) } elseif (file_exists("./themes/" . $themeName . "." . $language)) { return "themes/" . $themeName . "." . $language; // match system default language/locale } elseif (file_exists("./themes/" . $themeName . "." . $sysLanguage . "_" . $sysLocale)) { return "themes/" . $themeName . "." . $sysLanguage . "_" . $sysLocale; // match system default language } elseif (file_exists("./themes/" . $themeName . "." . $sysLanguage)) { return "themes/" . $themeName . "." . $sysLanguage; // holy crap Batman! can't match user locale or system locale! // one last thing we can try, perhaps. } elseif (file_exists("./themes/" . $themeName)) { return "themes/" . $themeName; // we must die, it is the final solution! } else { die("Fatal Error: No theme directory could be found for the \"" . safetext($themeName) . "\" theme in either the user locale or the system locale. If you mistyped the theme in the settings, edit websitesettings.php manually to fix it."); } } // theme_getThemeDirectory() // Expects: nothing in particular // Returns: theme's directory, based on user's current lang/locale/theme selection function theme_getThemeDirectory() { // TODO: Don't refer to $deftheme, but instead refer to the correct configuration option when we fix the config format global $deftheme; global $sysLanguage; global $sysLocale; if ($_COOKIE["theme"]) $themeName = $_COOKIE["theme"]; else $themeName = $deftheme; if ($_SESSION["language"]) $language = $_SESSION["language"]; else $language = $_COOKIE["language"]; if ($_SESSION["locale"]) $locale = $_SESSION["locale"]; else $language = $_COOKIE["locale"]; // match full locale (en_US) if (file_exists("./themes/" . $themeName . "." . $language . "_" . $locale)) { return "themes/" . $themeName . "." . $language . "_" . $locale; // match language only (en) } elseif (file_exists("./themes/" . $themeName . "." . $language)) { return "themes/" . $themeName . "." . $language; // match system default language/locale } elseif (file_exists("./themes/" . $themeName . "." . $sysLanguage . "_" . $sysLocale)) { return "themes/" . $themeName . "." . $sysLanguage . "_" . $sysLocale; // match system default language } elseif (file_exists("./themes/" . $themeName . "." . $sysLanguage)) { return "themes/" . $themeName . "." . $sysLanguage; // holy crap Batman! can't match user locale or system locale! // one last thing we can try, perhaps. } elseif (file_exists("./themes/" . $themeName)) { return "themes/" . $themeName; // we must die, it is the final solution! } else { die("Fatal Error: No theme directory could be found for the \"" . safetext($themeName) . "\" theme in either the user locale or the system locale. If you mistyped the theme in the settings, edit websitesettings.php manually to fix it."); } } // theme_loadCSS() // Expects: global $theme_info (i.e. theme.php loaded) // Returns: echos all s function theme_loadCSS() { global $theme_info; if ($theme_info['css'] != null) { foreach ($theme_info['css'] as $cssfile) { echo ""; } } } // theme_displayWhosOn() // Expects: a full moon // Returns: HTML for the who's on box function theme_displayWhosOn() { $totalusers = mysql_fetch_array(mysql_query("select count(*) from users where usertype>1", $db)); echo " Total members: " . $totalusers["count(*)"] . "
\n
\n"; echo " Online users:
\n"; $onusers = mysql_fetch_array(mysql_query("select count(*) from whoson where username!=''", $db)); echo " - " . $onusers["count(*)"] . " members"; if ($onusers["count(*)"] > 0) echo " (who?)"; echo "
\n"; $onguests = mysql_fetch_array(mysql_query("select count(*) from whoson where username=''", $db)); echo " - " . $onguests["count(*)"] . " guests
\n
\n"; echo " Current time:
\n " . date("g:i A, Y-m-d"); } // theme_displaySettings() // Expects: nothing in particular // Returns: HTML for the settings box function theme_displaySettings() { global $loggedin; global $userinfo; if ($loggedin) { if ($userinfo["postlogo"]) echo ' Logged in as ' . safetext($userinfo[
' . "\n"; else echo " Logged in as " . safetext($userinfo["dispname"]) . "
\n"; echo ' Settings - Logout' . "\n"; ?>
Edit your profile
" id="themes">
Close
You are not logged in
Login - Register


s function theme_loadScripts() { global $theme_info; echo ""; if ($theme_info['scripts'] != null) { foreach ($theme_info['scripts'] as $scriptfile) { echo ""; } } } // theme_docType($docType) // Expects: DT_ constant // Returns: echos the DOCTYPE. function theme_docType($docType) { switch ($docType) { case DT_NONE: break; case DT_HTML2: echo "\n"; break; case DT_HTML3: echo "\n"; break; case DT_HTML32: echo "\n"; break; case DT_HTML401_STRICT: echo "\n"; break; case DT_HTML401_TRANS: echo "\n"; break; case DT_HTML401_FRAMES: echo "\n"; break; case DT_XHTML1_STRICT: echo "\n"; break; case DT_XHTML1_TRANS: echo "\n"; break; case DT_XHTML1_FRAMES: echo "\n"; break; case DT_XHTML11: echo "\n"; break; default: echo "\n"; } } // theme_xmlPreamble($sendContentType, $includeInIncompatibleBrowsers) // Expects: $sendContentType (bool) : send application/xhtml+xml to browsers that accept it // $includeInIncompatibleBrowsers (bool) : in <=IE6 and <=Opera7, the XML preamble gets it stuck in // quirks mode // Returns: echos XML preamble and sends Content-Type header if needed function theme_xmlPreamble($sendContentType, $includeInIncompatibleBrowsers) { $myIncludePreamble = true; if ($sendContentType) { // check HTTP_ACCEPT if (strstr($_SERVER["HTTP_ACCEPT"], "application/xhtml+xml")) { header("Content-Type: application/xhtml+xml; charset=utf-8"); } elseif (strstr($_SERVER["HTTP_ACCEPT"], "application/xhtml")) { header("Content-Type: application/xhtml; charset=utf-8"); } elseif (strstr($_SERVER["HTTP_ACCEPT"], "text/xhtml")) { header("Content-Type: text/xhtml; charset=utf-8"); } else { header("Content-Type: text/html; charset=utf-8"); } } if (!$includeInIncompatibleBrowsers) { // figure out if the browser is supported // check Opera first. if (strstr($_SERVER["HTTP_USER_AGENT"], "Opera/7.")) $myIncludePreamble = false; // if MSIE 5/6 but not Opera if ((strstr($_SERVER["HTTP_USER_AGENT"], "MSIE 6.")) && !(strstr($_SERVER["HTTP_USER_AGENT"], "Opera"))) $myIncludePreamble = false; if ((strstr($_SERVER["HTTP_USER_AGENT"], "MSIE 5.")) && !(strstr($_SERVER["HTTP_USER_AGENT"], "Opera"))) $myIncludePreamble = false; if ($myIncludePreamble) { // some copies of PHP are gay and will break out of PHP mode... echo "<"; echo "?xml version=\"1.0\" encoding=\"UTF-8\" ?"; echo ">\n"; } } else { // some copies of PHP are gay and will break out of PHP mode... echo "<"; echo "?xml version=\"1.0\" encoding=\"UTF-8\" ?"; echo ">\n"; } } ?>