2 // output buffering forcing (mx)
3 if (!empty($_POST['FORCE_OB']) && $_POST['FORCE_OB'] == 'true') ob_start();
5 //header("Location: http://web.archive.org/web/20020925021139/http://kyberia.sk");
6 //echo "je to uz uplne v pici. vsetky data su stratene, prajem pekny den :)";
9 //starting timer for benchmarking purposes
10 $timer_start=Time()+
SubStr(MicroTime(),0,8);
12 //setting PHPSESSID cookie and starting user session
16 //$_SESSION['debugging']=1;
20 if ($_SESSION['debugging']) {
22 error_reporting(E_ALL
);
23 echo "GET VARIABLES::<br/>";
25 echo "POST VARIABLES::<br/>";
27 echo "<b>SESSION VARIABLES::</b><br/>";
31 //requiring main config file with path/database etc. constants
32 require('config/config.inc');
33 require(INCLUDE_DIR
.'senate.inc');
35 if (isset($_SERVER['HTTP_REFERER'])) {
36 preg_match("/id\/([0-9]*)\//",$_SERVER['HTTP_REFERER'],$ref_match);
37 $referer_id=$ref_match[1];
40 //connecting to database and creating universal $db object
41 require(INCLUDE_DIR
.'log.inc');
42 require(INCLUDE_DIR
.'ubik.inc');
43 require(INCLUDE_DIR
.'nodes.inc');
44 require(INCLUDE_DIR
.'error_messages.inc');
45 require(INCLUDE_DIR
.'database.inc');
47 $db = new CLASS_DATABASE();
49 if (!empty($_GET['template_id'])) {
50 $template_id=$_GET['template_id'];
52 else $template_id=false;
54 //initializing node methods
55 if (!empty($_GET['node_name'])) {
56 $node = nodes
::redirByName($_GET['node_name']);
58 elseif (!empty($_GET['node_id'])) {
59 $node = nodes
::getNodeById($_GET['node_id'],(isset($_SESSION['user_id']))?
$_SESSION['user_id']:'');
62 //XXX Paths are wrong (!)
63 //loading smarty template engine and setting main parameters
64 require(SMARTY_DIR
.'Smarty.class.php');
67 //$smarty->php_handling = SMARTY_PHP_REMOVE; //XXX
68 $smarty->template_dir
= TEMPLATE_DIR
;
69 //echo TEMPLATE_DIR.TEMPLATE_SET;
70 //echo $smarty->template_dir;
71 $smarty->compile_dir
= SYSTEM_DATA
."templates_c/";
72 $smarty->config_dir
= SMARTY_DIR
.'configs/'; //XXX neexistuje
73 $smarty->cache_dir
= SMARTY_DIR
.'cache/';
74 $smarty->plugins_dir
= SMARTY_PLUGIN_DIR
;
75 if ($_SESSION['debugging']) $smarty->debugging
=true;
77 // initializing variables
78 // preg_replace prevents LFI
79 if (empty($_POST['event'])) $event=false;
80 else $event= preg_replace( "![^a-zA-Z0-9_]+!", "", $_POST['event']);
83 if ($_SESSION['debugging']) {
84 echo "<pre><b>NODE::";
89 if ((isset($_SESSION['user_id']) && ($node['node_creator']==$_SESSION['user_id']))) {
90 $node['node_permission']='owner';
93 if (isset($_SESSION['cube_vector']) && ($_SESSION['cube_vector'])) {
94 if (strpos($node['node_vector'],$_SESSION['cube_vector'])===false) {
95 echo "node::".$node['node_vector'];
96 echo "cube_Vector::".$_SESSION['cube_vector'];
97 echo "you are out of allowed cwbe. access forbidden";
102 //if not existent node show our own 404
104 $nodes= nodes
::getNodesByName($_GET['node_name']);
106 $smarty->assign('nodes',$nodes);
107 $content=$smarty->display("404.tpl");
110 elseif ($_SESSION['user_id']) {
111 $smarty->assign('node_name',$_GET['node_name']);
112 $content=$smarty->display("modules/addnode.tpl");
116 //modifying node glass pearl //XXX WTF
117 if (is_array($children_types[$node['node_type']])) {
118 $smarty->assign('children_types',$children_types[$node['node_type']]);
120 $smarty->assign('types',$types);
123 //$node['node_type']=$types[$node['node_type']];
124 $node['node_content']= StripSlashes($node['node_content']);
125 $node['node_name']= StripSlashes($node['node_name']);
127 //checking permissions
128 function _checkPermissions()
130 global $permissions, $node;
132 require(INCLUDE_DIR
.'permissions.inc');
133 $permissions=permissions
::checkPermissions($node);
134 $permissions['h']=permissions
::isHierarch($node);
138 if ($template_id=='rss')
140 $_feedType = "RSS0.91";
141 if (!is_numeric($_SESSION['user_id']))
143 if (!isset($_SERVER['PHP_AUTH_USER'])) {
144 header('WWW-Authenticate: Basic realm="Kyberia"');
145 header('HTTP/1.0 401 Unauthorized');
146 echo 'Cancel button';
151 require_once(EVENT_DIR
.'/login.inc');
152 $_POST['login'] = $_SERVER['PHP_AUTH_USER'];
153 $_POST['password'] = $_SERVER['PHP_AUTH_PW'];
154 $_POST['login_type'] = "name";
157 echo "Zle meno/heslo.";
166 if ($_GET['node_id']==='24' && $permissions['r'])
168 require_once(INCLUDE_DIR
.'/feedcreator.class.php');
170 $rss = new UniversalFeedCreator();
171 $rss->title
= "Kyberia mail";
172 $rss->description
= "";
173 $rss->link
= "https://". SYSTEM_URL
. "/id/24";
175 $query = "select date_format(mail.mail_timestamp,\"%e.%c. %k:%i:%s\") as cas,
176 userfrom.user_action as locationfrom_action,
177 userfrom.user_action_id as locationfrom_action_id,
178 userto.user_action as locationto_action,
179 userto.user_action_id as locationto_action_id,
180 userto.login as mail_to_name, userfrom.login as mail_from_name,
181 mail.* from mail left join users as userfrom on
182 mail_from=userfrom.user_id left join users as userto on mail_to=userto.user_id
183 where mail_user='$_SESSION[user_id]' and mail_to='$_SESSION[user_id]' order by mail_id desc limit 0,10";
185 $set = $db->query($query);
187 while($set->next()) {
188 $m = $set->getRecord();
189 if ($m['mail_to'] != $_SESSION['user_id'])
191 $item = new FeedItem();
192 $item->title
= $m['mail_from_name'];
193 $item->link
= "https://".SYSTEM_URL
."/id/24";
194 $item->description
= $m['mail_text'];
195 $rss->addItem($item);
199 elseif ($_GET['node_id']=='19' && $permissions['r'])
201 require_once(INCLUDE_DIR
.'/feedcreator.class.php');
203 $rss = new UniversalFeedCreator();
204 $rss->title
= "Kyberia bookmarks";
205 $rss->link
= "http://".SYSTEM_URL
."/id/19";
207 require_once(SMARTY_PLUGIN_DIR
.'/function.get_bookmarks.php');
208 smarty_function_get_bookmarks(array(), $smarty);
209 $_items = $smarty->get_template_vars('get_bookmarks');
210 foreach ($_items as $_item)
212 if (is_array($_item['children']))
213 foreach ($_item['children'] as $_b)
215 $item = new FeedItem();
216 $item->title
= $_b['node_name'];
217 $item->link
= "http://".SYSTEM_URL
."/id/".$_b['node_id']."/rss";
218 $rss->addItem($item);
223 elseif ($permissions['r'])
225 require_once(INCLUDE_DIR
.'/feedcreator.class.php');
227 $rss = new UniversalFeedCreator();
228 $rss->title
= $node['node_name'];
229 $rss->description
= "";
230 $rss->link
= "http://".SYSTEM_URL
."/id/".$node['node_id'];
233 if ($_GET['node_id']=='15')
235 require_once(SMARTY_PLUGIN_DIR
.'/function.get_k.php');
236 smarty_function_get_k(array(), $smarty);
237 $_items = $smarty->get_template_vars('get_k');
241 require_once(SMARTY_PLUGIN_DIR
.'/function.get_children.php');
242 smarty_function_get_children(
243 array('orderby' => 'desc', 'orderby_type' => 'time'), $smarty);
244 $_items = $smarty->get_template_vars('get_children');
247 foreach ($_items as $_item)
249 $item = new FeedItem();
250 $item->title
= $_item['node_name'];
251 $item->link
= "http://".SYSTEM_URL
."/id/".$_item['node_id'];
252 $item->description
= $_item['node_content'];
253 $rss->addItem($item);
257 if ($permissions['r']) $rss->showFeed($_feedType);
266 if (($permissions['r']) ||
($event != 'register')) {
268 //performing node_events (based on update/insert/delete db queries)
270 require(INCLUDE_DIR
.'eventz.inc');
273 elseif ($transaction) {
274 require(INCLUDE_DIR
.'transaction.inc');
276 //end of performing node events
282 if ($permissions['r']) {
284 //these 4 lines are not the source of kyberia lagging problems. leave them. started on the 10.4. data gained will be used for scientific purposes
285 if ($_SESSION['user_id']) {
286 $q="insert delayed into levenshtein set user_id='".$_SESSION['user_id']."',node_id='".$node['node_id']."'";
291 if ($node['template_id']!='2019721'){
293 logger
::log('enter',$node['node_id'],'ok',$node['node_user_subchild_count']);
294 if (!empty($_SESSION['user_id']) && is_numeric($node['node_id'])) {
295 $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']."'";
297 $result=$db->update($q);
300 $q="insert into node_access set user_id='".$_SESSION['user_id']."',node_id='".$node['node_id']."',last_visit=NOW()";
303 }//end of if node os css
308 // DO NOT MESS WITH THIS !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
309 //creating neural network
310 $db->update("update nodes set node_views=node_views+1 where node_id='".$node['node_id']."'");
311 if (is_numeric($referer_id)) {
312 $q="update neurons set synapse=synapse+1 where dst='".$node['node_id']."' and src='$referer_id'";
313 $result=$db->update($q);
315 $q="insert into neurons set synapse_creator='".$_SESSION['user_id']."',dst='".$node['node_id']."',src='$referer_id',synapse=1";
321 elseif (!$permissions['r'] && $_GET['magic_word']) {
322 $magic_word_big=$_GET['magic_word'];
324 if ( preg_match("/(\d+)-(.+)/",$_GET['magic_word'],$mu)) {
326 $magic_word=addslashes($mu['2']);
327 $q="select login from users where user_id='$magic_uid' and magic_word='$magic_word'";
329 if ($set->getNumRows()) {
330 $permissions['r']=true;
340 logger
::log('enter',$node['node_id'],'failed');
345 //assigning user data to smarty if user logged in
346 if ($user_id=$_SESSION['user_id']) {
347 $smarty->assign('_POST',$_POST);
348 $smarty->assign('bookmarks',$_SESSION['bookmarks']);
349 $smarty->assign('ignore',$_SESSION['ignore']);
350 $smarty->assign('bookstyl',$_SESSION['bookstyl']);
351 $smarty->assign('fook',$_SESSION['fook']);
352 $smarty->assign('user_id',$_SESSION['user_id']);
353 if (!empty($_SESSION['cube_vector']))
354 $smarty->assign('cube_vector',$_SESSION['cube_vector']);
355 $smarty->assign('friends',$_SESSION['friends']); //req by freezy, done by darkaural
356 $smarty->assign('user_quota',$_SESSION['user_quota']);
358 $newmail_q = sprintf('select u.user_mail_id
362 , ms.user_id as mail_sender_id
363 , ms.login as mail_sender
365 left join users ms on ms.user_id = u.user_mail_id
366 where u.user_id = %d',
368 $newmailset = $db->query($newmail_q);
370 //$newmailset=$db->query("select user_mail,user_mail_name,user_k,k_wallet from users where user_id='$user_id'");
373 $new_mail=$newmailset->getString('user_mail');
374 $newmailset2 = $db->query("select users.user_mail_id,mailsender.login
375 from users left join users as mailsender on users.user_mail_id = mailsender.user_id where users.user_id = '$user_id'");
376 $newmailset2->next();
377 $smarty->assign('new_mail',$new_mail);
378 $smarty->assign('new_mail_name',$newmailset->getString('mail_sender'));
379 $smarty->assign('new_mail_name2',$newmailset2->getString('login'));
380 $user_k=$newmailset->getString('user_k');
381 $smarty->assign('user_k',$user_k);
382 $k_wallet=$newmailset->getString('k_wallet');
383 $smarty->assign('k_wallet',$k_wallet);
384 $user_id=$_SESSION['user_id'];
387 if ($node['node_name']=='mail') {
389 //clear new mail message
390 if ($new_mail) $db->query("update users set user_mail=0 where user_id='$user_id'");
392 //set messages as delivered to recipient
393 $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'");
394 while($set->next()) {
395 $db->query("update mail set mail_read='yes' where mail_id='".$set->getString('mail_duplicate_id')."'");
396 $db->query("update mail set mail_read='yes' where mail_id='".$set->getString('mail_id')."'");
398 $new_messages[$set->getString('mail_id')]=true;
401 if (count($new_messages)) {
402 $db->query("update mail set mail_read='yes' where mail_user='$user_id' and mail_user=mail_to and mail_read='no'");
403 $smarty->assign('new_messages',$new_messages);
412 if ($node['node_system_access']=='crypto') {
413 $smarty->assign('crypto_pass',$_SESSION['crypto'][$node['node_id']]);
416 $smarty->assign('error',$error);
417 $smarty->assign('permissions',$permissions);
418 $smarty->assign('current_vector',$node['node_vector']);
419 if ($permissions['r']) $smarty->assign('node',$node);
422 $smarty->assign('node',$node);
423 //new templates by Dark matter
424 $smarty->template_dir
=OWN_TEMPLATE_DIR
;
426 $smarty->display('1549864.tpl');
427 $smarty->display('1549885.tpl');
428 $smarty->display('630526.tpl');
431 //redirect to mainpage
432 // looks like poeple totaly hate this redirect!
433 // header("Location: /id/1");
437 if ($node['template_id']!='2019721'){
438 //setting user location
439 $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']."'";
440 $db->executequery($q);
443 $whole_time=SubStr((Time()+
SubStr(MicroTime(),0,8)-$timer_start),0,7);
444 $smarty->assign('whole_time',$whole_time);
447 if ($template_id=='download' OR $template_id=='download.jpg') {
448 if ($permissions['r']) {
449 $linkname = SYSTEM_ROOT
."/files/".$node['node_id'];
450 $filename= readlink($linkname);
451 $suffix=preg_replace("/(.*?)\.(.*?)/i","$2",$filename);
453 $ext = substr( $filename,-3 );
454 if( $filename == "" ) {
455 echo "ERROR: Empty file to download. ";
457 } elseif ( ! file_exists( $filename ) ) {
460 switch( strtolower($ext) ){
461 case "pdf": $ctype="application/pdf"; break;
462 case "exe": $ctype="application/octet-stream"; break;
463 case "zip": $ctype="application/zip"; break;
464 case "doc": $ctype="application/msword"; break;
465 case "xls": $ctype="application/vnd.ms-excel"; break;
466 case "ppt": $ctype="application/vnd.ms-powerpoint"; break;
467 case "gif": $ctype="image/gif"; break;
468 case "png": $ctype="image/png"; break;
469 case "jpg": $ctype="image/jpg"; break;
470 default: $ctype="application/force-download";
472 $file=str_replace(" ","_",$node['node_name']).".$ext";
473 header("Pragma: public");
474 header("Expires: 0");
475 header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
476 header("Content-Type: $ctype");
477 $user_agent = strtolower ($_SERVER["HTTP_USER_AGENT"]);
478 if ((is_integer (strpos($user_agent, "msie"))) && (is_integer
479 (strpos($user_agent, "win")))) {
480 header( "Content-Disposition: filename=$file;" );
482 header( "Content-Disposition: attachment;
485 header("Content-Transfer-Encoding: binary");
486 header("Content-Length: ".filesize($filename));
487 readfile("$filename");
490 else { echo "you don't have permissions for downloading this data"; die(); }
493 if ($node['template_id']=='2019721'){
494 Header("Cache-control: max-age=3600");
496 Header("Cache-control: no-cache");
497 Header("Expires:".gmdate("D, d M Y H:i:s")." GMT");
498 header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
502 //for cases like search & preview
503 $smarty->assign('post_vars',$_POST);
504 if (!empty($_POST['template_event'])) {
505 $smarty->assign('template_event',$_POST['template_event']);
509 //setting listing parameters
510 $children_count=$node['node_children_count'];
511 $descendant_count=$node['node_descendant_count'];
513 if (is_numeric($_POST['listing_amount'])) $listing_amount=$_POST['listing_amount'];
514 elseif (!empty($_SESSION['listing_amount'])) $listing_amount=$_SESSION['listing_amount'];
515 else $listing_amount=DEFAULT_LISTING_AMOUNT
;
516 $smarty->assign('listing_amount',$listing_amount);
518 if ($_POST['listing_order']) $listing_order=$_POST['listing_order'];
519 elseif (!empty($_SESSION['listing_order'])) $listing_order=$_SESSION['listing_order'];
520 else $listing_order=DEFAULT_LISTING_ORDER
;
521 $smarty->assign('listing_order',$listing_order);
523 if (is_numeric($_POST['get_children_offset'])) $offset=$_POST['get_children_offset'];
527 //movement forward and backward
528 // if ($listing_order=='asc' && !$offset) $offset=$descendant_count-$listing_amount;
530 if ($_POST['get_children_move']=='<') {
531 $offset=$offset-$listing_amount;
532 if ($offset<0) $offset=0;
534 elseif ($_POST['get_children_move']=='>') {
535 $offset=$offset+
$listing_amount;
537 elseif ($_POST['get_children_move']=='>>') {
538 $offset=$descendant_count-$listing_amount;
541 elseif ($_POST['get_children_move']=='<<') {
544 if ($offset<0) $offset=0;
545 $_POST['offset']=$offset;
546 $smarty->assign('offset',$offset);
549 if ($node['external_link']=='header://svg' && !is_numeric($template_id)) {
550 header("Content-Type: image/svg+xml");
554 elseif ($_SESSION['header_id']==true) {
555 $smarty->assign('header_id',$_SESSION['header_id']);
556 $smarty->template_dir
=OWN_TEMPLATE_DIR
;
557 $content=$smarty->fetch($_SESSION['header_id'].".tpl");
558 $smarty->template_dir
= TEMPLATE_DIR
.TEMPLATE_SET
;
559 //not registered user
560 if ($_SESSION['header_id']==2091520) {
567 $smarty->template_dir
=OWN_TEMPLATE_DIR
;
569 if (is_numeric($template_id)) {
570 $content.=$smarty->fetch($template_id.".tpl");
574 $template_id=$node['template_id'];
575 $content.=$smarty->fetch($node['template_id'].".tpl");
578 if ($template_id=='2019721'){
579 $content=$smarty->fetch($template_id.".tpl");
582 $time=SubStr((Time()+
SubStr(MicroTime(),0,8)-$timer_start),0,7);
584 // echo "<center>page generation took: $time second</center>";
588 // output buffering forcing (mx)
589 if (!empty($_POST['FORCE_OB']) && $_POST['FORCE_OB'] == 'true') ob_end_flush();
This page took 0.764452 seconds and 5 git commands to generate.