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 $node = nodes
::redirByName($_GET['node_name']);
54 elseif (!empty($_GET['node_id'])) {
55 $node = nodes
::getNodeById($_GET['node_id'],$_SESSION['user_id']);
58 //loading smarty template engine and setting main parameters
59 require(SMARTY_DIR
.'Smarty.class.php');
62 $smarty->template_dir
= TEMPLATE_DIR
.TEMPLATE_SET
;
63 //echo TEMPLATE_DIR.TEMPLATE_SET;
64 //echo $smarty->template_dir;
65 $smarty->compile_dir
= SYSTEM_ROOT
."data/templates_c/".TEMPLATE_SET
;
66 $smarty->config_dir
= SMARTY_DIR
.'configs/';
67 $smarty->cache_dir
= SMARTY_DIR
.'cache/';
68 $smarty->plugins_dir
= SMARTY_PLUGIN_DIR
;
69 if ($_SESSION['debugging']) $smarty->debugging
=true;
71 //initializing variables
72 if (empty($_POST['event'])) $event=false;
73 else $event=$_POST['event'];
76 if ($_SESSION['debugging']) {
77 echo "<pre><b>NODE::";
82 if ($node['node_creator']==$_SESSION['user_id']) $node['node_permission']='owner';
84 if ($_SESSION['cube_vector']) {
85 if (strpos($node['node_vector'],$_SESSION['cube_vector'])===false) {
86 echo "node::".$node['node_vector'];
87 echo "cube_Vector::".$_SESSION['cube_vector'];
88 echo "you are out of allowed cwbe. access forbidden";
93 //if not existent node show our own 404
95 $nodes= nodes
::getNodesByName($_GET['node_name']);
97 $smarty->assign('nodes',$nodes);
98 $content=$smarty->display("404.tpl");
101 elseif ($_SESSION['user_id']) {
102 $smarty->assign('node_name',$_GET['node_name']);
103 $content=$smarty->display("modules/addnode.tpl");
107 //modifying node glass pearl
108 if (is_array($children_types[$node['node_type']])) $smarty->assign('children_types',$children_types[$node['node_type']]);
109 $smarty->assign('types',$types);
112 //$node['node_type']=$types[$node['node_type']];
113 $node['node_content']=StripSlashes($node['node_content']);
114 $node['node_name']=StripSlashes($node['node_name']);
116 //checking permissions
117 function _checkPermissions()
119 global $permissions, $node;
121 require(SYSTEM_ROOT
.'inc/permissions.inc');
122 $permissions=permissions
::checkPermissions($node);
123 $permissions['h']=permissions
::isHierarch($node);
127 if ($template_id=='rss')
129 $_feedType = "RSS0.91";
130 if (!is_numeric($_SESSION['user_id']))
132 if (!isset($_SERVER['PHP_AUTH_USER'])) {
133 header('WWW-Authenticate: Basic realm="Kyberia"');
134 header('HTTP/1.0 401 Unauthorized');
135 echo 'Cancel button';
140 require_once(EVENT_DIR
.'/login.inc');
141 $_POST['login'] = $_SERVER['PHP_AUTH_USER'];
142 $_POST['password'] = $_SERVER['PHP_AUTH_PW'];
143 $_POST['login_type'] = "name";
146 echo "Zle meno/heslo.";
155 if ($_GET['node_id']==='24' && $permissions['r'])
157 require_once(INCLUDE_DIR
.'/feedcreator.class.php');
159 $rss =& new UniversalFeedCreator();
160 $rss->title
= "Kyberia mail";
161 $rss->description
= "";
162 $rss->link
= "https://kyberia.sk/id/24";
164 $query = "select date_format(mail.mail_timestamp,\"%e.%c. %k:%i:%s\") as cas,
165 userfrom.user_action as locationfrom_action,
166 userfrom.user_action_id as locationfrom_action_id,
167 userto.user_action as locationto_action,
168 userto.user_action_id as locationto_action_id,
169 userto.login as mail_to_name, userfrom.login as mail_from_name,
170 mail.* from mail left join users as userfrom on
171 mail_from=userfrom.user_id left join users as userto on mail_to=userto.user_id
172 where mail_user='$_SESSION[user_id]' and mail_to='$_SESSION[user_id]' order by mail_id desc limit 0,10";
174 $set = $db->query($query);
176 while($set->next()) {
177 $m = $set->getRecord();
178 if ($m['mail_to'] != $_SESSION['user_id'])
180 $item =& new FeedItem();
181 $item->title
= $m['mail_from_name'];
182 $item->link
= "https://kyberia.sk/id/24";
183 $item->description
= $m['mail_text'];
184 $rss->addItem($item);
188 elseif ($_GET['node_id']=='19' && $permissions['r'])
190 require_once(INCLUDE_DIR
.'/feedcreator.class.php');
192 $rss =& new UniversalFeedCreator();
193 $rss->title
= "Kyberia bookmarks";
194 $rss->link
= "http://kyberia.sk/id/19";
196 require_once(SMARTY_PLUGIN_DIR
.'/function.get_bookmarks.php');
197 smarty_function_get_bookmarks(array(), $smarty);
198 $_items = $smarty->get_template_vars('get_bookmarks');
199 foreach ($_items as $_item)
201 if (is_array($_item['children']))
202 foreach ($_item['children'] as $_b)
204 $item =& new FeedItem();
205 $item->title
= $_b['node_name'];
206 $item->link
= "http://kyberia.sk/id/".$_b['node_id']."/rss";
207 $rss->addItem($item);
212 elseif ($permissions['r'])
214 require_once(INCLUDE_DIR
.'/feedcreator.class.php');
216 $rss =& new UniversalFeedCreator();
217 $rss->title
= $node['node_name'];
218 $rss->description
= "";
219 $rss->link
= "http://kyberia.sk/id/".$node['node_id'];
222 if ($_GET['node_id']=='15')
224 require_once(SMARTY_PLUGIN_DIR
.'/function.get_k.php');
225 smarty_function_get_k(array(), $smarty);
226 $_items = $smarty->get_template_vars('get_k');
230 require_once(SMARTY_PLUGIN_DIR
.'/function.get_children.php');
231 smarty_function_get_children(
232 array('orderby' => 'desc', 'orderby_type' => 'time'), $smarty);
233 $_items = $smarty->get_template_vars('get_children');
236 foreach ($_items as $_item)
238 $item =& new FeedItem();
239 $item->title
= $_item['node_name'];
240 $item->link
= "http://kyberia.sk/id/".$_item['node_id'];
241 $item->description
= $_item['node_content'];
242 $rss->addItem($item);
246 if ($permissions['r']) $rss->showFeed($_feedType);
255 if (($permissions['r']) ||
($event != 'register')) {
257 //performing node_events (based on update/insert/delete db queries)
259 require(SYSTEM_ROOT
.'inc/eventz.inc');
262 elseif ($transaction) {
263 require(SYSTEM_ROOT
.'inc/transaction.inc');
265 //end of performing node events
271 if ($permissions['r']) {
273 //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
274 if ($_SESSION['user_id']) {
275 $q="insert delayed into levenshtein set user_id='".$_SESSION['user_id']."',node_id='".$node['node_id']."'";
280 if ($node['template_id']!='2019721'){
282 log
::log('enter',$node['node_id'],'ok',$node['node_user_subchild_count']);
283 if (!empty($_SESSION['user_id']) && is_numeric($node['node_id'])) {
284 $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']."'";
286 $result=$db->update($q);
289 $q="insert into node_access set user_id='".$_SESSION['user_id']."',node_id='".$node['node_id']."',last_visit=NOW()";
292 }//end of if node os css
297 // DO NOT MESS WITH THIS !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
298 //creating neural network
299 $db->update("update nodes set node_views=node_views+1 where node_id='".$node['node_id']."'");
300 if (is_numeric($referer_id)) {
301 $q="update neurons set synapse=synapse+1 where dst='".$node['node_id']."' and src='$referer_id'";
302 $result=$db->update($q);
304 $q="insert into neurons set synapse_creator='".$_SESSION['user_id']."',dst='".$node['node_id']."',src='$referer_id',synapse=1";
310 elseif (!$permissions['r'] && $_GET['magic_word']) {
311 $magic_word_big=$_GET['magic_word'];
313 if ( preg_match("/(\d+)-(.+)/",$_GET['magic_word'],$mu)) {
315 $magic_word=addslashes($mu['2']);
316 $q="select login from users where user_id='$magic_uid' and magic_word='$magic_word'";
318 if ($set->getNumRows()) {
319 $permissions['r']=true;
329 log
::log('enter',$node['node_id'],'failed');
334 //assigning user data to smarty if user logged in
335 if ($user_id=$_SESSION['user_id']) {
336 $smarty->assign('_POST',$_POST);
337 $smarty->assign('bookmarks',$_SESSION['bookmarks']);
338 $smarty->assign('ignore',$_SESSION['ignore']);
339 $smarty->assign('bookstyl',$_SESSION['bookstyl']);
340 $smarty->assign('fook',$_SESSION['fook']);
341 $smarty->assign('user_id',$_SESSION['user_id']);
342 if (!empty($_SESSION['cube_vector'])) $smarty->assign('cube_vector',$_SESSION['cube_vector']);
343 $smarty->assign('friends',$_SESSION['friends']); //req by freezy, done by darkaural
344 $smarty->assign('user_quota',$_SESSION['user_quota']);
345 $newmailset=$db->query("select user_mail,user_mail_name,user_k,k_wallet from users where user_id='$user_id'");
347 $new_mail=$newmailset->getString('user_mail');
348 $newmailset2 = $db->query("select users.user_mail_id,mailsender.login
349 from users left join users as mailsender on users.user_mail_id = mailsender.user_id where users.user_id = '$user_id'");
350 $newmailset2->next();
351 $smarty->assign('new_mail',$new_mail);
352 $smarty->assign('new_mail_name',$newmailset->getString('user_mail_name'));
353 $smarty->assign('new_mail_name2',$newmailset2->getString('login'));
354 $user_k=$newmailset->getString('user_k');
355 $smarty->assign('user_k',$user_k);
356 $k_wallet=$newmailset->getString('k_wallet');
357 $smarty->assign('k_wallet',$k_wallet);
358 $user_id=$_SESSION['user_id'];
361 if ($node['node_name']=='mail') {
363 //clear new mail message
364 if ($new_mail) $db->query("update users set user_mail=0 where user_id='$user_id'");
366 //set messages as delivered to recipient
367 $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'");
368 while($set->next()) {
369 $db->query("update mail set mail_read='yes' where mail_id='".$set->getString('mail_duplicate_id')."'");
370 $db->query("update mail set mail_read='yes' where mail_id='".$set->getString('mail_id')."'");
372 $new_messages[$set->getString('mail_id')]=true;
375 if (count($new_messages)) {
376 $db->query("update mail set mail_read='yes' where mail_user='$user_id' and mail_user=mail_to and mail_read='no'");
377 $smarty->assign('new_messages',$new_messages);
386 if ($node['node_system_access']=='crypto') {
387 $smarty->assign('crypto_pass',$_SESSION['crypto'][$node['node_id']]);
391 //$error .= "ocakavajte planovany vypadok okolo 6 hodiny <br>
392 //s pozdravom br .)";
393 //$error .= "dnes od 22:00 zurka v subclube! ucast povinna!";
395 $smarty->assign('error',$error);
396 $smarty->assign('permissions',$permissions);
397 $smarty->assign('current_vector',$node['node_vector']);
398 if ($permissions['r']) $smarty->assign('node',$node);
401 $smarty->assign('node',$node);
402 //new templates by Dark matter
403 $smarty->template_dir
=OWN_TEMPLATE_DIR
;
405 $smarty->display('1549864.tpl');
406 $smarty->display('1549885.tpl');
407 $smarty->display('630526.tpl');
410 //redirect to mainpage
411 // looks like poeple totaly hate this redirect!
412 // header("Location: /id/1");
416 if ($node['template_id']!='2019721'){
417 //setting user location
418 $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']."'";
419 $db->executequery($q);
422 $whole_time=SubStr((Time()+
SubStr(MicroTime(),0,8)-$timer_start),0,7);
423 $smarty->assign('whole_time',$whole_time);
426 if ($template_id=='download' OR $template_id=='download.jpg') {
427 if ($permissions['r']) {
428 $linkname = SYSTEM_ROOT
."/files/".$node['node_id'];
429 $filename= readlink($linkname);
430 $suffix=preg_replace("/(.*?)\.(.*?)/i","$2",$filename);
432 $ext = substr( $filename,-3 );
433 if( $filename == "" ) {
434 echo "ERROR: Empty file to download. ";
436 } elseif ( ! file_exists( $filename ) ) {
439 switch( strtolower($ext) ){
440 case "pdf": $ctype="application/pdf"; break;
441 case "exe": $ctype="application/octet-stream"; break;
442 case "zip": $ctype="application/zip"; break;
443 case "doc": $ctype="application/msword"; break;
444 case "xls": $ctype="application/vnd.ms-excel"; break;
445 case "ppt": $ctype="application/vnd.ms-powerpoint"; break;
446 case "gif": $ctype="image/gif"; break;
447 case "png": $ctype="image/png"; break;
448 case "jpg": $ctype="image/jpg"; break;
449 default: $ctype="application/force-download";
451 $file=str_replace(" ","_",$node['node_name']).".$ext";
452 header("Pragma: public");
453 header("Expires: 0");
454 header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
455 header("Content-Type: $ctype");
456 $user_agent = strtolower ($_SERVER["HTTP_USER_AGENT"]);
457 if ((is_integer (strpos($user_agent, "msie"))) && (is_integer
458 (strpos($user_agent, "win")))) {
459 header( "Content-Disposition: filename=$file;" );
461 header( "Content-Disposition: attachment;
464 header("Content-Transfer-Encoding: binary");
465 header("Content-Length: ".filesize($filename));
466 readfile("$filename");
469 else { echo "you don't have permissions for downloading this data"; die(); }
472 if ($node['template_id']=='2019721'){
473 Header("Cache-control: max-age=3600");
475 Header("Cache-control: no-cache");
476 Header("Expires:".gmdate("D, d M Y H:i:s")." GMT");
477 header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
481 //for cases like search & preview
482 $smarty->assign('post_vars',$_POST);
483 if (!empty($_POST['template_event'])) {
484 $smarty->assign('template_event',$_POST['template_event']);
488 //setting listing parameters
489 $children_count=$node['node_children_count'];
490 $descendant_count=$node['node_descendant_count'];
492 if (is_numeric($_POST['listing_amount'])) $listing_amount=$_POST['listing_amount'];
493 elseif (!empty($_SESSION['listing_amount'])) $listing_amount=$_SESSION['listing_amount'];
494 else $listing_amount=DEFAULT_LISTING_AMOUNT
;
495 $smarty->assign('listing_amount',$listing_amount);
497 if ($_POST['listing_order']) $listing_order=$_POST['listing_order'];
498 elseif (!empty($_SESSION['listing_order'])) $listing_order=$_SESSION['listing_order'];
499 else $listing_order=DEFAULT_LISTING_ORDER
;
500 $smarty->assign('listing_order',$listing_order);
502 if (is_numeric($_POST['get_children_offset'])) $offset=$_POST['get_children_offset'];
506 //movement forward and backward
507 // if ($listing_order=='asc' && !$offset) $offset=$descendant_count-$listing_amount;
509 if ($_POST['get_children_move']=='<') {
510 $offset=$offset-$listing_amount;
511 if ($offset<0) $offset=0;
513 elseif ($_POST['get_children_move']=='>') {
514 $offset=$offset+
$listing_amount;
516 elseif ($_POST['get_children_move']=='>>') {
517 $offset=$descendant_count-$listing_amount;
520 elseif ($_POST['get_children_move']=='<<') {
523 if ($offset<0) $offset=0;
524 $_POST['offset']=$offset;
525 $smarty->assign('offset',$offset);
528 if ($node['external_link']=='header://svg' && !is_numeric($template_id)) {
529 header("Content-Type: image/svg+xml");
533 elseif ($_SESSION['header_id']==true) {
534 $smarty->assign('header_id',$_SESSION['header_id']);
535 $smarty->template_dir
=OWN_TEMPLATE_DIR
;
536 $content=$smarty->fetch($_SESSION['header_id'].".tpl");
537 $smarty->template_dir
= TEMPLATE_DIR
.TEMPLATE_SET
;
538 //not registered user
539 if ($_SESSION['header_id']==2091520) {
546 $smarty->template_dir
=OWN_TEMPLATE_DIR
;
548 if (is_numeric($template_id)) {
549 $content.=$smarty->fetch($template_id.".tpl");
553 $template_id=$node['template_id'];
554 $content.=$smarty->fetch($node['template_id'].".tpl");
557 if ($template_id=='2019721'){
558 $content=$smarty->fetch($template_id.".tpl");
561 $time=SubStr((Time()+
SubStr(MicroTime(),0,8)-$timer_start),0,7);
563 // echo "<center>page generation took: $time second</center>";
567 // output buffering forcing (mx)
568 if (!empty($_POST['FORCE_OB']) && $_POST['FORCE_OB'] == 'true') ob_end_flush();
This page took 1.598391 seconds and 5 git commands to generate.