|
| |
1 |
|
<?php |
|
| |
2 |
|
|
|
| |
3 |
|
if (!function_exists('parse_portal_ini')) { |
|
| |
4 |
|
function parse_portal_ini($file, $parse_section = false) { |
|
| |
5 |
|
|
|
| |
6 |
|
if (!file_exists($file)) return false; |
|
| |
7 |
|
|
|
| |
8 |
|
if(file_exists($file) && !is_readable($file)) |
|
| |
9 |
|
die('Could Not Open Ini File'); |
|
| |
10 |
|
|
|
| |
11 |
|
$contents = file($file); |
|
| |
12 |
|
|
|
| |
13 |
|
$retval = array(); |
|
| |
14 |
|
|
|
| |
15 |
|
$section = ''; |
|
| |
16 |
|
$ln = 1; |
|
| |
17 |
|
$resave = false; |
|
| |
18 |
|
foreach($contents as $line) { |
|
| |
19 |
|
if ($ln == 1 && $line != '<'.'?'.'php die() ?'.">\n") { |
|
| |
20 |
|
$resave = true; |
|
| |
21 |
|
} |
|
| |
22 |
|
$ln++; |
|
| |
23 |
|
$line = trim($line); |
|
| |
24 |
|
$line = eregi_replace(';[.]*','',$line); |
|
| |
25 |
|
if(strlen($line) > 0) { |
|
| |
26 |
|
|
|
| |
27 |
|
if(eregi('^[[a-z]+]$',str_replace(' ', '', $line))) { |
|
| |
28 |
|
|
|
| |
29 |
|
$section = substr($line,1,(strlen($line)-2)); |
|
| |
30 |
|
if ($parse_section) { |
|
| |
31 |
|
$retval[$section] = array(); |
|
| |
32 |
|
} |
|
| |
33 |
|
continue; |
|
| |
34 |
|
} elseif(eregi('=',$line)) { |
|
| |
35 |
|
|
|
| |
36 |
|
list($key,$val) = explode(' = ',$line); |
|
| |
37 |
|
if (!$parse_section) { |
|
| |
38 |
|
$retval[trim($key)] = str_replace('"', '', $val); |
|
| |
39 |
|
} |
|
| |
40 |
|
else { |
|
| |
41 |
|
$retval[$section][trim($key)] = str_replace('"', '', $val); |
|
| |
42 |
|
} |
|
| |
43 |
|
} |
|
| |
44 |
|
|
|
| |
45 |
|
} |
|
| |
46 |
|
} |
|
| |
47 |
|
if ($resave) { |
|
| |
48 |
|
$fp = fopen($file, "w"); |
|
| |
49 |
|
reset($contents); |
|
| |
50 |
|
fwrite($fp,'<'.'?'.'php die() ?'.">\n\n"); |
|
| |
51 |
|
foreach($contents as $line) fwrite($fp,"$line"); |
|
| |
52 |
|
fclose($fp); |
|
| |
53 |
|
} |
|
| |
54 |
|
|
|
| |
55 |
|
return $retval; |
|
| |
56 |
|
} |
|
| |
57 |
|
} |
|
| |
58 |
|
|
|
| |
59 |
|
$vars = parse_portal_ini(FULL_PATH.'/config.php'); |
|
| |
60 |
|
if ($vars) { |
|
| |
61 |
|
foreach ($vars as $config_key => $config_value) { |
|
| |
62 |
|
$GLOBALS['g_'.$config_key] = $config_value; |
|
| |
63 |
|
} |
|
| |
64 |
|
unset($config_key, $config_value); |
|
| |
65 |
|
} |
|
| |
66 |
|
|
|
| |
67 |
|
|
|
| |
68 |
|
$ItemTables = array(); |
|
| |
69 |
|
|
|
| |
70 |
|
$KeywordIgnore = array(); |
|
| |
71 |
|
global $debuglevel; |
|
| |
72 |
|
|
|
| |
73 |
|
$debuglevel = 0; |
|
| |
74 |
|
|
|
| |
75 |
|
|
|
| |
76 |
|
|
|
| |
77 |
|
define('NEVER', 0); |
|
| |
78 |
|
define('ALWAYS', 1); |
|
| |
79 |
|
define('AUTO', 2); |
|
| |
80 |
|
|
|
| |
81 |
|
|
|
| |
82 |
|
if( !defined('STATUS_DISABLED') ) define('STATUS_DISABLED', 0); |
|
| |
83 |
|
if( !defined('STATUS_ACTIVE') ) define('STATUS_ACTIVE', 1); |
|
| |
84 |
|
if( !defined('STATUS_PENDING') ) define('STATUS_PENDING', 2); |
|
| |
85 |
|
|
|
| |
86 |
|
$LogLevel = 0; |
|
| |
87 |
|
$LogFile = NULL; |
|
| |
88 |
|
|
|
| |
89 |
|
|
|
| |
90 |
|
|
|
| |
91 |
|
|
|
| |
92 |
|
|
|
| |
93 |
|
|
|
| |
94 |
|
|
|
| |
95 |
|
function &GetADODBConnection($new_type = false) |
|
| |
96 |
|
{ |
|
| |
97 |
|
static $DB = null; |
|
| |
98 |
|
|
|
| |
99 |
|
global $g_DBType, $g_DBHost, $g_DBUser, $g_DBUserPassword, $g_DBName, $g_DebugMode; |
|
| |
100 |
|
global $ADODB_FETCH_MODE, $ADODB_COUNTRECS, $ADODB_CACHE_DIR, $pathtoroot; |
|
| |
101 |
|
|
|
| |
102 |
|
if ($new_type) { |
|
| |
103 |
|
$application =& kApplication::Instance(); |
|
| |
104 |
|
return $application->GetADODBConnection(); |
|
| |
105 |
|
} |
|
| |
106 |
|
|
|
| |
107 |
|
if( !isset($DB) && strlen($g_DBType) > 0 ) |
|
| |
108 |
|
{ |
|
| |
109 |
|
$DB = ADONewConnection($g_DBType); |
|
| |
110 |
|
$connected = $DB->Connect($g_DBHost, $g_DBUser, $g_DBUserPassword, $g_DBName); |
|
| |
111 |
|
if(!$connected) die("Error connecting to database $g_DBHost <br>\n"); |
|
| |
112 |
|
|
|
| |
113 |
|
$ADODB_CACHE_DIR = $pathtoroot."cache"; |
|
| |
114 |
|
$ADODB_FETCH_MODE = 2; |
|
| |
115 |
|
$ADODB_COUNTRECS = false; |
|
| |
116 |
|
$DB->debug = defined('ADODB_OUTP') ? 1 : 0; |
|
| |
117 |
|
$DB->cacheSecs = 3600; |
|
| |
118 |
|
$DB->Execute('SET SQL_BIG_SELECTS = 1'); |
|
| |
119 |
|
} |
|
| |
120 |
|
elseif( !strlen($g_DBType) ) |
|
| |
121 |
|
{ |
|
| |
122 |
|
global $rootURL; |
|
| |
123 |
|
echo 'In-Portal is probably not installed, or configuration file is missing.<br>'; |
|
| |
124 |
|
echo 'Please use the installation script to fix the problem.<br><br>'; |
|
| |
125 |
|
if ( !preg_match('/admin/', __FILE__) ) $ins = 'admin/'; |
|
| |
126 |
|
|
|
| |
127 |
|
echo '<a href="'.$rootURL.$ins.'install.php">Go to installation script</a><br><br>'; |
|
| |
128 |
|
flush(); |
|
| |
129 |
|
exit; |
|
| |
130 |
|
} |
|
| |
131 |
|
return $DB; |
|
| |
132 |
|
} |
|
| |
133 |
|
|
|
| |
134 |
|
function GetNextResourceId($Increment=1) |
|
| |
135 |
|
{ |
|
| |
136 |
|
global $objModules, $pathtoroot; |
|
| |
137 |
|
$table_name = GetTablePrefix().'IdGenerator'; |
|
| |
138 |
|
|
|
| |
139 |
|
$db = &GetADODBConnection(); |
|
| |
140 |
|
|
|
| |
141 |
|
|
|
| |
142 |
|
$max_resourceid = 0; |
|
| |
143 |
|
|
|
| |
144 |
|
$m = GetModuleArray(); |
|
| |
145 |
|
foreach($m as $key=>$value) |
|
| |
146 |
|
{ |
|
| |
147 |
|
$path = $pathtoroot. $value."admin/include/parser.php"; |
|
| |
148 |
|
if(file_exists($path)) |
|
| |
149 |
|
{ |
|
| |
150 |
|
include_once($path); |
|
| |
151 |
|
} |
|
| |
152 |
|
} |
|
| |
153 |
|
|
|
| |
154 |
|
$table_info = $objModules->ExecuteFunction('GetModuleInfo', 'dupe_resourceids'); |
|
| |
155 |
|
$sql_template = 'SELECT MAX(ResourceId) FROM '.GetTablePrefix().'%s'; |
|
| |
156 |
|
|
|
| |
157 |
|
foreach($table_info as $module_name => $module_info) |
|
| |
158 |
|
{ |
|
| |
159 |
|
foreach($module_info as $module_sub_info) |
|
| |
160 |
|
{ |
|
| |
161 |
|
$sql = sprintf($sql_template,$module_sub_info['Table']); |
|
| |
162 |
|
$tmp_resourceid = $db->GetOne($sql); |
|
| |
163 |
|
if($tmp_resourceid > $max_resourceid) $max_resourceid = $tmp_resourceid; |
|
| |
164 |
|
} |
|
| |
165 |
|
} |
|
| |
166 |
|
|
|
| |
167 |
|
|
|
| |
168 |
|
$db->Execute('LOCK TABLES '.$table_name.' WRITE'); |
|
| |
169 |
|
|
|
| |
170 |
|
$last_id = $db->GetOne('SELECT lastid FROM '.$table_name); |
|
| |
171 |
|
if ($last_id - 1 > $max_resourceid) $max_resourceid = $last_id - 1; |
|
| |
172 |
|
|
|
| |
173 |
|
$id_diff = $db->GetOne('SELECT '.$max_resourceid.' + 1 - lastid FROM '.$table_name); |
|
| |
174 |
|
if($id_diff) $Increment += $id_diff; |
|
| |
175 |
|
|
|
| |
176 |
|
$sql = 'UPDATE '.$table_name.' SET lastid = lastid + '.$Increment; |
|
| |
177 |
|
$db->Execute($sql); |
|
| |
178 |
|
|
|
| |
179 |
|
$val = $db->GetOne('SELECT lastid FROM '.$table_name); |
|
| |
180 |
|
if($val === false) |
|
| |
181 |
|
{ |
|
| |
182 |
|
$db->Execute('INSERT INTO '.$table_name.' (lastid) VALUES ('.$Increment.')'); |
|
| |
183 |
|
$val = $Increment; |
|
| |
184 |
|
} |
|
| |
185 |
|
$db->Execute('UNLOCK TABLES'); |
|
| |
186 |
|
|
|
| |
187 |
|
return $val - $Increment + $id_diff; |
|
| |
188 |
|
} |
|
| |
189 |
|
|
|
| |
190 |
|
function AddSlash($s) |
|
| |
191 |
|
{ |
|
| |
192 |
|
if(substr($s,-1) != "/") |
|
| |
193 |
|
{ |
|
| |
194 |
|
return $s."/"; |
|
| |
195 |
|
} |
|
| |
196 |
|
else |
|
| |
197 |
|
return $s; |
|
| |
198 |
|
} |
|
| |
199 |
|
|
|
| |
200 |
|
function StripNewline($s) |
|
| |
201 |
|
{ |
|
| |
202 |
|
$bfound = false; |
|
| |
203 |
|
while (strlen($s)>0 && !$bfound) |
|
| |
204 |
|
{ |
|
| |
205 |
|
if(ord(substr($s,-1))<32) |
|
| |
206 |
|
{ |
|
| |
207 |
|
$s = substr($s,0,-1); |
|
| |
208 |
|
} |
|
| |
209 |
|
else |
|
| |
210 |
|
$bfound = true; |
|
| |
211 |
|
} |
|
| |
212 |
|
return $s; |
|
| |
213 |
|
} |
|
| |
214 |
|
|
|
| |
215 |
|
function DeleteElement($array, $indice) |
|
| |
216 |
|
{ |
|
| |
217 |
|
for($i=$indice;$i<count($array)-1;$i++) |
|
| |
218 |
|
$array[$i] = $array[$i+1]; |
|
| |
219 |
|
unset($array[count($array)-1]); |
|
| |
220 |
|
return $array; |
|
| |
221 |
|
} |
|
| |
222 |
|
|
|
| |
223 |
|
function DeleteElementValue($needle, &$haystack) |
|
| |
224 |
|
{ |
|
| |
225 |
|
while(($gotcha = array_search($needle,$haystack)) > -1) |
|
| |
226 |
|
unset($haystack[$gotcha]); |
|
| |
227 |
|
} |
|
| |
228 |
|
|
|
| |
229 |
|
function TableCount($TableName, $where="",$JoinCats=1) |
|
| |
230 |
|
{ |
|
| |
231 |
|
$db = &GetADODBConnection(); |
|
| |
232 |
|
if(!$JoinCats) |
|
| |
233 |
|
{ |
|
| |
234 |
|
$sql = "SELECT count(*) as TableCount FROM $TableName"; |
|
| |
235 |
|
} |
|
| |
236 |
|
else |
|
| |
237 |
|
$sql = "SELECT count(*) as TableCount FROM $TableName INNER JOIN ".GetTablePrefix()."CategoryItems ON ".GetTablePrefix()."CategoryItems.ItemResourceId=$TableName.ResourceId"; |
|
| |
238 |
|
if(strlen($where)>0) |
|
| |
239 |
|
$sql .= " WHERE ".$where; |
|
| |
240 |
|
|
|
| |
241 |
|
$rs = $db->Execute($sql); |
|
| |
242 |
|
|
|
| |
243 |
|
|
|
| |
244 |
|
|
|
| |
245 |
|
$res = $rs->fields["TableCount"]; |
|
| |
246 |
|
return $res; |
|
| |
247 |
|
} |
|
| |
248 |
|
|
|
| |
249 |
|
Function QueryCount($sql) |
|
| |
250 |
|
{ |
|
| |
251 |
|
$sql = preg_replace('/SELECT(.*)FROM[ \n\r](.*)/is','SELECT COUNT(*) AS TableCount FROM $2', $sql); |
|
| |
252 |
|
$sql = preg_replace('/(.*)LIMIT(.*)/is','$1', $sql); |
|
| |
253 |
|
$sql = preg_replace('/(.*)ORDER BY(.*)/is','$1', $sql); |
|
| |
254 |
|
|
|
| |
255 |
|
|
|
| |
256 |
|
|
|
| |
257 |
|
$db =& GetADODBConnection(); |
|
| |
258 |
|
return $db->GetOne($sql); |
|
| |
259 |
|
} |
|
| |
260 |
|
|
|
| |
261 |
|
function GetPageCount($ItemsPerPage,$NumItems) |
|
| |
262 |
|
{ |
|
| |
263 |
|
if($ItemsPerPage==0 || $NumItems==0) |
|
| |
264 |
|
{ |
|
| |
265 |
|
return 1; |
|
| |
266 |
|
} |
|
| |
267 |
|
$value = $NumItems/$ItemsPerPage; |
|
| |
268 |
|
return ceil($value); |
|
| |
269 |
|
} |
|
| |
270 |
|
|
|
| |
271 |
|
|
|
| |
272 |
|
|
|
| |
273 |
|
|
|
| |
274 |
|
|
|
| |
275 |
|
|
|
| |
276 |
|
function GetTablePrefix() |
|
| |
277 |
|
{ |
|
| |
278 |
|
global $g_TablePrefix; |
|
| |
279 |
|
|
|
| |
280 |
|
return $g_TablePrefix; |
|
| |
281 |
|
} |
|
| |
282 |
|
|
|
| |
283 |
|
function TableHasPrefix($t) |
|
| |
284 |
|
{ |
|
| |
285 |
|
$pre = GetTablePrefix(); |
|
| |
286 |
|
|
|
| |
287 |
|
if(strlen($pre)>0) |
|
| |
288 |
|
{ |
|
| |
289 |
|
if(substr($t,0,strlen($pre))==$pre) |
|
| |
290 |
|
{ |
|
| |
291 |
|
return TRUE; |
|
| |
292 |
|
} |
|
| |
293 |
|
else |
|
| |
294 |
|
return FALSE; |
|
| |
295 |
|
} |
|
| |
296 |
|
else |
|
| |
297 |
|
return TRUE; |
|
| |
298 |
|
} |
|
| |
299 |
|
|
|
| |
300 |
|
function AddTablePrefix($t) |
|
| |
301 |
|
{ |
|
| |
302 |
|
if(!TableHasPrefix($t)) |
|
| |
303 |
|
$t = GetTablePrefix().$t; |
|
| |
304 |
|
|
|
| |
305 |
|
return $t; |
|
| |
306 |
|
} |
|
| |
307 |
|
|
|
| |
308 |
|
function ThisDomain() |
|
| |
309 |
|
{ |
|
| |
310 |
|
global $objConfig, $g_Domain; |
|
| |
311 |
|
|
|
| |
312 |
|
if($objConfig->Get("DomainDetect")) |
|
| |
313 |
|
{ |
|
| |
314 |
|
$d = $_SERVER['HTTP_HOST']; |
|
| |
315 |
|
} |
|
| |
316 |
|
else |
|
| |
317 |
|
$d = $g_Domain; |
|
| |
318 |
|
|
|
| |
319 |
|
return $d; |
|
| |
320 |
|
} |
|
| |
321 |
|
|
|
| |
322 |
|
function GetIndexUrl($secure=0) |
|
| |
323 |
|
{ |
|
| |
324 |
|
global $indexURL, $rootURL, $secureURL; |
|
| |
325 |
|
|
|
| |
326 |
|
if ( class_exists('kApplication') ) |
|
| |
327 |
|
{ |
|
| |
328 |
|
$application =& kApplication::Instance(); |
|
| |
329 |
|
return $application->BaseURL().'index.php'; |
|
| |
330 |
|
} |
|
| |
331 |
|
|
|
| |
332 |
|
switch($secure) |
|
| |
333 |
|
{ |
|
| |
334 |
|
case 0: |
|
| |
335 |
|
$ret = $indexURL; |
|
| |
336 |
|
break; |
|
| |
337 |
|
|
|
| |
338 |
|
case 1: |
|
| |
339 |
|
$ret = $secureURL."index.php"; |
|
| |
340 |
|
break; |
|
| |
341 |
|
|
|
| |
342 |
|
case 2: |
|
| |
343 |
|
$ret = $rootURL."index.php"; |
|
| |
344 |
|
break; |
|
| |
345 |
|
|
|
| |
346 |
|
default: |
|
| |
347 |
|
$ret = $i; |
|
| |
348 |
|
break; |
|
| |
349 |
|
} |
|
| |
350 |
|
return $ret; |
|
| |
351 |
|
} |
|
| |
352 |
|
|
|
| |
353 |
|
function GetLimitSQL($Page,$PerPage) |
|
| |
354 |
|
{ |
|
| |
355 |
|
if($Page<1) |
|
| |
356 |
|
$Page=1; |
|
| |
357 |
|
|
|
| |
358 |
|
if(is_numeric($PerPage)) |
|
| |
359 |
|
{ |
|
| |
360 |
|
if($PerPage==0) |
|
| |
361 |
|
$PerPage = 20; |
|
| |
362 |
|
$Start = ($Page-1)*$PerPage; |
|
| |
363 |
|
$limit = "LIMIT ".$Start.",".$PerPage; |
|
| |
364 |
|
} |
|
| |
365 |
|
else |
|
| |
366 |
|
$limit = NULL; |
|
| |
367 |
|
return $limit; |
|
| |
368 |
|
} |
|
| |
369 |
|
|
|
| |
370 |
|
function filelist ($currentdir, $startdir=NULL,$ext=NULL) |
|
| |
371 |
|
{ |
|
| |
372 |
|
global $pathchar; |
|
| |
373 |
|
|
|
| |
374 |
|
|
|
| |
375 |
|
|
|
| |
376 |
|
|
|
| |
377 |
|
if (!$startdir) |
|
| |
378 |
|
{ |
|
| |
379 |
|
$startdir = $currentdir; |
|
| |
380 |
|
} |
|
| |
381 |
|
|
|
| |
382 |
|
$d = @opendir($currentdir); |
|
| |
383 |
|
|
|
| |
384 |
|
$files = array(); |
|
| |
385 |
|
if(!$d) |
|
| |
386 |
|
return $files; |
|
| |
387 |
|
|
|
| |
388 |
|
while (false !== ($file = readdir($d))) |
|
| |
389 |
|
{ |
|
| |
390 |
|
if ($file != ".." && $file != ".") |
|
| |
391 |
|
{ |
|
| |
392 |
|
if (is_dir($currentdir."/".$file)) |
|
| |
393 |
|
{ |
|
| |
394 |
|
|
|
| |
395 |
|
$a = filelist ($currentdir."/".$file, $startdir,$ext); |
|
| |
396 |
|
if(is_array($a)) |
|
| |
397 |
|
$files = array_merge($files,$a); |
|
| |
398 |
|
} |
|
| |
399 |
|
else |
|
| |
400 |
|
{ |
|
| |
401 |
|
if($ext!=NULL) |
|
| |
402 |
|
{ |
|
| |
403 |
|
$extstr = stristr($file,".".$ext); |
|
| |
404 |
|
if(strlen($extstr)) |
|
| |
405 |
|
$files[] = $currentdir."/".$file; |
|
| |
406 |
|
} |
|
| |
407 |
|
else |
|
| |
408 |
|
$files[] = $currentdir.'/'.$file; |
|
| |
409 |
|
} |
|
| |
410 |
|
} |
|
| |
411 |
|
} |
|
| |
412 |
|
|
|
| |
413 |
|
closedir ($d); |
|
| |
414 |
|
|
|
| |
415 |
|
return $files; |
|
| |
416 |
|
} |
|
| |
417 |
|
|
|
| |
418 |
|
function DecimalToBin($dec,$WordLength=8) |
|
| |
419 |
|
{ |
|
| |
420 |
|
$bits = array(); |
|
| |
421 |
|
|
|
| |
422 |
|
$str = str_pad(decbin($dec),$WordLength,"0",STR_PAD_LEFT); |
|
| |
423 |
|
for($i=$WordLength;$i>0;$i--) |
|
| |
424 |
|
{ |
|
| |
425 |
|
$bits[$i-1] = (int)substr($str,$i-1,1); |
|
| |
426 |
|
} |
|
| |
427 |
|
return $bits; |
|
| |
428 |
|
} |
|
| |
429 |
|
|
|
| |
430 |
|
|
|
| |
431 |
|
|
|
| |
432 |
|
|
|
| |
433 |
|
|
|
| |
434 |
|
|
|
| |
435 |
|
|
|
| |
436 |
|
|
|
| |
437 |
|
|
|
| |
438 |
|
|
|
| |
439 |
|
|
|
| |
440 |
|
|
|
| |
441 |
|
|
|
| |
442 |
|
|
|
| |
443 |
|
|
|
| |
444 |
|
|
|
| |
445 |
|
|
|
| |
446 |
|
|
|
| |
447 |
|
|
|
| |
448 |
|
function inp_escape($var,$html=0) |
|
| |
449 |
|
{ |
|
| |
450 |
|
if($html)return $var; |
|
| |
451 |
|
if(is_array($var)) |
|
| |
452 |
|
foreach($var as $k=>$v) |
|
| |
453 |
|
$var[$k]=inp_escape($v); |
|
| |
454 |
|
else |
|
| |
455 |
|
|
|
| |
456 |
|
$var=strtr($var,Array('<'=>'<','>'=>'>',)); |
|
| |
457 |
|
return $var; |
|
| |
458 |
|
} |
|
| |
459 |
|
function inp_striptags($var,$html=0) |
|
| |
460 |
|
{ |
|
| |
461 |
|
if($html)return $var; |
|
| |
462 |
|
if(is_array($var)) |
|
| |
463 |
|
foreach($var as $k=>$v) |
|
| |
464 |
|
$var[$k]=inp_striptags($v); |
|
| |
465 |
|
else |
|
| |
466 |
|
$var=strip_tags($var); |
|
| |
467 |
|
return $var; |
|
| |
468 |
|
} |
|
| |
469 |
|
|
|
| |
470 |
|
function inp_unescape($in) |
|
| |
471 |
|
{ |
|
| |
472 |
|
|
|
| |
473 |
|
return $in; |
|
| |
474 |
|
$out=stripslashes($in); |
|
| |
475 |
|
return $out; |
|
| |
476 |
|
} |
|
| |
477 |
|
|
|
| |
478 |
|
function inp_textarea_unescape($in) |
|
| |
479 |
|
{ |
|
| |
480 |
|
|
|
| |
481 |
|
return $in; |
|
| |
482 |
|
$out=stripslashes($in); |
|
| |
483 |
|
$out = str_replace("\n<br />", "\n", $out); |
|
| |
484 |
|
return $out; |
|
| |
485 |
|
} |
|
| |
486 |
|
|
|
| |
487 |
|
function HighlightKeywords($Keywords, $html, $OpenTag="", $CloseTag="") |
|
| |
488 |
|
{ |
|
| |
489 |
|
global $objConfig; |
|
| |
490 |
|
|
|
| |
491 |
|
if(!strlen($OpenTag)) |
|
| |
492 |
|
$OpenTag = "<B>"; |
|
| |
493 |
|
if(!strlen($CloseTag)) |
|
| |
494 |
|
$CloseTag = "</B>"; |
|
| |
495 |
|
|
|
| |
496 |
|
$r = preg_split('((>)|(<))', $html, -1, PREG_SPLIT_DELIM_CAPTURE); |
|
| |
497 |
|
|
|
| |
498 |
|
foreach ($Keywords as $k) { |
|
| |
499 |
|
for ($i = 0; $i < count($r); $i++) { |
|
| |
500 |
|
if ($r[$i] == "<") { |
|
| |
501 |
|
$i++; continue; |
|
| |
502 |
|
} |
|
| |
503 |
|
$r[$i] = preg_replace("/($k)/i", "$OpenTag\\1$CloseTag", $r[$i]); |
|
| |
504 |
|
} |
|
| |
505 |
|
} |
|
| |
506 |
|
return join("", $r); |
|
| |
507 |
|
} |
|
| |
508 |
|
|
|
| |
509 |
|
|
|
| |
510 |
|
|
|
| |
511 |
|
|
|
| |
512 |
|
|
|
| |
513 |
|
|
|
| |
514 |
|
|
|
| |
515 |
|
|
|
| |
516 |
|
|
|
| |
517 |
|
|
|
| |
518 |
|
|
|
| |
519 |
|
|
|
| |
520 |
|
|
|
| |
521 |
|
|
|
| |
522 |
|
|
|
| |
523 |
|
|
|
| |
524 |
|
|
|
| |
525 |
|
|
|
| |
526 |
|
|
|
| |
527 |
|
|
|
| |
528 |
|
|
|
| |
529 |
|
|
|
| |
530 |
|
|
|
| |
531 |
|
|
|
| |
532 |
|
|
|
| |
533 |
|
|
|
| |
534 |
|
|
|
| |
535 |
|
|
|
| |
536 |
|
|
|
| |
537 |
|
function ExtractDatePart($part, $datestamp) |
|
| |
538 |
|
{ |
|
| |
539 |
|
if ($datestamp <= 0) return ''; |
|
| |
540 |
|
|
|
| |
541 |
|
$formats = Array( 'month' => 'm', 'day' => 'd', 'year' => 'Y', |
|
| |
542 |
|
'time_24hr' => 'H:i', 'time_12hr' => 'g:i a', 'time' => GetTimeFormat(), 'date' => GetDateFormat() ); |
|
| |
543 |
|
|
|
| |
544 |
|
$format = isset($formats[$part]) ? $formats[$part] : $part; |
|
| |
545 |
|
return adodb_date($format, $datestamp); |
|
| |
546 |
|
} |
|
| |
547 |
|
|
|
| |
548 |
|
function GetLocalTime($TimeStamp, $TargetZone = null) |
|
| |
549 |
|
{ |
|
| |
550 |
|
global $objConfig; |
|
| |
551 |
|
|
|
| |
552 |
|
if ($TargetZone == null) { |
|
| |
553 |
|
$TargetZone = $objConfig->Get('Config_Site_Time'); |
|
| |
554 |
|
} |
|
| |
555 |
|
|
|
| |
556 |
|
$server = $objConfig->Get('Config_Server_Time'); |
|
| |
557 |
|
if ($TargetZone != $server) { |
|
| |
558 |
|
$offset = ($server - $TargetZone) * -1; |
|
| |
559 |
|
$TimeStamp = $TimeStamp + (3600 * $offset); |
|
| |
560 |
|
} |
|
| |
561 |
|
|
|
| |
562 |
|
return $TimeStamp; |
|
| |
563 |
|
} |
|
| |
564 |
|
|
|
| |
565 |
|
function _unhtmlentities ($string) |
|
| |
566 |
|
{ |
|
| |
567 |
|
$trans_tbl = get_html_translation_table (HTML_ENTITIES); |
|
| |
568 |
|
$trans_tbl = array_flip ($trans_tbl); |
|
| |
569 |
|
return strtr ($string, $trans_tbl); |
|
| |
570 |
|
} |
|
| |
571 |
|
|
|
| |
572 |
|
function getLastStr($hay, $need){ |
|
| |
573 |
|
$getLastStr = 0; |
|
| |
574 |
|
$pos = strpos($hay, $need); |
|
| |
575 |
|
if (is_int ($pos)){ |
|
| |
576 |
|
while($pos) { |
|
| |
577 |
|
$getLastStr = $getLastStr + $pos + strlen($need); |
|
| |
578 |
|
$hay = substr ($hay , $pos + strlen($need)); |
|
| |
579 |
|
$pos = strpos($hay, $need); |
|
| |
580 |
|
} |
|
| |
581 |
|
return $getLastStr - strlen($need); |
|
| |
582 |
|
} else { |
|
| |
583 |
|
return -1; |
|
| |
584 |
|
} |
|
| |
585 |
|
} |
|
| |
586 |
|
|
|
| |
587 |
|
|
|
| |
588 |
|
function PreformatBBCodes($text) |
|
| |
589 |
|
{ |
|
| |
590 |
|
|
|
| |
591 |
|
|
|
| |
592 |
|
$text = preg_replace('/\[url=(.*)\](.*)\[\/url\]/Ui','[url href="$1"]$2[/url]',$text); |
|
| |
593 |
|
$text = preg_replace('/\[url\](.*)\[\/url\]/Ui','[url href="$1"]$1[/url]',$text); |
|
| |
594 |
|
|
|
| |
595 |
|
$text = preg_replace('/\[img\](.*)\[\/img\]/Ui','[img src="$1" border="0"][/img]',$text); |
|
| |
596 |
|
|
|
| |
597 |
|
$text = preg_replace('/\[color=(.*)\](.*)\[\/color\]/Ui','[font color="$1"]$2[/font]',$text); |
|
| |
598 |
|
|
|
| |
599 |
|
$text = preg_replace('/\[size=(.*)\](.*)\[\/size\]/Ui','[font size="$1"]$2[/font]',$text); |
|
| |
600 |
|
|
|
| |
601 |
|
$text = preg_replace('/\[list(.*)\](.*)\[\/list\]/Uis','[ul]$2[/ul]',$text); |
|
| |
602 |
|
|
|
| |
603 |
|
$text = preg_replace('/\[email\](.*)\[\/email\]/Ui','[url href="mailto:$1"]$1[/url]',$text); |
|
| |
604 |
|
|
|
| |
605 |
|
$text = preg_replace('/\[(b|i|u):(.*)\](.*)\[\/(b|i|u):(.*)\]/Ui','[$1]$3[/$4]',$text); |
|
| |
606 |
|
|
|
| |
607 |
|
$text = preg_replace('/\[code:(.*)\](.*)\[\/code:(.*)\]/Uis','[code]$2[/code]',$text); |
|
| |
608 |
|
return $text; |
|
| |
609 |
|
} |
|
| |
610 |
|
|
|
| |
611 |
|
|
|
| |
612 |
|
|
|
| |
613 |
|
|
|
| |
614 |
|
|
|
| |
615 |
|
|
|
| |
616 |
|
|
|
| |
617 |
|
|
|
| |
618 |
|
|
|
| |
619 |
|
function CheckBBCodeAttribs($BBCode, $TagParams, $TextInside, $ParamsAllowed) |
|
| |
620 |
|
{ |
|
| |
621 |
|
|
|
| |
622 |
|
|
|
| |
623 |
|
|
|
| |
624 |
|
$TagParams=str_replace('\"','"',$TagParams); |
|
| |
625 |
|
$TextInside=str_replace('\"','"',$TextInside); |
|
| |
626 |
|
if( $ParamsAllowed && preg_match_all('/ +([^=]*)=["\']?([^ "\']*)["\']?/is',$TagParams,$params,PREG_SET_ORDER) ) |
|
| |
627 |
|
{ |
|
| |
628 |
|
$ret = Array(); |
|
| |
629 |
|
foreach($params as $param) |
|
| |
630 |
|
{ |
|
| |
631 |
|
|
|
| |
632 |
|
$param[1] = strtolower(trim($param[1])); |
|
| |
633 |
|
if(($BBCode=='url')&&($param[1]=='href')) |
|
| |
634 |
|
if(false!==strpos(strtolower($param[2]),'script:')) |
|
| |
635 |
|
return $TextInside; |
|
| |
636 |
|
|
|
| |
637 |
|
if( isset($ParamsAllowed[ $param[1] ]) ) |
|
| |
638 |
|
$ret[] = $param[1].'="'.$param[2].'"'; |
|
| |
639 |
|
} |
|
| |
640 |
|
$ret = count($ret) ? ' '.implode(' ',$ret) : ''; |
|
| |
641 |
|
return '<'.$BBCode.$ret.'>'.$TextInside.'</'.$BBCode.'>'; |
|
| |
642 |
|
} |
|
| |
643 |
|
else |
|
| |
644 |
|
return '<'.$BBCode.'>'.$TextInside.'</'.$BBCode.'>'; |
|
| |
645 |
|
return false; |
|
| |
646 |
|
} |
|
| |
647 |
|
function ReplaceBBCode($text) |
|
| |
648 |
|
{ |
|
| |
649 |
|
global $objConfig; |
|
| |
650 |
|
|
|
| |
651 |
|
$text = PreformatBBCodes($text); |
|
| |
652 |
|
|
|
| |
653 |
|
|
|
| |
654 |
|
|
|
| |
655 |
|
$tags_defs = $objConfig->Get('BBTags'); |
|
| |
656 |
|
foreach(explode(';',$tags_defs) as $tag) |
|
| |
657 |
|
{ |
|
| |
658 |
|
$tag = explode(':',$tag); |
|
| |
659 |
|
$tag_name = $tag[0]; |
|
| |
660 |
|
$tag_params = $tag[1]?array_flip(explode('|',$tag[1])):0; |
|
| |
661 |
|
$text = preg_replace('/\['.$tag_name.'(.*)\](.*)\[\/'.$tag_name.' *\]/Uise','CheckBBCodeAttribs("'.$tag_name.'",\'$1\',\'$2\',$tag_params);', $text); |
|
| |
662 |
|
} |
|
| |
663 |
|
|
|
| |
664 |
|
|
|
| |
665 |
|
$text = preg_replace('/<url>(.*)<\/url>/Usi','<url href="$1">$1</url>',$text); |
|
| |
666 |
|
$text = preg_replace('/<font>(.*)<\/font>/Usi','$1',$text); |
|
| |
667 |
|
$text = str_replace( Array('<url','</url>','[*]'), |
|
| |
668 |
|
Array('<a target="_blank"','</a>','<li>'), |
|
| |
669 |
|
$text); |
|
| |
670 |
|
|
|
| |
671 |
|
|
|
| |
672 |
|
$text = preg_replace('/\[code\](.*)\[\/code\]/Uise', "ReplaceCodeBBCode('$1')", $text); |
|
| |
673 |
|
return $text; |
|
| |
674 |
|
} |
|
| |
675 |
|
function leadSpace2nbsp($x) |
|
| |
676 |
|
{ |
|
| |
677 |
|
return "\n".str_repeat(' ',strlen($x)); |
|
| |
678 |
|
} |
|
| |
679 |
|
function ReplaceCodeBBCode($input_string) |
|
| |
680 |
|
{ |
|
| |
681 |
|
$input_string=str_replace('\"','"',$input_string); |
|
| |
682 |
|
$input_string=$GLOBALS['objSmileys']->UndoSmileys(_unhtmlentities($input_string)); |
|
| |
683 |
|
$input_string=trim($input_string); |
|
| |
684 |
|
$input_string=inp_htmlize($input_string); |
|
| |
685 |
|
$input_string=str_replace("\r",'',$input_string); |
|
| |
686 |
|
$input_string = str_replace("\t", " ", $input_string); |
|
| |
687 |
|
$input_string = preg_replace('/\n( +)/se',"leadSpace2nbsp('$1')",$input_string); |
|
| |
688 |
|
$input_string='<div style="border:1px solid #888888;width:100%;background-color:#eeeeee;margin-top:6px;margin-bottom:6px"><div style="padding:10px;"><code>'.$input_string.'</code></div></div>'; |
|
| |
689 |
|
|
|
| |
690 |
|
return $input_string; |
|
| |
691 |
|
|
|
| |
692 |
|
if(false!==strpos($input_string,'<'.'?')) |
|
| |
693 |
|
{ |
|
| |
694 |
|
$input_string=str_replace('<'.'?','<'.'?php',$input_string); |
|
| |
695 |
|
$input_string=str_replace('<'.'?phpphp','<'.'?php',$input_string); |
|
| |
696 |
|
$input_string=@highlight_string($input_string,1); |
|
| |
697 |
|
} |
|
| |
698 |
|
else |
|
| |
699 |
|
{ |
|
| |
700 |
|
$input_string = @highlight_string('<'.'?php'.$input_string.'?'.'>',1); |
|
| |
701 |
|
$input_string = str_replace('<?php', '', str_replace('?>', '', $input_string)); |
|
| |
702 |
|
} |
|
| |
703 |
|
return str_replace('<br />','',$input_string); |
|
| |
704 |
|
|
|
| |
705 |
|
} |
|
| |
706 |
|
|
|
| |
707 |
|
|
|
| |
708 |
|
|
|
| |
709 |
|
|
|
| |
710 |
|
function GetMinValue($Table,$Field, $Where=NULL) |
|
| |
711 |
|
{ |
|
| |
712 |
|
$ret = 0; |
|
| |
713 |
|
$sql = "SELECT min($Field) as val FROM $Table "; |
|
| |
714 |
|
if(strlen($where)) |
|
| |
715 |
|
$sql .= "WHERE $Where"; |
|
| |
716 |
|
$ado = &GetADODBConnection(); |
|
| |
717 |
|
$rs = $ado->execute($sql); |
|
| |
718 |
|
if($rs) |
|
| |
719 |
|
$ret = (int)$rs->fields["val"]; |
|
| |
720 |
|
return $ret; |
|
| |
721 |
|
} |
|
| |
722 |
|
|
|
| |
723 |
|
|
|
| |
724 |
|
if (!function_exists( 'getmicrotime' ) ) { |
|
| |
725 |
|
function getmicrotime() |
|
| |
726 |
|
{ |
|
| |
727 |
|
list($usec, $sec) = explode(" ",microtime()); |
|
| |
728 |
|
return ((float)$usec + (float)$sec); |
|
| |
729 |
|
} |
|
| |
730 |
|
} |
|
| |
731 |
|
|
|
| |
732 |
|
function SetMissingDataErrors($f) |
|
| |
733 |
|
{ |
|
| |
734 |
|
global $FormError; |
|
| |
735 |
|
|
|
| |
736 |
|
$count = 0; |
|
| |
737 |
|
if(is_array($_POST)) |
|
| |
738 |
|
{ |
|
| |
739 |
|
if(is_array($_POST["required"])) |
|
| |
740 |
|
{ |
|
| |
741 |
|
foreach($_POST["required"] as $r) |
|
| |
742 |
|
{ |
|
| |
743 |
|
$found = FALSE; |
|
| |
744 |
|
if(is_array($_FILES)) |
|
| |
745 |
|
{ |
|
| |
746 |
|
if( isset($_FILES[$r]) && $_FILES[$r]['size'] > 0 ) $found = TRUE; |
|
| |
747 |
|
} |
|
| |
748 |
|
|
|
| |
749 |
|
if(!strlen(trim($_POST[$r])) && !$found) |
|
| |
750 |
|
{ |
|
| |
751 |
|
$count++; |
|
| |
752 |
|
|
|
| |
753 |
|
if (($r == "dob_day") || ($r == "dob_month") || ($r == "dob_year")) |
|
| |
754 |
|
$r = "dob"; |
|
| |
755 |
|
|
|
| |
756 |
|
$tag = isset($_POST["errors"]) ? $_POST["errors"][$r] : ''; |
|
| |
757 |
|
if(!strlen($tag)) |
|
| |
758 |
|
$tag = "lu_ferror_".$f."_".$r; |
|
| |
759 |
|
$FormError[$f][$r] = language($tag); |
|
| |
760 |
|
} |
|
| |
761 |
|
} |
|
| |
762 |
|
} |
|
| |
763 |
|
} |
|
| |
764 |
|
return $count; |
|
| |
765 |
|
} |
|
| |
766 |
|
|
|
| |
767 |
|
function makepassword($length=10) |
|
| |
768 |
|
{ |
|
| |
769 |
|
$pass_length=$length; |
|
| |
770 |
|
|
|
| |
771 |
|
$p1=array('b','c','d','f','g','h','j','k','l','m','n','p','q','r','s','t','v','w','x','y','z'); |
|
| |
772 |
|
$p2=array('a','e','i','o','u'); |
|
| |
773 |
|
$p3=array('1','2','3','4','5','6','7','8','9'); |
|
| |
774 |
|
$p4=array('(','&',')',';','%'); |
|
| |
775 |
|
|
|
| |
776 |
|
|
|
| |
777 |
|
|
|
| |
778 |
|
|
|
| |
779 |
|
$s1=21; |
|
| |
780 |
|
$s2=5; |
|
| |
781 |
|
$s3=9; |
|
| |
782 |
|
$s4=5; |
|
| |
783 |
|
|
|
| |
784 |
|
|
|
| |
785 |
|
|
|
| |
786 |
|
$c1='121'; |
|
| |
787 |
|
$c2='212'; |
|
| |
788 |
|
$c3='12'; |
|
| |
789 |
|
$c4='3'; |
|
| |
790 |
|
|
|
| |
791 |
|
|
|
| |
792 |
|
$comb='4'; |
|
| |
793 |
|
|
|
| |
794 |
|
|
|
| |
795 |
|
|
|
| |
796 |
|
for ($p=0;$p<$pass_length;) |
|
| |
797 |
|
{ |
|
| |
798 |
|
mt_srand((double)microtime()*1000000); |
|
| |
799 |
|
$strpart=mt_rand(1,$comb); |
|
| |
800 |
|
|
|
| |
801 |
|
if($strpart<>$previous) |
|
| |
802 |
|
{ |
|
| |
803 |
|
$pass_structure.=${'c'.$strpart}; |
|
| |
804 |
|
|
|
| |
805 |
|
|
|
| |
806 |
|
$p=$p+strlen(${'c'.$strpart}); |
|
| |
807 |
|
} |
|
| |
808 |
|
$previous=$strpart; |
|
| |
809 |
|
} |
|
| |
810 |
|
|
|
| |
811 |
|
|
|
| |
812 |
|
|
|
| |
813 |
|
for ($g=0;$g<strlen($pass_structure);$g++) |
|
| |
814 |
|
{ |
|
| |
815 |
|
mt_srand((double)microtime()*1000000); |
|
| |
816 |
|
$sel=substr($pass_structure,$g,1); |
|
| |
817 |
|
$pass.=${'p'.$sel}[mt_rand(0,-1+${'s'.$sel})]; |
|
| |
818 |
|
|
|
| |
819 |
|
} |
|
| |
820 |
|
return $pass; |
|
| |
821 |
|
} |
|
| |
822 |
|
|
|
| |
823 |
|
function LogEntry($text,$writefile=FALSE) |
|
| |
824 |
|
{ |
|
| |
825 |
|
global $g_LogFile,$LogFile, $LogData, $LogLevel, $timestart; |
|
| |
826 |
|
|
|
| |
827 |
|
static $last; |
|
| |
828 |
|
|
|
| |
829 |
|
if(strlen($g_LogFile)) |
|
| |
830 |
|
{ |
|
| |
831 |
|
$el = str_pad(getmicrotime()- $timestart,10," "); |
|
| |
832 |
|
if($last>0) |
|
| |
833 |
|
$elapsed = getmicrotime() - $last; |
|
| |
834 |
|
|
|
| |
835 |
|
if(strlen($el)>10) |
|
| |
836 |
|
$el = substr($el,0,10); |
|
| |
837 |
|
$indent = str_repeat(" ",$LogLevel); |
|
| |
838 |
|
$text = str_pad($text,$LogLevel,"==",STR_PAD_LEFT); |
|
| |
839 |
|
$LogData .= "$el:". round($elapsed,6).":$indent $text"; |
|
| |
840 |
|
$last = getmicrotime(); |
|
| |
841 |
|
if($writefile==TRUE && is_writable($g_LogFile)) |
|
| |
842 |
|
{ |
|
| |
843 |
|
if(!$LogFile) |
|
| |
844 |
|
{ |
|
| |
845 |
|
if(file_exists($g_LogFile)) |
|
| |
846 |
|
unlink($g_LogFile); |
|
| |
847 |
|
$LogFile=@fopen($g_LogFile,"w"); |
|
| |
848 |
|
} |
|
| |
849 |
|
if($LogFile) |
|
| |
850 |
|
{ |
|
| |
851 |
|
fputs($LogFile,$LogData); |
|
| |
852 |
|
} |
|
| |
853 |
|
} |
|
| |
854 |
|
} |
|
| |
855 |
|
} |
|
| |
856 |
|
|
|
| |
857 |
|
function ValidEmail($email) |
|
| |
858 |
|
{ |
|
| |
859 |
|
if (eregi("^[a-z0-9]+([-_\.]?[a-z0-9])+@[a-z0-9]+([-_\.]?[a-z0-9])+\.[a-z]{2,4}", $email)) |
|
| |
860 |
|
{ |
|
| |
861 |
|
return TRUE; |
|
| |
862 |
|
} |
|
| |
863 |
|
else |
|
| |
864 |
|
{ |
|
| |
865 |
|
return FALSE; |
|
| |
866 |
|
} |
|
| |
867 |
|
} |
|
| |
868 |
|
|
|
| |
869 |
|
function language($phrase,$LangId=0) |
|
| |
870 |
|
{ |
|
| |
871 |
|
global $objSession, $objLanguageCache, $objLanguages; |
|
| |
872 |
|
|
|
| |
873 |
|
if ($LangId == 0) { |
|
| |
874 |
|
$LangId = $objSession->Get('Language'); |
|
| |
875 |
|
} |
|
| |
876 |
|
|
|
| |
877 |
|
if ($LangId == 0) { |
|
| |
878 |
|
$LangId = $objLanguages->GetPrimary(); |
|
| |
879 |
|
} |
|
| |
880 |
|
|
|
| |
881 |
|
return $objLanguageCache->GetTranslation($phrase,$LangId); |
|
| |
882 |
|
} |
|
| |
883 |
|
|
|
| |
884 |
|
function admin_language($phrase,$lang=0,$LinkMissing=FALSE) |
|
| |
885 |
|
{ |
|
| |
886 |
|
global $objSession, $objLanguageCache, $objLanguages; |
|
| |
887 |
|
|
|
| |
888 |
|
|
|
| |
889 |
|
|
|
| |
890 |
|
if($lang==0) |
|
| |
891 |
|
$lang = $objSession->Get("Language"); |
|
| |
892 |
|
|
|
| |
893 |
|
|
|
| |
894 |
|
|
|
| |
895 |
|
if($lang==0) |
|
| |
896 |
|
$lang = $objLanguages->GetPrimary(); |
|
| |
897 |
|
|
|
| |
898 |
|
|
|
| |
899 |
|
|
|
| |
900 |
|
$translation = $objLanguageCache->GetTranslation($phrase,$lang); |
|
| |
901 |
|
if($LinkMissing && substr($translation,0,1)=="!" && substr($translation,-1)=="!") |
|
| |
902 |
|
{ |
|
| |
903 |
|
$res = "<A href=\"javascript:OpenPhraseEditor('&direct=1&label=$phrase'); \">$translation</A>"; |
|
| |
904 |
|
return $res; |
|
| |
905 |
|
} |
|
| |
906 |
|
else |
|
| |
907 |
|
return $translation; |
|
| |
908 |
|
} |
|
| |
909 |
|
|
|
| |
910 |
|
function prompt_language($phrase,$lang=0) |
|
| |
911 |
|
{ |
|
| |
912 |
|
return admin_language($phrase,$lang,TRUE); |
|
| |
913 |
|
} |
|
| |
914 |
|
|
|
| |
915 |
|
function GetPrimaryTranslation($Phrase) |
|
| |
916 |
|
{ |
|
| |
917 |
|
global $objLanguages; |
|
| |
918 |
|
|
|
| |
919 |
|
$l = $objLanguages->GetPrimary(); |
|
| |
920 |
|
return language($Phrase,$l); |
|
| |
921 |
|
} |
|
| |
922 |
|
|
|
| |
923 |
|
function CategoryNameCount($ParentId,$Name) |
|
| |
924 |
|
{ |
|
| |
925 |
|
$cat_table = GetTablePrefix()."Category"; |
|
| |
926 |
|
$sql = "SELECT Name from $cat_table WHERE ParentId=$ParentId AND "; |
|
| |
927 |
|
$sql .="(Name LIKE '".addslashes($Name)."' OR Name LIKE 'Copy of ".addslashes($Name)."' OR Name LIKE 'Copy % of ".addslashes($Name)."')"; |
|
| |
928 |
|
|
|
| |
929 |
|
$ado = &GetADODBConnection(); |
|
| |
930 |
|
$rs = $ado->Execute($sql); |
|
| |
931 |
|
$ret = array(); |
|
| |
932 |
|
while($rs && !$rs->EOF) |
|
| |
933 |
|
{ |
|
| |
934 |
|
$ret[] = $rs->fields["Name"]; |
|
| |
935 |
|
$rs->MoveNext(); |
|
| |
936 |
|
} |
|
| |
937 |
|
return $ret; |
|
| |
938 |
|
} |
|
| |
939 |
|
|
|
| |
940 |
|
function CategoryItemNameCount($CategoryId,$Table,$Field,$Name) |
|
| |
941 |
|
{ |
|
| |
942 |
|
$Name=addslashes($Name); |
|
| |
943 |
|
$cat_table = GetTablePrefix()."CategoryItems"; |
|
| |
944 |
|
$sql = "SELECT $Field FROM $Table INNER JOIN $cat_table ON ($Table.ResourceId=$cat_table.ItemResourceId) "; |
|
| |
945 |
|
$sql .=" WHERE ($Field LIKE 'Copy % of $Name' OR $Field LIKE '$Name' OR $Field LIKE 'Copy of $Name') AND CategoryId=$CategoryId"; |
|
| |
946 |
|
|
|
| |
947 |
|
$ado = &GetADODBConnection(); |
|
| |
948 |
|
$rs = $ado->Execute($sql); |
|
| |
949 |
|
$ret = array(); |
|
| |
950 |
|
while($rs && !$rs->EOF) |
|
| |
951 |
|
{ |
|
| |
952 |
|
$ret[] = $rs->fields[$Field]; |
|
| |
953 |
|
$rs->MoveNext(); |
|
| |
954 |
|
} |
|
| |
955 |
|
return $ret; |
|
| |
956 |
|
} |
|
| |
957 |
|
|
|
| |
958 |
|
function &GetItemCollection($ItemName) |
|
| |
959 |
|
{ |
|
| |
960 |
|
global $objItemTypes; |
|
| |
961 |
|
|
|
| |
962 |
|
if(is_numeric($ItemName)) |
|
| |
963 |
|
{ |
|
| |
964 |
|
$item = $objItemTypes->GetItem($ItemName); |
|
| |
965 |
|
} |
|
| |
966 |
|
else |
|
| |
967 |
|
$item = $objItemTypes->GetTypeByName($ItemName); |
|
| |
968 |
|
if(is_object($item)) |
|
| |
969 |
|
{ |
|
| |
970 |
|
$module = $item->Get("Module"); |
|
| |
971 |
|
$prefix = ModuleTagPrefix($module); |
|
| |
972 |
|
$func = $prefix."_ItemCollection"; |
|
| |
973 |
|
if(function_exists($func)) |
|
| |
974 |
|
{ |
|
| |
975 |
|
$var =& $func(); |
|
| |
976 |
|
} |
|
| |
977 |
|
} |
|
| |
978 |
|
return $var; |
|
| |
979 |
|
} |
|
| |
980 |
|
|
|
| |
981 |
|
|
|
| |
982 |
|
function UpdateCategoryCount($item_type,$CategoriesIds,$ListType='') |
|
| |
983 |
|
{ |
|
| |
984 |
|
global $objCountCache, $objItemTypes; |
|
| |
985 |
|
$db=&GetADODBConnection(); |
|
| |
986 |
|
if( !is_numeric($item_type) ) |
|
| |
987 |
|
{ |
|
| |
988 |
|
$sql = 'SELECT ItemType FROM '.$objItemTypes->SourceTable.' WHERE ItemName=\''.$item_type.'\''; |
|
| |
989 |
|
$item_type=$db->GetOne($sql); |
|
| |
990 |
|
} |
|
| |
991 |
|
$objCountCache->EraseGlobalTypeCache($item_type); |
|
| |
992 |
|
if($item_type) |
|
| |
993 |
|
{ |
|
| |
994 |
|
if(is_array($CategoriesIds)) |
|
| |
995 |
|
{ |
|
| |
996 |
|
$CategoriesIds=implode(',',$CategoriesIds); |
|
| |
997 |
|
} |
|
| |
998 |
|
if (!$CategoriesIds) |
|
| |
999 |
|
{ |
|
| |
1000 |
|
|
|
| |
1001 |
|
} |
|
| |
1002 |
|
|
|
| |
1003 |
|
if(!is_array($ListType)) $ListType=Array($ListType=>'opa'); |
|
| |
1004 |
|
|
|
| |
1005 |
|
$sql = 'SELECT ParentPath FROM '.GetTablePrefix().'Category WHERE CategoryId IN ('.$CategoriesIds.')'; |
|
| |
1006 |
|
$rs = $db->Execute($sql); |
|
| |
1007 |
|
$parents = Array(); |
|
| |
1008 |
|
while (!$rs->EOF) |
|
| |
1009 |
|
{ |
|
| |
1010 |
|
$tmp=$rs->fields['ParentPath']; |
|
| |
1011 |
|
$tmp=substr($tmp,1,strlen($tmp)-2); |
|
| |
1012 |
|
$tmp=explode('|',$tmp); |
|
| |
1013 |
|
foreach ($tmp as $tmp_cat_id) { |
|
| |
1014 |
|
$parents[$tmp_cat_id]=1; |
|
| |
1015 |
|
} |
|
| |
1016 |
|
$rs->MoveNext(); |
|
| |
1017 |
|
} |
|
| |
1018 |
|
$parents=array_keys($parents); |
|
| |
1019 |
|
$list_types=array_keys($ListType); |
|
| |
1020 |
|
foreach($parents as $ParentCategoryId) |
|
| |
1021 |
|
{ |
|
| |
1022 |
|
foreach ($list_types as $list_type) { |
|
| |
1023 |
|
$objCountCache->DeleteValue($list_type, $item_type, $ParentCategoryId, 0); |
|
| |
1024 |
|
$objCountCache->DeleteValue($list_type, $item_type, $ParentCategoryId, 1); |
|
| |
1025 |
|
} |
|
| |
1026 |
|
} |
|
| |
1027 |
|
} |
|
| |
1028 |
|
else |
|
| |
1029 |
|
{ |
|
| |
1030 |
|
die('wrong item type passed to "UpdateCategoryCount"'); |
|
| |
1031 |
|
} |
|
| |
1032 |
|
|
|
| |
1033 |
|
|
|
| |
1034 |
|
|
|
| |
1035 |
|
|
|
| |
1036 |
|
|
|
| |
1037 |
|
|
|
| |
1038 |
|
|
|
| |
1039 |
|
|
|
| |
1040 |
|
|
|
| |
1041 |
|
} |
|
| |
1042 |
|
|
|
| |
1043 |
|
function ResetCache($CategoryId) |
|
| |
1044 |
|
{ |
|
| |
1045 |
|
global $objCountCache; |
|
| |
1046 |
|
$db =& GetADODBConnection(); |
|
| |
1047 |
|
$sql = 'SELECT ParentPath FROM '.GetTablePrefix().'Category WHERE CategoryId = '.$CategoryId; |
|
| |
1048 |
|
$parents = $db->GetOne($sql); |
|
| |
1049 |
|
$parents = substr($parents,1,strlen($parents)-2); |
|
| |
1050 |
|
$parents = explode('|',$parents); |
|
| |
1051 |
|
foreach($parents as $ParentCategoryId) |
|
| |
1052 |
|
{ |
|
| |
1053 |
|
$objCountCache->DeleteValue('_', TYPE_TOPIC, $ParentCategoryId, 0); |
|
| |
1054 |
|
$objCountCache->DeleteValue('_', TYPE_TOPIC, $ParentCategoryId, 1); |
|
| |
1055 |
|
} |
|
| |
1056 |
|
} |
|
| |
1057 |
|
|
|
| |
1058 |
|
function UpdateModifiedCategoryCount($ItemTypeName,$CatId=NULL,$Modifier=0,$ExtraId=NULL) |
|
| |
1059 |
|
{ |
|
| |
1060 |
|
} |
|
| |
1061 |
|
|
|
| |
1062 |
|
function UpdateGroupCategoryCount($ItemTypeName,$CatId=NULL,$Modifier=0,$GroupId=NULL) |
|
| |
1063 |
|
{ |
|
| |
1064 |
|
} |
|
| |
1065 |
|
|
|
| |
1066 |
|
function GetTagCache($module,$tag,$attribs,$env) |
|
| |
1067 |
|
{ |
|
| |
1068 |
|
global $objSystemCache, $objSession, $objConfig; |
|
| |
1069 |
|
|
|
| |
1070 |
|
if($objConfig->Get("SystemTagCache") && !$objSession->Get('PortalUserId')) |
|
| |
1071 |
|
{ |
|
| |
1072 |
|
$name = $tag; |
|
| |
1073 |
|
if(is_array($attribs)) |
|
| |
1074 |
|
{ |
|
| |
1075 |
|
foreach($attribs as $n => $val) |
|
| |
1076 |
|
{ |
|
| |
1077 |
|
$name .= "-".$val; |
|
| |
1078 |
|
} |
|
| |
1079 |
|
} |
|
| |
1080 |
|
$CachedValue = $objSystemCache->GetContextValue($name,$module,$env, $objSession->Get("GroupList")); |
|
| |
1081 |
|
} |
|
| |
1082 |
|
else |
|
| |
1083 |
|
$CachedValue=""; |
|
| |
1084 |
|
return $CachedValue; |
|
| |
1085 |
|
} |
|
| |
1086 |
|
|
|
| |
1087 |
|
function SaveTagCache($module, $tag, $attribs, $env, $newvalue) |
|
| |
1088 |
|
{ |
|
| |
1089 |
|
global $objSystemCache, $objSession, $objConfig; |
|
| |
1090 |
|
|
|
| |
1091 |
|
if($objConfig->Get("SystemTagCache")) |
|
| |
1092 |
|
{ |
|
| |
1093 |
|
$name = $tag; |
|
| |
1094 |
|
if(is_array($attribs)) |
|
| |
1095 |
|
{ |
|
| |
1096 |
|
foreach($attribs as $a => $val) |
|
| |
1097 |
|
{ |
|
| |
1098 |
|
$name .= "-".$val; |
|
| |
1099 |
|
} |
|
| |
1100 |
|
} |
|
| |
1101 |
|
$objSystemCache->EditCacheItem($name,$newvalue,$module,0,$env,$objSession->Get("GroupList")); |
|
| |
1102 |
|
} |
|
| |
1103 |
|
} |
|
| |
1104 |
|
|
|
| |
1105 |
|
function DeleteTagCache($name,$extraparams, $env="") |
|
| |
1106 |
|
{ |
|
| |
1107 |
|
global $objSystemCache, $objConfig; |
|
| |
1108 |
|
|
|
| |
1109 |
|
if($objConfig->Get("SystemTagCache")) |
|
| |
1110 |
|
{ |
|
| |
1111 |
|
$where = "Name LIKE '$name%".$extraparams."'"; |
|
| |
1112 |
|
if(strlen($env)) |
|
| |
1113 |
|
$where .= " AND Context LIKE $env"; |
|
| |
1114 |
|
$objSystemCache->DeleteCachedItem($where); |
|
| |
1115 |
|
} |
|
| |
1116 |
|
} |
|
| |
1117 |
|
|
|
| |
1118 |
|
|
|
| |
1119 |
|
|
|
| |
1120 |
|
|
|
| |
1121 |
|
|
|
| |
1122 |
|
|
|
| |
1123 |
|
|
|
| |
1124 |
|
|
|
| |
1125 |
|
|
|
| |
1126 |
|
function DeleteModuleTagCache($module, $tagname='') |
|
| |
1127 |
|
{ |
|
| |
1128 |
|
global $objSystemCache, $objConfig; |
|
| |
1129 |
|
|
|
| |
1130 |
|
if($objConfig->Get("SystemTagCache")) |
|
| |
1131 |
|
{ |
|
| |
1132 |
|
$where = 'Module LIKE \''.$module.'\''; |
|
| |
1133 |
|
if(strlen($tagname)) |
|
| |
1134 |
|
{ |
|
| |
1135 |
|
$where .= ' AND Name LIKE \''.$tagname.'\''; |
|
| |
1136 |
|
} |
|
| |
1137 |
|
$objSystemCache->DeleteCachedItem($where); |
|
| |
1138 |
|
} |
|
| |
1139 |
|
} |
|
| |
1140 |
|
|
|
| |
1141 |
|
|
|
| |
1142 |
|
|
|
| |
1143 |
|
|
|
| |
1144 |
|
|
|
| |
1145 |
|
|
|
| |
1146 |
|
|
|
| |
1147 |
|
|
|
| |
1148 |
|
|
|
| |
1149 |
|
|
|
| |
1150 |
|
|
|
| |
1151 |
|
|
|
| |
1152 |
|
|
|
| |
1153 |
|
|
|
| |
1154 |
|
|
|
| |
1155 |
|
|
|
| |
1156 |
|
|
|
| |
1157 |
|
|
|
| |
1158 |
|
|
|
| |
1159 |
|
|
|
| |
1160 |
|
|
|
| |
1161 |
|
|
|
| |
1162 |
|
|
|
| |
1163 |
|
|
|
| |
1164 |
|
function ParseTagLibrary() |
|
| |
1165 |
|
{ |
|
| |
1166 |
|
$objTagList = new clsTagList(); |
|
| |
1167 |
|
$objTagList->ParseInportalTags(); |
|
| |
1168 |
|
unset($objTagList); |
|
| |
1169 |
|
} |
|
| |
1170 |
|
|
|
| |
1171 |
|
function GetDateFormat($LangId = 0, $is_input = false) |
|
| |
1172 |
|
{ |
|
| |
1173 |
|
global $objLanguages; |
|
| |
1174 |
|
|
|
| |
1175 |
|
if (!$LangId) { |
|
| |
1176 |
|
$LangId = $objLanguages->GetPrimary(); |
|
| |
1177 |
|
} |
|
| |
1178 |
|
|
|
| |
1179 |
|
$l = $objLanguages->GetItem($LangId); |
|
| |
1180 |
|
$fmt = is_object($l) ? $l->Get(($is_input ? 'Input' : '').'DateFormat') : 'm-d-Y'; |
|
| |
1181 |
|
|
|
| |
1182 |
|
if (getArrayValue($GLOBALS, 'FrontEnd')) { |
|
| |
1183 |
|
return $fmt; |
|
| |
1184 |
|
} |
|
| |
1185 |
|
return preg_replace('/y+/i','Y', $fmt); |
|
| |
1186 |
|
} |
|
| |
1187 |
|
|
|
| |
1188 |
|
function GetTimeFormat($LangId = 0, $is_input = false) |
|
| |
1189 |
|
{ |
|
| |
1190 |
|
global $objLanguages; |
|
| |
1191 |
|
|
|
| |
1192 |
|
if (!$LangId) { |
|
| |
1193 |
|
$LangId = $objLanguages->GetPrimary(); |
|
| |
1194 |
|
} |
|
| |
1195 |
|
$l = $objLanguages->GetItem($LangId); |
|
| |
1196 |
|
|
|
| |
1197 |
|
$fmt = is_object($l) ? $l->Get(($is_input ? 'Input' : '').'TimeFormat') : 'H:i:s'; |
|
| |
1198 |
|
return $fmt; |
|
| |
1199 |
|
} |
|
| |
1200 |
|
|
|
| |
1201 |
|
|
|
| |
1202 |
|
|
|
| |
1203 |
|
|
|
| |
1204 |
|
|
|
| |
1205 |
|
|
|
| |
1206 |
|
|
|
| |
1207 |
|
|
|
| |
1208 |
|
|
|
| |
1209 |
|
function GetRegionalOption($optionName,$LangId=0) |
|
| |
1210 |
|
{ |
|
| |
1211 |
|
global $objLanguages, $objSession; |
|
| |
1212 |
|
|
|
| |
1213 |
|
if(!$LangId) $LangId=$objSession->Get('Language'); |
|
| |
1214 |
|
if(!$LangId) $LangId=$objLanguages->GetPrimary(); |
|
| |
1215 |
|
$l = $objLanguages->GetItem($LangId); |
|
| |
1216 |
|
return is_object($l)?$l->Get($optionName):false; |
|
| |
1217 |
|
} |
|
| |
1218 |
|
|
|
| |
1219 |
|
|
|
| |
1220 |
|
|
|
| |
1221 |
|
|
|
| |
1222 |
|
|
|
| |
1223 |
|
|
|
| |
1224 |
|
|
|
| |
1225 |
|
|
|
| |
1226 |
|
|
|
| |
1227 |
|
function LangDate($TimeStamp = null, $LangId = 0, $is_input = false) |
|
| |
1228 |
|
{ |
|
| |
1229 |
|
$fmt = GetDateFormat($LangId, $is_input); |
|
| |
1230 |
|
return adodb_date($fmt, $TimeStamp); |
|
| |
1231 |
|
} |
|
| |
1232 |
|
|
|
| |
1233 |
|
|
|
| |
1234 |
|
|
|
| |
1235 |
|
|
|
| |
1236 |
|
|
|
| |
1237 |
|
|
|
| |
1238 |
|
|
|
| |
1239 |
|
|
|
| |
1240 |
|
|
|
| |
1241 |
|
function LangTime($TimeStamp = null, $LangId = 0, $is_input = false) |
|
| |
1242 |
|
{ |
|
| |
1243 |
|
$fmt = GetTimeFormat($LangId, $is_input); |
|
| |
1244 |
|
return adodb_date($fmt, $TimeStamp); |
|
| |
1245 |
|
} |
|
| |
1246 |
|
|
|
| |
1247 |
|
function LangNumber($Num,$DecPlaces=NULL,$LangId=0) |
|
| |
1248 |
|
{ |
|
| |
1249 |
|
global $objLanguages; |
|
| |
1250 |
|
|
|
| |
1251 |
|
if(!$LangId) |
|
| |
1252 |
|
$LangId= $objLanguages->GetPrimary(); |
|
| |
1253 |
|
$l = $objLanguages->GetItem($LangId); |
|
| |
1254 |
|
if(is_object($l)) |
|
| |
1255 |
|
{ |
|
| |
1256 |
|
$ret = number_format($Num,$DecPlaces,$l->Get("DecimalPoint"),$l->Get("ThousandSep")); |
|
| |
1257 |
|
} |
|
| |
1258 |
|
else |
|
| |
1259 |
|
$ret = $num; |
|
| |
1260 |
|
|
|
| |
1261 |
|
return $ret; |
|
| |
1262 |
|
} |
|
| |
1263 |
|
|
|
| |
1264 |
|
function replacePngTags($x, $spacer="images/spacer.gif") |
|
| |
1265 |
|
{ |
|
| |
1266 |
|
global $rootURL,$pathtoroot; |
|
| |
1267 |
|
|
|
| |
1268 |
|
|
|
| |
1269 |
|
|
|
| |
1270 |
|
$msie='/msie\s([5-9])\.?[0-9]*.*(win)/i'; |
|
| |
1271 |
|
$opera='/opera\s+[0-9]+/i'; |
|
| |
1272 |
|
if(!isset($_SERVER['HTTP_USER_AGENT']) || |
|
| |
1273 |
|
!preg_match($msie,$_SERVER['HTTP_USER_AGENT']) || |
|
| |
1274 |
|
preg_match($opera,$_SERVER['HTTP_USER_AGENT'])) |
|
| |
1275 |
|
return $x; |
|
| |
1276 |
|
|
|
| |
1277 |
|
|
|
| |
1278 |
|
preg_match_all('/background-image:\s*url\(\'(.*\.png)\'\);/Uis',$x,$background); |
|
| |
1279 |
|
for($i=0;$i<count($background[0]);$i++){ |
|
| |
1280 |
|
|
|
| |
1281 |
|
|
|
| |
1282 |
|
|
|
| |
1283 |
|
|
|
| |
1284 |
|
|
|
| |
1285 |
|
|
|
| |
1286 |
|
$x=str_replace($background[0][$i],'filter:progid:DXImageTransform.'. |
|
| |
1287 |
|
'Microsoft.AlphaImageLoader(enabled=true, sizingMethod=scale'. |
|
| |
1288 |
|
' src=\''.$background[1][$i].'\');',$x); |
|
| |
1289 |
|
} |
|
| |
1290 |
|
|
|
| |
1291 |
|
|
|
| |
1292 |
|
preg_match_all('/(<img.*\.png.*>|<input.*type=([\'"])image\\2.*\.png.*>)/Uis',$x,$images); |
|
| |
1293 |
|
while(list($imgnum,$v)=@each($images[0])){ |
|
| |
1294 |
|
$original=$v; |
|
| |
1295 |
|
$atts=''; $width=0; $height=0; |
|
| |
1296 |
|
|
|
| |
1297 |
|
preg_match_all('/style=".*(width: ([0-9]+))px.*'. |
|
| |
1298 |
|
'(height: ([0-9]+))px.*"/Ui',$v,$arr2); |
|
| |
1299 |
|
if(is_array($arr2) && count($arr2[0])){ |
|
| |
1300 |
|
|
|
| |
1301 |
|
$width=$arr2[2][0]; |
|
| |
1302 |
|
$height=$arr2[4][0]; |
|
| |
1303 |
|
} |
|
| |
1304 |
|
|
|
| |
1305 |
|
preg_match_all('/width=\"?([0-9]+)\"?/i',$v,$arr2); |
|
| |
1306 |
|
if(is_array($arr2) && count($arr2[0])){ |
|
| |
1307 |
|
$width=$arr2[1][0]; |
|
| |
1308 |
|
} |
|
| |
1309 |
|
preg_match_all('/height=\"?([0-9]+)\"?/i',$v,$arr2); |
|
| |
1310 |
|
if(is_array($arr2) && count($arr2[0])){ |
|
| |
1311 |
|
$height=$arr2[1][0]; |
|
| |
1312 |
|
} |
|
| |
1313 |
|
preg_match_all('/src=\"([^\"]+\.png)\"/i',$v,$arr2); |
|
| |
1314 |
|
if(isset($arr2[1][0]) && !empty($arr2[1][0])) |
|
| |
1315 |
|
$image=$arr2[1][0]; |
|
| |
1316 |
|
else |
|
| |
1317 |
|
$image=NULL; |
|
| |
1318 |
|
|
|
| |
1319 |
|
|
|
| |
1320 |
|
|
|
| |
1321 |
|
$tmp=split('[\\/]',$image); |
|
| |
1322 |
|
array_pop($tmp); |
|
| |
1323 |
|
$image_path=join('/',$tmp); |
|
| |
1324 |
|
if(substr($image,0,strlen($rootURL))==$rootURL) |
|
| |
1325 |
|
{ |
|
| |
1326 |
|
$path = str_replace($rootURL,$pathtoroot,$image); |
|
| |
1327 |
|
} |
|
| |
1328 |
|
else |
|
| |
1329 |
|
{ |
|
| |
1330 |
|
$path = $pathtoroot."themes/telestial/$image"; |
|
| |
1331 |
|
} |
|
| |
1332 |
|
|
|
| |
1333 |
|
|
|
| |
1334 |
|
|
|
| |
1335 |
|
|
|
| |
1336 |
|
|
|
| |
1337 |
|
$g = imagecreatefrompng($path); |
|
| |
1338 |
|
if($g) |
|
| |
1339 |
|
{ |
|
| |
1340 |
|
$height = imagesy($g); |
|
| |
1341 |
|
$width = imagesx($g); |
|
| |
1342 |
|
} |
|
| |
1343 |
|
|
|
| |
1344 |
|
if(strlen($image_path)) $image_path.='/'; |
|
| |
1345 |
|
|
|
| |
1346 |
|
|
|
| |
1347 |
|
$replace_src_with=$spacer.'" style="width: '.$width. |
|
| |
1348 |
|
'px; height: '.$height.'px; filter: progid:DXImageTransform.'. |
|
| |
1349 |
|
'Microsoft.AlphaImageLoader(src=\''.$image.'\', sizingMethod='. |
|
| |
1350 |
|
'\'scale\')'; |
|
| |
1351 |
|
|
|
| |
1352 |
|
|
|
| |
1353 |
|
$new_tag=str_replace($image,$replace_src_with,$original); |
|
| |
1354 |
|
|
|
| |
1355 |
|
|
|
| |
1356 |
|
$x=str_replace($original,$new_tag,$x); |
|
| |
1357 |
|
} |
|
| |
1358 |
|
return $x; |
|
| |
1359 |
|
} |
|
| |
1360 |
|
|
|
| |
1361 |
|
function GetOptions($field) |
|
| |
1362 |
|
{ |
|
| |
1363 |
|
|
|
| |
1364 |
|
$tmp =& new clsCustomField(); |
|
| |
1365 |
|
|
|
| |
1366 |
|
$tmp->LoadFromDatabase($field, 'FieldName'); |
|
| |
1367 |
|
$tmp_values = $tmp->Get('ValueList'); |
|
| |
1368 |
|
unset($tmp); |
|
| |
1369 |
|
$tmp_values = explode(',', $tmp_values); |
|
| |
1370 |
|
|
|
| |
1371 |
|
foreach($tmp_values as $mixed) |
|
| |
1372 |
|
{ |
|
| |
1373 |
|
$elem = explode('=', trim($mixed)); |
|
| |
1374 |
|
$ret[ $elem[0] ] = $elem[1]; |
|
| |
1375 |
|
} |
|
| |
1376 |
|
return $ret; |
|
| |
1377 |
|
} |
|
| |
1378 |
|
|
|
| |
1379 |
|
function ResetPage($module_prefix, $page_variable = 'p') |
|
| |
1380 |
|
{ |
|
| |
1381 |
|
|
|
| |
1382 |
|
global $objSession; |
|
| |
1383 |
|
if( !is_object($objSession) ) |
|
| |
1384 |
|
{ |
|
| |
1385 |
|
global $var_list, $SessionQueryString, $FrontEnd; |
|
| |
1386 |
|
$objSession = new clsUserSession($var_list["sid"],($SessionQueryString && $FrontEnd==1)); |
|
| |
1387 |
|
} |
|
| |
1388 |
|
|
|
| |
1389 |
|
$last_cat = $objSession->GetVariable('last_category'); |
|
| |
1390 |
|
$prev_cat = $objSession->GetVariable('prev_category'); |
|
| |
1391 |
|
|
|
| |
1392 |
|
|
|
| |
1393 |
|
if($prev_cat != $last_cat) $GLOBALS[$module_prefix.'_var_list'][$page_variable] = 1; |
|
| |
1394 |
|
} |
|
| |
1395 |
|
|
|
| |
1396 |
|
if( !function_exists('GetVar') ) |
|
| |
1397 |
|
{ |
|
| |
1398 |
|
|
|
| |
1399 |
|
|
|
| |
1400 |
|
|
|
| |
1401 |
|
|
|
| |
1402 |
|
|
|
| |
1403 |
|
|
|
| |
1404 |
|
function GetVar($name, $post_priority = false) |
|
| |
1405 |
|
{ |
|
| |
1406 |
|
if(!$post_priority) |
|
| |
1407 |
|
return isset($_REQUEST[$name]) ? $_REQUEST[$name] : false; |
|
| |
1408 |
|
else |
|
| |
1409 |
|
return isset($_POST[$name]) && $_POST[$name] !== false ? $_POST[$name] : ( isset($_GET[$name]) && $_GET[$name] ? $_GET[$name] : false ); |
|
| |
1410 |
|
} |
|
| |
1411 |
|
} |
|
| |
1412 |
|
|
|
| |
1413 |
|
function SetVar($VarName, $VarValue) |
|
| |
1414 |
|
{ |
|
| |
1415 |
|
$_REQUEST[$VarName] = $VarValue; |
|
| |
1416 |
|
$_POST[$VarName] = $VarValue; |
|
| |
1417 |
|
$_GET[$VarName] = $VarValue; |
|
| |
1418 |
|
} |
|
| |
1419 |
|
|
|
| |
1420 |
|
function PassVar(&$source) |
|
| |
1421 |
|
{ |
|
| |
1422 |
|
|
|
| |
1423 |
|
$params = func_get_args(); |
|
| |
1424 |
|
array_shift($params); |
|
| |
1425 |
|
|
|
| |
1426 |
|
if( count($params) ) |
|
| |
1427 |
|
{ |
|
| |
1428 |
|
$ret = Array(); |
|
| |
1429 |
|
foreach($params as $var_name) |
|
| |
1430 |
|
if( isset($source[$var_name]) ) |
|
| |
1431 |
|
$ret[] = $var_name.'='.$source[$var_name]; |
|
| |
1432 |
|
$ret = '&'.implode('&', $ret); |
|
| |
1433 |
|
} |
|
| |
1434 |
|
return $ret; |
|
| |
1435 |
|
} |
|
| |
1436 |
|
|
|
| |
1437 |
|
function GetSubmitVariable(&$array, $postfix) |
|
| |
1438 |
|
{ |
|
| |
1439 |
|
|
|
| |
1440 |
|
|
|
| |
1441 |
|
|
|
| |
1442 |
|
|
|
| |
1443 |
|
|
|
| |
1444 |
|
$modules = Array('In-Link' => 'Link', 'In-News' => 'News', 'In-Bulletin' => 'Topic', 'In-Portal'=>'Review'); |
|
| |
1445 |
|
foreach($modules as $module => $prefix) |
|
| |
1446 |
|
if( isset($array[$prefix.$postfix]) ) |
|
| |
1447 |
|
return Array('Module' => $module, 'variable' => $array[$prefix.$postfix]); |
|
| |
1448 |
|
return false; |
|
| |
1449 |
|
} |
|
| |
1450 |
|
|
|
| |
1451 |
|
function GetModuleByAction() |
|
| |
1452 |
|
{ |
|
| |
1453 |
|
$prefix2module = Array('m' => 'In-Portal', 'l' => 'In-Link', 'n' => 'In-News', 'bb' => 'In-Bulletin'); |
|
| |
1454 |
|
$action = GetVar('Action'); |
|
| |
1455 |
|
if($action) |
|
| |
1456 |
|
{ |
|
| |
1457 |
|
$module_prefix = explode('_', $action); |
|
| |
1458 |
|
return $prefix2module[ $module_prefix[0] ]; |
|
| |
1459 |
|
} |
|
| |
1460 |
|
else |
|
| |
1461 |
|
return false; |
|
| |
1462 |
|
} |
|
| |
1463 |
|
|
|
| |
1464 |
|
function dir_size($dir) { |
|
| |
1465 |
|
|
|
| |
1466 |
|
$totalsize=0; |
|
| |
1467 |
|
if ($dirstream = @opendir($dir)) { |
|
| |
1468 |
|
while (false !== ($filename = readdir($dirstream))) { |
|
| |
1469 |
|
if ($filename!="." && $filename!="..") |
|
| |
1470 |
|
{ |
|
| |
1471 |
|
if (is_file($dir."/".$filename)) |
|
| |
1472 |
|
$totalsize+=filesize($dir."/".$filename); |
|
| |
1473 |
|
|
|
| |
1474 |
|
if (is_dir($dir."/".$filename)) |
|
| |
1475 |
|
$totalsize+=dir_size($dir."/".$filename); |
|
| |
1476 |
|
} |
|
| |
1477 |
|
} |
|
| |
1478 |
|
} |
|
| |
1479 |
|
closedir($dirstream); |
|
| |
1480 |
|
return $totalsize; |
|
| |
1481 |
|
} |
|
| |
1482 |
|
|
|
| |
1483 |
|
function size($bytes) { |
|
| |
1484 |
|
|
|
| |
1485 |
|
$types = Array("la_bytes","la_kilobytes","la_megabytes","la_gigabytes","la_terabytes"); |
|
| |
1486 |
|
$current = 0; |
|
| |
1487 |
|
while ($bytes > 1024) { |
|
| |
1488 |
|
$current++; |
|
| |
1489 |
|
$bytes /= 1024; |
|
| |
1490 |
|
} |
|
| |
1491 |
|
return round($bytes,2)." ".language($types[$current]); |
|
| |
1492 |
|
} |
|
| |
1493 |
|
|
|
| |
1494 |
|
function echod($str) |
|
| |
1495 |
|
{ |
|
| |
1496 |
|
|
|
| |
1497 |
|
echo str_replace( Array('[',']'), Array('[<b>', '</b>]'), $str).'<br>'; |
|
| |
1498 |
|
} |
|
| |
1499 |
|
|
|
| |
1500 |
|
|
|
| |
1501 |
|
function PrepareParams($source, $to_lower, $mapping) |
|
| |
1502 |
|
{ |
|
| |
1503 |
|
|
|
| |
1504 |
|
$result = Array(); |
|
| |
1505 |
|
foreach($to_lower as $field) |
|
| |
1506 |
|
$result[ $field ] = $source[ strtolower($field) ]; |
|
| |
1507 |
|
|
|
| |
1508 |
|
if( is_array($mapping) ) |
|
| |
1509 |
|
{ |
|
| |
1510 |
|
foreach($mapping as $field_from => $field_to) |
|
| |
1511 |
|
$result[$field_to] = $source[$field_from]; |
|
| |
1512 |
|
} |
|
| |
1513 |
|
|
|
| |
1514 |
|
return $result; |
|
| |
1515 |
|
} |
|
| |
1516 |
|
|
|
| |
1517 |
|
function GetELT($field, $phrases = Array()) |
|
| |
1518 |
|
{ |
|
| |
1519 |
|
|
|
| |
1520 |
|
$ret = Array(); |
|
| |
1521 |
|
foreach($phrases as $phrase) |
|
| |
1522 |
|
$ret[] = admin_language($phrase); |
|
| |
1523 |
|
$ret = "'".implode("','", $ret)."'"; |
|
| |
1524 |
|
return 'ELT('.$field.','.$ret.')'; |
|
| |
1525 |
|
} |
|
| |
1526 |
|
|
|
| |
1527 |
|
function GetModuleImgPath($module) |
|
| |
1528 |
|
{ |
|
| |
1529 |
|
global $rootURL, $admin; |
|
| |
1530 |
|
return $rootURL.$module.'/'.$admin.'/images'; |
|
| |
1531 |
|
} |
|
| |
1532 |
|
|
|
| |
1533 |
|
function ActionPostProcess($StatusField, $ListClass, $ListObjectName = '', $IDField = null) |
|
| |
1534 |
|
{ |
|
| |
1535 |
|
|
|
| |
1536 |
|
if( !isset($_REQUEST[$StatusField]) ) return false; |
|
| |
1537 |
|
|
|
| |
1538 |
|
$list =& $GLOBALS[$ListObjectName]; |
|
| |
1539 |
|
if( !is_object($list) ) $list = new $ListClass(); |
|
| |
1540 |
|
$SFValue = $_REQUEST[$StatusField]; |
|
| |
1541 |
|
switch($SFValue) |
|
| |
1542 |
|
{ |
|
| |
1543 |
|
case 1: |
|
| |
1544 |
|
$list->CopyFromEditTable($IDField); |
|
| |
1545 |
|
break; |
|
| |
1546 |
|
case 2: |
|
| |
1547 |
|
$list->PurgeEditTable($IDField); |
|
| |
1548 |
|
break; |
|
| |
1549 |
|
} |
|
| |
1550 |
|
if( function_exists('SpecificProcessing') ) SpecificProcessing($StatusField, $SFValue); |
|
| |
1551 |
|
if($SFValue == 1 || $SFValue == 2) $list->Clear(); |
|
| |
1552 |
|
} |
|
| |
1553 |
|
|
|
| |
1554 |
|
function MakeHTMLTag($element, $attrib_prefix) |
|
| |
1555 |
|
{ |
|
| |
1556 |
|
$result = Array(); |
|
| |
1557 |
|
$ap_length = strlen($attrib_prefix); |
|
| |
1558 |
|
foreach($element->attributes as $attib_name => $attr_value) |
|
| |
1559 |
|
if( substr($attib_name, $ap_length) == $ap_length ) |
|
| |
1560 |
|
$result[] = substr($attib_name, $ap_length, strlen($attib_name)).'="'.$attr_value.'"'; |
|
| |
1561 |
|
return count($result) ? implode(' ', $result) : false; |
|
| |
1562 |
|
} |
|
| |
1563 |
|
|
|
| |
1564 |
|
function GetImportScripts() |
|
| |
1565 |
|
{ |
|
| |
1566 |
|
|
|
| |
1567 |
|
static $import_scripts = Array(); |
|
| |
1568 |
|
if( count($import_scripts) == 0 ) |
|
| |
1569 |
|
{ |
|
| |
1570 |
|
|
|
| |
1571 |
|
$sql = 'SELECT imp.* , m.LoadOrder |
|
| |
1572 |
|
FROM '.TABLE_PREFIX.'ImportScripts imp |
|
| |
1573 |
|
LEFT JOIN '.TABLE_PREFIX.'Modules m ON m.Name = imp.is_Module |
|
| |
1574 |
|
ORDER BY m.LoadOrder'; |
|
| |
1575 |
|
|
|
| |
1576 |
|
$db =& GetADODBConnection(); |
|
| |
1577 |
|
$rs = $db->Execute($sql); |
|
| |
1578 |
|
if ($rs && $rs->RecordCount() > 0) { |
|
| |
1579 |
|
while (!$rs->EOF) { |
|
| |
1580 |
|
$rec =& $rs->fields; |
|
| |
1581 |
|
$import_scripts[ $rec['is_id'] ] = Array( 'label' => $rec['is_label'], 'url' => $rec['is_script'], |
|
| |
1582 |
|
'enabled' => $rec['is_enabled'], 'field_prefix' => $rec['is_field_prefix'], |
|
| |
1583 |
|
'id' => $rec['is_string_id'], 'required_fields' => $rec['is_requred_fields'], |
|
| |
1584 |
|
'module' => strtolower($rec['is_Module']) ); |
|
| |
1585 |
|
$rs->MoveNext(); |
|
| |
1586 |
|
} |
|
| |
1587 |
|
} |
|
| |
1588 |
|
else { |
|
| |
1589 |
|
$import_scripts = Array(); |
|
| |
1590 |
|
} |
|
| |
1591 |
|
} |
|
| |
1592 |
|
return $import_scripts; |
|
| |
1593 |
|
} |
|
| |
1594 |
|
|
|
| |
1595 |
|
function GetImportScript($id) |
|
| |
1596 |
|
{ |
|
| |
1597 |
|
$scripts = GetImportScripts(); |
|
| |
1598 |
|
return isset($scripts[$id]) ? $scripts[$id] : false; |
|
| |
1599 |
|
} |
|
| |
1600 |
|
function GetNextTemplate($current_template) |
|
| |
1601 |
|
{ |
|
| |
1602 |
|
|
|
| |
1603 |
|
|
|
| |
1604 |
|
$dest = GetVar('dest', true); |
|
| |
1605 |
|
if(!$dest) $dest = GetVar('DestTemplate', true); |
|
| |
1606 |
|
return $dest ? $dest : $current_template; |
|
| |
1607 |
|
} |
|
| |
1608 |
|
|
|
| |
1609 |
|
|
|
| |
1610 |
|
|
|
| |
1611 |
|
function GenerateModuleEnv($prefix, $var_list) |
|
| |
1612 |
|
{ |
|
| |
1613 |
|
|
|
| |
1614 |
|
$main =& $GLOBALS[$prefix.'_var_list']; |
|
| |
1615 |
|
$update =& $GLOBALS[$prefix.'_var_list_update']; |
|
| |
1616 |
|
|
|
| |
1617 |
|
|
|
| |
1618 |
|
|
|
| |
1619 |
|
if( !is_array($update) || count($update) == 0 ) return ''; |
|
| |
1620 |
|
|
|
| |
1621 |
|
|
|
| |
1622 |
|
foreach($update as $vl_key => $vl_value) { |
|
| |
1623 |
|
if(!$vl_value) $update[$vl_key] = '0'; |
|
| |
1624 |
|
} |
|
| |
1625 |
|
|
|
| |
1626 |
|
foreach($main as $vl_key => $vl_value) { |
|
| |
1627 |
|
if(!$vl_value) $main[$vl_key] = '0'; |
|
| |
1628 |
|
} |
|
| |
1629 |
|
|
|
| |
1630 |
|
$ret = Array(); |
|
| |
1631 |
|
foreach($var_list as $var_name) { |
|
| |
1632 |
|
$value = GetEnvVar($prefix, $var_name); |
|
| |
1633 |
|
if(!$value && $var_name == 'id') $value = '0'; |
|
| |
1634 |
|
$ret[] = $value; |
|
| |
1635 |
|
} |
|
| |
1636 |
|
|
|
| |
1637 |
|
|
|
| |
1638 |
|
$keys = array_keys($update); |
|
| |
1639 |
|
foreach ($keys as $key) { |
|
| |
1640 |
|
unset($update[$key]); |
|
| |
1641 |
|
} |
|
| |
1642 |
|
|
|
| |
1643 |
|
return ':'.$prefix.implode('-',$ret); |
|
| |
1644 |
|
} |
|
| |
1645 |
|
|
|
| |
1646 |
|
|
|
| |
1647 |
|
function GenerateModuleEnv_NEW($prefix, $var_list) |
|
| |
1648 |
|
{ |
|
| |
1649 |
|
|
|
| |
1650 |
|
$main =& $GLOBALS[$prefix.'_var_list']; |
|
| |
1651 |
|
$update =& $GLOBALS[$prefix.'_var_list_update']; |
|
| |
1652 |
|
|
|
| |
1653 |
|
|
|
| |
1654 |
|
if ( isset($update) && $update ) |
|
| |
1655 |
|
{ |
|
| |
1656 |
|
|
|
| |
1657 |
|
foreach($update as $vl_key => $vl_value) { |
|
| |
1658 |
|
if(!$vl_value) $update[$vl_key] = '0'; |
|
| |
1659 |
|
} |
|
| |
1660 |
|
|
|
| |
1661 |
|
$app =& kApplication::Instance(); |
|
| |
1662 |
|
$passed = $app->GetVar('prefixes_passed'); |
|
| |
1663 |
|
$passed[] = $prefix; |
|
| |
1664 |
|
$app->SetVar('prefixes_passed', $passed); |
|
| |
1665 |
|
} |
|
| |
1666 |
|
else |
|
| |
1667 |
|
{ |
|
| |
1668 |
|
return Array(); |
|
| |
1669 |
|
} |
|
| |
1670 |
|
|
|
| |
1671 |
|
if ($main) { |
|
| |
1672 |
|
foreach($main as $vl_key => $vl_value) { |
|
| |
1673 |
|
if(!$vl_value) $main[$vl_key] = '0'; |
|
| |
1674 |
|
} |
|
| |
1675 |
|
} |
|
| |
1676 |
|
|
|
| |
1677 |
|
$ret = Array(); |
|
| |
1678 |
|
foreach($var_list as $src_name => $dst_name) { |
|
| |
1679 |
|
$ret[$dst_name] = GetEnvVar($prefix, $src_name); |
|
| |
1680 |
|
} |
|
| |
1681 |
|
|
|
| |
1682 |
|
|
|
| |
1683 |
|
if ( isset($update) && $update ) |
|
| |
1684 |
|
{ |
|
| |
1685 |
|
$keys = array_keys($update); |
|
| |
1686 |
|
foreach ($keys as $key) unset($update[$key]); |
|
| |
1687 |
|
} |
|
| |
1688 |
|
return $ret; |
|
| |
1689 |
|
} |
|
| |
1690 |
|
|
|
| |
1691 |
|
function GetEnvVar($prefix, $name) |
|
| |
1692 |
|
{ |
|
| |
1693 |
|
|
|
| |
1694 |
|
|
|
| |
1695 |
|
$main =& $GLOBALS[$prefix.'_var_list']; |
|
| |
1696 |
|
$update =& $GLOBALS[$prefix.'_var_list_update']; |
|
| |
1697 |
|
|
|
| |
1698 |
|
return isset($update[$name]) ? $update[$name] : ( isset($main[$name]) ? $main[$name] : ''); |
|
| |
1699 |
|
} |
|
| |
1700 |
|
|
|
| |
1701 |
|
|
|
| |
1702 |
|
|
|
| |
1703 |
|
|
|
| |
1704 |
|
|
|
| |
1705 |
|
|
|
| |
1706 |
|
function IsDebugMode($check_debugger = true) |
|
| |
1707 |
|
{ |
|
| |
1708 |
|
$application =& kApplication::Instance(); |
|
| |
1709 |
|
return $application->isDebugMode($check_debugger); |
|
| |
1710 |
|
} |
|
| |
1711 |
|
|
|
| |
1712 |
|
|
|
| |
1713 |
|
|
|
| |
1714 |
|
|
|
| |
1715 |
|
|
|
| |
1716 |
|
|
|
| |
1717 |
|
function IsAdmin() |
|
| |
1718 |
|
{ |
|
| |
1719 |
|
$application =& kApplication::Instance(); |
|
| |
1720 |
|
return $application->IsAdmin(); |
|
| |
1721 |
|
} |
|
| |
1722 |
|
|
|
| |
1723 |
|
|
|
| |
1724 |
|
|
|
| |
1725 |
|
|
|
| |
1726 |
|
|
|
| |
1727 |
|
|
|
| |
1728 |
|
|
|
| |
1729 |
|
|
|
| |
1730 |
|
|
|
| |
1731 |
|
|
|
| |
1732 |
|
|
|
| |
1733 |
|
function stricmp ($string1, $string2) { |
|
| |
1734 |
|
return strcmp(strtolower($string1), strtolower($string2)); |
|
| |
1735 |
|
} |
|
| |
1736 |
|
|
|
| |
1737 |
|
|
|
| |
1738 |
|
|
|
| |
1739 |
|
|
|
| |
1740 |
|
|
|
| |
1741 |
|
|
|
| |
1742 |
|
function GenerateCode() |
|
| |
1743 |
|
{ |
|
| |
1744 |
|
list($usec, $sec) = explode(" ",microtime()); |
|
| |
1745 |
|
|
|
| |
1746 |
|
$id_part_1 = substr($usec, 4, 4); |
|
| |
1747 |
|
$id_part_2 = mt_rand(1,9); |
|
| |
1748 |
|
$id_part_3 = substr($sec, 6, 4); |
|
| |
1749 |
|
$digit_one = substr($id_part_1, 0, 1); |
|
| |
1750 |
|
if ($digit_one == 0) { |
|
| |
1751 |
|
$digit_one = mt_rand(1,9); |
|
| |
1752 |
|
$id_part_1 = ereg_replace("^0","",$id_part_1); |
|
| |
1753 |
|
$id_part_1=$digit_one.$id_part_1; |
|
| |
1754 |
|
} |
|
| |
1755 |
|
return $id_part_1.$id_part_2.$id_part_3; |
|
| |
1756 |
|
} |
|
| |
1757 |
|
|
|
| |
1758 |
|
function bracket_comp($elem1, $elem2) |
|
| |
1759 |
|
{ |
|
| |
1760 |
|
if( ($elem1['End']>$elem2['End'] || $elem1['End'] == -1) && $elem2['End'] != -1 ) |
|
| |
1761 |
|
{ |
|
| |
1762 |
|
return 1; |
|
| |
1763 |
|
} |
|
| |
1764 |
|
elseif ( ($elem1['End']<$elem2['End'] || $elem2['End'] == -1) && $elem1['End'] != -1 ) |
|
| |
1765 |
|
{ |
|
| |
1766 |
|
return -1; |
|
| |
1767 |
|
} |
|
| |
1768 |
|
else |
|
| |
1769 |
|
{ |
|
| |
1770 |
|
return 0; |
|
| |
1771 |
|
} |
|
| |
1772 |
|
} |
|
| |
1773 |
|
|
|
| |
1774 |
|
function bracket_id_sort($first_id, $second_id) |
|
| |
1775 |
|
{ |
|
| |
1776 |
|
$first_abs = abs($first_id); |
|
| |
1777 |
|
$second_abs = abs($second_id); |
|
| |
1778 |
|
$first_sign = ($first_id == 0) ? 0 : $first_id / $first_abs; |
|
| |
1779 |
|
$second_sign = ($second_id == 0) ? 0 : $second_id / $second_abs; |
|
| |
1780 |
|
if($first_sign != $second_sign) |
|
| |
1781 |
|
{ |
|
| |
1782 |
|
if($first_id > $second_id) { |
|
| |
1783 |
|
$bigger =& $first_abs; |
|
| |
1784 |
|
$smaller =& $second_abs; |
|
| |
1785 |
|
} |
|
| |
1786 |
|
else { |
|
| |
1787 |
|
$bigger =& $second_abs; |
|
| |
1788 |
|
$smaller =& $first_abs; |
|
| |
1789 |
|
} |
|
| |
1790 |
|
$smaller = $bigger + $smaller; |
|
| |
1791 |
|
} |
|
| |
1792 |
|
|
|
| |
1793 |
|
if($first_abs > $second_abs) { |
|
| |
1794 |
|
return 1; |
|
| |
1795 |
|
} |
|
| |
1796 |
|
elseif ($first_abs < $second_abs) |
|
| |
1797 |
|
{ |
|
| |
1798 |
|
return -1; |
|
| |
1799 |
|
} |
|
| |
1800 |
|
else |
|
| |
1801 |
|
{ |
|
| |
1802 |
|
return 0; |
|
| |
1803 |
|
} |
|
| |
1804 |
|
} |
|
| |
1805 |
|
|
|
| |
1806 |
|
function pr_bracket_comp($elem1, $elem2) |
|
| |
1807 |
|
{ |
|
| |
1808 |
|
|
|
| |
1809 |
|
if ($elem1['MinQty']!="" && $elem1['MaxQty']=="" && $elem2['MinQty']!="" && $elem2['MaxQty']!="") return 1; |
|
| |
1810 |
|
if ($elem1['MinQty']!="" && $elem1['MaxQty']=="" && $elem2['MinQty']=="" && $elem2['MaxQty']=="") return -1; |
|
| |
1811 |
|
|
|
| |
1812 |
|
|
|
| |
1813 |
|
if ($elem1['MaxQty']=="" && $elem2['MaxQty']!="") return 1; |
|
| |
1814 |
|
if ($elem1['MaxQty']!="" && $elem2['MaxQty']=="") return -1; |
|
| |
1815 |
|
|
|
| |
1816 |
|
|
|
| |
1817 |
|
if( ($elem1['MaxQty']>$elem2['MaxQty'] && $elem2['MaxQty']!=-1) || ($elem1['MaxQty'] == -1 && $elem2['MaxQty'] != -1 )) |
|
| |
1818 |
|
{ |
|
| |
1819 |
|
return 1; |
|
| |
1820 |
|
} |
|
| |
1821 |
|
elseif ( ($elem1['MaxQty']<$elem2['MaxQty']) || ($elem2['MaxQty'] == -1 && $elem1['MaxQty'] != -1 )) |
|
| |
1822 |
|
{ |
|
| |
1823 |
|
return -1; |
|
| |
1824 |
|
} |
|
| |
1825 |
|
else |
|
| |
1826 |
|
{ |
|
| |
1827 |
|
return 0; |
|
| |
1828 |
|
} |
|
| |
1829 |
|
} |
|
| |
1830 |
|
|
|
| |
1831 |
|
function ap_bracket_comp($elem1, $elem2) |
|
| |
1832 |
|
{ |
|
| |
1833 |
|
|
|
| |
1834 |
|
if ($elem1['FromAmount']!="" && $elem1['ToAmount']=="" && $elem2['FromAmount']!="" && $elem2['ToAmount']!="") return 1; |
|
| |
1835 |
|
if ($elem1['FromAmount']!="" && $elem1['ToAmount']=="" && $elem2['FromAmount']=="" && $elem2['ToAmount']=="") return -1; |
|
| |
1836 |
|
|
|
| |
1837 |
|
|
|
| |
1838 |
|
if ($elem1['ToAmount']=="" && $elem2['ToAmount']!="") return 1; |
|
| |
1839 |
|
if ($elem1['ToAmount']!="" && $elem2['ToAmount']=="") return -1; |
|
| |
1840 |
|
|
|
| |
1841 |
|
|
|
| |
1842 |
|
if( ($elem1['ToAmount']>$elem2['ToAmount'] && $elem2['ToAmount']!=-1) || ($elem1['ToAmount'] == -1 && $elem2['ToAmount'] != -1 )) |
|
| |
1843 |
|
{ |
|
| |
1844 |
|
return 1; |
|
| |
1845 |
|
} |
|
| |
1846 |
|
elseif ( ($elem1['ToAmount']<$elem2['ToAmount']) || ($elem2['ToAmount'] == -1 && $elem1['ToAmount'] != -1 )) |
|
| |
1847 |
|
{ |
|
| |
1848 |
|
return -1; |
|
| |
1849 |
|
} |
|
| |
1850 |
|
else |
|
| |
1851 |
|
{ |
|
| |
1852 |
|
return 0; |
|
| |
1853 |
|
} |
|
| |
1854 |
|
} |
|
| |
1855 |
|
|
|
| |
1856 |
|
function pr_bracket_id_sort($first_id, $second_id) |
|
| |
1857 |
|
{ |
|
| |
1858 |
|
$first_abs = abs($first_id); |
|
| |
1859 |
|
$second_abs = abs($second_id); |
|
| |
1860 |
|
$first_sign = ($first_id == 0) ? 0 : $first_id / $first_abs; |
|
| |
1861 |
|
$second_sign = ($second_id == 0) ? 0 : $second_id / $second_abs; |
|
| |
1862 |
|
if($first_sign != $second_sign) |
|
| |
1863 |
|
{ |
|
| |
1864 |
|
if($first_id > $second_id) { |
|
| |
1865 |
|
$bigger =& $first_abs; |
|
| |
1866 |
|
$smaller =& $second_abs; |
|
| |
1867 |
|
} |
|
| |
1868 |
|
else { |
|
| |
1869 |
|
$bigger =& $second_abs; |
|
| |
1870 |
|
$smaller =& $first_abs; |
|
| |
1871 |
|
} |
|
| |
1872 |
|
$smaller = $bigger + $smaller; |
|
| |
1873 |
|
} |
|
| |
1874 |
|
|
|
| |
1875 |
|
if($first_abs > $second_abs) { |
|
| |
1876 |
|
return 1; |
|
| |
1877 |
|
} |
|
| |
1878 |
|
elseif ($first_abs < $second_abs) |
|
| |
1879 |
|
{ |
|
| |
1880 |
|
return -1; |
|
| |
1881 |
|
} |
|
| |
1882 |
|
else |
|
| |
1883 |
|
{ |
|
| |
1884 |
|
return 0; |
|
| |
1885 |
|
} |
|
| |
1886 |
|
} |
|
| |
1887 |
|
|
|
| |
1888 |
|
function inp_htmlize($var, $strip = 0) |
|
| |
1889 |
|
{ |
|
| |
1890 |
|
if( is_array($var) ) |
|
| |
1891 |
|
{ |
|
| |
1892 |
|
foreach($var as $k => $v) $var[$k] = inp_htmlize($v, $strip); |
|
| |
1893 |
|
} |
|
| |
1894 |
|
else |
|
| |
1895 |
|
{ |
|
| |
1896 |
|
$var = htmlspecialchars($strip ? stripslashes($var) : $var); |
|
| |
1897 |
|
} |
|
| |
1898 |
|
return $var; |
|
| |
1899 |
|
} |
|
| |
1900 |
|
|
|
| |
1901 |
|
|
|
| |
1902 |
|
|
|
| |
1903 |
|
|
|
| |
1904 |
|
|
|
| |
1905 |
|
|
|
| |
1906 |
|
|
|
| |
1907 |
|
|
|
| |
1908 |
|
|
|
| |
1909 |
|
function set_cookie($name, $value, $expire = 0, $cookie_path = null) |
|
| |
1910 |
|
{ |
|
| |
1911 |
|
if (!isset($cookie_path)) |
|
| |
1912 |
|
{ |
|
| |
1913 |
|
$cookie_path = IsAdmin() ? rtrim(BASE_PATH, '/').'/admin' : BASE_PATH; |
|
| |
1914 |
|
} |
|
| |
1915 |
|
setcookie($name, $value, $expire, $cookie_path, $_SERVER['HTTP_HOST']); |
|
| |
1916 |
|
} |
|
| |
1917 |
|
|
|
| |
1918 |
|
|
|
| |
1919 |
|
|
|
| |
1920 |
|
|
|
| |
1921 |
|
|
|
| |
1922 |
|
|
|
| |
1923 |
|
function require_login($condition = null, $redirect_params = 'logout=1', $pass_env = false) |
|
| |
1924 |
|
{ |
|
| |
1925 |
|
if( !isset($condition) ) $condition = !admin_login(); |
|
| |
1926 |
|
if(!$condition) return false; |
|
| |
1927 |
|
|
|
| |
1928 |
|
global $objSession, $adminURL; |
|
| |
1929 |
|
if( !headers_sent() ) set_cookie(SESSION_COOKIE_NAME, ' ', adodb_mktime() - 3600); |
|
| |
1930 |
|
$objSession->Logout(); |
|
| |
1931 |
|
if($pass_env) $redirect_params = 'env='.BuildEnv().'&'.$redirect_params; |
|
| |
1932 |
|
header('Location: '.$adminURL.'/index.php?'.$redirect_params); |
|
| |
1933 |
|
exit; |
|
| |
1934 |
|
} |
|
| |
1935 |
|
|
|
| |
1936 |
|
|
|
| |
1937 |
|
|
|
| |
1938 |
|
|
|
| |
1939 |
|
|
|
| |
1940 |
|
|
|
| |
1941 |
|
|
|
| |
1942 |
|
|
|
| |
1943 |
|
|
|
| |
1944 |
|
function HREF_Wrapper($t = '', $params = null, $index_file = null) |
|
| |
1945 |
|
{ |
|
| |
1946 |
|
$url_params = BuildEnv_NEW(); |
|
| |
1947 |
|
if( isset($params) ) $url_params = array_merge_recursive2($url_params, $params); |
|
| |
1948 |
|
if(!$t) |
|
| |
1949 |
|
{ |
|
| |
1950 |
|
$t = $url_params['t']; |
|
| |
1951 |
|
unset($url_params['t']); |
|
| |
1952 |
|
} |
|
| |
1953 |
|
$app =& kApplication::Instance(); |
|
| |
1954 |
|
return $app->HREF($t, '', $url_params, $index_file); |
|
| |
1955 |
|
} |
|
| |
1956 |
|
|
|
| |
1957 |
|
|
|
| |
1958 |
|
|
|
| |
1959 |
|
|
|
| |
1960 |
|
|
|
| |
1961 |
|
|
|
| |
1962 |
|
|
|
| |
1963 |
|
|
|
| |
1964 |
|
function MapTagParams(&$url_params, $tag_attribs, $params_map) |
|
| |
1965 |
|
{ |
|
| |
1966 |
|
foreach ($params_map as $tag_param => $url_param) |
|
| |
1967 |
|
{ |
|
| |
1968 |
|
if( getArrayValue($tag_attribs, $tag_param) ) $url_params[$url_param] = $tag_attribs[$tag_param]; |
|
| |
1969 |
|
} |
|
| |
1970 |
|
} |
|
| |
1971 |
|
|
|
| |
1972 |
|
function ExtractParams($params_str, $separator = '&') |
|
| |
1973 |
|
{ |
|
| |
1974 |
|
if(!$params_str) return Array(); |
|
| |
1975 |
|
|
|
| |
1976 |
|
$ret = Array(); |
|
| |
1977 |
|
$parts = explode($separator, trim($params_str, $separator) ); |
|
| |
1978 |
|
foreach ($parts as $part) |
|
| |
1979 |
|
{ |
|
| |
1980 |
|
list($var_name, $var_value) = explode('=', $part); |
|
| |
1981 |
|
$ret[$var_name] = $var_value; |
|
| |
1982 |
|
} |
|
| |
1983 |
|
return $ret; |
|
| |
1984 |
|
} |
|
| |
1985 |
|
|
|
| |
1986 |
|
function &recallObject($var_name, $class_name) |
|
| |
1987 |
|
{ |
|
| |
1988 |
|
if (!isset($GLOBALS[$var_name]) || !is_object($GLOBALS[$var_name])) |
|
| |
1989 |
|
{ |
|
| |
1990 |
|
$GLOBALS[$var_name] = new $class_name(); |
|
| |
1991 |
|
} |
|
| |
1992 |
|
return $GLOBALS[$var_name]; |
|
| |
1993 |
|
} |
|
| |
1994 |
|
|
|
| |
1995 |
|
|
|
| |
1996 |
|
|
|
| |
1997 |
|
|
|
| |
1998 |
|
|
|
| |
1999 |
|
|
|
| |
2000 |
|
function is12HourMode() |
|
| |
2001 |
|
{ |
|
| |
2002 |
|
return preg_match('/(a|A)/', GetTimeFormat() ); |
|
| |
2003 |
|
} |
|
| |
2004 |
|
|
|
| |
2005 |
|
|
|
| |
2006 |
|
|
|
| |
2007 |
|
|
|
| |
2008 |
|
|
|
| |
2009 |
|
|
|
| |
2010 |
|
|
|
| |
2011 |
|
|
|
| |
2012 |
|
function saveCustomFields($prefix, $resource_id, $item_type) |
|
| |
2013 |
|
{ |
|
| |
2014 |
|
$objCustomEdit = new clsCustomDataList(); |
|
| |
2015 |
|
$CustomFields = new clsCustomFieldList($item_type); |
|
| |
2016 |
|
|
|
| |
2017 |
|
$data_changed = false; |
|
| |
2018 |
|
for ($i = 0; $i < $CustomFields->NumItems(); $i++) { |
|
| |
2019 |
|
$objField =& $CustomFields->GetItemRefByIndex($i); |
|
| |
2020 |
|
$field_name = $objField->Get('FieldName'); |
|
| |
2021 |
|
|
|
| |
2022 |
|
$value = getCustomValue($field_name); |
|
| |
2023 |
|
if ($value !== false) { |
|
| |
2024 |
|
$objCustomEdit->SetFieldValue($objField->Get('CustomFieldId'), $resource_id, $value); |
|
| |
2025 |
|
$data_changed = true; |
|
| |
2026 |
|
} |
|
| |
2027 |
|
} |
|
| |
2028 |
|
|
|
| |
2029 |
|
if ($data_changed) { |
|
| |
2030 |
|
$objCustomEdit->SaveData($prefix, $resource_id); |
|
| |
2031 |
|
} |
|
| |
2032 |
|
} |
|
| |
2033 |
|
|
|
| |
2034 |
|
|
|
| |
2035 |
|
|
|
| |
2036 |
|
|
|
| |
2037 |
|
|
|
| |
2038 |
|
|
|
| |
2039 |
|
|
|
| |
2040 |
|
function getCustomValue($field_name) |
|
| |
2041 |
|
{ |
|
| |
2042 |
|
if (IsAdmin()) { |
|
| |
2043 |
|
$field_name = '_'.$field_name; |
|
| |
2044 |
|
} |
|
| |
2045 |
|
elseif (isset($_POST[strtolower($field_name)])) { |
|
| |
2046 |
|
$field_name = strtolower($field_name); |
|
| |
2047 |
|
} |
|
| |
2048 |
|
return GetVar($field_name); |
|
| |
2049 |
|
} |
|
| |
2050 |
|
|
|
| |
2051 |
|
?> |