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'];
55 //initializing node methods
56 if (!empty($_GET['node_name'])) {
57 $node = nodes
::redirByName($_GET['node_name']);
58 } elseif (!empty($_GET['node_id'])) {
59 $node = nodes
::getNodeById($_GET['node_id'],
60 (isset($_SESSION['user_id']))?
$_SESSION['user_id']:'');
63 //XXX Paths are wrong (!)
64 //loading smarty template engine and setting main parameters
65 require(SMARTY_DIR
.'Smarty.class.php');
68 //$smarty->php_handling = SMARTY_PHP_REMOVE; //XXX
69 $smarty->template_dir
= TEMPLATE_DIR
;
70 //echo TEMPLATE_DIR.TEMPLATE_SET;
71 //echo $smarty->template_dir;
72 $smarty->compile_dir
= SYSTEM_DATA
."templates_c/";
73 $smarty->config_dir
= SMARTY_DIR
.'configs/'; //XXX neexistuje
74 $smarty->cache_dir
= SMARTY_DIR
.'cache/';
75 $smarty->plugins_dir
= SMARTY_PLUGIN_DIR
;
76 if ($_SESSION['debugging']) $smarty->debugging
=true;
78 // initializing variables
79 // preg_replace prevents LFI
80 if (empty($_POST['event'])) $event=false;
81 else $event= preg_replace( "![^a-zA-Z0-9_]+!", "", $_POST['event']);
84 if ($_SESSION['debugging']) {
85 echo "<pre><b>NODE::";
90 if ((isset($_SESSION['user_id']) && ($node['node_creator']==$_SESSION['user_id']))) {
91 $node['node_permission']='owner';
94 if (isset($_SESSION['cube_vector']) && ($_SESSION['cube_vector'])) {
95 if (strpos($node['node_vector'],$_SESSION['cube_vector'])===false) {
96 echo "node::".$node['node_vector'];
97 echo "cube_Vector::".$_SESSION['cube_vector'];
98 echo "you are out of allowed cwbe. access forbidden";
103 //if not existent node show our own 404
105 $nodes= nodes
::getNodesByName($_GET['node_name']);
107 $smarty->assign('nodes',$nodes);
108 $content=$smarty->display("404.tpl");
111 elseif ($_SESSION['user_id']) {
112 $smarty->assign('node_name',$_GET['node_name']);
113 $content=$smarty->display("modules/addnode.tpl");
117 //modifying node glass pearl //XXX WTF
118 if (is_array($children_types[$node['node_type']])) {
119 $smarty->assign('children_types',$children_types[$node['node_type']]);
121 $smarty->assign('types',$types);
124 //$node['node_type']=$types[$node['node_type']];
125 $node['node_content']= StripSlashes($node['node_content']);
126 $node['node_name']= StripSlashes($node['node_name']);
128 //checking permissions
129 function _checkPermissions()
131 global $permissions, $node;
133 require(INCLUDE_DIR
.'permissions.inc');
134 $permissions=permissions
::checkPermissions($node);
135 $permissions['h']=permissions
::isHierarch($node);
139 if ($template_id=='rss') //XXX WHAT?
141 $_feedType = "RSS0.91";
142 if (!is_numeric($_SESSION['user_id']))
144 if (!isset($_SERVER['PHP_AUTH_USER'])) {
145 header('WWW-Authenticate: Basic realm="Kyberia"');
146 header('HTTP/1.0 401 Unauthorized');
147 echo 'Cancel button';
152 require_once(EVENT_DIR
.'/login.inc');
153 $_POST['login'] = $_SERVER['PHP_AUTH_USER'];
154 $_POST['password'] = $_SERVER['PHP_AUTH_PW'];
155 $_POST['login_type'] = "name";
158 echo "Zle meno/heslo.";
167 if ($_GET['node_id']==='24' && $permissions['r'])
169 require_once(INCLUDE_DIR
.'/feedcreator.class.php');
171 $rss = new UniversalFeedCreator();
172 $rss->title
= "Kyberia mail";
173 $rss->description
= "";
174 $rss->link
= "https://". SYSTEM_URL
. "/id/24";
177 $query = "select date_format(mail.mail_timestamp,\"%e.%c. %k:%i:%s\") as cas,
178 userfrom.user_action as locationfrom_action,
179 userfrom.user_action_id as locationfrom_action_id,
180 userto.user_action as locationto_action,
181 userto.user_action_id as locationto_action_id,
182 userto.login as mail_to_name, userfrom.login as mail_from_name,
183 mail.* from mail left join users as userfrom on
184 mail_from=userfrom.user_id left join users as userto on mail_to=userto.user_id
185 where mail_user='$_SESSION[user_id]' and mail_to='$_SESSION[user_id]' order by mail_id desc limit 0,10";
187 $set = $db->query($query);
189 while($set->next()) {
190 $m = $set->getRecord();
191 if ($m['mail_to'] != $_SESSION['user_id'])
193 $item = new FeedItem();
194 $item->title
= $m['mail_from_name'];
195 $item->link
= "https://".SYSTEM_URL
."/id/24";
196 $item->description
= $m['mail_text'];
197 $rss->addItem($item);
201 elseif ($_GET['node_id']=='19' && $permissions['r'])
203 require_once(INCLUDE_DIR
.'/feedcreator.class.php');
205 $rss = new UniversalFeedCreator();
206 $rss->title
= "Kyberia bookmarks";
207 $rss->link
= "http://".SYSTEM_URL
."/id/19"; //XXX https ?
209 require_once(SMARTY_PLUGIN_DIR
.'/function.get_bookmarks.php');
210 smarty_function_get_bookmarks(array(), $smarty);
211 $_items = $smarty->get_template_vars('get_bookmarks');
212 foreach ($_items as $_item)
214 if (is_array($_item['children']))
215 foreach ($_item['children'] as $_b)
217 $item = new FeedItem();
218 $item->title
= $_b['node_name'];
219 $item->link
= "http://".SYSTEM_URL
."/id/".$_b['node_id']."/rss";
220 $rss->addItem($item);
225 elseif ($permissions['r'])
227 require_once(INCLUDE_DIR
.'/feedcreator.class.php');
229 $rss = new UniversalFeedCreator();
230 $rss->title
= $node['node_name'];
231 $rss->description
= "";
232 $rss->link
= "http://".SYSTEM_URL
."/id/".$node['node_id'];
235 if ($_GET['node_id']=='15')
237 require_once(SMARTY_PLUGIN_DIR
.'/function.get_k.php');
238 smarty_function_get_k(array(), $smarty);
239 $_items = $smarty->get_template_vars('get_k');
243 require_once(SMARTY_PLUGIN_DIR
.'/function.get_children.php');
244 smarty_function_get_children(
245 array('orderby' => 'desc', 'orderby_type' => 'time'), $smarty);
246 $_items = $smarty->get_template_vars('get_children');
249 foreach ($_items as $_item)
251 $item = new FeedItem();
252 $item->title
= $_item['node_name'];
253 $item->link
= "http://".SYSTEM_URL
."/id/".$_item['node_id'];
254 $item->description
= $_item['node_content'];
255 $rss->addItem($item);
259 if ($permissions['r']) $rss->showFeed($_feedType);
268 if (($permissions['r']) ||
($event != 'register')) {
270 //performing node_events (based on update/insert/delete db queries)
272 require(INCLUDE_DIR
.'eventz.inc');
275 elseif ($transaction) {
276 require(INCLUDE_DIR
.'transaction.inc');
278 //end of performing node events
284 if ($permissions['r']) {
286 // these 4 lines are not the source of kyberia lagging problems.
287 // leave them. started on the 10.4.
288 // data gained will be used for scientific purposes
290 // if (isset($_SESSION['user_id']) {
291 // log_levenshtein($_SESSION['user_id'],$node['node_id']);
294 if ((isset($_SESSION['user_id'])) && ($_SESSION['user_id'])) {
295 $q="insert delayed into levenshtein set user_id='".$_SESSION['user_id']."',node_id='".$node['node_id']."'";
301 if ($node['template_id']!='2019721'){
303 logger
::log('enter',$node['node_id'],'ok',$node['node_user_subchild_count']);
304 if (!empty($_SESSION['user_id']) && is_numeric($node['node_id'])) {
305 $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']."'";
307 $result=$db->update($q);
310 $q="insert into node_access set user_id='".$_SESSION['user_id']."',node_id='".$node['node_id']."',last_visit=NOW()";
313 }//end of if node os css
319 // if (isset($_SESSION['user_id']) {
320 // if (isset($referer_id)) {
321 // update_nodes($_SESSION['user_id'],$node['node_id'],$referer_id);
323 // update_nodes($_SESSION['user_id'],$node['node_id'],0);
327 // DO NOT MESS WITH THIS !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
328 //creating neural network
329 $db->update("update nodes set node_views=node_views+1 where node_id='".$node['node_id']."'");
330 if (isset($referer_id) && is_numeric($referer_id)) {
331 $q="update neurons set synapse=synapse+1 where dst='".$node['node_id']."' and src='$referer_id'";
332 $result=$db->update($q);
334 $q="insert into neurons set synapse_creator='".$_SESSION['user_id']."',dst='".$node['node_id']."',src='$referer_id',synapse=1";
340 elseif (!$permissions['r'] && $_GET['magic_word']) {
341 $magic_word_big=$_GET['magic_word'];
343 if ( preg_match("/(\d+)-(.+)/",$_GET['magic_word'],$mu)) {
345 $magic_word=addslashes($mu['2']);
346 // XXX WTF column magic_word does not exists
347 $q="select login from users where user_id='$magic_uid' and magic_word='$magic_word'";
349 if ($set->getNumRows()) {
350 $permissions['r']=true;
360 logger
::log('enter',$node['node_id'],'failed');
365 //assigning user data to smarty if user logged in
366 if (isset($_SESSION['user_id'])&&($user_id=$_SESSION['user_id'])) {
367 $smarty->assign('_POST',$_POST);
368 $smarty->assign('bookmarks',$_SESSION['bookmarks']);
369 $smarty->assign('ignore',$_SESSION['ignore']);
370 $smarty->assign('bookstyl',$_SESSION['bookstyl']);
371 $smarty->assign('fook',$_SESSION['fook']);
372 $smarty->assign('user_id',$_SESSION['user_id']);
373 if (!empty($_SESSION['cube_vector']))
374 $smarty->assign('cube_vector',$_SESSION['cube_vector']);
375 $smarty->assign('friends',$_SESSION['friends']); //req by freezy, done by darkaural
376 $smarty->assign('user_quota',$_SESSION['user_quota']);
379 $newmail_q = sprintf('select u.user_mail_id
383 , ms.user_id as mail_sender_id
384 , ms.login as mail_sender
386 left join users ms on ms.user_id = u.user_mail_id
387 where u.user_id = %d',
389 $newmailset = $db->query($newmail_q);
393 $new_mail=$newmailset->getString('user_mail');
395 $newmailset2 = $db->query("select users.user_mail_id,mailsender.login
396 from users left join users as mailsender on users.user_mail_id = mailsender.user_id where users.user_id = '$user_id'");
397 $newmailset2->next();
398 $smarty->assign('new_mail',$new_mail);
399 $smarty->assign('new_mail_name',$newmailset->getString('mail_sender'));
400 $smarty->assign('new_mail_name2',$newmailset2->getString('login'));
401 $user_k=$newmailset->getString('user_k');
402 $smarty->assign('user_k',$user_k);
403 $k_wallet=$newmailset->getString('k_wallet');
404 $smarty->assign('k_wallet',$k_wallet);
405 $user_id=$_SESSION['user_id'];
408 if ($node['node_name']=='mail') {
410 //clear new mail message
412 if ($new_mail) $db->query("update users set user_mail=0 where user_id='$user_id'");
414 //set messages as delivered to recipient
415 $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'");
416 while($set->next()) {
417 $db->query("update mail set mail_read='yes' where mail_id='".$set->getString('mail_duplicate_id')."'");
418 $db->query("update mail set mail_read='yes' where mail_id='".$set->getString('mail_id')."'");
420 $new_messages[$set->getString('mail_id')]=true;
423 if (count($new_messages)) {
424 $db->query("update mail set mail_read='yes' where mail_user='$user_id' and mail_user=mail_to and mail_read='no'");
425 $smarty->assign('new_messages',$new_messages);
434 if ($node['node_system_access']=='crypto') {
435 $smarty->assign('crypto_pass',$_SESSION['crypto'][$node['node_id']]);
438 $smarty->assign('error',$error);
439 $smarty->assign('permissions',$permissions);
440 $smarty->assign('current_vector',$node['node_vector']);
441 if ($permissions['r']) $smarty->assign('node',$node);
444 $smarty->assign('node',$node);
445 //new templates by Dark matter
446 $smarty->template_dir
=OWN_TEMPLATE_DIR
;
448 $smarty->display('1549864.tpl');
449 $smarty->display('1549885.tpl');
450 $smarty->display('630526.tpl');
453 //redirect to mainpage
454 // looks like poeple totaly hate this redirect!
455 // header("Location: /id/1");
460 if (($node['template_id']!='2019721') && (isset($_SESSION['user_id']))){
461 //setting user location
462 $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']."'";
463 $db->executequery($q);
466 $whole_time=SubStr((Time()+
SubStr(MicroTime(),0,8)-$timer_start),0,7);
467 $smarty->assign('whole_time',$whole_time);
470 if ($template_id=='download' OR $template_id=='download.jpg') {
471 if ($permissions['r']) {
472 $linkname = SYSTEM_ROOT
."/files/".$node['node_id'];
473 $filename= readlink($linkname);
474 $suffix=preg_replace("/(.*?)\.(.*?)/i","$2",$filename);
476 $ext = substr( $filename,-3 );
477 if( $filename == "" ) {
478 echo "ERROR: Empty file to download. ";
480 } elseif ( ! file_exists( $filename ) ) {
483 switch( strtolower($ext) ){
484 case "pdf": $ctype="application/pdf"; break;
485 case "exe": $ctype="application/octet-stream"; break;
486 case "zip": $ctype="application/zip"; break;
487 case "doc": $ctype="application/msword"; break;
488 case "xls": $ctype="application/vnd.ms-excel"; break;
489 case "ppt": $ctype="application/vnd.ms-powerpoint"; break;
490 case "gif": $ctype="image/gif"; break;
491 case "png": $ctype="image/png"; break;
492 case "jpg": $ctype="image/jpg"; break;
493 default: $ctype="application/force-download";
495 $file=str_replace(" ","_",$node['node_name']).".$ext";
496 header("Pragma: public");
497 header("Expires: 0");
498 header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
499 header("Content-Type: $ctype");
500 $user_agent = strtolower ($_SERVER["HTTP_USER_AGENT"]);
501 if ((is_integer (strpos($user_agent, "msie"))) && (is_integer
502 (strpos($user_agent, "win")))) {
503 header( "Content-Disposition: filename=$file;" );
505 header( "Content-Disposition: attachment;
508 header("Content-Transfer-Encoding: binary");
509 header("Content-Length: ".filesize($filename));
510 readfile("$filename");
513 else { echo "you don't have permissions for downloading this data"; die(); }
516 if ($node['template_id']=='2019721'){
517 Header("Cache-control: max-age=3600");
519 Header("Cache-control: no-cache");
520 Header("Expires:".gmdate("D, d M Y H:i:s")." GMT");
521 header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
525 //for cases like search & preview
526 $smarty->assign('post_vars',$_POST);
527 if (!empty($_POST['template_event'])) {
528 $smarty->assign('template_event',$_POST['template_event']);
532 //setting listing parameters
533 $children_count=$node['node_children_count'];
534 $descendant_count=$node['node_descendant_count'];
536 if (isset($_POST['listing_amount']) && is_numeric($_POST['listing_amount'])) {
537 $listing_amount=mysql_real_escape_string($_POST['listing_amount']);
538 }elseif (!empty($_SESSION['listing_amount'])) $listing_amount=$_SESSION['listing_amount'];
539 else $listing_amount=DEFAULT_LISTING_AMOUNT
;
540 $smarty->assign('listing_amount',$listing_amount);
542 if (isset($_POST['listing_order']) && $_POST['listing_order']) {
543 $listing_order=mysql_real_escape_string($_POST['listing_order']);
544 } elseif (!empty($_SESSION['listing_order'])) $listing_order=$_SESSION['listing_order'];
545 else $listing_order=DEFAULT_LISTING_ORDER
;
546 $smarty->assign('listing_order',$listing_order);
548 if (isset ($_POST['get_children_offset']) && is_numeric($_POST['get_children_offset'])) {
549 $offset=$_POST['get_children_offset'];
550 } else { $offset=0; }
553 //movement forward and backward
554 // if ($listing_order=='asc' && !$offset) $offset=$descendant_count-$listing_amount;
556 if ($_POST['get_children_move']=='<') {
557 $offset=$offset-$listing_amount;
558 if ($offset<0) $offset=0;
560 elseif ($_POST['get_children_move']=='>') {
561 $offset=$offset+
$listing_amount;
563 elseif ($_POST['get_children_move']=='>>') {
564 $offset=$descendant_count-$listing_amount;
567 elseif ($_POST['get_children_move']=='<<') {
570 if ($offset<0) $offset=0;
571 $_POST['offset']=$offset;
572 $smarty->assign('offset',$offset);
575 if ($node['external_link']=='header://svg' && !is_numeric($template_id)) {
576 header("Content-Type: image/svg+xml");
580 elseif (isset($_SESSION['header_id']) && ($_SESSION['header_id']==true)) {
581 $smarty->assign('header_id',$_SESSION['header_id']);
582 $smarty->template_dir
=OWN_TEMPLATE_DIR
;
583 $content=$smarty->fetch($_SESSION['header_id'].".tpl");
584 $smarty->template_dir
= TEMPLATE_DIR
.TEMPLATE_SET
;
585 //not registered user
586 if ($_SESSION['header_id']==2091520) {
593 $smarty->template_dir
=OWN_TEMPLATE_DIR
;
595 if (is_numeric($template_id)) {
596 $content.=$smarty->fetch($template_id.".tpl");
600 $template_id=$node['template_id'];
601 $content.=$smarty->fetch($node['template_id'].".tpl");
604 if ($template_id=='2019721'){
605 $content=$smarty->fetch($template_id.".tpl");
608 $time=SubStr((Time()+
SubStr(MicroTime(),0,8)-$timer_start),0,7);
610 // echo "<center>page generation took: $time second</center>";
614 // output buffering forcing (mx)
615 if (!empty($_POST['FORCE_OB']) && $_POST['FORCE_OB'] == 'true') ob_end_flush();
This page took 0.76186 seconds and 5 git commands to generate.