3 global $node,$db,$error,$referer_id,$smarty,$permissions,$template_id;
5 if (!$referer_id) $referer_id=1;
8 $node_id=$node['node_id'];
9 $user_id=(empty($_SESSION['user_id'])) ? "" : $_SESSION['user_id'];
11 if ($permissions['r']) {
13 // data gained will be used for scientific purposes
15 if ((isset($_SESSION['user_id'])) && ($_SESSION['user_id'])) {
16 nodes::levenshteinLog($_SESSION['user_id'],$node['node_id']);
22 if ($node['template_id']!='2019721'){
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']."'";
27 $result=$db->update($q);
30 $q="insert into node_access set user_id='".$_SESSION['user_id']."',node_id='".$node['node_id']."',last_visit=NOW()";
33 }//end of if node os css
38 //assigning user data to smarty if user logged in
39 if (isset($_SESSION['user_id'])&&($user_id=$_SESSION['user_id'])) {
40 $smarty->assign('_POST',$_POST);
41 $smarty->assign('bookmarks',$_SESSION['bookmarks']);
42 if (isset($_SESSION['ignore'])) { $smarty->assign('ignore',$_SESSION['ignore']); };
43 $smarty->assign('bookstyl',$_SESSION['bookstyl']);
44 if (isset($_SESSION['fook'])) {$smarty->assign('fook',$_SESSION['fook']); };
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
50 if (isset($_SESSION['user_quota'])) {$smarty->assign('user_quota',$_SESSION['user_quota']);};
53 $newmail_q = sprintf('select u.user_mail_id
57 , ms.user_id as mail_sender_id
58 , ms.login as mail_sender
60 left join users ms on ms.user_id = u.user_mail_id
61 where u.user_id = %d',
63 $newmailset = $db->query($newmail_q);
67 $new_mail=$newmailset->getString('user_mail');
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'");
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'];
81 //mail node //OMG remove constant
82 if ($node['node_id']==MAIL_NODE) {
84 //clear new mail message
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'");
96 if ($node['node_system_access']=='crypto') {
97 $smarty->assign('crypto_pass',$_SESSION['crypto'][$node['node_id']]);
100 $smarty->assign('error',$error);
101 $smarty->assign('permissions',$permissions);
102 $smarty->assign('current_vector',$node['node_vector']);
103 if ($permissions['r']) {
104 $smarty->assign('node',$node);
105 $smarty->assign('node_json',json_encode($node));
108 $smarty->assign('node',$node);
109 //new templates by Dark matter
110 $smarty->template_dir=OWN_TEMPLATE_DIR;
112 $smarty->display('1549864.tpl');
113 $smarty->display('1549885.tpl');
114 $smarty->display('630526.tpl');
117 //redirect to mainpage
118 // looks like poeple totaly hate this redirect!
119 // header("Location: /id/1");
124 if (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']."'";
132 $whole_time=SubStr((Time()+SubStr(MicroTime(),0,8)-$timer_start),0,7);
133 $smarty->assign('whole_time',$whole_time);
136 if ($template_id=='data') {
137 if ($permissions['r']) {
138 $linkname = FILE_DIR."/".$node['node_id'];
139 $filename= readlink($linkname);
140 $suffix=preg_replace("/(.*?)\.(.*?)/i","$2",$filename);
142 $ext = substr( $filename,-3 );
143 if( $filename == "" ) {
144 echo "ERROR: Empty file to download. ";
146 } elseif ( ! file_exists( $filename ) ) {
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";
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;" );
171 header( "Content-Disposition: attachment;
174 header("Content-Transfer-Encoding: binary");
175 header("Content-Length: ".filesize($filename));
176 readfile("$filename");
180 echo "you don't have permissions for downloading this data";
187 //for cases like search & preview
188 $smarty->assign('post_vars',$_POST);
189 if (!empty($_POST['template_event'])) {
190 $smarty->assign('template_event',$_POST['template_event']);
194 //setting listing parameters
195 $children_count=$node['node_children_count'];
196 $descendant_count=$node['node_descendant_count'];
198 if (isset($_POST['listing_amount']) && is_numeric($_POST['listing_amount'])) {
199 $listing_amount=db_escape_string($_POST['listing_amount']);
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);
204 if (isset($_POST['listing_order']) && $_POST['listing_order']) {
205 $listing_order=db_escape_string($_POST['listing_order']);
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);
210 if (isset ($_POST['get_children_offset']) && is_numeric($_POST['get_children_offset'])) {
211 $offset=$_POST['get_children_offset'];
212 } else { $offset=0; }
215 //movement forward and backward
216 // if ($listing_order=='asc' && !$offset) $offset=$descendant_count-$listing_amount;
218 if (isset($_POST['get_children_move'])) {
219 if ($_POST['get_children_move']=='<') {
220 $offset=$offset-$listing_amount;
221 if ($offset<0) $offset=0;
223 elseif ($_POST['get_children_move']=='>') {
224 $offset=$offset+$listing_amount;
226 elseif ($_POST['get_children_move']=='>>') {
227 $offset=$descendant_count-$listing_amount;
230 elseif ($_POST['get_children_move']=='<<') {
234 if ($offset<0) $offset=0;
235 $_POST['offset']=$offset; // XXX sqli?
236 $smarty->assign('offset',$offset);
238 if ($node['external_link']=='header://svg' && !is_numeric($template_id)) {
239 header("Content-Type: image/svg+xml");
243 elseif (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) {
256 $smarty->template_dir=OWN_TEMPLATE_DIR;
258 if (is_numeric($template_id)) {
259 $content.=$smarty->fetch($template_id.".tpl");
263 $template_id=$node['template_id'];
264 $content.=$smarty->fetch($node['template_id'].".tpl");
267 // XXX remove constant
268 if ($template_id=='2019721'){
269 $content=$smarty->fetch($template_id.".tpl");
272 $time=SubStr((Time()+SubStr(MicroTime(),0,8)-$timer_start),0,7);
274 // echo "<center>page generation took: $time second</center>";