|
foxel@0
|
1 |
<?php
|
|
foxel@0
|
2 |
|
|
foxel@0
|
3 |
// -------------------------------------------------------------------------- \\
|
|
foxel@0
|
4 |
// This is the main QuickFox 2 file \\
|
|
foxel@0
|
5 |
// (c) LION 2007 - 2008 \\
|
|
foxel@0
|
6 |
// -------------------------------------------------------------------------- \\
|
|
foxel@0
|
7 |
|
|
foxel@0
|
8 |
// Simple InUSE Check
|
|
foxel@0
|
9 |
if ( !defined('QF_STARTED') )
|
|
foxel@0
|
10 |
die('Hacking attempt');
|
|
foxel@0
|
11 |
|
|
foxel@0
|
12 |
if (defined('QF_FOX_STARTED'))
|
|
foxel@0
|
13 |
die('Scripting error');
|
|
foxel@0
|
14 |
|
|
foxel@0
|
15 |
define('QF_FOX_STARTED', true);
|
|
foxel@0
|
16 |
|
|
foxel@0
|
17 |
define('QUICKFOX_DIR', dirname(__FILE__).'/');
|
|
foxel@0
|
18 |
|
|
foxel@0
|
19 |
// data directories constants
|
|
foxel@0
|
20 |
define('QF_INC_ROOT', QF_DATA_ROOT.'includes/');
|
|
foxel@0
|
21 |
define('QF_MODULES_DIR', QF_DATA_ROOT.'modules/');
|
|
foxel@0
|
22 |
define('QF_PAGES_DIR', QF_INC_ROOT.'pages/');
|
|
foxel@0
|
23 |
define('QF_SCRIPTS_DIR', QF_INC_ROOT.'scripts/');
|
|
foxel@0
|
24 |
|
|
foxel@0
|
25 |
// Defining some usefull constants
|
|
foxel@0
|
26 |
define('QF_FOX2_LOGIN_MASK', '^[0-9\w_\+\-=\(\)\[\] ]{3,16}$');
|
|
foxel@0
|
27 |
define('QF_FOX2_SERVICE_PERIOD', 60); // 1 minute service check period
|
|
foxel@0
|
28 |
define('QF_FOX2_RESULT_LIFETIME', 3600);
|
|
foxel@0
|
29 |
define('QF_FOX2_MAXULEVEL', 7);
|
|
foxel@0
|
30 |
|
|
foxel@0
|
31 |
define('QF_FOX2_URLTEMPS_CACHENAME', 'FOX2.URLTEMPS');
|
|
foxel@0
|
32 |
define('QF_FOX2_URLTEMPS_RW_CACHENAME', 'FOX2.RW_URLTEMPS');
|
|
foxel@0
|
33 |
|
|
foxel@0
|
34 |
class Fox2
|
|
foxel@0
|
35 |
{
|
|
foxel@0
|
36 |
var $URL_temps;
|
|
foxel@33
|
37 |
var $URL_domain = null;
|
|
foxel@34
|
38 |
var $VIS_redefs = Array();
|
|
foxel@0
|
39 |
var $err_traced = Array();
|
|
foxel@0
|
40 |
|
|
foxel@0
|
41 |
function Fox2()
|
|
foxel@0
|
42 |
{
|
|
foxel@0
|
43 |
global $QF;
|
|
foxel@0
|
44 |
if ($CL_Config = qf_file_get_carray(QUICKFOX_DIR.'modules.qfc'))
|
|
foxel@0
|
45 |
{
|
|
foxel@0
|
46 |
foreach ($CL_Config as $mod => $cfg)
|
|
foxel@0
|
47 |
{
|
|
foxel@0
|
48 |
$cfg = explode('|', $cfg);
|
|
foxel@0
|
49 |
if (isset($cfg[1]) && $cfg[1])
|
|
foxel@0
|
50 |
$QF->Register_Module($mod, QUICKFOX_DIR.trim($cfg[1]), trim($cfg[0]));
|
|
foxel@0
|
51 |
else
|
|
foxel@0
|
52 |
$QF->Register_Module($mod, QUICKFOX_DIR.trim($cfg[0]));
|
|
foxel@0
|
53 |
}
|
|
foxel@0
|
54 |
}
|
|
foxel@0
|
55 |
|
|
foxel@0
|
56 |
}
|
|
foxel@0
|
57 |
|
|
foxel@0
|
58 |
function _Start()
|
|
foxel@0
|
59 |
{
|
|
foxel@0
|
60 |
global $QF;
|
|
foxel@0
|
61 |
$GLOBALS['FOX'] =& $this;
|
|
foxel@0
|
62 |
|
|
foxel@0
|
63 |
//qf_file_put_contents('acc'.$QF->Timer->time, qf_array_definition($_REQUEST));
|
|
foxel@0
|
64 |
|
|
foxel@0
|
65 |
$QF->Timer->Time_Log('FOX2 module started');
|
|
foxel@0
|
66 |
|
|
foxel@0
|
67 |
if ($QF->GPC->Get_Bin('drop_cache', QF_GPC_GET))
|
|
foxel@0
|
68 |
$QF->Cache->Clear();
|
|
foxel@0
|
69 |
|
|
foxel@0
|
70 |
$QF->LNG->Load_Language('common');
|
|
foxel@33
|
71 |
//$QF->Config->Set('linked_domains', Array('gallery' => 'www.quickfox.dev'), 'fox2');
|
|
foxel@33
|
72 |
//$QF->Config->Set('basic_domain', 'quickfox.dev', 'fox2');
|
|
foxel@0
|
73 |
|
|
foxel@33
|
74 |
// starting neded modules
|
|
foxel@33
|
75 |
$QF->Run_Module('DSets');
|
|
foxel@33
|
76 |
$QF->Run_Module('User');
|
|
foxel@33
|
77 |
|
|
foxel@33
|
78 |
$revision = $QF->DSets->Get_DSet_Value('dev_rev_info', 'qf2');
|
|
foxel@33
|
79 |
header('X-Powered-By: QuickFox 2 ['.$revision.'] (PHP/'.PHP_VERSION.')');
|
|
foxel@33
|
80 |
|
|
foxel@33
|
81 |
// url reparsing
|
|
foxel@33
|
82 |
$rw_id = $QF->GPC->Get_String('rw_id', QF_GPC_GET, QF_STR_WORD);
|
|
foxel@33
|
83 |
$rw_data = $QF->GPC->Get_String('rw_data', QF_GPC_GET, QF_STR_LINE);
|
|
foxel@33
|
84 |
// working with multidomain
|
|
foxel@0
|
85 |
if ($QF->Config->Get('tgl_multidomain', 'fox2'))
|
|
foxel@0
|
86 |
{
|
|
foxel@0
|
87 |
$d_schemas = $QF->Config->Get('domain_schemas', 'fox2');
|
|
foxel@0
|
88 |
$domain = strtolower($QF->HTTP->SrvName);
|
|
foxel@0
|
89 |
if (!is_array($d_schemas))
|
|
foxel@0
|
90 |
$d_schemas = Array();
|
|
foxel@0
|
91 |
|
|
foxel@0
|
92 |
if (!isset($d_schemas[$domain]))
|
|
foxel@0
|
93 |
{
|
|
foxel@0
|
94 |
$d_schemas[$domain] = '';
|
|
foxel@0
|
95 |
$QF->Config->Set('domain_schemas', $d_schemas, 'fox2', true);
|
|
foxel@0
|
96 |
}
|
|
foxel@0
|
97 |
elseif ($d_schemas[$domain])
|
|
foxel@0
|
98 |
$QF->Config->Select_Scheme($d_schemas[$domain]);
|
|
foxel@33
|
99 |
|
|
foxel@33
|
100 |
if (($domains = $QF->Config->Get('linked_domains', 'fox2'))
|
|
foxel@33
|
101 |
&& ($basic_domain = $QF->Config->Get('basic_domain', 'fox2'))
|
|
foxel@33
|
102 |
&& is_array($domains) && count($domains))
|
|
foxel@33
|
103 |
{
|
|
foxel@33
|
104 |
list($link) = array_keys($domains, $domain);
|
|
foxel@33
|
105 |
if ($link)
|
|
foxel@33
|
106 |
{
|
|
foxel@33
|
107 |
$this->URL_domain = $basic_domain;
|
|
foxel@33
|
108 |
if ($rw_id && $rw_id != $link)
|
|
foxel@33
|
109 |
$rw_data = $rw_id.'/'.$rw_data;
|
|
foxel@33
|
110 |
$rw_id = $link;
|
|
foxel@0
|
111 |
}
|
|
foxel@33
|
112 |
}
|
|
foxel@33
|
113 |
}
|
|
foxel@33
|
114 |
// rewrited url reparsing
|
|
foxel@33
|
115 |
if ($rw_id)
|
|
foxel@33
|
116 |
{
|
|
foxel@33
|
117 |
$this->_Parse_RW($rw_id, $rw_data);
|
|
foxel@33
|
118 |
$QF->Events->Set_On_Event('HTTP_HTML_parse', Array(&$this, 'HTML_FullURLs') );
|
|
foxel@0
|
119 |
$QF->Events->Set_On_Event('HTML_block_parse', Array(&$this, 'HTML_FullURLs') );
|
|
foxel@0
|
120 |
}
|
|
foxel@0
|
121 |
|
|
foxel@0
|
122 |
// running the services
|
|
foxel@0
|
123 |
$next_start = $QF->Config->Get('service_nextstart', 'temp');
|
|
foxel@0
|
124 |
if ($next_start < $QF->Timer->time)
|
|
foxel@0
|
125 |
{
|
|
foxel@0
|
126 |
$QF->Run_Module('Services');
|
|
foxel@0
|
127 |
$QF->Config->Set('service_nextstart', ($QF->Timer->time + QF_FOX2_RESULT_LIFETIME), 'temp', true);
|
|
foxel@0
|
128 |
}
|
|
foxel@0
|
129 |
|
|
foxel@0
|
130 |
// registering extended modules
|
|
foxel@0
|
131 |
if ($r_mods = $QF->DSets->Get_DSet('fox_modules'))
|
|
foxel@0
|
132 |
foreach ($r_mods as $r_mod => $r_cfg)
|
|
foxel@0
|
133 |
{
|
|
foxel@0
|
134 |
$r_cfg = explode('|', $r_cfg);
|
|
foxel@0
|
135 |
if (isset($r_cfg[1]) && $r_cfg[1])
|
|
foxel@0
|
136 |
$QF->Register_Module($r_mod, QF_MODULES_DIR.trim($r_cfg[1]), trim($r_cfg[0]));
|
|
foxel@0
|
137 |
else
|
|
foxel@0
|
138 |
$QF->Register_Module($r_mod, QF_MODULES_DIR.trim($r_cfg[0]));
|
|
foxel@0
|
139 |
}
|
|
foxel@0
|
140 |
|
|
foxel@0
|
141 |
//$this->_Parse_PathInfo();
|
|
foxel@0
|
142 |
|
|
foxel@0
|
143 |
if ($domain = $QF->Config->Get('cookie_domain'))
|
|
foxel@0
|
144 |
$QF->HTTP->Set_Cookie_Domain($domain);
|
|
foxel@0
|
145 |
|
|
foxel@19
|
146 |
$QF->Events->Set_On_Event('VIS_PreParse', Array(&$this, 'On_VIS_Prep') );
|
|
foxel@34
|
147 |
$QF->Events->Set_On_Event('EJS_PreParse', Array(&$this, 'On_EJS_Prep') );
|
|
foxel@19
|
148 |
if ($QF->Config->Get('vis_redefined', 'fox2'))
|
|
foxel@0
|
149 |
$QF->Events->Set_On_Event('VIS_RawParse', Array(&$this, '_VISUserMods_Add') );
|
|
foxel@0
|
150 |
|
|
foxel@0
|
151 |
// running any autoruns from packages
|
|
foxel@0
|
152 |
if ($ar_datas = $QF->DSets->Get_DSet('fox_autoruns'))
|
|
foxel@0
|
153 |
foreach ($ar_datas as $arun)
|
|
foxel@0
|
154 |
if (isset($arun['module'], $arun['method']))
|
|
foxel@0
|
155 |
{
|
|
foxel@0
|
156 |
$QF->Run_Module($arun['module']);
|
|
foxel@0
|
157 |
qf_func_call(Array(&$QF->$arun['module'], $arun['method']));
|
|
foxel@0
|
158 |
}
|
|
foxel@0
|
159 |
|
|
foxel@0
|
160 |
|
|
foxel@0
|
161 |
// first try to determine if we are running a datapage
|
|
foxel@0
|
162 |
if ($data_page = $QF->GPC->Get_String('sr', QF_GPC_GET, QF_STR_WORD))
|
|
foxel@0
|
163 |
$this->Run_Data($data_page);
|
|
foxel@0
|
164 |
|
|
foxel@0
|
165 |
// open session
|
|
foxel@0
|
166 |
$QF->Session->Open_Session();
|
|
foxel@0
|
167 |
if ($QF->Config->Get('sid_urls', 'session', true) && $QF->Config->Get('cookie_check', 'session') && $QF->Session->Get_Status(QF_SESSION_USEURL | QF_SESSION_LOADED) == QF_SESSION_USEURL)
|
|
foxel@0
|
168 |
$QF->HTTP->Redirect($QF->HTTP->Request);
|
|
foxel@0
|
169 |
|
|
foxel@0
|
170 |
// then try to determine if we are running an AJAX parser
|
|
foxel@0
|
171 |
if ($aj_page = $QF->GPC->Get_String('aj', QF_GPC_GET, QF_STR_WORD))
|
|
foxel@0
|
172 |
$QF->User->is_spider || $this->Run_AJAX($aj_page);
|
|
foxel@0
|
173 |
|
|
foxel@0
|
174 |
// then try to run script if needed
|
|
foxel@0
|
175 |
if ($script = $QF->GPC->Get_String('script', QF_GPC_POST, QF_STR_WORD))
|
|
foxel@0
|
176 |
$QF->User->is_spider || $this->Run_Script($script);
|
|
foxel@0
|
177 |
|
|
foxel@0
|
178 |
// if we don't need to run scripts or datapages we will draw a normal page
|
|
foxel@0
|
179 |
$QF->Run_Module('VIS');
|
|
foxel@0
|
180 |
$vis_style = $QF->Config->Get('vis_style', '', 'qf_def');
|
|
foxel@0
|
181 |
$vis_style = explode('|', $vis_style);
|
|
foxel@0
|
182 |
if (!isset($vis_style[1]))
|
|
foxel@0
|
183 |
$vis_style[1] = QF_KERNEL_VIS_COMMON;
|
|
foxel@0
|
184 |
$QF->VIS->Configure(Array(
|
|
foxel@0
|
185 |
'root_node' => 'GLOBAL_HTMLPAGE',
|
|
foxel@19
|
186 |
'style' => $vis_style[0],
|
|
foxel@0
|
187 |
'CSS' => $vis_style[1],
|
|
foxel@0
|
188 |
), false);
|
|
foxel@0
|
189 |
|
|
foxel@0
|
190 |
|
|
foxel@0
|
191 |
if ($QF->Config->Get('css_separate'))
|
|
foxel@0
|
192 |
{
|
|
foxel@0
|
193 |
$QF->VIS->Configure(Array('force_append' => false));
|
|
foxel@0
|
194 |
$QF->VIS->Add_Data(0, 'META', '<link rel="stylesheet" type="text/css" href="'.$this->Gen_URL('fox2_css_data', $vis_style, true).'" />');
|
|
foxel@0
|
195 |
}
|
|
foxel@0
|
196 |
$this->Link_JScript('common');
|
|
foxel@0
|
197 |
$this->Link_JScript('effects');
|
|
foxel@0
|
198 |
|
|
foxel@0
|
199 |
$QF->VIS->Set_VConsts(Array('MAXULEVEL' => QF_FOX2_MAXULEVEL));
|
|
foxel@0
|
200 |
$QF->VIS->Load_Templates();
|
|
foxel@0
|
201 |
|
|
foxel@0
|
202 |
$page = $QF->GPC->Get_String('st', QF_GPC_GET, QF_STR_WORD);
|
|
foxel@0
|
203 |
|
|
foxel@0
|
204 |
if (!$page)
|
|
foxel@0
|
205 |
$page = $QF->Config->Get('index_dpage', 'fox2', 'pages');
|
|
foxel@0
|
206 |
|
|
foxel@0
|
207 |
$this->Show_Page($page);
|
|
foxel@0
|
208 |
}
|
|
foxel@0
|
209 |
|
|
foxel@0
|
210 |
function Run_Data($name)
|
|
foxel@0
|
211 |
{
|
|
foxel@0
|
212 |
global $QF;
|
|
foxel@0
|
213 |
|
|
foxel@0
|
214 |
if (connection_aborted())
|
|
foxel@0
|
215 |
trigger_error('FOX: connection was aborted at client side', E_USER_WARNING);
|
|
foxel@0
|
216 |
if (($data = $QF->DSets->Get_DSet_Value('fox_datapages', $name)) && isset($data['module'], $data['method']))
|
|
foxel@0
|
217 |
{
|
|
foxel@0
|
218 |
$QF->Run_Module($data['module']);
|
|
foxel@0
|
219 |
qf_func_call(Array(&$QF->$data['module'], $data['method']));
|
|
foxel@0
|
220 |
trigger_error('FOX: datapage "'.$name.'" did not end execution by it\'s own', E_USER_NOTICE);
|
|
foxel@0
|
221 |
}
|
|
foxel@0
|
222 |
else
|
|
foxel@0
|
223 |
trigger_error('FOX: there is no "'.$name.'" datapage data', E_USER_WARNING);
|
|
foxel@0
|
224 |
|
|
foxel@0
|
225 |
header ($QF->HTTP->SERVER["SERVER_PROTOCOL"].' 501 Not Implemented');
|
|
foxel@0
|
226 |
$QF->HTTP->Redirect(($QF->HTTP->Referer && !$QF->HTTP->ExtRef) ? $QF->HTTP->Referer : QF_INDEX);
|
|
foxel@0
|
227 |
}
|
|
foxel@0
|
228 |
|
|
foxel@0
|
229 |
function Run_AJAX($name)
|
|
foxel@0
|
230 |
{
|
|
foxel@0
|
231 |
global $QF;
|
|
foxel@0
|
232 |
|
|
foxel@0
|
233 |
$AJAX_DATA = null;
|
|
foxel@0
|
234 |
$AJAX_STATUS = 200;
|
|
foxel@0
|
235 |
|
|
foxel@0
|
236 |
if (connection_aborted())
|
|
foxel@0
|
237 |
trigger_error('FOX: connection was aborted at client side', E_USER_WARNING);
|
|
foxel@0
|
238 |
elseif ($name == 'PING') // session pinger works
|
|
foxel@0
|
239 |
{
|
|
foxel@0
|
240 |
|
|
foxel@0
|
241 |
}
|
|
foxel@0
|
242 |
elseif (($data = $QF->DSets->Get_DSet_Value('fox_ajax_scripts', $name)) && isset($data['module'], $data['method']))
|
|
foxel@0
|
243 |
{
|
|
foxel@0
|
244 |
$QF->Run_Module($data['module']);
|
|
foxel@0
|
245 |
$AJAX_DATA = qf_func_call_ref(Array(&$QF->$data['module'], $data['method']), $AJAX_STATUS);
|
|
foxel@0
|
246 |
}
|
|
foxel@0
|
247 |
else
|
|
foxel@0
|
248 |
{
|
|
foxel@0
|
249 |
trigger_error('FOX: there is no "'.$name.'" AJAX parser file', E_USER_WARNING);
|
|
foxel@0
|
250 |
$AJAX_STATUS = 404;
|
|
foxel@0
|
251 |
$AJAX_DATA = 'Parser Not Found';
|
|
foxel@0
|
252 |
}
|
|
foxel@0
|
253 |
|
|
foxel@0
|
254 |
$AJAX_DATA = '{ status: '.intval($AJAX_STATUS).', data: '.qf_value_JS_definition($AJAX_DATA).' }';
|
|
foxel@0
|
255 |
if ($QF->GPC->Get_String('AJMethod', QF_GPC_GET, QF_STR_WORD) == 'form')
|
|
foxel@0
|
256 |
{
|
|
foxel@0
|
257 |
$AJAX_ID = $QF->GPC->Get_String('AJID', QF_GPC_GET, QF_STR_WORD);
|
|
foxel@0
|
258 |
$AJAX_DATA = 'top && top.QF_AJAX && top.QF_AJAX.Form_Ready(\''.$AJAX_ID.'\', '.$AJAX_DATA.' );';
|
|
foxel@0
|
259 |
$AJAX_DATA = '<?xml version="1.0"?>
|
|
foxel@0
|
260 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
|
foxel@0
|
261 |
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
foxel@0
|
262 |
<head><!--Meta-Content-Type--></head><body><script type="text/javascript">
|
|
foxel@0
|
263 |
// JavaScript Starts Here <![CDATA[
|
|
foxel@0
|
264 |
'.$AJAX_DATA.'
|
|
foxel@0
|
265 |
//]]> JavaScript ends here
|
|
foxel@0
|
266 |
</script></body></html>';
|
|
foxel@0
|
267 |
}
|
|
foxel@0
|
268 |
else
|
|
foxel@0
|
269 |
$QF->HTTP->do_HTML = false;
|
|
foxel@0
|
270 |
|
|
foxel@0
|
271 |
$QF->HTTP->Clear();
|
|
foxel@0
|
272 |
$QF->HTTP->Write($AJAX_DATA);
|
|
foxel@0
|
273 |
$QF->HTTP->Send_Buffer($QF->Session->Get('recode_out'));
|
|
foxel@0
|
274 |
}
|
|
foxel@0
|
275 |
|
|
foxel@0
|
276 |
function Run_Script($name)
|
|
foxel@0
|
277 |
{
|
|
foxel@0
|
278 |
global $QF;
|
|
foxel@0
|
279 |
|
|
foxel@0
|
280 |
if (connection_aborted())
|
|
foxel@0
|
281 |
trigger_error('FOX: connection was aborted at client side', E_USER_WARNING);
|
|
foxel@0
|
282 |
elseif ($data = $QF->DSets->Get_DSet_Value('fox_scripts', $name))
|
|
foxel@0
|
283 |
{
|
|
foxel@0
|
284 |
Ignore_User_Abort(True);
|
|
foxel@0
|
285 |
|
|
foxel@0
|
286 |
$result = false;
|
|
foxel@0
|
287 |
|
|
foxel@0
|
288 |
if (isset($data['module'], $data['method']))
|
|
foxel@0
|
289 |
{
|
|
foxel@0
|
290 |
$QF->Run_Module($data['module']);
|
|
foxel@0
|
291 |
$result = qf_func_call(Array(&$QF->$data['module'], $data['method']));
|
|
foxel@0
|
292 |
if (!$result)
|
|
foxel@0
|
293 |
{
|
|
foxel@0
|
294 |
trigger_error('FOX: script "'.$file.'" did not set result by it\'s own', E_USER_NOTICE);
|
|
foxel@0
|
295 |
$result = Array(Lang('SCR_FINISHED_NORES'));
|
|
foxel@0
|
296 |
}
|
|
foxel@0
|
297 |
elseif (!is_array($result))
|
|
foxel@0
|
298 |
$result = Array($result);
|
|
foxel@0
|
299 |
}
|
|
foxel@0
|
300 |
elseif (isset($data['include']) && ($file = QF_SCRIPTS_DIR.$data['include'].'.php') && file_exists($file))
|
|
foxel@0
|
301 |
{
|
|
foxel@0
|
302 |
include ($file);
|
|
foxel@0
|
303 |
trigger_error('FOX: script-include "'.$file.'" did not end execution by it\'s own', E_USER_NOTICE);
|
|
foxel@0
|
304 |
$result = Array(Lang('SCR_FINISHED_NORES'));
|
|
foxel@0
|
305 |
}
|
|
foxel@0
|
306 |
else
|
|
foxel@0
|
307 |
{
|
|
foxel@0
|
308 |
$result = Array(Lang('ERR_SCR_CODE_NOTFOUND'), '', true);
|
|
foxel@0
|
309 |
trigger_error('FOX: there is no "'.$name.'" script data', E_USER_WARNING);
|
|
foxel@0
|
310 |
}
|
|
foxel@0
|
311 |
|
|
foxel@0
|
312 |
call_user_func_array(Array(&$this, 'Set_Result'), $result);
|
|
foxel@0
|
313 |
}
|
|
foxel@0
|
314 |
else
|
|
foxel@0
|
315 |
trigger_error('FOX: there is no "'.$name.'" script data', E_USER_WARNING);
|
|
foxel@0
|
316 |
}
|
|
foxel@0
|
317 |
|
|
foxel@0
|
318 |
function Show_Page($pg)
|
|
foxel@0
|
319 |
{
|
|
foxel@0
|
320 |
global $QF;
|
|
foxel@0
|
321 |
|
|
foxel@0
|
322 |
// running prepage autoruns from packages
|
|
foxel@0
|
323 |
if ($ar_datas = $QF->DSets->Get_DSet('fox_prepages'))
|
|
foxel@0
|
324 |
foreach ($ar_datas as $arun)
|
|
foxel@0
|
325 |
if (isset($arun['module'], $arun['method']))
|
|
foxel@0
|
326 |
{
|
|
foxel@0
|
327 |
$QF->Run_Module($arun['module']);
|
|
foxel@0
|
328 |
qf_func_call(Array(&$QF->$arun['module'], $arun['method']), $pg);
|
|
foxel@0
|
329 |
}
|
|
foxel@0
|
330 |
|
|
foxel@0
|
331 |
$QF->VIS->Add_Data_Array(0, Array(
|
|
foxel@0
|
332 |
'SITE_NAME' => ($site_name = $QF->Config->Get('site_name')) ? htmlspecialchars($site_name) : 'QuickFox 2',
|
|
foxel@0
|
333 |
) );
|
|
foxel@0
|
334 |
if ($adv = $QF->Config->Get('adv_data', 'visual'))
|
|
foxel@0
|
335 |
$QF->VIS->Add_Data(0, 'ADV', $adv);
|
|
foxel@0
|
336 |
|
|
foxel@0
|
337 |
|
|
foxel@0
|
338 |
if ((list($data, $pkg) = $QF->DSets->Get_DSet_Value('fox_pages', $pg, true)) && isset($data['module'], $data['method']))
|
|
foxel@0
|
339 |
{
|
|
foxel@0
|
340 |
// redirecting on multidomain redirection enabled
|
|
foxel@0
|
341 |
if ($QF->Config->Get('tgl_multidomain', 'fox2') && $QF->Config->Get('tgl_mdomain_redir', 'fox2') && ($domains = $QF->Config->Get('package_domains', 'fox2')) && is_array($domains) && count($domains))
|
|
foxel@0
|
342 |
{
|
|
foxel@0
|
343 |
if (isset($domains[$pkg]))
|
|
foxel@0
|
344 |
{
|
|
foxel@0
|
345 |
$domain = $domains[$pkg];
|
|
foxel@0
|
346 |
$domain = preg_replace('#^http\:(?:/)*|/$#i', '', $domain);
|
|
foxel@0
|
347 |
if ($domain != $QF->HTTP->SrvName)
|
|
foxel@0
|
348 |
{
|
|
foxel@0
|
349 |
$url = qf_full_url($QF->HTTP->Request, false, $domain);
|
|
foxel@0
|
350 |
$QF->HTTP->Redirect($url);
|
|
foxel@0
|
351 |
}
|
|
foxel@0
|
352 |
}
|
|
foxel@0
|
353 |
}
|
|
foxel@0
|
354 |
|
|
foxel@0
|
355 |
$QF->Run_Module($data['module']);
|
|
foxel@0
|
356 |
$p_subtitle = $p_title = '';
|
|
foxel@0
|
357 |
$d_result = false;
|
|
foxel@0
|
358 |
$d_status = 200;
|
|
foxel@0
|
359 |
$pg_node = qf_func_call_arr(Array(&$QF->$data['module'], $data['method']), Array(&$p_title, &$p_subtitle, &$d_result, &$d_status));
|
|
foxel@0
|
360 |
if ($pg_node)
|
|
foxel@0
|
361 |
$QF->VIS->Append_Node($pg_node, 'PAGE_CONT', 0);
|
|
foxel@0
|
362 |
if ($p_title)
|
|
foxel@0
|
363 |
$QF->VIS->Add_Data(0, 'PAGE_TITLE', $p_title);
|
|
foxel@0
|
364 |
if ($p_subtitle)
|
|
foxel@0
|
365 |
$QF->VIS->Add_Data(0, 'PAGE_SUBTITLE', $p_subtitle);
|
|
foxel@0
|
366 |
if ($d_status != 200)
|
|
foxel@0
|
367 |
$QF->HTTP->Set_Status($d_status);
|
|
foxel@0
|
368 |
if ($d_result && is_array($d_result))
|
|
foxel@0
|
369 |
call_user_method_array('Draw_Result', $this, $d_result);
|
|
foxel@0
|
370 |
}
|
|
foxel@0
|
371 |
elseif (($file = QF_PAGES_DIR.$pg.'_inc.php') && file_exists($file))
|
|
foxel@0
|
372 |
include ($file);
|
|
foxel@0
|
373 |
else
|
|
foxel@0
|
374 |
{
|
|
foxel@0
|
375 |
$this->Draw_Result(Lang('ERR_INCLUDE_LOAD'), ($QF->HTTP->Referer && !$QF->HTTP->ExtRef) ? $QF->HTTP->Referer : QF_INDEX, true);
|
|
foxel@0
|
376 |
$QF->HTTP->Set_Status(404);
|
|
foxel@0
|
377 |
}
|
|
foxel@0
|
378 |
|
|
foxel@0
|
379 |
|
|
foxel@0
|
380 |
$this->Draw_menu();
|
|
foxel@0
|
381 |
if ($QF->User->UID || ($QF->Config->Get('show_login_pan') && !$QF->User->is_spider))
|
|
foxel@0
|
382 |
$this->Draw_Panel('login');
|
|
foxel@0
|
383 |
|
|
foxel@0
|
384 |
|
|
foxel@0
|
385 |
if ($recode = $QF->GPC->Get_String('recode', QF_GPC_GET, QF_STR_WORD))
|
|
foxel@0
|
386 |
$QF->Session->Set('recode_out', $recode);
|
|
foxel@0
|
387 |
elseif ($recode !== null)
|
|
foxel@0
|
388 |
$QF->Session->Drop('recode_out');
|
|
foxel@0
|
389 |
|
|
foxel@0
|
390 |
// running postpage autoruns from packages
|
|
foxel@0
|
391 |
if ($ar_datas = $QF->DSets->Get_DSet('fox_postpages'))
|
|
foxel@0
|
392 |
foreach ($ar_datas as $arun)
|
|
foxel@0
|
393 |
if (isset($arun['module'], $arun['method']))
|
|
foxel@0
|
394 |
{
|
|
foxel@0
|
395 |
$QF->Run_Module($arun['module']);
|
|
foxel@0
|
396 |
qf_func_call(Array(&$QF->$arun['module'], $arun['method']), $pg, $pg_node);
|
|
foxel@0
|
397 |
}
|
|
foxel@0
|
398 |
|
|
foxel@0
|
399 |
$QF->HTTP->Clear();
|
|
foxel@0
|
400 |
$QF->HTTP->Write($QF->VIS->Make_HTML());
|
|
foxel@0
|
401 |
$QF->HTTP->Send_Buffer($QF->Session->Get('recode_out'));
|
|
foxel@0
|
402 |
}
|
|
foxel@0
|
403 |
|
|
foxel@0
|
404 |
function Draw_Menu()
|
|
foxel@0
|
405 |
{
|
|
foxel@0
|
406 |
global $QF;
|
|
foxel@0
|
407 |
$menubts = $QF->Config->Get('menu_buttons', 'visual');
|
|
foxel@0
|
408 |
$cur_butt = false;
|
|
foxel@0
|
409 |
if (is_array($menubts))
|
|
foxel@0
|
410 |
foreach ($menubts as $butt)
|
|
foxel@33
|
411 |
if (is_array($butt) && qf_str_is_url($butt['url']))
|
|
foxel@0
|
412 |
{
|
|
foxel@0
|
413 |
$butt['url'] = qf_full_url($butt['url'], true, $this->URL_domain);
|
|
foxel@0
|
414 |
if (isset($butt['is_sub']) && $butt['is_sub'] && $cur_butt)
|
|
foxel@0
|
415 |
$QF->VIS->Add_Node('MENU_SUBBUTTON', 'SUBS', $cur_butt, $butt);
|
|
foxel@0
|
416 |
else
|
|
foxel@0
|
417 |
$cur_butt = $QF->VIS->Add_Node('MENU_BUTTON', 'MENU_ITEMS', 0, $butt);
|
|
foxel@0
|
418 |
}
|
|
foxel@0
|
419 |
}
|
|
foxel@0
|
420 |
|
|
foxel@0
|
421 |
function Draw_Panel($name)
|
|
foxel@0
|
422 |
{
|
|
foxel@0
|
423 |
global $QF;
|
|
foxel@0
|
424 |
|
|
foxel@0
|
425 |
|
|
foxel@0
|
426 |
if (($data = $QF->DSets->Get_DSet_Value('fox_panels', $name)) && isset($data['module'], $data['method']))
|
|
foxel@0
|
427 |
{
|
|
foxel@0
|
428 |
$CUR_PANEL = $QF->VIS->Add_Node('PANEL_BODY', 'PANELS', 0, false, $name.'_panel');
|
|
foxel@0
|
429 |
$QF->Run_Module($data['module']);
|
|
foxel@0
|
430 |
qf_func_call(Array(&$QF->$data['module'], $data['method']), $CUR_PANEL);
|
|
foxel@0
|
431 |
return true;
|
|
foxel@0
|
432 |
}
|
|
foxel@0
|
433 |
else
|
|
foxel@0
|
434 |
return false;
|
|
foxel@0
|
435 |
}
|
|
foxel@0
|
436 |
|
|
foxel@0
|
437 |
|
|
foxel@0
|
438 |
function Gen_ASCode()
|
|
foxel@0
|
439 |
{
|
|
foxel@0
|
440 |
global $QF;
|
|
foxel@0
|
441 |
|
|
foxel@0
|
442 |
$new_code = qf_short_uid();
|
|
foxel@0
|
443 |
|
|
foxel@0
|
444 |
if ($QF->Session->Set('QFox2_ASCode', $new_code))
|
|
foxel@0
|
445 |
return $new_code;
|
|
foxel@0
|
446 |
|
|
foxel@0
|
447 |
return false;
|
|
foxel@0
|
448 |
}
|
|
foxel@0
|
449 |
|
|
foxel@0
|
450 |
function Check_ASCode($code)
|
|
foxel@0
|
451 |
{
|
|
foxel@0
|
452 |
global $QF;
|
|
foxel@0
|
453 |
|
|
foxel@0
|
454 |
$real_code = $QF->Session->Get('QFox2_ASCode');
|
|
foxel@0
|
455 |
|
|
foxel@0
|
456 |
return ($code == $real_code);
|
|
foxel@0
|
457 |
}
|
|
foxel@0
|
458 |
|
|
foxel@0
|
459 |
|
|
foxel@0
|
460 |
function Set_Result($text, $redir_to = '', $is_err = false, $code = '')
|
|
foxel@0
|
461 |
{
|
|
foxel@0
|
462 |
global $QF;
|
|
foxel@0
|
463 |
|
|
foxel@0
|
464 |
$res_id = qf_short_uid('res');
|
|
foxel@0
|
465 |
|
|
foxel@0
|
466 |
$QF->DBase->Do_Delete('results', 'WHERE time < '.($QF->Timer->time - QF_FOX2_RESULT_LIFETIME));
|
|
foxel@0
|
467 |
if (!$QF->Session->SID)
|
|
foxel@0
|
468 |
$QF->Session->Open_Session();
|
|
foxel@0
|
469 |
$ins_data = Array(
|
|
foxel@0
|
470 |
'res_id' => $res_id,
|
|
foxel@0
|
471 |
'code' => $code,
|
|
foxel@0
|
472 |
'text' => (string) $text,
|
|
foxel@0
|
473 |
'is_err' => ($is_err) ? 1 : 0,
|
|
foxel@0
|
474 |
'tr_errs' => ($is_err) ? implode('|', qf_array_parse($this->err_traced, 'dechex')) : '',
|
|
foxel@0
|
475 |
'time' => $QF->Timer->time,
|
|
foxel@0
|
476 |
'got_at' => $QF->HTTP->Request,
|
|
foxel@0
|
477 |
'redir_to' => $redir_to,
|
|
foxel@0
|
478 |
'u_sid' => $QF->Session->SID,
|
|
foxel@0
|
479 |
'u_id' => $QF->User->UID,
|
|
foxel@0
|
480 |
);
|
|
foxel@0
|
481 |
|
|
foxel@0
|
482 |
if ($QF->DBase->Do_Insert('results', $ins_data))
|
|
foxel@0
|
483 |
$QF->HTTP->Redirect($this->Gen_URL('fox2_showresult_page', Array($res_id)));
|
|
foxel@0
|
484 |
else
|
|
foxel@0
|
485 |
{
|
|
foxel@0
|
486 |
trigger_error('FOX: error setting result data', E_USER_WARNING);
|
|
foxel@0
|
487 |
// if user must be regirected we'll try do this without setting result data
|
|
foxel@0
|
488 |
if ($redir_to)
|
|
foxel@0
|
489 |
$QF->HTTP->Redirect($redir_to);
|
|
foxel@0
|
490 |
}
|
|
foxel@0
|
491 |
|
|
foxel@0
|
492 |
}
|
|
foxel@0
|
493 |
|
|
foxel@0
|
494 |
function Trace_Error($err_code)
|
|
foxel@0
|
495 |
{
|
|
foxel@0
|
496 |
global $QF;
|
|
foxel@0
|
497 |
$this->err_traced[] = (int) $err_code;
|
|
foxel@0
|
498 |
if ($QF->Config->Get('log_errors', 'loggers', 1))
|
|
foxel@0
|
499 |
$this->Log_Event($err_code, 'err_log');
|
|
foxel@0
|
500 |
}
|
|
foxel@0
|
501 |
|
|
foxel@0
|
502 |
function Link_JScript($name)
|
|
foxel@0
|
503 |
{
|
|
foxel@0
|
504 |
global $QF;
|
|
foxel@0
|
505 |
static $separate = null;
|
|
foxel@0
|
506 |
static $linked = Array();
|
|
foxel@0
|
507 |
|
|
foxel@0
|
508 |
if (!isset($QF->VIS))
|
|
foxel@0
|
509 |
return false;
|
|
foxel@0
|
510 |
|
|
foxel@0
|
511 |
if (is_null($separate))
|
|
foxel@0
|
512 |
$separate = (bool) $QF->Config->Get('css_separate');
|
|
foxel@0
|
513 |
|
|
foxel@0
|
514 |
if (in_array($name, $linked))
|
|
foxel@0
|
515 |
return true;
|
|
foxel@0
|
516 |
|
|
foxel@0
|
517 |
$linked[] = $name;
|
|
foxel@0
|
518 |
|
|
foxel@0
|
519 |
if ($separate)
|
|
foxel@0
|
520 |
return $QF->VIS->Add_Data(0, 'JS_BLOCKS', '<script type="text/javascript" src="'.$this->Gen_URL('fox2_js_data', $name, true).'" ></script>');
|
|
foxel@0
|
521 |
else
|
|
foxel@0
|
522 |
return $QF->VIS->Load_EJS($name);
|
|
foxel@0
|
523 |
}
|
|
foxel@0
|
524 |
|
|
foxel@0
|
525 |
function Describe_ErrCodes($descr_errs = false)
|
|
foxel@0
|
526 |
{
|
|
foxel@0
|
527 |
global $QF;
|
|
foxel@0
|
528 |
if (!$descr_errs)
|
|
foxel@0
|
529 |
$descr_errs = $this->err_traced;
|
|
foxel@0
|
530 |
|
|
foxel@0
|
531 |
if (is_array($descr_errs) && count($descr_errs))
|
|
foxel@0
|
532 |
{
|
|
foxel@0
|
533 |
$output = Array();
|
|
foxel@0
|
534 |
$packs = Array();
|
|
foxel@0
|
535 |
foreach ($descr_errs as $err_code)
|
|
foxel@0
|
536 |
{
|
|
foxel@0
|
537 |
$err_code = '0x'.dechex($err_code);
|
|
foxel@0
|
538 |
$info = $pkg = null;
|
|
foxel@0
|
539 |
list ($info, $pkg) = $QF->DSets->Get_DSet_Value('err_messages', $err_code, true);
|
|
foxel@0
|
540 |
|
|
foxel@0
|
541 |
if (!$info)
|
|
foxel@0
|
542 |
continue;
|
|
foxel@0
|
543 |
if (isset($info['sys']) && $info['sys'])
|
|
foxel@0
|
544 |
continue;
|
|
foxel@0
|
545 |
|
|
foxel@0
|
546 |
if (!in_array($pkg, $packs))
|
|
foxel@0
|
547 |
{
|
|
foxel@0
|
548 |
array_push($packs, $pkg);
|
|
foxel@0
|
549 |
$QF->LNG->Load_Language($pkg.'_errs');
|
|
foxel@0
|
550 |
}
|
|
foxel@0
|
551 |
|
|
foxel@0
|
552 |
|
|
foxel@0
|
553 |
$message = $info['mess'];
|
|
foxel@0
|
554 |
if (substr($message, 0, 2) == 'L_')
|
|
foxel@0
|
555 |
$message = $QF->LNG->Lang(substr($message, 2));
|
|
foxel@0
|
556 |
|
|
foxel@0
|
557 |
$output[$err_code] = $message;
|
|
foxel@0
|
558 |
}
|
|
foxel@0
|
559 |
|
|
foxel@0
|
560 |
return $output;
|
|
foxel@0
|
561 |
}
|
|
foxel@0
|
562 |
return false;
|
|
foxel@0
|
563 |
}
|
|
foxel@0
|
564 |
|
|
foxel@0
|
565 |
function Draw_Result($text, $redir_to = '', $is_err = false, $descr_errs = false)
|
|
foxel@0
|
566 |
{
|
|
foxel@0
|
567 |
global $QF;
|
|
foxel@0
|
568 |
|
|
foxel@0
|
569 |
$hurl = '';
|
|
foxel@0
|
570 |
|
|
foxel@33
|
571 |
if ($redir_to)
|
|
foxel@0
|
572 |
{
|
|
foxel@0
|
573 |
$url = qf_full_url($redir_to, false, $this->URL_domain);
|
|
foxel@0
|
574 |
$QF->Events->Call_Event_Ref('HTTP_URL_Parse', $url );
|
|
foxel@0
|
575 |
$hurl = strtr($url, Array('&' => '&'));
|
|
foxel@0
|
576 |
|
|
foxel@0
|
577 |
header('Refresh: 7; URL="'.$url.'"');
|
|
foxel@0
|
578 |
}
|
|
foxel@0
|
579 |
$res_node = $QF->VIS->Add_Node('FOX_RESULT_WINDOW', 'PAGE_CONT', 0, Array(
|
|
foxel@0
|
580 |
'text' => $text,
|
|
foxel@0
|
581 |
'is_err' => ($is_err) ? 1 : null,
|
|
foxel@0
|
582 |
'redir_url' => $hurl,
|
|
foxel@0
|
583 |
) );
|
|
foxel@0
|
584 |
$QF->VIS->Add_Data(0, 'PAGE_TITLE', ($is_err) ? Lang('RES_CAPT_ERR') : Lang('RES_CAPT'));
|
|
foxel@0
|
585 |
|
|
foxel@0
|
586 |
if ($descr_errs = $this->Describe_ErrCodes($descr_errs))
|
|
foxel@0
|
587 |
{
|
|
foxel@0
|
588 |
$err_nodes = Array();
|
|
foxel@0
|
589 |
foreach($descr_errs as $code => $mess)
|
|
foxel@0
|
590 |
$err_nodes[] = Array('ERRCODE' => $code, 'MESSAGE' => $mess);
|
|
foxel@0
|
591 |
|
|
foxel@0
|
592 |
if (count($err_nodes))
|
|
foxel@0
|
593 |
$QF->VIS->Add_Node_Array('FOX_RESULT_ERR_ITEM', 'ERRORS', $res_node, $err_nodes);
|
|
foxel@0
|
594 |
}
|
|
foxel@0
|
595 |
}
|
|
foxel@0
|
596 |
|
|
foxel@0
|
597 |
function Gen_Pages($pages, $cur_page, $params = false)
|
|
foxel@0
|
598 |
{
|
|
foxel@0
|
599 |
if (!is_array($params))
|
|
foxel@0
|
600 |
$params = Array();
|
|
foxel@0
|
601 |
|
|
foxel@0
|
602 |
if ($pages < 2)
|
|
foxel@0
|
603 |
return false;
|
|
foxel@0
|
604 |
|
|
foxel@0
|
605 |
$cur_page = max(1, min($cur_page, $pages));
|
|
foxel@0
|
606 |
|
|
foxel@0
|
607 |
$draw_pages = Array();
|
|
foxel@0
|
608 |
$pp = False;
|
|
foxel@0
|
609 |
for($stt = 1; $stt <= $pages; $stt++)
|
|
foxel@0
|
610 |
{
|
|
foxel@0
|
611 |
if ($stt <= 4 || $stt >= ($pages - 3) || Abs($stt - $cur_page) < 3) {
|
|
foxel@0
|
612 |
$draw_pages[] = $params + Array('PAGE' => $stt, 'CUR' => ($stt == $cur_page) ? true : null);
|
|
foxel@0
|
613 |
$pp = true;
|
|
foxel@0
|
614 |
}
|
|
foxel@0
|
615 |
elseif ($pp)
|
|
foxel@0
|
616 |
{
|
|
foxel@0
|
617 |
$draw_pages[] = Array('SEPAR' => true);
|
|
foxel@0
|
618 |
$pp = false;
|
|
foxel@0
|
619 |
}
|
|
foxel@0
|
620 |
}
|
|
foxel@0
|
621 |
|
|
foxel@0
|
622 |
return $draw_pages;
|
|
foxel@0
|
623 |
}
|
|
foxel@0
|
624 |
|
|
foxel@0
|
625 |
function Log_Event($event, $log_name = 'common')
|
|
foxel@0
|
626 |
{
|
|
foxel@0
|
627 |
global $QF;
|
|
foxel@0
|
628 |
$log_name = substr(preg_replace('#\W#', '_', $log_name), 0, 32);
|
|
foxel@0
|
629 |
$ins_data = Array(
|
|
foxel@0
|
630 |
'log_id' => $log_name,
|
|
foxel@0
|
631 |
'time' => $QF->Timer->time,
|
|
foxel@0
|
632 |
'event' => $event,
|
|
foxel@0
|
633 |
'cl_ip' => $QF->HTTP->IP_int,
|
|
foxel@0
|
634 |
'cl_req' => $QF->HTTP->Request,
|
|
foxel@0
|
635 |
'cl_uagent' => $QF->HTTP->UAgent,
|
|
foxel@0
|
636 |
);
|
|
foxel@0
|
637 |
return $QF->DBase->Do_Insert('fox_logs', $ins_data);
|
|
foxel@0
|
638 |
}
|
|
foxel@0
|
639 |
|
|
foxel@0
|
640 |
function Gen_URL($url_id, $params = Array(), $with_amps = false, $no_enc = false)
|
|
foxel@0
|
641 |
{
|
|
foxel@0
|
642 |
global $QF;
|
|
foxel@0
|
643 |
static $vars;
|
|
foxel@0
|
644 |
if (!$vars)
|
|
foxel@0
|
645 |
$vars = Array(
|
|
foxel@0
|
646 |
'{QF_SID}' => $QF->Session->SID,
|
|
foxel@0
|
647 |
'{TIME}' => $QF->Timer->time,
|
|
foxel@0
|
648 |
);
|
|
foxel@0
|
649 |
|
|
foxel@0
|
650 |
if (!is_array($params))
|
|
foxel@0
|
651 |
$params = Array($params);
|
|
foxel@0
|
652 |
if (!$url_id)
|
|
foxel@0
|
653 |
return QF_INDEX;
|
|
foxel@0
|
654 |
|
|
foxel@0
|
655 |
$url_id = strtoupper($url_id);
|
|
foxel@0
|
656 |
|
|
foxel@0
|
657 |
if (!is_array($this->URL_temps))
|
|
foxel@0
|
658 |
$this->_Load_URLS();
|
|
foxel@0
|
659 |
|
|
foxel@0
|
660 |
if (isset($this->URL_temps[$url_id]))
|
|
foxel@0
|
661 |
{
|
|
foxel@0
|
662 |
if (!$no_enc)
|
|
foxel@0
|
663 |
$params = qf_array_parse($params, 'qf_url_encode_part');
|
|
foxel@0
|
664 |
|
|
foxel@0
|
665 |
$string = strtr($this->URL_temps[$url_id], $vars);
|
|
foxel@0
|
666 |
$masks = Array();
|
|
foxel@0
|
667 |
$a_params = $r_params = Array();
|
|
foxel@0
|
668 |
|
|
foxel@0
|
669 |
$count = preg_match_all('#\%(\d+)\$|\%\w#', $string, $masks, PREG_PATTERN_ORDER);
|
|
foxel@0
|
670 |
if ($count > 0)
|
|
foxel@0
|
671 |
{
|
|
foxel@0
|
672 |
$masks = $masks[1];
|
|
foxel@0
|
673 |
$count = max($count, max($masks));
|
|
foxel@0
|
674 |
$r_params = explode('|', str_repeat('|', $count));
|
|
foxel@0
|
675 |
}
|
|
foxel@0
|
676 |
|
|
foxel@0
|
677 |
foreach($params as $key => $param)
|
|
foxel@0
|
678 |
{
|
|
foxel@0
|
679 |
if (is_int($key))
|
|
foxel@0
|
680 |
$r_params[$key] = $param;
|
|
foxel@0
|
681 |
else
|
|
foxel@0
|
682 |
$a_params[] = qf_url_encode_part($key).'='.$param;
|
|
foxel@0
|
683 |
}
|
|
foxel@0
|
684 |
$string = qf_sprintf_arr($string, $r_params);
|
|
foxel@0
|
685 |
if (count($a_params))
|
|
foxel@0
|
686 |
$string.= ((strstr($string, '?')) ? '&' : '?').implode('&', $a_params);
|
|
foxel@0
|
687 |
|
|
foxel@0
|
688 |
$string = ($with_amps) ? preg_replace('#\&(?![A-z]+;)#', '&', $string) : str_replace('&', '&', $string);
|
|
foxel@0
|
689 |
return $string;
|
|
foxel@0
|
690 |
}
|
|
foxel@0
|
691 |
else
|
|
foxel@0
|
692 |
return '#';
|
|
foxel@1
|
693 |
}
|
|
foxel@0
|
694 |
|
|
foxel@0
|
695 |
function On_VIS_Prep(&$indata, $type = false)
|
|
foxel@0
|
696 |
{
|
|
foxel@0
|
697 |
if (!is_array($this->URL_temps))
|
|
foxel@6
|
698 |
$this->_Load_URLS();
|
|
foxel@0
|
699 |
|
|
foxel@0
|
700 |
$indata = preg_replace_callback('#\{(?>(F|R)?URL:((?:\w+|\"[^\"]+\"|\|)+))\}#',Array(&$this, '_VISParse_URL_CB'),$indata);
|
|
foxel@1
|
701 |
}
|
|
foxel@0
|
702 |
|
|
foxel@0
|
703 |
function On_EJS_Prep(&$indata, $type = false)
|
|
foxel@0
|
704 |
{
|
|
foxel@0
|
705 |
if (!is_array($this->URL_temps))
|
|
foxel@6
|
706 |
$this->_Load_URLS();
|
|
foxel@0
|
707 |
|
|
foxel@0
|
708 |
$indata = preg_replace_callback('#\{(?>(F|R)?URL:((?:\w+|\"[^\"]+\"|\|)+))\}#',Array(&$this, '_VISParse_URL_CB'),$indata);
|
|
foxel@34
|
709 |
}
|
|
foxel@34
|
710 |
|
|
foxel@34
|
711 |
function _VISUserMods_Add(&$indata, $style, $part)
|
|
foxel@34
|
712 |
{
|
|
foxel@34
|
713 |
global $QF;
|
|
foxel@34
|
714 |
|
|
foxel@34
|
715 |
if (!isset($this->VIS_redefs[$style]) && !$this->_VISUserMods_Preload($style))
|
|
foxel@34
|
716 |
return;
|
|
foxel@34
|
717 |
|
|
foxel@34
|
718 |
if (isset($this->VIS_redefs[$style]) && isset($this->VIS_redefs[$style][$part]))
|
|
foxel@34
|
719 |
$indata.= $this->VIS_redefs[$style][$part];
|
|
foxel@34
|
720 |
}
|
|
foxel@19
|
721 |
|
|
foxel@19
|
722 |
/*function _VISUserMods_Preload()
|
|
foxel@34
|
723 |
{
|
|
foxel@34
|
724 |
global $QF;
|
|
foxel@34
|
725 |
$QF->VIS->Load_Templates('user_redefined');
|
|
foxel@34
|
726 |
} */
|
|
foxel@34
|
727 |
|
|
foxel@34
|
728 |
function _VISUserMods_Preload($style)
|
|
foxel@34
|
729 |
{
|
|
foxel@34
|
730 |
global $QF;
|
|
foxel@34
|
731 |
if (!$QF->Check_Module('VIS'))
|
|
foxel@34
|
732 |
return false;
|
|
foxel@34
|
733 |
|
|
foxel@34
|
734 |
$style = strtolower($style);
|
|
foxel@34
|
735 |
if (isset($this->VIS_redefs[$style]))
|
|
foxel@34
|
736 |
return true;
|
|
foxel@34
|
737 |
|
|
foxel@34
|
738 |
$cachename = QF_KERNEL_VIS_VPREFIX.$style.'_redefs';
|
|
foxel@34
|
739 |
$cfile = QF_STYLES_DIR.$style.'/redefined.vis';
|
|
foxel@34
|
740 |
if ($data = $QF->Cache->Get($cachename))
|
|
foxel@34
|
741 |
$this->VIS_redefs[$style] = $data;
|
|
foxel@34
|
742 |
elseif ($data = qf_file_get_contents($cfile))
|
|
foxel@34
|
743 |
{
|
|
foxel@34
|
744 |
preg_match_all('#\<\<part \'(\w+)\'\>\>|[^\<]+|\<#', $data, $struct, PREG_SET_ORDER);
|
|
foxel@34
|
745 |
$data = Array();
|
|
foxel@34
|
746 |
$p_name = QF_KERNEL_VIS_COMMON;
|
|
foxel@34
|
747 |
foreach ($struct as $part)
|
|
foxel@34
|
748 |
{
|
|
foxel@34
|
749 |
if ($part[1])
|
|
foxel@34
|
750 |
$p_name = strtolower($part[1]);
|
|
foxel@34
|
751 |
elseif (isset($data[$p_name]))
|
|
foxel@34
|
752 |
$data[$p_name].= $part[0];
|
|
foxel@34
|
753 |
else
|
|
foxel@34
|
754 |
$data[$p_name] = $part[0];
|
|
foxel@34
|
755 |
}
|
|
foxel@34
|
756 |
$QF->Cache->Set($cachename, $data);
|
|
foxel@19
|
757 |
$this->VIS_redefs[$style] = $data;
|
|
foxel@19
|
758 |
return true;
|
|
foxel@0
|
759 |
}
|
|
foxel@0
|
760 |
else
|
|
foxel@0
|
761 |
return false;
|
|
foxel@0
|
762 |
}
|
|
foxel@0
|
763 |
|
|
foxel@0
|
764 |
function _VISParse_URL_CB($matches)
|
|
foxel@0
|
765 |
{
|
|
foxel@0
|
766 |
$code = $matches[2];
|
|
foxel@0
|
767 |
$code = explode('|', $code);
|
|
foxel@0
|
768 |
|
|
foxel@0
|
769 |
if (!($url_id = strtoupper($code[0])))
|
|
foxel@0
|
770 |
return '#';
|
|
foxel@0
|
771 |
if (!isset($this->URL_temps[$url_id]))
|
|
foxel@0
|
772 |
return '#';
|
|
foxel@0
|
773 |
|
|
foxel@0
|
774 |
if ($params = array_slice($code, 1))
|
|
foxel@0
|
775 |
{
|
|
foxel@0
|
776 |
foreach ($params as $id => $val)
|
|
foxel@0
|
777 |
$params[$id] = (is_numeric($val{0})) ? (int) $val : (($val{0} == '"') ? rawurlencode(substr($val, 1, -1)) : '{URLEN:'.$val.'}');
|
|
foxel@0
|
778 |
}
|
|
foxel@33
|
779 |
else
|
|
foxel@7
|
780 |
$params = Array();
|
|
foxel@7
|
781 |
|
|
foxel@7
|
782 |
$url = $this->Gen_URL($url_id, $params, true, true);
|
|
foxel@7
|
783 |
if ($matches[1] == 'F')
|
|
foxel@7
|
784 |
$url = qf_full_url($url, true, $this->URL_domain);
|
|
foxel@7
|
785 |
elseif ($matches[1] == 'R') // && $url{0} != '/'
|
|
foxel@7
|
786 |
{
|
|
foxel@0
|
787 |
$comps = parse_url($url);
|
|
foxel@0
|
788 |
if (!$comps['scheme'])
|
|
foxel@0
|
789 |
$url = '{QF_ROOT}'.$url;
|
|
foxel@0
|
790 |
}
|
|
foxel@0
|
791 |
|
|
foxel@0
|
792 |
return $url;
|
|
foxel@0
|
793 |
}
|
|
foxel@0
|
794 |
|
|
foxel@0
|
795 |
function _Load_URLS()
|
|
foxel@0
|
796 |
{
|
|
foxel@0
|
797 |
global $QF;
|
|
foxel@0
|
798 |
static $consts = Array(
|
|
foxel@0
|
799 |
'{QF_INDEX}' => QF_INDEX,
|
|
foxel@0
|
800 |
);
|
|
foxel@0
|
801 |
|
|
foxel@0
|
802 |
|
|
foxel@0
|
803 |
if (count($this->URL_temps))
|
|
foxel@0
|
804 |
return false;
|
|
foxel@0
|
805 |
|
|
foxel@0
|
806 |
$cachename = ($QF->Config->Get('gen_rwurls'))
|
|
foxel@0
|
807 |
? QF_FOX2_URLTEMPS_RW_CACHENAME : QF_FOX2_URLTEMPS_CACHENAME;
|
|
foxel@0
|
808 |
|
|
foxel@0
|
809 |
if ($data = $QF->Cache->Get($cachename))
|
|
foxel@0
|
810 |
$this->URL_temps = $data;
|
|
foxel@0
|
811 |
elseif (list($data, $pkgs) = $QF->DSets->Get_DSet('urltemplates', true))
|
|
foxel@0
|
812 |
{
|
|
foxel@0
|
813 |
if ($QF->Config->Get('gen_rwurls') && (list($rwdata, $rwpkgs) = $QF->DSets->Get_DSet('mod_rw_urlts', true)))
|
|
foxel@0
|
814 |
{
|
|
foxel@0
|
815 |
$data = $rwdata + $data;
|
|
foxel@0
|
816 |
$pkgs = $rwpkgs + $pkgs;
|
|
foxel@33
|
817 |
}
|
|
foxel@33
|
818 |
|
|
foxel@33
|
819 |
$data = str_replace(array_keys($consts), array_values($consts), $data);
|
|
foxel@33
|
820 |
|
|
foxel@33
|
821 |
|
|
foxel@33
|
822 |
if ($QF->Config->Get('tgl_multidomain', 'fox2'))
|
|
foxel@33
|
823 |
{
|
|
foxel@33
|
824 |
$domains = $QF->Config->Get('package_domains', 'fox2');
|
|
foxel@0
|
825 |
$ldomains = $QF->Config->Get('linked_domains', 'fox2');
|
|
foxel@33
|
826 |
$basedomain = $QF->Config->Get('basic_domain', 'fox2');
|
|
foxel@0
|
827 |
if (!is_array($domains))
|
|
foxel@33
|
828 |
$domains = Array();
|
|
foxel@33
|
829 |
if (!is_array($ldomains) || !$basedomain)
|
|
foxel@33
|
830 |
$ldomains = Array();
|
|
foxel@33
|
831 |
|
|
foxel@33
|
832 |
if (count($domains) || count($ldomains))
|
|
foxel@0
|
833 |
{
|
|
foxel@33
|
834 |
$domains = preg_replace('#^http\:(?:/)*|/$#i', '', $domains);
|
|
foxel@33
|
835 |
$ldomains = preg_replace('#^http\:(?:/)*|/$#i', '', $ldomains);
|
|
foxel@33
|
836 |
$basedomain = preg_replace('#^http\:(?:/)*|/$#i', '', $basedomain);
|
|
foxel@33
|
837 |
|
|
foxel@33
|
838 |
foreach ($data as $key => $val)
|
|
foxel@33
|
839 |
{
|
|
foxel@33
|
840 |
$cur_pkg = $pkgs[$key];
|
|
foxel@33
|
841 |
list($cur_link, $cur_url) = explode('/', $val, 2);
|
|
foxel@33
|
842 |
if ($cur_link && isset($ldomains[$cur_link]))
|
|
foxel@33
|
843 |
{
|
|
foxel@33
|
844 |
$domain = $ldomains[$cur_link];
|
|
foxel@33
|
845 |
$val = qf_full_url($cur_url, true, $domain);
|
|
foxel@33
|
846 |
$data[$key] = $val;
|
|
foxel@33
|
847 |
}
|
|
foxel@0
|
848 |
elseif (isset($domains[$cur_pkg]))
|
|
foxel@0
|
849 |
{
|
|
foxel@0
|
850 |
$domain = $domains[$cur_pkg];
|
|
foxel@0
|
851 |
$val = qf_full_url($val, true, $domain);
|
|
foxel@0
|
852 |
$data[$key] = $val;
|
|
foxel@0
|
853 |
}
|
|
foxel@0
|
854 |
}
|
|
foxel@0
|
855 |
}
|
|
foxel@0
|
856 |
}
|
|
foxel@0
|
857 |
|
|
foxel@0
|
858 |
$QF->Cache->Set($cachename, $data);
|
|
foxel@0
|
859 |
$this->URL_temps = $data;
|
|
foxel@0
|
860 |
}
|
|
foxel@0
|
861 |
else
|
|
foxel@0
|
862 |
$this->URL_temps = Array();
|
|
foxel@0
|
863 |
|
|
foxel@0
|
864 |
return true;
|
|
foxel@0
|
865 |
}
|
|
foxel@0
|
866 |
|
|
foxel@0
|
867 |
function _Parse_PathInfo()
|
|
foxel@0
|
868 |
{
|
|
foxel@0
|
869 |
global $QF;
|
|
foxel@0
|
870 |
if (!($pt_info = $QF->HTTP->PtInfo))
|
|
foxel@0
|
871 |
return false;
|
|
foxel@0
|
872 |
|
|
foxel@0
|
873 |
$pt_info = explode('/', $pt_info);
|
|
foxel@0
|
874 |
$pt_id = $pt_info[0];
|
|
foxel@0
|
875 |
$pt_parse = $QF->DSets->Get_DSet_Value('ptinfo_masks', $pt_id);
|
|
foxel@0
|
876 |
if (is_array($pt_parse))
|
|
foxel@0
|
877 |
{
|
|
foxel@0
|
878 |
$pt_parse = array_values($pt_parse);
|
|
foxel@0
|
879 |
$pt_data = Array();
|
|
foxel@0
|
880 |
$imax = min(count($pt_parse), count($pt_info));
|
|
foxel@0
|
881 |
for ($i=0; $i<$imax; $i++)
|
|
foxel@0
|
882 |
$pt_data[$pt_parse[$i]] = $pt_info[$i];
|
|
foxel@0
|
883 |
|
|
foxel@0
|
884 |
trigger_error(qf_array_definition($pt_data), E_USER_WARNING);
|
|
foxel@0
|
885 |
|
|
foxel@0
|
886 |
$QF->GPC->Set_Raws($pt_data, QF_GPC_GET);
|
|
foxel@0
|
887 |
}
|
|
foxel@0
|
888 |
}
|
|
foxel@0
|
889 |
|
|
foxel@0
|
890 |
|
|
foxel@0
|
891 |
function _Parse_RW($rw_id, $rw_data)
|
|
foxel@0
|
892 |
{
|
|
foxel@0
|
893 |
global $QF;
|
|
foxel@0
|
894 |
|
|
foxel@0
|
895 |
if (!$rw_id)
|
|
foxel@0
|
896 |
return false;
|
|
foxel@0
|
897 |
|
|
foxel@0
|
898 |
$rw_mask = $QF->DSets->Get_DSet_Value('RW_masks', $rw_id);
|
|
foxel@0
|
899 |
$rw_data = preg_replace('#\.\w*$#D', '', $rw_data);
|
|
foxel@0
|
900 |
|
|
foxel@0
|
901 |
if (!$rw_mask)
|
|
foxel@0
|
902 |
{
|
|
foxel@0
|
903 |
$QF->GPC->Set_Raws(Array('st' => $rw_id, 'dpath' => $rw_data), QF_GPC_GET);
|
|
foxel@0
|
904 |
}
|
|
foxel@0
|
905 |
elseif (is_array($rw_mask))
|
|
foxel@0
|
906 |
{
|
|
foxel@0
|
907 |
$rw_data = explode('/', $rw_data);
|
|
foxel@0
|
908 |
$rw_mask = preg_replace('#\$(\d+)#e', '(isset(\$rw_data[\1])) ? \$rw_data[\1] : ""', $rw_mask);
|
|
foxel@0
|
909 |
|
|
foxel@0
|
910 |
$QF->GPC->Set_Raws($rw_mask, QF_GPC_GET);
|
|
foxel@0
|
911 |
}
|
|
foxel@0
|
912 |
else
|
|
foxel@0
|
913 |
return false;
|
|
foxel@0
|
914 |
|
|
foxel@0
|
915 |
return true;
|
|
foxel@0
|
916 |
}
|
|
foxel@0
|
917 |
|
|
foxel@0
|
918 |
function HTML_FullURLs(&$buffer)
|
|
foxel@0
|
919 |
{
|
|
foxel@0
|
920 |
$buffer = preg_replace_callback('#(<(a|form|img|link|script)\s+[^>]*?)(href|action|src)\s*=\s*(\"([^\"<>\(\)]*)\"|\'([^\'<>\(\)]*)\'|[^\s<>\(\)]+)#i', Array(&$this, '_FullURLs_Parse_Callback'), $buffer);
|
|
foxel@0
|
921 |
}
|
|
foxel@0
|
922 |
|
|
foxel@0
|
923 |
function _FullURLs_Parse_Callback($vars)
|
|
foxel@0
|
924 |
{
|
|
foxel@0
|
925 |
Global $QF;
|
|
foxel@0
|
926 |
if (!is_array($vars))
|
|
foxel@0
|
927 |
return false;
|
|
foxel@0
|
928 |
|
|
foxel@0
|
929 |
if (isset($vars[6]))
|
|
foxel@0
|
930 |
{
|
|
foxel@0
|
931 |
$url = $vars[6];
|
|
foxel@0
|
932 |
$bounds = '\'';
|
|
foxel@0
|
933 |
}
|
|
foxel@0
|
934 |
elseif (isset($vars[5]))
|
|
foxel@0
|
935 |
{
|
|
foxel@0
|
936 |
$url = $vars[5];
|
|
foxel@0
|
937 |
$bounds = '"';
|
|
foxel@0
|
938 |
}
|
|
foxel@0
|
939 |
else
|
|
foxel@33
|
940 |
{
|
|
foxel@0
|
941 |
$url = $vars[4];
|
|
foxel@0
|
942 |
$bounds = '';
|
|
foxel@0
|
943 |
}
|
|
foxel@0
|
944 |
|
|
foxel@0
|
945 |
if (qf_str_is_url($url) == 2)
|
|
foxel@0
|
946 |
$url = qf_full_url($url, true, $this->URL_domain);
|
|
foxel@0
|
947 |
|
|
foxel@0
|
948 |
return $vars[1].$vars[3].'='.$bounds.$url.$bounds;
|
|
foxel@0
|
949 |
|
|
foxel@0
|
950 |
}
|
|
foxel@0
|
951 |
|
|
foxel@34
|
952 |
}
|
|
foxel@34
|
953 |
|
|
foxel@34
|
954 |
$QF->Register_Module('FOX', __FILE__, 'Fox2');
|
|
foxel@34
|
955 |
$QF->Run_Module('FOX');
|
|
foxel@34
|
956 |
|
|
foxel@34
|
957 |
?>
|