k_neurons fix & small warnings removed
authorniekt0 <niekt0@kyberia.cz>
Fri, 1 Apr 2011 23:13:45 +0000 (01:13 +0200)
committerniekt0 <niekt0@kyberia.cz>
Fri, 1 Apr 2011 23:13:45 +0000 (01:13 +0200)
wwwroot/backend/mysql/backend.inc
wwwroot/backend/mysql/functions.sql
wwwroot/inc/eventz.inc
wwwroot/inc/eventz/display.inc

index bdc85152631c56af2cebf295cff829752571a5da..87e1d2d744bd09297fafed0b8050e5eb81d66d78 100644 (file)
@@ -363,6 +363,11 @@ function setSynapse($params){
        $dst=$params['dst'];
        $weight=$params['weight'];
 
+       // weight could be only positive
+       if ( $weight < 0) {
+               return false;
+       }
+
        // if already exists
        $q="select count(src) from neurons where dst ='$dst' and src = '$src'";
        $set=$db->query($q);
index b5c81a13ec4ae4c08238323f28a52edbe383b3ef..c50f19dffa333ca44b2d0ce03dc3f5933c914e2f 100644 (file)
@@ -20,17 +20,19 @@ BEGIN
                /* weigths from user to: 
                        - all nodes from node to root node
                        - all node owners from node to root node
-                       - all nodes between themselves (safe?)
+                       - all nodes between themselves (safe?) XXX removed
                */
-               select node_weight,node_creator into n_weight,n_owner from nodes where node_id=node2;
+               select /*node_weight,*/node_creator into /*n_weight,*/n_owner from nodes where node_id=node2;
                select synapse_weight into s_weight from neurons where src=user and dst=node2;
+               if found_rows() = 0  then set s_weight=1; end if;
                select synapse_weight into o_weight from neurons where src=user and dst=n_owner;
+               if found_rows() = 0 then set o_weight=1; end if;
+       
+/*             if o_weight = NULL or o_weight=0 then set o_weight=1; end if;
+               if s_weight = NULL or s_weight=0 then set s_weight=1; end if;*/
+               /*if n_weight = NULL or n_weight=0 then set n_weight=1; end if;*/
                
-               if o_weight = NULL or o_weight=0 then set o_weight=1; end if;
-               if s_weight = NULL or s_weight=0 then set s_weight=1; end if;
-               if n_weight = NULL or n_weight=0 then set n_weight=1; end if;
-               
-               set final = final * s_weight * o_weight * n_weight;
+               set final = final * s_weight * o_weight;/* * n_weight;*/
        END WHILE;
        RETURN final;
 END//
@@ -43,6 +45,7 @@ BEGIN
                nodes.node_name,
                nodes.node_creator,
                nodes.node_content,
+               nodes.k,
                nodes.node_parent,(k_get_node_weigth(nodes.node_id,user_id)*nodes.k) as weight_k,
                users.login as creator_name,
                parent.node_name as parent_name 
index 418ab07671fc82b3a0afecb8535aba1c82853b53..a47a4c65fda14b88f658d0a83f6a9283429e8797 100644 (file)
@@ -1,12 +1,13 @@
 <?php
-if(preg_match('/36$/', $event) || preg_match('/36$/', $_POST['event'])) {
+if(preg_match('/36$/', $event) ||  (!empty($_POST['event']) && preg_match('/36$/', $_POST['event']))) {
   $event = preg_replace('/36$/', '', $event);
   $_POST['event'] = preg_replace('/36$/', '', $_POST['event']);
   $_POST['nodeshell_id'] = base_convert($_POST['nodeshell_id'], 36, 10); //put36
   $_POST['new_parent'] = base_convert($_POST['new_parent'], 36, 10); //set_parent36
 }
 
-if($event=='delete' || $_POST['event']=='delete') { //XXX TODO FIXME UglyFuckingHack - should go to delete.inc (but something is broken)
+if($event=='delete' || (!empty($_POST['event']) && $_POST['event']=='delete')) { 
+//XXX TODO FIXME UglyFuckingHack - should go to delete.inc (but something is broken)
   $event='set_parent';
   $_POST['event']=$event;
   $_POST['new_parent']=123456; //XXX TODO FIXME Hardcoded
index fdfa0fdca68d15146aac5ae148559cd8dff45595..24abb01e60b5b6e35ac6d5a4566c623abc4ef8b4 100644 (file)
@@ -1,6 +1,7 @@
 <?php
 function display() {
        global $node,$db,$error,$referer_id,$smarty,$permissions,$template_id;
+       global $timer_start;
        if (!$referer_id) $referer_id=1;
 
        $node_id=$node['node_id'];
@@ -54,15 +55,15 @@ if ($node['template_id']!='2019721'){
 if (isset($_SESSION['user_id'])&&($user_id=$_SESSION['user_id'])) {
        $smarty->assign('_POST',$_POST);
        $smarty->assign('bookmarks',$_SESSION['bookmarks']);
-       $smarty->assign('ignore',$_SESSION['ignore']);
+       if (isset($_SESSION['ignore'])) { $smarty->assign('ignore',$_SESSION['ignore']); };
        $smarty->assign('bookstyl',$_SESSION['bookstyl']);
-       $smarty->assign('fook',$_SESSION['fook']);
+       if (isset($_SESSION['fook'])) {$smarty->assign('fook',$_SESSION['fook']); };
        $smarty->assign('user_id',$_SESSION['user_id']);
        $smarty->assign('user_name',$_SESSION['user_name']);
        if (!empty($_SESSION['cube_vector'])) 
                $smarty->assign('cube_vector',$_SESSION['cube_vector']);
         $smarty->assign('friends',$_SESSION['friends']); //req by freezy, done by darkaural
-       $smarty->assign('user_quota',$_SESSION['user_quota']);
+       if (isset($_SESSION['user_quota'])) {$smarty->assign('user_quota',$_SESSION['user_quota']);};
 
        // XXX into function
        $newmail_q = sprintf('select u.user_mail_id
@@ -244,23 +245,25 @@ if (!empty($_POST['template_event'])) {
         //movement forward and backward
 //     if ($listing_order=='asc' && !$offset) $offset=$descendant_count-$listing_amount;
 
-        if ($_POST['get_children_move']=='<') {
-               $offset=$offset-$listing_amount;
-                     if ($offset<0) $offset=0;
-        }
-        elseif ($_POST['get_children_move']=='>') {
-               $offset=$offset+$listing_amount;
-        }
-       elseif ($_POST['get_children_move']=='>>') {
-               $offset=$descendant_count-$listing_amount;
-               }
-
-        elseif ($_POST['get_children_move']=='<<') {
-               $offset=0;
-        }
-        if ($offset<0) $offset=0;
-        $_POST['offset']=$offset;
-        $smarty->assign('offset',$offset);
+       if (isset($_POST['get_children_move'])) { 
+               if ($_POST['get_children_move']=='<') {
+                       $offset=$offset-$listing_amount;
+                       if ($offset<0) $offset=0;
+               }
+               elseif ($_POST['get_children_move']=='>') {
+                       $offset=$offset+$listing_amount;
+               }
+               elseif ($_POST['get_children_move']=='>>') {
+                       $offset=$descendant_count-$listing_amount;
+               }
+
+               elseif ($_POST['get_children_move']=='<<') {
+                       $offset=0;
+               }
+       }
+       if ($offset<0) $offset=0;
+       $_POST['offset']=$offset; // XXX sqli?
+       $smarty->assign('offset',$offset);
 
 
 if ($node['external_link']=='header://svg' && !is_numeric($template_id)) {
@@ -292,6 +295,7 @@ else {
        $content.=$smarty->fetch($node['template_id'].".tpl");
 }
 
+// XXX remove constant
 if ($template_id=='2019721'){
        $content=$smarty->fetch($template_id.".tpl");
        echo $content;
This page took 0.357985 seconds and 4 git commands to generate.