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