Kyberia v2.3 - 1st revision from SVN (Without patches of kyberia.sk team)
[mirrors/Kyberia-bloodline.git] / inc / eventz / put.inc
index 6edf2fa481e3fb51cb7454a7532f4590b065ba94..c4105d4b84816ffe056babc49c245dc9af38e5f4 100644 (file)
@@ -1,38 +1,33 @@
 <?php
-/* This program is free software. It comes without any warranty, to
- * the extent permitted by applicable law. You can redistribute it
- * and/or modify it under the terms of the Do What The Fuck You Want
- * To Public License, Version 2, as published by Sam Hocevar. See
- * http://sam.zoy.org/wtfpl/COPYING for more details. */
-
-
 function put() {
-       global $db,$node;
-       $user_id=$_SESSION['user_id'];
-       $nodeshell_id=$_POST['nodeshell_id'];
-        $nodeshell=nodes::getNodeById($nodeshell_id,$_SESSION['user_id']);
-        $nodeshell_permissions=permissions::checkPermissions($nodeshell);
+       global $error_messages,$db,$node,$error;
+       $user_id = $_SESSION['user_id'];
+
+       if (!empty($_POST['nodeshell_id'])) $nodeshell_id = mysql_real_escape_string($_POST['nodeshell_id']);
+       else $nodeshell_id = mysql_real_escape_string($_POST['nodeshell_id_select']);
 
-        if (!$nodeshell_permissions['w']) {
-                $error="you don't have permissions for writing into node $nodeshell_id";
-                return false;
-        }
+       $nodeshell = nodes::getNodeById($nodeshell_id,$_SESSION['user_id']);
+       $nodeshell_permissions = permissions::checkPermissions($nodeshell);
+       $nodeshell_vector = $nodeshell['node_vector'];
 
-        if (is_array($_POST['node_chosen'])) {
-                $put_array=$_POST['node_chosen'];
-        }
-        else $put_array[]=$node['node_id'];
+       if (!$nodeshell_permissions['w']) {
+               $error = $error_messages['WRITE_PERMISSION_ERROR'];
+               return false;
+    }
 
+       if (is_array($_POST['node_chosen'])) $put_array = $_POST['node_chosen'];
+       else $put_array[] = $node['node_id'];
 
        foreach ($put_array as $chosen) {
-               $dst_vector=$nodeshell['node_vector'].str_pad($chosen,VECTOR_CHARS,"0",STR_PAD_LEFT);
-               $q="update neurons set dst_vector='$dst_vector',synapse_created=NOW(),link='hard',synapse=synapse+1 where src='$chosen' and dst='$nodeshell_id'";
-               echo $q;
-                $result=$db->update($q);
-                if (!$result) {
-                       $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");
-               }
+               $dst_vector = $nodeshell_vector.str_pad($chosen,VECTOR_CHARS,0,STR_PAD_LEFT);
+               $q = "update neurons set synapse_created=NOW(),link='hard',synapse=synapse+1,
+dst_vector='$dst_vector' where src='$chosen' and dst='$nodeshell_id'";
+               $result=$db->update($q);
+
+               if (!$result) $db->query("insert into neurons set synapse_creator='$user_id',synapse_created=NOW(),
+src='$chosen',dst='$nodeshell_id',dst_vector='$dst_vector',link='hard',synapse=1");
+
                $db->query("update nodes set lastdescendant_created=NOW() where node_id='$nodeshell_id'");
        }
 }
-?>
\ No newline at end of file
+?>
This page took 0.126231 seconds and 4 git commands to generate.