Added default timezone to config (prevents lots of warnings during debuging)
[mirrors/Kyberia-bloodline.git] / wwwroot / nodes.php
CommitLineData
51ff3226 1<?php
a81e2af2 2//echo($_SERVER['PATH_INFO']."\n<pre>"); var_dump(preg_split('/\//', $_SERVER['PATH_INFO'])); die(); //PATH_INFO Debug (usefull when messing with mod_rewrite)
51ff3226 3// output buffering forcing (mx)
4if (!empty($_POST['FORCE_OB']) && $_POST['FORCE_OB'] == 'true') ob_start();
5
51ff3226 6//header("Location: http://web.archive.org/web/20020925021139/http://kyberia.sk");
51ff3226 7//echo "je to uz uplne v pici. vsetky data su stratene, prajem pekny den :)";
8//exit;
ab8ec5e5 9
51ff3226 10//starting timer for benchmarking purposes
11$timer_start=Time()+SubStr(MicroTime(),0,8);
51ff3226 12//setting PHPSESSID cookie and starting user session
13session_start();
14
45a1b870 15error_reporting(1);
cb4300b2 16//$_SESSION['debugging']=1;
45a1b870 17//exit;
18
51ff3226 19
20if ($_SESSION['debugging']) {
21
22 error_reporting(E_ALL);
a81e2af2 23 echo 'GET VARIABLES::<br/>';
51ff3226 24 print_r($_GET);
a81e2af2 25 echo 'POST VARIABLES::<br/>';
51ff3226 26 print_r($_POST);
a81e2af2 27 echo '<b>SESSION VARIABLES::</b><br/>';
51ff3226 28 print_r($_SESSION);
29}
30
4dd26acd
H
31//Smarty from DB
32$smarty_resource = 'kyberia:';
2a026138 33//$smarty_resource = ''; //same as 'file:' (fallback)
822594dc 34
a81e2af2 35//Path info (Experimental - this replaced most of mod_rewrites...)
822594dc
H
36@$PATH_INFO=trim($_SERVER[PATH_INFO]);
37if($PATH_INFO != '') {
a81e2af2 38 $PATH_CHUNKS = preg_split('/\//', $PATH_INFO);
20b73641 39 if(isset($PATH_CHUNKS[1])) switch($PATH_CHUNKS[1]) {
822594dc
H
40 case 'k':
41 if(isset($PATH_CHUNKS[2]) && $PATH_CHUNKS[2] != '') $_GET['node_kid'] = $PATH_CHUNKS[2];
42 if(isset($PATH_CHUNKS[3]) && $PATH_CHUNKS[3] != '') $_GET['template_kid'] = $PATH_CHUNKS[3];
43 break;
44 case 'id':
45 if(isset($PATH_CHUNKS[2]) && $PATH_CHUNKS[2] != '') $_GET['node_id'] = $PATH_CHUNKS[2];
46 if(isset($PATH_CHUNKS[3]) && $PATH_CHUNKS[3] != '') $_GET['template_id'] = $PATH_CHUNKS[3];
47 break;
20b73641
H
48 default:
49 if($PATH_CHUNKS[1] != '') $_GET['node_name'] = $PATH_CHUNKS[1];
50 if(isset($PATH_CHUNKS[2]) && $PATH_CHUNKS[2] != '') $_GET['template_kid'] = $PATH_CHUNKS[2];
51 break;
822594dc
H
52 }
53}
15de3e32
H
54if(
55 (!isset($_GET['node_kid']) || trim($_GET['node_kid']) == '') &&
56 (!isset($_GET['node_id']) || trim($_GET['node_id']) == '')
57) $_GET['node_kid'] = 1;
822594dc 58
96a2b554
H
59//Base36 http://en.wikipedia.org/wiki/Base_36 (Initial support only :-)
60if(isset($_GET['node_kid'])) $_GET['node_id'] = base_convert($_GET['node_kid'], 36, 10);
61if(isset($_GET['template_kid'])) $_GET['template_id'] = base_convert($_GET['template_kid'], 36, 10);
62
51ff3226 63//requiring main config file with path/database etc. constants
ab8ec5e5 64require('config/config.inc');
1757f060 65require(INCLUDE_DIR.'senate.inc');
51ff3226 66
2bcd35a6 67if (isset($_SERVER['HTTP_REFERER'])) {
a81e2af2 68 preg_match('/(k|id)\/([0-9]*)\//',$_SERVER['HTTP_REFERER'],$ref_match);
2bcd35a6 69 $referer_id=$ref_match[1];
70}
51ff3226 71
72//connecting to database and creating universal $db object
1757f060 73require(INCLUDE_DIR.'log.inc');
74require(INCLUDE_DIR.'ubik.inc');
75require(INCLUDE_DIR.'nodes.inc');
76require(INCLUDE_DIR.'error_messages.inc');
77require(INCLUDE_DIR.'database.inc');
51ff3226 78
e23557a6 79$db = new CLASS_DATABASE();
51ff3226 80
81if (!empty($_GET['template_id'])) {
82 $template_id=$_GET['template_id'];
5b9c0808 83} else {
84 $template_id=false;
51ff3226 85}
51ff3226 86
87//initializing node methods
88if (!empty($_GET['node_name'])) {
51ff3226 89 $node = nodes::redirByName($_GET['node_name']);
5b9c0808 90} elseif (!empty($_GET['node_id'])) {
91 $node = nodes::getNodeById($_GET['node_id'],
92 (isset($_SESSION['user_id']))?$_SESSION['user_id']:'');
51ff3226 93}
94
065440d5 95//XXX Paths are wrong (!)
51ff3226 96//loading smarty template engine and setting main parameters
97require(SMARTY_DIR.'Smarty.class.php');
98$smarty = new Smarty;
6a967e24 99require(INCLUDE_DIR.'smarty/resource.kyberia.php');
51ff3226 100
065440d5 101//$smarty->php_handling = SMARTY_PHP_REMOVE; //XXX
39244cfc 102$smarty->template_dir = TEMPLATE_DIR;
51ff3226 103//echo TEMPLATE_DIR.TEMPLATE_SET;
104//echo $smarty->template_dir;
a81e2af2 105$smarty->compile_dir = SYSTEM_DATA.'templates_c/';
175043f4 106$smarty->config_dir = SMARTY_DIR.'configs/'; //XXX neexistuje
51ff3226 107$smarty->cache_dir = SMARTY_DIR.'cache/';
108$smarty->plugins_dir = SMARTY_PLUGIN_DIR ;
109if ($_SESSION['debugging']) $smarty->debugging=true;
110
9850bdc4 111// initializing variables
112// preg_replace prevents LFI
51ff3226 113if (empty($_POST['event'])) $event=false;
9850bdc4 114else $event= preg_replace( "![^a-zA-Z0-9_]+!", "", $_POST['event']);
51ff3226 115
116
117if ($_SESSION['debugging']) {
118 echo "<pre><b>NODE::";
119 print_r($node);
120 echo "</pre>";
121}
122
12425f11 123if ((isset($_SESSION['user_id']) && ($node['node_creator']==$_SESSION['user_id']))) {
006bd683 124 $node['node_permission']='owner';
125}
51ff3226 126
006bd683 127if (isset($_SESSION['cube_vector']) && ($_SESSION['cube_vector'])) {
51ff3226 128 if (strpos($node['node_vector'],$_SESSION['cube_vector'])===false) {
129 echo "node::".$node['node_vector'];
130 echo "cube_Vector::".$_SESSION['cube_vector'];
131 echo "you are out of allowed cwbe. access forbidden";
132 die();
133 }
134}
135
136//if not existent node show our own 404
137if (empty($node)) {
138 $nodes= nodes::getNodesByName($_GET['node_name']);
139 if ($nodes) {
140 $smarty->assign('nodes',$nodes);
4dd26acd 141 $content=$smarty->display($smarty_resource.'404.tpl');
51ff3226 142 die();
143 }
144 elseif ($_SESSION['user_id']) {
145 $smarty->assign('node_name',$_GET['node_name']);
146 $content=$smarty->display("modules/addnode.tpl");
147 }
148}
149
006bd683 150//modifying node glass pearl //XXX WTF
151if (is_array($children_types[$node['node_type']])) {
152 $smarty->assign('children_types',$children_types[$node['node_type']]);
153}
51ff3226 154$smarty->assign('types',$types);
155
156
157//$node['node_type']=$types[$node['node_type']];
006bd683 158$node['node_content']= StripSlashes($node['node_content']);
159$node['node_name']= StripSlashes($node['node_name']);
51ff3226 160
161//checking permissions
162function _checkPermissions()
163{
164 global $permissions, $node;
165
e909f81b 166 require(INCLUDE_DIR.'permissions.inc');
51ff3226 167 $permissions=permissions::checkPermissions($node);
168 $permissions['h']=permissions::isHierarch($node);
169}
170
171// mail rss
5b9c0808 172if ($template_id=='rss') //XXX WHAT?
51ff3226 173{
174 $_feedType = "RSS0.91";
175 if (!is_numeric($_SESSION['user_id']))
176 {
177 if (!isset($_SERVER['PHP_AUTH_USER'])) {
178 header('WWW-Authenticate: Basic realm="Kyberia"');
179 header('HTTP/1.0 401 Unauthorized');
180 echo 'Cancel button';
181 exit;
182 }
183 else
184 {
185 require_once(EVENT_DIR.'/login.inc');
186 $_POST['login'] = $_SERVER['PHP_AUTH_USER'];
187 $_POST['password'] = $_SERVER['PHP_AUTH_PW'];
188 $_POST['login_type'] = "name";
189 if (!login())
190 {
191 echo "Zle meno/heslo.";
192 exit();
193 }
194 }
195 }
196
197 _checkPermissions();
198
199 // Mail
200 if ($_GET['node_id']==='24' && $permissions['r'])
201 {
202 require_once(INCLUDE_DIR.'/feedcreator.class.php');
203
82765da6 204 $rss = new UniversalFeedCreator();
51ff3226 205 $rss->title = "Kyberia mail";
206 $rss->description = "";
b6e35197 207 $rss->link = "https://". SYSTEM_URL . "/id/24";
51ff3226 208
5b9c0808 209 //XXX into function
51ff3226 210 $query = "select date_format(mail.mail_timestamp,\"%e.%c. %k:%i:%s\") as cas,
211 userfrom.user_action as locationfrom_action,
212 userfrom.user_action_id as locationfrom_action_id,
213 userto.user_action as locationto_action,
214 userto.user_action_id as locationto_action_id,
215 userto.login as mail_to_name, userfrom.login as mail_from_name,
216 mail.* from mail left join users as userfrom on
217 mail_from=userfrom.user_id left join users as userto on mail_to=userto.user_id
218 where mail_user='$_SESSION[user_id]' and mail_to='$_SESSION[user_id]' order by mail_id desc limit 0,10";
219
220 $set = $db->query($query);
221
222 while($set->next()) {
223 $m = $set->getRecord();
224 if ($m['mail_to'] != $_SESSION['user_id'])
225 continue;
82765da6 226 $item = new FeedItem();
51ff3226 227 $item->title = $m['mail_from_name'];
b6e35197 228 $item->link = "https://".SYSTEM_URL."/id/24";
51ff3226 229 $item->description = $m['mail_text'];
230 $rss->addItem($item);
231 }
232 }
233 // bookmarks
234 elseif ($_GET['node_id']=='19' && $permissions['r'])
235 {
236 require_once(INCLUDE_DIR.'/feedcreator.class.php');
237
82765da6 238 $rss = new UniversalFeedCreator();
51ff3226 239 $rss->title = "Kyberia bookmarks";
5b9c0808 240 $rss->link = "http://".SYSTEM_URL."/id/19"; //XXX https ?
51ff3226 241
242 require_once(SMARTY_PLUGIN_DIR.'/function.get_bookmarks.php');
243 smarty_function_get_bookmarks(array(), $smarty);
244 $_items = $smarty->get_template_vars('get_bookmarks');
245 foreach ($_items as $_item)
246 {
247 if (is_array($_item['children']))
248 foreach ($_item['children'] as $_b)
249 {
82765da6 250 $item = new FeedItem();
51ff3226 251 $item->title = $_b['node_name'];
b6e35197 252 $item->link = "http://".SYSTEM_URL."/id/".$_b['node_id']."/rss";
51ff3226 253 $rss->addItem($item);
254 }
255 }
256 $_feedType = 'OPML';
257 }
258 elseif ($permissions['r'])
259 {
260 require_once(INCLUDE_DIR.'/feedcreator.class.php');
261
82765da6 262 $rss = new UniversalFeedCreator();
51ff3226 263 $rss->title = $node['node_name'];
264 $rss->description = "";
b6e35197 265 $rss->link = "http://".SYSTEM_URL."/id/".$node['node_id'];
51ff3226 266
267 // K list
268 if ($_GET['node_id']=='15')
269 {
270 require_once(SMARTY_PLUGIN_DIR.'/function.get_k.php');
271 smarty_function_get_k(array(), $smarty);
272 $_items = $smarty->get_template_vars('get_k');
273 }
274 else
275 {
276 require_once(SMARTY_PLUGIN_DIR.'/function.get_children.php');
277 smarty_function_get_children(
278 array('orderby' => 'desc', 'orderby_type' => 'time'), $smarty);
279 $_items = $smarty->get_template_vars('get_children');
280 }
281
282 foreach ($_items as $_item)
283 {
82765da6 284 $item = new FeedItem();
51ff3226 285 $item->title = $_item['node_name'];
b6e35197 286 $item->link = "http://".SYSTEM_URL."/id/".$_item['node_id'];
51ff3226 287 $item->description = $_item['node_content'];
288 $rss->addItem($item);
289 }
290 }
291
292 if ($permissions['r']) $rss->showFeed($_feedType);
293 exit();
294}
295
296_checkPermissions();
297
298//entering the node
299
300//sventest
301if (($permissions['r']) || ($event != 'register')) {
302
5b9c0808 303 //performing node_events (based on update/insert/delete db queries)
304 if ($event) {
305 require(INCLUDE_DIR.'eventz.inc');
306 }
51ff3226 307
5b9c0808 308 elseif ($transaction) {
309 require(INCLUDE_DIR.'transaction.inc');
310 }
311 //end of performing node events
51ff3226 312
5b9c0808 313 //sventest
51ff3226 314}
315
316
317if ($permissions['r']) {
318
5b9c0808 319// these 4 lines are not the source of kyberia lagging problems.
320// leave them. started on the 10.4.
321// data gained will be used for scientific purposes
322
323// if (isset($_SESSION['user_id']) {
324// log_levenshtein($_SESSION['user_id'],$node['node_id']);
325// }
326
d9464c68 327if ((isset($_SESSION['user_id'])) && ($_SESSION['user_id'])) {
51ff3226 328 $q="insert delayed into levenshtein set user_id='".$_SESSION['user_id']."',node_id='".$node['node_id']."'";
329 $db->update($q);
330}
331
332//if node is css
5b9c0808 333//XXX into function
51ff3226 334if ($node['template_id']!='2019721'){
335
fd15ea3a 336 logger::log('enter',$node['node_id'],'ok',$node['node_user_subchild_count']);
51ff3226 337 if (!empty($_SESSION['user_id']) && is_numeric($node['node_id'])) {
338 $q="update node_access set visits=visits+1,node_user_subchild_count='0',last_visit=NOW() where node_id='".$node['node_id']."' and user_id='".$_SESSION['user_id']."'";
339// echo $q;
340 $result=$db->update($q);
341
342 if (!$result) {
343 $q="insert into node_access set user_id='".$_SESSION['user_id']."',node_id='".$node['node_id']."',last_visit=NOW()";
344 $db->query($q);
5b9c0808 345 }
346 }//end of if node os css
51ff3226 347}
348
5b9c0808 349}
350
351//XXX into function
352// if (isset($_SESSION['user_id']) {
353// if (isset($referer_id)) {
354// update_nodes($_SESSION['user_id'],$node['node_id'],$referer_id);
355// } else {
356// update_nodes($_SESSION['user_id'],$node['node_id'],0);
357// }
358// }
51ff3226 359
51ff3226 360// DO NOT MESS WITH THIS !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
361//creating neural network
362$db->update("update nodes set node_views=node_views+1 where node_id='".$node['node_id']."'");
202718bc 363if (isset($referer_id) && is_numeric($referer_id)) {
51ff3226 364 $q="update neurons set synapse=synapse+1 where dst='".$node['node_id']."' and src='$referer_id'";
365 $result=$db->update($q);
366 if (!$result) {
367 $q="insert into neurons set synapse_creator='".$_SESSION['user_id']."',dst='".$node['node_id']."',src='$referer_id',synapse=1";
368 $db->query($q);
369 }
370}
371
372
373elseif (!$permissions['r'] && $_GET['magic_word']) {
374 $magic_word_big=$_GET['magic_word'];
375
376 if ( preg_match("/(\d+)-(.+)/",$_GET['magic_word'],$mu)) {
377 $magic_uid=$mu['1'];
378 $magic_word=addslashes($mu['2']);
5b9c0808 379 // XXX WTF column magic_word does not exists
51ff3226 380 $q="select login from users where user_id='$magic_uid' and magic_word='$magic_word'";
381 $set=$db->query($q);
382 if ($set->getNumRows()) {
383 $permissions['r']=true;
384 }
385 }
386}
387
388
389
390
391
392else {
fd15ea3a 393 logger::log('enter',$node['node_id'],'failed');
51ff3226 394}
395
396
397
398//assigning user data to smarty if user logged in
58a9d5d7 399if (isset($_SESSION['user_id'])&&($user_id=$_SESSION['user_id'])) {
51ff3226 400 $smarty->assign('_POST',$_POST);
401 $smarty->assign('bookmarks',$_SESSION['bookmarks']);
402 $smarty->assign('ignore',$_SESSION['ignore']);
403 $smarty->assign('bookstyl',$_SESSION['bookstyl']);
404 $smarty->assign('fook',$_SESSION['fook']);
405 $smarty->assign('user_id',$_SESSION['user_id']);
9a7d7230 406 if (!empty($_SESSION['cube_vector']))
407 $smarty->assign('cube_vector',$_SESSION['cube_vector']);
51ff3226 408 $smarty->assign('friends',$_SESSION['friends']); //req by freezy, done by darkaural
409 $smarty->assign('user_quota',$_SESSION['user_quota']);
9a7d7230 410
5b9c0808 411 // XXX into function
9a7d7230 412 $newmail_q = sprintf('select u.user_mail_id
413 , u.user_k
414 , u.k_wallet
415 , u.user_mail
416 , ms.user_id as mail_sender_id
417 , ms.login as mail_sender
418 from users u
419 left join users ms on ms.user_id = u.user_mail_id
420 where u.user_id = %d',
421 $user_id);
422 $newmailset = $db->query($newmail_q);
423
9a7d7230 424
51ff3226 425 $newmailset->next();
426 $new_mail=$newmailset->getString('user_mail');
5b9c0808 427 // XXX into function
51ff3226 428 $newmailset2 = $db->query("select users.user_mail_id,mailsender.login
429 from users left join users as mailsender on users.user_mail_id = mailsender.user_id where users.user_id = '$user_id'");
430 $newmailset2->next();
431 $smarty->assign('new_mail',$new_mail);
9a7d7230 432 $smarty->assign('new_mail_name',$newmailset->getString('mail_sender'));
51ff3226 433 $smarty->assign('new_mail_name2',$newmailset2->getString('login'));
434 $user_k=$newmailset->getString('user_k');
435 $smarty->assign('user_k',$user_k);
436 $k_wallet=$newmailset->getString('k_wallet');
437 $smarty->assign('k_wallet',$k_wallet);
438 $user_id=$_SESSION['user_id'];
439
440 //mail node
441 if ($node['node_name']=='mail') {
442
443 //clear new mail message
5b9c0808 444
51ff3226 445 if ($new_mail) $db->query("update users set user_mail=0 where user_id='$user_id'");
446
447 //set messages as delivered to recipient
448 $set=$db->query("select mail_id,mail_duplicate_id from mail where mail_user='$user_id' and mail_to='$user_id' and mail_read='no'");
449 while($set->next()) {
450 $db->query("update mail set mail_read='yes' where mail_id='".$set->getString('mail_duplicate_id')."'");
451 $db->query("update mail set mail_read='yes' where mail_id='".$set->getString('mail_id')."'");
452
453 $new_messages[$set->getString('mail_id')]=true;
454 }
455/*
456 if (count($new_messages)) {
457 $db->query("update mail set mail_read='yes' where mail_user='$user_id' and mail_user=mail_to and mail_read='no'");
458 $smarty->assign('new_messages',$new_messages);
459
460 }
461*/
462 }
463}
464
465
466
467if ($node['node_system_access']=='crypto') {
468 $smarty->assign('crypto_pass',$_SESSION['crypto'][$node['node_id']]);
469}
470
51ff3226 471$smarty->assign('error',$error);
472$smarty->assign('permissions',$permissions);
473$smarty->assign('current_vector',$node['node_vector']);
474if ($permissions['r']) $smarty->assign('node',$node);
475else {
476
477 $smarty->assign('node',$node);
478 //new templates by Dark matter
479 $smarty->template_dir=OWN_TEMPLATE_DIR;
480
4dd26acd
H
481 $smarty->display($smarty_resource.'1549864.tpl');
482 $smarty->display($smarty_resource.'1549885.tpl');
483 $smarty->display($smarty_resource.'630526.tpl');
51ff3226 484 die();
485
486 //redirect to mainpage
487// looks like poeple totaly hate this redirect!
488// header("Location: /id/1");
489}
490
491
5b9c0808 492// XXX into function
58a9d5d7 493if (($node['template_id']!='2019721') && (isset($_SESSION['user_id']))){
51ff3226 494//setting user location
495$q="update users set last_action=NOW(),user_location_vector='".$node['node_vector']."',user_action='".addslashes($node['node_name'])."',user_action_id='".$node['node_id']."' where user_id='".$_SESSION['user_id']."'";
496$db->executequery($q);
497}
498
499$whole_time=SubStr((Time()+SubStr(MicroTime(),0,8)-$timer_start),0,7);
500$smarty->assign('whole_time',$whole_time);
501
502
503if ($template_id=='download' OR $template_id=='download.jpg') {
504 if ($permissions['r']) {
505 $linkname = SYSTEM_ROOT."/files/".$node['node_id'];
506 $filename= readlink($linkname);
507 $suffix=preg_replace("/(.*?)\.(.*?)/i","$2",$filename);
508
509 $ext = substr( $filename,-3 );
510 if( $filename == "" ) {
511 echo "ERROR: Empty file to download. ";
512 exit;
513 } elseif ( ! file_exists( $filename ) ) {
514 exit;
515 };
516 switch( strtolower($ext) ){
517 case "pdf": $ctype="application/pdf"; break;
518 case "exe": $ctype="application/octet-stream"; break;
519 case "zip": $ctype="application/zip"; break;
520 case "doc": $ctype="application/msword"; break;
521 case "xls": $ctype="application/vnd.ms-excel"; break;
522 case "ppt": $ctype="application/vnd.ms-powerpoint"; break;
523 case "gif": $ctype="image/gif"; break;
524 case "png": $ctype="image/png"; break;
525 case "jpg": $ctype="image/jpg"; break;
526 default: $ctype="application/force-download";
527 }
528 $file=str_replace(" ","_",$node['node_name']).".$ext";
529 header("Pragma: public");
530 header("Expires: 0");
531 header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
532 header("Content-Type: $ctype");
533 $user_agent = strtolower ($_SERVER["HTTP_USER_AGENT"]);
534 if ((is_integer (strpos($user_agent, "msie"))) && (is_integer
535 (strpos($user_agent, "win")))) {
536 header( "Content-Disposition: filename=$file;" );
537 } else {
538 header( "Content-Disposition: attachment;
539 filename=$file;" );
540 }
541 header("Content-Transfer-Encoding: binary");
542 header("Content-Length: ".filesize($filename));
543 readfile("$filename");
544 exit();
545 }
546 else { echo "you don't have permissions for downloading this data"; die(); }
547}
548
549if ($node['template_id']=='2019721'){
550Header("Cache-control: max-age=3600");
551}else{
552Header("Cache-control: no-cache");
553Header("Expires:".gmdate("D, d M Y H:i:s")." GMT");
554header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
555}
556
557
558//for cases like search & preview
559 $smarty->assign('post_vars',$_POST);
560if (!empty($_POST['template_event'])) {
561 $smarty->assign('template_event',$_POST['template_event']);
562
563}
564
565//setting listing parameters
566 $children_count=$node['node_children_count'];
567 $descendant_count=$node['node_descendant_count'];
568
202718bc 569 if (isset($_POST['listing_amount']) && is_numeric($_POST['listing_amount'])) {
570 $listing_amount=mysql_real_escape_string($_POST['listing_amount']);
571 }elseif (!empty($_SESSION['listing_amount'])) $listing_amount=$_SESSION['listing_amount'];
51ff3226 572 else $listing_amount=DEFAULT_LISTING_AMOUNT;
573 $smarty->assign('listing_amount',$listing_amount);
574
202718bc 575 if (isset($_POST['listing_order']) && $_POST['listing_order']) {
576 $listing_order=mysql_real_escape_string($_POST['listing_order']);
577 } elseif (!empty($_SESSION['listing_order'])) $listing_order=$_SESSION['listing_order'];
51ff3226 578 else $listing_order=DEFAULT_LISTING_ORDER;
579 $smarty->assign('listing_order',$listing_order);
580
202718bc 581 if (isset ($_POST['get_children_offset']) && is_numeric($_POST['get_children_offset'])) {
582 $offset=$_POST['get_children_offset'];
583 } else { $offset=0; }
51ff3226 584
585
586 //movement forward and backward
587// if ($listing_order=='asc' && !$offset) $offset=$descendant_count-$listing_amount;
588
589 if ($_POST['get_children_move']=='<') {
590 $offset=$offset-$listing_amount;
591 if ($offset<0) $offset=0;
592 }
593 elseif ($_POST['get_children_move']=='>') {
594 $offset=$offset+$listing_amount;
595 }
596 elseif ($_POST['get_children_move']=='>>') {
597 $offset=$descendant_count-$listing_amount;
598 }
599
600 elseif ($_POST['get_children_move']=='<<') {
601 $offset=0;
602 }
603 if ($offset<0) $offset=0;
604 $_POST['offset']=$offset;
605 $smarty->assign('offset',$offset);
606
607
608if ($node['external_link']=='header://svg' && !is_numeric($template_id)) {
609 header("Content-Type: image/svg+xml");
610}
611
612//show own header
58a9d5d7 613elseif (isset($_SESSION['header_id']) && ($_SESSION['header_id']==true)) {
51ff3226 614 $smarty->assign('header_id',$_SESSION['header_id']);
615 $smarty->template_dir=OWN_TEMPLATE_DIR;
4dd26acd 616 $content=$smarty->fetch($smarty_resource.$_SESSION['header_id'].".tpl");
51ff3226 617 $smarty->template_dir = TEMPLATE_DIR.TEMPLATE_SET;
618 //not registered user
619 if ($_SESSION['header_id']==2091520) {
620 echo $content;
621 session_destroy();
622 die();
623 }
624}
625
626$smarty->template_dir=OWN_TEMPLATE_DIR;
627
628if (is_numeric($template_id)) {
4dd26acd 629 $content.=$smarty->fetch($smarty_resource.$template_id.".tpl");
51ff3226 630}
631
632else {
633 $template_id=$node['template_id'];
4dd26acd 634 $content.=$smarty->fetch($smarty_resource.$node['template_id'].".tpl");
51ff3226 635}
636
637if ($template_id=='2019721'){
4dd26acd 638 $content=$smarty->fetch($smarty_resource.$template_id.".tpl");
51ff3226 639 echo $content;
640}else{
641 $time=SubStr((Time()+SubStr(MicroTime(),0,8)-$timer_start),0,7);
642 echo $content;
643// echo "<center>page generation took: $time second</center>";
644}
645//end of displaying
646
647// output buffering forcing (mx)
648if (!empty($_POST['FORCE_OB']) && $_POST['FORCE_OB'] == 'true') ob_end_flush();
649
650?>
This page took 0.599888 seconds and 4 git commands to generate.