2 //echo($_SERVER['PATH_INFO']."\n<pre>"); var_dump(preg_split('/\//', $_SERVER['PATH_INFO'])); die(); //PATH_INFO Debug (usefull when messing with mod_rewrite)
3 // output buffering forcing (mx)
4 if (!empty($_POST['FORCE_OB']) && $_POST['FORCE_OB'] == 'true') ob_start();
6 //header("Location: http://web.archive.org/web/20020925021139/http://kyberia.sk");
7 //echo "je to uz uplne v pici. vsetky data su stratene, prajem pekny den :)";
10 //starting timer for benchmarking purposes
11 $timer_start=Time()+
SubStr(MicroTime(),0,8);
13 //setting PHPSESSID cookie and starting user session
17 //$_SESSION['debugging']=1;
21 if ($_SESSION['debugging']) {
23 error_reporting(E_ALL
);
24 echo 'GET VARIABLES::<br/>';
26 echo 'POST VARIABLES::<br/>';
28 echo '<b>SESSION VARIABLES::</b><br/>';
33 //Path info (Experimental - this replaced most of mod_rewrites...)
34 @$PATH_INFO=trim($_SERVER[PATH_INFO
]);
35 if($PATH_INFO != '') {
36 $PATH_CHUNKS = preg_split('/\//', $PATH_INFO);
37 if(isset($PATH_CHUNKS[1])) switch($PATH_CHUNKS[1]) {
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];
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];
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];
53 //Base36 http://en.wikipedia.org/wiki/Base_36 (Initial support only :-)
54 if(isset($_GET['node_kid'])) $_GET['node_id'] = base_convert($_GET['node_kid'], 36, 10);
55 if(isset($_GET['template_kid'])) $_GET['template_id'] = base_convert($_GET['template_kid'], 36, 10);
57 //requiring main config file with path/database etc. constants
58 require('config/config.inc');
59 require(INCLUDE_DIR
.'senate.inc');
61 if (isset($_SERVER['HTTP_REFERER'])) {
62 preg_match('/(k|id)\/([0-9]*)\//',$_SERVER['HTTP_REFERER'],$ref_match);
63 $referer_id=$ref_match[1];
66 //connecting to database and creating universal $db object
67 require(INCLUDE_DIR
.'log.inc');
68 require(INCLUDE_DIR
.'ubik.inc');
69 require(INCLUDE_DIR
.'nodes.inc');
70 require(INCLUDE_DIR
.'error_messages.inc');
71 require(INCLUDE_DIR
.'database.inc');
73 $db = new CLASS_DATABASE();
75 if (!empty($_GET['template_id'])) {
76 $template_id=$_GET['template_id'];
81 //initializing node methods
82 if (!empty($_GET['node_name'])) {
83 $node = nodes
::redirByName($_GET['node_name']);
84 } elseif (!empty($_GET['node_id'])) {
85 $node = nodes
::getNodeById($_GET['node_id'],
86 (isset($_SESSION['user_id']))?
$_SESSION['user_id']:'');
89 //XXX Paths are wrong (!)
90 //loading smarty template engine and setting main parameters
91 require(SMARTY_DIR
.'Smarty.class.php');
94 //$smarty->php_handling = SMARTY_PHP_REMOVE; //XXX
95 $smarty->template_dir
= TEMPLATE_DIR
;
96 //echo TEMPLATE_DIR.TEMPLATE_SET;
97 //echo $smarty->template_dir;
98 $smarty->compile_dir
= SYSTEM_DATA
.'templates_c/';
99 $smarty->config_dir
= SMARTY_DIR
.'configs/'; //XXX neexistuje
100 $smarty->cache_dir
= SMARTY_DIR
.'cache/';
101 $smarty->plugins_dir
= SMARTY_PLUGIN_DIR
;
102 if ($_SESSION['debugging']) $smarty->debugging
=true;
104 // initializing variables
105 // preg_replace prevents LFI
106 if (empty($_POST['event'])) $event=false;
107 else $event= preg_replace( "![^a-zA-Z0-9_]+!", "", $_POST['event']);
110 if ($_SESSION['debugging']) {
111 echo "<pre><b>NODE::";
116 if ((isset($_SESSION['user_id']) && ($node['node_creator']==$_SESSION['user_id']))) {
117 $node['node_permission']='owner';
120 if (isset($_SESSION['cube_vector']) && ($_SESSION['cube_vector'])) {
121 if (strpos($node['node_vector'],$_SESSION['cube_vector'])===false) {
122 echo "node::".$node['node_vector'];
123 echo "cube_Vector::".$_SESSION['cube_vector'];
124 echo "you are out of allowed cwbe. access forbidden";
129 //if not existent node show our own 404
131 $nodes= nodes
::getNodesByName($_GET['node_name']);
133 $smarty->assign('nodes',$nodes);
134 $content=$smarty->display("404.tpl");
137 elseif ($_SESSION['user_id']) {
138 $smarty->assign('node_name',$_GET['node_name']);
139 $content=$smarty->display("modules/addnode.tpl");
143 //modifying node glass pearl //XXX WTF
144 if (is_array($children_types[$node['node_type']])) {
145 $smarty->assign('children_types',$children_types[$node['node_type']]);
147 $smarty->assign('types',$types);
150 //$node['node_type']=$types[$node['node_type']];
151 $node['node_content']= StripSlashes($node['node_content']);
152 $node['node_name']= StripSlashes($node['node_name']);
154 //checking permissions
155 function _checkPermissions()
157 global $permissions, $node;
159 require(INCLUDE_DIR
.'permissions.inc');
160 $permissions=permissions
::checkPermissions($node);
161 $permissions['h']=permissions
::isHierarch($node);
165 if ($template_id=='rss') //XXX WHAT?
167 $_feedType = "RSS0.91";
168 if (!is_numeric($_SESSION['user_id']))
170 if (!isset($_SERVER['PHP_AUTH_USER'])) {
171 header('WWW-Authenticate: Basic realm="Kyberia"');
172 header('HTTP/1.0 401 Unauthorized');
173 echo 'Cancel button';
178 require_once(EVENT_DIR
.'/login.inc');
179 $_POST['login'] = $_SERVER['PHP_AUTH_USER'];
180 $_POST['password'] = $_SERVER['PHP_AUTH_PW'];
181 $_POST['login_type'] = "name";
184 echo "Zle meno/heslo.";
193 if ($_GET['node_id']==='24' && $permissions['r'])
195 require_once(INCLUDE_DIR
.'/feedcreator.class.php');
197 $rss = new UniversalFeedCreator();
198 $rss->title
= "Kyberia mail";
199 $rss->description
= "";
200 $rss->link
= "https://". SYSTEM_URL
. "/id/24";
203 $query = "select date_format(mail.mail_timestamp,\"%e.%c. %k:%i:%s\") as cas,
204 userfrom.user_action as locationfrom_action,
205 userfrom.user_action_id as locationfrom_action_id,
206 userto.user_action as locationto_action,
207 userto.user_action_id as locationto_action_id,
208 userto.login as mail_to_name, userfrom.login as mail_from_name,
209 mail.* from mail left join users as userfrom on
210 mail_from=userfrom.user_id left join users as userto on mail_to=userto.user_id
211 where mail_user='$_SESSION[user_id]' and mail_to='$_SESSION[user_id]' order by mail_id desc limit 0,10";
213 $set = $db->query($query);
215 while($set->next()) {
216 $m = $set->getRecord();
217 if ($m['mail_to'] != $_SESSION['user_id'])
219 $item = new FeedItem();
220 $item->title
= $m['mail_from_name'];
221 $item->link
= "https://".SYSTEM_URL
."/id/24";
222 $item->description
= $m['mail_text'];
223 $rss->addItem($item);
227 elseif ($_GET['node_id']=='19' && $permissions['r'])
229 require_once(INCLUDE_DIR
.'/feedcreator.class.php');
231 $rss = new UniversalFeedCreator();
232 $rss->title
= "Kyberia bookmarks";
233 $rss->link
= "http://".SYSTEM_URL
."/id/19"; //XXX https ?
235 require_once(SMARTY_PLUGIN_DIR
.'/function.get_bookmarks.php');
236 smarty_function_get_bookmarks(array(), $smarty);
237 $_items = $smarty->get_template_vars('get_bookmarks');
238 foreach ($_items as $_item)
240 if (is_array($_item['children']))
241 foreach ($_item['children'] as $_b)
243 $item = new FeedItem();
244 $item->title
= $_b['node_name'];
245 $item->link
= "http://".SYSTEM_URL
."/id/".$_b['node_id']."/rss";
246 $rss->addItem($item);
251 elseif ($permissions['r'])
253 require_once(INCLUDE_DIR
.'/feedcreator.class.php');
255 $rss = new UniversalFeedCreator();
256 $rss->title
= $node['node_name'];
257 $rss->description
= "";
258 $rss->link
= "http://".SYSTEM_URL
."/id/".$node['node_id'];
261 if ($_GET['node_id']=='15')
263 require_once(SMARTY_PLUGIN_DIR
.'/function.get_k.php');
264 smarty_function_get_k(array(), $smarty);
265 $_items = $smarty->get_template_vars('get_k');
269 require_once(SMARTY_PLUGIN_DIR
.'/function.get_children.php');
270 smarty_function_get_children(
271 array('orderby' => 'desc', 'orderby_type' => 'time'), $smarty);
272 $_items = $smarty->get_template_vars('get_children');
275 foreach ($_items as $_item)
277 $item = new FeedItem();
278 $item->title
= $_item['node_name'];
279 $item->link
= "http://".SYSTEM_URL
."/id/".$_item['node_id'];
280 $item->description
= $_item['node_content'];
281 $rss->addItem($item);
285 if ($permissions['r']) $rss->showFeed($_feedType);
294 if (($permissions['r']) ||
($event != 'register')) {
296 //performing node_events (based on update/insert/delete db queries)
298 require(INCLUDE_DIR
.'eventz.inc');
301 elseif ($transaction) {
302 require(INCLUDE_DIR
.'transaction.inc');
304 //end of performing node events
310 if ($permissions['r']) {
312 // these 4 lines are not the source of kyberia lagging problems.
313 // leave them. started on the 10.4.
314 // data gained will be used for scientific purposes
316 // if (isset($_SESSION['user_id']) {
317 // log_levenshtein($_SESSION['user_id'],$node['node_id']);
320 if ((isset($_SESSION['user_id'])) && ($_SESSION['user_id'])) {
321 $q="insert delayed into levenshtein set user_id='".$_SESSION['user_id']."',node_id='".$node['node_id']."'";
327 if ($node['template_id']!='2019721'){
329 logger
::log('enter',$node['node_id'],'ok',$node['node_user_subchild_count']);
330 if (!empty($_SESSION['user_id']) && is_numeric($node['node_id'])) {
331 $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']."'";
333 $result=$db->update($q);
336 $q="insert into node_access set user_id='".$_SESSION['user_id']."',node_id='".$node['node_id']."',last_visit=NOW()";
339 }//end of if node os css
345 // if (isset($_SESSION['user_id']) {
346 // if (isset($referer_id)) {
347 // update_nodes($_SESSION['user_id'],$node['node_id'],$referer_id);
349 // update_nodes($_SESSION['user_id'],$node['node_id'],0);
353 // DO NOT MESS WITH THIS !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
354 //creating neural network
355 $db->update("update nodes set node_views=node_views+1 where node_id='".$node['node_id']."'");
356 if (isset($referer_id) && is_numeric($referer_id)) {
357 $q="update neurons set synapse=synapse+1 where dst='".$node['node_id']."' and src='$referer_id'";
358 $result=$db->update($q);
360 $q="insert into neurons set synapse_creator='".$_SESSION['user_id']."',dst='".$node['node_id']."',src='$referer_id',synapse=1";
366 elseif (!$permissions['r'] && $_GET['magic_word']) {
367 $magic_word_big=$_GET['magic_word'];
369 if ( preg_match("/(\d+)-(.+)/",$_GET['magic_word'],$mu)) {
371 $magic_word=addslashes($mu['2']);
372 // XXX WTF column magic_word does not exists
373 $q="select login from users where user_id='$magic_uid' and magic_word='$magic_word'";
375 if ($set->getNumRows()) {
376 $permissions['r']=true;
386 logger
::log('enter',$node['node_id'],'failed');
391 //assigning user data to smarty if user logged in
392 if (isset($_SESSION['user_id'])&&($user_id=$_SESSION['user_id'])) {
393 $smarty->assign('_POST',$_POST);
394 $smarty->assign('bookmarks',$_SESSION['bookmarks']);
395 $smarty->assign('ignore',$_SESSION['ignore']);
396 $smarty->assign('bookstyl',$_SESSION['bookstyl']);
397 $smarty->assign('fook',$_SESSION['fook']);
398 $smarty->assign('user_id',$_SESSION['user_id']);
399 if (!empty($_SESSION['cube_vector']))
400 $smarty->assign('cube_vector',$_SESSION['cube_vector']);
401 $smarty->assign('friends',$_SESSION['friends']); //req by freezy, done by darkaural
402 $smarty->assign('user_quota',$_SESSION['user_quota']);
405 $newmail_q = sprintf('select u.user_mail_id
409 , ms.user_id as mail_sender_id
410 , ms.login as mail_sender
412 left join users ms on ms.user_id = u.user_mail_id
413 where u.user_id = %d',
415 $newmailset = $db->query($newmail_q);
419 $new_mail=$newmailset->getString('user_mail');
421 $newmailset2 = $db->query("select users.user_mail_id,mailsender.login
422 from users left join users as mailsender on users.user_mail_id = mailsender.user_id where users.user_id = '$user_id'");
423 $newmailset2->next();
424 $smarty->assign('new_mail',$new_mail);
425 $smarty->assign('new_mail_name',$newmailset->getString('mail_sender'));
426 $smarty->assign('new_mail_name2',$newmailset2->getString('login'));
427 $user_k=$newmailset->getString('user_k');
428 $smarty->assign('user_k',$user_k);
429 $k_wallet=$newmailset->getString('k_wallet');
430 $smarty->assign('k_wallet',$k_wallet);
431 $user_id=$_SESSION['user_id'];
434 if ($node['node_name']=='mail') {
436 //clear new mail message
438 if ($new_mail) $db->query("update users set user_mail=0 where user_id='$user_id'");
440 //set messages as delivered to recipient
441 $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'");
442 while($set->next()) {
443 $db->query("update mail set mail_read='yes' where mail_id='".$set->getString('mail_duplicate_id')."'");
444 $db->query("update mail set mail_read='yes' where mail_id='".$set->getString('mail_id')."'");
446 $new_messages[$set->getString('mail_id')]=true;
449 if (count($new_messages)) {
450 $db->query("update mail set mail_read='yes' where mail_user='$user_id' and mail_user=mail_to and mail_read='no'");
451 $smarty->assign('new_messages',$new_messages);
460 if ($node['node_system_access']=='crypto') {
461 $smarty->assign('crypto_pass',$_SESSION['crypto'][$node['node_id']]);
464 $smarty->assign('error',$error);
465 $smarty->assign('permissions',$permissions);
466 $smarty->assign('current_vector',$node['node_vector']);
467 if ($permissions['r']) $smarty->assign('node',$node);
470 $smarty->assign('node',$node);
471 //new templates by Dark matter
472 $smarty->template_dir
=OWN_TEMPLATE_DIR
;
474 $smarty->display('1549864.tpl');
475 $smarty->display('1549885.tpl');
476 $smarty->display('630526.tpl');
479 //redirect to mainpage
480 // looks like poeple totaly hate this redirect!
481 // header("Location: /id/1");
486 if (($node['template_id']!='2019721') && (isset($_SESSION['user_id']))){
487 //setting user location
488 $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']."'";
489 $db->executequery($q);
492 $whole_time=SubStr((Time()+
SubStr(MicroTime(),0,8)-$timer_start),0,7);
493 $smarty->assign('whole_time',$whole_time);
496 if ($template_id=='download' OR $template_id=='download.jpg') {
497 if ($permissions['r']) {
498 $linkname = SYSTEM_ROOT
."/files/".$node['node_id'];
499 $filename= readlink($linkname);
500 $suffix=preg_replace("/(.*?)\.(.*?)/i","$2",$filename);
502 $ext = substr( $filename,-3 );
503 if( $filename == "" ) {
504 echo "ERROR: Empty file to download. ";
506 } elseif ( ! file_exists( $filename ) ) {
509 switch( strtolower($ext) ){
510 case "pdf": $ctype="application/pdf"; break;
511 case "exe": $ctype="application/octet-stream"; break;
512 case "zip": $ctype="application/zip"; break;
513 case "doc": $ctype="application/msword"; break;
514 case "xls": $ctype="application/vnd.ms-excel"; break;
515 case "ppt": $ctype="application/vnd.ms-powerpoint"; break;
516 case "gif": $ctype="image/gif"; break;
517 case "png": $ctype="image/png"; break;
518 case "jpg": $ctype="image/jpg"; break;
519 default: $ctype="application/force-download";
521 $file=str_replace(" ","_",$node['node_name']).".$ext";
522 header("Pragma: public");
523 header("Expires: 0");
524 header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
525 header("Content-Type: $ctype");
526 $user_agent = strtolower ($_SERVER["HTTP_USER_AGENT"]);
527 if ((is_integer (strpos($user_agent, "msie"))) && (is_integer
528 (strpos($user_agent, "win")))) {
529 header( "Content-Disposition: filename=$file;" );
531 header( "Content-Disposition: attachment;
534 header("Content-Transfer-Encoding: binary");
535 header("Content-Length: ".filesize($filename));
536 readfile("$filename");
539 else { echo "you don't have permissions for downloading this data"; die(); }
542 if ($node['template_id']=='2019721'){
543 Header("Cache-control: max-age=3600");
545 Header("Cache-control: no-cache");
546 Header("Expires:".gmdate("D, d M Y H:i:s")." GMT");
547 header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
551 //for cases like search & preview
552 $smarty->assign('post_vars',$_POST);
553 if (!empty($_POST['template_event'])) {
554 $smarty->assign('template_event',$_POST['template_event']);
558 //setting listing parameters
559 $children_count=$node['node_children_count'];
560 $descendant_count=$node['node_descendant_count'];
562 if (isset($_POST['listing_amount']) && is_numeric($_POST['listing_amount'])) {
563 $listing_amount=mysql_real_escape_string($_POST['listing_amount']);
564 }elseif (!empty($_SESSION['listing_amount'])) $listing_amount=$_SESSION['listing_amount'];
565 else $listing_amount=DEFAULT_LISTING_AMOUNT
;
566 $smarty->assign('listing_amount',$listing_amount);
568 if (isset($_POST['listing_order']) && $_POST['listing_order']) {
569 $listing_order=mysql_real_escape_string($_POST['listing_order']);
570 } elseif (!empty($_SESSION['listing_order'])) $listing_order=$_SESSION['listing_order'];
571 else $listing_order=DEFAULT_LISTING_ORDER
;
572 $smarty->assign('listing_order',$listing_order);
574 if (isset ($_POST['get_children_offset']) && is_numeric($_POST['get_children_offset'])) {
575 $offset=$_POST['get_children_offset'];
576 } else { $offset=0; }
579 //movement forward and backward
580 // if ($listing_order=='asc' && !$offset) $offset=$descendant_count-$listing_amount;
582 if ($_POST['get_children_move']=='<') {
583 $offset=$offset-$listing_amount;
584 if ($offset<0) $offset=0;
586 elseif ($_POST['get_children_move']=='>') {
587 $offset=$offset+
$listing_amount;
589 elseif ($_POST['get_children_move']=='>>') {
590 $offset=$descendant_count-$listing_amount;
593 elseif ($_POST['get_children_move']=='<<') {
596 if ($offset<0) $offset=0;
597 $_POST['offset']=$offset;
598 $smarty->assign('offset',$offset);
601 if ($node['external_link']=='header://svg' && !is_numeric($template_id)) {
602 header("Content-Type: image/svg+xml");
606 elseif (isset($_SESSION['header_id']) && ($_SESSION['header_id']==true)) {
607 $smarty->assign('header_id',$_SESSION['header_id']);
608 $smarty->template_dir
=OWN_TEMPLATE_DIR
;
609 $content=$smarty->fetch($_SESSION['header_id'].".tpl");
610 $smarty->template_dir
= TEMPLATE_DIR
.TEMPLATE_SET
;
611 //not registered user
612 if ($_SESSION['header_id']==2091520) {
619 $smarty->template_dir
=OWN_TEMPLATE_DIR
;
621 if (is_numeric($template_id)) {
622 $content.=$smarty->fetch($template_id.".tpl");
626 $template_id=$node['template_id'];
627 $content.=$smarty->fetch($node['template_id'].".tpl");
630 if ($template_id=='2019721'){
631 $content=$smarty->fetch($template_id.".tpl");
634 $time=SubStr((Time()+
SubStr(MicroTime(),0,8)-$timer_start),0,7);
636 // echo "<center>page generation took: $time second</center>";
640 // output buffering forcing (mx)
641 if (!empty($_POST['FORCE_OB']) && $_POST['FORCE_OB'] == 'true') ob_end_flush();
This page took 0.732447 seconds and 5 git commands to generate.