* * $Id: site.inc.php,v 1.14 2002/02/09 17:32:20 haakon Exp $ * * 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. * * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ function cleanStr($s) { // returns a "clean" string stripped for slashes and HTML tags return htmlentities(stripslashes(ereg_replace("<([^>]|\n)*>", "", $s))); } function deleteUserCache($username) { global $config; $cachefile = $config["sipssys"] ."/users/$username[0]/$username/cache"; if (file_exists($cachefile)) { unlink($cachefile); } } function getUserValues($username) { global $config; $lines = file($config["sipssys"] ."/users/$username[0]/$username/user"); for ($i = 0; $i < count($lines); $i++) { $keyval = explode("::", $lines[$i]); $val[$keyval[0]] = chop($keyval[1]); } return $val; } function getUserValue($username, $key) { global $config; $lines = file($config["sipssys"] ."/users/$username[0]/$username/user"); for ($i=0; ($i", $out); $out = ereg_replace("#/I#", "", $out); $out = ereg_replace("#B#", "", $out); $out = ereg_replace("#/B#", "", $out); return $out; } $VERSION = "0.3.1"; error_reporting(1); // <- remove this line when debugging include($config["sipssys"] ."/lang/" .$config["lang"] .".lang"); $cryptuser = $HTTP_COOKIE_VARS["user"]; if ($cryptuser == "") { $usrname = "default"; } else { $auth = explode(":", $cryptuser); $u = $auth[0]; if (file_exists($config["sipssys"] ."/users/$u[0]/$u/user")) { $usr = getUserValues($u); if ($usr["Password"] == $auth[1]) { $usrname = $auth[0]; // we're in! if ($usr["Timezone"] == "") { // temp code to ease transition to timezone system. This code will be removed eventually... $t = getUserValue("default", "Timezone"); setUserValue($usrname, "Timezone", $t); $usr["Timezone"] = $t; } } else { setcookie("user"); $usrname = "default"; // password in cookie is incorrect, resigning to default } } else { // account has been deleted from somewhere else, this cookie is obsolete, resigning to default setcookie("user"); $usrname = "default"; } } if ($usrname == "default") $usr = getUserValues("default"); else { if (($usr["Theme"] == "") || (!file_exists($config["sipssys"] ."/themes/" .$usr["Theme"]))) { $t = getUserValue("default", "Theme"); setUserValue($usrname, "Theme", $t); $usr["Theme"] = $t; } } $themeconfig = $config["sipssys"] ."/themes/" .$usr["Theme"] ."/.themeconfig.php"; if (file_exists($themeconfig)) include $themeconfig; function printTop($pagetitle) { //prints the top html global $config, $usr, $bottom; $full = implode("", file($config["sipssys"] ."/themes/" .$usr["Theme"] ."/site")); $full = str_replace("#TITLE#", $config["sitename"] ." | $pagetitle", $full); $full = str_replace("#DATE#", strftime($config["date-format"]), $full); $h = split("#CONTENT#", $full); print($h[0]); $bottom = $h[1]; } function printBottom() { //prints the bottom html global $bottom; print($bottom); } ?>