3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the Revised BSD License.
6 This program is distributed in the hope that it will be useful,
7 but WITHOUT ANY WARRANTY; without even the implied warranty of
8 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 Revised BSD License for more details.
11 Copyright 2004-2009 iDB Support - http://idb.berlios.de/
12 Copyright 2004-2009 Game Maker 2k - http://gamemaker2k.org/
14 $FileInfo: functions.php - Last Update: 8/8/2009 SVN 299 - Author: cooldude2k $
16 $File3Name = basename($_SERVER['SCRIPT_NAME']);
17 if ($File3Name=="functions.php"||$File3Name=="/functions.php") {
20 // Check the file names
21 function CheckFile($FileName) {
22 $File3Name = basename($_SERVER['SCRIPT_NAME']);
23 if ($File3Name==$FileName||$File3Name=="/".$FileName) {
27 function CheckFiles($FileName) {
28 $File3Name = basename($_SERVER['SCRIPT_NAME']);
29 if ($File3Name==$FileName||$File3Name=="/".$FileName) {
31 CheckFile("functions.php");
32 require($SettDir['misc']."compression.php");
34 if ($_GET['act']=="DeleteSession") { @session_destroy(); }
35 if ($_GET['act']=="ResetSession") { @session_unset(); }
36 if ($_GET['act']=="NewSessionID") { @session_regenerate_id(); }
37 if ($_GET['act']=="PHPInfo") { @phpinfo(); exit(); }
38 if ($_GET['act']=="phpinfo") { @phpinfo(); exit(); }
39 if ($_GET['act']=="PHPCredits") { @phpcredits(); exit(); }
40 if ($_GET['act']=="phpcredits") { @phpcredits(); exit(); }
41 */// Connect to mysql database
42 function ConnectMysql($sqlhost,$sqluser,$sqlpass,$sqldb,$retlink=false) {
43 if($retlink!==true) { $retlink = false; }
44 $StatSQL = @mysql_connect($sqlhost,$sqluser,$sqlpass);
45 $StatBase = @mysql_select_db($sqldb);
46 if (!$StatSQL) { return false; }
47 if (!$StatBase) { return false; }
48 if($retlink===true) { return $StatSQL; }
49 if($retlink===false) { return true; } }
50 $Names['RS'] = "Renee Sabonis";
51 define("_renee_", $Names['RS']);
52 // Change the title and gzip page
53 function change_title($new_title,$use_gzip="off",$gzip_type="gzip") {
55 if($gzip_type!="gzip") { if($gzip_type!="deflate") { $gzip_type = "gzip"; } }
56 $output = @ob_get_clean();
57 $output = preg_replace("/<title>(.*?)<\/title>/i", "<title>".$new_title."</title>", $output);
58 /* Change Some PHP Settings Fix the &PHPSESSID to &PHPSESSID */
59 $SessName = @session_name();
60 $output = preg_replace("/&PHPSESSID/", "&PHPSESSID", $output);
61 $qstrcode = htmlentities($Settings['qstr'], ENT_QUOTES, $Settings['charset']);
62 $output = str_replace($Settings['qstr'].$SessName, $qstrcode.$SessName, $output);
66 if($gzip_type=="gzip") {
67 $goutput = gzencode($output); }
68 if($gzip_type=="deflate") {
69 $goutput = gzcompress($output); }
71 // Fix amp => (&) to & and gzip page
72 function fix_amp($use_gzip="off",$gzip_type="gzip") {
74 if($gzip_type!="gzip") { if($gzip_type!="deflate") { $gzip_type = "gzip"; } }
75 $output = @ob_get_clean();
76 /* Change Some PHP Settings Fix the &PHPSESSID to &PHPSESSID */
77 $SessName = @session_name();
78 $output = preg_replace("/&PHPSESSID/", "&PHPSESSID", $output);
79 $qstrcode = htmlentities($Settings['qstr'], ENT_QUOTES, $Settings['charset']);
80 $output = str_replace($Settings['qstr'].$SessName, $qstrcode.$SessName, $output);
84 if($gzip_type=="gzip") {
85 $goutput = gzencode($output); }
86 if($gzip_type=="deflate") {
87 $goutput = gzcompress($output); }
89 $Names['RJ'] = "Rene Johnson";
90 define("_rene_", $Names['RJ']);
91 // GZip page for faster download
92 function gzip_page($use_gzip="off",$gzip_type="gzip") {
94 $output = @ob_get_clean();
95 if($gzip_type!="gzip") { if($gzip_type!="deflate") { $gzip_type = "gzip"; } }
99 if($gzip_type=="gzip") {
100 $goutput = gzencode($output); }
101 if($gzip_type=="deflate") {
102 $goutput = gzcompress($output); }
104 $foo="bar"; $$foo="foo";
105 if(function_exists('mysql_set_charset')===false) {
106 function mysql_set_charset($charset) {
107 mysql_query("SET CHARACTER SET '".$charset."'");
108 mysql_query("SET NAMES '".$charset."'");
110 // SafeSQL Lite Source Code by Cool Dude 2k
111 // Make SQL Query's safe
112 function query($query_string,$query_vars) {
113 $query_array = array(array("%i","%I","%F","%S"),array("%d","%d","%f","%s"));
114 $query_string = str_replace($query_array[0], $query_array[1], $query_string);
115 if (get_magic_quotes_gpc()) {
116 $query_vars = array_map("stripslashes", $query_vars); }
117 $query_vars = array_map("mysql_real_escape_string", $query_vars);
118 $query_val = $query_vars;
119 $query_num = count($query_val);
121 while ($query_i < $query_num) {
122 $query_is = $query_i+1;
123 $query_val[$query_is] = $query_vars[$query_i];
125 $query_val[0] = $query_string;
126 return call_user_func_array("sprintf",$query_val); }
127 $Names['KP'] = "Kazuki Przyborowski";
128 define("_kazuki_", $Names['KP']);
129 // Kill bad vars for some functions
130 function killbadvars($varname) {
131 $badphp1 = array('$'); $badphp2 = array(null);
132 $varname = str_replace($badphp1, $badphp2, $varname);
133 $varname = preg_replace("/(_SERVER|_ENV|_COOKIE|_SESSION)/i", null, $varname);
134 $varname = preg_replace("/(_GET|_POST|_FILES|_REQUEST|GLOBALS)/i", null, $varname);
135 $varname = preg_replace("/(HTTP_SERVER_VARS|HTTP_ENV_VARS)/i", null, $varname);
136 $varname = preg_replace("/(HTTP_COOKIE_VARS|HTTP_SESSION_VARS)/i", null, $varname);
137 $varname = preg_replace("/(HTTP_GET_VARS|HTTP_POST_VARS|HTTP_POST_FILES)/i", null, $varname);
139 // Trying to fix this bug. ^_^
140 // http://xforce.iss.net/xforce/xfdb/49697
141 if(!isset($Settings['DefaultTheme'])) {
142 $Settings['DefaultTheme'] = "iDB"; }
143 $BoardTheme = $Settings['DefaultTheme'];
144 //Check to make sure theme exists
145 function chack_themes($theme) {
147 if(!isset($theme)) { $theme = null; }
148 require('settings.php');
149 $ckskindir = dirname(realpath("settings.php"))."/".$SettDir['themes'];
150 if ($handle = opendir($ckskindir)) { $dirnum = null;
151 while (false !== ($ckfile = readdir($handle))) {
152 if ($dirnum==null) { $dirnum = 0; }
153 if (file_exists($ckskindir.$ckfile."/info.php")) {
154 if ($ckfile != "." && $ckfile != "..") {
155 //include($ckskindir.$ckfile."/info.php");
156 $cktheme[$dirnum] = $ckfile;
158 closedir($handle); asort($cktheme); }
159 $theme=preg_replace("/(.*?)\.\/(.*?)/", $BoardTheme, $theme);
160 if(!in_array($theme,$cktheme)||strlen($theme)>26) {
161 $theme = $BoardTheme; } return $theme; }
162 // Change the text to icons(smileys)
163 function text2icons($Text,$sqlt) {
165 $reneequery=query("SELECT * FROM `".$sqlt."smileys`", array(null));
166 $reneeresult=mysql_query($reneequery);
167 $reneenum=mysql_num_rows($reneeresult);
169 while ($renees < $reneenum) {
170 $FileName=mysql_result($reneeresult,$renees,"FileName");
171 $SmileName=mysql_result($reneeresult,$renees,"SmileName");
172 $SmileText=mysql_result($reneeresult,$renees,"SmileText");
173 $SmileDirectory=mysql_result($reneeresult,$renees,"Directory");
174 $ShowSmile=mysql_result($reneeresult,$renees,"Show");
175 $ReplaceType=mysql_result($reneeresult,$renees,"ReplaceCI");
176 if($ReplaceType=="on") { $ReplaceType = "yes"; }
177 if($ReplaceType=="off") { $ReplaceType = "no"; }
178 if($ReplaceType!="yes"||$ReplaceType!="no") { $ReplaceType = "no"; }
179 $Smile1 = $SmileText;
180 $Smile2 = '<img src="'.$SmileDirectory.''.$FileName.'" style="vertical-align: middle; border: 0px;" title="'.$SmileName.'" alt="'.$SmileName.'" />';
181 if($ReplaceType=="no") {
182 $Text = str_replace($Smile1, $Smile2, $Text); }
183 if($ReplaceType=="yes") {
184 $Smile1 = preg_quote($SmileText,"/");
185 $Text = preg_replace("/".$Smile1."/i",$Smile2,$Text); }
186 ++$renees; } return $Text; }
187 // Removes the bad stuff
188 function remove_bad_entities($Text) {
189 //HTML Entities Dec Version
190 $Text = preg_replace("/‮/isU","",$Text);
191 $Text = preg_replace("/ /isU","",$Text);
192 $Text = preg_replace("/ /isU","",$Text);
193 $Text = preg_replace("/ /isU","",$Text);
194 $Text = preg_replace("/‌/isU","",$Text);
195 $Text = preg_replace("/‍/isU","",$Text);
196 $Text = preg_replace("/‎/isU","",$Text);
197 $Text = preg_replace("/‏/isU","",$Text);
198 //HTML Entities Hex Version
199 $Text = preg_replace("/‮/isU","",$Text);
200 $Text = preg_replace("/ /isU","",$Text);
201 $Text = preg_replace("/ /isU","",$Text);
202 $Text = preg_replace("/ /isU","",$Text);
203 $Text = preg_replace("/‌/isU","",$Text);
204 $Text = preg_replace("/‍/isU","",$Text);
205 $Text = preg_replace("/‎/isU","",$Text);
206 $Text = preg_replace("/‏/isU","",$Text);
207 //HTML Entities Name Version
208 $Text = preg_replace("/ /isU","",$Text);
209 $Text = preg_replace("/ /isU","",$Text);
210 $Text = preg_replace("/ /isU","",$Text);
211 $Text = preg_replace("/‌/isU","",$Text);
212 $Text = preg_replace("/‍/isU","",$Text);
213 $Text = preg_replace("/‎/isU","",$Text);
214 $Text = preg_replace("/‏/isU","",$Text);
216 // Remove the bad stuff
217 function remove_spaces($Text) {
218 $Text = preg_replace("/(^\t+|\t+$)/","",$Text);
219 $Text = preg_replace("/(^\n+|\n+$)/","",$Text);
220 $Text = preg_replace("/(^\r+|\r+$)/","",$Text);
221 $Text = preg_replace("/(\r|\n|\t)+/"," ",$Text);
222 $Text = preg_replace("/\s\s+/"," ",$Text);
223 $Text = preg_replace("/(^\s+|\s+$)/","",$Text);
224 $Text = @remove_bad_entities($Text);
227 function fixbamps($text) {
228 $fixamps1 = array("&copy;","&reg;","&trade;","&quot;","&amp;","&lt;","&gt;","&(a|e|i|o|u|y)acute;","&(a|e|i|o|u)grave;","&(a|e|i|o|u)circ;","&(a|e|i|o|u|y)uml;","&(a|o|n)tilde;","&aring;","&aelig;","&ccedil;","&eth;","&oslash;","&szlig;","&thorn;");
229 $fixamps2 = array("©","®","™",""","&","<",">","&\\1acute;","&\\1grave;","&\\1circ;","&\\1uml;","&\\1tilde;","å","æ","ç","ð","ø","ß","þ");
230 $ampnum = count($fixamps1); $ampi=0;
231 while ($ampi < $ampnum) {
232 $text = preg_replace("/".$fixamps1[$ampi]."/i", $fixamps2[$ampi], $text);
234 $text = preg_replace("/&#(x[a-f0-9]+|[0-9]+);/i", "&#$1;", $text);
236 // Get next id for stuff
237 function getnextid($tablepre,$table) {
238 $getnextidq = query("SHOW TABLE STATUS LIKE '".$tablepre.$table."'", array());
239 $getnextidr = mysql_query($getnextidq);
240 $getnextid = mysql_fetch_assoc($getnextidr);
241 return $getnextid['Auto_increment'];
242 @mysql_free_result($getnextidr); }
243 // Get number of rows for table
244 function getnumrows($tablepre,$table) {
245 $getnextidq = query("SHOW TABLE STATUS LIKE '".$tablepre.$table."'", array());
246 $getnextidr = mysql_query($getnextidq);
247 $getnextid = mysql_fetch_assoc($getnextidr);
248 return $getnextid['Rows'];
249 @mysql_free_result($getnextidr); }
250 $Names['K'] = "Katarzyna";
251 define("_katarzyna_", $Names['K']);
252 // Change Time Stamp to a readable time
253 function GMTimeChange($format,$timestamp,$offset,$minoffset=null,$dst=null) {
254 $TCHour = date("H",$timestamp);
255 $TCMinute = date("i",$timestamp);
256 $TCSecond = date("s",$timestamp);
257 $TCMonth = date("n",$timestamp);
258 $TCDay = date("d",$timestamp);
259 $TCYear = date("Y",$timestamp);
261 if(!is_numeric($minoffset)) { $minoffset = "00"; }
262 $ts_array = explode(":",$offset);
263 if(count($ts_array)!=2) {
264 if(!isset($ts_array[0])) { $ts_array[0] = "0"; }
265 if(!isset($ts_array[1])) { $ts_array[1] = "00"; }
266 $offset = $ts_array[0].":".$ts_array[1]; }
267 if(!is_numeric($ts_array[0])) { $ts_array[0] = "0"; }
268 if($ts_array[0]>12) { $ts_array[0] = "12"; $offset = $ts_array[0].":".$ts_array[1]; }
269 if($ts_array[0]<-12) { $ts_array[0] = "-12"; $offset = $ts_array[0].":".$ts_array[1]; }
270 if(!is_numeric($ts_array[1])) { $ts_array[1] = "00"; }
271 if($ts_array[1]>59) { $ts_array[1] = "59"; $offset = $ts_array[0].":".$ts_array[1]; }
272 if($ts_array[1]<0) { $ts_array[1] = "00"; $offset = $ts_array[0].":".$ts_array[1]; }
273 $tsa = array("offset" => $offset, "hour" => $ts_array[0], "minute" => $ts_array[1]);
274 //$tsa['minute'] = $tsa['minute'] + $minoffset;
275 if($dst!="on"&&$dst!="off") { $dst = "off"; }
276 if($dst=="on") { if($dstake!="done") {
277 $dstake = "done"; $tsa['hour'] = $tsa['hour']+1; } }
278 $TCHour = $TCHour + $tsa['hour'];
279 $TCMinute = $TCMinute + $tsa['minute'];
280 return date($format,mktime($TCHour,$TCMinute,$TCSecond,$TCMonth,$TCDay,$TCYear)); }
281 $Names['D'] = "Dagmara";
282 define("_dagmara_", $Names['D']);
283 // Change Time Stamp to a readable time
284 function TimeChange($format,$timestamp,$offset,$minoffset=null,$dst=null) {
285 return GMTimeChange($format,$timestamp,$offset,$minoffset,$dst); }
286 // Make a GMT Time Stamp
287 function GMTimeStamp() {
288 $GMTHour = gmdate("H");
289 $GMTMinute = gmdate("i");
290 $GMTSecond = gmdate("s");
291 $GMTMonth = gmdate("n");
292 $GMTDay = gmdate("d");
293 $GMTYear = gmdate("Y");
294 return mktime($GMTHour,$GMTMinute,$GMTSecond,$GMTMonth,$GMTDay,$GMTYear); }
295 // Make a GMT Time Stamp alt version
296 function GMTimeStampS() { return time() - date('Z', time()); }
298 function GMTimeGet($format,$offset,$minoffset=null,$dst=null) {
299 return GMTimeChange($format,GMTimeStamp(),$offset,$minoffset,$dst); }
300 // Get GMT Time alt version
301 function GMTimeGetS($format,$offset,$minoffset=null,$dst=null) {
303 if(!is_numeric($offset)) { $offset = "0"; }
304 if(!is_numeric($minoffset)) { $minoffset = "00"; }
305 $ts_array = explode(":",$offset);
306 if(count($ts_array)!=2) {
307 if(!isset($ts_array[0])) { $ts_array[0] = "0"; }
308 if(!isset($ts_array[1])) { $ts_array[1] = "00"; }
309 $offset = $ts_array[0].":".$ts_array[1]; }
310 if(!is_numeric($ts_array[0])) { $ts_array[0] = "0"; }
311 if($ts_array[0]>12) { $ts_array[0] = "12"; $offset = $ts_array[0].":".$ts_array[1]; }
312 if($ts_array[0]<-12) { $ts_array[0] = "-12"; $offset = $ts_array[0].":".$ts_array[1]; }
313 if(!is_numeric($ts_array[1])) { $ts_array[1] = "00"; }
314 if($ts_array[1]>59) { $ts_array[1] = "59"; $offset = $ts_array[0].":".$ts_array[1]; }
315 if($ts_array[1]<0) { $ts_array[1] = "00"; $offset = $ts_array[0].":".$ts_array[1]; }
316 $tsa = array("offset" => $offset, "hour" => $ts_array[0], "minute" => $ts_array[1]);
317 //$tsa['minute'] = $tsa['minute'] + $minoffset;
318 if($dst!="on"&&$dst!="off") { $dst = "off"; }
319 if($dst=="on") { if($dstake!="done") {
320 $dstake = "done"; $tsa['hour'] = $tsa['hour']+1; } }
321 return date($format,mktime(gmdate('h')+$tsa['hour'],gmdate('i')+$tsa['minute'],gmdate('s'),gmdate('n'),gmdate('j'),gmdate('Y'))); }
323 function GetSeverZone() {
324 $TestHour1 = date("H");
325 @putenv("OTZ=".@getenv("TZ"));
327 $TestHour2 = date("H");
328 @putenv("TZ=".@getenv("OTZ"));
329 $TestHour3 = $TestHour1-$TestHour2;
331 // Get Server offset alt version
332 function SeverOffSet() {
333 $TestHour1 = date("H");
334 $TestHour2 = gmdate("H");
335 $TestHour3 = $TestHour1-$TestHour2;
337 // Get Server offset new version
338 function SeverOffSetNew() {
339 return gmdate("g",mktime(0,date("Z"))); }
340 function gmtime() { return time() - (int) date('Z'); }
341 // Acts like highlight_file();
342 function file_get_source($filename,$return = FALSE) {
343 $phpsrc = file_get_contents($filename);
344 $phpsrcs = highlight_string($phpsrc,$return);
346 // Also acts like highlight_file(); but valid xhtml
347 function valid_get_source($filename) {
348 $phpsrcs = file_get_source($filename,TRUE);
349 // Change font tag to span tag for valid xhtml
350 $phpsrcs = preg_replace("/\<font color=\"(.*?)\"\>/i", "<span style=\"color: \\1;\">", $phpsrcs);
351 $phpsrcs = preg_replace("/\<\/font>/i", "</span>", $phpsrcs);
353 function GetUserName($idu,$sqlt) {
354 $gunquery = query("SELECT * FROM `".$sqlt."members` WHERE `id`=%i", array($idu));
355 $gunresult=mysql_query($gunquery);
356 $gunnum=mysql_num_rows($gunresult);
358 $UsersName=mysql_result($gunresult,0,"Name"); }
359 @mysql_free_result($gunresult);
361 // Check to see if I'm hidden from you. >_> | ^_^ | <_<
362 function GetHiddenMember($idu,$sqlt) {
363 $gunquery = query("SELECT * FROM `".$sqlt."members` WHERE `id`=%i", array($idu));
364 $gunresult=mysql_query($gunquery);
365 $gunnum=mysql_num_rows($gunresult);
366 // I'm now hidden from you. ^_^ | <_< I cant find you.
367 $UsersHidden = "yes";
369 // Am i still hidden. o_O <_< I see you.
370 $UsersHidden=mysql_result($gunresult,0,"HiddenMember"); }
371 @mysql_free_result($gunresult);
372 return $UsersHidden; }
373 // hmac hash function
374 function hmac($data,$key,$hash='sha1',$blocksize=64) {
375 if (strlen($key)>$blocksize) {
376 $key=pack('H*',$hash($key)); }
377 $key=str_pad($key, $blocksize, chr(0x00));
378 $ipad=str_repeat(chr(0x36),$blocksize);
379 $opad=str_repeat(chr(0x5c),$blocksize);
380 return $hash(($key^$opad).pack('H*',$hash(($key^$ipad).$data))); }
381 // b64hmac hash function
382 function b64e_hmac($data,$key,$extdata,$hash='sha1',$blocksize=64) {
383 $extdata2 = hexdec($extdata); $key = $key.$extdata2;
384 return base64_encode(hmac($data,$key,$hash,$blocksize).$extdata); }
385 // b64hmac rot13 hash function
386 function b64e_rot13_hmac($data,$key,$extdata,$hash='sha1',$blocksize=64) {
387 $data = str_rot13($data);
388 $extdata2 = hexdec($extdata); $key = $key.$extdata2;
389 return base64_encode(hmac($data,$key,$hash,$blocksize).$extdata); }
390 // salt hmac hash function
391 function salt_hmac($size1=4,$size2=6) {
392 $hprand = rand(4,6); $i = 0; $hpass = "";
393 while ($i < $hprand) {
394 $hspsrand = rand(1,2);
395 if($hspsrand!=1&&$hspsrand!=2) { $hspsrand=1; }
396 if($hspsrand==1) { $hpass .= chr(rand(48,57)); }
397 if($hspsrand==2) { $hpass .= chr(rand(65,70)); }
398 ++$i; } return $hpass; }
399 /* is_empty by M at http://us2.php.net/manual/en/function.empty.php#74093 */
400 function is_empty($var) {
401 if (((is_null($var) || rtrim($var) == "") &&
402 $var !== false) || (is_array($var) && empty($var))) {
403 return true; } else { return false; } }
404 // Try and convert IPB 2.0.0 style passwords to iDB style passwords
405 function hash2xkey($data,$key,$hash1='md5',$hash2='md5') {
406 return $hash1($hash2($key).$hash2($data)); }
407 // Hash two times with md5 and sha1 for DF2k
408 function PassHash2x($Text) {
412 // Hash two times with hmac-md5 and hmac-sha1
413 function PassHash2x2($data,$key,$extdata,$blocksize=64) {
414 $extdata2 = hexdec($extdata); $key = $key.$extdata2;
415 $Text = hmac($data,$key,"md5").$extdata;
416 $Text = hmac($Text,$key,"sha1").$extdata;
417 return base64_encode($Text); }
418 function cp($infile,$outfile,$mode="w") {
419 $contents = file_get_contents($infile);
420 $cpfp = fopen($outfile,$mode);
421 fwrite($cpfp, $contents);
424 /* str_ireplace for PHP below ver. 5 updated //
425 // by Kazuki Przyborowski - Cool Dude 2k //
426 // and upaded by Kazuki Przyborowski again */
427 if(!function_exists('str_ireplace')) {
428 function str_ireplace($search,$replace,$subject) {
429 if(!is_array($search)&&is_array($replace)) {
430 $search = array($search); }
431 if(is_array($search)&&!is_array($replace)) {
432 $replace = array($replace); }
433 if(is_array($search)&&is_array($replace)) {
434 $sc=count($search); $rc=count($replace); $sn=0;
435 if($sc!=$rc) { return false; }
437 $search[$sn] = preg_quote($search[$sn], "/");
438 $subject = preg_replace("/".$search[$sn]."/i", $replace[$sn], $subject);
440 if(!is_array($search)&&!is_array($replace)) {
441 $search = preg_quote($search, "/");
442 $subject = preg_replace("/".$search."/i", $replace, $subject); }
444 /* Adds mysql_set_charset to PHP below Ver. 5.2.3 - by: Janez R. //
445 // http://us.php.net/manual/en/function.mysql-set-charset.php#77565 */
446 if (!function_exists('mysql_set_charset')) {
447 function mysql_set_charset($charset) {
448 return mysql_query("set names $charset"); } }
449 /* Adds httponly to PHP below Ver. 5.2.0 //
450 // by Kazuki Przyborowski - Cool Dude 2k */
451 function http_set_cookie($name,$value=null,$expire=null,$path=null,$domain=null,$secure=false,$httponly=false) {
452 $mkcookie = null; $expireGMT = null;
453 if(!isset($name)) { echo "Error: You need to enter a name for cookie."; return false; }
454 if(!isset($expire)) { echo "Error: You need to enter a time for cookie to expire."; return false; }
455 $expireGMT = gmdate("D, d-M-Y H:i:s \G\M\T", $expire);
456 if(!isset($value)) { $value = null; }
457 if(!isset($httponly)||$httponly==false) {
458 setcookie($name, $value, $expire, $path, $domain, $secure); return true; }
459 if(version_compare(PHP_VERSION,"5.2.0",">=")&&$httponly==true) {
460 setcookie($name, $value, $expire, $path, $domain, $secure, $httponly); return true; }
461 if(version_compare(PHP_VERSION,"5.2.0","<")&&$httponly==true) {
462 $mkcookie = "Set-Cookie: ".rawurlencode($name)."=".rawurlencode($value);
463 $mkcookie = $mkcookie."; expires=".$expireGMT;
464 if(isset($path)&&$path!=null) { $mkcookie = $mkcookie."; path=".$path; }
465 if(isset($domain)&&$domain!=null) { $mkcookie = $mkcookie."; domain=".$domain; }
466 if(isset($secure)&&$secure===true) { $mkcookie = $mkcookie."; secure"; }
467 if(isset($httponly)&&$httponly===true) { $mkcookie = $mkcookie."; HttpOnly"; }
468 header($mkcookie, false); return true; } }
469 $foobar="fubar"; $$foobar="foobar";
471 function dump_included_files() { return var_dump(get_included_files()); }
472 function count_included_files() { return count(get_included_files()); }
473 function dump_extensions() { return var_dump(get_loaded_extensions()); }
474 function count_extensions() { return count(get_loaded_extensions()); }