Commit | Line | Data |
---|---|---|
51ff3226 | 1 | <?php |
2bfe7a1f H |
2 | require_once('config/config.inc'); //requiring main config file with path/database etc. constants |
3 | if(isset($realm) && isset($users)) require_once(INCLUDE_DIR.'http_auth.php'); //Ask for auth if enabled... | |
a81e2af2 | 4 | //echo($_SERVER['PATH_INFO']."\n<pre>"); var_dump(preg_split('/\//', $_SERVER['PATH_INFO'])); die(); //PATH_INFO Debug (usefull when messing with mod_rewrite) |
51ff3226 | 5 | // output buffering forcing (mx) |
6 | if (!empty($_POST['FORCE_OB']) && $_POST['FORCE_OB'] == 'true') ob_start(); | |
7 | ||
51ff3226 | 8 | //header("Location: http://web.archive.org/web/20020925021139/http://kyberia.sk"); |
51ff3226 | 9 | //echo "je to uz uplne v pici. vsetky data su stratene, prajem pekny den :)"; |
10 | //exit; | |
ab8ec5e5 | 11 | |
51ff3226 | 12 | //starting timer for benchmarking purposes |
13 | $timer_start=Time()+SubStr(MicroTime(),0,8); | |
51ff3226 | 14 | //setting PHPSESSID cookie and starting user session |
15 | session_start(); | |
16 | ||
45a1b870 | 17 | error_reporting(1); |
cb4300b2 | 18 | //$_SESSION['debugging']=1; |
88698052 | 19 | //unset($_SESSION['debugging']); //Well... we should make some event or JavaScript page to turning this on/off... |
45a1b870 | 20 | //exit; |
21 | ||
51ff3226 | 22 | |
23 | if ($_SESSION['debugging']) { | |
24 | ||
25 | error_reporting(E_ALL); | |
a81e2af2 | 26 | echo 'GET VARIABLES::<br/>'; |
51ff3226 | 27 | print_r($_GET); |
a81e2af2 | 28 | echo 'POST VARIABLES::<br/>'; |
51ff3226 | 29 | print_r($_POST); |
a81e2af2 | 30 | echo '<b>SESSION VARIABLES::</b><br/>'; |
51ff3226 | 31 | print_r($_SESSION); |
32 | } | |
33 | ||
5c9aff9f H |
34 | @ini_set('magic_quotes_gpc' , 'off'); |
35 | if(get_magic_quotes_gpc()) die("Error: magic_quotes_gpc needs to be disabled! F00K!\n"); | |
36 | ||
4dd26acd | 37 | //Smarty from DB |
00be2b5c H |
38 | $smarty_resource = 'kyberia'; |
39 | //$smarty_resource = ''; //same as 'file' (fallback) | |
40 | /* I have moved old templates to DB using following lame script: | |
41 | * for i in *.tpl; do j=$(echo "$i" | cut -d . -f 1); echo UPDATE nodes SET node_content = "'$(php -r "echo mysql_escape_string(file_get_contents('$i'));")'" WHERE node_id = "'$j'" COLLATE utf8_bin LIMIT '1;'; done | mysql --user=kyberia --password=PASSSSSSS kyberia | |
42 | * In future we should have some mechanism for distributing templates because they are very important part of kyberia source... | |
43 | */ | |
822594dc | 44 | |
a81e2af2 | 45 | //Path info (Experimental - this replaced most of mod_rewrites...) |
822594dc H |
46 | @$PATH_INFO=trim($_SERVER[PATH_INFO]); |
47 | if($PATH_INFO != '') { | |
a81e2af2 | 48 | $PATH_CHUNKS = preg_split('/\//', $PATH_INFO); |
20b73641 | 49 | if(isset($PATH_CHUNKS[1])) switch($PATH_CHUNKS[1]) { |
822594dc H |
50 | case 'k': |
51 | if(isset($PATH_CHUNKS[2]) && $PATH_CHUNKS[2] != '') $_GET['node_kid'] = $PATH_CHUNKS[2]; | |
52 | if(isset($PATH_CHUNKS[3]) && $PATH_CHUNKS[3] != '') $_GET['template_kid'] = $PATH_CHUNKS[3]; | |
53 | break; | |
54 | case 'id': | |
55 | if(isset($PATH_CHUNKS[2]) && $PATH_CHUNKS[2] != '') $_GET['node_id'] = $PATH_CHUNKS[2]; | |
56 | if(isset($PATH_CHUNKS[3]) && $PATH_CHUNKS[3] != '') $_GET['template_id'] = $PATH_CHUNKS[3]; | |
692f2b82 H |
57 | |
58 | //Base36 fascism redirect | |
93748c08 | 59 | if($_GET['template_id'] == 'download') break; //Fix ugly download hack... |
692f2b82 H |
60 | if(!count($_POST)) { |
61 | header('Location: /k/'.base_convert($_GET['node_id'], 10, 36). | |
62 | (isset($_GET['template_id'])?'/'.base_convert($_GET['template_id'], 10, 36):'') | |
63 | ); | |
64 | die("Base36 fascism...\n"); //If you want to be a fascist you have to die imediatelly... | |
65 | } | |
66 | ||
822594dc | 67 | break; |
20b73641 H |
68 | default: |
69 | if($PATH_CHUNKS[1] != '') $_GET['node_name'] = $PATH_CHUNKS[1]; | |
70 | if(isset($PATH_CHUNKS[2]) && $PATH_CHUNKS[2] != '') $_GET['template_kid'] = $PATH_CHUNKS[2]; | |
71 | break; | |
822594dc H |
72 | } |
73 | } | |
15de3e32 H |
74 | if( |
75 | (!isset($_GET['node_kid']) || trim($_GET['node_kid']) == '') && | |
76 | (!isset($_GET['node_id']) || trim($_GET['node_id']) == '') | |
77 | ) $_GET['node_kid'] = 1; | |
822594dc | 78 | |
96a2b554 H |
79 | //Base36 http://en.wikipedia.org/wiki/Base_36 (Initial support only :-) |
80 | if(isset($_GET['node_kid'])) $_GET['node_id'] = base_convert($_GET['node_kid'], 36, 10); | |
81 | if(isset($_GET['template_kid'])) $_GET['template_id'] = base_convert($_GET['template_kid'], 36, 10); | |
82 | ||
2bcd35a6 | 83 | if (isset($_SERVER['HTTP_REFERER'])) { |
a81e2af2 | 84 | preg_match('/(k|id)\/([0-9]*)\//',$_SERVER['HTTP_REFERER'],$ref_match); |
2bcd35a6 | 85 | $referer_id=$ref_match[1]; |
86 | } | |
51ff3226 | 87 | |
88 | //connecting to database and creating universal $db object | |
570ab4b6 | 89 | require_once(INCLUDE_DIR.'senate.inc'); |
cb5cd120 H |
90 | require_once(INCLUDE_DIR.'log.inc'); |
91 | require_once(INCLUDE_DIR.'ubik.inc'); | |
92 | require_once(INCLUDE_DIR.'nodes.inc'); | |
93 | require_once(INCLUDE_DIR.'error_messages.inc'); | |
94 | require_once(INCLUDE_DIR.'database.inc'); | |
95 | require_once(INCLUDE_DIR.'transports.inc'); | |
51ff3226 | 96 | |
e23557a6 | 97 | $db = new CLASS_DATABASE(); |
51ff3226 | 98 | |
99 | if (!empty($_GET['template_id'])) { | |
100 | $template_id=$_GET['template_id']; | |
5b9c0808 | 101 | } else { |
102 | $template_id=false; | |
51ff3226 | 103 | } |
51ff3226 | 104 | |
105 | //initializing node methods | |
106 | if (!empty($_GET['node_name'])) { | |
51ff3226 | 107 | $node = nodes::redirByName($_GET['node_name']); |
5b9c0808 | 108 | } elseif (!empty($_GET['node_id'])) { |
109 | $node = nodes::getNodeById($_GET['node_id'], | |
110 | (isset($_SESSION['user_id']))?$_SESSION['user_id']:''); | |
51ff3226 | 111 | } |
112 | ||
065440d5 | 113 | //XXX Paths are wrong (!) |
51ff3226 | 114 | //loading smarty template engine and setting main parameters |
115 | require(SMARTY_DIR.'Smarty.class.php'); | |
116 | $smarty = new Smarty; | |
6a967e24 | 117 | require(INCLUDE_DIR.'smarty/resource.kyberia.php'); |
00be2b5c | 118 | $smarty->default_resource_type=$smarty_resource; |
51ff3226 | 119 | |
065440d5 | 120 | //$smarty->php_handling = SMARTY_PHP_REMOVE; //XXX |
39244cfc | 121 | $smarty->template_dir = TEMPLATE_DIR; |
51ff3226 | 122 | //echo TEMPLATE_DIR.TEMPLATE_SET; |
123 | //echo $smarty->template_dir; | |
a81e2af2 | 124 | $smarty->compile_dir = SYSTEM_DATA.'templates_c/'; |
175043f4 | 125 | $smarty->config_dir = SMARTY_DIR.'configs/'; //XXX neexistuje |
51ff3226 | 126 | $smarty->cache_dir = SMARTY_DIR.'cache/'; |
127 | $smarty->plugins_dir = SMARTY_PLUGIN_DIR ; | |
128 | if ($_SESSION['debugging']) $smarty->debugging=true; | |
129 | ||
9850bdc4 | 130 | // initializing variables |
131 | // preg_replace prevents LFI | |
65c78def | 132 | if (empty($_POST['event'])) $event='display'; |
9850bdc4 | 133 | else $event= preg_replace( "![^a-zA-Z0-9_]+!", "", $_POST['event']); |
51ff3226 | 134 | |
135 | ||
136 | if ($_SESSION['debugging']) { | |
137 | echo "<pre><b>NODE::"; | |
138 | print_r($node); | |
139 | echo "</pre>"; | |
140 | } | |
141 | ||
12425f11 | 142 | if ((isset($_SESSION['user_id']) && ($node['node_creator']==$_SESSION['user_id']))) { |
006bd683 | 143 | $node['node_permission']='owner'; |
144 | } | |
51ff3226 | 145 | |
006bd683 | 146 | if (isset($_SESSION['cube_vector']) && ($_SESSION['cube_vector'])) { |
51ff3226 | 147 | if (strpos($node['node_vector'],$_SESSION['cube_vector'])===false) { |
148 | echo "node::".$node['node_vector']; | |
149 | echo "cube_Vector::".$_SESSION['cube_vector']; | |
150 | echo "you are out of allowed cwbe. access forbidden"; | |
151 | die(); | |
152 | } | |
153 | } | |
154 | ||
155 | //if not existent node show our own 404 | |
156 | if (empty($node)) { | |
157 | $nodes= nodes::getNodesByName($_GET['node_name']); | |
158 | if ($nodes) { | |
159 | $smarty->assign('nodes',$nodes); | |
00be2b5c | 160 | $content=$smarty->display('404.tpl'); |
51ff3226 | 161 | die(); |
162 | } | |
163 | elseif ($_SESSION['user_id']) { | |
164 | $smarty->assign('node_name',$_GET['node_name']); | |
165 | $content=$smarty->display("modules/addnode.tpl"); | |
166 | } | |
167 | } | |
168 | ||
006bd683 | 169 | //modifying node glass pearl //XXX WTF |
09f0f2fa | 170 | //if (is_array($children_types[$node['node_type']])) { |
171 | // $smarty->assign('children_types',$children_types[$node['node_type']]); | |
172 | //} | |
173 | ||
ac6dff25 | 174 | //smarty->assign('types',$types); |
51ff3226 | 175 | //$node['node_type']=$types[$node['node_type']]; |
570ab4b6 H |
176 | |
177 | @include_once(INCLUDE_DIR.'mail_rss.inc'); //haluz... | |
51ff3226 | 178 | |
179 | //checking permissions | |
180 | function _checkPermissions() | |
181 | { | |
182 | global $permissions, $node; | |
e909f81b | 183 | require(INCLUDE_DIR.'permissions.inc'); |
51ff3226 | 184 | $permissions=permissions::checkPermissions($node); |
185 | $permissions['h']=permissions::isHierarch($node); | |
186 | } | |
51ff3226 | 187 | _checkPermissions(); |
188 | ||
570ab4b6 | 189 | //entering the node (executing the eventz) |
51ff3226 | 190 | if (($permissions['r']) || ($event != 'register')) { |
5b9c0808 | 191 | //performing node_events (based on update/insert/delete db queries) |
192 | if ($event) { | |
193 | require(INCLUDE_DIR.'eventz.inc'); | |
194 | } | |
51ff3226 | 195 | } |
196 | ||
570ab4b6 | 197 | if (isset($_POST['FORCE_OB'])) ob_end_flush(); //output buffering forcing (mx) |
51ff3226 | 198 | |
199 | ?> |