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