3 function sanitise_intacl(&$item) {
4 $item = '<' . intval(notags(trim($item))) . '>';
8 function sanitise_acl(&$item) {
9 $item = '<' . notags(trim($item)) . '>';
12 function item_post(&$a) {
14 if((! local_user()) && (! remote_user()))
17 require_once('include/security.php');
19 $uid = $_SESSION['uid'];
20 $parent = ((x($_POST,'parent')) ? intval($_POST['parent']) : 0);
21 $profile_uid = ((x($_POST,'profile_uid')) ? intval($_POST['profile_uid']) : 0);
23 if(! can_write_wall($a,$profile_uid)) {
24 notice("Permission denied." . EOL) ;
28 $str_group_allow = '';
29 $group_allow = $_POST['group_allow'];
30 if(is_array($group_allow)) {
31 array_walk($group_allow,'sanitise_acl');
32 $str_group_allow = implode('',$group_allow);
35 $str_contact_allow = '';
36 $contact_allow = $_POST['contact_allow'];
37 if(is_array($contact_allow)) {
38 array_walk($contact_allow,'sanitise_intacl');
39 $str_contact_allow = implode('',$contact_allow);
43 $group_deny = $_POST['group_deny'];
44 if(is_array($group_deny)) {
45 array_walk($group_deny,'sanitise_acl');
46 $str_group_deny = implode('',$group_deny);
49 $str_contact_deny = '';
50 $contact_deny = $_POST['contact_deny'];
51 if(is_array($contact_deny)) {
52 array_walk($contact_deny,'sanitise_intacl');
53 $str_contact_deny = implode('',$contact_deny);
57 $body = escape_tags(trim($_POST['body']));
60 notice("Empty post discarded." . EOL );
61 goaway($a->get_baseurl() . "/profile/$profile_uid");
64 if((x($_SESSION,'visitor_id')) && (intval($_SESSION['visitor_id'])))
65 $contact_id = $_SESSION['visitor_id'];
67 $r = q("SELECT `id` FROM `contact` WHERE `uid` = %d AND `self` = 1 LIMIT 1",
68 intval($_SESSION['uid']));
70 $contact_id = $r[0]['id'];
73 $notify_type = (($parent) ? 'comment-new' : 'wall-new' );
75 if($_POST['type'] == 'jot') {
79 $hash = random_string();
80 $r = q("SELECT `id` FROM `item` WHERE `hash` = '%s' LIMIT 1",
84 } while($dups == true);
87 $r = q("INSERT INTO `item` (`uid`,`type`,`contact-id`,`created`,`edited`,`hash`,`body`,
88 `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid`)
89 VALUES( %d, '%s', %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' )",
96 dbesc(escape_tags(trim($_POST['body']))),
97 dbesc($str_contact_allow),
98 dbesc($str_group_allow),
99 dbesc($str_contact_deny),
100 dbesc($str_group_deny)
103 $r = q("SELECT `id` FROM `item` WHERE `hash` = '%s' LIMIT 1",
106 $post_id = $r[0]['id'];
108 $r = q("UPDATE `item` SET `last-child` = 0 WHERE `parent` = %d ",
116 $r = q("UPDATE `item` SET `parent` = %d, `last-child` = 1, `visible` = 1
117 WHERE `id` = %d LIMIT 1",
122 $url = bin2hex($a->get_baseurl());
124 proc_close(proc_open("php include/notifier.php $url $notify_type $post_id > notify.log &",
128 goaway($a->get_baseurl() . "/profile/$profile_uid");