// Check if the URL is an image, video or audio file. If so format
// the URL with the corresponding BBCode media tag
// Fetch the header of the URL
- $curlResponse = DI::httpRequest()->get($url, false, ['novalidate' => true, 'nobody' => true]);
+ $curlResponse = DI::httpRequest()->get($url, ['novalidate' => true, 'nobody' => true]);
if ($curlResponse->isSuccess()) {
// Convert the header fields into an array
if (!in_array($ext, $noexts)) {
// try oembed autodiscovery
- $html_text = DI::httpRequest()->fetch($embedurl, false, 15, 'text/*');
+ $html_text = DI::httpRequest()->fetch($embedurl, 15, 'text/*');
if ($html_text) {
$dom = @DOMDocument::loadHTML($html_text);
if ($dom) {
continue;
}
- $curlResult = DI::httpRequest()->get($mtch[1], true);
+ $curlResult = DI::httpRequest()->get($mtch[1]);
if (!$curlResult->isSuccess()) {
continue;
}
$searchUrl .= '&page=' . $page;
}
- $resultJson = DI::httpRequest()->fetch($searchUrl, false, 0, 'application/json');
+ $resultJson = DI::httpRequest()->fetch($searchUrl, 0, 'application/json');
$results = json_decode($resultJson, true);
$return = Contact::searchByName($search, $mode);
} else {
$p = $page > 1 ? 'p=' . $page : '';
- $curlResult = DI::httpRequest()->get(self::getGlobalDirectory() . '/search/people?' . $p . '&q=' . urlencode($search), false, ['accept_content' => 'application/json']);
+ $curlResult = DI::httpRequest()->get(self::getGlobalDirectory() . '/search/people?' . $p . '&q=' . urlencode($search), ['accept_content' => 'application/json']);
if ($curlResult->isSuccess()) {
$searchResult = json_decode($curlResult->getBody(), true);
if (!empty($searchResult['profiles'])) {
}
$url = DI::baseUrl() . '/worker';
- DI::httpRequest()->fetch($url, false, 1);
+ DI::httpRequest()->fetch($url, 1);
}
/**
// When a nodeinfo is present, we don't need to dig further
$xrd_timeout = DI::config()->get('system', 'xrd_timeout');
- $curlResult = DI::httpRequest()->get($url . '/.well-known/nodeinfo', false, ['timeout' => $xrd_timeout]);
+ $curlResult = DI::httpRequest()->get($url . '/.well-known/nodeinfo', ['timeout' => $xrd_timeout]);
if ($curlResult->isTimeout()) {
self::setFailure($url);
return false;
$basedata = ['detection-method' => self::DETECT_MANUAL];
}
- $curlResult = DI::httpRequest()->get($baseurl, false, ['timeout' => $xrd_timeout]);
+ $curlResult = DI::httpRequest()->get($baseurl, ['timeout' => $xrd_timeout]);
if ($curlResult->isSuccess()) {
$basedata = self::analyseRootHeader($curlResult, $basedata);
$basedata = self::analyseRootBody($curlResult, $basedata, $baseurl);
// When the base path doesn't seem to contain a social network we try the complete path.
// Most detectable system have to be installed in the root directory.
// We checked the base to avoid false positives.
- $curlResult = DI::httpRequest()->get($url, false, ['timeout' => $xrd_timeout]);
+ $curlResult = DI::httpRequest()->get($url, ['timeout' => $xrd_timeout]);
if ($curlResult->isSuccess()) {
$urldata = self::analyseRootHeader($curlResult, $serverdata);
$urldata = self::analyseRootBody($curlResult, $urldata, $url);
private static function validHostMeta(string $url)
{
$xrd_timeout = DI::config()->get('system', 'xrd_timeout');
- $curlResult = DI::httpRequest()->get($url . '/.well-known/host-meta', false, ['timeout' => $xrd_timeout]);
+ $curlResult = DI::httpRequest()->get($url . '/.well-known/host-meta', ['timeout' => $xrd_timeout]);
if (!$curlResult->isSuccess()) {
return false;
}
if (!empty($accesstoken)) {
$api = 'https://instances.social/api/1.0/instances/list?count=0';
$header = ['Authorization: Bearer '.$accesstoken];
- $curlResult = DI::httpRequest()->get($api, false, ['headers' => $header]);
+ $curlResult = DI::httpRequest()->get($api, ['headers' => $header]);
if ($curlResult->isSuccess()) {
$servers = json_decode($curlResult->getBody(), true);
$filename = basename($image_url);
if (!empty($image_url)) {
- $ret = DI::httpRequest()->get($image_url, true);
+ $ret = DI::httpRequest()->get($image_url);
$img_str = $ret->getBody();
$type = $ret->getContentType();
} else {
$photo_failure = false;
$filename = basename($photo);
- $curlResult = DI::httpRequest()->get($photo, true);
+ $curlResult = DI::httpRequest()->get($photo);
if ($curlResult->isSuccess()) {
$img_str = $curlResult->getBody();
$type = $curlResult->getContentType();
use Friendica\Core\ACL;
use Friendica\Core\Hook;
use Friendica\Core\Renderer;
+use Friendica\Core\Session;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact;
self::$forumContactId = $parameters['contact_id'] ?? 0;
- self::$selectedTab = DI::pConfig()->get(local_user(), 'network.view', 'selected_tab', '');
+ self::$selectedTab = Session::get('network-tab', '');
if (!empty($get['star'])) {
self::$selectedTab = 'star';
self::$selectedTab = $get['order'];
}
- DI::pConfig()->set(local_user(), 'network.view', 'selected_tab', self::$selectedTab);
+ Session::set('network-tab', self::$selectedTab);
- self::$star = intval($get['star'] ?? 0);
- self::$mention = intval($_GET['mention'] ?? 0);
- self::$order = in_array(self::$selectedTab, ['received', 'commented', 'created', 'uriid']) ? self::$selectedTab : 'commented';
+ self::$star = intval($get['star'] ?? 0);
+ self::$mention = intval($get['mention'] ?? 0);
+ self::$order = $get['order'] ?? Session::get('network-order', 'commented');
- self::$accountTypeString = $_GET['accounttype'] ?? $parameters['accounttype'] ?? '';
+ self::$selectedTab = self::$selectedTab ?? self::$order;
+
+ Session::set('network-tab', self::$selectedTab);
+ Session::set('network-order', self::$order);
+
+ self::$accountTypeString = $get['accounttype'] ?? $parameters['accounttype'] ?? '';
self::$accountType = User::getAccountTypeByString(self::$accountTypeString);
self::$network = $get['nets'] ?? '';
DI::config()->get('system', 'itemspage_network'));
}
- self::$min_id = $_GET['min_id'] ?? null;
- self::$max_id = $_GET['max_id'] ?? null;
+ self::$min_id = $get['min_id'] ?? null;
+ self::$max_id = $get['max_id'] ?? null;
- switch (self::$selectedTab) {
+ switch (self::$order) {
case 'received':
- self::$max_id = $_GET['last_received'] ?? self::$max_id;
+ self::$max_id = $get['last_received'] ?? self::$max_id;
break;
case 'commented':
- self::$max_id = $_GET['last_commented'] ?? self::$max_id;
+ self::$max_id = $get['last_commented'] ?? self::$max_id;
break;
case 'created':
- self::$max_id = $_GET['last_created'] ?? self::$max_id;
+ self::$max_id = $get['last_created'] ?? self::$max_id;
break;
case 'uriid':
- self::$max_id = $_GET['last_uriid'] ?? self::$max_id;
+ self::$max_id = $get['last_uriid'] ?? self::$max_id;
break;
}
}
$items = array_reverse($items);
}
- $parents_str = '';
if (DBA::isResult($items)) {
- $parents_arr = [];
-
- foreach ($items as $item) {
- if (!in_array($item['parent'], $parents_arr) && ($item['parent'] > 0)) {
- $parents_arr[] = $item['parent'];
- }
- }
- $parents_str = implode(', ', $parents_arr);
+ $parents = array_column($items, 'parent');
+ } else {
+ $parents = [];
}
// We aren't going to try and figure out at the item, group, and page
// level which items you've seen and which you haven't. If you're looking
// at the top level network page just mark everything seen.
- if (!self::$groupId && !self::$forumContactId && self::$selectedTab != 'star') {
+ if (!self::$groupId && !self::$forumContactId && !self::$star && !self::$mention) {
$condition = ['unseen' => true, 'uid' => local_user()];
self::setItemsSeenByCondition($condition);
- } elseif ($parents_str) {
- $condition = ["`uid` = ? AND `unseen` AND `parent` IN (" . DBA::escape($parents_str) . ")", local_user()];
+ } elseif (!empty($parents)) {
+ $condition = ['unseen' => true, 'uid' => local_user(), 'parent' => $parents];
self::setItemsSeenByCondition($condition);
}
);
// Try to get an authentication token from the other instance.
- $curlResult = DI::httpRequest()->get($basepath . '/owa', false, ['headers' => $headers]);
+ $curlResult = DI::httpRequest()->get($basepath . '/owa', ['headers' => $headers]);
if ($curlResult->isSuccess()) {
$j = json_decode($curlResult->getBody(), true);
*
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
- public function get(string $url, bool $binary = false, array $opts = [], int &$redirects = 0)
+ public function get(string $url, array $opts = [], int &$redirects = 0)
{
$stamp1 = microtime(true);
curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
}
- if ($binary) {
- @curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
- }
-
- // don't let curl abort the entire application
- // if it throws any errors.
+ $logger = $this->logger;
$s = @curl_exec($ch);
$curl_info = @curl_getinfo($ch);
$redirects++;
$this->logger->notice('Curl redirect.', ['url' => $url, 'to' => $curlResponse->getRedirectUrl()]);
@curl_close($ch);
- return $this->get($curlResponse->getRedirectUrl(), $binary, $opts, $redirects);
+ return $this->get($curlResponse->getRedirectUrl(), $opts, $redirects);
}
@curl_close($ch);
*
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
- public function fetch(string $url, bool $binary = false, int $timeout = 0, string $accept_content = '', string $cookiejar = '', int &$redirects = 0)
+ public function fetch(string $url, int $timeout = 0, string $accept_content = '', string $cookiejar = '', int &$redirects = 0)
{
- $ret = $this->fetchFull($url, $binary, $timeout, $accept_content, $cookiejar, $redirects);
+ $ret = $this->fetchFull($url, $timeout, $accept_content, $cookiejar, $redirects);
return $ret->getBody();
}
*
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
- public function fetchFull(string $url, bool $binary = false, int $timeout = 0, string $accept_content = '', string $cookiejar = '', int &$redirects = 0)
+ public function fetchFull(string $url, int $timeout = 0, string $accept_content = '', string $cookiejar = '', int &$redirects = 0)
{
return $this->get(
$url,
- $binary,
[
'timeout' => $timeout,
'accept_content' => $accept_content,
* to preserve cookies from one request to the next.
*
* @param string $url URL to fetch
- * @param bool $binary default false
* TRUE if asked to return binary results (file download)
* @param int $timeout Timeout in seconds, default system config value or 60 seconds
* @param string $accept_content supply Accept: header with 'accept_content' as the value
*
* @return string The fetched content
*/
- public function fetch(string $url, bool $binary = false, int $timeout = 0, string $accept_content = '', string $cookiejar = '');
+ public function fetch(string $url, int $timeout = 0, string $accept_content = '', string $cookiejar = '');
/**
* Fetches the whole response of an URL.
* all the information collected during the fetch.
*
* @param string $url URL to fetch
- * @param bool $binary default false
* TRUE if asked to return binary results (file download)
* @param int $timeout Timeout in seconds, default system config value or 60 seconds
* @param string $accept_content supply Accept: header with 'accept_content' as the value
*
* @return CurlResult With all relevant information, 'body' contains the actual fetched content.
*/
- public function fetchFull(string $url, bool $binary = false, int $timeout = 0, string $accept_content = '', string $cookiejar = '');
+ public function fetchFull(string $url, int $timeout = 0, string $accept_content = '', string $cookiejar = '');
/**
* Send a GET to an URL.
*
* @param string $url URL to fetch
- * @param bool $binary default false
* TRUE if asked to return binary results (file download)
* @param array $opts (optional parameters) assoziative array with:
* 'accept_content' => supply Accept: header with 'accept_content' as the value
*
* @return CurlResult
*/
- public function get(string $url, bool $binary = false, array $opts = []);
+ public function get(string $url, array $opts = []);
/**
* Send POST request to an URL
Logger::info('Probing', ['host' => $host, 'ssl_url' => $ssl_url, 'url' => $url, 'callstack' => System::callstack(20)]);
$xrd = null;
- $curlResult = DI::httpRequest()->get($ssl_url, false, ['timeout' => $xrd_timeout, 'accept_content' => 'application/xrd+xml']);
+ $curlResult = DI::httpRequest()->get($ssl_url, ['timeout' => $xrd_timeout, 'accept_content' => 'application/xrd+xml']);
$ssl_connection_error = ($curlResult->getErrorNumber() == CURLE_COULDNT_CONNECT) || ($curlResult->getReturnCode() == 0);
if ($curlResult->isSuccess()) {
$xml = $curlResult->getBody();
}
if (!is_object($xrd) && !empty($url)) {
- $curlResult = DI::httpRequest()->get($url, false, ['timeout' => $xrd_timeout, 'accept_content' => 'application/xrd+xml']);
+ $curlResult = DI::httpRequest()->get($url, ['timeout' => $xrd_timeout, 'accept_content' => 'application/xrd+xml']);
$connection_error = ($curlResult->getErrorNumber() == CURLE_COULDNT_CONNECT) || ($curlResult->getReturnCode() == 0);
if ($curlResult->isTimeout()) {
Logger::info('Probing timeout', ['url' => $url]);
{
$xrd_timeout = DI::config()->get('system', 'xrd_timeout', 20);
- $curlResult = DI::httpRequest()->get($url, false, ['timeout' => $xrd_timeout, 'accept_content' => $type]);
+ $curlResult = DI::httpRequest()->get($url, ['timeout' => $xrd_timeout, 'accept_content' => $type]);
if ($curlResult->isTimeout()) {
self::$istimeout = true;
return [];
self::$conv_list[$conversation] = true;
- $curlResult = DI::httpRequest()->get($conversation, false, ['accept_content' => 'application/atom+xml, text/html']);
+ $curlResult = DI::httpRequest()->get($conversation, ['accept_content' => 'application/atom+xml, text/html']);
if (!$curlResult->isSuccess()) {
return;
}
$stored = false;
- $curlResult = DI::httpRequest()->get($related, false, ['accept_content' => 'application/atom+xml, text/html']);
+ $curlResult = DI::httpRequest()->get($related, ['accept_content' => 'application/atom+xml, text/html']);
if (!$curlResult->isSuccess()) {
return;
$curl_opts = $opts;
$curl_opts['header'] = $headers;
- $curlResult = DI::httpRequest()->get($request, false, $curl_opts);
+ $curlResult = DI::httpRequest()->get($request, $curl_opts);
$return_code = $curlResult->getReturnCode();
Logger::log('Fetched for user ' . $uid . ' from ' . $request . ' returned ' . $return_code, Logger::DEBUG);
return $data;
}
- $img_str = DI::httpRequest()->fetch($url, true, 4);
+ $img_str = DI::httpRequest()->fetch($url, 4);
if (!$img_str) {
return [];
}
$cookiejar = tempnam(get_temppath(), 'cookiejar-onepoll-');
- $curlResult = DI::httpRequest()->get($contact['poll'], false, ['cookiejar' => $cookiejar]);
+ $curlResult = DI::httpRequest()->get($contact['poll'], ['cookiejar' => $cookiejar]);
unlink($cookiejar);
if ($curlResult->isTimeout()) {