| 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 | function delete() { |
| 9 | global $node,$db,$error; |
| 10 | $nodes=$_POST['node_chosen']; |
| 11 | |
| 12 | if (empty($nodes)) { |
| 13 | $nodes[]=$node['node_id']; |
| 14 | } |
| 15 | |
| 16 | foreach ($nodes as $chosen) { |
| 17 | if (empty($chosen)) { |
| 18 | $error="just a little bug"; |
| 19 | return false; |
| 20 | } |
| 21 | |
| 22 | $delete_node=nodes::getNodeById($chosen); |
| 23 | $vector=$delete_node['node_vector']; |
| 24 | |
| 25 | |
| 26 | if ($delete_node['node_creator']==$_SESSION['user_id'] || isHierarch($delete_node)) { |
| 27 | $q="insert into tiamat (node_id,node_name,node_parent,node_thread_vector,node_type,node_external_access,node_system_access,node_children_count,node_creator,node_created,lastchild_created,k,node_views,node_destructor,node_content,node_descendant_count,lastdescendant_created,template_id) select nodes.node_id,node_name,node_parent,node_vector,node_type,node_external_access,node_system_access,node_children_count,node_creator,node_created,lastchild_created,k,node_views,'$user_id',node_content,node_descendant_count,lastdescendant_created,template_id from nodes left join node_content on nodes.node_id=node_content.node_id where nodes.node_id='$chosen'"; |
| 28 | echo $q; |
| 29 | // $db->query($q); |
| 30 | $q="delete from nodes where node_id='$chosen'"; |
| 31 | echo $q; |
| 32 | // $db->query($q); |
| 33 | $q="delete from node_access where node_id='$chosen'"; |
| 34 | echo $q; |
| 35 | // $db->query($q); |
| 36 | echo $q; |
| 37 | $q="update node_access set node_user_subchild_count=node_user_subchild_count-1 where node_id='$node_parent' and last_visit<'$created'"; |
| 38 | // $db->query($q); |
| 39 | echo $q; |
| 40 | if (!empty($vector)) { |
| 41 | $q="update nodes set node_vector=replace(node_vector,'$vector','') where node_vector like '$vector%'"; |
| 42 | echo $q; |
| 43 | // $db->query($q); |
| 44 | } |
| 45 | |
| 46 | } |
| 47 | |
| 48 | } |
| 49 | |
| 50 | } |
| 51 | ?> |