3 global $node,$db,$error,$referer_id,$smarty,$permissions,$template_id;
4 if (!$referer_id) $referer_id=1;
6 $node_id=$node['node_id'];
7 $user_id=$_SESSION['user_id'];
9 if ($permissions['r']) {
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
15 // if (isset($_SESSION['user_id']) {
16 // log_levenshtein($_SESSION['user_id'],$node['node_id']);
19 if ((isset($_SESSION['user_id'])) && ($_SESSION['user_id'])) {
20 $q="insert delayed into levenshtein set user_id='".$_SESSION['user_id']."',node_id='".$node['node_id']."'";
26 if ($node['template_id']!='2019721'){
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']."'";
32 $result=$db->update($q);
35 $q="insert into node_access set user_id='".$_SESSION['user_id']."',node_id='".$node['node_id']."',last_visit=NOW()";
38 }//end of if node os css
44 // if (isset($_SESSION['user_id']) {
45 // if (isset($referer_id)) {
46 // update_nodes($_SESSION['user_id'],$node['node_id'],$referer_id);
48 // update_nodes($_SESSION['user_id'],$node['node_id'],0);
53 //assigning user data to smarty if user logged in
54 if (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']);
68 $newmail_q = sprintf('select u.user_mail_id
72 , ms.user_id as mail_sender_id
73 , ms.login as mail_sender
75 left join users ms on ms.user_id = u.user_mail_id
76 where u.user_id = %d',
78 $newmailset = $db->query($newmail_q);
82 $new_mail=$newmailset->getString('user_mail');
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'");
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'];
97 if ($node['node_name']=='mail') {
99 //clear new mail message
101 if ($new_mail) $db->query("update users set user_mail=0 where user_id='$user_id'");
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')."'");
109 $new_messages[$set->getString('mail_id')]=true;
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);
123 if ($node['node_system_access']=='crypto') {
124 $smarty->assign('crypto_pass',$_SESSION['crypto'][$node['node_id']]);
127 $smarty->assign('error',$error);
128 $smarty->assign('permissions',$permissions);
129 $smarty->assign('current_vector',$node['node_vector']);
130 if ($permissions['r']) {
131 $smarty->assign('node',$node);
132 $smarty->assign('node_json',json_encode($node));
135 $smarty->assign('node',$node);
136 //new templates by Dark matter
137 $smarty->template_dir=OWN_TEMPLATE_DIR;
139 $smarty->display('1549864.tpl');
140 $smarty->display('1549885.tpl');
141 $smarty->display('630526.tpl');
144 //redirect to mainpage
145 // looks like poeple totaly hate this redirect!
146 // header("Location: /id/1");
151 if (($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);
157 $whole_time=SubStr((Time()+SubStr(MicroTime(),0,8)-$timer_start),0,7);
158 $smarty->assign('whole_time',$whole_time);
161 if ($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);
167 $ext = substr( $filename,-3 );
168 if( $filename == "" ) {
169 echo "ERROR: Empty file to download. ";
171 } elseif ( ! file_exists( $filename ) ) {
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";
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;" );
196 header( "Content-Disposition: attachment;
199 header("Content-Transfer-Encoding: binary");
200 header("Content-Length: ".filesize($filename));
201 readfile("$filename");
204 else { echo "you don't have permissions for downloading this data"; die(); }
207 if ($node['template_id']=='2019721'){
208 Header("Cache-control: max-age=3600");
210 Header("Cache-control: no-cache");
211 Header("Expires:".gmdate("D, d M Y H:i:s")." GMT");
212 header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
216 //for cases like search & preview
217 $smarty->assign('post_vars',$_POST);
218 if (!empty($_POST['template_event'])) {
219 $smarty->assign('template_event',$_POST['template_event']);
223 //setting listing parameters
224 $children_count=$node['node_children_count'];
225 $descendant_count=$node['node_descendant_count'];
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);
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);
239 if (isset ($_POST['get_children_offset']) && is_numeric($_POST['get_children_offset'])) {
240 $offset=$_POST['get_children_offset'];
241 } else { $offset=0; }
244 //movement forward and backward
245 // if ($listing_order=='asc' && !$offset) $offset=$descendant_count-$listing_amount;
247 if ($_POST['get_children_move']=='<') {
248 $offset=$offset-$listing_amount;
249 if ($offset<0) $offset=0;
251 elseif ($_POST['get_children_move']=='>') {
252 $offset=$offset+$listing_amount;
254 elseif ($_POST['get_children_move']=='>>') {
255 $offset=$descendant_count-$listing_amount;
258 elseif ($_POST['get_children_move']=='<<') {
261 if ($offset<0) $offset=0;
262 $_POST['offset']=$offset;
263 $smarty->assign('offset',$offset);
266 if ($node['external_link']=='header://svg' && !is_numeric($template_id)) {
267 header("Content-Type: image/svg+xml");
271 elseif (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) {
284 $smarty->template_dir=OWN_TEMPLATE_DIR;
286 if (is_numeric($template_id)) {
287 $content.=$smarty->fetch($template_id.".tpl");
291 $template_id=$node['template_id'];
292 $content.=$smarty->fetch($node['template_id'].".tpl");
295 if ($template_id=='2019721'){
296 $content=$smarty->fetch($template_id.".tpl");
299 $time=SubStr((Time()+SubStr(MicroTime(),0,8)-$timer_start),0,7);
301 // echo "<center>page generation took: $time second</center>";