static function getNodeIdByName($name, $external_link=false) {
global $db;
- $qh = sprintf('select node_id from nodes where node_name = "%s"', mysql_real_escape_string($name));
+ $qh = sprintf('select node_id from nodes where node_name = "%s"', db_escape_string($name));
if ($external_link)
- $qh .= sprintf(' and external_link="%s"', mysql_real_escape_string($external_link));
+ $qh .= sprintf(' and external_link="%s"', db_escape_string($external_link));
$set = $db->query($qh);
$set->next();
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;
}
+}
+
+?>