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();
46 if (!empty($_GET['template_id'])) {
47 $template_id=$_GET['template_id'];
49 else $template_id=false;
51 //initializing node methods
52 if (!empty($_GET['node_name'])) {
53 $node = nodes
::redirByName($_GET['node_name']);
55 elseif (!empty($_GET['node_id'])) {
56 $node = nodes
::getNodeById($_GET['node_id'],$_SESSION['user_id']);
59 //XXX Paths are wrong (!)
60 //loading smarty template engine and setting main parameters
61 require(SMARTY_DIR
.'Smarty.class.php');
64 //$smarty->php_handling = SMARTY_PHP_REMOVE; //XXX
65 $smarty->template_dir
= TEMPLATE_DIR
.TEMPLATE_SET
;
66 //echo TEMPLATE_DIR.TEMPLATE_SET;
67 //echo $smarty->template_dir;
68 $smarty->compile_dir
= SYSTEM_ROOT
."data/templates_c/".TEMPLATE_SET
;
69 $smarty->config_dir
= SMARTY_DIR
.'configs/';
70 $smarty->cache_dir
= SMARTY_DIR
.'cache/';
71 $smarty->plugins_dir
= SMARTY_PLUGIN_DIR
;
72 if ($_SESSION['debugging']) $smarty->debugging
=true;
74 //initializing variables
75 if (empty($_POST['event'])) $event=false;
76 else $event=$_POST['event'];
79 if ($_SESSION['debugging']) {
80 echo "<pre><b>NODE::";
85 if ($node['node_creator']==$_SESSION['user_id']) $node['node_permission']='owner';
87 if ($_SESSION['cube_vector']) {
88 if (strpos($node['node_vector'],$_SESSION['cube_vector'])===false) {
89 echo "node::".$node['node_vector'];
90 echo "cube_Vector::".$_SESSION['cube_vector'];
91 echo "you are out of allowed cwbe. access forbidden";
96 //if not existent node show our own 404
98 $nodes= nodes
::getNodesByName($_GET['node_name']);
100 $smarty->assign('nodes',$nodes);
101 $content=$smarty->display("404.tpl");
104 elseif ($_SESSION['user_id']) {
105 $smarty->assign('node_name',$_GET['node_name']);
106 $content=$smarty->display("modules/addnode.tpl");
110 //modifying node glass pearl
111 if (is_array($children_types[$node['node_type']])) $smarty->assign('children_types',$children_types[$node['node_type']]);
112 $smarty->assign('types',$types);
115 //$node['node_type']=$types[$node['node_type']];
116 $node['node_content']=StripSlashes($node['node_content']);
117 $node['node_name']=StripSlashes($node['node_name']);
119 //checking permissions
120 function _checkPermissions()
122 global $permissions, $node;
124 require(INCLUDE_DIR
.'permissions.inc');
125 $permissions=permissions
::checkPermissions($node);
126 $permissions['h']=permissions
::isHierarch($node);
130 if ($template_id=='rss')
132 $_feedType = "RSS0.91";
133 if (!is_numeric($_SESSION['user_id']))
135 if (!isset($_SERVER['PHP_AUTH_USER'])) {
136 header('WWW-Authenticate: Basic realm="Kyberia"');
137 header('HTTP/1.0 401 Unauthorized');
138 echo 'Cancel button';
143 require_once(EVENT_DIR
.'/login.inc');
144 $_POST['login'] = $_SERVER['PHP_AUTH_USER'];
145 $_POST['password'] = $_SERVER['PHP_AUTH_PW'];
146 $_POST['login_type'] = "name";
149 echo "Zle meno/heslo.";
158 if ($_GET['node_id']==='24' && $permissions['r'])
160 require_once(INCLUDE_DIR
.'/feedcreator.class.php');
162 $rss =& new UniversalFeedCreator();
163 $rss->title
= "Kyberia mail";
164 $rss->description
= "";
165 $rss->link
= "https://". SYSTEM_URL
. "/id/24";
167 $query = "select date_format(mail.mail_timestamp,\"%e.%c. %k:%i:%s\") as cas,
168 userfrom.user_action as locationfrom_action,
169 userfrom.user_action_id as locationfrom_action_id,
170 userto.user_action as locationto_action,
171 userto.user_action_id as locationto_action_id,
172 userto.login as mail_to_name, userfrom.login as mail_from_name,
173 mail.* from mail left join users as userfrom on
174 mail_from=userfrom.user_id left join users as userto on mail_to=userto.user_id
175 where mail_user='$_SESSION[user_id]' and mail_to='$_SESSION[user_id]' order by mail_id desc limit 0,10";
177 $set = $db->query($query);
179 while($set->next()) {
180 $m = $set->getRecord();
181 if ($m['mail_to'] != $_SESSION['user_id'])
183 $item =& new FeedItem();
184 $item->title
= $m['mail_from_name'];
185 $item->link
= "https://".SYSTEM_URL
."/id/24";
186 $item->description
= $m['mail_text'];
187 $rss->addItem($item);
191 elseif ($_GET['node_id']=='19' && $permissions['r'])
193 require_once(INCLUDE_DIR
.'/feedcreator.class.php');
195 $rss =& new UniversalFeedCreator();
196 $rss->title
= "Kyberia bookmarks";
197 $rss->link
= "http://".SYSTEM_URL
."/id/19";
199 require_once(SMARTY_PLUGIN_DIR
.'/function.get_bookmarks.php');
200 smarty_function_get_bookmarks(array(), $smarty);
201 $_items = $smarty->get_template_vars('get_bookmarks');
202 foreach ($_items as $_item)
204 if (is_array($_item['children']))
205 foreach ($_item['children'] as $_b)
207 $item =& new FeedItem();
208 $item->title
= $_b['node_name'];
209 $item->link
= "http://".SYSTEM_URL
."/id/".$_b['node_id']."/rss";
210 $rss->addItem($item);
215 elseif ($permissions['r'])
217 require_once(INCLUDE_DIR
.'/feedcreator.class.php');
219 $rss =& new UniversalFeedCreator();
220 $rss->title
= $node['node_name'];
221 $rss->description
= "";
222 $rss->link
= "http://".SYSTEM_URL
."/id/".$node['node_id'];
225 if ($_GET['node_id']=='15')
227 require_once(SMARTY_PLUGIN_DIR
.'/function.get_k.php');
228 smarty_function_get_k(array(), $smarty);
229 $_items = $smarty->get_template_vars('get_k');
233 require_once(SMARTY_PLUGIN_DIR
.'/function.get_children.php');
234 smarty_function_get_children(
235 array('orderby' => 'desc', 'orderby_type' => 'time'), $smarty);
236 $_items = $smarty->get_template_vars('get_children');
239 foreach ($_items as $_item)
241 $item =& new FeedItem();
242 $item->title
= $_item['node_name'];
243 $item->link
= "http://".SYSTEM_URL
."/id/".$_item['node_id'];
244 $item->description
= $_item['node_content'];
245 $rss->addItem($item);
249 if ($permissions['r']) $rss->showFeed($_feedType);
258 if (($permissions['r']) ||
($event != 'register')) {
260 //performing node_events (based on update/insert/delete db queries)
262 require(INCLUDE_DIR
.'eventz.inc');
265 elseif ($transaction) {
266 require(INCLUDE_DIR
.'transaction.inc');
268 //end of performing node events
274 if ($permissions['r']) {
276 //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
277 if ($_SESSION['user_id']) {
278 $q="insert delayed into levenshtein set user_id='".$_SESSION['user_id']."',node_id='".$node['node_id']."'";
283 if ($node['template_id']!='2019721'){
285 $log->log('enter',$node['node_id'],'ok',$node['node_user_subchild_count']);
286 if (!empty($_SESSION['user_id']) && is_numeric($node['node_id'])) {
287 $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']."'";
289 $result=$db->update($q);
292 $q="insert into node_access set user_id='".$_SESSION['user_id']."',node_id='".$node['node_id']."',last_visit=NOW()";
295 }//end of if node os css
300 // DO NOT MESS WITH THIS !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
301 //creating neural network
302 $db->update("update nodes set node_views=node_views+1 where node_id='".$node['node_id']."'");
303 if (is_numeric($referer_id)) {
304 $q="update neurons set synapse=synapse+1 where dst='".$node['node_id']."' and src='$referer_id'";
305 $result=$db->update($q);
307 $q="insert into neurons set synapse_creator='".$_SESSION['user_id']."',dst='".$node['node_id']."',src='$referer_id',synapse=1";
313 elseif (!$permissions['r'] && $_GET['magic_word']) {
314 $magic_word_big=$_GET['magic_word'];
316 if ( preg_match("/(\d+)-(.+)/",$_GET['magic_word'],$mu)) {
318 $magic_word=addslashes($mu['2']);
319 $q="select login from users where user_id='$magic_uid' and magic_word='$magic_word'";
321 if ($set->getNumRows()) {
322 $permissions['r']=true;
332 $log->log('enter',$node['node_id'],'failed');
337 //assigning user data to smarty if user logged in
338 if ($user_id=$_SESSION['user_id']) {
339 $smarty->assign('_POST',$_POST);
340 $smarty->assign('bookmarks',$_SESSION['bookmarks']);
341 $smarty->assign('ignore',$_SESSION['ignore']);
342 $smarty->assign('bookstyl',$_SESSION['bookstyl']);
343 $smarty->assign('fook',$_SESSION['fook']);
344 $smarty->assign('user_id',$_SESSION['user_id']);
345 if (!empty($_SESSION['cube_vector'])) $smarty->assign('cube_vector',$_SESSION['cube_vector']);
346 $smarty->assign('friends',$_SESSION['friends']); //req by freezy, done by darkaural
347 $smarty->assign('user_quota',$_SESSION['user_quota']);
348 $newmailset=$db->query("select user_mail,user_mail_name,user_k,k_wallet from users where user_id='$user_id'");
350 $new_mail=$newmailset->getString('user_mail');
351 $newmailset2 = $db->query("select users.user_mail_id,mailsender.login
352 from users left join users as mailsender on users.user_mail_id = mailsender.user_id where users.user_id = '$user_id'");
353 $newmailset2->next();
354 $smarty->assign('new_mail',$new_mail);
355 $smarty->assign('new_mail_name',$newmailset->getString('user_mail_name'));
356 $smarty->assign('new_mail_name2',$newmailset2->getString('login'));
357 $user_k=$newmailset->getString('user_k');
358 $smarty->assign('user_k',$user_k);
359 $k_wallet=$newmailset->getString('k_wallet');
360 $smarty->assign('k_wallet',$k_wallet);
361 $user_id=$_SESSION['user_id'];
364 if ($node['node_name']=='mail') {
366 //clear new mail message
367 if ($new_mail) $db->query("update users set user_mail=0 where user_id='$user_id'");
369 //set messages as delivered to recipient
370 $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'");
371 while($set->next()) {
372 $db->query("update mail set mail_read='yes' where mail_id='".$set->getString('mail_duplicate_id')."'");
373 $db->query("update mail set mail_read='yes' where mail_id='".$set->getString('mail_id')."'");
375 $new_messages[$set->getString('mail_id')]=true;
378 if (count($new_messages)) {
379 $db->query("update mail set mail_read='yes' where mail_user='$user_id' and mail_user=mail_to and mail_read='no'");
380 $smarty->assign('new_messages',$new_messages);
389 if ($node['node_system_access']=='crypto') {
390 $smarty->assign('crypto_pass',$_SESSION['crypto'][$node['node_id']]);
393 $smarty->assign('error',$error);
394 $smarty->assign('permissions',$permissions);
395 $smarty->assign('current_vector',$node['node_vector']);
396 if ($permissions['r']) $smarty->assign('node',$node);
399 $smarty->assign('node',$node);
400 //new templates by Dark matter
401 $smarty->template_dir
=OWN_TEMPLATE_DIR
;
403 $smarty->display('1549864.tpl');
404 $smarty->display('1549885.tpl');
405 $smarty->display('630526.tpl');
408 //redirect to mainpage
409 // looks like poeple totaly hate this redirect!
410 // header("Location: /id/1");
414 if ($node['template_id']!='2019721'){
415 //setting user location
416 $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']."'";
417 $db->executequery($q);
420 $whole_time=SubStr((Time()+
SubStr(MicroTime(),0,8)-$timer_start),0,7);
421 $smarty->assign('whole_time',$whole_time);
424 if ($template_id=='download' OR $template_id=='download.jpg') {
425 if ($permissions['r']) {
426 $linkname = SYSTEM_ROOT
."/files/".$node['node_id'];
427 $filename= readlink($linkname);
428 $suffix=preg_replace("/(.*?)\.(.*?)/i","$2",$filename);
430 $ext = substr( $filename,-3 );
431 if( $filename == "" ) {
432 echo "ERROR: Empty file to download. ";
434 } elseif ( ! file_exists( $filename ) ) {
437 switch( strtolower($ext) ){
438 case "pdf": $ctype="application/pdf"; break;
439 case "exe": $ctype="application/octet-stream"; break;
440 case "zip": $ctype="application/zip"; break;
441 case "doc": $ctype="application/msword"; break;
442 case "xls": $ctype="application/vnd.ms-excel"; break;
443 case "ppt": $ctype="application/vnd.ms-powerpoint"; break;
444 case "gif": $ctype="image/gif"; break;
445 case "png": $ctype="image/png"; break;
446 case "jpg": $ctype="image/jpg"; break;
447 default: $ctype="application/force-download";
449 $file=str_replace(" ","_",$node['node_name']).".$ext";
450 header("Pragma: public");
451 header("Expires: 0");
452 header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
453 header("Content-Type: $ctype");
454 $user_agent = strtolower ($_SERVER["HTTP_USER_AGENT"]);
455 if ((is_integer (strpos($user_agent, "msie"))) && (is_integer
456 (strpos($user_agent, "win")))) {
457 header( "Content-Disposition: filename=$file;" );
459 header( "Content-Disposition: attachment;
462 header("Content-Transfer-Encoding: binary");
463 header("Content-Length: ".filesize($filename));
464 readfile("$filename");
467 else { echo "you don't have permissions for downloading this data"; die(); }
470 if ($node['template_id']=='2019721'){
471 Header("Cache-control: max-age=3600");
473 Header("Cache-control: no-cache");
474 Header("Expires:".gmdate("D, d M Y H:i:s")." GMT");
475 header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
479 //for cases like search & preview
480 $smarty->assign('post_vars',$_POST);
481 if (!empty($_POST['template_event'])) {
482 $smarty->assign('template_event',$_POST['template_event']);
486 //setting listing parameters
487 $children_count=$node['node_children_count'];
488 $descendant_count=$node['node_descendant_count'];
490 if (is_numeric($_POST['listing_amount'])) $listing_amount=$_POST['listing_amount'];
491 elseif (!empty($_SESSION['listing_amount'])) $listing_amount=$_SESSION['listing_amount'];
492 else $listing_amount=DEFAULT_LISTING_AMOUNT
;
493 $smarty->assign('listing_amount',$listing_amount);
495 if ($_POST['listing_order']) $listing_order=$_POST['listing_order'];
496 elseif (!empty($_SESSION['listing_order'])) $listing_order=$_SESSION['listing_order'];
497 else $listing_order=DEFAULT_LISTING_ORDER
;
498 $smarty->assign('listing_order',$listing_order);
500 if (is_numeric($_POST['get_children_offset'])) $offset=$_POST['get_children_offset'];
504 //movement forward and backward
505 // if ($listing_order=='asc' && !$offset) $offset=$descendant_count-$listing_amount;
507 if ($_POST['get_children_move']=='<') {
508 $offset=$offset-$listing_amount;
509 if ($offset<0) $offset=0;
511 elseif ($_POST['get_children_move']=='>') {
512 $offset=$offset+
$listing_amount;
514 elseif ($_POST['get_children_move']=='>>') {
515 $offset=$descendant_count-$listing_amount;
518 elseif ($_POST['get_children_move']=='<<') {
521 if ($offset<0) $offset=0;
522 $_POST['offset']=$offset;
523 $smarty->assign('offset',$offset);
526 if ($node['external_link']=='header://svg' && !is_numeric($template_id)) {
527 header("Content-Type: image/svg+xml");
531 elseif ($_SESSION['header_id']==true) {
532 $smarty->assign('header_id',$_SESSION['header_id']);
533 $smarty->template_dir
=OWN_TEMPLATE_DIR
;
534 $content=$smarty->fetch($_SESSION['header_id'].".tpl");
535 $smarty->template_dir
= TEMPLATE_DIR
.TEMPLATE_SET
;
536 //not registered user
537 if ($_SESSION['header_id']==2091520) {
544 $smarty->template_dir
=OWN_TEMPLATE_DIR
;
546 if (is_numeric($template_id)) {
547 $content.=$smarty->fetch($template_id.".tpl");
551 $template_id=$node['template_id'];
552 $content.=$smarty->fetch($node['template_id'].".tpl");
555 if ($template_id=='2019721'){
556 $content=$smarty->fetch($template_id.".tpl");
559 $time=SubStr((Time()+
SubStr(MicroTime(),0,8)-$timer_start),0,7);
561 // echo "<center>page generation took: $time second</center>";
565 // output buffering forcing (mx)
566 if (!empty($_POST['FORCE_OB']) && $_POST['FORCE_OB'] == 'true') ob_end_flush();
This page took 0.769614 seconds and 5 git commands to generate.