Commit | Line | Data |
---|---|---|
e586807d | 1 | <?php |
b42b2bf9 H |
2 | // output buffering forcing (mx) |
3 | if (!empty($_POST['FORCE_OB']) && $_POST['FORCE_OB'] == 'true') ob_start(); | |
4 | ||
5 | //header("Location: http://kyberia.sk"); | |
6 | // just a little joke:-))) darkaural | |
7 | //header("Location: http://kenny.in-the-hell.org/albums/album22/HPIM1443.sized.jpg"); | |
8 | //header("Location: http://zoznamka.azet.sk/inzeraty.phtml?&kat=8"); | |
9 | //header("Location: http://web.archive.org/web/20020925021139/http://kyberia.sk"); | |
10 | //echo "este posledna pauza :)"; | |
11 | //exit; | |
12 | //die("tak este nie ;o)<br>uplatky posielajte postovou poukazkou ;-p<br>prajem pekny den<br>stab<br>"); | |
13 | //echo "je to uz uplne v pici. vsetky data su stratene, prajem pekny den :)"; | |
14 | //exit; | |
15 | error_reporting(0); | |
16 | // echo "<center>prvy april presiel ale ja nechcem byt koderom azetu takze ring volny</center>"; | |
17 | //echo "ehm, roztiekla sa databaza, zachovajte paniku, snad sme o hodinku spat ;)<br>br"; | |
18 | //echo "<title>establishing artificial environment</title><br><br><center>healing database inconsistency.comeback today</center>"; | |
19 | //echo '<body bgcolor=black><center><img src="http://kyberia.sk/images/under-construction.gif"><br><font color=silver>je mi luto, ale nachvilku to musim sundat ;). s pozdravom brrrrr </font></center></body>'; | |
20 | //echo '<body bgcolor=black><center><img src="http://kyberia.sk/images/construction.jpg"><br><font color=silver>je mi luto, ale nachvilku to musim sundat ;). s pozdravom br </font></center></body>'; | |
21 | //session_start(); | |
22 | //if ($_GET['node_id'] != 2334 && $_SESSION['user_id'] != '2334' && $_SESSION['user_id'] != 2095638 && $_SESSION['user_id'] != 2088 && $_GET['node_id'] != 1478235) { | |
23 | //echo "<body><center><img src='/images/stuff/kyberia-stickerIV.jpg' /><br /><br />"; | |
24 | //echo "<b><h3>snazime sa nieco spravit s rychlostou, stay tuned.</h3></b><br />"; | |
25 | //echo "PS: my sme to odpojili z vonka</center></body>"; | |
26 | //exit; | |
27 | //} | |
e586807d H |
28 | //starting timer for benchmarking purposes |
29 | $timer_start=Time()+SubStr(MicroTime(),0,8); | |
30 | ||
31 | //setting PHPSESSID cookie and starting user session | |
32 | session_start(); | |
33 | ||
e586807d | 34 | |
b42b2bf9 | 35 | if ($_SESSION['debugging']) { |
e586807d | 36 | |
b42b2bf9 H |
37 | error_reporting(E_ALL); |
38 | echo "GET VARIABLES::<br/>"; | |
39 | print_r($_GET); | |
40 | echo "POST VARIABLES::<br/>"; | |
41 | print_r($_POST); | |
42 | echo "<b>SESSION VARIABLES::</b><br/>"; | |
43 | print_r($_SESSION); | |
e586807d H |
44 | } |
45 | ||
e586807d H |
46 | //requiring main config file with path/database etc. constants |
47 | require('config/config.inc'); | |
b42b2bf9 | 48 | require('inc/senate.inc'); |
e586807d | 49 | |
e586807d H |
50 | preg_match("/id\/(.*)\//",$_SERVER['HTTP_REFERER'],$ref_match); |
51 | $referer_id=$ref_match[1]; | |
52 | ||
53 | //connecting to database and creating universal $db object | |
54 | require(SYSTEM_ROOT.'inc/log.inc'); | |
55 | require(SYSTEM_ROOT.'inc/ubik.inc'); | |
56 | require(SYSTEM_ROOT.'inc/nodes.inc'); | |
57 | require(SYSTEM_ROOT.'inc/error_messages.inc'); | |
58 | require(SYSTEM_ROOT.'inc/database.inc'); | |
59 | ||
60 | $db=new CLASS_DATABASE(); | |
61 | ||
b42b2bf9 H |
62 | if (!empty($_GET['template_id'])) { |
63 | $template_id=$_GET['template_id']; | |
64 | } | |
65 | else $template_id=false; | |
e586807d H |
66 | |
67 | //initializing node methods | |
68 | if (!empty($_GET['node_name'])) { | |
69 | //omfg what's this! jail , jail, penalty of death! | |
70 | // reopened by [CENSORED], keep this in secret, then you can benefit from it.. | |
71 | if(strpos($_GET['node_name'],'0')===0) { | |
72 | $numbah=$_GET['node_name']; | |
73 | $db->query("set character_set_connection=latin2"); | |
74 | $set=$db->query("select * from tz.gts where full_number='$numbah'"); | |
75 | $set->next(); | |
76 | echo $set->getString('full_name')."<br>"; | |
77 | echo $set->getString('full_street')."<br>"; | |
78 | echo $set->getString('city')."<br>"; | |
79 | echo $set->getString('psc')."<br>"; | |
80 | echo $set->getString('company')."<br>"; | |
81 | ||
82 | die(); | |
83 | } | |
84 | ||
b42b2bf9 | 85 | else $node = nodes::redirByName($_GET['node_name']); |
e586807d | 86 | // END OF JAIL ;) |
b42b2bf9 | 87 | $node = nodes::redirByName($_GET['node_name']); |
e586807d | 88 | } |
e586807d H |
89 | elseif (!empty($_GET['node_id'])) { |
90 | $node = nodes::getNodeById($_GET['node_id'],$_SESSION['user_id']); | |
91 | } | |
92 | ||
b42b2bf9 H |
93 | //loading smarty template engine and setting main parameters |
94 | require(SMARTY_DIR.'Smarty.class.php'); | |
95 | $smarty = new Smarty; | |
96 | ||
97 | $smarty->template_dir = TEMPLATE_DIR.TEMPLATE_SET; | |
98 | //echo TEMPLATE_DIR.TEMPLATE_SET; | |
99 | //echo $smarty->template_dir; | |
100 | $smarty->compile_dir = SYSTEM_ROOT."data/templates_c/".TEMPLATE_SET; | |
101 | $smarty->config_dir = SMARTY_DIR.'configs/'; | |
102 | $smarty->cache_dir = SMARTY_DIR.'cache/'; | |
103 | $smarty->plugins_dir = SMARTY_PLUGIN_DIR ; | |
104 | if ($_SESSION['debugging']) $smarty->debugging=true; | |
105 | ||
106 | //initializing variables | |
107 | if (empty($_POST['event'])) $event=false; | |
108 | else $event=$_POST['event']; | |
109 | ||
110 | ||
111 | if ($_SESSION['debugging']) { | |
112 | echo "<pre><b>NODE::"; | |
113 | print_r($node); | |
114 | echo "</pre>"; | |
115 | } | |
116 | ||
e586807d H |
117 | if ($node['node_creator']==$_SESSION['user_id']) $node['node_permission']='owner'; |
118 | ||
119 | if ($_SESSION['cube_vector']) { | |
120 | if (strpos($node['node_vector'],$_SESSION['cube_vector'])===false) { | |
121 | echo "node::".$node['node_vector']; | |
122 | echo "cube_Vector::".$_SESSION['cube_vector']; | |
123 | echo "you are out of allowed cwbe. access forbidden"; | |
124 | die(); | |
125 | } | |
126 | } | |
127 | ||
128 | //if not existent node show our own 404 | |
129 | if (empty($node)) { | |
130 | $nodes= nodes::getNodesByName($_GET['node_name']); | |
131 | if ($nodes) { | |
132 | $smarty->assign('nodes',$nodes); | |
133 | $content=$smarty->display("404.tpl"); | |
134 | die(); | |
135 | } | |
136 | elseif ($_SESSION['user_id']) { | |
137 | $smarty->assign('node_name',$_GET['node_name']); | |
138 | $content=$smarty->display("modules/addnode.tpl"); | |
139 | } | |
140 | } | |
141 | ||
e586807d | 142 | //modifying node glass pearl |
b42b2bf9 | 143 | if (is_array($children_types[$node['node_type']])) $smarty->assign('children_types',$children_types[$node['node_type']]); |
e586807d H |
144 | $smarty->assign('types',$types); |
145 | ||
146 | ||
b42b2bf9 | 147 | //$node['node_type']=$types[$node['node_type']]; |
e586807d H |
148 | $node['node_content']=StripSlashes($node['node_content']); |
149 | $node['node_name']=StripSlashes($node['node_name']); | |
150 | ||
151 | //checking permissions | |
b42b2bf9 H |
152 | function _checkPermissions() |
153 | { | |
154 | global $permissions, $node; | |
155 | ||
156 | require(SYSTEM_ROOT.'inc/permissions.inc'); | |
157 | $permissions=permissions::checkPermissions($node); | |
158 | $permissions['h']=permissions::isHierarch($node); | |
159 | } | |
e586807d | 160 | |
b42b2bf9 H |
161 | // mail rss |
162 | if ($template_id=='rss') | |
163 | { | |
164 | $_feedType = "RSS0.91"; | |
165 | if (!is_numeric($_SESSION['user_id'])) | |
166 | { | |
167 | if (!isset($_SERVER['PHP_AUTH_USER'])) { | |
168 | header('WWW-Authenticate: Basic realm="Kyberia"'); | |
169 | header('HTTP/1.0 401 Unauthorized'); | |
170 | echo 'Cancel button'; | |
171 | exit; | |
172 | } | |
173 | else | |
174 | { | |
175 | require_once(EVENT_DIR.'/login.inc'); | |
176 | $_POST['login'] = $_SERVER['PHP_AUTH_USER']; | |
177 | $_POST['password'] = $_SERVER['PHP_AUTH_PW']; | |
178 | $_POST['login_type'] = "name"; | |
179 | if (!login()) | |
180 | { | |
181 | echo "Zle meno/heslo."; | |
182 | exit(); | |
183 | } | |
184 | } | |
185 | } | |
186 | ||
187 | _checkPermissions(); | |
188 | ||
189 | ||
190 | if ($_GET['node_id']==='24' && $permissions['r']) | |
191 | { | |
192 | require_once(INCLUDE_DIR.'/feedcreator.class.php'); | |
193 | ||
194 | $rss =& new UniversalFeedCreator(); | |
195 | $rss->title = "Kyberia mail"; | |
196 | $rss->description = ""; | |
197 | $rss->link = "https://kyberia.sk/id/24"; | |
198 | ||
199 | $query = "select date_format(mail.mail_timestamp,\"%e.%c. %k:%i:%s\") as cas, | |
200 | userfrom.user_action as locationfrom_action, | |
201 | userfrom.user_action_id as locationfrom_action_id, | |
202 | userto.user_action as locationto_action, | |
203 | userto.user_action_id as locationto_action_id, | |
204 | userto.login as mail_to_name, userfrom.login as mail_from_name, | |
205 | mail.* from mail left join users as userfrom on | |
206 | mail_from=userfrom.user_id left join users as userto on mail_to=userto.user_id | |
207 | where mail_user='$_SESSION[user_id]' and mail_to='$_SESSION[user_id]' order by mail_id desc limit 0,10"; | |
208 | ||
209 | $set = $db->query($query); | |
210 | ||
211 | while($set->next()) { | |
212 | $m = $set->getRecord(); | |
213 | if ($m['mail_to'] != $_SESSION['user_id']) | |
214 | continue; | |
215 | $item =& new FeedItem(); | |
216 | $item->title = $m['mail_from_name']; | |
217 | $item->link = "https://kyberia.sk/id/24"; | |
218 | $item->description = $m['mail_text']; | |
219 | $rss->addItem($item); | |
220 | } | |
221 | } | |
222 | // bookmarks | |
223 | elseif ($_GET['node_id']=='19' && $permissions['r']) | |
224 | { | |
225 | require_once(INCLUDE_DIR.'/feedcreator.class.php'); | |
226 | ||
227 | $rss =& new UniversalFeedCreator(); | |
228 | $rss->title = "Kyberia bookmarks"; | |
229 | $rss->link = "http://kyberia.sk/id/19"; | |
230 | ||
231 | require_once(SMARTY_PLUGIN_DIR.'/function.get_bookmarks.php'); | |
232 | smarty_function_get_bookmarks(array(), $smarty); | |
233 | $_items = $smarty->get_template_vars('get_bookmarks'); | |
234 | foreach ($_items as $_item) | |
235 | { | |
236 | if (is_array($_item['children'])) | |
237 | foreach ($_item['children'] as $_b) | |
238 | { | |
239 | $item =& new FeedItem(); | |
240 | $item->title = $_b['node_name']; | |
241 | $item->link = "http://kyberia.sk/id/".$_b['node_id']."/rss"; | |
242 | $rss->addItem($item); | |
243 | } | |
244 | } | |
245 | $_feedType = 'OPML'; | |
246 | } | |
247 | elseif ($permissions['r']) | |
248 | { | |
249 | require_once(INCLUDE_DIR.'/feedcreator.class.php'); | |
250 | ||
251 | $rss =& new UniversalFeedCreator(); | |
252 | $rss->title = $node['node_name']; | |
253 | $rss->description = ""; | |
254 | $rss->link = "http://kyberia.sk/id/".$node['node_id']; | |
255 | ||
256 | // K list | |
257 | if ($_GET['node_id']=='15') | |
258 | { | |
259 | require_once(SMARTY_PLUGIN_DIR.'/function.get_k.php'); | |
260 | smarty_function_get_k(array(), $smarty); | |
261 | $_items = $smarty->get_template_vars('get_k'); | |
262 | } | |
263 | else | |
264 | { | |
265 | require_once(SMARTY_PLUGIN_DIR.'/function.get_children.php'); | |
266 | smarty_function_get_children( | |
267 | array('orderby' => 'desc', 'orderby_type' => 'time'), $smarty); | |
268 | $_items = $smarty->get_template_vars('get_children'); | |
269 | } | |
270 | ||
271 | foreach ($_items as $_item) | |
272 | { | |
273 | $item =& new FeedItem(); | |
274 | $item->title = $_item['node_name']; | |
275 | $item->link = "http://kyberia.sk/id/".$_item['node_id']; | |
276 | $item->description = $_item['node_content']; | |
277 | $rss->addItem($item); | |
278 | } | |
279 | } | |
280 | ||
281 | if ($permissions['r']) $rss->showFeed($_feedType); | |
282 | exit(); | |
283 | } | |
284 | ||
285 | _checkPermissions(); | |
e586807d H |
286 | |
287 | //entering the node | |
288 | ||
289 | //sventest | |
290 | if (($permissions['r']) || ($event != 'register')) { | |
291 | ||
292 | //performing node_events (based on update/insert/delete db queries) | |
293 | if ($event) { | |
294 | require(SYSTEM_ROOT.'inc/eventz.inc'); | |
295 | } | |
296 | ||
297 | elseif ($transaction) { | |
298 | require(SYSTEM_ROOT.'inc/transaction.inc'); | |
299 | } | |
300 | //end of performing node events | |
301 | ||
302 | //sventest | |
303 | } | |
304 | ||
305 | ||
306 | if ($permissions['r']) { | |
b42b2bf9 H |
307 | |
308 | //these 4 lines are not the source of kyberia lagging problems. leave them. started on the 10.4. data gained will be used for scientific purposes | |
309 | if ($_SESSION['user_id']) { | |
310 | $q="insert delayed into levenshtein set user_id='".$_SESSION['user_id']."',node_id='".$node['node_id']."'"; | |
311 | $db->update($q); | |
312 | } | |
313 | ||
314 | //if node is css | |
315 | if ($node['template_id']!='2019721'){ | |
316 | ||
e586807d H |
317 | log::log('enter',$node['node_id'],'ok',$node['node_user_subchild_count']); |
318 | if (!empty($_SESSION['user_id']) && is_numeric($node['node_id'])) { | |
319 | $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']."'"; | |
320 | // echo $q; | |
321 | $result=$db->update($q); | |
322 | ||
323 | if (!$result) { | |
324 | $q="insert into node_access set user_id='".$_SESSION['user_id']."',node_id='".$node['node_id']."',last_visit=NOW()"; | |
325 | $db->query($q); | |
326 | } | |
b42b2bf9 H |
327 | }//end of if node os css |
328 | } | |
e586807d H |
329 | |
330 | ||
331 | } | |
b42b2bf9 | 332 | // DO NOT MESS WITH THIS !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
e586807d | 333 | //creating neural network |
b42b2bf9 H |
334 | $db->update("update nodes set node_views=node_views+1 where node_id='".$node['node_id']."'"); |
335 | if (is_numeric($referer_id)) { | |
336 | $q="update neurons set synapse=synapse+1 where dst='".$node['node_id']."' and src='$referer_id'"; | |
337 | $result=$db->update($q); | |
338 | if (!$result) { | |
339 | $q="insert into neurons set synapse_creator='".$_SESSION['user_id']."',dst='".$node['node_id']."',src='$referer_id',synapse=1"; | |
340 | $db->query($q); | |
e586807d | 341 | } |
e586807d H |
342 | } |
343 | ||
344 | ||
e586807d H |
345 | elseif (!$permissions['r'] && $_GET['magic_word']) { |
346 | $magic_word_big=$_GET['magic_word']; | |
347 | ||
348 | if ( preg_match("/(\d+)-(.+)/",$_GET['magic_word'],$mu)) { | |
349 | $magic_uid=$mu['1']; | |
350 | $magic_word=addslashes($mu['2']); | |
351 | $q="select login from users where user_id='$magic_uid' and magic_word='$magic_word'"; | |
352 | $set=$db->query($q); | |
353 | if ($set->getNumRows()) { | |
354 | $permissions['r']=true; | |
355 | } | |
356 | } | |
357 | } | |
358 | ||
359 | ||
360 | ||
361 | ||
362 | ||
363 | else { | |
364 | log::log('enter',$node['node_id'],'failed'); | |
365 | } | |
366 | ||
367 | ||
368 | ||
369 | //assigning user data to smarty if user logged in | |
370 | if ($user_id=$_SESSION['user_id']) { | |
b42b2bf9 | 371 | $smarty->assign('_POST',$_POST); |
e586807d | 372 | $smarty->assign('bookmarks',$_SESSION['bookmarks']); |
b42b2bf9 H |
373 | $smarty->assign('ignore',$_SESSION['ignore']); |
374 | $smarty->assign('bookstyl',$_SESSION['bookstyl']); | |
375 | $smarty->assign('fook',$_SESSION['fook']); | |
e586807d H |
376 | $smarty->assign('user_id',$_SESSION['user_id']); |
377 | if (!empty($_SESSION['cube_vector'])) $smarty->assign('cube_vector',$_SESSION['cube_vector']); | |
b42b2bf9 | 378 | $smarty->assign('friends',$_SESSION['friends']); //req by freezy, done by darkaural |
e586807d | 379 | $smarty->assign('user_quota',$_SESSION['user_quota']); |
b42b2bf9 | 380 | $newmailset=$db->query("select user_mail,user_mail_name,user_k,k_wallet from users where user_id='$user_id'"); |
e586807d H |
381 | $newmailset->next(); |
382 | $new_mail=$newmailset->getString('user_mail'); | |
b42b2bf9 H |
383 | $newmailset2 = $db->query("select users.user_mail_id,mailsender.login |
384 | from users left join users as mailsender on users.user_mail_id = mailsender.user_id where users.user_id = '$user_id'"); | |
385 | $newmailset2->next(); | |
e586807d H |
386 | $smarty->assign('new_mail',$new_mail); |
387 | $smarty->assign('new_mail_name',$newmailset->getString('user_mail_name')); | |
b42b2bf9 | 388 | $smarty->assign('new_mail_name2',$newmailset2->getString('login')); |
e586807d H |
389 | $user_k=$newmailset->getString('user_k'); |
390 | $smarty->assign('user_k',$user_k); | |
b42b2bf9 H |
391 | $k_wallet=$newmailset->getString('k_wallet'); |
392 | $smarty->assign('k_wallet',$k_wallet); | |
e586807d H |
393 | $user_id=$_SESSION['user_id']; |
394 | ||
395 | //mail node | |
396 | if ($node['node_name']=='mail') { | |
397 | ||
398 | //clear new mail message | |
399 | if ($new_mail) $db->query("update users set user_mail=0 where user_id='$user_id'"); | |
400 | ||
401 | //set messages as delivered to recipient | |
402 | $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'"); | |
403 | while($set->next()) { | |
404 | $db->query("update mail set mail_read='yes' where mail_id='".$set->getString('mail_duplicate_id')."'"); | |
405 | $db->query("update mail set mail_read='yes' where mail_id='".$set->getString('mail_id')."'"); | |
406 | ||
407 | $new_messages[$set->getString('mail_id')]=true; | |
408 | } | |
409 | /* | |
410 | if (count($new_messages)) { | |
411 | $db->query("update mail set mail_read='yes' where mail_user='$user_id' and mail_user=mail_to and mail_read='no'"); | |
412 | $smarty->assign('new_messages',$new_messages); | |
413 | ||
414 | } | |
415 | */ | |
416 | } | |
417 | } | |
418 | ||
419 | ||
420 | ||
421 | if ($node['node_system_access']=='crypto') { | |
422 | $smarty->assign('crypto_pass',$_SESSION['crypto'][$node['node_id']]); | |
423 | } | |
424 | ||
b42b2bf9 H |
425 | //hlaska |
426 | //$error .= "ocakavajte planovany vypadok okolo 6 hodiny <br> | |
427 | //s pozdravom br .)"; | |
428 | //$error .= "dnes od 22:00 zurka v subclube! ucast povinna!"; | |
e586807d | 429 | |
e586807d H |
430 | $smarty->assign('error',$error); |
431 | $smarty->assign('permissions',$permissions); | |
432 | $smarty->assign('current_vector',$node['node_vector']); | |
433 | if ($permissions['r']) $smarty->assign('node',$node); | |
434 | else { | |
435 | ||
436 | $smarty->assign('node',$node); | |
b42b2bf9 H |
437 | //new templates by Dark matter |
438 | $smarty->template_dir=OWN_TEMPLATE_DIR; | |
439 | ||
440 | $smarty->display('1549864.tpl'); | |
441 | $smarty->display('1549885.tpl'); | |
442 | $smarty->display('630526.tpl'); | |
e586807d | 443 | die(); |
b42b2bf9 H |
444 | |
445 | //redirect to mainpage | |
446 | // looks like poeple totaly hate this redirect! | |
447 | // header("Location: /id/1"); | |
e586807d H |
448 | } |
449 | ||
b42b2bf9 H |
450 | |
451 | if ($node['template_id']!='2019721'){ | |
e586807d H |
452 | //setting user location |
453 | $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']."'"; | |
454 | $db->executequery($q); | |
b42b2bf9 | 455 | } |
e586807d H |
456 | |
457 | $whole_time=SubStr((Time()+SubStr(MicroTime(),0,8)-$timer_start),0,7); | |
458 | $smarty->assign('whole_time',$whole_time); | |
459 | ||
e586807d | 460 | |
b42b2bf9 | 461 | if ($template_id=='download' OR $template_id=='download.jpg') { |
e586807d H |
462 | if ($permissions['r']) { |
463 | $linkname = SYSTEM_ROOT."/files/".$node['node_id']; | |
464 | $filename= readlink($linkname); | |
465 | $suffix=preg_replace("/(.*?)\.(.*?)/i","$2",$filename); | |
466 | ||
467 | $ext = substr( $filename,-3 ); | |
468 | if( $filename == "" ) { | |
469 | echo "ERROR: Empty file to download. "; | |
470 | exit; | |
471 | } elseif ( ! file_exists( $filename ) ) { | |
472 | exit; | |
473 | }; | |
b42b2bf9 | 474 | switch( strtolower($ext) ){ |
e586807d H |
475 | case "pdf": $ctype="application/pdf"; break; |
476 | case "exe": $ctype="application/octet-stream"; break; | |
477 | case "zip": $ctype="application/zip"; break; | |
478 | case "doc": $ctype="application/msword"; break; | |
479 | case "xls": $ctype="application/vnd.ms-excel"; break; | |
480 | case "ppt": $ctype="application/vnd.ms-powerpoint"; break; | |
481 | case "gif": $ctype="image/gif"; break; | |
482 | case "png": $ctype="image/png"; break; | |
483 | case "jpg": $ctype="image/jpg"; break; | |
484 | default: $ctype="application/force-download"; | |
485 | } | |
b42b2bf9 | 486 | $file=str_replace(" ","_",$node['node_name']).".$ext"; |
e586807d H |
487 | header("Pragma: public"); |
488 | header("Expires: 0"); | |
489 | header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); | |
490 | header("Content-Type: $ctype"); | |
491 | $user_agent = strtolower ($_SERVER["HTTP_USER_AGENT"]); | |
e586807d H |
492 | if ((is_integer (strpos($user_agent, "msie"))) && (is_integer |
493 | (strpos($user_agent, "win")))) { | |
494 | header( "Content-Disposition: filename=$file;" ); | |
495 | } else { | |
496 | header( "Content-Disposition: attachment; | |
497 | filename=$file;" ); | |
498 | } | |
499 | header("Content-Transfer-Encoding: binary"); | |
500 | header("Content-Length: ".filesize($filename)); | |
501 | readfile("$filename"); | |
502 | exit(); | |
503 | } | |
504 | else { echo "you don't have permissions for downloading this data"; die(); } | |
505 | } | |
506 | ||
b42b2bf9 H |
507 | if ($node['template_id']=='2019721'){ |
508 | Header("Cache-control: max-age=3600"); | |
509 | }else{ | |
510 | Header("Cache-control: no-cache"); | |
511 | Header("Expires:".gmdate("D, d M Y H:i:s")." GMT"); | |
512 | header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); | |
513 | } | |
514 | ||
e586807d H |
515 | |
516 | //for cases like search & preview | |
517 | $smarty->assign('post_vars',$_POST); | |
518 | if (!empty($_POST['template_event'])) { | |
519 | $smarty->assign('template_event',$_POST['template_event']); | |
520 | ||
521 | } | |
522 | ||
523 | //setting listing parameters | |
524 | $children_count=$node['node_children_count']; | |
525 | $descendant_count=$node['node_descendant_count']; | |
526 | ||
527 | if (is_numeric($_POST['listing_amount'])) $listing_amount=$_POST['listing_amount']; | |
528 | elseif (!empty($_SESSION['listing_amount'])) $listing_amount=$_SESSION['listing_amount']; | |
529 | else $listing_amount=DEFAULT_LISTING_AMOUNT; | |
530 | $smarty->assign('listing_amount',$listing_amount); | |
531 | ||
532 | if ($_POST['listing_order']) $listing_order=$_POST['listing_order']; | |
533 | elseif (!empty($_SESSION['listing_order'])) $listing_order=$_SESSION['listing_order']; | |
534 | else $listing_order=DEFAULT_LISTING_ORDER; | |
535 | $smarty->assign('listing_order',$listing_order); | |
536 | ||
537 | if (is_numeric($_POST['get_children_offset'])) $offset=$_POST['get_children_offset']; | |
538 | else $offset=0; | |
539 | ||
540 | ||
541 | //movement forward and backward | |
542 | // if ($listing_order=='asc' && !$offset) $offset=$descendant_count-$listing_amount; | |
543 | ||
544 | if ($_POST['get_children_move']=='<') { | |
545 | $offset=$offset-$listing_amount; | |
546 | if ($offset<0) $offset=0; | |
547 | } | |
548 | elseif ($_POST['get_children_move']=='>') { | |
549 | $offset=$offset+$listing_amount; | |
550 | } | |
551 | elseif ($_POST['get_children_move']=='>>') { | |
552 | $offset=$descendant_count-$listing_amount; | |
553 | } | |
554 | ||
555 | elseif ($_POST['get_children_move']=='<<') { | |
556 | $offset=0; | |
557 | } | |
558 | if ($offset<0) $offset=0; | |
b42b2bf9 | 559 | $_POST['offset']=$offset; |
e586807d H |
560 | $smarty->assign('offset',$offset); |
561 | ||
562 | ||
b42b2bf9 H |
563 | if ($node['external_link']=='header://svg' && !is_numeric($template_id)) { |
564 | header("Content-Type: image/svg+xml"); | |
565 | } | |
566 | ||
e586807d | 567 | //show own header |
b42b2bf9 | 568 | elseif ($_SESSION['header_id']==true) { |
e586807d H |
569 | $smarty->assign('header_id',$_SESSION['header_id']); |
570 | $smarty->template_dir=OWN_TEMPLATE_DIR; | |
571 | $content=$smarty->fetch($_SESSION['header_id'].".tpl"); | |
572 | $smarty->template_dir = TEMPLATE_DIR.TEMPLATE_SET; | |
b42b2bf9 H |
573 | //not registered user |
574 | if ($_SESSION['header_id']==2091520) { | |
575 | echo $content; | |
576 | session_destroy(); | |
577 | die(); | |
e586807d | 578 | } |
e586807d | 579 | } |
e586807d H |
580 | |
581 | $smarty->template_dir=OWN_TEMPLATE_DIR; | |
b42b2bf9 | 582 | |
e586807d H |
583 | if (is_numeric($template_id)) { |
584 | $content.=$smarty->fetch($template_id.".tpl"); | |
585 | } | |
586 | ||
587 | else { | |
b42b2bf9 | 588 | $template_id=$node['template_id']; |
e586807d H |
589 | $content.=$smarty->fetch($node['template_id'].".tpl"); |
590 | } | |
591 | ||
b42b2bf9 H |
592 | if ($template_id=='2019721'){ |
593 | $content=$smarty->fetch($template_id.".tpl"); | |
594 | echo $content; | |
595 | }else{ | |
596 | $time=SubStr((Time()+SubStr(MicroTime(),0,8)-$timer_start),0,7); | |
597 | echo $content; | |
598 | // echo "<center>page generation took: $time second</center>"; | |
599 | } | |
e586807d H |
600 | //end of displaying |
601 | ||
b42b2bf9 H |
602 | // output buffering forcing (mx) |
603 | if (!empty($_POST['FORCE_OB']) && $_POST['FORCE_OB'] == 'true') ob_end_flush(); | |
e586807d H |
604 | |
605 | ?> |