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