query_first("SELECT * FROM vwar".$n."_settings"); while (list($key,$value) = each($row)) { $$key = dbSelect ($value, 0, 0); } $textwon = rehtmlspecialchars ($textwon); $textlost = rehtmlspecialchars ($textlost); $textdraw = rehtmlspecialchars ($textdraw); $urltovwar = checkPath ($urltovwar); ## -------------------------------------------------------------------------------------------------------------- ## // we save all incoming $HTTP_*_VARS or $_* in the $GPC array // 'magic_quotes_gpc = off' is overwritten for all vars if ( !defined("VWAR_GLOBALS_GRABBED") ) { $GPC = array(); // only do it once! define("VWAR_GLOBALS_GRABBED", 1); $magic_quotes = get_magic_quotes_gpc(); function checkValue ($arg) { global $magic_quotes; if (is_string($arg)) { $arg = ( $magic_quotes ) ? $arg : addslashes($arg); $arg = rehtmlspecialchars(htmlspecialchars($arg)); } else { foreach ($arg AS $key => $value) { $arg[$key] = checkValue($value); } } return $arg; } function regGlobals ($array, &$target_array) { reset($array); $reserved = array('vwar_root', 'vwar_root2', 'vwar_xroot', 'n', 'sql'); // get the vars out of the get-, post- or cookie-arrays foreach ($array AS $key => $value) { global ${$key}; // we don't want the reserved keys to be changed! if (!in_array($key, $reserved)) { // we don't register arrays with more than one dimension, // we only add slashes if required and use rehtmlspecialchars() $value = checkValue($value); ${$key} = $value; $target_array[$key] = $value; } } return true; } if (!empty($_GET)) { regGlobals($_GET, $GPC); } else if (!empty($HTTP_GET_VARS)) { regGlobals($HTTP_GET_VARS, $GPC); } if (!empty($_POST)) { regGlobals($_POST, $GPC); } else if (!empty($HTTP_POST_VARS)) { regGlobals($HTTP_POST_VARS, $GPC); } if (!empty($_COOKIE)) { regGlobals($_COOKIE, $GPC); } else if (!empty($HTTP_COOKIE_VARS)) { regGlobals($HTTP_COOKIE_VARS, $GPC); } if (!empty($_SERVER)) { $GPC["PHP_SELF"] = $_SERVER["PHP_SELF"]; $GPC["PURE_PHP_SELF"] = basename($_SERVER["PHP_SELF"]); $GPC["QUERY_STRING"] = $_SERVER["QUERY_STRING"]; $GPC["HTTP_USER_AGENT"] = $_SERVER["HTTP_USER_AGENT"]; $GPC["HTTP_ACCEPT_ENCODING"] = $_SERVER["HTTP_ACCEPT_ENCODING"]; } else if (!empty($HTTP_SERVER_VARS)) { $GPC["PHP_SELF"] = $HTTP_SERVER_VARS["PHP_SELF"]; $GPC["PURE_PHP_SELF"] = basename($HTTP_SERVER_VARS["PHP_SELF"]); $GPC["QUERY_STRING"] = $HTTP_SERVER_VARS["QUERY_STRING"]; $GPC["HTTP_USER_AGENT"] = $HTTP_SERVER_VARS["HTTP_USER_AGENT"]; $GPC["HTTP_ACCEPT_ENCODING"] = $HTTP_SERVER_VARS["HTTP_ACCEPT_ENCODING"]; } } // set cookie values to their real values $GPC['vwarid'] = $GPC[$n . 'vwarid']; $GPC['vwarpassword'] = $GPC[$n . 'vwarpassword']; $GPC['vwarlanguage'] = $GPC[$n . 'vwarlanguage']; ## -------------------------------------------------------------------------------------------------------------- ## // last activity if ($whoisonline == 1 && !empty($GPC['vwarid']) && !defined("VWAR_LAST_ACTIVITY")) { define("VWAR_LAST_ACTIVITY", 1); $vwardb->query("UPDATE vwar".$n."_member SET lastactivity = '".time()."' WHERE memberid = '".$GPC['vwarid']."'"); } ## -------------------------------------------------------------------------------------------------------------- ## ## FUNCTIONS ## -------------------------------------------------------------------------------------------------------------- ## function checkCookie() { global $vwardb, $n, $GPC, $vwar_memberinfo; $check_id = $n . "vwarid"; $check_pass = $n . "vwarpassword"; if ( !isset($vwar_memberinfo) ) { $result = $vwardb->query(" SELECT memberid, ismember, password FROM vwar".$n."_member WHERE memberid = '".$GPC[$check_id]."' "); $vwar_memberinfo = $vwardb->fetch_array($result); } return ifelse($vwar_memberinfo['memberid'] && $vwar_memberinfo['ismember'] == 1 && md5($vwar_memberinfo['password']) == $GPC[$check_pass], true, false); } ## -------------------------------------------------------------------------------------------------------------- ## function SetVWarCookie($name, $value, $delete = 0) { global $cookiedomain, $n, $cookiepath; // cookie expires in 1 year if ($delete == 1) { $expire = time() - (3600 * 24 * 365); } else { $expire = time() + (3600 * 24 * 365); } // set global cookie, if path is empty if (empty($cookiepath)) { $cookiepath = "/"; } // set the cookie SetCookie( $n . $name, $value, $expire, $cookiepath, $cookiedomain ); return; } ## -------------------------------------------------------------------------------------------------------------- ## function formatdatetime($time,$dateformat="",$dontconvert=0) { global $longdateformat,$timezoneoffset,$timeformat; if (!is_numeric($timezoneoffset)) $timezoneoffset = 0; if (!$dateformat) { $dateformat = $longdateformat; } if ($dontconvert == 0) { if ($timeformat == "0" && $dateformat == $longdateformat) { $dateformat = str_replace("H","h",$dateformat); return date($dateformat . "a", $time + ($timezoneoffset * 3600)); } else { return date($dateformat, $time + ($timezoneoffset * 3600)); } } else { return date($dateformat,$time); } } ## -------------------------------------------------------------------------------------------------------------- ## function checkMail($mail) { global $checked; if ($mail) { //if (eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$",$mail)) $checked = ifelse(eregi("^[_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,}$",$mail), true, false); } else { $checked = false; } return $checked; } ## -------------------------------------------------------------------------------------------------------------- ## function ifelse ($expression,$returntrue,$returnfalse="") { if (!$expression) { return $returnfalse; } else { return $returntrue; } } ## -------------------------------------------------------------------------------------------------------------- ## function makeimgtag($path,$alt="",$align="middle",$width="",$height="") { if (!$width && ($size = @getimagesize($path))) { $width = $size[0]; $height = $size[1]; } return "'; } ## -------------------------------------------------------------------------------------------------------------- ## function makelink($link,$name,$title="",$target="",$completeurl=0,$cutname=0,$maxwidth=60,$startwidth=40,$endwidth=-15) { if (!trim($name)) { $name = $link; } if ($completeurl == 1) { $link = checkUrlFormat($link); } if (strlen($name) > $maxwidth && $cutname == 1) { $name = substr($name, 0, $startwidth) . "..." . substr($name, $endwidth); } $link = "" . $name . ""; return $link; } ## -------------------------------------------------------------------------------------------------------------- ## function popupwin($target, $name, $class="",$scrollbar=true,$x=520, $y=520, $href="#",$resizable=true,$menubar=false,$locationbar=false) { $scroll = ($scrollbar ? "yes":"no"); // nb. scrollbars=no produces an unusable scroll ghost, none at all inserts them when necessary $resize = ($resizable ? "yes":"no"); $menu = ($menubar ? "yes":"no"); $location = ($locationbar ? "yes":"no"); $class = ifelse($class != "", "class='$class'"); $originX = 100; $originY = 100; // applies to NS only $result = "$name"; return $result; } ## -------------------------------------------------------------------------------------------------------------- ## function checkUrlFormat($url) { if ( empty($url) ) { return ""; } if (substr($url,0,7) != "http://" AND substr($url,0,6) != "ftp://") { $url = "http://" . $url; } return $url; } ## -------------------------------------------------------------------------------------------------------------- ## function checkPath($path) { return (substr($path,(strlen($path)-1),1) != "/") ? $path . "/" : $path; } ## -------------------------------------------------------------------------------------------------------------- ## function encodeMail($mailstring) { if (preg_match_all('#([_\.0-9a-z-]+@[0-9a-z][0-9a-z-]+\.+[a-z]{2,})#i',$mailstring,$matches)) { for ($matchcount = 0; $matchcount < (sizeof($matches)); $matchcount++) { for ($pos = 0; $pos < (strlen($matches[1][$matchcount])); $pos++) { $tmp .= "&#".ord(substr($matches[1][$matchcount],$pos,1)).";"; } $mailstring = str_replace($matches[1][$matchcount],$tmp,$mailstring); $tmp = ""; } } return $mailstring; } ## -------------------------------------------------------------------------------------------------------------- ## function parseText($text, $ismember=0, $dosmilies=1, $docensor=1, $dobbcode=1, $dourlsearch=1, $external=0, $noimage=0) { global $vwar_root; // this is the main function to parse a text with bbcode, smilies and censor protection // include the functions to parse the text include_once ( $vwar_root . "includes/functions_textparser.php" ); // call the main function $text = parse ( $text, $ismember, $dosmilies, $docensor, $dobbcode, $dourlsearch, $external, $noimage); return $text; } ## -------------------------------------------------------------------------------------------------------------- ## function dbSelect ( &$arg, $stripslashes=0, $donl2br=1, $dohtml = 1 ) { global $htmlcode; if (is_string($arg)) { //