3 //requiring main config file with path/database etc. constants
4 require_once('config/config.inc');
6 //Ask for auth if enabled...
7 //if(isset($realm) && isset($users)) require_once(INCLUDE_DIR.'http_auth.php');
9 //PATH_INFO Debug (usefull when messing with mod_rewrite)
10 //echo($_SERVER['PATH_INFO']."\n<pre>");
11 //var_dump(preg_split('/\//', $_SERVER['PATH_INFO'])); die();
12 //output buffering forcing (mx)
14 if (!empty($_POST['FORCE_OB']) && $_POST['FORCE_OB'] == 'true') ob_start();
16 //header("Location: http://web.archive.org/web/20020925021139/http://kyberia.sk");
17 //echo "je to uz uplne v pici. vsetky data su stratene, prajem pekny den :)";
20 //starting timer for benchmarking purposes
21 $timer_start=Time()+
SubStr(MicroTime(),0,8);
22 //setting PHPSESSID cookie and starting user session
26 //$_SESSION['debugging']=1;
27 //unset($_SESSION['debugging']);
28 //Well... we should make some event
29 //or JavaScript page to turning this on/off...
33 if ($_SESSION['debugging']) {
35 error_reporting(E_ALL
);
36 echo 'GET VARIABLES::<br/>';
38 echo 'POST VARIABLES::<br/>';
40 echo '<b>SESSION VARIABLES::</b><br/>';
44 @ini_set
('magic_quotes_gpc' , 'off');
45 if(get_magic_quotes_gpc()) {
46 die("Error: magic_quotes_gpc needs to be disabled! F00K!\n");
50 $smarty_resource = 'kyberia';
51 //$smarty_resource = ''; //same as 'file' (fallback)
52 /* I have moved old templates to DB using following lame script:
53 * for i in *.tpl; do j=$(echo "$i" | cut -d . -f 1);
54 echo UPDATE nodes SET node_content = "'$(php -r
55 "echo mysql_escape_string(file_get_contents('$i'));")'" WHERE
56 node_id = "'$j'" COLLATE utf8_bin LIMIT '1;';
57 done | mysql --user=kyberia --password=PASSSSSSS kyberia
58 * In future we should have some mechanism for distributing templates
59 * because they are very important part of kyberia source...
62 //Path info (Experimental - this replaced most of mod_rewrites...)
63 @$PATH_INFO=trim($_SERVER[PATH_INFO
]);
64 if($PATH_INFO != '') {
65 $PATH_CHUNKS = preg_split('/\//', $PATH_INFO);
66 if(isset($PATH_CHUNKS[1])) switch($PATH_CHUNKS[1]) {
68 if(isset($PATH_CHUNKS[2]) && $PATH_CHUNKS[2] != '') $_GET['node_kid'] = $PATH_CHUNKS[2];
69 if(isset($PATH_CHUNKS[3]) && $PATH_CHUNKS[3] != '') $_GET['template_kid'] = $PATH_CHUNKS[3];
72 if(isset($PATH_CHUNKS[2]) && $PATH_CHUNKS[2] != '') $_GET['node_id'] = $PATH_CHUNKS[2];
73 if(isset($PATH_CHUNKS[3]) && $PATH_CHUNKS[3] != '') $_GET['template_id'] = $PATH_CHUNKS[3];
75 //Base36 fascism redirect
76 if($_GET['template_id'] == 'download') break; //Fix ugly download hack...
78 header('Location: /k/'.base_convert($_GET['node_id'], 10, 36).
79 (isset($_GET['template_id'])?
'/'.base_convert($_GET['template_id'], 10, 36):'')
81 die("Base36 fascism...\n");
82 // If you want to be a fascist
83 // you have to die imediatelly...
88 if($PATH_CHUNKS[1] != '') $_GET['node_name'] = $PATH_CHUNKS[1];
89 if(isset($PATH_CHUNKS[2]) && $PATH_CHUNKS[2] != '') $_GET['template_kid'] = $PATH_CHUNKS[2];
94 (!isset($_GET['node_kid']) ||
trim($_GET['node_kid']) == '') &&
95 (!isset($_GET['node_id']) ||
trim($_GET['node_id']) == '')
96 ) $_GET['node_kid'] = 1;
98 //Base36 http://en.wikipedia.org/wiki/Base_36 (Initial support only :-)
99 if(isset($_GET['node_kid'])) $_GET['node_id'] = base_convert($_GET['node_kid'], 36, 10);
100 if(isset($_GET['template_kid'])) $_GET['template_id'] = base_convert($_GET['template_kid'], 36, 10);
102 if (isset($_SERVER['HTTP_REFERER'])) {
103 preg_match('/(k|id)\/([0-9]*)\//',$_SERVER['HTTP_REFERER'],$ref_match);
104 $referer_id=$ref_match[1];
107 //connecting to database and creating universal $db object
108 //require_once(INCLUDE_DIR.'senate.inc'); // in config already
109 require_once(INCLUDE_DIR
.'log.inc');
110 require_once(INCLUDE_DIR
.'ubik.inc');
111 require_once(INCLUDE_DIR
.'nodes.inc');
112 require_once(INCLUDE_DIR
.'error_messages.inc');
113 require_once(INCLUDE_DIR
.'database.inc');
114 require_once(INCLUDE_DIR
.'transports.inc');
116 $db = new CLASS_DATABASE();
118 if (!empty($_GET['template_id'])) {
119 $template_id=$_GET['template_id'];
124 //initializing node methods
125 if (!empty($_GET['node_name'])) {
126 $node = nodes
::redirByName($_GET['node_name']);
127 } elseif (!empty($_GET['node_id'])) {
128 $node = nodes
::getNodeById($_GET['node_id'],
129 (isset($_SESSION['user_id']))?
$_SESSION['user_id']:'');
132 //XXX Paths are wrong (!)
133 //loading smarty template engine and setting main parameters
134 require(SMARTY_DIR
.'Smarty.class.php');
135 $smarty = new Smarty
;
136 require(INCLUDE_DIR
.'smarty/resource.kyberia.php');
137 $smarty->default_resource_type
=$smarty_resource;
139 //$smarty->php_handling = SMARTY_PHP_REMOVE; //XXX
140 $smarty->template_dir
= TEMPLATE_DIR
;
141 //echo TEMPLATE_DIR.TEMPLATE_SET;
142 //echo $smarty->template_dir;
143 $smarty->compile_dir
= SYSTEM_DATA
.'templates_c/';
144 $smarty->config_dir
= SMARTY_DIR
.'configs/'; //XXX neexistuje
145 $smarty->cache_dir
= SMARTY_DIR
.'cache/';
146 $smarty->plugins_dir
= SMARTY_PLUGIN_DIR
;
147 if ($_SESSION['debugging']) $smarty->debugging
=true;
149 // initializing variables
150 // preg_replace prevents LFI
151 if (empty($_POST['event'])) $event='display';
152 else $event= preg_replace( "![^a-zA-Z0-9_]+!", "", $_POST['event']);
155 if ($_SESSION['debugging']) {
156 echo "<pre><b>NODE::";
161 if ((isset($_SESSION['user_id']) && ($node['node_creator']==$_SESSION['user_id']))) {
162 $node['node_permission']='owner';
165 if (isset($_SESSION['cube_vector']) && ($_SESSION['cube_vector'])) {
166 if (strpos($node['node_vector'],$_SESSION['cube_vector'])===false) {
167 echo "node::".$node['node_vector'];
168 echo "cube_Vector::".$_SESSION['cube_vector'];
169 echo "you are out of allowed cwbe. access forbidden";
174 //if not existent node show our own 404
176 $nodes= nodes
::getNodesByName($_GET['node_name']);
178 $smarty->assign('nodes',$nodes);
179 $content=$smarty->display('404.tpl');
182 elseif ($_SESSION['user_id']) {
183 $smarty->assign('node_name',$_GET['node_name']);
184 $content=$smarty->display("modules/addnode.tpl");
188 //modifying node glass pearl //XXX WTF
189 //if (is_array($children_types[$node['node_type']])) {
190 // $smarty->assign('children_types',$children_types[$node['node_type']]);
193 //smarty->assign('types',$types);
194 //$node['node_type']=$types[$node['node_type']];
196 @include_once
(INCLUDE_DIR
.'mail_rss.inc'); //haluz...
198 //checking permissions
199 function _checkPermissions()
201 global $permissions, $node;
202 require(INCLUDE_DIR
.'permissions.inc');
203 $permissions=permissions
::checkPermissions($node);
204 $permissions['h']=permissions
::isHierarch($node);
208 //entering the node (executing the eventz)
209 if (($permissions['r']) ||
($event != 'register')) {
210 //performing node_events (based on update/insert/delete db queries)
212 require(INCLUDE_DIR
.'eventz.inc');
216 if (isset($_POST['FORCE_OB'])) ob_end_flush(); //output buffering forcing (mx)
This page took 0.94948 seconds and 4 git commands to generate.