$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)) { $D->error = TRUE;
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; } }
$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 (!empty($item->source_description) && $item->source_description != $message) {
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); $numb->try_new_candidate_by_array($posts_id);
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; } else {
$message = preg_replace('/^(.)*:/iusU', '', $item->source_title); } if (empty($message) && !empty($item->source_description)) { if (!$obj->is_twitter) { $message = $item->source_description; } else { $message = preg_replace('/^(.)*:/iusU', '', $item->source_description); } } if (empty($message)) { continue; } $p = null; $p = new newpost(); $api_id = $obj->is_twitter == 1 ? 6 : 2; $p->set_api_id($api_id); $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) && !$obj->is_twitter) { $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) {