4 function item_post(&$a) {
6 if((! local_user()) && (! remote_user()))
9 require_once('include/security.php');
11 $uid = $_SESSION['uid'];
12 $parent = ((x($_POST,'parent')) ? intval($_POST['parent']) : 0);
13 $profile_uid = ((x($_POST,'profile_uid')) ? intval($_POST['profile_uid']) : 0);
14 if(! can_write_wall($a,$profile_uid)) {
15 notice("Permission denied." . EOL) ;
19 if((x($_SESSION,'visitor_id')) && (intval($_SESSION['visitor_id'])))
20 $contact_id = $_SESSION['visitor_id'];
22 $r = q("SELECT `id` FROM `contact` WHERE `uid` = %d AND `self` = 1 LIMIT 1",
23 intval($_SESSION['uid']));
25 $contact_id = $r[0]['id'];
27 if($_POST['type'] == 'jot') {
31 $hash = random_string();
32 $r = q("SELECT `id` FROM `item` WHERE `hash` = '%s' LIMIT 1",
36 } while($dups == true);
39 $r = q("INSERT INTO `item` (`uid`,`type`,`contact-id`,`created`,`edited`,`hash`,`body`)
40 VALUES( %d, '%s', %d, '%s', '%s', '%s', '%s' )",
47 dbesc(escape_tags(trim($_POST['body'])))
49 $r = q("SELECT `id` FROM `item` WHERE `hash` = '%s' LIMIT 1",
52 $post_id = $r[0]['id'];
55 $r = q("UPDATE `item` SET `parent` = %d, `visible` = 1
56 WHERE `id` = %d LIMIT 1",
61 // require('notifier.php');
64 // notifier($a,$post_id,$parent);
67 goaway($a->get_baseurl() . "/profile/$profile_uid");