private function item_validate_attachments($item) { if (!empty($item->source_image)) { $p = new newpost(); if (!($a = $p->attach_image($item->source_image))) { $item->source_image = ''; } elseif ($a->size_original[0] < 100 || $a->size_original[1] < 100) { $item->source_image = ''; } } if (!empty($item->source_video)) { $p = new newpost(); if (!($a = $p->attach_videoembed($item->source_video))) { $item->source_video = ''; } } return $item; }
$D->error = FALSE; $D->errmsg = ''; $D->message = ''; if ($this->param('mention') && !isset($_POST['message']) && ($tmp = $this->network->get_user_by_username($this->param('mention')))) { $D->message = '@' . $tmp->username . ' '; } if (isset($_POST['message'])) { $D->submit = TRUE; $D->message = trim($_POST['message']); $D->message = preg_replace('/\\s+/ius', ' ', $D->message); $D->message = trim($D->message); if (mb_strlen($D->message) > $C->POST_MAX_SYMBOLS) { $D->message = mb_substr($D->message, 0, $C->POST_MAX_SYMBOLS); } $D->message = trim($D->message); $p = new newpost(); $p->set_api_id($C->API_ID); $p->set_message($D->message); if (!$D->error && $to_user) { if (!$p->set_to_user($to_user->id)) { $D->error = TRUE; $D->errmsg = 'newpost_err_system'; } } if (!$D->error && $to_group) { if (!$p->set_group_id($to_group->id)) { $D->error = TRUE; $D->errmsg = 'newpost_err_system'; } } if (!$D->error && empty($D->message)) {
if ($f->title != $obj->feed_title && !empty($f->title)) { $db2->query('UPDATE users_rssfeeds SET feed_title="' . $db2->e($f->title) . '" WHERE id="' . $obj->id . '" LIMIT 1'); } $items = $f->get_ordered_items($obj->date_last_item, $obj->filter_keywords); if (count($items) > 0) { $posts = 0; foreach ($items as $item) { $message = $item->source_title; if (empty($message) && !empty($item->source_description)) { $message = $item->source_description; } if (empty($message)) { continue; } $p = null; $p = new newpost(); $p->set_api_id(2); $tmpu = $network->get_user_by_id($obj->user_id); $tmpu->info = $tmpu; $tmpu->is_logged = TRUE; $p->set_user_advanced($network, $tmpu); $p->set_message($message); if (!empty($item->source_url)) { $p->attach_link($item->source_url); } if (!empty($item->source_image)) { $p->attach_image($item->source_image); } if (!empty($item->source_video)) { $p->attach_videoembed($item->source_video); }
if (isset($a[$type])) { unset($a[$type]); } } } $p->set_attached($a); $res = $p->save(); if (!$res) { echo '<result><status>ERROR</status><message>' . $this->lang('pf_msgerr_sys') . '</message></result>'; exit; } $p->remove_post_cache(); echo '<result><status>OK</status><message>' . $this->lang('pf_msgok_edited') . '</message></result>'; exit; } else { $p = new newpost(); $p->set_api_id(0); if (isset($_POST['username'])) { $uid = $this->network->get_user_by_username($_POST['username'], FALSE, TRUE); $r = $p->set_to_user($uid); if (!$r) { echo '<result><status>ERROR</status><message>' . $this->lang('pf_msgerr_user') . $this->lang('pf_msgerr_user2') . '</message></result>'; exit; } } elseif (isset($_POST['groupname'])) { $gid = $this->network->get_group_by_name($_POST['groupname'], FALSE, TRUE); $r = $p->set_group_id($gid); if (!$r) { echo '<result><status>ERROR</status><message>' . $this->lang('pf_msgerr_group') . '</message></result>'; exit; }
require_once $C->INCPATH . 'helpers/func_additional.php'; if ($twitter_tag != '0' && !empty($twitter_tag)) { $since_id = $last_post_id != '0' && !empty($last_post_id) ? '&since_id=' . $last_post_id : ''; $http = curl_init(); curl_setopt($http, CURLOPT_URL, 'http://search.twitter.com/search.json?q=%23' . $twitter_tag . '&result_type=recent&rpp=100' . $since_id); curl_setopt($http, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($http, CURLOPT_HEADER, FALSE); $twitter = curl_exec($http); curl_close($http); $twitter = json_decode($twitter, true); $posts_id = array(); foreach ($twitter['results'] as $twit) { $posts_id[] = $twit['id_str']; if ($tmpu = $network->get_user_by_twitter_username($twit['from_user'])) { $p = null; $p = new newpost(); $p->set_api_id(get_app_id('twitter')); $tmpu->info = $tmpu; $tmpu->is_logged = TRUE; $p->set_user_advanced($network, $tmpu); $p->set_message(preg_replace('/#' . $twitter_tag . '/iu', '', $twit['text'])); $p->save(); } } if (count($posts_id) > 0) { if (is_64bit()) { $max_post_id = max($posts_id); } else { $numb = new bigcompare(); //$numb->try_new_candidate(1234); //$numb->try_new_candidate(1234);
} else { echo generate_error($api_session->format, 'Invalid user id.', $_SERVER['REQUEST_URI'], $api_session->callback); } exit; } if ($message = $this->db2->fetch_field('SELECT message FROM posts_pr WHERE user_id="' . intval($this->db2->e($user->id)) . '" ORDER BY id DESC LIMIT 1')) { if ($message == $_POST['text']) { if (!isset($_POST['suppress_response_codes'])) { header('HTTP/1.1 304 Not Modified'); } else { echo generate_error($api_session->format, 'Provide a different message.', $_SERVER['REQUEST_URI'], $api_session->callback); } exit; } } $newpost = new newpost(); $ok = $newpost->set_api_id($app_id); if ($ok) { $ok = $newpost->set_to_user($to_id); } if ($ok) { $newpost->set_message($_POST['text']); $ok = $newpost->save(); } if (!$ok) { if (!isset($_POST['suppress_response_codes'])) { header('HTTP/1.1 500 Internal Server Error'); } else { echo generate_error($api_session->format, 'Server error (Stage N2).', $_SERVER['REQUEST_URI'], $api_session->callback); } exit;
if (isset($s['POSTFORM_TEMP_POSTS'][$post_temp_id])) { $a = $s['POSTFORM_TEMP_POSTS'][$post_temp_id]->get_attached(); } if (!$attached_link) { unset($a['link']); } if (!$attached_image) { unset($a['image']); } if (!$attached_videoembed) { unset($a['videoembed']); } if (!$attached_file) { unset($a['file']); } $p = new newpost(); $p->set_attached($a); $p->set_api_id($C->API_ID); $p->set_message($message); if (preg_match('/^group\\:(.*)$/iu', $sharewith, $m)) { if ($g = $this->network->get_group_by_name($m[1])) { if (!$p->set_group_id($g->id)) { $D->error = TRUE; } $redirect = $C->SITE_URL . $g->groupname; } else { $D->error = TRUE; } } elseif ($sharewith == 'user') { if ($u = $this->network->get_user_by_username($sharewithx)) { if (!$p->set_to_user($u->id)) {
continue; } $db2->query('UPDATE users_rssfeeds SET date_last_item="' . $dt . '" WHERE id="' . $obj->id . '" LIMIT 1'); $items = $f->get_ordered_items($obj->date_last_item, $obj->filter_keywords); if (count($items) > 0) { $posts = 0; foreach ($items as $item) { $message = $item->source_title; if (empty($message) && !empty($item->source_description)) { $message = $item->source_description; } if (empty($message)) { continue; } $p = null; $p = new newpost(); $p->set_api_id(2); $p->set_user_advanced($network, (object) array('id' => $obj->user_id, 'is_logged' => TRUE)); $p->set_message($message); if (!empty($item->source_url)) { $p->attach_link($item->source_url); } if (!empty($item->source_image)) { $p->attach_image($item->source_image); } if (!empty($item->source_video)) { $p->attach_videoembed($item->source_video); } if (!empty($item->source_description) && $item->source_description != $message) { $p->attach_richtext($item->source_description); }
echo generate_error($api_session->format, 'Empty status parameter.', $_SERVER['REQUEST_URI'], $api_session->callback); } exit; } elseif (isset($_POST['status']) && mb_strlen($_POST['status']) > 140) { if (!isset($_POST['suppress_response_codes'])) { header('HTTP/1.1 403 Forbidden'); } else { echo generate_error($api_session->format, 'Status could no be longer than 140 symbols.', $_SERVER['REQUEST_URI'], $api_session->callback); } exit; } $_POST['status'] = trim(stripslashes(htmlspecialchars(urldecode($_POST['status'])))); if (!isset($_POST['in_reply_to_status_id'])) { $text = $this->db2->fetch_field('SELECT message FROM posts WHERE user_id ="' . intval($this->db2->e($user->id)) . '" ORDER BY id DESC LIMIT 1'); if ($text && $text != $_POST['status'] || !$text) { $newpost = new newpost(); $newpost->set_api_id($app_id); $newpost->set_message($_POST['status']); if ($api_session->resource == 'group_update') { if (isset($api_session->resource_option) && is_numeric($api_session->resource_option)) { $group_id = $api_session->resource_option; } elseif (isset($api_session->resource_option)) { $g = $network->get_group_by_name(urldecode($api_session->resource_option)); if (!$g) { if (!isset($_POST['suppress_response_codes'])) { header('HTTP/1.1 403 Forbidden'); } else { echo generate_error($api_session->format, 'Invalid group parameter.', $_SERVER['REQUEST_URI'], $api_session->callback); } exit; }