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-2007 Cool Dude 2k - http://intdb.sourceforge.net/
12 Copyright 2004-2007 Game Maker 2k - http://upload.idb.s1.jcink.com/
14 $FileInfo: function.php - Last Update: 06/14/2007 SVN 23 - Author: cooldude2k $
16 $File3Name = basename($_SERVER['SCRIPT_NAME']);
17 if ($File3Name=="function.php"||$File3Name=="/function.php") {
20 require_once($SettDir['misc'].'functions.php');
21 /* Change Some PHP Settings Fix the & to &
22 if($Settings['use_iniset']==true&&$Settings['qstr']!="/") {
23 @ini_set("arg_separator.output",htmlentities($Settings['qstr'], ENT_QUOTES));
24 @ini_set("arg_separator.input",$Settings['qstr']);
25 @ini_set("arg_separator",htmlentities($Settings['qstr'], ENT_QUOTES)); }
26 //$basepath = pathinfo($_SERVER['REQUEST_URI']);
27 if(dirname($_SERVER['REQUEST_URI'])!="."||
28 dirname($_SERVER['REQUEST_URI'])!=null) {
29 $basedir = dirname($_SERVER['REQUEST_URI'])."/"; }*/
30 if(dirname($_SERVER['SCRIPT_NAME'])!="."||
31 dirname($_SERVER['SCRIPT_NAME'])!=null) {
32 $basedir = dirname($_SERVER['SCRIPT_NAME'])."/"; }
33 if($basedir==null||$basedir==".") {
34 if(dirname($_SERVER['SCRIPT_NAME'])=="."||
35 dirname($_SERVER['SCRIPT_NAME'])==null) {
36 $basedir = dirname($_SERVER['PHP_SELF'])."/"; } }
37 if($basedir=="\/") { $basedir="/"; }
38 $basedir = str_replace("//", "/", $basedir);
39 if($Settings['fixbasedir']!=null&&$Settings['fixbasedir']!="") {
40 $basedir = $Settings['fixbasedir']; }
42 // Get our Host Name and Referer URL's Host Name
43 if(!isset($_SERVER['HTTP_REFERER'])) { $_SERVER['HTTP_REFERER'] = null; }
44 $REFERERurl = parse_url($_SERVER['HTTP_REFERER']);
45 if(!isset($REFERERurl['host'])) { $REFERERurl['host'] = null; }
46 $URL['REFERER'] = $REFERERurl['host'];
47 $URL['HOST'] = $_SERVER["SERVER_NAME"];
48 $REFERERurl = null; unset($REFERERurl);
49 function qstring($qstr=";",$qsep="=")
50 { $_GET = null; $_GET = array();
51 if (!isset($_SERVER['QUERY_STRING'])) {
52 $_SERVER['QUERY_STRING'] = getenv('QUERY_STRING'); }
53 @ini_get("arg_separator.input", $qstr);
54 $_SERVER['QUERY_STRING'] = urldecode($_SERVER['QUERY_STRING']);
55 $preqs = explode($qstr,$_SERVER["QUERY_STRING"]);
56 $qsnum = count($preqs); $qsi = 0;
57 while ($qsi < $qsnum) {
58 $preqst = explode($qsep,$preqs[$qsi],2);
59 $fix1 = array(" ",'$'); $fix2 = array("_","_");
60 $preqst[0] = str_replace($fix1, $fix2, $preqst[0]);
61 $preqst[0] = killbadvars($preqst[0]);
62 if($preqst[0]!=null) {
63 $_GET[$preqst[0]] = $preqst[1]; }
64 ++$qsi; } return true; }
65 if($_SERVER['PATH_INFO']==null) {
66 if(@getenv('PATH_INFO')!=null&&@getenv('PATH_INFO')!="1") {
67 $_SERVER['PATH_INFO'] = @getenv('PATH_INFO'); }
68 if(@getenv('PATH_INFO')==null) {
69 $myscript = $_SERVER["SCRIPT_NAME"];
70 $myphpath = $_SERVER["PHP_SELF"];
71 $mypathinfo = str_replace($myscript, "", $myphpath);
72 @putenv("PATH_INFO=".$mypathinfo); } }
74 $urlvar = explode('/',$_SERVER['PATH_INFO']);
75 $num=count($urlvar); $i=1;
77 //$urlvar[$i] = urldecode($urlvar[$i]);
78 if(!isset($_GET[$urlvar[$i]])) { $_GET[$urlvar[$i]] = null; }
79 if(!isset($urlvar[$i])) { $urlvar[$i] = null; }
80 if($_GET[$urlvar[$i]]==null&&$urlvar[$i]!=null) {
81 $fix1 = array(" ",'$'); $fix2 = array("_","_");
82 $urlvar[$i] = str_replace($fix1, $fix2, $urlvar[$i]);
83 $urlvar[$i] = killbadvars($urlvar[$i]);
84 $_GET[$urlvar[$i]] = $urlvar[$i+1]; }
85 ++$i; ++$i; } return true; }
86 function redirect($type,$file,$time=0,$url=null,$dbsr=true)
88 if($type!="location"&&
94 $file = str_replace("//", "/", $file); }
95 if($type=="refresh") {
96 header("Refresh: ".$time."; URL=".$file); }
97 if($type=="location") {
98 @session_write_close();
99 header("Location: ".$file); }
101 function url_maker($file,$ext,$qvarstr=null,$qstr=";",$qsep="=",$prexqstr=null,$exqstr=null,$fixhtml=true) {
103 if($ext==null) { $ext = ".php"; }
104 if($ext=="noext"||$ext=="no ext"||$ext=="no+ext") { $ext = null; }
106 if($qvarstr==null) { $fileurl = $file; }
108 $qstr = htmlentities($qstr, ENT_QUOTES);
109 $qsep = htmlentities($qsep, ENT_QUOTES); }
110 if($prexqstr!=null) {
111 $rene1 = explode("&",$prexqstr);
112 $renenum=count($rene1);
114 $reneqstr = "index.php?";
115 if($qstr!="/") { $fileurl = $file."?"; }
116 if($qstr=="/") { $fileurl = $file."/"; }
117 while ($renei < $renenum) {
118 $rene2 = explode("=",$rene1[$renei]);
119 $rene2[0] = urlencode($rene2[0]);
120 $rene2[1] = urlencode($rene2[1]);
122 $fileurl = $fileurl.$rene2[0].$qsep.$rene2[1]; }
124 $fileurl = $fileurl.$rene2[0]."/".$rene2[1]."/"; }
125 $reneis = $renei + 1;
127 if($reneis < $renenum) { $fileurl = $fileurl.$qstr; } }
129 if($qvarstr!=null&&$qstr!="/") { $fileurl = $fileurl.$qstr; }
131 if($prexqstr==null) {
132 if($qstr!="/") { $fileurl = $file."?"; }
133 if($qstr=="/") { $fileurl = $file."/"; } }
134 $cind1 = explode("&",$qvarstr);
135 $cindnum=count($cind1);
137 $cindqstr = "index.php?";
138 while ($cindi < $cindnum) {
139 $cind2 = explode("=",$cind1[$cindi]);
140 $cind2[0] = urlencode($cind2[0]);
141 $cind2[1] = urlencode($cind2[1]);
143 $fileurl = $fileurl.$cind2[0].$qsep.$cind2[1]; }
145 $fileurl = $fileurl.$cind2[0]."/".$cind2[1]."/"; }
146 $cindis = $cindi + 1;
148 if($cindis < $cindnum) { $fileurl = $fileurl.$qstr; } }
150 if($exqstr!=null&&$qstr!="/") { $fileurl = $fileurl.$qstr; }
152 if($qvarstr==null&&$prexqstr==null) {
153 if($qstr!="/") { $fileurl = $file."?"; }
154 if($qstr=="/") { $fileurl = $file."/"; } }
155 $sand1 = explode("&",$exqstr);
156 $sanum=count($sand1);
158 $sandqstr = "index.php?";
159 while ($sandi < $sanum) {
160 $sand2 = explode("=",$sand1[$sandi]);
161 $sand2[0] = urlencode($sand2[0]);
162 $sand2[1] = urlencode($sand2[1]);
164 $fileurl = $fileurl.$sand2[0].$qsep.$sand2[1]; }
166 $fileurl = $fileurl.$sand2[0]."/".$sand2[1]."/"; }
167 $sandis = $sandi + 1;
169 if($sandis < $sanum) { $fileurl = $fileurl.$qstr; } }
172 $thisdir = dirname(realpath("Preindex.php"))."/";
173 function GetQueryStr($qstr=";",$qsep="=",$fixhtml=true)
174 { $pregqstr = preg_quote($qstr,"/");
175 $pregqsep = preg_quote($qsep,"/");
176 $oqstr = $qstr; $oqsep = $qsep;
177 if($fixhtml==true||$fixhtml==null) {
178 $qstr = htmlentities($qstr, ENT_QUOTES);
179 $qsep = htmlentities($qsep, ENT_QUOTES); }
180 $OldBoardQuery = preg_replace("/".$pregqstr."/isxS", $qstr, $_SERVER['QUERY_STRING']);
181 $BoardQuery = "?".$OldBoardQuery;
182 return $BoardQuery; }