0c3802391a7203cac09aa775a22646d43a61c2c6
2 //requiring main config file with path/database etc. constants
3 require_once('config/config.inc');
5 //Ask for auth if enabled...
6 //if(isset($realm) && isset($users)) require_once(INCLUDE_DIR.'http_auth.php');
8 //starting timer for benchmarking purposes
9 $timer_start=Time()+
SubStr(MicroTime(),0,8);
10 //setting PHPSESSID cookie and starting user session
13 @ini_set
('magic_quotes_gpc' , 'off');
14 if(get_magic_quotes_gpc()) {
15 die("Error: magic_quotes_gpc needs to be disabled! F00K!\n");
19 $smarty_resource = 'kyberia';
20 //$smarty_resource = ''; //same as 'file' (fallback)
21 /* I have moved old templates to DB using following lame script:
22 * for i in *.tpl; do j=$(echo "$i" | cut -d . -f 1);
23 echo UPDATE nodes SET node_content = "'$(php -r
24 "echo mysql_escape_string(file_get_contents('$i'));")'" WHERE
25 node_id = "'$j'" COLLATE utf8_bin LIMIT '1;';
26 done | mysql --user=kyberia --password=PASSSSSSS kyberia
27 * In future we should have some mechanism for distributing templates
28 * because they are very important part of kyberia source...
31 //connecting to database and creating universal $db object
32 //require_once(INCLUDE_DIR.'senate.inc'); // in config already
33 require_once(INCLUDE_DIR
.'log.inc');
34 require_once(INCLUDE_DIR
.'ubik.inc');
35 require_once(INCLUDE_DIR
.'nodes.inc');
36 require_once(INCLUDE_DIR
.'error_messages.inc');
37 require_once(INCLUDE_DIR
.'database.inc');
38 require_once(INCLUDE_DIR
.'transports.inc');
40 $db = new CLASS_DATABASE();
42 if (preg_match('/id\/([0-9]+)(?:\/([0-9]+)\/?)?/',$_SERVER['PATH_INFO'],$match)) {
44 $_GET['node_id']=$match[1];
45 if (!empty($match[2])) {
46 $_GET['template_id']=$match[2];
48 } elseif (preg_match('/k\/([a-z0-9]{1,7})(?:\/([a-z0-9]{1,7}))?/',$_SERVER['PATH_INFO'],$match)) {
49 $_GET['node_id']=base_convert($match[1], 36, 10);
50 if (!empty($match[2])) {
51 $_GET['template_id']=base_convert($match[2],36,10);
53 } elseif (preg_match('/name\/(.*?)\/?$/',$_SERVER['PATH_INFO'],$match)) {
54 $_GET['node_id'] = nodes
::getNodeIdByName($match[1]);
57 if (!empty($_GET['template_id'])) {
58 $template_id=$_GET['template_id'];
64 $_SESSION['debugging']=0;
65 //unset($_SESSION['debugging']);
66 //Well... we should make some event
67 //or JavaScript page to turning this on/off...
69 if ($_SESSION['debugging']) {
70 error_reporting(E_ALL
);
71 echo 'GET VARIABLES::<br/>';
73 echo 'POST VARIABLES::<br/>';
75 echo '<b>SESSION VARIABLES::</b><br/>';
82 if (!is_numeric($_GET['node_id'])) {
83 $_GET['node_id']=WELCOME_NODE
;
86 $node = nodes
::getNodeById($_GET['node_id'],(isset($_SESSION['user_id']))?
$_SESSION['user_id']:'');
88 //XXX Paths are wrong (!)
89 //loading smarty template engine and setting main parameters
90 require(SMARTY_DIR
.'Smarty.class.php');
92 require(INCLUDE_DIR
.'smarty/resource.kyberia.php');
93 $smarty->default_resource_type
=$smarty_resource;
95 //$smarty->php_handling = SMARTY_PHP_REMOVE; //XXX
96 $smarty->template_dir
= TEMPLATE_DIR
;
97 //echo TEMPLATE_DIR.TEMPLATE_SET;
98 //echo $smarty->template_dir;
99 $smarty->compile_dir
= SYSTEM_DATA
.'templates_c/';
100 $smarty->config_dir
= SMARTY_DIR
.'configs/'; //XXX neexistuje
101 $smarty->cache_dir
= SMARTY_DIR
.'cache/';
102 $smarty->plugins_dir
= SMARTY_PLUGIN_DIR
;
103 if ($_SESSION['debugging']) $smarty->debugging
=true;
105 // initializing variables
106 // preg_replace prevents LFI
107 if (empty($_POST['event'])) $event='display';
108 else $event= preg_replace( "![^a-zA-Z0-9_]+!", "", $_POST['event']);
111 if ($_SESSION['debugging']) {
112 echo "<pre><b>NODE::";
117 if ((isset($_SESSION['user_id']) && ($node['node_creator']==$_SESSION['user_id']))) {
118 $node['node_permission']='owner';
121 if (isset($_SESSION['cube_vector']) && ($_SESSION['cube_vector'])) {
122 if (strpos($node['node_vector'],$_SESSION['cube_vector'])===false) {
123 echo "node::".$node['node_vector'];
124 echo "cube_Vector::".$_SESSION['cube_vector'];
125 echo "you are out of allowed cwbe. access forbidden";
130 @include_once
(INCLUDE_DIR
.'mail_rss.inc'); //haluz...
132 //checking permissions
133 function _checkPermissions()
135 global $permissions, $node;
136 require(INCLUDE_DIR
.'permissions.inc');
137 $permissions=permissions
::checkPermissions($node);
138 $permissions['h']=permissions
::isHierarch($node);
143 // DO NOT MESS WITH THIS !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
144 //creating neural network
145 $db->update("update nodes set node_views=node_views+1 where node_id='".$node['node_id']."'");
146 if (isset($referer_id) && is_numeric($referer_id)) {
147 $q="update neurons set synapse=synapse+1 where dst='".$node['node_id']."' and src='$referer_id'";
148 $result=$db->update($q);
150 $q="insert into neurons set synapse_creator='".$_SESSION['user_id']."',dst='".$node['node_id']."',src='$referer_id',synapse=1";
154 logger
::log('enter',$node['node_id'],'failed');
159 //entering the node (executing the eventz)
160 if (($permissions['r']) ||
($event != 'register')) {
161 //performing node_events (based on update/insert/delete db queries)
163 require(INCLUDE_DIR
.'eventz.inc');
This page took 1.011214 seconds and 3 git commands to generate.