| 1 | <?php |
| 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 | |
| 6 | if (preg_match('/^Re[:[]/', $_in)) { |
| 7 | if (preg_match('/^Re[/', $_in)) |
| 8 | return (preg_replace_callback('/^(Re[)(d*)(].*)$/', 'title_reply_callback', $_in)); |
| 9 | else return (preg_replace('/^(Re)(:.*)$/', '1[2]2', $_in)); |
| 10 | } else return ('Re: '.$_in); |
| 11 | } |
| 12 | |
| 13 | //Pridanie prispevku |
| 14 | function add_test() { |
| 15 | |
| 16 | global $db,$error,$node,$permissions,$types; |
| 17 | |
| 18 | $node_content=$_POST['node_content']; |
| 19 | $node_parent=$_POST['node_parent']; |
| 20 | $template_id=$_POST['template_id']; |
| 21 | |
| 22 | if (empty($template_id)) $template_id=4; |
| 23 | $node_type=$template_id; |
| 24 | |
| 25 | if (strlen($node_name)<1){ |
| 26 | // $error="node_name too short. please write some title"; |
| 27 | // return false; |
| 28 | |
| 29 | } |
| 30 | |
| 31 | $node_name=addslashes(strip_tags($_POST['node_name'])); |
| 32 | $external_link=addslashes(strip_tags($_POST['external_link'])); |
| 33 | |
| 34 | if (!empty($_POST['node_chosen'])) { |
| 35 | $node_chosen=$_POST['node_chosen']; |
| 36 | |
| 37 | if (count($node_chosen)>1) { |
| 38 | $error="please select only one node."; |
| 39 | return false; |
| 40 | }else { |
| 41 | $node_parent=addslashes($node_chosen['0']); |
| 42 | $q="select * from nodes where node_id='".$node_parent."'"; |
| 43 | |
| 44 | $p_set = $db->query($q); |
| 45 | if($p_set->next()){ |
| 46 | $node_parent_name = $p_set->getString('node_name'); |
| 47 | $node_parent_template = $p_set->getString('template_id'); |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | }else{ |
| 52 | $node_parent_name = $node['node_name']; |
| 53 | $node_parent_template = $node['template_id']; |
| 54 | } |
| 55 | |
| 56 | |
| 57 | if (empty($node_name)) { |
| 58 | |
| 59 | if (empty($node_parent_name)){ |
| 60 | $node_name=date("d.m.Y-G:i:s"); |
| 61 | }elseif ($node_parent_template == "4"){ |
| 62 | $node_name = title_reply($node_parent_name); |
| 63 | }else{ |
| 64 | $node_name=date("d.m.Y-G:i:s"); |
| 65 | |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | if (empty($node_name)) { |
| 70 | $node_name=date("d.m.Y-G:i:s"); |
| 71 | } |
| 72 | $parent_name=$node['node_name']; |
| 73 | |
| 74 | $node_creator=$_SESSION['user_id']; |
| 75 | |
| 76 | $node_system_access=$node['node_system_access']; |
| 77 | |
| 78 | |
| 79 | if (empty($node_system_access)) { |
| 80 | $node_system_access='public'; |
| 81 | } |
| 82 | |
| 83 | |
| 84 | $node_external_access=$_POST['node_external_access']; |
| 85 | if (empty($node_external_access)) { |
| 86 | $node_external_access='yes'; |
| 87 | } |
| 88 | |
| 89 | |
| 90 | if (empty($node_content)) { |
| 91 | |
| 92 | $error=$error_messages['ADD_NO_CONTENT']; |
| 93 | return false; |
| 94 | } |
| 95 | |
| 96 | if (is_numeric($_SESSION['mood_id'])) { |
| 97 | $node_content .= "<br><br><small>".$_SESSION['mood_content']."</small>"; |
| 98 | } |
| 99 | |
| 100 | $node_content=nodes::processContent($node_content); |
| 101 | |
| 102 | if ($node_system_access=='crypto') { |
| 103 | |
| 104 | |
| 105 | require(SYSTEM_ROOT.'/inc/crypto.inc'); |
| 106 | |
| 107 | if ($_SESSION['crypto'][$node_parent]) { |
| 108 | $key=$_SESSION['crypto'][$node_parent]; |
| 109 | } |
| 110 | else { |
| 111 | |
| 112 | $key = substr(md5(uniqid(rand(), true)),0,8); |
| 113 | } |
| 114 | |
| 115 | $node_content=crypto::crypto($node_content,$key); |
| 116 | |
| 117 | |
| 118 | //setting generated crypto password for viewing |
| 119 | if ($node_system_access=='crypto') { |
| 120 | |
| 121 | $_SESSION['crypto'][$id]=$key; |
| 122 | } |
| 123 | |
| 124 | } |
| 125 | |
| 126 | $params['node_name']=$node_name; |
| 127 | $params['template_id']=$template_id; |
| 128 | |
| 129 | $params['node_parent']=$node_parent; |
| 130 | $params['node_system_access']=$node_system_access; |
| 131 | $params['node_creator']=$_SESSION['user_id']; |
| 132 | $params['node_content']=$node_content; |
| 133 | $params['external_link']=$external_link; |
| 134 | nodes::addNode($params); |
| 135 | |
| 136 | return true; |
| 137 | } |
| 138 | ?> |