X-Git-Url: http://git.harvie.cz/?a=blobdiff_plain;f=wwwroot%2Fnodes.php;h=a6b0620ba4d9bf39c5afa39a9cdd8cd05b3c2634;hb=20b73641f851cc13883ae5496c790901638f625e;hp=2ace75364fb1e679f25b6b24ab90bec1142e195f;hpb=12425f118c94f4c30d09b1f196d6c209a2b816dc;p=mirrors%2FKyberia-bloodline.git diff --git a/wwwroot/nodes.php b/wwwroot/nodes.php index 2ace753..a6b0620 100644 --- a/wwwroot/nodes.php +++ b/wwwroot/nodes.php @@ -28,12 +28,39 @@ if ($_SESSION['debugging']) { print_r($_SESSION); } + +//Path info (Experimental - thish should replace most of mod_rewrites in future...) +@$PATH_INFO=trim($_SERVER[PATH_INFO]); +if($PATH_INFO != '') { + $PATH_CHUNKS = preg_split("/\//", $PATH_INFO); + if(isset($PATH_CHUNKS[1])) switch($PATH_CHUNKS[1]) { + case 'k': + if(isset($PATH_CHUNKS[2]) && $PATH_CHUNKS[2] != '') $_GET['node_kid'] = $PATH_CHUNKS[2]; + if(isset($PATH_CHUNKS[3]) && $PATH_CHUNKS[3] != '') $_GET['template_kid'] = $PATH_CHUNKS[3]; + break; + case 'id': + if(isset($PATH_CHUNKS[2]) && $PATH_CHUNKS[2] != '') $_GET['node_id'] = $PATH_CHUNKS[2]; + if(isset($PATH_CHUNKS[3]) && $PATH_CHUNKS[3] != '') $_GET['template_id'] = $PATH_CHUNKS[3]; + break; + default: + if($PATH_CHUNKS[1] != '') $_GET['node_name'] = $PATH_CHUNKS[1]; + if(isset($PATH_CHUNKS[2]) && $PATH_CHUNKS[2] != '') $_GET['template_kid'] = $PATH_CHUNKS[2]; + break; + } +} + +//Base36 http://en.wikipedia.org/wiki/Base_36 (Initial support only :-) +if(isset($_GET['node_kid'])) $_GET['node_id'] = base_convert($_GET['node_kid'], 36, 10); +if(isset($_GET['template_kid'])) $_GET['template_id'] = base_convert($_GET['template_kid'], 36, 10); + //requiring main config file with path/database etc. constants require('config/config.inc'); require(INCLUDE_DIR.'senate.inc'); -preg_match("/id\/(.*)\//",$_SERVER['HTTP_REFERER'],$ref_match); -$referer_id=$ref_match[1]; +if (isset($_SERVER['HTTP_REFERER'])) { + preg_match("/id\/([0-9]*)\//",$_SERVER['HTTP_REFERER'],$ref_match); + $referer_id=$ref_match[1]; +} //connecting to database and creating universal $db object require(INCLUDE_DIR.'log.inc'); @@ -46,15 +73,16 @@ $db = new CLASS_DATABASE(); if (!empty($_GET['template_id'])) { $template_id=$_GET['template_id']; +} else { + $template_id=false; } -else $template_id=false; //initializing node methods if (!empty($_GET['node_name'])) { $node = nodes::redirByName($_GET['node_name']); -} -elseif (!empty($_GET['node_id'])) { - $node = nodes::getNodeById($_GET['node_id'],$_SESSION['user_id']); +} elseif (!empty($_GET['node_id'])) { + $node = nodes::getNodeById($_GET['node_id'], + (isset($_SESSION['user_id']))?$_SESSION['user_id']:''); } //XXX Paths are wrong (!) @@ -133,7 +161,7 @@ function _checkPermissions() } // mail rss -if ($template_id=='rss') +if ($template_id=='rss') //XXX WHAT? { $_feedType = "RSS0.91"; if (!is_numeric($_SESSION['user_id'])) @@ -170,6 +198,7 @@ if ($template_id=='rss') $rss->description = ""; $rss->link = "https://". SYSTEM_URL . "/id/24"; + //XXX into function $query = "select date_format(mail.mail_timestamp,\"%e.%c. %k:%i:%s\") as cas, userfrom.user_action as locationfrom_action, userfrom.user_action_id as locationfrom_action_id, @@ -200,7 +229,7 @@ if ($template_id=='rss') $rss = new UniversalFeedCreator(); $rss->title = "Kyberia bookmarks"; - $rss->link = "http://".SYSTEM_URL."/id/19"; + $rss->link = "http://".SYSTEM_URL."/id/19"; //XXX https ? require_once(SMARTY_PLUGIN_DIR.'/function.get_bookmarks.php'); smarty_function_get_bookmarks(array(), $smarty); @@ -263,29 +292,37 @@ _checkPermissions(); //sventest if (($permissions['r']) || ($event != 'register')) { -//performing node_events (based on update/insert/delete db queries) -if ($event) { - require(INCLUDE_DIR.'eventz.inc'); -} + //performing node_events (based on update/insert/delete db queries) + if ($event) { + require(INCLUDE_DIR.'eventz.inc'); + } -elseif ($transaction) { - require(INCLUDE_DIR.'transaction.inc'); -} -//end of performing node events + elseif ($transaction) { + require(INCLUDE_DIR.'transaction.inc'); + } + //end of performing node events -//sventest + //sventest } if ($permissions['r']) { -//these 4 lines are not the source of kyberia lagging problems. leave them. started on the 10.4. data gained will be used for scientific purposes -if ($_SESSION['user_id']) { +// these 4 lines are not the source of kyberia lagging problems. +// leave them. started on the 10.4. +// data gained will be used for scientific purposes + +// if (isset($_SESSION['user_id']) { +// log_levenshtein($_SESSION['user_id'],$node['node_id']); +// } + +if ((isset($_SESSION['user_id'])) && ($_SESSION['user_id'])) { $q="insert delayed into levenshtein set user_id='".$_SESSION['user_id']."',node_id='".$node['node_id']."'"; $db->update($q); } //if node is css +//XXX into function if ($node['template_id']!='2019721'){ logger::log('enter',$node['node_id'],'ok',$node['node_user_subchild_count']); @@ -297,16 +334,25 @@ if ($node['template_id']!='2019721'){ if (!$result) { $q="insert into node_access set user_id='".$_SESSION['user_id']."',node_id='".$node['node_id']."',last_visit=NOW()"; $db->query($q); - } -}//end of if node os css + } + }//end of if node os css } +} + +//XXX into function +// if (isset($_SESSION['user_id']) { +// if (isset($referer_id)) { +// update_nodes($_SESSION['user_id'],$node['node_id'],$referer_id); +// } else { +// update_nodes($_SESSION['user_id'],$node['node_id'],0); +// } +// } - } // DO NOT MESS WITH THIS !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! //creating neural network $db->update("update nodes set node_views=node_views+1 where node_id='".$node['node_id']."'"); -if (is_numeric($referer_id)) { +if (isset($referer_id) && is_numeric($referer_id)) { $q="update neurons set synapse=synapse+1 where dst='".$node['node_id']."' and src='$referer_id'"; $result=$db->update($q); if (!$result) { @@ -322,6 +368,7 @@ elseif (!$permissions['r'] && $_GET['magic_word']) { if ( preg_match("/(\d+)-(.+)/",$_GET['magic_word'],$mu)) { $magic_uid=$mu['1']; $magic_word=addslashes($mu['2']); + // XXX WTF column magic_word does not exists $q="select login from users where user_id='$magic_uid' and magic_word='$magic_word'"; $set=$db->query($q); if ($set->getNumRows()) { @@ -341,7 +388,7 @@ else { //assigning user data to smarty if user logged in -if ($user_id=$_SESSION['user_id']) { +if (isset($_SESSION['user_id'])&&($user_id=$_SESSION['user_id'])) { $smarty->assign('_POST',$_POST); $smarty->assign('bookmarks',$_SESSION['bookmarks']); $smarty->assign('ignore',$_SESSION['ignore']); @@ -353,6 +400,7 @@ if ($user_id=$_SESSION['user_id']) { $smarty->assign('friends',$_SESSION['friends']); //req by freezy, done by darkaural $smarty->assign('user_quota',$_SESSION['user_quota']); + // XXX into function $newmail_q = sprintf('select u.user_mail_id , u.user_k , u.k_wallet @@ -365,10 +413,10 @@ if ($user_id=$_SESSION['user_id']) { $user_id); $newmailset = $db->query($newmail_q); -//$newmailset=$db->query("select user_mail,user_mail_name,user_k,k_wallet from users where user_id='$user_id'"); $newmailset->next(); $new_mail=$newmailset->getString('user_mail'); + // XXX into function $newmailset2 = $db->query("select users.user_mail_id,mailsender.login from users left join users as mailsender on users.user_mail_id = mailsender.user_id where users.user_id = '$user_id'"); $newmailset2->next(); @@ -385,6 +433,7 @@ if ($user_id=$_SESSION['user_id']) { if ($node['node_name']=='mail') { //clear new mail message + if ($new_mail) $db->query("update users set user_mail=0 where user_id='$user_id'"); //set messages as delivered to recipient @@ -432,7 +481,8 @@ else { } -if ($node['template_id']!='2019721'){ +// XXX into function +if (($node['template_id']!='2019721') && (isset($_SESSION['user_id']))){ //setting user location $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']."'"; $db->executequery($q); @@ -508,18 +558,21 @@ if (!empty($_POST['template_event'])) { $children_count=$node['node_children_count']; $descendant_count=$node['node_descendant_count']; - if (is_numeric($_POST['listing_amount'])) $listing_amount=$_POST['listing_amount']; - elseif (!empty($_SESSION['listing_amount'])) $listing_amount=$_SESSION['listing_amount']; + if (isset($_POST['listing_amount']) && is_numeric($_POST['listing_amount'])) { + $listing_amount=mysql_real_escape_string($_POST['listing_amount']); + }elseif (!empty($_SESSION['listing_amount'])) $listing_amount=$_SESSION['listing_amount']; else $listing_amount=DEFAULT_LISTING_AMOUNT; $smarty->assign('listing_amount',$listing_amount); - if ($_POST['listing_order']) $listing_order=$_POST['listing_order']; - elseif (!empty($_SESSION['listing_order'])) $listing_order=$_SESSION['listing_order']; + if (isset($_POST['listing_order']) && $_POST['listing_order']) { + $listing_order=mysql_real_escape_string($_POST['listing_order']); + } elseif (!empty($_SESSION['listing_order'])) $listing_order=$_SESSION['listing_order']; else $listing_order=DEFAULT_LISTING_ORDER; $smarty->assign('listing_order',$listing_order); - if (is_numeric($_POST['get_children_offset'])) $offset=$_POST['get_children_offset']; - else $offset=0; + if (isset ($_POST['get_children_offset']) && is_numeric($_POST['get_children_offset'])) { + $offset=$_POST['get_children_offset']; + } else { $offset=0; } //movement forward and backward @@ -549,7 +602,7 @@ if ($node['external_link']=='header://svg' && !is_numeric($template_id)) { } //show own header -elseif ($_SESSION['header_id']==true) { +elseif (isset($_SESSION['header_id']) && ($_SESSION['header_id']==true)) { $smarty->assign('header_id',$_SESSION['header_id']); $smarty->template_dir=OWN_TEMPLATE_DIR; $content=$smarty->fetch($_SESSION['header_id'].".tpl");