Commit | Line | Data |
---|---|---|
e586807d H |
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 add() { | |
10 | ||
11 | global $db,$error,$node,$permissions,$types; | |
12 | $error="kyberia.sk had shut down operations. read-only mode. we'll make a comeback on 23.10. or later ;=]"; | |
13 | return false; | |
14 | ||
15 | $node_content=$_POST['node_content']; | |
16 | $node_parent=$_POST['node_parent']; | |
17 | $template_id=$_POST['template_id']; | |
18 | if (empty($template_id)) $template_id=4; | |
19 | $node_type=$template_id; | |
20 | ||
21 | $node_name=addslashes(strip_tags($_POST['node_name'])); | |
22 | $external_link=addslashes(strip_tags($_POST['external_link'])); | |
23 | ||
24 | if (empty($node_name)) { $node_name=date("d.m.Y-G:i:s"); } | |
25 | $parent_name=$node['node_name']; | |
26 | $node_creator=$_SESSION['user_id']; | |
27 | $node_system_access=$node['node_system_access']; | |
28 | ||
29 | if (!empty($_POST['node_chosen'])) { | |
30 | $node_chosen=$_POST['node_chosen']; | |
31 | if (count($node_chosen)>1) { | |
32 | $error="please select only one node."; | |
33 | return false; | |
34 | } | |
35 | else { | |
36 | $node_parent=$node_chosen['0']; | |
37 | } | |
38 | ||
39 | } | |
40 | ||
41 | if (empty($node_system_access)) { | |
42 | $node_system_access='public'; | |
43 | } | |
44 | ||
45 | $node_external_access=$_POST['node_external_access']; | |
46 | if (empty($node_external_access)) { | |
47 | $node_external_access='yes'; | |
48 | } | |
49 | ||
50 | ||
51 | if (empty($node_content)) { | |
52 | $error=$error_messages['ADD_NO_CONTENT']; | |
53 | return false; | |
54 | } | |
55 | ||
56 | $node_content=nodes::processContent($node_content); | |
57 | ||
58 | if ($node_system_access=='crypto') { | |
59 | ||
60 | require(SYSTEM_ROOT.'/inc/crypto.inc'); | |
61 | ||
62 | if ($_SESSION['crypto'][$node_parent]) { | |
63 | $key=$_SESSION['crypto'][$node_parent]; | |
64 | } | |
65 | else { | |
66 | $key = substr(md5(uniqid(rand(), true)),0,8); | |
67 | } | |
68 | ||
69 | $node_content=crypto::crypto($node_content,$key); | |
70 | ||
71 | ||
72 | //setting generated crypto password for viewing | |
73 | if ($node_system_access=='crypto') { | |
74 | $_SESSION['crypto'][$id]=$key; | |
75 | } | |
76 | ||
77 | } | |
78 | ||
79 | $params['node_name']=$node_name; | |
80 | $params['template_id']=$template_id; | |
81 | $params['node_parent']=$node_parent; | |
82 | $params['node_system_access']=$node_system_access; | |
83 | $params['node_creator']=$_SESSION['user_id']; | |
84 | $params['node_content']=$node_content; | |
85 | $params['external_link']=$external_link; | |
86 | nodes::addNode($params); | |
87 | return true; | |
88 | } | |
89 | ?> |