OSDN Git Service

Small update.
[idb/iDB.git.git] / inc / misc / functions.php
1 <?php
2 /*
3     This program is free software; you can redistribute it and/or modify
4     it under the terms of the Revised BSD License.
5
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.
10
11     Copyright 2004-2008 Cool Dude 2k - http://idb.berlios.de/
12     Copyright 2004-2008 Game Maker 2k - http://intdb.sourceforge.net/
13
14     $FileInfo: functions.php - Last Update: 10/27/2008 SVN 184 - Author: cooldude2k $
15 */
16 $File3Name = basename($_SERVER['SCRIPT_NAME']);
17 if ($File3Name=="functions.php"||$File3Name=="/functions.php") {
18         require('index.php');
19         exit(); }
20 // Check the file names
21 function CheckFile($FileName) {
22 $File3Name = basename($_SERVER['SCRIPT_NAME']);
23 if ($File3Name==$FileName||$File3Name=="/".$FileName) {
24         require('index.php');
25         exit(); }
26 return null; }
27 function CheckFiles($FileName) {
28 $File3Name = basename($_SERVER['SCRIPT_NAME']);
29 if ($File3Name==$FileName||$File3Name=="/".$FileName) {
30         return true; } }
31 CheckFile("functions.php");
32 require($SettDir['misc']."compression.php");
33 /* 
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) {
43 $StatSQL = @mysql_connect($sqlhost,$sqluser,$sqlpass);
44 $StatBase = @mysql_select_db($sqldb);
45 if (!$StatSQL) { return false; }
46 if (!$StatBase) { return false; }
47 return true; }
48         $Names['RS'] = "Renee Sabonis";
49 define("_renee_", $Names['RS']);
50 // Change the title and gzip page
51 function change_title($new_title,$use_gzip="off",$gzip_type="gzip") {
52 global $Settings;
53 if($gzip_type!="gzip") { if($gzip_type!="deflate") { $gzip_type = "gzip"; } }
54 $output = @ob_get_clean();
55 $output = preg_replace("/<title>(.*?)<\/title>/i", "<title>".$new_title."</title>", $output);
56 /* Change Some PHP Settings Fix the &PHPSESSID to &amp;PHPSESSID */
57 $SessName = @session_name();
58 $output = preg_replace("/&PHPSESSID/", "&amp;PHPSESSID", $output);
59 $qstrcode = htmlentities($Settings['qstr'], ENT_QUOTES, $Settings['charset']);
60 $output = str_replace($Settings['qstr'].$SessName, $qstrcode.$SessName, $output);
61 if($use_gzip!="on") {
62         echo $output; }
63 if($use_gzip=="on") {
64         if($gzip_type=="gzip") {
65         $goutput = gzencode($output); }
66         if($gzip_type=="deflate") {
67         $goutput = gzcompress($output); }
68         echo $goutput; } }
69 // Fix amp => (&) to &amp; and gzip page
70 function fix_amp($use_gzip="off",$gzip_type="gzip") {
71 global $Settings;
72 if($gzip_type!="gzip") { if($gzip_type!="deflate") { $gzip_type = "gzip"; } }
73 $output = @ob_get_clean();
74 /* Change Some PHP Settings Fix the &PHPSESSID to &amp;PHPSESSID */
75 $SessName = @session_name();
76 $output = preg_replace("/&PHPSESSID/", "&amp;PHPSESSID", $output);
77 $qstrcode = htmlentities($Settings['qstr'], ENT_QUOTES, $Settings['charset']);
78 $output = str_replace($Settings['qstr'].$SessName, $qstrcode.$SessName, $output);
79 if($use_gzip!="on") {
80         echo $output; }
81 if($use_gzip=="on") {
82         if($gzip_type=="gzip") {
83         $goutput = gzencode($output); }
84         if($gzip_type=="deflate") {
85         $goutput = gzcompress($output); }
86         echo $goutput; } }
87 $output = @ob_get_clean();
88         $Names['RJ'] = "Kazuki Przyborowski";
89 define("_rene_", $Names['RJ']);
90 // GZip page for faster download
91 function gzip_page($use_gzip="off",$gzip_type="gzip") {
92 global $Settings;
93 $output = @ob_get_clean();
94 if($gzip_type!="gzip") { if($gzip_type!="deflate") { $gzip_type = "gzip"; } }
95 if($use_gzip!="on") {
96         echo $output; }
97 if($use_gzip=="on") {
98         if($gzip_type=="gzip") {
99         $goutput = gzencode($output); }
100         if($gzip_type=="deflate") {
101         $goutput = gzcompress($output); }
102         echo $goutput; } }
103 $foo="bar"; $$foo="foo";
104 // SafeSQL Lite Source Code by Cool Dude 2k
105 // Make SQL Query's safe
106 function query($query_string,$query_vars) {
107    $query_array = array(array("%i","%I","%F","%S"),array("%d","%d","%f","%s"));
108    $query_string = str_replace($query_array[0], $query_array[1], $query_string);
109    if (get_magic_quotes_gpc()) {
110        $query_vars  = array_map("stripslashes", $query_vars); }
111    $query_vars = array_map("mysql_real_escape_string", $query_vars);
112    $query_val = $query_vars;
113 $query_num = count($query_val);
114 $query_i = 0;
115 while ($query_i < $query_num) {
116 $query_is = $query_i+1;
117 $query_val[$query_is] = $query_vars[$query_i];
118 ++$query_i; }
119    $query_val[0] = $query_string;
120    return call_user_func_array("sprintf",$query_val); }
121         $Names['KP'] = "Kazuki Przyborowski";
122 define("_kazuki_", $Names['KP']);
123 // Kill bad vars for some functions
124 function killbadvars($varname) {
125 $badphp1 = array('$'); $badphp2 = array(null);
126 $varname = str_replace($badphp1, $badphp2, $varname);
127 $varname = preg_replace("/(_SERVER|_ENV|_COOKIE|_SESSION)/i", null, $varname);
128 $varname = preg_replace("/(_GET|_POST|_FILES|_REQUEST|GLOBALS)/i", null, $varname);
129 $varname = preg_replace("/(HTTP_SERVER_VARS|HTTP_ENV_VARS)/i", null, $varname);
130 $varname = preg_replace("/(HTTP_COOKIE_VARS|HTTP_SESSION_VARS)/i", null, $varname);
131 $varname = preg_replace("/(HTTP_GET_VARS|HTTP_POST_VARS|HTTP_POST_FILES)/i", null, $varname);
132         return $varname; }
133 // Change the text to icons(smileys)
134 function text2icons($Text,$sqlt) {
135 global $Settings;
136 $reneequery=query("SELECT * FROM `".$sqlt."smileys`", array(null));
137 $reneeresult=mysql_query($reneequery);
138 $reneenum=mysql_num_rows($reneeresult);
139 $renees=0;
140 while ($renees < $reneenum) {
141 $FileName=mysql_result($reneeresult,$renees,"FileName");
142 $SmileName=mysql_result($reneeresult,$renees,"SmileName");
143 $SmileText=mysql_result($reneeresult,$renees,"SmileText");
144 $SmileDirectory=mysql_result($reneeresult,$renees,"Directory");
145 $ShowSmile=mysql_result($reneeresult,$renees,"Show");
146 $ReplaceType=mysql_result($reneeresult,$renees,"ReplaceCI");
147 if($ReplaceType=="on") { $ReplaceType = "yes"; }
148 if($ReplaceType=="off") { $ReplaceType = "no"; }
149 if($ReplaceType!="yes"||$ReplaceType!="no") { $ReplaceType = "no"; }
150 $Smile1 = $SmileText;
151 $Smile2 = '<img src="'.$SmileDirectory.''.$FileName.'" style="vertical-align: middle; border: 0px;" title="'.$SmileName.'" alt="'.$SmileName.'" />';
152 if($ReplaceType=="no") {
153 $Text = str_replace($Smile1, $Smile2, $Text); }
154 if($ReplaceType=="yes") {
155         $Smile1 = preg_quote($SmileText,"/");
156 $Text = preg_replace("/".$Smile1."/i",$Smile2,$Text); }
157 ++$renees; } return $Text; }
158 // Removes the bad stuff
159 function remove_bad_entities($Text) {
160 //HTML Entities Dec Version
161 $Text = preg_replace("/&#8238;/isU","",$Text);
162 $Text = preg_replace("/&#8194;/isU","",$Text);
163 $Text = preg_replace("/&#8195;/isU","",$Text);
164 $Text = preg_replace("/&#8201;/isU","",$Text);
165 $Text = preg_replace("/&#8204;/isU","",$Text);
166 $Text = preg_replace("/&#8205;/isU","",$Text);
167 $Text = preg_replace("/&#8206;/isU","",$Text);
168 $Text = preg_replace("/&#8207;/isU","",$Text);
169 //HTML Entities Hex Version
170 $Text = preg_replace("/&#x202e;/isU","",$Text);
171 $Text = preg_replace("/&#x2002;/isU","",$Text);
172 $Text = preg_replace("/&#x2003;/isU","",$Text);
173 $Text = preg_replace("/&#x2009;/isU","",$Text);
174 $Text = preg_replace("/&#x200c;/isU","",$Text);
175 $Text = preg_replace("/&#x200d;/isU","",$Text);
176 $Text = preg_replace("/&#x200e;/isU","",$Text);
177 $Text = preg_replace("/&#x200f;/isU","",$Text);
178 //HTML Entities Name Version
179 $Text = preg_replace("/&ensp;/isU","",$Text);
180 $Text = preg_replace("/&emsp;/isU","",$Text);
181 $Text = preg_replace("/&thinsp;/isU","",$Text);
182 $Text = preg_replace("/&zwnj;/isU","",$Text);
183 $Text = preg_replace("/&zwj;/isU","",$Text);
184 $Text = preg_replace("/&lrm;/isU","",$Text);
185 $Text = preg_replace("/&rlm;/isU","",$Text);
186 return $Text; }
187 // Remove the bad stuff
188 function remove_spaces($Text) {
189 $Text = preg_replace("/(^\t+|\t+$)/","",$Text);
190 $Text = preg_replace("/(^\n+|\n+$)/","",$Text);
191 $Text = preg_replace("/(^\r+|\r+$)/","",$Text);
192 $Text = preg_replace("/(\r|\n|\t)+/"," ",$Text);
193 $Text = preg_replace("/\s\s+/"," ",$Text);
194 $Text = preg_replace("/(^\s+|\s+$)/","",$Text);
195 $Text = @remove_bad_entities($Text);
196 return $Text; }
197 // Fix some chars
198 function fixbamps($text) {
199 $fixamps1 = array("&amp;copy;","&amp;reg;","&amp;trade;","&amp;quot;","&amp;amp;","&amp;lt;","&amp;gt;","&amp;(a|e|i|o|u|y)acute;","&amp;(a|e|i|o|u)grave;","&amp;(a|e|i|o|u)circ;","&amp;(a|e|i|o|u|y)uml;","&amp;(a|o|n)tilde;","&amp;aring;","&amp;aelig;","&amp;ccedil;","&amp;eth;","&amp;oslash;","&amp;szlig;","&amp;thorn;");
200 $fixamps2 = array("&copy;","&reg;","&trade;","&quot;","&amp;","&lt;","&gt;","&\\1acute;","&\\1grave;","&\\1circ;","&\\1uml;","&\\1tilde;","&aring;","&aelig;","&ccedil;","&eth;","&oslash;","&szlig;","&thorn;");
201 $ampnum = count($fixamps1); $ampi=0;
202 while ($ampi < $ampnum) {
203 $text = preg_replace("/".$fixamps1[$ampi]."/i", $fixamps2[$ampi], $text);
204 ++$ampi; }
205 $text = preg_replace("/&amp;#(x[a-f0-9]+|[0-9]+);/i", "&#$1;", $text);
206 return $text; }
207 // Get next id for stuff
208 function getnextid($tablepre,$table) {
209    $getnextidq = query("SHOW TABLE STATUS LIKE '".$tablepre.$table."'", array());
210    $getnextidr = mysql_query($getnextidq);
211    $getnextid = mysql_fetch_assoc($getnextidr);
212    return $getnextid['Auto_increment'];
213    @mysql_free_result($getnextidr); }
214 function getnumrows($tablepre,$table) {
215    $getnextidq = query("SHOW TABLE STATUS LIKE '".$tablepre.$table."'", array());
216    $getnextidr = mysql_query($getnextidq);
217    $getnextid = mysql_fetch_assoc($getnextidr);
218    return $getnextid['Rows'];
219    @mysql_free_result($getnextidr); }
220         $Names['K'] = "Katarzyna";
221 define("_katarzyna_", $Names['K']);
222 // Change Time Stamp to a readable time
223 function GMTimeChange($format,$timestamp,$offset,$minoffset=null,$dst=null) {
224 $TCHour = date("H",$timestamp);
225 $TCMinute = date("i",$timestamp);
226 $TCSecond = date("s",$timestamp);
227 $TCMonth = date("n",$timestamp);
228 $TCDay = date("d",$timestamp);
229 $TCYear = date("Y",$timestamp);
230 $dstake = null;
231 if(!is_numeric($minoffset)) { $minoffset = "00"; }
232 $ts_array = explode(":",$offset);
233 if(count($ts_array)!=2) {
234         if(!isset($ts_array[0])) { $ts_array[0] = "0"; }
235         if(!isset($ts_array[1])) { $ts_array[1] = "00"; }
236         $offset = $ts_array[0].":".$ts_array[1]; }
237 if(!is_numeric($ts_array[0])) { $ts_array[0] = "0"; }
238 if($ts_array[0]>12) { $ts_array[0] = "12"; $offset = $ts_array[0].":".$ts_array[1]; }
239 if($ts_array[0]<-12) { $ts_array[0] = "-12"; $offset = $ts_array[0].":".$ts_array[1]; }
240 if(!is_numeric($ts_array[1])) { $ts_array[1] = "00"; }
241 if($ts_array[1]>59) { $ts_array[1] = "59"; $offset = $ts_array[0].":".$ts_array[1]; }
242 if($ts_array[1]<0) { $ts_array[1] = "00"; $offset = $ts_array[0].":".$ts_array[1]; }
243 $tsa = array("offset" => $offset, "hour" => $ts_array[0], "minute" => $ts_array[1]);
244 //$tsa['minute'] = $tsa['minute'] + $minoffset;
245 if($dst!="on"&&$dst!="off") { $dst = "off"; }
246 if($dst=="on") { if($dstake!="done") { 
247         $dstake = "done"; $tsa['hour'] = $tsa['hour']+1; } }
248 $TCHour = $TCHour + $tsa['hour'];
249 $TCMinute = $TCMinute + $tsa['minute'];
250 return date($format,mktime($TCHour,$TCMinute,$TCSecond,$TCMonth,$TCDay,$TCYear)); }
251         $Names['CK'] = "Christine";
252 define("_christine_", $Names['CK']);
253 // Change Time Stamp to a readable time
254 function TimeChange($format,$timestamp,$offset,$minoffset=null,$dst=null) {
255 return GMTimeChange($format,$timestamp,$offset,$minoffset,$dst); }
256 // Make a GMT Time Stamp
257 function GMTimeStamp() {
258 $GMTHour = gmdate("H");
259 $GMTMinute = gmdate("i");
260 $GMTSecond = gmdate("s");
261 $GMTMonth = gmdate("n");
262 $GMTDay = gmdate("d");
263 $GMTYear = gmdate("Y");
264 return mktime($GMTHour,$GMTMinute,$GMTSecond,$GMTMonth,$GMTDay,$GMTYear); }
265 function GMTimeStampS() { return time() - date('Z', time()); }
266 function GMTimeGet($format,$offset,$minoffset=null,$dst=null) { 
267         return GMTimeChange($format,GMTimeStamp(),$offset,$minoffset,$dst); }
268 function GMTimeGetS($format,$offset,$minoffset=null,$dst=null) {
269 $dstake = null;
270 if(!is_numeric($offset)) { $offset = "0"; }
271 if(!is_numeric($minoffset)) { $minoffset = "00"; }
272 $ts_array = explode(":",$offset);
273 if(count($ts_array)!=2) {
274         if(!isset($ts_array[0])) { $ts_array[0] = "0"; }
275         if(!isset($ts_array[1])) { $ts_array[1] = "00"; }
276         $offset = $ts_array[0].":".$ts_array[1]; }
277 if(!is_numeric($ts_array[0])) { $ts_array[0] = "0"; }
278 if($ts_array[0]>12) { $ts_array[0] = "12"; $offset = $ts_array[0].":".$ts_array[1]; }
279 if($ts_array[0]<-12) { $ts_array[0] = "-12"; $offset = $ts_array[0].":".$ts_array[1]; }
280 if(!is_numeric($ts_array[1])) { $ts_array[1] = "00"; }
281 if($ts_array[1]>59) { $ts_array[1] = "59"; $offset = $ts_array[0].":".$ts_array[1]; }
282 if($ts_array[1]<0) { $ts_array[1] = "00"; $offset = $ts_array[0].":".$ts_array[1]; }
283 $tsa = array("offset" => $offset, "hour" => $ts_array[0], "minute" => $ts_array[1]);
284 //$tsa['minute'] = $tsa['minute'] + $minoffset;
285 if($dst!="on"&&$dst!="off") { $dst = "off"; }
286 if($dst=="on") { if($dstake!="done") { 
287         $dstake = "done"; $tsa['hour'] = $tsa['hour']+1; } }
288 return date($format,mktime(gmdate('h')+$tsa['hour'],gmdate('i')+$tsa['minute'],gmdate('s'),gmdate('n'),gmdate('j'),gmdate('Y'))); }
289 // Get Server offset
290 function GetSeverZone() {
291 $TestHour1 = date("H");
292 @putenv("OTZ=".@getenv("TZ"));
293 @putenv("TZ=GMT");
294 $TestHour2 = date("H");
295 @putenv("TZ=".@getenv("OTZ"));
296 $TestHour3 = $TestHour1-$TestHour2;
297 return $TestHour3; }
298 function SeverOffSet() {
299 $TestHour1 = date("H");
300 $TestHour2 = gmdate("H");
301 $TestHour3 = $TestHour1-$TestHour2;
302 return $TestHour3; }
303 function SeverOffSetNew() {
304 return gmdate("g",mktime(0,date("Z"))); }
305 function gmtime() { return time() - (int) date('Z'); }
306 function file_get_source($filename,$return = FALSE) {
307 // Acts like highlight_file();
308 $phpsrc = file_get_contents($filename);
309 $phpsrcs = highlight_string($phpsrc,$return);
310 return $phpsrcs; }
311 function valid_get_source($filename) {
312 $phpsrcs = file_get_source($filename,TRUE);
313 // Change font tag to span tag for valid xhtml
314 $phpsrcs = preg_replace("/\<font color=\"(.*?)\"\>/i", "<span style=\"color: \\1;\">", $phpsrcs);
315 $phpsrcs = preg_replace("/\<\/font>/i", "</span>", $phpsrcs);
316 return $phpsrcs; }
317 function GetUserName($idu,$sqlt) {
318 $gunquery = query("SELECT * FROM `".$sqlt."members` WHERE `id`=%i", array($idu));
319 $gunresult=mysql_query($gunquery);
320 $gunnum=mysql_num_rows($gunresult);
321 if($gunnum>0){
322 $UsersName=mysql_result($gunresult,0,"Name"); }
323 @mysql_free_result($gunresult);
324 return $UsersName; }
325 // hmac hash function
326 function hmac($data,$key,$hash='sha1',$blocksize=64) {
327   if (strlen($key)>$blocksize) {
328   $key=pack('H*',$hash($key)); }
329   $key=str_pad($key, $blocksize, chr(0x00));
330   $ipad=str_repeat(chr(0x36),$blocksize);
331   $opad=str_repeat(chr(0x5c),$blocksize);
332   return $hash(($key^$opad).pack('H*',$hash(($key^$ipad).$data))); }
333 // b64hmac hash function
334 function b64e_hmac($data,$key,$extdata,$hash='sha1',$blocksize=64) {
335         $extdata2 = hexdec($extdata); $key = $key.$extdata2;
336   return base64_encode(hmac($data,$key,$hash,$blocksize).$extdata); }
337 // salt hmac hash function
338 function salt_hmac($size1=4,$size2=6) {
339 $hprand = rand(4,6); $i = 0; $hpass = "";
340 while ($i < $hprand) {
341 $hspsrand = rand(1,2);
342 if($hspsrand!=1&&$hspsrand!=2) { $hspsrand=1; }
343 if($hspsrand==1) { $hpass .= chr(rand(48,57)); }
344 if($hspsrand==2) { $hpass .= chr(rand(65,70)); }
345 ++$i; } return $hpass; }
346 /* is_empty by M at http://us2.php.net/manual/en/function.empty.php#74093 */
347 function is_empty($var) {
348     if (((is_null($var) || rtrim($var) == "") &&
349                 $var !== false) || (is_array($var) && empty($var))) {
350         return true; } else { return false; } }
351 // Hash two times with md5 and sha1
352 function PassHash2x($Text) {
353 $Text = md5($Text);
354 $Text = sha1($Text);
355 return $Text; }
356 // Hash two times with hmac-md5 and hmac-sha1
357 function PassHash2x2($data,$key,$extdata,$blocksize=64) {
358 $extdata2 = hexdec($extdata); $key = $key.$extdata2;
359 $Text = hmac($data,$key,"md5").$extdata; 
360 $Text = hmac($Text,$key,"sha1").$extdata;
361 return base64_encode($Text); }
362 function cp($infile,$outfile,$mode="w") { 
363    $contents = file_get_contents($infile);
364    $cpfp = fopen($outfile,$mode);
365    fwrite($cpfp, $contents);
366    fclose($cpfp);
367    return true; }
368 /* str_ireplace for PHP below ver. 5 updated // 
369 //       by Kazuki Przyborowski - Cool Dude 2k      //
370 //      and upaded by Kazuki Przyborowski again     */
371 if(!function_exists('str_ireplace')) {
372 function str_ireplace($search,$replace,$subject) {
373 if(!is_array($search)&&is_array($replace)) {
374         $search = array($search); }
375 if(is_array($search)&&!is_array($replace)) {
376         $replace = array($replace); }
377 if(is_array($search)&&is_array($replace)) {
378         $sc=count($search); $rc=count($replace); $sn=0;
379         if($sc!=$rc) { return false; }
380 while ($sc > $sn) {
381         $search[$sn] = preg_quote($search[$sn], "/");
382         $subject = preg_replace("/".$search[$sn]."/i", $replace[$sn], $subject);
383         ++$sn; } }
384 if(!is_array($search)&&!is_array($replace)) {
385 $search = preg_quote($search, "/");
386 $subject = preg_replace("/".$search."/i", $replace, $subject); }
387 return $subject; } }
388 /*   Adds mysql_set_charset to PHP below Ver. 5.2.3 - by: Janez R.      // 
389 //   http://us.php.net/manual/en/function.mysql-set-charset.php#77565   */
390 if (!function_exists('mysql_set_charset')) {
391   function mysql_set_charset($charset) {
392     return mysql_query("set names $charset"); } }
393 /*   Adds httponly to PHP below Ver. 5.2.0   // 
394 //       by Kazuki Przyborowski - Cool Dude 2k      */
395 function http_set_cookie($name,$value=null,$expire=null,$path=null,$domain=null,$secure=false,$httponly=false) {
396         $mkcookie = null; $expireGMT = null;
397         if(!isset($name)) { echo "Error: You need to enter a name for cookie."; return false; }
398         if(!isset($expire)) { echo "Error: You need to enter a time for cookie to expire."; return false; }
399         $expireGMT = gmdate("D, d-M-Y H:i:s \G\M\T", $expire);
400         if(!isset($value)) { $value = null; }
401         if(!isset($httponly)||$httponly==false) {
402         setcookie($name, $value, $expire, $path, $domain, $secure); return true; }
403         if(version_compare(PHP_VERSION,"5.2.0",">=")&&$httponly==true) {
404         setcookie($name, $value, $expire, $path, $domain, $secure, $httponly); return true; }
405         if(version_compare(PHP_VERSION,"5.2.0","<")&&$httponly==true) {
406         $mkcookie = "Set-Cookie: ".rawurlencode($name)."=".rawurlencode($value);
407         $mkcookie = $mkcookie."; expires=".$expireGMT;
408         if(isset($path)&&$path!=null) { $mkcookie = $mkcookie."; path=".$path; }
409         if(isset($domain)&&$domain!=null) { $mkcookie = $mkcookie."; domain=".$domain; }
410         if(isset($secure)&&$secure===true) { $mkcookie = $mkcookie."; secure"; }
411         if(isset($httponly)&&$httponly===true) { $mkcookie = $mkcookie."; HttpOnly"; }
412 header($mkcookie, false); return true; } }
413 $foobar="fubar"; $$foobar="foobar";
414 // Debug info
415 function dump_included_files() {        return var_dump(get_included_files()); }
416 function count_included_files() {       return count(get_included_files()); }
417 function dump_extensions() {    return var_dump(get_loaded_extensions()); }
418 function count_extensions() {   return count(get_loaded_extensions()); }
419 ?>