Kyberia v2.0
[mirrors/Kyberia-bloodline.git] / inc / eventz / put.inc
1 <?php
2 /* This program is free software. It comes without any warranty, to
3 * the extent permitted by applicable law. You can redistribute it
4 * and/or modify it under the terms of the Do What The Fuck You Want
5 * To Public License, Version 2, as published by Sam Hocevar. See
6 * http://sam.zoy.org/wtfpl/COPYING for more details. */
7
8
9 function put() {
10 global $db,$node;
11 $user_id=$_SESSION['user_id'];
12 $nodeshell_id=$_POST['nodeshell_id'];
13 $nodeshell=nodes::getNodeById($nodeshell_id,$_SESSION['user_id']);
14 $nodeshell_permissions=permissions::checkPermissions($nodeshell);
15
16 if (!$nodeshell_permissions['w']) {
17 $error="you don't have permissions for writing into node $nodeshell_id";
18 return false;
19 }
20
21 if (is_array($_POST['node_chosen'])) {
22 $put_array=$_POST['node_chosen'];
23 }
24 else $put_array[]=$node['node_id'];
25
26
27 foreach ($put_array as $chosen) {
28 $dst_vector=$nodeshell['node_vector'].str_pad($chosen,VECTOR_CHARS,"0",STR_PAD_LEFT);
29 $q="update neurons set dst_vector='$dst_vector',synapse_created=NOW(),link='hard',synapse=synapse+1 where src='$chosen' and dst='$nodeshell_id'";
30 echo $q;
31 $result=$db->update($q);
32 if (!$result) {
33 $db->query("insert into neurons set dst_vector='$dst_vector',synapse_creator='$user_id',synapse_created=NOW(),src='$chosen',dst='$nodeshell_id',link='hard',synapse=1");
34 }
35 $db->query("update nodes set lastdescendant_created=NOW() where node_id='$nodeshell_id'");
36 }
37 }
38 ?>
This page took 0.251367 seconds and 4 git commands to generate.