From 186fa4a9024e7751d47272b7e01347479e1cfe25 Mon Sep 17 00:00:00 2001 From: niekt0 Date: Mon, 4 Apr 2011 12:17:54 +0200 Subject: [PATCH] added get_synapse_weight function --- wwwroot/backend/mysql/backend.inc | 25 +++++++++++++++++++ .../node_methodz/function.get_k_neurons.php | 2 +- .../function.get_synapse_weight.php | 18 +++++++++++++ 3 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 wwwroot/inc/smarty/node_methodz/function.get_synapse_weight.php 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); + +} +?> -- 2.30.2