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 | ||
4dd26acd | 34 | //Smarty from DB |
00be2b5c H |
35 | $smarty_resource = 'kyberia'; |
36 | //$smarty_resource = ''; //same as 'file' (fallback) | |
37 | /* I have moved old templates to DB using following lame script: | |
38 | * 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 | |
39 | * In future we should have some mechanism for distributing templates because they are very important part of kyberia source... | |
40 | */ | |
822594dc | 41 | |
a81e2af2 | 42 | //Path info (Experimental - this replaced most of mod_rewrites...) |
822594dc H |
43 | @$PATH_INFO=trim($_SERVER[PATH_INFO]); |
44 | if($PATH_INFO != '') { | |
a81e2af2 | 45 | $PATH_CHUNKS = preg_split('/\//', $PATH_INFO); |
20b73641 | 46 | if(isset($PATH_CHUNKS[1])) switch($PATH_CHUNKS[1]) { |
822594dc H |
47 | case 'k': |
48 | if(isset($PATH_CHUNKS[2]) && $PATH_CHUNKS[2] != '') $_GET['node_kid'] = $PATH_CHUNKS[2]; | |
49 | if(isset($PATH_CHUNKS[3]) && $PATH_CHUNKS[3] != '') $_GET['template_kid'] = $PATH_CHUNKS[3]; | |
50 | break; | |
51 | case 'id': | |
52 | if(isset($PATH_CHUNKS[2]) && $PATH_CHUNKS[2] != '') $_GET['node_id'] = $PATH_CHUNKS[2]; | |
53 | if(isset($PATH_CHUNKS[3]) && $PATH_CHUNKS[3] != '') $_GET['template_id'] = $PATH_CHUNKS[3]; | |
692f2b82 H |
54 | |
55 | //Base36 fascism redirect | |
93748c08 | 56 | if($_GET['template_id'] == 'download') break; //Fix ugly download hack... |
692f2b82 H |
57 | if(!count($_POST)) { |
58 | header('Location: /k/'.base_convert($_GET['node_id'], 10, 36). | |
59 | (isset($_GET['template_id'])?'/'.base_convert($_GET['template_id'], 10, 36):'') | |
60 | ); | |
61 | die("Base36 fascism...\n"); //If you want to be a fascist you have to die imediatelly... | |
62 | } | |
63 | ||
822594dc | 64 | break; |
20b73641 H |
65 | default: |
66 | if($PATH_CHUNKS[1] != '') $_GET['node_name'] = $PATH_CHUNKS[1]; | |
67 | if(isset($PATH_CHUNKS[2]) && $PATH_CHUNKS[2] != '') $_GET['template_kid'] = $PATH_CHUNKS[2]; | |
68 | break; | |
822594dc H |
69 | } |
70 | } | |
15de3e32 H |
71 | if( |
72 | (!isset($_GET['node_kid']) || trim($_GET['node_kid']) == '') && | |
73 | (!isset($_GET['node_id']) || trim($_GET['node_id']) == '') | |
74 | ) $_GET['node_kid'] = 1; | |
822594dc | 75 | |
96a2b554 H |
76 | //Base36 http://en.wikipedia.org/wiki/Base_36 (Initial support only :-) |
77 | if(isset($_GET['node_kid'])) $_GET['node_id'] = base_convert($_GET['node_kid'], 36, 10); | |
78 | if(isset($_GET['template_kid'])) $_GET['template_id'] = base_convert($_GET['template_kid'], 36, 10); | |
79 | ||
1757f060 | 80 | require(INCLUDE_DIR.'senate.inc'); |
51ff3226 | 81 | |
2bcd35a6 | 82 | if (isset($_SERVER['HTTP_REFERER'])) { |
a81e2af2 | 83 | preg_match('/(k|id)\/([0-9]*)\//',$_SERVER['HTTP_REFERER'],$ref_match); |
2bcd35a6 | 84 | $referer_id=$ref_match[1]; |
85 | } | |
51ff3226 | 86 | |
87 | //connecting to database and creating universal $db object | |
1757f060 | 88 | require(INCLUDE_DIR.'log.inc'); |
89 | require(INCLUDE_DIR.'ubik.inc'); | |
90 | require(INCLUDE_DIR.'nodes.inc'); | |
91 | require(INCLUDE_DIR.'error_messages.inc'); | |
92 | require(INCLUDE_DIR.'database.inc'); | |
51ff3226 | 93 | |
e23557a6 | 94 | $db = new CLASS_DATABASE(); |
51ff3226 | 95 | |
96 | if (!empty($_GET['template_id'])) { | |
97 | $template_id=$_GET['template_id']; | |
5b9c0808 | 98 | } else { |
99 | $template_id=false; | |
51ff3226 | 100 | } |
51ff3226 | 101 | |
102 | //initializing node methods | |
103 | if (!empty($_GET['node_name'])) { | |
51ff3226 | 104 | $node = nodes::redirByName($_GET['node_name']); |
5b9c0808 | 105 | } elseif (!empty($_GET['node_id'])) { |
106 | $node = nodes::getNodeById($_GET['node_id'], | |
107 | (isset($_SESSION['user_id']))?$_SESSION['user_id']:''); | |
51ff3226 | 108 | } |
109 | ||
065440d5 | 110 | //XXX Paths are wrong (!) |
51ff3226 | 111 | //loading smarty template engine and setting main parameters |
112 | require(SMARTY_DIR.'Smarty.class.php'); | |
113 | $smarty = new Smarty; | |
6a967e24 | 114 | require(INCLUDE_DIR.'smarty/resource.kyberia.php'); |
00be2b5c | 115 | $smarty->default_resource_type=$smarty_resource; |
51ff3226 | 116 | |
065440d5 | 117 | //$smarty->php_handling = SMARTY_PHP_REMOVE; //XXX |
39244cfc | 118 | $smarty->template_dir = TEMPLATE_DIR; |
51ff3226 | 119 | //echo TEMPLATE_DIR.TEMPLATE_SET; |
120 | //echo $smarty->template_dir; | |
a81e2af2 | 121 | $smarty->compile_dir = SYSTEM_DATA.'templates_c/'; |
175043f4 | 122 | $smarty->config_dir = SMARTY_DIR.'configs/'; //XXX neexistuje |
51ff3226 | 123 | $smarty->cache_dir = SMARTY_DIR.'cache/'; |
124 | $smarty->plugins_dir = SMARTY_PLUGIN_DIR ; | |
125 | if ($_SESSION['debugging']) $smarty->debugging=true; | |
126 | ||
9850bdc4 | 127 | // initializing variables |
128 | // preg_replace prevents LFI | |
51ff3226 | 129 | if (empty($_POST['event'])) $event=false; |
9850bdc4 | 130 | else $event= preg_replace( "![^a-zA-Z0-9_]+!", "", $_POST['event']); |
51ff3226 | 131 | |
132 | ||
133 | if ($_SESSION['debugging']) { | |
134 | echo "<pre><b>NODE::"; | |
135 | print_r($node); | |
136 | echo "</pre>"; | |
137 | } | |
138 | ||
12425f11 | 139 | if ((isset($_SESSION['user_id']) && ($node['node_creator']==$_SESSION['user_id']))) { |
006bd683 | 140 | $node['node_permission']='owner'; |
141 | } | |
51ff3226 | 142 | |
006bd683 | 143 | if (isset($_SESSION['cube_vector']) && ($_SESSION['cube_vector'])) { |
51ff3226 | 144 | if (strpos($node['node_vector'],$_SESSION['cube_vector'])===false) { |
145 | echo "node::".$node['node_vector']; | |
146 | echo "cube_Vector::".$_SESSION['cube_vector']; | |
147 | echo "you are out of allowed cwbe. access forbidden"; | |
148 | die(); | |
149 | } | |
150 | } | |
151 | ||
152 | //if not existent node show our own 404 | |
153 | if (empty($node)) { | |
154 | $nodes= nodes::getNodesByName($_GET['node_name']); | |
155 | if ($nodes) { | |
156 | $smarty->assign('nodes',$nodes); | |
00be2b5c | 157 | $content=$smarty->display('404.tpl'); |
51ff3226 | 158 | die(); |
159 | } | |
160 | elseif ($_SESSION['user_id']) { | |
161 | $smarty->assign('node_name',$_GET['node_name']); | |
162 | $content=$smarty->display("modules/addnode.tpl"); | |
163 | } | |
164 | } | |
165 | ||
006bd683 | 166 | //modifying node glass pearl //XXX WTF |
09f0f2fa | 167 | //if (is_array($children_types[$node['node_type']])) { |
168 | // $smarty->assign('children_types',$children_types[$node['node_type']]); | |
169 | //} | |
170 | ||
ac6dff25 | 171 | //smarty->assign('types',$types); |
51ff3226 | 172 | |
173 | ||
174 | //$node['node_type']=$types[$node['node_type']]; | |
006bd683 | 175 | $node['node_content']= StripSlashes($node['node_content']); |
176 | $node['node_name']= StripSlashes($node['node_name']); | |
51ff3226 | 177 | |
178 | //checking permissions | |
179 | function _checkPermissions() | |
180 | { | |
181 | global $permissions, $node; | |
182 | ||
e909f81b | 183 | require(INCLUDE_DIR.'permissions.inc'); |
51ff3226 | 184 | $permissions=permissions::checkPermissions($node); |
185 | $permissions['h']=permissions::isHierarch($node); | |
186 | } | |
187 | ||
188 | // mail rss | |
5b9c0808 | 189 | if ($template_id=='rss') //XXX WHAT? |
51ff3226 | 190 | { |
191 | $_feedType = "RSS0.91"; | |
192 | if (!is_numeric($_SESSION['user_id'])) | |
193 | { | |
194 | if (!isset($_SERVER['PHP_AUTH_USER'])) { | |
195 | header('WWW-Authenticate: Basic realm="Kyberia"'); | |
196 | header('HTTP/1.0 401 Unauthorized'); | |
197 | echo 'Cancel button'; | |
198 | exit; | |
199 | } | |
200 | else | |
201 | { | |
202 | require_once(EVENT_DIR.'/login.inc'); | |
203 | $_POST['login'] = $_SERVER['PHP_AUTH_USER']; | |
204 | $_POST['password'] = $_SERVER['PHP_AUTH_PW']; | |
205 | $_POST['login_type'] = "name"; | |
206 | if (!login()) | |
207 | { | |
208 | echo "Zle meno/heslo."; | |
209 | exit(); | |
210 | } | |
211 | } | |
212 | } | |
213 | ||
214 | _checkPermissions(); | |
215 | ||
216 | ||
217 | if ($_GET['node_id']==='24' && $permissions['r']) | |
218 | { | |
219 | require_once(INCLUDE_DIR.'/feedcreator.class.php'); | |
220 | ||
82765da6 | 221 | $rss = new UniversalFeedCreator(); |
51ff3226 | 222 | $rss->title = "Kyberia mail"; |
223 | $rss->description = ""; | |
b6e35197 | 224 | $rss->link = "https://". SYSTEM_URL . "/id/24"; |
51ff3226 | 225 | |
5b9c0808 | 226 | //XXX into function |
51ff3226 | 227 | $query = "select date_format(mail.mail_timestamp,\"%e.%c. %k:%i:%s\") as cas, |
228 | userfrom.user_action as locationfrom_action, | |
229 | userfrom.user_action_id as locationfrom_action_id, | |
230 | userto.user_action as locationto_action, | |
231 | userto.user_action_id as locationto_action_id, | |
232 | userto.login as mail_to_name, userfrom.login as mail_from_name, | |
233 | mail.* from mail left join users as userfrom on | |
234 | mail_from=userfrom.user_id left join users as userto on mail_to=userto.user_id | |
235 | where mail_user='$_SESSION[user_id]' and mail_to='$_SESSION[user_id]' order by mail_id desc limit 0,10"; | |
236 | ||
237 | $set = $db->query($query); | |
238 | ||
239 | while($set->next()) { | |
240 | $m = $set->getRecord(); | |
241 | if ($m['mail_to'] != $_SESSION['user_id']) | |
242 | continue; | |
82765da6 | 243 | $item = new FeedItem(); |
51ff3226 | 244 | $item->title = $m['mail_from_name']; |
b6e35197 | 245 | $item->link = "https://".SYSTEM_URL."/id/24"; |
51ff3226 | 246 | $item->description = $m['mail_text']; |
247 | $rss->addItem($item); | |
248 | } | |
249 | } | |
250 | // bookmarks | |
251 | elseif ($_GET['node_id']=='19' && $permissions['r']) | |
252 | { | |
253 | require_once(INCLUDE_DIR.'/feedcreator.class.php'); | |
254 | ||
82765da6 | 255 | $rss = new UniversalFeedCreator(); |
51ff3226 | 256 | $rss->title = "Kyberia bookmarks"; |
5b9c0808 | 257 | $rss->link = "http://".SYSTEM_URL."/id/19"; //XXX https ? |
51ff3226 | 258 | |
259 | require_once(SMARTY_PLUGIN_DIR.'/function.get_bookmarks.php'); | |
260 | smarty_function_get_bookmarks(array(), $smarty); | |
261 | $_items = $smarty->get_template_vars('get_bookmarks'); | |
262 | foreach ($_items as $_item) | |
263 | { | |
264 | if (is_array($_item['children'])) | |
265 | foreach ($_item['children'] as $_b) | |
266 | { | |
82765da6 | 267 | $item = new FeedItem(); |
51ff3226 | 268 | $item->title = $_b['node_name']; |
b6e35197 | 269 | $item->link = "http://".SYSTEM_URL."/id/".$_b['node_id']."/rss"; |
51ff3226 | 270 | $rss->addItem($item); |
271 | } | |
272 | } | |
273 | $_feedType = 'OPML'; | |
274 | } | |
275 | elseif ($permissions['r']) | |
276 | { | |
277 | require_once(INCLUDE_DIR.'/feedcreator.class.php'); | |
278 | ||
82765da6 | 279 | $rss = new UniversalFeedCreator(); |
51ff3226 | 280 | $rss->title = $node['node_name']; |
281 | $rss->description = ""; | |
b6e35197 | 282 | $rss->link = "http://".SYSTEM_URL."/id/".$node['node_id']; |
51ff3226 | 283 | |
284 | // K list | |
285 | if ($_GET['node_id']=='15') | |
286 | { | |
287 | require_once(SMARTY_PLUGIN_DIR.'/function.get_k.php'); | |
288 | smarty_function_get_k(array(), $smarty); | |
289 | $_items = $smarty->get_template_vars('get_k'); | |
290 | } | |
291 | else | |
292 | { | |
293 | require_once(SMARTY_PLUGIN_DIR.'/function.get_children.php'); | |
294 | smarty_function_get_children( | |
295 | array('orderby' => 'desc', 'orderby_type' => 'time'), $smarty); | |
296 | $_items = $smarty->get_template_vars('get_children'); | |
297 | } | |
298 | ||
299 | foreach ($_items as $_item) | |
300 | { | |
82765da6 | 301 | $item = new FeedItem(); |
51ff3226 | 302 | $item->title = $_item['node_name']; |
b6e35197 | 303 | $item->link = "http://".SYSTEM_URL."/id/".$_item['node_id']; |
51ff3226 | 304 | $item->description = $_item['node_content']; |
305 | $rss->addItem($item); | |
306 | } | |
307 | } | |
308 | ||
309 | if ($permissions['r']) $rss->showFeed($_feedType); | |
310 | exit(); | |
311 | } | |
312 | ||
313 | _checkPermissions(); | |
314 | ||
315 | //entering the node | |
316 | ||
317 | //sventest | |
318 | if (($permissions['r']) || ($event != 'register')) { | |
319 | ||
5b9c0808 | 320 | //performing node_events (based on update/insert/delete db queries) |
321 | if ($event) { | |
322 | require(INCLUDE_DIR.'eventz.inc'); | |
323 | } | |
51ff3226 | 324 | |
5b9c0808 | 325 | elseif ($transaction) { |
326 | require(INCLUDE_DIR.'transaction.inc'); | |
327 | } | |
328 | //end of performing node events | |
51ff3226 | 329 | |
5b9c0808 | 330 | //sventest |
51ff3226 | 331 | } |
332 | ||
333 | ||
334 | if ($permissions['r']) { | |
335 | ||
5b9c0808 | 336 | // these 4 lines are not the source of kyberia lagging problems. |
337 | // leave them. started on the 10.4. | |
338 | // data gained will be used for scientific purposes | |
339 | ||
340 | // if (isset($_SESSION['user_id']) { | |
341 | // log_levenshtein($_SESSION['user_id'],$node['node_id']); | |
342 | // } | |
343 | ||
d9464c68 | 344 | if ((isset($_SESSION['user_id'])) && ($_SESSION['user_id'])) { |
51ff3226 | 345 | $q="insert delayed into levenshtein set user_id='".$_SESSION['user_id']."',node_id='".$node['node_id']."'"; |
346 | $db->update($q); | |
347 | } | |
348 | ||
349 | //if node is css | |
5b9c0808 | 350 | //XXX into function |
51ff3226 | 351 | if ($node['template_id']!='2019721'){ |
352 | ||
fd15ea3a | 353 | logger::log('enter',$node['node_id'],'ok',$node['node_user_subchild_count']); |
51ff3226 | 354 | if (!empty($_SESSION['user_id']) && is_numeric($node['node_id'])) { |
355 | $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']."'"; | |
356 | // echo $q; | |
357 | $result=$db->update($q); | |
358 | ||
359 | if (!$result) { | |
360 | $q="insert into node_access set user_id='".$_SESSION['user_id']."',node_id='".$node['node_id']."',last_visit=NOW()"; | |
361 | $db->query($q); | |
5b9c0808 | 362 | } |
363 | }//end of if node os css | |
51ff3226 | 364 | } |
365 | ||
5b9c0808 | 366 | } |
367 | ||
368 | //XXX into function | |
369 | // if (isset($_SESSION['user_id']) { | |
370 | // if (isset($referer_id)) { | |
371 | // update_nodes($_SESSION['user_id'],$node['node_id'],$referer_id); | |
372 | // } else { | |
373 | // update_nodes($_SESSION['user_id'],$node['node_id'],0); | |
374 | // } | |
375 | // } | |
51ff3226 | 376 | |
51ff3226 | 377 | // DO NOT MESS WITH THIS !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
378 | //creating neural network | |
379 | $db->update("update nodes set node_views=node_views+1 where node_id='".$node['node_id']."'"); | |
202718bc | 380 | if (isset($referer_id) && is_numeric($referer_id)) { |
51ff3226 | 381 | $q="update neurons set synapse=synapse+1 where dst='".$node['node_id']."' and src='$referer_id'"; |
382 | $result=$db->update($q); | |
383 | if (!$result) { | |
384 | $q="insert into neurons set synapse_creator='".$_SESSION['user_id']."',dst='".$node['node_id']."',src='$referer_id',synapse=1"; | |
385 | $db->query($q); | |
386 | } | |
387 | } | |
388 | ||
389 | ||
390 | elseif (!$permissions['r'] && $_GET['magic_word']) { | |
391 | $magic_word_big=$_GET['magic_word']; | |
392 | ||
393 | if ( preg_match("/(\d+)-(.+)/",$_GET['magic_word'],$mu)) { | |
394 | $magic_uid=$mu['1']; | |
395 | $magic_word=addslashes($mu['2']); | |
5b9c0808 | 396 | // XXX WTF column magic_word does not exists |
51ff3226 | 397 | $q="select login from users where user_id='$magic_uid' and magic_word='$magic_word'"; |
398 | $set=$db->query($q); | |
399 | if ($set->getNumRows()) { | |
400 | $permissions['r']=true; | |
401 | } | |
402 | } | |
403 | } | |
404 | ||
405 | ||
406 | ||
407 | ||
408 | ||
409 | else { | |
fd15ea3a | 410 | logger::log('enter',$node['node_id'],'failed'); |
51ff3226 | 411 | } |
412 | ||
413 | ||
414 | ||
415 | //assigning user data to smarty if user logged in | |
58a9d5d7 | 416 | if (isset($_SESSION['user_id'])&&($user_id=$_SESSION['user_id'])) { |
51ff3226 | 417 | $smarty->assign('_POST',$_POST); |
418 | $smarty->assign('bookmarks',$_SESSION['bookmarks']); | |
419 | $smarty->assign('ignore',$_SESSION['ignore']); | |
420 | $smarty->assign('bookstyl',$_SESSION['bookstyl']); | |
421 | $smarty->assign('fook',$_SESSION['fook']); | |
422 | $smarty->assign('user_id',$_SESSION['user_id']); | |
9a7d7230 | 423 | if (!empty($_SESSION['cube_vector'])) |
424 | $smarty->assign('cube_vector',$_SESSION['cube_vector']); | |
51ff3226 | 425 | $smarty->assign('friends',$_SESSION['friends']); //req by freezy, done by darkaural |
426 | $smarty->assign('user_quota',$_SESSION['user_quota']); | |
9a7d7230 | 427 | |
5b9c0808 | 428 | // XXX into function |
9a7d7230 | 429 | $newmail_q = sprintf('select u.user_mail_id |
430 | , u.user_k | |
431 | , u.k_wallet | |
432 | , u.user_mail | |
433 | , ms.user_id as mail_sender_id | |
434 | , ms.login as mail_sender | |
435 | from users u | |
436 | left join users ms on ms.user_id = u.user_mail_id | |
437 | where u.user_id = %d', | |
438 | $user_id); | |
439 | $newmailset = $db->query($newmail_q); | |
440 | ||
9a7d7230 | 441 | |
51ff3226 | 442 | $newmailset->next(); |
443 | $new_mail=$newmailset->getString('user_mail'); | |
5b9c0808 | 444 | // XXX into function |
51ff3226 | 445 | $newmailset2 = $db->query("select users.user_mail_id,mailsender.login |
446 | from users left join users as mailsender on users.user_mail_id = mailsender.user_id where users.user_id = '$user_id'"); | |
447 | $newmailset2->next(); | |
448 | $smarty->assign('new_mail',$new_mail); | |
9a7d7230 | 449 | $smarty->assign('new_mail_name',$newmailset->getString('mail_sender')); |
51ff3226 | 450 | $smarty->assign('new_mail_name2',$newmailset2->getString('login')); |
451 | $user_k=$newmailset->getString('user_k'); | |
452 | $smarty->assign('user_k',$user_k); | |
453 | $k_wallet=$newmailset->getString('k_wallet'); | |
454 | $smarty->assign('k_wallet',$k_wallet); | |
455 | $user_id=$_SESSION['user_id']; | |
456 | ||
457 | //mail node | |
458 | if ($node['node_name']=='mail') { | |
459 | ||
460 | //clear new mail message | |
5b9c0808 | 461 | |
51ff3226 | 462 | if ($new_mail) $db->query("update users set user_mail=0 where user_id='$user_id'"); |
463 | ||
464 | //set messages as delivered to recipient | |
465 | $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'"); | |
466 | while($set->next()) { | |
467 | $db->query("update mail set mail_read='yes' where mail_id='".$set->getString('mail_duplicate_id')."'"); | |
468 | $db->query("update mail set mail_read='yes' where mail_id='".$set->getString('mail_id')."'"); | |
469 | ||
470 | $new_messages[$set->getString('mail_id')]=true; | |
471 | } | |
472 | /* | |
473 | if (count($new_messages)) { | |
474 | $db->query("update mail set mail_read='yes' where mail_user='$user_id' and mail_user=mail_to and mail_read='no'"); | |
475 | $smarty->assign('new_messages',$new_messages); | |
476 | ||
477 | } | |
478 | */ | |
479 | } | |
480 | } | |
481 | ||
482 | ||
483 | ||
484 | if ($node['node_system_access']=='crypto') { | |
485 | $smarty->assign('crypto_pass',$_SESSION['crypto'][$node['node_id']]); | |
486 | } | |
487 | ||
51ff3226 | 488 | $smarty->assign('error',$error); |
489 | $smarty->assign('permissions',$permissions); | |
490 | $smarty->assign('current_vector',$node['node_vector']); | |
491 | if ($permissions['r']) $smarty->assign('node',$node); | |
492 | else { | |
493 | ||
494 | $smarty->assign('node',$node); | |
495 | //new templates by Dark matter | |
496 | $smarty->template_dir=OWN_TEMPLATE_DIR; | |
497 | ||
00be2b5c H |
498 | $smarty->display('1549864.tpl'); |
499 | $smarty->display('1549885.tpl'); | |
500 | $smarty->display('630526.tpl'); | |
51ff3226 | 501 | die(); |
502 | ||
503 | //redirect to mainpage | |
504 | // looks like poeple totaly hate this redirect! | |
505 | // header("Location: /id/1"); | |
506 | } | |
507 | ||
508 | ||
5b9c0808 | 509 | // XXX into function |
58a9d5d7 | 510 | if (($node['template_id']!='2019721') && (isset($_SESSION['user_id']))){ |
51ff3226 | 511 | //setting user location |
512 | $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']."'"; | |
513 | $db->executequery($q); | |
514 | } | |
515 | ||
516 | $whole_time=SubStr((Time()+SubStr(MicroTime(),0,8)-$timer_start),0,7); | |
517 | $smarty->assign('whole_time',$whole_time); | |
518 | ||
519 | ||
520 | if ($template_id=='download' OR $template_id=='download.jpg') { | |
521 | if ($permissions['r']) { | |
522 | $linkname = SYSTEM_ROOT."/files/".$node['node_id']; | |
523 | $filename= readlink($linkname); | |
524 | $suffix=preg_replace("/(.*?)\.(.*?)/i","$2",$filename); | |
525 | ||
526 | $ext = substr( $filename,-3 ); | |
527 | if( $filename == "" ) { | |
528 | echo "ERROR: Empty file to download. "; | |
529 | exit; | |
530 | } elseif ( ! file_exists( $filename ) ) { | |
531 | exit; | |
532 | }; | |
533 | switch( strtolower($ext) ){ | |
534 | case "pdf": $ctype="application/pdf"; break; | |
535 | case "exe": $ctype="application/octet-stream"; break; | |
536 | case "zip": $ctype="application/zip"; break; | |
537 | case "doc": $ctype="application/msword"; break; | |
538 | case "xls": $ctype="application/vnd.ms-excel"; break; | |
539 | case "ppt": $ctype="application/vnd.ms-powerpoint"; break; | |
540 | case "gif": $ctype="image/gif"; break; | |
541 | case "png": $ctype="image/png"; break; | |
542 | case "jpg": $ctype="image/jpg"; break; | |
543 | default: $ctype="application/force-download"; | |
544 | } | |
545 | $file=str_replace(" ","_",$node['node_name']).".$ext"; | |
546 | header("Pragma: public"); | |
547 | header("Expires: 0"); | |
548 | header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); | |
549 | header("Content-Type: $ctype"); | |
550 | $user_agent = strtolower ($_SERVER["HTTP_USER_AGENT"]); | |
551 | if ((is_integer (strpos($user_agent, "msie"))) && (is_integer | |
552 | (strpos($user_agent, "win")))) { | |
553 | header( "Content-Disposition: filename=$file;" ); | |
554 | } else { | |
555 | header( "Content-Disposition: attachment; | |
556 | filename=$file;" ); | |
557 | } | |
558 | header("Content-Transfer-Encoding: binary"); | |
559 | header("Content-Length: ".filesize($filename)); | |
560 | readfile("$filename"); | |
561 | exit(); | |
562 | } | |
563 | else { echo "you don't have permissions for downloading this data"; die(); } | |
564 | } | |
565 | ||
566 | if ($node['template_id']=='2019721'){ | |
567 | Header("Cache-control: max-age=3600"); | |
568 | }else{ | |
569 | Header("Cache-control: no-cache"); | |
570 | Header("Expires:".gmdate("D, d M Y H:i:s")." GMT"); | |
571 | header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); | |
572 | } | |
573 | ||
574 | ||
575 | //for cases like search & preview | |
576 | $smarty->assign('post_vars',$_POST); | |
577 | if (!empty($_POST['template_event'])) { | |
578 | $smarty->assign('template_event',$_POST['template_event']); | |
579 | ||
580 | } | |
581 | ||
582 | //setting listing parameters | |
583 | $children_count=$node['node_children_count']; | |
584 | $descendant_count=$node['node_descendant_count']; | |
585 | ||
202718bc | 586 | if (isset($_POST['listing_amount']) && is_numeric($_POST['listing_amount'])) { |
587 | $listing_amount=mysql_real_escape_string($_POST['listing_amount']); | |
588 | }elseif (!empty($_SESSION['listing_amount'])) $listing_amount=$_SESSION['listing_amount']; | |
51ff3226 | 589 | else $listing_amount=DEFAULT_LISTING_AMOUNT; |
590 | $smarty->assign('listing_amount',$listing_amount); | |
591 | ||
202718bc | 592 | if (isset($_POST['listing_order']) && $_POST['listing_order']) { |
593 | $listing_order=mysql_real_escape_string($_POST['listing_order']); | |
594 | } elseif (!empty($_SESSION['listing_order'])) $listing_order=$_SESSION['listing_order']; | |
51ff3226 | 595 | else $listing_order=DEFAULT_LISTING_ORDER; |
596 | $smarty->assign('listing_order',$listing_order); | |
597 | ||
202718bc | 598 | if (isset ($_POST['get_children_offset']) && is_numeric($_POST['get_children_offset'])) { |
599 | $offset=$_POST['get_children_offset']; | |
600 | } else { $offset=0; } | |
51ff3226 | 601 | |
602 | ||
603 | //movement forward and backward | |
604 | // if ($listing_order=='asc' && !$offset) $offset=$descendant_count-$listing_amount; | |
605 | ||
606 | if ($_POST['get_children_move']=='<') { | |
607 | $offset=$offset-$listing_amount; | |
608 | if ($offset<0) $offset=0; | |
609 | } | |
610 | elseif ($_POST['get_children_move']=='>') { | |
611 | $offset=$offset+$listing_amount; | |
612 | } | |
613 | elseif ($_POST['get_children_move']=='>>') { | |
614 | $offset=$descendant_count-$listing_amount; | |
615 | } | |
616 | ||
617 | elseif ($_POST['get_children_move']=='<<') { | |
618 | $offset=0; | |
619 | } | |
620 | if ($offset<0) $offset=0; | |
621 | $_POST['offset']=$offset; | |
622 | $smarty->assign('offset',$offset); | |
623 | ||
624 | ||
625 | if ($node['external_link']=='header://svg' && !is_numeric($template_id)) { | |
626 | header("Content-Type: image/svg+xml"); | |
627 | } | |
628 | ||
629 | //show own header | |
58a9d5d7 | 630 | elseif (isset($_SESSION['header_id']) && ($_SESSION['header_id']==true)) { |
51ff3226 | 631 | $smarty->assign('header_id',$_SESSION['header_id']); |
632 | $smarty->template_dir=OWN_TEMPLATE_DIR; | |
00be2b5c | 633 | $content=$smarty->fetch($_SESSION['header_id'].".tpl"); |
51ff3226 | 634 | $smarty->template_dir = TEMPLATE_DIR.TEMPLATE_SET; |
635 | //not registered user | |
636 | if ($_SESSION['header_id']==2091520) { | |
637 | echo $content; | |
638 | session_destroy(); | |
639 | die(); | |
640 | } | |
641 | } | |
642 | ||
643 | $smarty->template_dir=OWN_TEMPLATE_DIR; | |
644 | ||
645 | if (is_numeric($template_id)) { | |
00be2b5c | 646 | $content.=$smarty->fetch($template_id.".tpl"); |
51ff3226 | 647 | } |
648 | ||
649 | else { | |
650 | $template_id=$node['template_id']; | |
00be2b5c | 651 | $content.=$smarty->fetch($node['template_id'].".tpl"); |
51ff3226 | 652 | } |
653 | ||
654 | if ($template_id=='2019721'){ | |
00be2b5c | 655 | $content=$smarty->fetch($template_id.".tpl"); |
51ff3226 | 656 | echo $content; |
657 | }else{ | |
658 | $time=SubStr((Time()+SubStr(MicroTime(),0,8)-$timer_start),0,7); | |
659 | echo $content; | |
660 | // echo "<center>page generation took: $time second</center>"; | |
661 | } | |
662 | //end of displaying | |
663 | ||
664 | // output buffering forcing (mx) | |
665 | if (!empty($_POST['FORCE_OB']) && $_POST['FORCE_OB'] == 'true') ob_end_flush(); | |
666 | ||
667 | ?> |