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-2011 iDB Support - http://idb.berlios.de/
12 Copyright 2004-2011 Game Maker 2k - http://gamemaker2k.org/
14 $FileInfo: functions.php - Last Update: 06/14/2011 SVN 672 - 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");
33 if($Settings['sqltype']=="mysql") {
34 require($SettDir['sql']."mysql.php"); }
35 if($Settings['sqltype']=="mysqli") {
36 require($SettDir['sql']."mysqli.php"); }
37 if($Settings['sqltype']=="pgsql") {
38 require($SettDir['sql']."pgsql.php"); }
39 if($Settings['sqltype']=="sqlite") {
40 require($SettDir['sql']."sqlite.php"); }
41 require($SettDir['misc']."useragents.php");
43 if ($_GET['act']=="DeleteSession") { session_destroy(); }
44 if ($_GET['act']=="ResetSession") { session_unset(); }
45 if ($_GET['act']=="NewSessionID") { session_regenerate_id(); }
46 if ($_GET['act']=="PHPInfo") { phpinfo(); exit(); }
47 if ($_GET['act']=="phpinfo") { phpinfo(); exit(); }
48 if ($_GET['act']=="PHPCredits") { phpcredits(); exit(); }
49 if ($_GET['act']=="phpcredits") { phpcredits(); exit(); }
51 // Renee Marilyn Sabonis is the best ever. ^_^
52 $Names['RS'] = "Renee Sabonis";
53 define("_renee_", $Names['RS']);
54 $CD2k_Loves="Renee Sabonis"; $I_Love="Renee Sabonis";
55 // Change the title and gzip page
56 function change_title($new_title,$use_gzip="off",$gzip_type="gzip") {
57 global $Settings,$urlstatus;
58 if(!isset($urlstatus)||!is_numeric($urlstatus)) { $urlstatus = 200; }
59 if($gzip_type!="gzip") { if($gzip_type!="deflate") { $gzip_type = "gzip"; } }
60 $output = ob_get_clean();
61 $output = preg_replace("/<title>(.*?)<\/title>/i", "<title>".$new_title."</title>", $output);
62 /* Change Some PHP Settings Fix the &PHPSESSID to &PHPSESSID */
63 $SessName = session_name();
64 $output = preg_replace("/&PHPSESSID/", "&PHPSESSID", $output);
65 $qstrcode = htmlentities($Settings['qstr'], ENT_QUOTES, $Settings['charset']);
66 $output = str_replace($Settings['qstr'].$SessName, $qstrcode.$SessName, $output);
68 idb_log_maker($urlstatus,strlen($output));
71 if($gzip_type=="gzip") {
72 $goutput = gzencode($output); }
73 if($gzip_type=="deflate") {
74 $goutput = gzcompress($output); }
75 idb_log_maker($urlstatus,strlen($goutput));
77 // Fix amp => (&) to & and gzip page
78 function fix_amp($use_gzip="off",$gzip_type="gzip") {
79 global $Settings,$urlstatus;
80 if(!isset($urlstatus)||!is_numeric($urlstatus)) { $urlstatus = 200; }
81 if($gzip_type!="gzip") { if($gzip_type!="deflate") { $gzip_type = "gzip"; } }
82 $output = ob_get_clean();
83 /* Change Some PHP Settings Fix the &PHPSESSID to &PHPSESSID */
84 $SessName = session_name();
85 $output = preg_replace("/&PHPSESSID/", "&PHPSESSID", $output);
86 $qstrcode = htmlentities($Settings['qstr'], ENT_QUOTES, $Settings['charset']);
87 $output = str_replace($Settings['qstr'].$SessName, $qstrcode.$SessName, $output);
89 idb_log_maker($urlstatus,strlen($output));
92 if($gzip_type=="gzip") {
93 $goutput = gzencode($output); }
94 if($gzip_type=="deflate") {
95 $goutput = gzcompress($output); }
96 idb_log_maker($urlstatus,strlen($goutput));
98 $Names['RJ'] = "Rene Johnson";
99 define("_rene_", $Names['RJ']);
100 // GZip page for faster download
101 function gzip_page($use_gzip="off",$gzip_type="gzip") {
102 global $Settings,$urlstatus;
103 if(!isset($urlstatus)||!is_numeric($urlstatus)) { $urlstatus = 200; }
104 $output = ob_get_clean();
105 if($gzip_type!="gzip") { if($gzip_type!="deflate") { $gzip_type = "gzip"; } }
106 if($use_gzip!="on") {
107 idb_log_maker($urlstatus,strlen($output));
109 if($use_gzip=="on") {
110 if($gzip_type=="gzip") {
111 $goutput = gzencode($output); }
112 if($gzip_type=="deflate") {
113 $goutput = gzcompress($output); }
114 idb_log_maker($urlstatus,strlen($goutput));
116 $foo="bar"; $$foo="foo";
117 $Names['KSP'] = "Kazuki Suzuki Przyborowski";
118 define("_kazuki_", $Names['KSP']);
119 // Kill bad vars for some functions
120 function killbadvars($varname) {
121 $badphp1 = array('$'); $badphp2 = array(null);
122 $varname = str_replace($badphp1, $badphp2, $varname);
123 $varname = preg_replace("/(_SERVER|_ENV|_COOKIE|_SESSION)/i", null, $varname);
124 $varname = preg_replace("/(_GET|_POST|_FILES|_REQUEST|GLOBALS)/i", null, $varname);
125 $varname = preg_replace("/(HTTP_SERVER_VARS|HTTP_ENV_VARS)/i", null, $varname);
126 $varname = preg_replace("/(HTTP_COOKIE_VARS|HTTP_SESSION_VARS)/i", null, $varname);
127 $varname = preg_replace("/(HTTP_GET_VARS|HTTP_POST_VARS|HTTP_POST_FILES)/i", null, $varname);
129 // Trying to fix this bug. ^_^
130 // http://xforce.iss.net/xforce/xfdb/49697
131 if(!isset($Settings['DefaultTheme'])) {
132 $Settings['DefaultTheme'] = "iDB"; }
133 // Change the text to icons(smileys)
134 function text2icons($Text,$sqlt,$link=null) {
136 if(!isset($link)) { $link = $SQLStat; }
137 $reneequery=sql_pre_query("SELECT * FROM \"".$sqlt."smileys\"", array(null));
138 $reneeresult=sql_query($reneequery,$link);
139 $reneenum=sql_num_rows($reneeresult);
141 while ($renees < $reneenum) {
142 $FileName=sql_result($reneeresult,$renees,"FileName");
143 $SmileName=sql_result($reneeresult,$renees,"SmileName");
144 $SmileText=sql_result($reneeresult,$renees,"SmileText");
145 $SmileDirectory=sql_result($reneeresult,$renees,"Directory");
146 $ShowSmile=sql_result($reneeresult,$renees,"Display");
147 $ReplaceType=sql_result($reneeresult,$renees,"ReplaceCI");
148 if($ReplaceType=="on") { $ReplaceType = "yes"; }
149 if($ReplaceType=="off") { $ReplaceType = "no"; }
150 if($ReplaceType!="yes"||$ReplaceType!="no") { $ReplaceType = "no"; }
151 $Smile1 = $SmileText;
152 $Smile2 = '<img src="'.$SmileDirectory.''.$FileName.'" style="vertical-align: middle; border: 0px;" title="'.$SmileName.'" alt="'.$SmileName.'" />';
153 if($ReplaceType=="no") {
154 $Text = str_replace($Smile1, $Smile2, $Text); }
155 if($ReplaceType=="yes") {
156 $Smile1 = preg_quote($SmileText,"/");
157 $Text = preg_replace("/".$Smile1."/i",$Smile2,$Text); }
158 ++$renees; } return $Text; }
159 // Removes the bad stuff
160 function remove_bad_entities($Text) {
161 //HTML Entities Dec Version
162 $Text = preg_replace("/‮/isU","",$Text);
163 $Text = preg_replace("/ /isU","",$Text);
164 $Text = preg_replace("/ /isU","",$Text);
165 $Text = preg_replace("/ /isU","",$Text);
166 $Text = preg_replace("/‌/isU","",$Text);
167 $Text = preg_replace("/‍/isU","",$Text);
168 $Text = preg_replace("/‎/isU","",$Text);
169 $Text = preg_replace("/‏/isU","",$Text);
170 //HTML Entities Hex Version
171 $Text = preg_replace("/‮/isU","",$Text);
172 $Text = preg_replace("/ /isU","",$Text);
173 $Text = preg_replace("/ /isU","",$Text);
174 $Text = preg_replace("/ /isU","",$Text);
175 $Text = preg_replace("/‌/isU","",$Text);
176 $Text = preg_replace("/‍/isU","",$Text);
177 $Text = preg_replace("/‎/isU","",$Text);
178 $Text = preg_replace("/‏/isU","",$Text);
179 //HTML Entities Name Version
180 $Text = preg_replace("/ /isU","",$Text);
181 $Text = preg_replace("/ /isU","",$Text);
182 $Text = preg_replace("/ /isU","",$Text);
183 $Text = preg_replace("/‌/isU","",$Text);
184 $Text = preg_replace("/‍/isU","",$Text);
185 $Text = preg_replace("/‎/isU","",$Text);
186 $Text = preg_replace("/‏/isU","",$Text);
188 // Remove the bad stuff
189 function remove_spaces($Text) {
190 $Text = preg_replace("/(^\t+|\t+$)/","",$Text);
191 $Text = preg_replace("/(^\n+|\n+$)/","",$Text);
192 $Text = preg_replace("/(^\r+|\r+$)/","",$Text);
193 $Text = preg_replace("/(\r|\n|\t)+/"," ",$Text);
194 $Text = preg_replace("/\s\s+/"," ",$Text);
195 $Text = preg_replace("/(^\s+|\s+$)/","",$Text);
196 $Text = remove_bad_entities($Text);
199 function fixbamps($text) {
200 $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;");
201 $fixamps2 = array("©","®","™",""","&","<",">","&\\1acute;","&\\1grave;","&\\1circ;","&\\1uml;","&\\1tilde;","å","æ","ç","ð","ø","ß","þ");
202 $ampnum = count($fixamps1); $ampi=0;
203 while ($ampi < $ampnum) {
204 $text = preg_replace("/".$fixamps1[$ampi]."/i", $fixamps2[$ampi], $text);
206 $text = preg_replace("/&#(x[a-f0-9]+|[0-9]+);/i", "&#$1;", $text);
208 $Names['K'] = "Katarzyna";
209 define("_katarzyna_", $Names['K']);
210 $utshour = $dayconv['hour'];
211 $utsminute = $dayconv['minute'];
212 // Change Time Stamp to a readable time
213 function GMTimeChange($format,$timestamp,$offset,$minoffset=null,$dst=null) {
214 global $utshour,$utsminute;
216 if(!is_numeric($minoffset)) { $minoffset = "00"; }
217 $ts_array = explode(":",$offset);
218 if(count($ts_array)!=2) {
219 if(!isset($ts_array[0])) { $ts_array[0] = "0"; }
220 if(!isset($ts_array[1])) { $ts_array[1] = "00"; }
221 $offset = $ts_array[0].":".$ts_array[1]; }
222 if(!is_numeric($ts_array[0])) { $ts_array[0] = "0"; }
223 if(!is_numeric($ts_array[1])) { $ts_array[1] = "00"; }
224 if($ts_array[1]<0) { $ts_array[1] = "00"; $offset = $ts_array[0].":".$ts_array[1]; }
225 $tsa = array("offset" => $offset, "hour" => $ts_array[0], "minute" => $ts_array[1]);
226 //$tsa['minute'] = $tsa['minute'] + $minoffset;
227 if($dst!="on"&&$dst!="off") { $dst = "off"; }
228 if($dst=="on") { if($dstake!="done") {
229 $dstake = "done"; $tsa['hour'] = $tsa['hour']+1; } }
230 $utimestamp = $tsa['hour'] * $utshour;
231 $utimestamp = $utimestamp + $tsa['minute'] * $utsminute;
232 $utimestamp = $utimestamp + $minoffset * $utsminute;
233 $timestamp = $timestamp + $utimestamp;
234 return date($format,$timestamp); }
235 $Names['SB'] = "Stephanie Braun";
236 define("_stephanie_", $Names['SB']);
237 // Change Time Stamp to a readable time
238 function TimeChange($format,$timestamp,$offset,$minoffset=null,$dst=null) {
239 return GMTimeChange($format,$timestamp,$offset,$minoffset,$dst); }
240 // Make a GMT Time Stamp
241 function GMTimeStamp() {
242 $GMTHour = gmdate("H");
243 $GMTMinute = gmdate("i");
244 $GMTSecond = gmdate("s");
245 $GMTMonth = gmdate("n");
246 $GMTDay = gmdate("d");
247 $GMTYear = gmdate("Y");
248 return mktime($GMTHour,$GMTMinute,$GMTSecond,$GMTMonth,$GMTDay,$GMTYear); }
249 // Make a GMT Time Stamp alt version
250 function GMTimeStampS() { return time() - date('Z', time()); }
252 function GMTimeGet($format,$offset,$minoffset=null,$dst=null) {
253 return GMTimeChange($format,GMTimeStamp(),$offset,$minoffset,$dst); }
254 // Get GMT Time alt version
255 function GMTimeGetS($format,$offset,$minoffset=null,$dst=null) {
256 global $utshour,$utsminute;
258 if(!is_numeric($offset)) { $offset = "0"; }
259 if(!is_numeric($minoffset)) { $minoffset = "00"; }
260 $ts_array = explode(":",$offset);
261 if(count($ts_array)!=2) {
262 if(!isset($ts_array[0])) { $ts_array[0] = "0"; }
263 if(!isset($ts_array[1])) { $ts_array[1] = "00"; }
264 $offset = $ts_array[0].":".$ts_array[1]; }
265 if(!is_numeric($ts_array[0])) { $ts_array[0] = "0"; }
266 if(!is_numeric($ts_array[1])) { $ts_array[1] = "00"; }
267 if($ts_array[1]<0) { $ts_array[1] = "00"; $offset = $ts_array[0].":".$ts_array[1]; }
268 $tsa = array("offset" => $offset, "hour" => $ts_array[0], "minute" => $ts_array[1]);
269 //$tsa['minute'] = $tsa['minute'] + $minoffset;
270 if($dst!="on"&&$dst!="off") { $dst = "off"; }
271 if($dst=="on") { if($dstake!="done") {
272 $dstake = "done"; $tsa['hour'] = $tsa['hour']+1; } }
273 $utimestamp = $tsa['hour'] * $utshour;
274 $utimestamp = $utimestamp + $tsa['minute'] * $utsminute;
275 $utimestamp = $utimestamp + $minoffset * $utsminute;
276 $timestamp = $timestamp + $utimestamp;
277 return date($format,mktime()+$timestamp); }
278 $Names['StB'] = "Stevie Braun";
279 define("_stevie_", $Names['StB']);
281 function GetSeverZone() {
282 $TestHour1 = date("H");
283 @putenv("OTZ=".getenv("TZ"));
285 $TestHour2 = date("H");
286 @putenv("TZ=".getenv("OTZ"));
287 $TestHour3 = $TestHour1-$TestHour2;
289 // Get Server offset alt version
290 function SeverOffSet() {
291 $TestHour1 = date("H");
292 $TestHour2 = gmdate("H");
293 $TestHour3 = $TestHour1-$TestHour2;
295 // Get Server offset new version
296 function SeverOffSetNew() {
297 return gmdate("g",mktime(0,date("Z"))); }
298 function gmtime() { return time() - (int) date('Z'); }
299 // Acts like highlight_file();
300 function file_get_source($filename,$return = FALSE) {
301 $phpsrc = file_get_contents($filename);
302 $phpsrcs = highlight_string($phpsrc,$return);
304 // Also acts like highlight_file(); but valid xhtml
305 function valid_get_source($filename) {
306 $phpsrcs = file_get_source($filename,TRUE);
307 // Change font tag to span tag for valid xhtml
308 $phpsrcs = preg_replace("/\<font color=\"(.*?)\"\>/i", "<span style=\"color: \\1;\">", $phpsrcs);
309 $phpsrcs = preg_replace("/\<\/font>/i", "</span>", $phpsrcs);
311 // Check to see if the user is hidden/shy/timid. >_> | ^_^ | <_<
312 function GetUserName($idu,$sqlt,$link=null) { $UsersName = null;
314 if(!isset($link)) { $link = $SQLStat; }
315 $gunquery = sql_pre_query("SELECT * FROM \"".$sqlt."members\" WHERE \"id\"=%i LIMIT 1", array($idu));
316 $gunresult=sql_query($gunquery,$link);
317 $gunnum=sql_num_rows($gunresult);
318 // I'm now hidden from you. ^_^ | <_< I cant find you.
319 $UsersHidden = "yes";
321 $UsersName=sql_result($gunresult,0,"Name");
322 // Am i still hidden. o_O <_< I can see you.
323 $UsersHidden=sql_result($gunresult,0,"HiddenMember"); }
324 sql_free_result($gunresult);
325 $UsersInfo['Name'] = $UsersName;
326 $UsersInfo['Hidden'] = $UsersHidden;
328 if(!function_exists('hash_hmac')) {
329 function hash_hmac($algo, $data, $key, $raw_output = false) {
331 if (strlen($key)>$blocksize) {
332 if (function_exists('hash')) {
333 $key=pack('H*',hash($hash, $key)); }
334 if (!function_exists('hash')) {
335 $key=pack('H*',$hash($key)); } }
336 $key=str_pad($key, $blocksize, chr(0x00));
337 $ipad=str_repeat(chr(0x36),$blocksize);
338 $opad=str_repeat(chr(0x5c),$blocksize);
339 return hash($algo, ($key^$opad).pack('H*',hash($algo, ($key^$ipad).$data))); } }
340 if(!function_exists('hash')) {
341 function hash($algo, $data, $raw_output = false) {
342 if($algo!="md5"&&$algo!="sha1") { $algo = "md5"; }
343 return $algo($data); } }
344 if(!function_exists('hash_algos')) {
345 function hash_algos() {
346 return array(0 => "md5", 1 => "sha1"); } }
347 // hmac hash function
348 function hmac($data,$key,$hash='sha1',$blocksize=64) {
349 if (!function_exists('hash_hmac')) {
350 if (strlen($key)>$blocksize) {
351 if (function_exists('hash')) {
352 $key=pack('H*',hash($hash, $key)); }
353 if (!function_exists('hash')) {
354 $key=pack('H*',$hash($key)); } }
355 $key=str_pad($key, $blocksize, chr(0x00));
356 $ipad=str_repeat(chr(0x36),$blocksize);
357 $opad=str_repeat(chr(0x5c),$blocksize);
358 if (function_exists('hash')) {
359 return hash($hash, ($key^$opad).pack('H*',hash($hash, ($key^$ipad).$data))); }
360 if (!function_exists('hash')) {
361 return $hash(($key^$opad).pack('H*',$hash(($key^$ipad).$data))); } }
362 if (function_exists('hash_hmac')) {
363 return hash_hmac($hash,$data,$key); } }
364 // b64hmac hash function
365 function b64e_hmac($data,$key,$extdata,$hash='sha1',$blocksize=64) {
366 $extdata2 = hexdec($extdata); $key = $key.$extdata2;
367 return base64_encode(hmac($data,$key,$hash,$blocksize).$extdata); }
368 // b64hmac rot13 hash function
369 function b64e_rot13_hmac($data,$key,$extdata,$hash='sha1',$blocksize=64) {
370 $data = str_rot13($data);
371 $extdata2 = hexdec($extdata); $key = $key.$extdata2;
372 return base64_encode(hmac($data,$key,$hash,$blocksize).$extdata); }
373 // salt hmac hash function
374 function salt_hmac($size1=6,$size2=12) {
375 $hprand = rand($size1,$size2); $i = 0; $hpass = "";
376 while ($i < $hprand) {
377 $hspsrand = rand(1,2);
378 if($hspsrand!=1&&$hspsrand!=2) { $hspsrand=1; }
379 if($hspsrand==1) { $hpass .= chr(rand(48,57)); }
380 /* if($hspsrand==2) { $hpass .= chr(rand(65,70)); } */
381 if($hspsrand==2) { $hpass .= chr(rand(97,102)); }
382 ++$i; } return $hpass; }
383 /* is_empty by M at http://us2.php.net/manual/en/function.empty.php#74093 */
384 function is_empty($var) {
385 if (((is_null($var) || rtrim($var) == "") &&
386 $var !== false) || (is_array($var) && empty($var))) {
387 return true; } else { return false; } }
388 // PHP 5 hash algorithms to functions :o
389 if(function_exists('hash')&&function_exists('hash_algos')) {
390 if(in_array("md2",hash_algos())) {
391 function md2($data) { return hash("md2",$data); } }
392 if(in_array("md4",hash_algos())) {
393 function md4($data) { return hash("md4",$data); } }
394 if(in_array("sha224",hash_algos())) {
395 function sha224($data) { return hash("sha224",$data); } }
396 if(in_array("sha256",hash_algos())) {
397 function sha256($data) { return hash("sha256",$data); } }
398 if(in_array("sha384",hash_algos())) {
399 function sha384($data) { return hash("sha384",$data); } }
400 if(in_array("sha512",hash_algos())) {
401 function sha512($data) { return hash("sha512",$data); } }
402 if(in_array("ripemd128",hash_algos())) {
403 function ripemd128($data) { return hash("ripemd128",$data); } }
404 if(in_array("ripemd160",hash_algos())) {
405 function ripemd160($data) { return hash("ripemd160",$data); } }
406 if(in_array("ripemd256",hash_algos())) {
407 function ripemd256($data) { return hash("ripemd256",$data); } }
408 if(in_array("ripemd512",hash_algos())) {
409 function ripemd320($data) { return hash("ripemd320",$data); } }
410 if(in_array("salsa10",hash_algos())) {
411 function salsa10($data) { return hash("salsa10",$data); } }
412 if(in_array("salsa20",hash_algos())) {
413 function salsa20($data) { return hash("salsa20",$data); } }
414 if(in_array("snefru",hash_algos())) {
415 function snefru($data) { return hash("snefru",$data); } }
416 if(in_array("snefru256",hash_algos())) {
417 function snefru256($data) { return hash("snefru256",$data); } }
418 if(in_array("gost",hash_algos())) {
419 function gost($data) { return hash("gost",$data); } } }
420 // Try and convert IPB 2.0.0 style passwords to iDB style passwords
421 function hash2xkey($data,$key,$hash1='md5',$hash2='md5') {
422 return $hash1($hash2($key).$hash2($data)); }
423 // Hash two times with md5 and sha1 for DF2k
424 function PassHash2x($Text) {
428 // Hash two times with hmac-md5 and hmac-sha1
429 function PassHash2x2($data,$key,$extdata,$blocksize=64) {
430 $extdata2 = hexdec($extdata); $key = $key.$extdata2;
431 $Text = hmac($data,$key,"md5").$extdata;
432 $Text = hmac($Text,$key,"sha1").$extdata;
433 return base64_encode($Text); }
434 function cp($infile,$outfile,$mode="w") {
435 $contents = file_get_contents($infile);
436 $cpfp = fopen($outfile,$mode);
437 fwrite($cpfp, $contents);
440 /* str_ireplace for PHP below ver. 5 updated //
441 // by Kazuki Przyborowski - Cool Dude 2k //
442 // and upaded by Kazuki Przyborowski again */
443 if(!function_exists('str_ireplace')) {
444 function str_ireplace($search,$replace,$subject) {
445 if(!is_array($search)&&is_array($replace)) {
446 $search = array($search); }
447 if(is_array($search)&&!is_array($replace)) {
448 $replace = array($replace); }
449 if(is_array($search)&&is_array($replace)) {
450 $sc=count($search); $rc=count($replace); $sn=0;
451 if($sc!=$rc) { return false; }
453 $search[$sn] = preg_quote($search[$sn], "/");
454 $subject = preg_replace("/".$search[$sn]."/i", $replace[$sn], $subject);
456 if(!is_array($search)&&!is_array($replace)) {
457 $search = preg_quote($search, "/");
458 $subject = preg_replace("/".$search."/i", $replace, $subject); }
460 /* Adds httponly to PHP below Ver. 5.2.0 //
461 // by Kazuki Przyborowski - Cool Dude 2k */
462 function http_set_cookie($name,$value=null,$expire=null,$path=null,$domain=null,$secure=false,$httponly=false) {
463 $mkcookie = null; $expireGMT = null;
465 output_error("Error: You need to enter a name for cookie.",E_USER_ERROR);
467 if(!isset($expire)) {
468 output_error("Error: You need to enter a time for cookie to expire.",E_USER_ERROR);
470 $expireGMT = gmdate("D, d-M-Y H:i:s \G\M\T", $expire);
471 if(!isset($value)) { $value = null; }
472 if(!isset($httponly)||$httponly==false) {
473 setcookie($name, $value, $expire, $path, $domain, $secure); return true; }
474 if(version_compare(PHP_VERSION,"5.2.0",">=")&&$httponly==true) {
475 setcookie($name, $value, $expire, $path, $domain, $secure, $httponly); return true; }
476 if(version_compare(PHP_VERSION,"5.2.0","<")&&$httponly==true) {
477 $mkcookie = "Set-Cookie: ".rawurlencode($name)."=".rawurlencode($value);
478 $mkcookie = $mkcookie."; expires=".$expireGMT;
479 if(isset($path)&&$path!=null) { $mkcookie = $mkcookie."; path=".$path; }
480 if(isset($domain)&&$domain!=null) { $mkcookie = $mkcookie."; domain=".$domain; }
481 if(isset($secure)&&$secure===true) { $mkcookie = $mkcookie."; secure"; }
482 if(isset($httponly)&&$httponly===true) { $mkcookie = $mkcookie."; HttpOnly"; }
483 header($mkcookie, false); return true; } }
484 $foobar="fubar"; $$foobar="foobar";
486 function dump_included_files($type="var_dump") {
487 if(!isset($type)) { $type = "var_dump"; }
488 if($type=="print_r") { return print_r(get_included_files()); }
489 if($type=="var_dump") { return var_dump(get_included_files()); }
490 if($type=="var_export") { return var_export(get_included_files()); } }
491 function count_included_files() { return count(get_included_files()); }
492 function dump_extensions($type="var_dump") {
493 if(!isset($type)) { $type = "var_dump"; }
494 if($type=="print_r") { return print_r(get_loaded_extensions()); }
495 if($type=="var_dump") { return var_dump(get_loaded_extensions()); }
496 if($type=="var_export") { return var_export(get_loaded_extensions()); } }
497 function count_extensions() { return count(get_loaded_extensions()); }