2 //funkcie na pridanie Re: alebo Re[x]: do nazvu (by Maniax)
3 function title_reply_callback($_matches) {return ($_matches[1].($_matches[2] + 1).$_matches[3]);}
4 function title_reply($_in) {
5 if (preg_match('/^Re[:\[]/', $_in)) {
6 if (preg_match('/^Re\[/', $_in))
7 return (preg_replace_callback('/^(Re\[)(\d*)(\].*)$/', 'title_reply_callback', $_in));
8 else return (preg_replace('/^(Re)(:.*)$/', '\1[2]\2', $_in));
9 } else return ('Re: '.$_in);
15 global $db,$error,$node,$permissions,$types;
17 $node_content=$_POST['node_content'];
18 $node_parent=$_POST['node_parent'];
19 $template_id=$_POST['template_id'];
20 if (empty($template_id)) $template_id=4;
21 $node_type=$template_id;
23 if (strlen($node_name)<1){
24 // $error="node_name too short. please write some title";
28 $node_name=addslashes(strip_tags($_POST['node_name']));
29 $external_link=addslashes(strip_tags($_POST['external_link']));
31 if (!empty($_POST['node_chosen'])) {
32 $node_chosen=$_POST['node_chosen'];
33 if (count($node_chosen)>1) {
34 $error="please select only one node.";
37 $node_parent=addslashes($node_chosen['0']);
38 $q="select * from nodes where node_id='".$node_parent."'";
39 $p_set = $db->query($q);
41 $node_parent_name = $p_set->getString('node_name');
42 $node_parent_template = $p_set->getString('template_id');
46 $node_parent_name = $node['node_name'];
47 $node_parent_template = $node['template_id'];
51 if (empty($node_name)) {
52 if (empty($node_parent_name)){
53 $node_name=date("d.m.Y-G:i:s");
54 }elseif ($node_parent_template == "4"){
55 $node_name = title_reply($node_parent_name);
57 $node_name=date("d.m.Y-G:i:s");
61 if (empty($node_name)) {
62 $node_name=date("d.m.Y-G:i:s");
64 $parent_name=$node['node_name'];
65 $node_creator=$_SESSION['user_id'];
67 $node_system_access=$node['node_system_access'];
70 if (empty($node_system_access)) {
71 $node_system_access='public';
74 $node_external_access=$_POST['node_external_access'];
75 if (empty($node_external_access)) {
76 $node_external_access='yes';
80 if (empty($node_content)) {
81 $error=$error_messages['ADD_NO_CONTENT'];
85 // prida mood na koniec contentu
86 if (is_numeric($_SESSION['mood_id']) && $node['external_link'] != 'db://user' && $node['external_link'] != 'session://user') {
87 $node_content .= "\n\n<small>".$_SESSION['mood_content']."</small>";
90 $node_content=nodes::processContent($node_content);
92 if ($node_system_access=='crypto') {
94 require(INCLUDE_DIR.'crypto.inc');
96 if ($_SESSION['crypto'][$node_parent]) {
97 $key=$_SESSION['crypto'][$node_parent];
100 $key = substr(md5(uniqid(rand(), true)),0,8);
103 $node_content=crypto::crypto($node_content,$key);
109 $params['node_name']=$node_name;
110 $params['template_id']=$template_id;
111 $params['node_parent']=$node_parent;
112 $params['node_system_access']=$node_system_access;
113 $params['node_creator']=$_SESSION['user_id'];
114 $params['node_content']=mysql_escape_string($node_content);
115 $params['external_link']=$external_link;
116 nodes::addNode($params);