/** * */ function api_statuses_repeat(&$a, $type) { global $called_api; if (api_user() === false) { return false; } $user_info = api_get_user($a); // params $id = intval($a->argv[3]); if ($id == 0) { $id = intval($_REQUEST["id"]); } // Hotot workaround if ($id == 0) { $id = intval($a->argv[4]); } logger('API: api_statuses_repeat: ' . $id); $r = q("SELECT `item`.*, `item`.`id` AS `item_id`, `item`.`network` AS `item_network`, `contact`.`nick` as `reply_author`,\n\t\t\t`contact`.`name`, `contact`.`photo` as `reply_photo`, `contact`.`url` as `reply_url`, `contact`.`rel`,\n\t\t\t`contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`,\n\t\t\t`contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`\n\t\t\tFROM `item`, `contact`\n\t\t\tWHERE `item`.`visible` = 1 and `item`.`moderated` = 0 AND `item`.`deleted` = 0\n\t\t\tAND `contact`.`id` = `item`.`contact-id`\n\t\t\tAND `contact`.`blocked` = 0 AND `contact`.`pending` = 0\n\t\t\t{$sql_extra}\n\t\t\tAND `item`.`id`=%d", intval($id)); if ($r[0]['body'] != "") { if (!intval(get_config('system', 'old_share'))) { if (strpos($r[0]['body'], "[/share]") !== false) { $pos = strpos($r[0]['body'], "[share"); $post = substr($r[0]['body'], $pos); } else { $post = share_header($r[0]['author-name'], $r[0]['author-link'], $r[0]['author-avatar'], $r[0]['guid'], $r[0]['created'], $r[0]['plink']); $post .= $r[0]['body']; $post .= "[/share]"; } $_REQUEST['body'] = $post; } else { $_REQUEST['body'] = html_entity_decode("♲ ", ENT_QUOTES, 'UTF-8') . "[url=" . $r[0]['reply_url'] . "]" . $r[0]['reply_author'] . "[/url] \n" . $r[0]['body']; } $_REQUEST['profile_uid'] = api_user(); $_REQUEST['type'] = 'wall'; $_REQUEST['api_source'] = true; if (!x($_REQUEST, "source")) { $_REQUEST["source"] = api_source(); } item_post($a); } // this should output the last post (the one we just posted). $called_api = null; return api_status_show($a, $type); }
function api_statuses_update(&$a, $type) { if (api_user() === false) { logger('api_statuses_update: no user'); return false; } logger('api_statuses_update: REQUEST ' . print_r($_REQUEST, true)); logger('api_statuses_update: FILES ' . print_r($_FILES, true)); // set this so that the item_post() function is quiet and doesn't redirect or emit json $_REQUEST['api_source'] = true; $user_info = api_get_user($a); // convert $_POST array items to the form we use for web posts. // logger('api_post: ' . print_r($_POST,true)); if (requestdata('htmlstatus')) { require_once 'library/HTMLPurifier.auto.php'; require_once 'include/html2bbcode.php'; $txt = requestdata('htmlstatus'); if (strpos($txt, '<') !== false || strpos($txt, '>') !== false) { $txt = html2bb_video($txt); $config = HTMLPurifier_Config::createDefault(); $config->set('Cache.DefinitionImpl', null); $purifier = new HTMLPurifier($config); $txt = $purifier->purify($txt); } $_REQUEST['body'] = html2bbcode($txt); } else { $_REQUEST['body'] = requestdata('status'); } $parent = requestdata('in_reply_to_status_id'); if (ctype_digit($parent)) { $_REQUEST['parent'] = $parent; } else { $_REQUEST['parent_mid'] = $parent; } if ($_REQUEST['namespace'] && $parent) { $x = q("select iid from item_id where service = '%s' and sid = '%s' limit 1", dbesc($_REQUEST['namespace']), dbesc($parent)); if ($x) { $_REQUEST['parent'] = $x[0]['iid']; } } if (requestdata('lat') && requestdata('long')) { $_REQUEST['coord'] = sprintf("%s %s", requestdata('lat'), requestdata('long')); } $_REQUEST['profile_uid'] = api_user(); if ($parent) { $_REQUEST['type'] = 'net-comment'; } else { $_REQUEST['type'] = 'wall'; if (x($_FILES, 'media')) { $_FILES['userfile'] = $_FILES['media']; // upload the image if we have one $_REQUEST['silent'] = '1'; //tell wall_upload function to return img info instead of echo require_once 'mod/wall_attach.php'; $media = wall_attach_post($a); if (strlen($media) > 0) { $_REQUEST['body'] .= "\n\n" . $media; } } } // call out normal post function require_once 'mod/item.php'; item_post($a); // this should output the last post (the one we just posted). return api_status_show($a, $type); }
function api_statuses_update(&$a, $type) { if (local_user() === false) { return false; } $user_info = api_get_user($a); // convert $_POST array items to the form we use for web posts. // logger('api_post: ' . print_r($_POST,true)); if (requestdata('htmlstatus')) { require_once 'library/HTMLPurifier.auto.php'; require_once 'include/html2bbcode.php'; $txt = requestdata('htmlstatus'); if (strpos($txt, '<') !== false || strpos($txt, '>') !== false) { $txt = html2bb_video($txt); $config = HTMLPurifier_Config::createDefault(); $config->set('Cache.DefinitionImpl', null); $purifier = new HTMLPurifier($config); $txt = $purifier->purify($txt); $_POST['body'] = html2bbcode($txt); } } else { $_POST['body'] = urldecode(requestdata('status')); } $parent = requestdata('in_reply_to_status_id'); if (ctype_digit($parent)) { $_POST['parent'] = $parent; } else { $_POST['parent_uri'] = $parent; } if (requestdata('lat') && requestdata('long')) { $_POST['coord'] = sprintf("%s %s", requestdata('lat'), requestdata('long')); } $_POST['profile_uid'] = local_user(); if (requestdata('parent')) { $_POST['type'] = 'net-comment'; } else { $_POST['type'] = 'wall'; } // set this so that the item_post() function is quiet and doesn't redirect or emit json $_POST['api_source'] = true; // call out normal post function require_once 'mod/item.php'; item_post($a); // this should output the last post (the one we just posted). return api_status_show($a, $type); }