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 $_SESSION['debugging']=1;
12 //starting timer for benchmarking purposes
13 $timer_start=Time()+
SubStr(MicroTime(),0,8);
15 //setting PHPSESSID cookie and starting user session
19 if ($_SESSION['debugging']) {
21 error_reporting(E_ALL
);
22 echo "GET VARIABLES::<br/>";
24 echo "POST VARIABLES::<br/>";
26 echo "<b>SESSION VARIABLES::</b><br/>";
30 //requiring main config file with path/database etc. constants
31 require('config/config.inc');
32 require(INCLUDE_DIR
.'senate.inc');
34 preg_match("/id\/(.*)\//",$_SERVER['HTTP_REFERER'],$ref_match);
35 $referer_id=$ref_match[1];
37 //connecting to database and creating universal $db object
38 require(INCLUDE_DIR
.'log.inc');
39 require(INCLUDE_DIR
.'ubik.inc');
40 require(INCLUDE_DIR
.'nodes.inc');
41 require(INCLUDE_DIR
.'error_messages.inc');
42 require(INCLUDE_DIR
.'database.inc');
44 $db = new CLASS_DATABASE();
47 if (!empty($_GET['template_id'])) {
48 $template_id=$_GET['template_id'];
50 else $template_id=false;
52 //initializing node methods
53 if (!empty($_GET['node_name'])) {
54 $node = nodes
::redirByName($_GET['node_name']);
56 elseif (!empty($_GET['node_id'])) {
57 $node = nodes
::getNodeById($_GET['node_id'],$_SESSION['user_id']);
60 //XXX Paths are wrong (!)
61 //loading smarty template engine and setting main parameters
62 require(SMARTY_DIR
.'Smarty.class.php');
65 //$smarty->php_handling = SMARTY_PHP_REMOVE; //XXX
66 $smarty->template_dir
= TEMPLATE_DIR
;
67 //echo TEMPLATE_DIR.TEMPLATE_SET;
68 //echo $smarty->template_dir;
69 $smarty->compile_dir
= SYSTEM_DATA
."templates_c/";
70 $smarty->config_dir
= SMARTY_DIR
.'configs/'; #XXX neexistuje
71 $smarty->cache_dir
= SMARTY_DIR
.'cache/';
72 $smarty->plugins_dir
= SMARTY_PLUGIN_DIR
;
73 if ($_SESSION['debugging']) $smarty->debugging
=true;
75 //initializing variables
76 if (empty($_POST['event'])) $event=false;
77 else $event=$_POST['event'];
80 if ($_SESSION['debugging']) {
81 echo "<pre><b>NODE::";
86 if ($node['node_creator']==$_SESSION['user_id']) $node['node_permission']='owner';
88 if ($_SESSION['cube_vector']) {
89 if (strpos($node['node_vector'],$_SESSION['cube_vector'])===false) {
90 echo "node::".$node['node_vector'];
91 echo "cube_Vector::".$_SESSION['cube_vector'];
92 echo "you are out of allowed cwbe. access forbidden";
97 //if not existent node show our own 404
99 $nodes= nodes
::getNodesByName($_GET['node_name']);
101 $smarty->assign('nodes',$nodes);
102 $content=$smarty->display("404.tpl");
105 elseif ($_SESSION['user_id']) {
106 $smarty->assign('node_name',$_GET['node_name']);
107 $content=$smarty->display("modules/addnode.tpl");
111 //modifying node glass pearl
112 if (is_array($children_types[$node['node_type']])) $smarty->assign('children_types',$children_types[$node['node_type']]);
113 $smarty->assign('types',$types);
116 //$node['node_type']=$types[$node['node_type']];
117 $node['node_content']=StripSlashes($node['node_content']);
118 $node['node_name']=StripSlashes($node['node_name']);
120 //checking permissions
121 function _checkPermissions()
123 global $permissions, $node;
125 require(INCLUDE_DIR
.'permissions.inc');
126 $permissions=permissions
::checkPermissions($node);
127 $permissions['h']=permissions
::isHierarch($node);
131 if ($template_id=='rss')
133 $_feedType = "RSS0.91";
134 if (!is_numeric($_SESSION['user_id']))
136 if (!isset($_SERVER['PHP_AUTH_USER'])) {
137 header('WWW-Authenticate: Basic realm="Kyberia"');
138 header('HTTP/1.0 401 Unauthorized');
139 echo 'Cancel button';
144 require_once(EVENT_DIR
.'/login.inc');
145 $_POST['login'] = $_SERVER['PHP_AUTH_USER'];
146 $_POST['password'] = $_SERVER['PHP_AUTH_PW'];
147 $_POST['login_type'] = "name";
150 echo "Zle meno/heslo.";
159 if ($_GET['node_id']==='24' && $permissions['r'])
161 require_once(INCLUDE_DIR
.'/feedcreator.class.php');
163 $rss =& new UniversalFeedCreator();
164 $rss->title
= "Kyberia mail";
165 $rss->description
= "";
166 $rss->link
= "https://". SYSTEM_URL
. "/id/24";
168 $query = "select date_format(mail.mail_timestamp,\"%e.%c. %k:%i:%s\") as cas,
169 userfrom.user_action as locationfrom_action,
170 userfrom.user_action_id as locationfrom_action_id,
171 userto.user_action as locationto_action,
172 userto.user_action_id as locationto_action_id,
173 userto.login as mail_to_name, userfrom.login as mail_from_name,
174 mail.* from mail left join users as userfrom on
175 mail_from=userfrom.user_id left join users as userto on mail_to=userto.user_id
176 where mail_user='$_SESSION[user_id]' and mail_to='$_SESSION[user_id]' order by mail_id desc limit 0,10";
178 $set = $db->query($query);
180 while($set->next()) {
181 $m = $set->getRecord();
182 if ($m['mail_to'] != $_SESSION['user_id'])
184 $item =& new FeedItem();
185 $item->title
= $m['mail_from_name'];
186 $item->link
= "https://".SYSTEM_URL
."/id/24";
187 $item->description
= $m['mail_text'];
188 $rss->addItem($item);
192 elseif ($_GET['node_id']=='19' && $permissions['r'])
194 require_once(INCLUDE_DIR
.'/feedcreator.class.php');
196 $rss =& new UniversalFeedCreator();
197 $rss->title
= "Kyberia bookmarks";
198 $rss->link
= "http://".SYSTEM_URL
."/id/19";
200 require_once(SMARTY_PLUGIN_DIR
.'/function.get_bookmarks.php');
201 smarty_function_get_bookmarks(array(), $smarty);
202 $_items = $smarty->get_template_vars('get_bookmarks');
203 foreach ($_items as $_item)
205 if (is_array($_item['children']))
206 foreach ($_item['children'] as $_b)
208 $item =& new FeedItem();
209 $item->title
= $_b['node_name'];
210 $item->link
= "http://".SYSTEM_URL
."/id/".$_b['node_id']."/rss";
211 $rss->addItem($item);
216 elseif ($permissions['r'])
218 require_once(INCLUDE_DIR
.'/feedcreator.class.php');
220 $rss =& new UniversalFeedCreator();
221 $rss->title
= $node['node_name'];
222 $rss->description
= "";
223 $rss->link
= "http://".SYSTEM_URL
."/id/".$node['node_id'];
226 if ($_GET['node_id']=='15')
228 require_once(SMARTY_PLUGIN_DIR
.'/function.get_k.php');
229 smarty_function_get_k(array(), $smarty);
230 $_items = $smarty->get_template_vars('get_k');
234 require_once(SMARTY_PLUGIN_DIR
.'/function.get_children.php');
235 smarty_function_get_children(
236 array('orderby' => 'desc', 'orderby_type' => 'time'), $smarty);
237 $_items = $smarty->get_template_vars('get_children');
240 foreach ($_items as $_item)
242 $item =& new FeedItem();
243 $item->title
= $_item['node_name'];
244 $item->link
= "http://".SYSTEM_URL
."/id/".$_item['node_id'];
245 $item->description
= $_item['node_content'];
246 $rss->addItem($item);
250 if ($permissions['r']) $rss->showFeed($_feedType);
259 if (($permissions['r']) ||
($event != 'register')) {
261 //performing node_events (based on update/insert/delete db queries)
263 require(INCLUDE_DIR
.'eventz.inc');
266 elseif ($transaction) {
267 require(INCLUDE_DIR
.'transaction.inc');
269 //end of performing node events
275 if ($permissions['r']) {
277 //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
278 if ($_SESSION['user_id']) {
279 $q="insert delayed into levenshtein set user_id='".$_SESSION['user_id']."',node_id='".$node['node_id']."'";
284 if ($node['template_id']!='2019721'){
286 $log->log('enter',$node['node_id'],'ok',$node['node_user_subchild_count']);
287 if (!empty($_SESSION['user_id']) && is_numeric($node['node_id'])) {
288 $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']."'";
290 $result=$db->update($q);
293 $q="insert into node_access set user_id='".$_SESSION['user_id']."',node_id='".$node['node_id']."',last_visit=NOW()";
296 }//end of if node os css
301 // DO NOT MESS WITH THIS !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
302 //creating neural network
303 $db->update("update nodes set node_views=node_views+1 where node_id='".$node['node_id']."'");
304 if (is_numeric($referer_id)) {
305 $q="update neurons set synapse=synapse+1 where dst='".$node['node_id']."' and src='$referer_id'";
306 $result=$db->update($q);
308 $q="insert into neurons set synapse_creator='".$_SESSION['user_id']."',dst='".$node['node_id']."',src='$referer_id',synapse=1";
314 elseif (!$permissions['r'] && $_GET['magic_word']) {
315 $magic_word_big=$_GET['magic_word'];
317 if ( preg_match("/(\d+)-(.+)/",$_GET['magic_word'],$mu)) {
319 $magic_word=addslashes($mu['2']);
320 $q="select login from users where user_id='$magic_uid' and magic_word='$magic_word'";
322 if ($set->getNumRows()) {
323 $permissions['r']=true;
333 $log->log('enter',$node['node_id'],'failed');
338 //assigning user data to smarty if user logged in
339 if ($user_id=$_SESSION['user_id']) {
340 $smarty->assign('_POST',$_POST);
341 $smarty->assign('bookmarks',$_SESSION['bookmarks']);
342 $smarty->assign('ignore',$_SESSION['ignore']);
343 $smarty->assign('bookstyl',$_SESSION['bookstyl']);
344 $smarty->assign('fook',$_SESSION['fook']);
345 $smarty->assign('user_id',$_SESSION['user_id']);
346 if (!empty($_SESSION['cube_vector'])) $smarty->assign('cube_vector',$_SESSION['cube_vector']);
347 $smarty->assign('friends',$_SESSION['friends']); //req by freezy, done by darkaural
348 $smarty->assign('user_quota',$_SESSION['user_quota']);
349 $newmailset=$db->query("select user_mail,user_mail_name,user_k,k_wallet from users where user_id='$user_id'");
351 $new_mail=$newmailset->getString('user_mail');
352 $newmailset2 = $db->query("select users.user_mail_id,mailsender.login
353 from users left join users as mailsender on users.user_mail_id = mailsender.user_id where users.user_id = '$user_id'");
354 $newmailset2->next();
355 $smarty->assign('new_mail',$new_mail);
356 $smarty->assign('new_mail_name',$newmailset->getString('user_mail_name'));
357 $smarty->assign('new_mail_name2',$newmailset2->getString('login'));
358 $user_k=$newmailset->getString('user_k');
359 $smarty->assign('user_k',$user_k);
360 $k_wallet=$newmailset->getString('k_wallet');
361 $smarty->assign('k_wallet',$k_wallet);
362 $user_id=$_SESSION['user_id'];
365 if ($node['node_name']=='mail') {
367 //clear new mail message
368 if ($new_mail) $db->query("update users set user_mail=0 where user_id='$user_id'");
370 //set messages as delivered to recipient
371 $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'");
372 while($set->next()) {
373 $db->query("update mail set mail_read='yes' where mail_id='".$set->getString('mail_duplicate_id')."'");
374 $db->query("update mail set mail_read='yes' where mail_id='".$set->getString('mail_id')."'");
376 $new_messages[$set->getString('mail_id')]=true;
379 if (count($new_messages)) {
380 $db->query("update mail set mail_read='yes' where mail_user='$user_id' and mail_user=mail_to and mail_read='no'");
381 $smarty->assign('new_messages',$new_messages);
390 if ($node['node_system_access']=='crypto') {
391 $smarty->assign('crypto_pass',$_SESSION['crypto'][$node['node_id']]);
394 $smarty->assign('error',$error);
395 $smarty->assign('permissions',$permissions);
396 $smarty->assign('current_vector',$node['node_vector']);
397 if ($permissions['r']) $smarty->assign('node',$node);
400 $smarty->assign('node',$node);
401 //new templates by Dark matter
402 $smarty->template_dir
=OWN_TEMPLATE_DIR
;
404 $smarty->display('1549864.tpl');
405 $smarty->display('1549885.tpl');
406 $smarty->display('630526.tpl');
409 //redirect to mainpage
410 // looks like poeple totaly hate this redirect!
411 // header("Location: /id/1");
415 if ($node['template_id']!='2019721'){
416 //setting user location
417 $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']."'";
418 $db->executequery($q);
421 $whole_time=SubStr((Time()+
SubStr(MicroTime(),0,8)-$timer_start),0,7);
422 $smarty->assign('whole_time',$whole_time);
425 if ($template_id=='download' OR $template_id=='download.jpg') {
426 if ($permissions['r']) {
427 $linkname = SYSTEM_ROOT
."/files/".$node['node_id'];
428 $filename= readlink($linkname);
429 $suffix=preg_replace("/(.*?)\.(.*?)/i","$2",$filename);
431 $ext = substr( $filename,-3 );
432 if( $filename == "" ) {
433 echo "ERROR: Empty file to download. ";
435 } elseif ( ! file_exists( $filename ) ) {
438 switch( strtolower($ext) ){
439 case "pdf": $ctype="application/pdf"; break;
440 case "exe": $ctype="application/octet-stream"; break;
441 case "zip": $ctype="application/zip"; break;
442 case "doc": $ctype="application/msword"; break;
443 case "xls": $ctype="application/vnd.ms-excel"; break;
444 case "ppt": $ctype="application/vnd.ms-powerpoint"; break;
445 case "gif": $ctype="image/gif"; break;
446 case "png": $ctype="image/png"; break;
447 case "jpg": $ctype="image/jpg"; break;
448 default: $ctype="application/force-download";
450 $file=str_replace(" ","_",$node['node_name']).".$ext";
451 header("Pragma: public");
452 header("Expires: 0");
453 header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
454 header("Content-Type: $ctype");
455 $user_agent = strtolower ($_SERVER["HTTP_USER_AGENT"]);
456 if ((is_integer (strpos($user_agent, "msie"))) && (is_integer
457 (strpos($user_agent, "win")))) {
458 header( "Content-Disposition: filename=$file;" );
460 header( "Content-Disposition: attachment;
463 header("Content-Transfer-Encoding: binary");
464 header("Content-Length: ".filesize($filename));
465 readfile("$filename");
468 else { echo "you don't have permissions for downloading this data"; die(); }
471 if ($node['template_id']=='2019721'){
472 Header("Cache-control: max-age=3600");
474 Header("Cache-control: no-cache");
475 Header("Expires:".gmdate("D, d M Y H:i:s")." GMT");
476 header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
480 //for cases like search & preview
481 $smarty->assign('post_vars',$_POST);
482 if (!empty($_POST['template_event'])) {
483 $smarty->assign('template_event',$_POST['template_event']);
487 //setting listing parameters
488 $children_count=$node['node_children_count'];
489 $descendant_count=$node['node_descendant_count'];
491 if (is_numeric($_POST['listing_amount'])) $listing_amount=$_POST['listing_amount'];
492 elseif (!empty($_SESSION['listing_amount'])) $listing_amount=$_SESSION['listing_amount'];
493 else $listing_amount=DEFAULT_LISTING_AMOUNT
;
494 $smarty->assign('listing_amount',$listing_amount);
496 if ($_POST['listing_order']) $listing_order=$_POST['listing_order'];
497 elseif (!empty($_SESSION['listing_order'])) $listing_order=$_SESSION['listing_order'];
498 else $listing_order=DEFAULT_LISTING_ORDER
;
499 $smarty->assign('listing_order',$listing_order);
501 if (is_numeric($_POST['get_children_offset'])) $offset=$_POST['get_children_offset'];
505 //movement forward and backward
506 // if ($listing_order=='asc' && !$offset) $offset=$descendant_count-$listing_amount;
508 if ($_POST['get_children_move']=='<') {
509 $offset=$offset-$listing_amount;
510 if ($offset<0) $offset=0;
512 elseif ($_POST['get_children_move']=='>') {
513 $offset=$offset+
$listing_amount;
515 elseif ($_POST['get_children_move']=='>>') {
516 $offset=$descendant_count-$listing_amount;
519 elseif ($_POST['get_children_move']=='<<') {
522 if ($offset<0) $offset=0;
523 $_POST['offset']=$offset;
524 $smarty->assign('offset',$offset);
527 if ($node['external_link']=='header://svg' && !is_numeric($template_id)) {
528 header("Content-Type: image/svg+xml");
532 elseif ($_SESSION['header_id']==true) {
533 $smarty->assign('header_id',$_SESSION['header_id']);
534 $smarty->template_dir
=OWN_TEMPLATE_DIR
;
535 $content=$smarty->fetch($_SESSION['header_id'].".tpl");
536 $smarty->template_dir
= TEMPLATE_DIR
.TEMPLATE_SET
;
537 //not registered user
538 if ($_SESSION['header_id']==2091520) {
545 $smarty->template_dir
=OWN_TEMPLATE_DIR
;
547 if (is_numeric($template_id)) {
548 $content.=$smarty->fetch($template_id.".tpl");
552 $template_id=$node['template_id'];
553 $content.=$smarty->fetch($node['template_id'].".tpl");
556 if ($template_id=='2019721'){
557 $content=$smarty->fetch($template_id.".tpl");
560 $time=SubStr((Time()+
SubStr(MicroTime(),0,8)-$timer_start),0,7);
562 // echo "<center>page generation took: $time second</center>";
566 // output buffering forcing (mx)
567 if (!empty($_POST['FORCE_OB']) && $_POST['FORCE_OB'] == 'true') ob_end_flush();
This page took 1.507715 seconds and 4 git commands to generate.