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