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 :)";
11 //starting timer for benchmarking purposes
12 $timer_start=Time()+
SubStr(MicroTime(),0,8);
14 //setting PHPSESSID cookie and starting user session
18 if ($_SESSION['debugging']) {
20 error_reporting(E_ALL
);
21 echo "GET VARIABLES::<br/>";
23 echo "POST VARIABLES::<br/>";
25 echo "<b>SESSION VARIABLES::</b><br/>";
29 //requiring main config file with path/database etc. constants
30 require('config/config.inc');
31 require(INCLUDE_DIR
.'senate.inc');
33 preg_match("/id\/(.*)\//",$_SERVER['HTTP_REFERER'],$ref_match);
34 $referer_id=$ref_match[1];
36 //connecting to database and creating universal $db object
37 require(INCLUDE_DIR
.'log.inc');
38 require(INCLUDE_DIR
.'ubik.inc');
39 require(INCLUDE_DIR
.'nodes.inc');
40 require(INCLUDE_DIR
.'error_messages.inc');
41 require(INCLUDE_DIR
.'database.inc');
43 $db=new CLASS_DATABASE();
45 if (!empty($_GET['template_id'])) {
46 $template_id=$_GET['template_id'];
48 else $template_id=false;
50 //initializing node methods
51 if (!empty($_GET['node_name'])) {
52 //omfg what's this! jail , jail, penalty of death!
53 // reopened by [CENSORED], keep this in secret, then you can benefit from it..
54 if(strpos($_GET['node_name'],'0')===0) {
55 $numbah=$_GET['node_name'];
56 $db->query("set character_set_connection=latin2");
57 $set=$db->query("select * from tz.gts where full_number='$numbah'");
59 echo $set->getString('full_name')."<br>";
60 echo $set->getString('full_street')."<br>";
61 echo $set->getString('city')."<br>";
62 echo $set->getString('psc')."<br>";
63 echo $set->getString('company')."<br>";
68 else $node = nodes
::redirByName($_GET['node_name']);
70 $node = nodes
::redirByName($_GET['node_name']);
72 elseif (!empty($_GET['node_id'])) {
73 $node = nodes
::getNodeById($_GET['node_id'],$_SESSION['user_id']);
76 //loading smarty template engine and setting main parameters
77 require(SMARTY_DIR
.'Smarty.class.php');
80 $smarty->template_dir
= TEMPLATE_DIR
.TEMPLATE_SET
;
81 //echo TEMPLATE_DIR.TEMPLATE_SET;
82 //echo $smarty->template_dir;
83 $smarty->compile_dir
= SYSTEM_ROOT
."data/templates_c/".TEMPLATE_SET
;
84 $smarty->config_dir
= SMARTY_DIR
.'configs/';
85 $smarty->cache_dir
= SMARTY_DIR
.'cache/';
86 $smarty->plugins_dir
= SMARTY_PLUGIN_DIR
;
87 if ($_SESSION['debugging']) $smarty->debugging
=true;
89 //initializing variables
90 if (empty($_POST['event'])) $event=false;
91 else $event=$_POST['event'];
94 if ($_SESSION['debugging']) {
95 echo "<pre><b>NODE::";
100 if ($node['node_creator']==$_SESSION['user_id']) $node['node_permission']='owner';
102 if ($_SESSION['cube_vector']) {
103 if (strpos($node['node_vector'],$_SESSION['cube_vector'])===false) {
104 echo "node::".$node['node_vector'];
105 echo "cube_Vector::".$_SESSION['cube_vector'];
106 echo "you are out of allowed cwbe. access forbidden";
111 //if not existent node show our own 404
113 $nodes= nodes
::getNodesByName($_GET['node_name']);
115 $smarty->assign('nodes',$nodes);
116 $content=$smarty->display("404.tpl");
119 elseif ($_SESSION['user_id']) {
120 $smarty->assign('node_name',$_GET['node_name']);
121 $content=$smarty->display("modules/addnode.tpl");
125 //modifying node glass pearl
126 if (is_array($children_types[$node['node_type']])) $smarty->assign('children_types',$children_types[$node['node_type']]);
127 $smarty->assign('types',$types);
130 //$node['node_type']=$types[$node['node_type']];
131 $node['node_content']=StripSlashes($node['node_content']);
132 $node['node_name']=StripSlashes($node['node_name']);
134 //checking permissions
135 function _checkPermissions()
137 global $permissions, $node;
139 require(SYSTEM_ROOT
.'inc/permissions.inc');
140 $permissions=permissions
::checkPermissions($node);
141 $permissions['h']=permissions
::isHierarch($node);
145 if ($template_id=='rss')
147 $_feedType = "RSS0.91";
148 if (!is_numeric($_SESSION['user_id']))
150 if (!isset($_SERVER['PHP_AUTH_USER'])) {
151 header('WWW-Authenticate: Basic realm="Kyberia"');
152 header('HTTP/1.0 401 Unauthorized');
153 echo 'Cancel button';
158 require_once(EVENT_DIR
.'/login.inc');
159 $_POST['login'] = $_SERVER['PHP_AUTH_USER'];
160 $_POST['password'] = $_SERVER['PHP_AUTH_PW'];
161 $_POST['login_type'] = "name";
164 echo "Zle meno/heslo.";
173 if ($_GET['node_id']==='24' && $permissions['r'])
175 require_once(INCLUDE_DIR
.'/feedcreator.class.php');
177 $rss =& new UniversalFeedCreator();
178 $rss->title
= "Kyberia mail";
179 $rss->description
= "";
180 $rss->link
= "https://kyberia.sk/id/24";
182 $query = "select date_format(mail.mail_timestamp,\"%e.%c. %k:%i:%s\") as cas,
183 userfrom.user_action as locationfrom_action,
184 userfrom.user_action_id as locationfrom_action_id,
185 userto.user_action as locationto_action,
186 userto.user_action_id as locationto_action_id,
187 userto.login as mail_to_name, userfrom.login as mail_from_name,
188 mail.* from mail left join users as userfrom on
189 mail_from=userfrom.user_id left join users as userto on mail_to=userto.user_id
190 where mail_user='$_SESSION[user_id]' and mail_to='$_SESSION[user_id]' order by mail_id desc limit 0,10";
192 $set = $db->query($query);
194 while($set->next()) {
195 $m = $set->getRecord();
196 if ($m['mail_to'] != $_SESSION['user_id'])
198 $item =& new FeedItem();
199 $item->title
= $m['mail_from_name'];
200 $item->link
= "https://kyberia.sk/id/24";
201 $item->description
= $m['mail_text'];
202 $rss->addItem($item);
206 elseif ($_GET['node_id']=='19' && $permissions['r'])
208 require_once(INCLUDE_DIR
.'/feedcreator.class.php');
210 $rss =& new UniversalFeedCreator();
211 $rss->title
= "Kyberia bookmarks";
212 $rss->link
= "http://kyberia.sk/id/19";
214 require_once(SMARTY_PLUGIN_DIR
.'/function.get_bookmarks.php');
215 smarty_function_get_bookmarks(array(), $smarty);
216 $_items = $smarty->get_template_vars('get_bookmarks');
217 foreach ($_items as $_item)
219 if (is_array($_item['children']))
220 foreach ($_item['children'] as $_b)
222 $item =& new FeedItem();
223 $item->title
= $_b['node_name'];
224 $item->link
= "http://kyberia.sk/id/".$_b['node_id']."/rss";
225 $rss->addItem($item);
230 elseif ($permissions['r'])
232 require_once(INCLUDE_DIR
.'/feedcreator.class.php');
234 $rss =& new UniversalFeedCreator();
235 $rss->title
= $node['node_name'];
236 $rss->description
= "";
237 $rss->link
= "http://kyberia.sk/id/".$node['node_id'];
240 if ($_GET['node_id']=='15')
242 require_once(SMARTY_PLUGIN_DIR
.'/function.get_k.php');
243 smarty_function_get_k(array(), $smarty);
244 $_items = $smarty->get_template_vars('get_k');
248 require_once(SMARTY_PLUGIN_DIR
.'/function.get_children.php');
249 smarty_function_get_children(
250 array('orderby' => 'desc', 'orderby_type' => 'time'), $smarty);
251 $_items = $smarty->get_template_vars('get_children');
254 foreach ($_items as $_item)
256 $item =& new FeedItem();
257 $item->title
= $_item['node_name'];
258 $item->link
= "http://kyberia.sk/id/".$_item['node_id'];
259 $item->description
= $_item['node_content'];
260 $rss->addItem($item);
264 if ($permissions['r']) $rss->showFeed($_feedType);
273 if (($permissions['r']) ||
($event != 'register')) {
275 //performing node_events (based on update/insert/delete db queries)
277 require(SYSTEM_ROOT
.'inc/eventz.inc');
280 elseif ($transaction) {
281 require(SYSTEM_ROOT
.'inc/transaction.inc');
283 //end of performing node events
289 if ($permissions['r']) {
291 //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
292 if ($_SESSION['user_id']) {
293 $q="insert delayed into levenshtein set user_id='".$_SESSION['user_id']."',node_id='".$node['node_id']."'";
298 if ($node['template_id']!='2019721'){
300 log
::log('enter',$node['node_id'],'ok',$node['node_user_subchild_count']);
301 if (!empty($_SESSION['user_id']) && is_numeric($node['node_id'])) {
302 $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']."'";
304 $result=$db->update($q);
307 $q="insert into node_access set user_id='".$_SESSION['user_id']."',node_id='".$node['node_id']."',last_visit=NOW()";
310 }//end of if node os css
315 // DO NOT MESS WITH THIS !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
316 //creating neural network
317 $db->update("update nodes set node_views=node_views+1 where node_id='".$node['node_id']."'");
318 if (is_numeric($referer_id)) {
319 $q="update neurons set synapse=synapse+1 where dst='".$node['node_id']."' and src='$referer_id'";
320 $result=$db->update($q);
322 $q="insert into neurons set synapse_creator='".$_SESSION['user_id']."',dst='".$node['node_id']."',src='$referer_id',synapse=1";
328 elseif (!$permissions['r'] && $_GET['magic_word']) {
329 $magic_word_big=$_GET['magic_word'];
331 if ( preg_match("/(\d+)-(.+)/",$_GET['magic_word'],$mu)) {
333 $magic_word=addslashes($mu['2']);
334 $q="select login from users where user_id='$magic_uid' and magic_word='$magic_word'";
336 if ($set->getNumRows()) {
337 $permissions['r']=true;
347 log
::log('enter',$node['node_id'],'failed');
352 //assigning user data to smarty if user logged in
353 if ($user_id=$_SESSION['user_id']) {
354 $smarty->assign('_POST',$_POST);
355 $smarty->assign('bookmarks',$_SESSION['bookmarks']);
356 $smarty->assign('ignore',$_SESSION['ignore']);
357 $smarty->assign('bookstyl',$_SESSION['bookstyl']);
358 $smarty->assign('fook',$_SESSION['fook']);
359 $smarty->assign('user_id',$_SESSION['user_id']);
360 if (!empty($_SESSION['cube_vector'])) $smarty->assign('cube_vector',$_SESSION['cube_vector']);
361 $smarty->assign('friends',$_SESSION['friends']); //req by freezy, done by darkaural
362 $smarty->assign('user_quota',$_SESSION['user_quota']);
363 $newmailset=$db->query("select user_mail,user_mail_name,user_k,k_wallet from users where user_id='$user_id'");
365 $new_mail=$newmailset->getString('user_mail');
366 $newmailset2 = $db->query("select users.user_mail_id,mailsender.login
367 from users left join users as mailsender on users.user_mail_id = mailsender.user_id where users.user_id = '$user_id'");
368 $newmailset2->next();
369 $smarty->assign('new_mail',$new_mail);
370 $smarty->assign('new_mail_name',$newmailset->getString('user_mail_name'));
371 $smarty->assign('new_mail_name2',$newmailset2->getString('login'));
372 $user_k=$newmailset->getString('user_k');
373 $smarty->assign('user_k',$user_k);
374 $k_wallet=$newmailset->getString('k_wallet');
375 $smarty->assign('k_wallet',$k_wallet);
376 $user_id=$_SESSION['user_id'];
379 if ($node['node_name']=='mail') {
381 //clear new mail message
382 if ($new_mail) $db->query("update users set user_mail=0 where user_id='$user_id'");
384 //set messages as delivered to recipient
385 $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'");
386 while($set->next()) {
387 $db->query("update mail set mail_read='yes' where mail_id='".$set->getString('mail_duplicate_id')."'");
388 $db->query("update mail set mail_read='yes' where mail_id='".$set->getString('mail_id')."'");
390 $new_messages[$set->getString('mail_id')]=true;
393 if (count($new_messages)) {
394 $db->query("update mail set mail_read='yes' where mail_user='$user_id' and mail_user=mail_to and mail_read='no'");
395 $smarty->assign('new_messages',$new_messages);
404 if ($node['node_system_access']=='crypto') {
405 $smarty->assign('crypto_pass',$_SESSION['crypto'][$node['node_id']]);
409 //$error .= "ocakavajte planovany vypadok okolo 6 hodiny <br>
410 //s pozdravom br .)";
411 //$error .= "dnes od 22:00 zurka v subclube! ucast povinna!";
413 $smarty->assign('error',$error);
414 $smarty->assign('permissions',$permissions);
415 $smarty->assign('current_vector',$node['node_vector']);
416 if ($permissions['r']) $smarty->assign('node',$node);
419 $smarty->assign('node',$node);
420 //new templates by Dark matter
421 $smarty->template_dir
=OWN_TEMPLATE_DIR
;
423 $smarty->display('1549864.tpl');
424 $smarty->display('1549885.tpl');
425 $smarty->display('630526.tpl');
428 //redirect to mainpage
429 // looks like poeple totaly hate this redirect!
430 // header("Location: /id/1");
434 if ($node['template_id']!='2019721'){
435 //setting user location
436 $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']."'";
437 $db->executequery($q);
440 $whole_time=SubStr((Time()+
SubStr(MicroTime(),0,8)-$timer_start),0,7);
441 $smarty->assign('whole_time',$whole_time);
444 if ($template_id=='download' OR $template_id=='download.jpg') {
445 if ($permissions['r']) {
446 $linkname = SYSTEM_ROOT
."/files/".$node['node_id'];
447 $filename= readlink($linkname);
448 $suffix=preg_replace("/(.*?)\.(.*?)/i","$2",$filename);
450 $ext = substr( $filename,-3 );
451 if( $filename == "" ) {
452 echo "ERROR: Empty file to download. ";
454 } elseif ( ! file_exists( $filename ) ) {
457 switch( strtolower($ext) ){
458 case "pdf": $ctype="application/pdf"; break;
459 case "exe": $ctype="application/octet-stream"; break;
460 case "zip": $ctype="application/zip"; break;
461 case "doc": $ctype="application/msword"; break;
462 case "xls": $ctype="application/vnd.ms-excel"; break;
463 case "ppt": $ctype="application/vnd.ms-powerpoint"; break;
464 case "gif": $ctype="image/gif"; break;
465 case "png": $ctype="image/png"; break;
466 case "jpg": $ctype="image/jpg"; break;
467 default: $ctype="application/force-download";
469 $file=str_replace(" ","_",$node['node_name']).".$ext";
470 header("Pragma: public");
471 header("Expires: 0");
472 header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
473 header("Content-Type: $ctype");
474 $user_agent = strtolower ($_SERVER["HTTP_USER_AGENT"]);
475 if ((is_integer (strpos($user_agent, "msie"))) && (is_integer
476 (strpos($user_agent, "win")))) {
477 header( "Content-Disposition: filename=$file;" );
479 header( "Content-Disposition: attachment;
482 header("Content-Transfer-Encoding: binary");
483 header("Content-Length: ".filesize($filename));
484 readfile("$filename");
487 else { echo "you don't have permissions for downloading this data"; die(); }
490 if ($node['template_id']=='2019721'){
491 Header("Cache-control: max-age=3600");
493 Header("Cache-control: no-cache");
494 Header("Expires:".gmdate("D, d M Y H:i:s")." GMT");
495 header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
499 //for cases like search & preview
500 $smarty->assign('post_vars',$_POST);
501 if (!empty($_POST['template_event'])) {
502 $smarty->assign('template_event',$_POST['template_event']);
506 //setting listing parameters
507 $children_count=$node['node_children_count'];
508 $descendant_count=$node['node_descendant_count'];
510 if (is_numeric($_POST['listing_amount'])) $listing_amount=$_POST['listing_amount'];
511 elseif (!empty($_SESSION['listing_amount'])) $listing_amount=$_SESSION['listing_amount'];
512 else $listing_amount=DEFAULT_LISTING_AMOUNT
;
513 $smarty->assign('listing_amount',$listing_amount);
515 if ($_POST['listing_order']) $listing_order=$_POST['listing_order'];
516 elseif (!empty($_SESSION['listing_order'])) $listing_order=$_SESSION['listing_order'];
517 else $listing_order=DEFAULT_LISTING_ORDER
;
518 $smarty->assign('listing_order',$listing_order);
520 if (is_numeric($_POST['get_children_offset'])) $offset=$_POST['get_children_offset'];
524 //movement forward and backward
525 // if ($listing_order=='asc' && !$offset) $offset=$descendant_count-$listing_amount;
527 if ($_POST['get_children_move']=='<') {
528 $offset=$offset-$listing_amount;
529 if ($offset<0) $offset=0;
531 elseif ($_POST['get_children_move']=='>') {
532 $offset=$offset+
$listing_amount;
534 elseif ($_POST['get_children_move']=='>>') {
535 $offset=$descendant_count-$listing_amount;
538 elseif ($_POST['get_children_move']=='<<') {
541 if ($offset<0) $offset=0;
542 $_POST['offset']=$offset;
543 $smarty->assign('offset',$offset);
546 if ($node['external_link']=='header://svg' && !is_numeric($template_id)) {
547 header("Content-Type: image/svg+xml");
551 elseif ($_SESSION['header_id']==true) {
552 $smarty->assign('header_id',$_SESSION['header_id']);
553 $smarty->template_dir
=OWN_TEMPLATE_DIR
;
554 $content=$smarty->fetch($_SESSION['header_id'].".tpl");
555 $smarty->template_dir
= TEMPLATE_DIR
.TEMPLATE_SET
;
556 //not registered user
557 if ($_SESSION['header_id']==2091520) {
564 $smarty->template_dir
=OWN_TEMPLATE_DIR
;
566 if (is_numeric($template_id)) {
567 $content.=$smarty->fetch($template_id.".tpl");
571 $template_id=$node['template_id'];
572 $content.=$smarty->fetch($node['template_id'].".tpl");
575 if ($template_id=='2019721'){
576 $content=$smarty->fetch($template_id.".tpl");
579 $time=SubStr((Time()+
SubStr(MicroTime(),0,8)-$timer_start),0,7);
581 // echo "<center>page generation took: $time second</center>";
585 // output buffering forcing (mx)
586 if (!empty($_POST['FORCE_OB']) && $_POST['FORCE_OB'] == 'true') ob_end_flush();
This page took 0.711819 seconds and 4 git commands to generate.