From: niekt0 Date: Mon, 4 Apr 2011 10:17:54 +0000 (+0200) Subject: added get_synapse_weight function X-Git-Url: https://git.harvie.cz/?p=mirrors%2FKyberia-bloodline.git;a=commitdiff_plain;h=186fa4a9024e7751d47272b7e01347479e1cfe25 added get_synapse_weight function --- diff --git a/wwwroot/backend/mysql/backend.inc b/wwwroot/backend/mysql/backend.inc index 87e1d2d..3c6da90 100644 --- a/wwwroot/backend/mysql/backend.inc +++ b/wwwroot/backend/mysql/backend.inc @@ -387,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(); + $synapes_weight=$set->getString('synapse_weight'); + + if (! ($synapse_weight) ) { $synapse_weight = 1;} + + return $synapse_weight; } +} + +?> diff --git a/wwwroot/inc/smarty/node_methodz/function.get_k_neurons.php b/wwwroot/inc/smarty/node_methodz/function.get_k_neurons.php index 3711415..c188c6e 100644 --- a/wwwroot/inc/smarty/node_methodz/function.get_k_neurons.php +++ b/wwwroot/inc/smarty/node_methodz/function.get_k_neurons.php @@ -2,7 +2,7 @@ function smarty_function_get_k_neurons($params,&$smarty) { - global $db,$node; + global $db; if (isset($params['offset']) && (is_numeric($params['offset']))) { $offset=$params['offset']; } else {$offset=20;} diff --git a/wwwroot/inc/smarty/node_methodz/function.get_synapse_weight.php b/wwwroot/inc/smarty/node_methodz/function.get_synapse_weight.php new file mode 100644 index 0000000..1e31ef3 --- /dev/null +++ b/wwwroot/inc/smarty/node_methodz/function.get_synapse_weight.php @@ -0,0 +1,18 @@ +assign('synapse_weight',$synapse_weight); + +} +?>