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