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