X-Git-Url: http://git.harvie.cz/?a=blobdiff_plain;f=wwwroot%2Fbackend%2Fmysql%2Fbackend.inc;h=515b344aa00d701f4b52671bb35029d220fdd738;hb=95a6ccc277bc41d750ced09fe5a1a779bde342c7;hp=bdc85152631c56af2cebf295cff829752571a5da;hpb=9c833cbaa6b865dda14760b7f448467ec1a912d6;p=mirrors%2FKyberia-bloodline.git diff --git a/wwwroot/backend/mysql/backend.inc b/wwwroot/backend/mysql/backend.inc index bdc8515..515b344 100644 --- a/wwwroot/backend/mysql/backend.inc +++ b/wwwroot/backend/mysql/backend.inc @@ -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); @@ -382,6 +387,31 @@ function setSynapse($params){ return true; } +// getSynapseWeight + +// If synapse does not exists, weight is 1 +// Secure. +// Returns synapse weight (from user to node) + +function getSynapseWeight($user_id,$node_id){ + global $db; + + if (!is_numeric($user_id)) + { return -1; } + if (!is_numeric($node_id)) + { return -1; } + + $set=$db->query("select synapse_weight from neurons where src =". + $user_id." and dst = ".$node_id." and link='synapse'"); + + $set->next(); + $synapse_weight=$set->getString('synapse_weight'); + if (! ($synapse_weight) ) { $synapse_weight = 1;} + return $synapse_weight; + +} } + +?>