function oexchange_content(&$a) { if (!local_user()) { $o = login(false); return $o; } if ($a->argc > 1 && $a->argv[1] === 'done') { info(t('Post successful.') . EOL); return; } $url = x($_GET, 'url') && strlen($_GET['url']) ? urlencode(notags(trim($_GET['url']))) : ''; $title = x($_GET, 'title') && strlen($_GET['title']) ? '&title=' . urlencode(notags(trim($_GET['title']))) : ''; $description = x($_GET, 'description') && strlen($_GET['description']) ? '&description=' . urlencode(notags(trim($_GET['description']))) : ''; $tags = x($_GET, 'tags') && strlen($_GET['tags']) ? '&tags=' . urlencode(notags(trim($_GET['tags']))) : ''; $s = fetch_url($a->get_baseurl() . '/parse_url?f=&url=' . $url . $title . $description . $tags); if (!strlen($s)) { return; } require_once 'include/html2bbcode.php'; $post = array(); $post['profile_uid'] = local_user(); $post['return'] = '/oexchange/done'; $post['body'] = html2bbcode($s); $post['type'] = 'wall'; $_POST = $post; require_once 'mod/item.php'; item_post($a); }
function oexchange_content(&$a) { if (!local_channel()) { if (remote_channel()) { $observer = $a->get_observer(); if ($observer && $observer['xchan_url']) { $parsed = @parse_url($observer['xchan_url']); if (!$parsed) { notice(t('Unable to find your hub.') . EOL); return; } $url = $parsed['scheme'] . '://' . $parsed['host'] . ($parsed['port'] ? ':' . $parsed['port'] : ''); $url .= '/oexchange'; $result = z_post_url($url, $_REQUEST); json_return_and_die($result); } } return login(false); } if (argc() > 1 && argv(1) === 'done') { info(t('Post successful.') . EOL); return; } $url = x($_REQUEST, 'url') && strlen($_REQUEST['url']) ? urlencode(notags(trim($_REQUEST['url']))) : ''; $title = x($_REQUEST, 'title') && strlen($_REQUEST['title']) ? '&title=' . urlencode(notags(trim($_REQUEST['title']))) : ''; $description = x($_REQUEST, 'description') && strlen($_REQUEST['description']) ? '&description=' . urlencode(notags(trim($_REQUEST['description']))) : ''; $tags = x($_REQUEST, 'tags') && strlen($_REQUEST['tags']) ? '&tags=' . urlencode(notags(trim($_REQUEST['tags']))) : ''; $ret = z_fetch_url($a->get_baseurl() . '/urlinfo?f=&url=' . $url . $title . $description . $tags); if ($ret['success']) { $s = $ret['body']; } if (!strlen($s)) { return; } $post = array(); $post['profile_uid'] = local_channel(); $post['return'] = '/oexchange/done'; $post['body'] = $s; $post['type'] = 'wall'; $_REQUEST = $post; require_once 'mod/item.php'; item_post($a); }
/** * */ function api_statuses_repeat(&$a, $type) { if (api_user() === false) { return false; } $user_info = api_get_user($a); // params $id = intval(argv(3)); logger('API: api_statuses_repeat: ' . $id); //$include_entities = (x($_REQUEST,'include_entities')?$_REQUEST['include_entities']:false); $observer = get_app()->get_observer(); $item_normal = item_normal(); $r = q("SELECT * from item where and id = %d {$item_normal} limit 1", intval($id)); if (perm_is_allowed($r[0]['uid'], $observer['xchan_hash'], 'view_stream')) { if ($r[0]['body'] != "") { $_REQUEST['body'] = html_entity_decode("♲ ", ENT_QUOTES, 'UTF-8') . "[zrl=" . $r[0]['reply_url'] . "]" . $r[0]['reply_author'] . "[/zrl] \n" . $r[0]['body']; $_REQUEST['profile_uid'] = api_user(); $_REQUEST['type'] = 'wall'; $_REQUEST['api_source'] = true; require_once 'mod/item.php'; item_post($a); } } else { return false; } if ($type == 'xml') { $ok = "true"; } else { $ok = "ok"; } return api_apply_template('test', $type, array('$ok' => $ok)); }
/** * */ 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 (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); }
function pumpio_fetchtimeline(&$a, $uid) { $ckey = get_pconfig($uid, 'pumpio', 'consumer_key'); $csecret = get_pconfig($uid, 'pumpio', 'consumer_secret'); $otoken = get_pconfig($uid, 'pumpio', 'oauth_token'); $osecret = get_pconfig($uid, 'pumpio', 'oauth_token_secret'); $lastdate = get_pconfig($uid, 'pumpio', 'lastdate'); $hostname = get_pconfig($uid, 'pumpio', 'host'); $username = get_pconfig($uid, "pumpio", "user"); // get the application name for the pump.io app // 1st try personal config, then system config and fallback to the // hostname of the node if neither one is set. $application_name = get_pconfig($uid, 'pumpio', 'application_name'); if ($application_name == "") { $application_name = get_config('pumpio', 'application_name'); } if ($application_name == "") { $application_name = $a->get_hostname(); } $first_time = $lastdate == ""; $client = new oauth_client_class(); $client->oauth_version = '1.0a'; $client->authorization_header = true; $client->url_parameters = false; $client->client_id = $ckey; $client->client_secret = $csecret; $client->access_token = $otoken; $client->access_token_secret = $osecret; $url = 'https://' . $hostname . '/api/user/' . $username . '/feed/major'; logger('pumpio: fetching for user ' . $uid . ' ' . $url . ' C:' . $client->client_id . ' CS:' . $client->client_secret . ' T:' . $client->access_token . ' TS:' . $client->access_token_secret); $username = $user . '@' . $host; if (pumpio_reachable($url)) { $success = $client->CallAPI($url, 'GET', array(), array('FailOnAccessError' => true), $user); } else { $success = false; } if (!$success) { logger('pumpio: error fetching posts for user ' . $uid . " " . $username . " " . print_r($user, true)); return; } $posts = array_reverse($user->items); $initiallastdate = $lastdate; $lastdate = ''; if (count($posts)) { foreach ($posts as $post) { if ($post->published <= $initiallastdate) { continue; } if ($lastdate < $post->published) { $lastdate = $post->published; } if ($first_time) { continue; } $receiptians = array(); if (@is_array($post->cc)) { $receiptians = array_merge($receiptians, $post->cc); } if (@is_array($post->to)) { $receiptians = array_merge($receiptians, $post->to); } $public = false; foreach ($receiptians as $receiver) { if (is_string($receiver->objectType)) { if ($receiver->id == "http://activityschema.org/collection/public") { $public = true; } } } if ($public and !stristr($post->generator->displayName, $application_name)) { require_once 'include/html2bbcode.php'; $_SESSION["authenticated"] = true; $_SESSION["uid"] = $uid; unset($_REQUEST); $_REQUEST["type"] = "wall"; $_REQUEST["api_source"] = true; $_REQUEST["profile_uid"] = $uid; $_REQUEST["source"] = "pump.io"; if ($post->object->displayName != "") { $_REQUEST["title"] = html2bbcode($post->object->displayName); } else { $_REQUEST["title"] = ""; } $_REQUEST["body"] = html2bbcode($post->object->content); // To-Do: Picture has to be cached and stored locally if ($post->object->fullImage->url != "") { if ($post->object->fullImage->pump_io->proxyURL != "") { $_REQUEST["body"] = "[url=" . $post->object->fullImage->pump_io->proxyURL . "][img]" . $post->object->image->pump_io->proxyURL . "[/img][/url]\n" . $_REQUEST["body"]; } else { $_REQUEST["body"] = "[url=" . $post->object->fullImage->url . "][img]" . $post->object->image->url . "[/img][/url]\n" . $_REQUEST["body"]; } } logger('pumpio: posting for user ' . $uid); require_once 'mod/item.php'; item_post($a); logger('pumpio: posting done - user ' . $uid); } } } if ($lastdate != 0) { set_pconfig($uid, 'pumpio', 'lastdate', $lastdate); } }
function fromgplus_post($a, $uid, $source, $body, $location, $coord) { //$uid = 2; // Don't know what it is. Maybe some trash from the mobile client $trash = html_entity_decode("", ENT_QUOTES, 'UTF-8'); $body = str_replace($trash, "", $body); $body = trim($body); if (substr($body, 0, 3) == "[b]") { $pos = strpos($body, "[/b]"); $title = substr($body, 3, $pos - 3); $body = trim(substr($body, $pos + 4)); } else { $title = ""; } $_SESSION['authenticated'] = true; $_SESSION['uid'] = $uid; unset($_REQUEST); $_REQUEST['type'] = 'wall'; $_REQUEST['api_source'] = true; $_REQUEST['profile_uid'] = $uid; $_REQUEST['source'] = $source; $_REQUEST['extid'] = NETWORK_GPLUS; // $_REQUEST['verb'] // $_REQUEST['parent'] // $_REQUEST['parent_uri'] $_REQUEST['title'] = $title; $_REQUEST['body'] = $body; $_REQUEST['location'] = $location; $_REQUEST['coord'] = $coord; if ($_REQUEST['title'] == "" and $_REQUEST['body'] == "") { logger('fromgplus: empty post for user ' . $uid . " " . print_r($_REQUEST, true)); return; } require_once 'mod/item.php'; //print_r($_REQUEST); logger('fromgplus: posting for user ' . $uid . " " . print_r($_REQUEST, true)); item_post($a); logger('fromgplus: done for user ' . $uid); }
function twitter_fetchtimeline($a, $uid) { $ckey = get_config('twitter', 'consumerkey'); $csecret = get_config('twitter', 'consumersecret'); $otoken = get_pconfig($uid, 'twitter', 'oauthtoken'); $osecret = get_pconfig($uid, 'twitter', 'oauthsecret'); $lastid = get_pconfig($uid, 'twitter', 'lastid'); $application_name = get_config('twitter', 'application_name'); if ($application_name == "") { $application_name = $a->get_hostname(); } $has_picture = false; require_once 'mod/item.php'; require_once 'include/items.php'; require_once 'mod/share.php'; require_once 'library/twitteroauth.php'; $connection = new TwitterOAuth($ckey, $csecret, $otoken, $osecret); $parameters = array("exclude_replies" => true, "trim_user" => false, "contributor_details" => true, "include_rts" => true); $first_time = $lastid == ""; if ($lastid != "") { $parameters["since_id"] = $lastid; } $items = $connection->get('statuses/user_timeline', $parameters); if (!is_array($items)) { return; } $posts = array_reverse($items); if (count($posts)) { foreach ($posts as $post) { if ($post->id_str > $lastid) { $lastid = $post->id_str; set_pconfig($uid, 'twitter', 'lastid', $lastid); } if ($first_time) { continue; } if (!stristr($post->source, $application_name)) { $_SESSION["authenticated"] = true; $_SESSION["uid"] = $uid; unset($_REQUEST); $_REQUEST["type"] = "wall"; $_REQUEST["api_source"] = true; $_REQUEST["profile_uid"] = $uid; //$_REQUEST["source"] = "Twitter"; $_REQUEST["source"] = $post->source; $_REQUEST["extid"] = NETWORK_TWITTER; //$_REQUEST["date"] = $post->created_at; $_REQUEST["title"] = ""; if (is_object($post->retweeted_status)) { $_REQUEST['body'] = $post->retweeted_status->text; $picture = ""; // media if (is_array($post->retweeted_status->entities->media)) { foreach ($post->retweeted_status->entities->media as $media) { switch ($media->type) { case 'photo': //$_REQUEST['body'] = str_replace($media->url, "\n\n[img]".$media->media_url_https."[/img]\n", $_REQUEST['body']); //$has_picture = true; $_REQUEST['body'] = str_replace($media->url, "", $_REQUEST['body']); $picture = $media->media_url_https; break; } } } $converted = twitter_expand_entities($a, $_REQUEST['body'], $post->retweeted_status, true, $picture); $_REQUEST['body'] = $converted["body"]; if (function_exists("share_header")) { $_REQUEST['body'] = share_header($post->retweeted_status->user->name, "https://twitter.com/" . $post->retweeted_status->user->screen_name, $post->retweeted_status->user->profile_image_url_https, "", datetime_convert('UTC', 'UTC', $post->retweeted_status->created_at), "https://twitter.com/" . $post->retweeted_status->user->screen_name . "/status/" . $post->retweeted_status->id_str) . $_REQUEST['body']; } else { $_REQUEST['body'] = "[share author='" . $post->retweeted_status->user->name . "' profile='https://twitter.com/" . $post->retweeted_status->user->screen_name . "' avatar='" . $post->retweeted_status->user->profile_image_url_https . "' posted='" . datetime_convert('UTC', 'UTC', $post->retweeted_status->created_at) . "' link='https://twitter.com/" . $post->retweeted_status->user->screen_name . "/status/" . $post->retweeted_status->id_str . "']" . $_REQUEST['body']; } $_REQUEST['body'] .= "[/share]"; } else { $_REQUEST["body"] = $post->text; $picture = ""; if (is_array($post->entities->media)) { foreach ($post->entities->media as $media) { switch ($media->type) { case 'photo': //$_REQUEST['body'] = str_replace($media->url, "\n\n[img]".$media->media_url_https."[/img]\n", $_REQUEST['body']); //$has_picture = true; $_REQUEST['body'] = str_replace($media->url, "", $_REQUEST['body']); $picture = $media->media_url_https; break; } } } $converted = twitter_expand_entities($a, $_REQUEST["body"], $post, true, $picture); $_REQUEST['body'] = $converted["body"]; } if (is_string($post->place->name)) { $_REQUEST["location"] = $post->place->name; } if (is_string($post->place->full_name)) { $_REQUEST["location"] = $post->place->full_name; } if (is_array($post->geo->coordinates)) { $_REQUEST["coord"] = $post->geo->coordinates[0] . " " . $post->geo->coordinates[1]; } if (is_array($post->coordinates->coordinates)) { $_REQUEST["coord"] = $post->coordinates->coordinates[1] . " " . $post->coordinates->coordinates[0]; } //print_r($_REQUEST); logger('twitter: posting for user ' . $uid); // require_once('mod/item.php'); item_post($a); } } } set_pconfig($uid, 'twitter', 'lastid', $lastid); }
function statusnet_fetchtimeline($a, $uid) { $ckey = get_pconfig($uid, 'statusnet', 'consumerkey'); $csecret = get_pconfig($uid, 'statusnet', 'consumersecret'); $api = get_pconfig($uid, 'statusnet', 'baseapi'); $otoken = get_pconfig($uid, 'statusnet', 'oauthtoken'); $osecret = get_pconfig($uid, 'statusnet', 'oauthsecret'); $lastid = get_pconfig($uid, 'statusnet', 'lastid'); require_once 'mod/item.php'; require_once 'include/items.php'; // get the application name for the SN app // 1st try personal config, then system config and fallback to the // hostname of the node if neither one is set. $application_name = get_pconfig($uid, 'statusnet', 'application_name'); if ($application_name == "") { $application_name = get_config('statusnet', 'application_name'); } if ($application_name == "") { $application_name = $a->get_hostname(); } $connection = new StatusNetOAuth($api, $ckey, $csecret, $otoken, $osecret); $parameters = array("exclude_replies" => true, "trim_user" => true, "contributor_details" => false, "include_rts" => false); $first_time = $lastid == ""; if ($lastid != "") { $parameters["since_id"] = $lastid; } $items = $connection->get('statuses/user_timeline', $parameters); if (!is_array($items)) { return; } $posts = array_reverse($items); if (count($posts)) { foreach ($posts as $post) { if ($post->id > $lastid) { $lastid = $post->id; } if ($first_time) { continue; } if ($post->source == "activity") { continue; } if (is_object($post->retweeted_status)) { continue; } if ($post->in_reply_to_status_id != "") { continue; } if (!stristr($post->source, $application_name)) { $_SESSION["authenticated"] = true; $_SESSION["uid"] = $uid; unset($_REQUEST); $_REQUEST["type"] = "wall"; $_REQUEST["api_source"] = true; $_REQUEST["profile_uid"] = $uid; //$_REQUEST["source"] = "StatusNet"; $_REQUEST["source"] = $post->source; $_REQUEST["extid"] = NETWORK_STATUSNET; //$_REQUEST["date"] = $post->created_at; $_REQUEST["title"] = ""; $_REQUEST["body"] = add_page_info_to_body($post->text, true); if (is_string($post->place->name)) { $_REQUEST["location"] = $post->place->name; } if (is_string($post->place->full_name)) { $_REQUEST["location"] = $post->place->full_name; } if (is_array($post->geo->coordinates)) { $_REQUEST["coord"] = $post->geo->coordinates[0] . " " . $post->geo->coordinates[1]; } if (is_array($post->coordinates->coordinates)) { $_REQUEST["coord"] = $post->coordinates->coordinates[1] . " " . $post->coordinates->coordinates[0]; } //print_r($_REQUEST); if ($_REQUEST["body"] != "") { logger('statusnet: posting for user ' . $uid); item_post($a); } } } } set_pconfig($uid, 'statusnet', 'lastid', $lastid); }
/** * */ function api_statuses_repeat(&$a, $type) { if (api_user() === false) { return false; } $user_info = api_get_user($a); // params $id = intval($a->argv[3]); logger('API: api_statuses_repeat: ' . $id); //$include_entities = (x($_REQUEST,'include_entities')?$_REQUEST['include_entities']:false); $r = q("SELECT `item`.*, `item`.`id` AS `item_id`, `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', 'new_share'))) { $post = "[share author='" . str_replace("'", "'", $r[0]['reply_author']) . "' profile='" . $r[0]['reply_url'] . "' avatar='" . $r[0]['reply_photo'] . "' link='" . $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; require_once 'mod/item.php'; item_post($a); } if ($type == 'xml') { $ok = "true"; } else { $ok = "ok"; } return api_apply_template('test', $type, array('$ok' => $ok)); }
function fbpost_fetchwall($a, $uid) { require_once "include/oembed.php"; require_once "include/network.php"; require_once "include/items.php"; require_once "mod/item.php"; require_once "include/bbcode.php"; $access_token = get_pconfig($uid, 'facebook', 'access_token'); $post_to_page = get_pconfig($uid, 'facebook', 'post_to_page'); $mirror_page = get_pconfig($uid, 'facebook', 'mirror_page'); $lastcreated = get_pconfig($uid, 'facebook', 'last_created'); if ((int) $post_to_page == 0) { $post_to_page = "me"; } if ((int) $mirror_page != 0) { $post_to_page = $mirror_page; } $url = "https://graph.facebook.com/" . $post_to_page . "/feed?access_token=" . $access_token; $first_time = $lastcreated == ""; if ($lastcreated != "") { $url .= "&since=" . urlencode($lastcreated); } $feed = fetch_url($url); $data = json_decode($feed); if (!is_array($data->data)) { return; } $items = array_reverse($data->data); foreach ($items as $item) { if ($item->created_time > $lastcreated) { $lastcreated = $item->created_time; } if ($first_time) { continue; } if ($item->application->id == get_config('facebook', 'appid')) { continue; } if (isset($item->privacy) && $item->privacy->value !== 'EVERYONE' && (int) $mirror_page == 0) { continue; } elseif (isset($item->privacy) && $item->privacy->value !== 'EVERYONE' && $item->privacy->value !== '') { continue; } elseif (!isset($item->privacy)) { continue; } if ($post_to_page != $item->from->id and (int) $post_to_page != 0) { continue; } if (!strstr($item->id, $item->from->id . "_") and isset($item->to) and (int) $post_to_page == 0) { continue; } $_SESSION["authenticated"] = true; $_SESSION["uid"] = $uid; unset($_REQUEST); $_REQUEST["type"] = "wall"; $_REQUEST["api_source"] = true; $_REQUEST["profile_uid"] = $uid; //$_REQUEST["source"] = "Facebook"; $_REQUEST["source"] = $item->application->name; $_REQUEST["extid"] = NETWORK_FACEBOOK; $_REQUEST["title"] = ""; $_REQUEST["body"] = isset($item->message) ? escape_tags($item->message) : ''; $pagedata = array(); $content = ""; $pagedata["type"] = ""; if (isset($item->name) and isset($item->link)) { $item->link = original_url($item->link); $oembed_data = oembed_fetch_url($item->link); $pagedata["type"] = $oembed_data->type; $pagedata["url"] = $item->link; $pagedata["title"] = $item->name; $content = "[bookmark=" . $item->link . "]" . $item->name . "[/bookmark]"; // If a link is not only attached but also added in the body, look if it can be removed in the body. $removedlink = trim(str_replace($item->link, "", $_REQUEST["body"])); if ($removedlink == "" or strstr($_REQUEST["body"], $removedlink)) { $_REQUEST["body"] = $removedlink; } } elseif (isset($item->name)) { $content .= "[b]" . $item->name . "[/b]"; } $pagedata["text"] = ""; if (isset($item->description) and $item->type != "photo") { $pagedata["text"] = $item->description; } if (isset($item->caption) and $item->type == "photo") { $pagedata["text"] = $item->caption; } // Only import the picture when the message is no video // oembed display a picture of the video as well //if ($item->type != "video") { //if (($item->type != "video") and ($item->type != "photo")) { if ($pagedata["type"] == "" or $pagedata["type"] == "link") { $pagedata["type"] = $item->type; if (isset($item->picture)) { $pagedata["images"][0]["src"] = $item->picture; } if ($pagedata["type"] == "photo" and isset($item->object_id)) { logger('fbpost_fetchwall: fetching fbid ' . $item->object_id, LOGGER_DEBUG); $url = "https://graph.facebook.com/" . $item->object_id . "?access_token=" . $access_token; $feed = fetch_url($url); $data = json_decode($feed); if (isset($data->images)) { $pagedata["images"][0]["src"] = $data->images[0]->source; logger('got fbid image from images for ' . $item->object_id, LOGGER_DEBUG); } elseif (isset($data->source)) { $pagedata["images"][0]["src"] = $data->source; logger('got fbid image from source for ' . $item->object_id, LOGGER_DEBUG); } elseif (isset($data->picture)) { $pagedata["images"][0]["src"] = $data->picture; logger('got fbid image from picture for ' . $item->object_id, LOGGER_DEBUG); } } if (trim($_REQUEST["body"] . $content . $pagedata["text"]) == '') { logger('facebook: empty body 1 ' . $item->id . ' ' . print_r($item, true)); continue; } $pagedata["images"][0]["src"] = fbpost_cleanpicture($pagedata["images"][0]["src"]); if ($pagedata["images"][0]["src"] != "" && isset($item->link)) { $item->link = original_url($item->link); $pagedata["url"] = $item->link; $content .= "\n" . '[url=' . $item->link . '][img]' . $pagedata["images"][0]["src"] . '[/img][/url]'; } else { if ($pagedata["images"][0]["src"] != "") { $content .= "\n" . '[img]' . $pagedata["images"][0]["src"] . '[/img]'; } // if just a link, it may be a wall photo - check if (isset($item->link)) { $content .= fbpost_get_photo($uid, $item->link); } } } if (trim($_REQUEST["body"] . $content . $pagedata["text"]) == '') { logger('facebook: empty body 2 ' . $item->id . ' ' . print_r($item, true)); continue; } if ($pagedata["type"] != "") { $_REQUEST["body"] .= add_page_info_data($pagedata); } else { if ($content) { $_REQUEST["body"] .= "\n" . trim($content); } if ($pagedata["text"]) { $_REQUEST["body"] .= "\n[quote]" . $pagedata["text"] . "[/quote]"; } $_REQUEST["body"] = trim($_REQUEST["body"]); } if (isset($item->place)) { if ($item->place->name or $item->place->location->street or $item->place->location->city or $item->place->location->country) { $_REQUEST["location"] = ''; if ($item->place->name) { $_REQUEST["location"] .= $item->place->name; } if ($item->place->location->street) { $_REQUEST["location"] .= " " . $item->place->location->street; } if ($item->place->location->city) { $_REQUEST["location"] .= " " . $item->place->location->city; } if ($item->place->location->country) { $_REQUEST["location"] .= " " . $item->place->location->country; } $_REQUEST["location"] = trim($_REQUEST["location"]); } if ($item->place->location->latitude and $item->place->location->longitude) { $_REQUEST["coord"] = substr($item->place->location->latitude, 0, 8) . ' ' . substr($item->place->location->longitude, 0, 8); } } if (trim($_REQUEST["body"]) == '') { logger('facebook: empty body 3 ' . $item->id . ' ' . print_r($item, true)); continue; } if (trim(strip_tags(bbcode($_REQUEST["body"], false, false))) == '') { logger('facebook: empty body 4 ' . $item->id . ' ' . print_r($item, true)); continue; } //print_r($_REQUEST); logger('facebook: posting for user ' . $uid); item_post($a); } set_pconfig($uid, 'facebook', 'last_created', $lastcreated); }
function user_update() { if ($this->input->post('pass')) { $this->db->update('usuarios', array('pass' => md5($this->input->post('pass'))), array('id' => $this->session->userdata('id'))); } $this->db->query("UPDATE usuarios SET " . item_post('user') . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t " . item_post('name') . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t " . item_post('apellido') . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t " . item_post('fnacimiento', 'json') . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t " . item_post('email') . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t " . item_post('soy') . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t " . item_post('orientacion') . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t " . item_post('pais') . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t " . item_post('estado') . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t " . item_post('idiomas', 'json') . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t " . item_post('frasedia') . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t " . item_post('look') . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t " . item_post('raza') . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t " . item_post('estatura') . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t " . item_post('peso') . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t " . item_post('complexion') . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t " . item_post('ojos') . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t " . item_post('pelo') . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t " . item_post('vello') . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t " . item_post('largopolla') . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t " . item_post('grosopolla') . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t " . item_post('circunci') . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t " . item_post('piercing') . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t " . item_post('tatus') . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t " . item_post('armario') . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t " . item_post('situacion') . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t " . item_post('actitud') . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t " . item_post('busco') . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t " . item_post('quebusco', 'json') . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t " . item_post('tabaco') . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t " . item_post('alcohol') . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t " . item_post('drogas') . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t " . item_post('aficiones', 'json') . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t " . item_post('fidelidad') . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t " . item_post('rol') . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t " . item_post('sexosegur') . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t " . item_post('tipochico', 'json') . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t " . item_post('fetiches', 'json') . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t " . item_post('psexuales', 'json') . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t " . item_post('tsitio') . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t " . item_post('ttsitio') . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t " . item_post('hotel') . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t " . item_post('thotel') . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t " . item_post('viajes') . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t " . item_post('roll') . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t " . htmlentities(item_post('especial')) . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t " . htmlentities(item_post('descr')) . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t WHERE id = '" . $this->session->userdata('id') . "'"); }
function user() { if ($this->uri->segment(3)) { $this->db->query("UPDATE usuarios SET " . item_post('user') . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t " . item_post('name') . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t " . item_post('apellido') . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t " . item_post('fnacimiento', 'json') . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t " . item_post('email') . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t " . item_post('soy') . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t " . item_post('orientacion') . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t " . item_post('pais') . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t " . item_post('estado') . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t " . item_post('idiomas', 'json') . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t " . item_post('frasedia') . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t " . item_post('look') . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t " . item_post('raza') . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t " . item_post('estatura') . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t " . item_post('peso') . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t " . item_post('complexion') . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t " . item_post('ojos') . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t " . item_post('pelo') . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t " . item_post('vello') . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t " . item_post('largopolla') . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t " . item_post('grosopolla') . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t " . item_post('circunci') . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t " . item_post('piercing') . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t " . item_post('tatus') . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t " . item_post('armario') . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t " . item_post('situacion') . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t " . item_post('actitud') . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t " . item_post('busco') . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t " . item_post('quebusco', 'json') . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t " . item_post('tabaco') . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t " . item_post('alcohol') . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t " . item_post('drogas') . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t " . item_post('aficiones', 'json') . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t " . item_post('fidelidad') . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t " . item_post('rol') . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t " . item_post('sexosegur') . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t " . item_post('tipochico', 'json') . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t " . item_post('fetiches', 'json') . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t " . item_post('psexuales', 'json') . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t " . item_post('tsitio') . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t " . item_post('ttsitio') . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t " . item_post('hotel') . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t " . item_post('thotel') . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t " . item_post('viajes') . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t " . item_post('roll') . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t " . item_post('especial') . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t WHERE id = '" . $_POST['id'] . "'"); redirect('admin/usuarios/views/' . $_POST['id']); } }
function ifttt_message($uid, $item) { $a = get_app(); $_SESSION["authenticated"] = true; $_SESSION["uid"] = $uid; unset($_REQUEST); $_REQUEST["type"] = "wall"; $_REQUEST["api_source"] = true; $_REQUEST["profile_uid"] = $uid; $_REQUEST["source"] = "IFTTT"; $_REQUEST["title"] = ""; $_REQUEST["body"] = $item["msg"]; //$_REQUEST["date"] = $item["date"]; //$_REQUEST["uri"] = $item["url"]; if (strstr($item["url"], "facebook.com")) { $_REQUEST["extid"] = NETWORK_FACEBOOK; } if ($item["type"] == "link") { $data = query_page_info($item["link"]); if (isset($item["title"]) and trim($item["title"]) != "") { $data["title"] = $item["title"]; } if (isset($item["description"]) and trim($item["description"]) != "") { $data["text"] = $item["description"]; } $_REQUEST["body"] .= add_page_info_data($data); } elseif ($item["type"] == "photo" and $item["image"] != "") { $_REQUEST["body"] .= "\n\n[img]" . $item["image"] . "[/img]\n"; } //print_r($_REQUEST); item_post($a); }