Commit | Line | Data |
---|---|---|
65c78def H |
1 | <?php |
2 | function display() { | |
3 | /*global $node,$db,$error,$referer_id; | |
4 | if (!$referer_id) $referer_id=1; | |
5 | ||
6 | $node_id=$node['node_id']; | |
7 | $user_id=$_SESSION['user_id'];*/ | |
8 | ||
9 | return false; | |
10 | } | |
11 | ||
12 | //XXX TODO: CELY TOHLE JE HACK A JE POTREBA TO NARVAT DO FUNKCE display() nahore...//// | |
13 | ||
14 | if ($permissions['r']) { | |
15 | ||
16 | // these 4 lines are not the source of kyberia lagging problems. | |
17 | // leave them. started on the 10.4. | |
18 | // data gained will be used for scientific purposes | |
19 | ||
20 | // if (isset($_SESSION['user_id']) { | |
21 | // log_levenshtein($_SESSION['user_id'],$node['node_id']); | |
22 | // } | |
23 | ||
24 | if ((isset($_SESSION['user_id'])) && ($_SESSION['user_id'])) { | |
25 | $q="insert delayed into levenshtein set user_id='".$_SESSION['user_id']."',node_id='".$node['node_id']."'"; | |
26 | $db->update($q); | |
27 | } | |
28 | ||
29 | //if node is css | |
30 | //XXX into function | |
31 | if ($node['template_id']!='2019721'){ | |
32 | ||
33 | logger::log('enter',$node['node_id'],'ok',$node['node_user_subchild_count']); | |
34 | if (!empty($_SESSION['user_id']) && is_numeric($node['node_id'])) { | |
35 | $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']."'"; | |
36 | // echo $q; | |
37 | $result=$db->update($q); | |
38 | ||
39 | if (!$result) { | |
40 | $q="insert into node_access set user_id='".$_SESSION['user_id']."',node_id='".$node['node_id']."',last_visit=NOW()"; | |
41 | $db->query($q); | |
42 | } | |
43 | }//end of if node os css | |
44 | } | |
45 | ||
46 | } | |
47 | ||
48 | //XXX into function | |
49 | // if (isset($_SESSION['user_id']) { | |
50 | // if (isset($referer_id)) { | |
51 | // update_nodes($_SESSION['user_id'],$node['node_id'],$referer_id); | |
52 | // } else { | |
53 | // update_nodes($_SESSION['user_id'],$node['node_id'],0); | |
54 | // } | |
55 | // } | |
56 | ||
57 | // DO NOT MESS WITH THIS !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
58 | //creating neural network | |
59 | $db->update("update nodes set node_views=node_views+1 where node_id='".$node['node_id']."'"); | |
60 | if (isset($referer_id) && is_numeric($referer_id)) { | |
61 | $q="update neurons set synapse=synapse+1 where dst='".$node['node_id']."' and src='$referer_id'"; | |
62 | $result=$db->update($q); | |
63 | if (!$result) { | |
64 | $q="insert into neurons set synapse_creator='".$_SESSION['user_id']."',dst='".$node['node_id']."',src='$referer_id',synapse=1"; | |
65 | $db->query($q); | |
66 | } | |
67 | } | |
68 | ||
69 | ||
70 | elseif (!$permissions['r'] && $_GET['magic_word']) { | |
71 | $magic_word_big=$_GET['magic_word']; | |
72 | ||
73 | if ( preg_match("/(\d+)-(.+)/",$_GET['magic_word'],$mu)) { | |
74 | $magic_uid=$mu['1']; | |
75 | $magic_word=addslashes($mu['2']); | |
76 | // XXX WTF column magic_word does not exists | |
77 | $q="select login from users where user_id='$magic_uid' and magic_word='$magic_word'"; | |
78 | $set=$db->query($q); | |
79 | if ($set->getNumRows()) { | |
80 | $permissions['r']=true; | |
81 | } | |
82 | } | |
83 | } | |
84 | ||
85 | ||
86 | ||
87 | ||
88 | ||
89 | else { | |
90 | logger::log('enter',$node['node_id'],'failed'); | |
91 | } | |
92 | ||
93 | ||
94 | ||
95 | //assigning user data to smarty if user logged in | |
96 | if (isset($_SESSION['user_id'])&&($user_id=$_SESSION['user_id'])) { | |
97 | $smarty->assign('_POST',$_POST); | |
98 | $smarty->assign('bookmarks',$_SESSION['bookmarks']); | |
99 | $smarty->assign('ignore',$_SESSION['ignore']); | |
100 | $smarty->assign('bookstyl',$_SESSION['bookstyl']); | |
101 | $smarty->assign('fook',$_SESSION['fook']); | |
102 | $smarty->assign('user_id',$_SESSION['user_id']); | |
103 | $smarty->assign('user_name',$_SESSION['user_name']); | |
104 | if (!empty($_SESSION['cube_vector'])) | |
105 | $smarty->assign('cube_vector',$_SESSION['cube_vector']); | |
106 | $smarty->assign('friends',$_SESSION['friends']); //req by freezy, done by darkaural | |
107 | $smarty->assign('user_quota',$_SESSION['user_quota']); | |
108 | ||
109 | // XXX into function | |
110 | $newmail_q = sprintf('select u.user_mail_id | |
111 | , u.user_k | |
112 | , u.k_wallet | |
113 | , u.user_mail | |
114 | , ms.user_id as mail_sender_id | |
115 | , ms.login as mail_sender | |
116 | from users u | |
117 | left join users ms on ms.user_id = u.user_mail_id | |
118 | where u.user_id = %d', | |
119 | $user_id); | |
120 | $newmailset = $db->query($newmail_q); | |
121 | ||
122 | ||
123 | $newmailset->next(); | |
124 | $new_mail=$newmailset->getString('user_mail'); | |
125 | // XXX into function | |
126 | $newmailset2 = $db->query("select users.user_mail_id,mailsender.login | |
127 | from users left join users as mailsender on users.user_mail_id = mailsender.user_id where users.user_id = '$user_id'"); | |
128 | $newmailset2->next(); | |
129 | $smarty->assign('new_mail',$new_mail); | |
130 | $smarty->assign('new_mail_name',$newmailset->getString('mail_sender')); | |
131 | $smarty->assign('new_mail_name2',$newmailset2->getString('login')); | |
132 | $user_k=$newmailset->getString('user_k'); | |
133 | $smarty->assign('user_k',$user_k); | |
134 | $k_wallet=$newmailset->getString('k_wallet'); | |
135 | $smarty->assign('k_wallet',$k_wallet); | |
136 | $user_id=$_SESSION['user_id']; | |
137 | ||
138 | //mail node | |
139 | if ($node['node_name']=='mail') { | |
140 | ||
141 | //clear new mail message | |
142 | ||
143 | if ($new_mail) $db->query("update users set user_mail=0 where user_id='$user_id'"); | |
144 | ||
145 | //set messages as delivered to recipient | |
146 | $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'"); | |
147 | while($set->next()) { | |
148 | $db->query("update mail set mail_read='yes' where mail_id='".$set->getString('mail_duplicate_id')."'"); | |
149 | $db->query("update mail set mail_read='yes' where mail_id='".$set->getString('mail_id')."'"); | |
150 | ||
151 | $new_messages[$set->getString('mail_id')]=true; | |
152 | } | |
153 | /* | |
154 | if (count($new_messages)) { | |
155 | $db->query("update mail set mail_read='yes' where mail_user='$user_id' and mail_user=mail_to and mail_read='no'"); | |
156 | $smarty->assign('new_messages',$new_messages); | |
157 | ||
158 | } | |
159 | */ | |
160 | } | |
161 | } | |
162 | ||
163 | ||
164 | ||
165 | if ($node['node_system_access']=='crypto') { | |
166 | $smarty->assign('crypto_pass',$_SESSION['crypto'][$node['node_id']]); | |
167 | } | |
168 | ||
169 | $smarty->assign('error',$error); | |
170 | $smarty->assign('permissions',$permissions); | |
171 | $smarty->assign('current_vector',$node['node_vector']); | |
172 | if ($permissions['r']) { | |
173 | $smarty->assign('node',$node); | |
174 | $smarty->assign('node_json',json_encode($node)); | |
175 | } | |
176 | else { | |
177 | ||
178 | $smarty->assign('node',$node); | |
179 | //new templates by Dark matter | |
180 | $smarty->template_dir=OWN_TEMPLATE_DIR; | |
181 | ||
182 | $smarty->display('1549864.tpl'); | |
183 | $smarty->display('1549885.tpl'); | |
184 | $smarty->display('630526.tpl'); | |
185 | die(); | |
186 | ||
187 | //redirect to mainpage | |
188 | // looks like poeple totaly hate this redirect! | |
189 | // header("Location: /id/1"); | |
190 | } | |
191 | ||
192 | ||
193 | // XXX into function | |
194 | if (($node['template_id']!='2019721') && (isset($_SESSION['user_id']))){ | |
195 | //setting user location | |
196 | $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']."'"; | |
197 | $db->executequery($q); | |
198 | } | |
199 | ||
200 | $whole_time=SubStr((Time()+SubStr(MicroTime(),0,8)-$timer_start),0,7); | |
201 | $smarty->assign('whole_time',$whole_time); | |
202 | ||
203 | ||
204 | if ($template_id=='download' OR $template_id=='download.jpg') { | |
205 | if ($permissions['r']) { | |
206 | $linkname = SYSTEM_ROOT."/files/".$node['node_id']; | |
207 | $filename= readlink($linkname); | |
208 | $suffix=preg_replace("/(.*?)\.(.*?)/i","$2",$filename); | |
209 | ||
210 | $ext = substr( $filename,-3 ); | |
211 | if( $filename == "" ) { | |
212 | echo "ERROR: Empty file to download. "; | |
213 | exit; | |
214 | } elseif ( ! file_exists( $filename ) ) { | |
215 | exit; | |
216 | }; | |
217 | switch( strtolower($ext) ){ | |
218 | case "pdf": $ctype="application/pdf"; break; | |
219 | case "exe": $ctype="application/octet-stream"; break; | |
220 | case "zip": $ctype="application/zip"; break; | |
221 | case "doc": $ctype="application/msword"; break; | |
222 | case "xls": $ctype="application/vnd.ms-excel"; break; | |
223 | case "ppt": $ctype="application/vnd.ms-powerpoint"; break; | |
224 | case "gif": $ctype="image/gif"; break; | |
225 | case "png": $ctype="image/png"; break; | |
226 | case "jpg": $ctype="image/jpg"; break; | |
227 | default: $ctype="application/force-download"; | |
228 | } | |
229 | $file=str_replace(" ","_",$node['node_name']).".$ext"; | |
230 | header("Pragma: public"); | |
231 | header("Expires: 0"); | |
232 | header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); | |
233 | header("Content-Type: $ctype"); | |
234 | $user_agent = strtolower ($_SERVER["HTTP_USER_AGENT"]); | |
235 | if ((is_integer (strpos($user_agent, "msie"))) && (is_integer | |
236 | (strpos($user_agent, "win")))) { | |
237 | header( "Content-Disposition: filename=$file;" ); | |
238 | } else { | |
239 | header( "Content-Disposition: attachment; | |
240 | filename=$file;" ); | |
241 | } | |
242 | header("Content-Transfer-Encoding: binary"); | |
243 | header("Content-Length: ".filesize($filename)); | |
244 | readfile("$filename"); | |
245 | exit(); | |
246 | } | |
247 | else { echo "you don't have permissions for downloading this data"; die(); } | |
248 | } | |
249 | ||
250 | if ($node['template_id']=='2019721'){ | |
251 | Header("Cache-control: max-age=3600"); | |
252 | }else{ | |
253 | Header("Cache-control: no-cache"); | |
254 | Header("Expires:".gmdate("D, d M Y H:i:s")." GMT"); | |
255 | header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); | |
256 | } | |
257 | ||
258 | ||
259 | //for cases like search & preview | |
260 | $smarty->assign('post_vars',$_POST); | |
261 | if (!empty($_POST['template_event'])) { | |
262 | $smarty->assign('template_event',$_POST['template_event']); | |
263 | ||
264 | } | |
265 | ||
266 | //setting listing parameters | |
267 | $children_count=$node['node_children_count']; | |
268 | $descendant_count=$node['node_descendant_count']; | |
269 | ||
270 | if (isset($_POST['listing_amount']) && is_numeric($_POST['listing_amount'])) { | |
271 | $listing_amount=mysql_real_escape_string($_POST['listing_amount']); | |
272 | }elseif (!empty($_SESSION['listing_amount'])) $listing_amount=$_SESSION['listing_amount']; | |
273 | else $listing_amount=DEFAULT_LISTING_AMOUNT; | |
274 | $smarty->assign('listing_amount',$listing_amount); | |
275 | ||
276 | if (isset($_POST['listing_order']) && $_POST['listing_order']) { | |
277 | $listing_order=mysql_real_escape_string($_POST['listing_order']); | |
278 | } elseif (!empty($_SESSION['listing_order'])) $listing_order=$_SESSION['listing_order']; | |
279 | else $listing_order=DEFAULT_LISTING_ORDER; | |
280 | $smarty->assign('listing_order',$listing_order); | |
281 | ||
282 | if (isset ($_POST['get_children_offset']) && is_numeric($_POST['get_children_offset'])) { | |
283 | $offset=$_POST['get_children_offset']; | |
284 | } else { $offset=0; } | |
285 | ||
286 | ||
287 | //movement forward and backward | |
288 | // if ($listing_order=='asc' && !$offset) $offset=$descendant_count-$listing_amount; | |
289 | ||
290 | if ($_POST['get_children_move']=='<') { | |
291 | $offset=$offset-$listing_amount; | |
292 | if ($offset<0) $offset=0; | |
293 | } | |
294 | elseif ($_POST['get_children_move']=='>') { | |
295 | $offset=$offset+$listing_amount; | |
296 | } | |
297 | elseif ($_POST['get_children_move']=='>>') { | |
298 | $offset=$descendant_count-$listing_amount; | |
299 | } | |
300 | ||
301 | elseif ($_POST['get_children_move']=='<<') { | |
302 | $offset=0; | |
303 | } | |
304 | if ($offset<0) $offset=0; | |
305 | $_POST['offset']=$offset; | |
306 | $smarty->assign('offset',$offset); | |
307 | ||
308 | ||
309 | if ($node['external_link']=='header://svg' && !is_numeric($template_id)) { | |
310 | header("Content-Type: image/svg+xml"); | |
311 | } | |
312 | ||
313 | //show own header | |
314 | elseif (isset($_SESSION['header_id']) && ($_SESSION['header_id']==true)) { | |
315 | $smarty->assign('header_id',$_SESSION['header_id']); | |
316 | $smarty->template_dir=OWN_TEMPLATE_DIR; | |
317 | $content=$smarty->fetch($_SESSION['header_id'].".tpl"); | |
318 | $smarty->template_dir = TEMPLATE_DIR.TEMPLATE_SET; | |
319 | //not registered user | |
320 | if ($_SESSION['header_id']==2091520) { | |
321 | echo $content; | |
322 | session_destroy(); | |
323 | die(); | |
324 | } | |
325 | } | |
326 | ||
327 | $smarty->template_dir=OWN_TEMPLATE_DIR; | |
328 | ||
329 | if (is_numeric($template_id)) { | |
330 | $content.=$smarty->fetch($template_id.".tpl"); | |
331 | } | |
332 | ||
333 | else { | |
334 | $template_id=$node['template_id']; | |
335 | $content.=$smarty->fetch($node['template_id'].".tpl"); | |
336 | } | |
337 | ||
338 | if ($template_id=='2019721'){ | |
339 | $content=$smarty->fetch($template_id.".tpl"); | |
340 | echo $content; | |
341 | }else{ | |
342 | $time=SubStr((Time()+SubStr(MicroTime(),0,8)-$timer_start),0,7); | |
343 | echo $content; | |
344 | // echo "<center>page generation took: $time second</center>"; | |
345 | } | |
346 | //end of displaying | |
347 |