X-Git-Url: https://git.harvie.cz/?a=blobdiff_plain;f=wwwroot%2Fbackend%2Fmysql%2Fbackend.inc;h=f72a1025162d95aef1c54a3d78ad6a5c9c1fd812;hb=a0e722be3ebca8f1f25ba76a7c93d8cae7155462;hp=aa6e3c97b9ab0314284a6fbe3432f67e4ceb1ac3;hpb=1f014b94d50fde9d3fefc5c4b29cf3afe4ab0b05;p=mirrors%2FKyberia-bloodline.git diff --git a/wwwroot/backend/mysql/backend.inc b/wwwroot/backend/mysql/backend.inc index aa6e3c9..f72a102 100644 --- a/wwwroot/backend/mysql/backend.inc +++ b/wwwroot/backend/mysql/backend.inc @@ -289,7 +289,7 @@ public static function GetUserSubmissionsChildren($user_id,$limit=23,$offset=0,$ // XXX orderby mysql escape $q = "select child.*, users.login as login, parent.node_name as parent_name from nodes as child join - (select node_id,node_creator from nodes where node_creator='$user_id') + (select node_id,node_name,node_creator from nodes where node_creator='$user_id') as parent on child.node_parent=parent.node_id and child.node_creator <> '$user_id' join users as users on users.user_id=child.node_creator order by node_created desc $orderby LIMIT $offset,$limit"; @@ -370,9 +370,9 @@ public static function getLast($params) { else $offset=addslashes($params['offset']); global $db,$node; - if ($node['node_id']==23) { + if ($node['node_id']==DEF_LAST_NODE) { $interval=" nodes.node_created>NOW()-INTERVAL 65 HOUR and"; - $params['vector']="00"; + $vector="00"; } else { $vector=$node['node_vector']; @@ -388,6 +388,13 @@ public static function getLast($params) { nodes.node_system_access!='private' order by nodes.node_id desc LIMIT $offset,$listing_amount "; $set=$db->query($q); + + while ($set->next()) { + $last[]=$set->getRecord(); + } + + return $last; + } @@ -475,8 +482,97 @@ public static function getSynapseWeight($user_id,$node_id){ if (! ($synapse_weight) ) { $synapse_weight = 1;} return $synapse_weight; +} + +// getNodeUserlist + +// Get list of users currently viewing specified node. +// Secure. +// Returns list of (login, user_id) + +public static function getNodeUserlist($node_id) { + + global $db; + if (!is_numeric($node_id)) + { return -1; } + + + $set=$db->query("select login,user_id from users where user_action_id='$node_id'"); + while ($set->next()) { + $userlist[]=$set->getRecord(); + } + + return $userlist; +} + +// getNodeCommanders + +// Get logins of all node commanders (used in configure) +// Secure. +// Returns list of (node_permission, login) + +public static function getNodeCommanders($node_id) { + global $db; + if (!is_numeric($node_id)) + { return -1; } + + $set=$db->query("select node_permission,users.login from node_access + left join users on node_access.user_id=users.user_id where + node_id='$node_id' and node_permission!='' order by node_permission"); + + while ($set->next()) { + $commanders[$set->getString('node_permission')].=$set->getString('login').";"; + } + + return $commanders; } + +// logout + +// Log out user. +// Secure + +public static function logout() { + global $db; + $q="update users set user_action_id=null where user_id='".$_SESSION['user_id']."'"; + $db->query($q); +} + +// getNodesByType + +// +// Secure +// returns xxx + +public static function getNodesByType($vector,$user_id,$type,$orderby,$offset,$listing_amount) { + global $db; + + if ((!is_numeric($user_id)) + or (!is_numeric($offset)) + or (!is_numeric($listing_amount)) + or ($vector && !is_numeric($vector)) + or (!is_numeric($type))) + { return -1; } + + $orderby=db_escape_string($orderby); + + + $q="select parent.node_name as parent_name,users.*,nodes.*,node_access.node_user_subchild_count from nodes + left join nodes as parent on parent.node_id=nodes.node_parent + left join node_access on node_access.node_id=nodes.node_id and node_access.user_id='$user_id' + left join users on users.user_id=nodes.node_creator where "; + if ($vector) $q.="nodes.node_vector like '$vector%' and"; + $q.=" nodes.template_id='$type' and nodes.node_system_access!='private'"; + if ($orderby) $q.=" order by $orderby "; + else $q.=" order by nodes.node_id desc "; + $q.= " LIMIT $offset,$listing_amount "; + $set=$db->query($q); + + while ($set->next()) $result[]=$set->getRecord(); + + return $result; } +} ?>