Minor display cleanup
[mirrors/Kyberia-bloodline.git] / wwwroot / backend / mysql / backend.inc
index bd765afeb26b58f1d8a4409df126c954d3c0b32b..554ba63c37358dc693def85738493c7f5443d1a6 100644 (file)
@@ -586,7 +586,7 @@ public static function getLinkedNodes($node_id,$orderby,$offset,$listing_amount)
        if ((!is_numeric($node_id))
                or (!is_numeric($offset))
                or (!is_numeric($listing_amount)))
-               { return -1; } // XXX check return value by caller?
+               { return false; } // XXX check return value by caller?
        $orderby=db_escape_string($orderby);
 
        $q="select neurons.synapse_created,node_content,author.login,linker.login as linker,nodes.* from neurons 
@@ -604,7 +604,152 @@ public static function getLinkedNodes($node_id,$orderby,$offset,$listing_amount)
                $array['node_created']=$array['synapse_created'];
                $get_linked_nodes[]=$array;
        }
-       return $get_linked_nodes;
+       return (isset($get_linked_nodes) ? $get_linked_nodes : false);
+}
+
+// getThreadedChildren
+
+
+public static function getThreadedChildren($node_id,$node_vector,$offset,$limit,$orderby,$time,$synapse_time,$security,$link,$search,$search_param) {
+       global $db;
+
+       $sql_synapse="";
+       $sql_type="";
+       $sql_time="";
+
+       if ($synapse_time) { $sql_synapse.=" and node_created >'".db_escape_string($synapse_time)."'"; }
+
+       if ($orderby=='' OR $orderby=='desc') {
+               $orderby="concat(node_vector,'z') desc,depth";
+       } else {
+               $orderby="node_vector asc";
+       }
+
+       if ($time) {
+               $sql_time="node_created > '".db_escape_string($time)."' and";
+       }
+
+       // WTF? 
+       if ($security) { $security=" and node_system_access!='private'"; }
+       else { $security = ""; }
+
+
+       if ($search=='content') {
+               $sql_type.=" and node_content like '%".db_escape_string($search_param)."%' ";
+       }
+       if ($search=='user') {
+               if (!is_numeric($search_param)) { return false; }
+               $sql_type=" and nodes.node_creator='$search_param'";
+       }
+
+
+       $q="";
+       if ($link=='yes') $q.="(";
+       $q.="select nodes.node_id,node_name,node_external_access,external_link,node_parent,
+               node_system_access,node_children_count,node_creator,node_created,lastchild_created,
+               k,node_views,node_descendant_count,lastdescendant_created,template_id,node_updated,
+               length(node_vector) as depth,users.login,node_vector, node_content,'' as synapse_creator 
+               from nodes
+               left join users on users.user_id=nodes.node_creator 
+               where $sql_time node_vector like '".$node_vector."%' $sql_type  
+                       and node_id != '".$node_id."' $security 
+               order by $orderby LIMIT $offset,$limit";
+
+       if ($link=='yes') {
+               $q.=" ) UNION (select nodes.node_id,node_name,node_external_access,external_link,
+                       node_parent,node_system_access,node_children_count,node_creator,node_created,
+                       lastchild_created,k,node_views,node_descendant_count,lastdescendant_created,
+                       template_id,node_updated,length(dst_vector) as depth,
+                       users.login,dst_vector as node_vector,node_content,synapse_creator 
+                       from neurons 
+                       left join nodes on neurons.src=nodes.node_id 
+                       left join users on users.user_id=nodes.node_creator 
+                       where  $sql_time dst_vector like '".$node_vector."%' $sql_synapse $sql_type  
+                               and node_id != '".$node_id."' order by $orderby LIMIT $offset,$limit)";
+       }
+
+       if ($link=='yes') $q.=" order by $orderby LIMIT $limit";
+
+       $result=$db->query($q);
+
+       while ($result->next()) {
+               $child = $result->getRecord();
+               transport_process_node($child);
+               if($child['synapse_creator']!='') $child['node_status']='linked';
+
+               $get_children_array[]=$child;
+       }
+
+       return $get_children_array;
+}
+
+// XXX
+
+public static function getPoll($user_id,$poll_id) {
+       global $db;
+               
+       $set=$db->query("select nodes.*,node_access.node_permission from nodes 
+               left join node_access on (nodes.node_id=node_access.node_id and node_access.user_id='$user_id') 
+               where node_parent='$poll_id' and template_id='1549834' order by node_id desc limit 1");
+
+       $set->next();
+       $array=$set->getRecord();
+       
+       return $array;
+}
+
+// XXX
+
+public static function resetPassword($login_id,$login,$vercode,$password) {
+       global $db;
+
+       // Security checks
+       $login = db_escape_string($login);
+       if (!is_numeric($login_id)) {
+               $error="Not numeric id is not numeric. Here, take this stone.";
+               return $error; 
+       } 
+
+       if ($login == '') {
+               $error="Please enter name or id";
+               return $error;
+       }
+
+       if ($login_id == 0) {
+               $set=$db->query("select * from users where login='$login'");
+       } else {
+               $set=$db->query("select * from users where user_id='$login_id'");
+       }
+
+       $set->next();
+       $user_name=$set->getString('login');
+       $user_id=$set->getString('user_id');
+       $hash=$set->getString('hash');  
+
+       if ($hash != $vercode) {
+               $error="Bad verification code!";
+               return $error;
+       }
+
+       $password = sha1($password);
+       $q="update users set password='$password',hash='' where user_id='$user_id'";
+       $db->query($q);
+       
+       $error="OK, password was RE-set";
+       return $error;
+}
+
+// levenshteinLog
+
+// Log user action for later analysis
+// Secure.
+
+public static function levenshteinLog($userid,$nodeid) {
+       global $db;
+
+       $q="insert delayed into levenshtein set user_id='".$userid."',node_id='".$node_id."'";
+       $db->update($q);
+       
 }
 
 
This page took 0.159793 seconds and 4 git commands to generate.