2015-08-31 23:59:08 +03:00
|
|
|
<?php
|
2017-02-11 18:16:56 +03:00
|
|
|
class FacebookBridge extends BridgeAbstract {
|
2015-08-31 23:59:08 +03:00
|
|
|
|
2018-07-08 18:16:00 +03:00
|
|
|
const MAINTAINER = 'teromene, logmanoriginal';
|
2019-10-28 21:01:04 +03:00
|
|
|
const NAME = 'Facebook Bridge | Main Site';
|
2017-02-11 18:16:56 +03:00
|
|
|
const URI = 'https://www.facebook.com/';
|
2021-06-12 21:15:56 +03:00
|
|
|
const CACHE_TIMEOUT = 1800; // 30min
|
2017-02-11 18:16:56 +03:00
|
|
|
const DESCRIPTION = 'Input a page title or a profile log. For a profile log,
|
|
|
|
please insert the parameter as follow : myExamplePage/132621766841117';
|
2015-11-03 17:36:19 +03:00
|
|
|
|
2018-07-08 18:16:00 +03:00
|
|
|
const PARAMETERS = array(
|
|
|
|
'User' => array(
|
|
|
|
'u' => array(
|
|
|
|
'name' => 'Username',
|
|
|
|
'required' => true
|
|
|
|
),
|
|
|
|
'media_type' => array(
|
|
|
|
'name' => 'Media type',
|
|
|
|
'type' => 'list',
|
|
|
|
'required' => false,
|
|
|
|
'values' => array(
|
|
|
|
'All' => 'all',
|
|
|
|
'Video' => 'video',
|
|
|
|
'No Video' => 'novideo'
|
|
|
|
),
|
|
|
|
'defaultValue' => 'all'
|
2017-07-25 17:04:21 +03:00
|
|
|
),
|
2018-07-08 18:16:00 +03:00
|
|
|
'skip_reviews' => array(
|
|
|
|
'name' => 'Skip reviews',
|
|
|
|
'type' => 'checkbox',
|
|
|
|
'required' => false,
|
|
|
|
'defaultValue' => false,
|
2020-08-16 09:23:48 +03:00
|
|
|
'title' => 'Feed includes reviews when unchecked'
|
2018-07-08 18:16:00 +03:00
|
|
|
)
|
2018-06-24 11:52:00 +03:00
|
|
|
),
|
2018-07-08 18:16:00 +03:00
|
|
|
'Group' => array(
|
|
|
|
'g' => array(
|
|
|
|
'name' => 'Group',
|
|
|
|
'type' => 'text',
|
|
|
|
'required' => true,
|
|
|
|
'exampleValue' => 'https://www.facebook.com/groups/743149642484225',
|
|
|
|
'title' => 'Insert group name or facebook group URL'
|
|
|
|
)
|
2018-10-15 18:33:19 +03:00
|
|
|
),
|
|
|
|
'global' => array(
|
|
|
|
'limit' => array(
|
|
|
|
'name' => 'Limit',
|
|
|
|
'type' => 'number',
|
|
|
|
'required' => false,
|
|
|
|
'title' => 'Specify the number of items to return (default: -1)',
|
|
|
|
'defaultValue' => -1
|
|
|
|
)
|
2017-02-11 18:16:56 +03:00
|
|
|
)
|
2018-07-08 18:16:00 +03:00
|
|
|
);
|
2015-08-31 23:59:08 +03:00
|
|
|
|
2017-02-11 18:16:56 +03:00
|
|
|
private $authorName = '';
|
2018-07-08 18:16:00 +03:00
|
|
|
private $groupName = '';
|
|
|
|
|
2018-10-26 19:07:34 +03:00
|
|
|
public function getIcon() {
|
|
|
|
return 'https://static.xx.fbcdn.net/rsrc.php/yo/r/iRmz9lCMBD2.ico';
|
|
|
|
}
|
|
|
|
|
2018-09-25 19:56:33 +03:00
|
|
|
public function getName(){
|
|
|
|
|
|
|
|
switch($this->queriedContext) {
|
|
|
|
|
|
|
|
case 'User':
|
|
|
|
if(!empty($this->authorName)) {
|
2019-10-28 21:01:04 +03:00
|
|
|
return isset($this->extraInfos['name']) ? $this->extraInfos['name'] : $this->authorName;
|
2018-09-25 19:56:33 +03:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'Group':
|
|
|
|
if(!empty($this->groupName)) {
|
2019-10-28 21:01:04 +03:00
|
|
|
return $this->groupName;
|
2018-09-25 19:56:33 +03:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return parent::getName();
|
|
|
|
}
|
|
|
|
|
2019-10-16 22:32:30 +03:00
|
|
|
public function detectParameters($url){
|
|
|
|
$params = array();
|
|
|
|
|
|
|
|
// By profile
|
|
|
|
$regex = '/^(https?:\/\/)?(www\.)?facebook\.com\/profile\.php\?id\=([^\/?&\n]+)?(.*)/';
|
|
|
|
if(preg_match($regex, $url, $matches) > 0) {
|
|
|
|
$params['u'] = urldecode($matches[3]);
|
|
|
|
return $params;
|
|
|
|
}
|
|
|
|
|
|
|
|
// By group
|
|
|
|
$regex = '/^(https?:\/\/)?(www\.)?facebook\.com\/groups\/([^\/?\n]+)?(.*)/';
|
|
|
|
if(preg_match($regex, $url, $matches) > 0) {
|
|
|
|
$params['g'] = urldecode($matches[3]);
|
|
|
|
return $params;
|
|
|
|
}
|
|
|
|
|
|
|
|
// By username
|
|
|
|
$regex = '/^(https?:\/\/)?(www\.)?facebook\.com\/([^\/?\n]+)/';
|
|
|
|
|
|
|
|
if(preg_match($regex, $url, $matches) > 0) {
|
|
|
|
$params['u'] = urldecode($matches[3]);
|
|
|
|
return $params;
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2018-07-08 18:16:00 +03:00
|
|
|
public function getURI() {
|
|
|
|
$uri = self::URI;
|
|
|
|
|
|
|
|
switch($this->queriedContext) {
|
|
|
|
|
|
|
|
case 'Group':
|
2018-09-25 19:56:33 +03:00
|
|
|
// Discover groups via https://www.facebook.com/groups/
|
|
|
|
// Example group: https://www.facebook.com/groups/sailors.worldwide
|
2018-07-08 18:16:00 +03:00
|
|
|
$uri .= 'groups/' . $this->sanitizeGroup(filter_var($this->getInput('g'), FILTER_SANITIZE_URL));
|
|
|
|
break;
|
|
|
|
|
2018-09-25 19:56:33 +03:00
|
|
|
case 'User':
|
|
|
|
// Example user 1: https://www.facebook.com/artetv/
|
|
|
|
// Example user 2: artetv
|
|
|
|
$user = $this->sanitizeUser($this->getInput('u'));
|
|
|
|
|
|
|
|
if(!strpos($user, '/')) {
|
2018-10-24 18:23:09 +03:00
|
|
|
$uri .= urlencode($user) . '/posts';
|
2018-09-25 19:56:33 +03:00
|
|
|
} else {
|
|
|
|
$uri .= 'pages/' . $user;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
2018-07-08 18:16:00 +03:00
|
|
|
}
|
|
|
|
|
2018-09-25 19:56:33 +03:00
|
|
|
// Request the mobile version to reduce page size (no javascript)
|
|
|
|
// More information: https://stackoverflow.com/a/11103592
|
2018-07-08 18:16:00 +03:00
|
|
|
return $uri .= '?_fb_noscript=1';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function collectData() {
|
|
|
|
|
|
|
|
switch($this->queriedContext) {
|
|
|
|
|
|
|
|
case 'Group':
|
|
|
|
$this->collectGroupData();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'User':
|
|
|
|
$this->collectUserData();
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
returnClientError('Unknown context: "' . $this->queriedContext . '"!');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-10-15 18:33:19 +03:00
|
|
|
$limit = $this->getInput('limit') ?: -1;
|
|
|
|
|
|
|
|
if($limit > 0 && count($this->items) > $limit) {
|
|
|
|
$this->items = array_slice($this->items, 0, $limit);
|
|
|
|
}
|
|
|
|
|
2018-07-08 18:16:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#region Group
|
|
|
|
|
|
|
|
private function collectGroupData() {
|
|
|
|
|
2019-09-07 19:32:06 +03:00
|
|
|
if(getEnv('HTTP_ACCEPT_LANGUAGE')) {
|
|
|
|
$header = array('Accept-Language: ' . getEnv('HTTP_ACCEPT_LANGUAGE'));
|
|
|
|
} else {
|
|
|
|
$header = array();
|
|
|
|
}
|
2018-07-08 18:16:00 +03:00
|
|
|
|
2020-10-29 06:42:49 +03:00
|
|
|
$touchURI = str_replace(
|
|
|
|
'https://www.facebook',
|
|
|
|
'https://touch.facebook',
|
|
|
|
$this->getURI()
|
|
|
|
);
|
|
|
|
|
|
|
|
$html = getSimpleHTMLDOM($touchURI, $header)
|
2018-07-08 18:16:00 +03:00
|
|
|
or returnServerError('Failed loading facebook page: ' . $this->getURI());
|
|
|
|
|
|
|
|
if(!$this->isPublicGroup($html)) {
|
|
|
|
returnClientError('This group is not public! RSS-Bridge only supports public groups!');
|
|
|
|
}
|
|
|
|
|
|
|
|
defaultLinkTo($html, substr(self::URI, 0, strlen(self::URI) - 1));
|
|
|
|
|
|
|
|
$this->groupName = $this->extractGroupName($html);
|
|
|
|
|
2020-10-29 06:42:49 +03:00
|
|
|
$posts = $html->find('div.story_body_container')
|
2018-07-08 18:16:00 +03:00
|
|
|
or returnServerError('Failed finding posts!');
|
|
|
|
|
|
|
|
foreach($posts as $post) {
|
|
|
|
|
|
|
|
$item = array();
|
|
|
|
|
2020-10-29 06:42:49 +03:00
|
|
|
$item['uri'] = $this->extractGroupPostURI($post);
|
|
|
|
$item['title'] = $this->extractGroupPostTitle($post);
|
|
|
|
$item['author'] = $this->extractGroupPostAuthor($post);
|
|
|
|
$item['content'] = $this->extractGroupPostContent($post);
|
|
|
|
$item['enclosures'] = $this->extractGroupPostEnclosures($post);
|
2018-07-08 18:16:00 +03:00
|
|
|
|
|
|
|
$this->items[] = $item;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
private function sanitizeGroup($group) {
|
|
|
|
|
|
|
|
if(filter_var(
|
|
|
|
$group,
|
2018-12-28 18:13:03 +03:00
|
|
|
FILTER_VALIDATE_URL, FILTER_FLAG_PATH_REQUIRED)) {
|
2018-07-08 18:16:00 +03:00
|
|
|
// User provided a URL
|
|
|
|
|
|
|
|
$urlparts = parse_url($group);
|
|
|
|
|
2020-10-15 12:08:03 +03:00
|
|
|
$this->validateHost($urlparts['host']);
|
2018-07-08 18:16:00 +03:00
|
|
|
|
|
|
|
return explode('/', $urlparts['path'])[2];
|
|
|
|
|
|
|
|
} elseif(strpos($group, '/') !== false) {
|
|
|
|
returnClientError('The group you provided is invalid: ' . $group);
|
|
|
|
} else {
|
|
|
|
return $group;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2020-10-15 12:08:03 +03:00
|
|
|
private function validateHost($provided_host) {
|
|
|
|
// Handle mobile links
|
|
|
|
if (strpos($provided_host, 'm.') === 0) {
|
|
|
|
$provided_host = substr($provided_host, strlen('m.'));
|
|
|
|
}
|
2020-10-29 06:42:49 +03:00
|
|
|
if (strpos($provided_host, 'touch.') === 0) {
|
|
|
|
$provided_host = substr($provided_host, strlen('touch.'));
|
|
|
|
}
|
2020-10-15 12:08:03 +03:00
|
|
|
|
|
|
|
$facebook_host = parse_url(self::URI)['host'];
|
|
|
|
|
|
|
|
if ($provided_host !== $facebook_host
|
|
|
|
&& 'www.' . $provided_host !== $facebook_host) {
|
|
|
|
returnClientError('The host you provided is invalid! Received "'
|
|
|
|
. $provided_host
|
|
|
|
. '", expected "'
|
|
|
|
. $facebook_host
|
|
|
|
. '"!');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-29 06:42:49 +03:00
|
|
|
/**
|
|
|
|
* @param $html simple_html_dom
|
|
|
|
* @return bool
|
|
|
|
*/
|
2018-07-08 18:16:00 +03:00
|
|
|
private function isPublicGroup($html) {
|
|
|
|
|
2020-10-29 06:42:49 +03:00
|
|
|
// Facebook touch just presents a login page for non-public groups
|
|
|
|
$title = $html->find('title', 0);
|
|
|
|
return $title->plaintext !== 'Log in to Facebook | Facebook';
|
2018-07-08 18:16:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
private function extractGroupName($html) {
|
|
|
|
|
2020-10-29 06:42:49 +03:00
|
|
|
$ogtitle = $html->find('._de1', 0)
|
2018-07-08 18:16:00 +03:00
|
|
|
or returnServerError('Unable to find group title!');
|
2016-08-28 15:24:17 +03:00
|
|
|
|
2020-10-29 06:42:49 +03:00
|
|
|
return html_entity_decode($ogtitle->plaintext, ENT_QUOTES);
|
2018-07-08 18:16:00 +03:00
|
|
|
}
|
|
|
|
|
2020-10-29 06:42:49 +03:00
|
|
|
private function extractGroupPostURI($post) {
|
2018-07-08 18:16:00 +03:00
|
|
|
|
|
|
|
$elements = $post->find('a')
|
|
|
|
or returnServerError('Unable to find URI!');
|
|
|
|
|
|
|
|
foreach($elements as $anchor) {
|
|
|
|
|
|
|
|
// Find the one that is a permalink
|
|
|
|
if(strpos($anchor->href, 'permalink') !== false) {
|
2020-11-06 16:43:10 +03:00
|
|
|
$arr = explode('?', $anchor->href, 2);
|
|
|
|
return $arr[0];
|
2018-07-08 18:16:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2020-10-29 06:42:49 +03:00
|
|
|
private function extractGroupPostContent($post) {
|
2018-07-08 18:16:00 +03:00
|
|
|
|
2020-10-29 06:42:49 +03:00
|
|
|
$content = $post->find('div._5rgt', 0)
|
2018-07-08 18:16:00 +03:00
|
|
|
or returnServerError('Unable to find user content!');
|
|
|
|
|
2020-10-29 06:42:49 +03:00
|
|
|
$context_text = $content->innertext;
|
|
|
|
if ($content->next_sibling() !== null) {
|
|
|
|
$context_text .= $content->next_sibling()->innertext;
|
|
|
|
}
|
|
|
|
return $context_text;
|
2018-07-08 18:16:00 +03:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2020-10-29 06:42:49 +03:00
|
|
|
private function extractGroupPostAuthor($post) {
|
2018-07-08 18:16:00 +03:00
|
|
|
|
2020-10-29 06:42:49 +03:00
|
|
|
$element = $post->find('h3 a', 0)
|
2018-07-08 18:16:00 +03:00
|
|
|
or returnServerError('Unable to find author information!');
|
|
|
|
|
2020-10-29 06:42:49 +03:00
|
|
|
return $element->plaintext;
|
2018-07-08 18:16:00 +03:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2020-10-29 06:42:49 +03:00
|
|
|
private function extractGroupPostEnclosures($post) {
|
2018-07-08 18:16:00 +03:00
|
|
|
|
2020-10-29 06:42:49 +03:00
|
|
|
$elements = $post->find('span._6qdm');
|
|
|
|
if ($post->find('div._5rgt', 0)->next_sibling() !== null) {
|
|
|
|
array_push($elements, ...$post->find('div._5rgt', 0)->next_sibling()->find('i.img'));
|
|
|
|
}
|
2018-07-08 18:16:00 +03:00
|
|
|
|
|
|
|
$enclosures = array();
|
|
|
|
|
2020-10-29 06:42:49 +03:00
|
|
|
$background_img_regex = '/background-image: ?url\\((.+?)\\);/';
|
|
|
|
|
2018-07-08 18:16:00 +03:00
|
|
|
foreach($elements as $enclosure) {
|
2020-10-29 06:42:49 +03:00
|
|
|
if(preg_match($background_img_regex, $enclosure, $matches) > 0) {
|
|
|
|
$bg_img_value = trim(html_entity_decode($matches[1], ENT_QUOTES), "'\"");
|
|
|
|
$bg_img_url = urldecode(preg_replace('/\\\([0-9a-z]{2}) /', '%$1', $bg_img_value));
|
|
|
|
$enclosures[] = urldecode($bg_img_url);
|
|
|
|
}
|
2018-07-08 18:16:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return empty($enclosures) ? null : $enclosures;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2020-10-29 06:42:49 +03:00
|
|
|
private function extractGroupPostTitle($post) {
|
2018-07-08 18:16:00 +03:00
|
|
|
|
2020-10-29 06:42:49 +03:00
|
|
|
$element = $post->find('h3', 0)
|
2018-07-08 18:16:00 +03:00
|
|
|
or returnServerError('Unable to find title!');
|
|
|
|
|
|
|
|
if(strpos($element->plaintext, 'shared') === false) {
|
|
|
|
|
2020-10-29 06:42:49 +03:00
|
|
|
$content = strip_tags($this->extractGroupPostContent($post));
|
2018-07-08 18:16:00 +03:00
|
|
|
|
2020-10-29 06:42:49 +03:00
|
|
|
return $this->extractGroupPostAuthor($post)
|
2018-07-08 18:16:00 +03:00
|
|
|
. ' posted: '
|
|
|
|
. substr(
|
|
|
|
$content,
|
|
|
|
0,
|
|
|
|
strpos(wordwrap($content, 64), "\n")
|
|
|
|
)
|
|
|
|
. '...';
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return $element->plaintext;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-09-25 19:56:33 +03:00
|
|
|
#endregion (Group)
|
2018-07-08 18:16:00 +03:00
|
|
|
|
2018-09-25 19:56:33 +03:00
|
|
|
#region User
|
2015-08-31 23:59:08 +03:00
|
|
|
|
2018-09-25 19:56:33 +03:00
|
|
|
/**
|
|
|
|
* Checks if $user is a valid username or URI and returns the username
|
|
|
|
*/
|
|
|
|
private function sanitizeUser($user) {
|
|
|
|
if (filter_var($user, FILTER_VALIDATE_URL)) {
|
|
|
|
|
|
|
|
$urlparts = parse_url($user);
|
|
|
|
|
2020-10-15 12:08:03 +03:00
|
|
|
$this->validateHost($urlparts['host']);
|
2018-09-25 19:56:33 +03:00
|
|
|
|
|
|
|
if(!array_key_exists('path', $urlparts)
|
|
|
|
|| $urlparts['path'] === '/') {
|
|
|
|
returnClientError('The URL you provided doesn\'t contain the user name!');
|
|
|
|
}
|
|
|
|
|
|
|
|
return explode('/', $urlparts['path'])[1];
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
// First character cannot be a forward slash
|
|
|
|
if(strpos($user, '/') === 0) {
|
|
|
|
returnClientError('Remove leading slash "/" from the username!');
|
|
|
|
}
|
|
|
|
|
|
|
|
return $user;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Bypass external link redirection
|
|
|
|
*/
|
|
|
|
private function unescape_fb_link($content){
|
|
|
|
return preg_replace_callback('/ href=\"([^"]+)\"/i', function($matches){
|
2017-07-29 20:28:00 +03:00
|
|
|
if(is_array($matches) && count($matches) > 1) {
|
2018-09-25 19:56:33 +03:00
|
|
|
|
2015-10-23 13:08:18 +03:00
|
|
|
$link = $matches[1];
|
2018-09-25 19:56:33 +03:00
|
|
|
|
2017-02-11 18:16:56 +03:00
|
|
|
if(strpos($link, 'facebook.com/l.php?u=') !== false)
|
|
|
|
$link = urldecode(extractFromDelimiters($link, 'facebook.com/l.php?u=', '&'));
|
2018-09-25 19:56:33 +03:00
|
|
|
|
2017-02-11 18:16:56 +03:00
|
|
|
return ' href="' . $link . '"';
|
2018-09-25 19:56:33 +03:00
|
|
|
|
2015-10-23 13:08:18 +03:00
|
|
|
}
|
2018-09-25 19:56:33 +03:00
|
|
|
}, $content);
|
|
|
|
}
|
|
|
|
|
2018-11-06 18:58:58 +03:00
|
|
|
/**
|
|
|
|
* Remove Facebook's tracking code
|
|
|
|
*/
|
|
|
|
private function remove_tracking_codes($content){
|
|
|
|
return preg_replace_callback('/ href=\"([^"]+)\"/i', function($matches){
|
|
|
|
if(is_array($matches) && count($matches) > 1) {
|
|
|
|
|
|
|
|
$link = $matches[1];
|
|
|
|
|
|
|
|
if(strpos($link, 'facebook.com') !== false) {
|
|
|
|
if(strpos($link, '?') !== false) {
|
|
|
|
$link = substr($link, 0, strpos($link, '?'));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ' href="' . $link . '"';
|
|
|
|
|
|
|
|
}
|
|
|
|
}, $content);
|
|
|
|
}
|
|
|
|
|
2018-09-25 19:56:33 +03:00
|
|
|
/**
|
|
|
|
* Convert textual representation of emoticons back to ASCII emoticons.
|
|
|
|
* i.e. "<i><u>smile emoticon</u></i>" => ":)"
|
|
|
|
*/
|
|
|
|
private function unescape_fb_emote($content){
|
|
|
|
return preg_replace_callback('/<i><u>([^ <>]+) ([^<>]+)<\/u><\/i>/i', function($matches){
|
|
|
|
static $facebook_emoticons = array(
|
|
|
|
'smile' => ':)',
|
|
|
|
'frown' => ':(',
|
|
|
|
'tongue' => ':P',
|
|
|
|
'grin' => ':D',
|
|
|
|
'gasp' => ':O',
|
|
|
|
'wink' => ';)',
|
|
|
|
'pacman' => ':<',
|
|
|
|
'grumpy' => '>_<',
|
|
|
|
'unsure' => ':/',
|
|
|
|
'cry' => ':\'(',
|
|
|
|
'kiki' => '^_^',
|
|
|
|
'glasses' => '8-)',
|
|
|
|
'sunglasses' => 'B-)',
|
|
|
|
'heart' => '<3',
|
|
|
|
'devil' => ']:D',
|
|
|
|
'angel' => '0:)',
|
|
|
|
'squint' => '-_-',
|
|
|
|
'confused' => 'o_O',
|
|
|
|
'upset' => 'xD',
|
|
|
|
'colonthree' => ':3',
|
|
|
|
'like' => '👍');
|
|
|
|
|
|
|
|
$len = count($matches);
|
|
|
|
|
|
|
|
if ($len > 1)
|
|
|
|
for ($i = 1; $i < $len; $i++)
|
|
|
|
foreach ($facebook_emoticons as $name => $emote)
|
|
|
|
if ($matches[$i] === $name)
|
|
|
|
return $emote;
|
|
|
|
|
|
|
|
return $matches[0];
|
|
|
|
}, $content);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the captcha message for the given captcha
|
|
|
|
*/
|
|
|
|
private function returnCaptchaMessage($captcha) {
|
|
|
|
// Save form for submitting after getting captcha response
|
|
|
|
if (session_status() == PHP_SESSION_NONE) {
|
|
|
|
session_start();
|
|
|
|
}
|
|
|
|
|
|
|
|
$captcha_fields = array();
|
|
|
|
|
|
|
|
foreach ($captcha->find('input, button') as $input) {
|
|
|
|
$captcha_fields[$input->name] = $input->value;
|
|
|
|
}
|
|
|
|
|
|
|
|
$_SESSION['captcha_fields'] = $captcha_fields;
|
|
|
|
$_SESSION['captcha_action'] = $captcha->find('form', 0)->action;
|
|
|
|
|
|
|
|
// Show captcha filling form to the viewer, proxying the captcha image
|
|
|
|
$img = base64_encode(getContents($captcha->find('img', 0)->src));
|
|
|
|
|
2018-11-05 21:28:47 +03:00
|
|
|
header('Content-Type: text/html', true, 500);
|
2018-09-25 19:56:33 +03:00
|
|
|
|
|
|
|
$message = <<<EOD
|
|
|
|
<form method="post" action="?{$_SERVER['QUERY_STRING']}">
|
|
|
|
<h2>Facebook captcha challenge</h2>
|
|
|
|
<p>Unfortunately, rss-bridge cannot fetch the requested page.<br />
|
|
|
|
Facebook wants rss-bridge to resolve the following captcha:</p>
|
|
|
|
<p><img src="data:image/png;base64,{$img}" /></p>
|
|
|
|
<p><b>Response:</b> <input name="captcha_response" placeholder="please fill in" />
|
|
|
|
<input type="submit" value="Submit!" /></p>
|
|
|
|
</form>
|
|
|
|
EOD;
|
|
|
|
|
|
|
|
die($message);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Checks if a capture response was received and tries to load the contents
|
|
|
|
* @return mixed null if no capture response was received, simplhtmldom document otherwise
|
|
|
|
*/
|
|
|
|
private function handleCaptchaResponse() {
|
2017-07-29 20:28:00 +03:00
|
|
|
if (isset($_POST['captcha_response'])) {
|
2016-01-23 23:53:23 +03:00
|
|
|
if (session_status() == PHP_SESSION_NONE)
|
|
|
|
session_start();
|
2018-09-25 19:56:33 +03:00
|
|
|
|
2017-07-29 20:28:00 +03:00
|
|
|
if (isset($_SESSION['captcha_fields'], $_SESSION['captcha_action'])) {
|
2016-01-23 23:53:23 +03:00
|
|
|
$captcha_action = $_SESSION['captcha_action'];
|
|
|
|
$captcha_fields = $_SESSION['captcha_fields'];
|
2018-06-30 00:55:33 +03:00
|
|
|
$captcha_fields['captcha_response'] = preg_replace('/[^a-zA-Z0-9]+/', '', $_POST['captcha_response']);
|
2018-03-25 15:01:35 +03:00
|
|
|
|
2018-09-25 19:56:33 +03:00
|
|
|
$header = array(
|
|
|
|
'Content-type: application/x-www-form-urlencoded',
|
|
|
|
'Referer: ' . $captcha_action,
|
|
|
|
'Cookie: noscript=1'
|
|
|
|
);
|
|
|
|
|
2018-03-25 15:01:35 +03:00
|
|
|
$opts = array(
|
|
|
|
CURLOPT_POST => 1,
|
|
|
|
CURLOPT_POSTFIELDS => http_build_query($captcha_fields)
|
2016-01-23 23:53:23 +03:00
|
|
|
);
|
2018-03-25 15:01:35 +03:00
|
|
|
|
2018-09-25 19:56:33 +03:00
|
|
|
$html = getSimpleHTMLDOM($captcha_action, $header, $opts)
|
|
|
|
or returnServerError('Failed to submit captcha response back to Facebook');
|
2017-02-11 18:16:56 +03:00
|
|
|
|
2018-09-25 19:56:33 +03:00
|
|
|
return $html;
|
2016-01-23 23:53:23 +03:00
|
|
|
}
|
2018-09-25 19:56:33 +03:00
|
|
|
|
2016-01-23 23:53:23 +03:00
|
|
|
unset($_SESSION['captcha_fields']);
|
|
|
|
unset($_SESSION['captcha_action']);
|
|
|
|
}
|
|
|
|
|
2018-09-25 19:56:33 +03:00
|
|
|
return null;
|
|
|
|
}
|
2018-06-24 12:03:43 +03:00
|
|
|
|
2018-09-25 19:56:33 +03:00
|
|
|
private function collectUserData(){
|
2018-06-24 12:03:43 +03:00
|
|
|
|
2018-09-25 19:56:33 +03:00
|
|
|
$html = $this->handleCaptchaResponse();
|
2018-03-23 23:23:27 +03:00
|
|
|
|
2018-09-25 19:56:33 +03:00
|
|
|
// Retrieve page contents
|
|
|
|
if(is_null($html)) {
|
2018-06-24 12:03:43 +03:00
|
|
|
|
2019-09-07 19:32:06 +03:00
|
|
|
if(getEnv('HTTP_ACCEPT_LANGUAGE')) {
|
|
|
|
$header = array('Accept-Language: ' . getEnv('HTTP_ACCEPT_LANGUAGE'));
|
|
|
|
} else {
|
|
|
|
$header = array();
|
|
|
|
}
|
2018-06-24 12:03:43 +03:00
|
|
|
|
2018-09-25 19:56:33 +03:00
|
|
|
$html = getSimpleHTMLDOM($this->getURI(), $header)
|
|
|
|
or returnServerError('No results for this query.');
|
2018-06-24 12:03:43 +03:00
|
|
|
|
2015-09-05 15:31:57 +03:00
|
|
|
}
|
2015-09-02 14:49:36 +03:00
|
|
|
|
2018-09-25 19:56:33 +03:00
|
|
|
// Handle captcha form?
|
2016-01-23 23:53:23 +03:00
|
|
|
$captcha = $html->find('div.captcha_interstitial', 0);
|
2018-09-25 19:56:33 +03:00
|
|
|
|
2017-07-29 20:28:00 +03:00
|
|
|
if (!is_null($captcha)) {
|
2018-09-25 19:56:33 +03:00
|
|
|
$this->returnCaptchaMessage($captcha);
|
2016-01-23 23:53:23 +03:00
|
|
|
}
|
|
|
|
|
2018-09-25 19:56:33 +03:00
|
|
|
// No captcha? We can carry on retrieving page contents :)
|
2020-10-29 06:42:49 +03:00
|
|
|
// First, we check whether the page is public or not
|
2018-05-05 15:49:49 +03:00
|
|
|
$loginForm = $html->find('._585r', 0);
|
2018-09-25 19:56:33 +03:00
|
|
|
|
2018-05-05 15:49:49 +03:00
|
|
|
if($loginForm != null) {
|
|
|
|
returnServerError('You must be logged in to view this page. This is not supported by RSS-Bridge.');
|
|
|
|
}
|
|
|
|
|
2017-02-11 18:16:56 +03:00
|
|
|
$element = $html
|
|
|
|
->find('#pagelet_timeline_main_column')[0]
|
|
|
|
->children(0)
|
|
|
|
->children(0)
|
|
|
|
->next_sibling()
|
|
|
|
->children(0);
|
2015-08-31 23:59:08 +03:00
|
|
|
|
2017-07-29 20:28:00 +03:00
|
|
|
if(isset($element)) {
|
2015-08-31 23:59:08 +03:00
|
|
|
|
2018-11-08 21:04:58 +03:00
|
|
|
$author = str_replace(' - Posts | Facebook', '', $html->find('title#pageTitle', 0)->innertext);
|
2018-09-25 19:56:33 +03:00
|
|
|
|
|
|
|
$profilePic = $html->find('meta[property="og:image"]', 0)->content;
|
2017-02-11 18:16:56 +03:00
|
|
|
|
2016-08-28 15:24:17 +03:00
|
|
|
$this->authorName = $author;
|
2015-08-31 23:59:08 +03:00
|
|
|
|
2017-07-29 20:28:00 +03:00
|
|
|
foreach($element->children() as $cell) {
|
2017-04-10 14:04:38 +03:00
|
|
|
// Manage summary posts
|
2017-07-29 20:28:00 +03:00
|
|
|
if(strpos($cell->class, '_3xaf') !== false) {
|
2017-04-10 14:04:38 +03:00
|
|
|
$posts = $cell->children();
|
|
|
|
} else {
|
|
|
|
$posts = array($cell);
|
|
|
|
}
|
2015-09-05 15:31:57 +03:00
|
|
|
|
2018-06-24 11:52:00 +03:00
|
|
|
// Optionally skip reviews
|
|
|
|
if($this->getInput('skip_reviews')
|
|
|
|
&& !is_null($cell->find('#review_composer_container', 0))) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2017-07-29 20:28:00 +03:00
|
|
|
foreach($posts as $post) {
|
2017-07-25 17:04:21 +03:00
|
|
|
// Check media type
|
2017-07-29 20:28:00 +03:00
|
|
|
switch($this->getInput('media_type')) {
|
2017-07-25 17:04:21 +03:00
|
|
|
case 'all': break;
|
|
|
|
case 'video':
|
|
|
|
if(empty($post->find('[aria-label=Video]'))) continue 2;
|
|
|
|
break;
|
|
|
|
case 'novideo':
|
|
|
|
if(!empty($post->find('[aria-label=Video]'))) continue 2;
|
|
|
|
break;
|
|
|
|
default: break;
|
|
|
|
}
|
2017-07-25 16:39:26 +03:00
|
|
|
|
2017-04-10 14:04:38 +03:00
|
|
|
$item = array();
|
|
|
|
|
2017-07-29 20:28:00 +03:00
|
|
|
if(count($post->find('abbr')) > 0) {
|
2017-04-10 14:04:38 +03:00
|
|
|
|
2018-10-20 16:38:44 +03:00
|
|
|
$content = $post->find('.userContentWrapper', 0);
|
2017-04-10 14:04:38 +03:00
|
|
|
|
2018-11-08 20:44:09 +03:00
|
|
|
// This array specifies filters applied to all posts in order of appearance
|
|
|
|
$content_filters = array(
|
|
|
|
'._5mly', // Remove embedded videos (the preview image remains)
|
|
|
|
'._2ezg', // Remove "Views ..."
|
|
|
|
'.hidden_elem', // Remove hidden elements (they are hidden anyway)
|
2019-07-26 11:56:34 +03:00
|
|
|
'.timestampContent', // Remove relative timestamp
|
|
|
|
'._6spk', // Remove redundant separator
|
2018-11-08 20:44:09 +03:00
|
|
|
);
|
|
|
|
|
|
|
|
foreach($content_filters as $filter) {
|
|
|
|
foreach($content->find($filter) as $subject) {
|
2019-06-02 14:03:26 +03:00
|
|
|
$subject->outertext = '';
|
2018-11-08 20:44:09 +03:00
|
|
|
}
|
2018-11-08 20:06:51 +03:00
|
|
|
}
|
|
|
|
|
2018-11-08 21:23:52 +03:00
|
|
|
// Change origin tag for embedded media from div to paragraph
|
|
|
|
foreach($content->find('._59tj') as $subject) {
|
|
|
|
$subject->outertext = '<p>' . $subject->innertext . '</p>';
|
|
|
|
}
|
|
|
|
|
2018-11-08 20:06:51 +03:00
|
|
|
// Change title tag for embedded media from anchor to paragraph
|
2018-11-08 20:44:09 +03:00
|
|
|
foreach($content->find('._3n1k a') as $anchor) {
|
2018-11-08 21:23:52 +03:00
|
|
|
$anchor->outertext = '<p>' . $anchor->innertext . '</p>';
|
2018-11-08 20:21:42 +03:00
|
|
|
}
|
|
|
|
|
2017-04-10 14:04:38 +03:00
|
|
|
$content = preg_replace(
|
|
|
|
'/(?i)><div class=\"_3dp([^>]+)>(.+?)div\ class=\"[^u]+userContent\"/i',
|
|
|
|
'',
|
|
|
|
$content);
|
|
|
|
|
|
|
|
$content = preg_replace(
|
|
|
|
'/(?i)><div class=\"_4l5([^>]+)>(.+?)<\/div>/i',
|
|
|
|
'',
|
|
|
|
$content);
|
|
|
|
|
2018-09-25 19:56:33 +03:00
|
|
|
// Remove "SpSonsSoriSsés"
|
Catching up | [Main] Debug mode, parse utils, MIME | [Bridges] Add/Improve 20 bridges (#802)
* Debug mode improvements
- Improve debug warning message
- Restore error reporting in debug mode
- Fix 'notice' messages for unset fields
* Add parsing utility functions
html.php
- extractFromDelimiters
- stripWithDelimiters
- stripRecursiveHTMLSection
- markdownToHtml (partial)
bridges
- remove now-duplicate functions
- call functions from html.php instead
* [Anidex] New bridge
Anime torrent tracker
* [Anime-Ultime] Restore thumbnail
* [CNET] Recreate bridge
Full rewrite as the previous one was broken
* [Dilbert] Minor URI fix
Use new self::URI property
* [EstCeQuonMetEnProd] Fix content extraction
Bridge was broken
* [Facebook] Fix "SpSonsSoriSsés" label
... which was taking space in item title
* [Futura-Sciences] Use HTTPS, More cleanup
Use HTTPS as FS now offer HTTPS
Clean additional useless HTML elements
* [GBATemp] Multiple fixes
- Fix categories: missing "break" statements
- Restore thumbnail as enclosure
- Fix date extraction
- Fix user blog post extraction
- Use getSimpleHTMLDOMCached
* [JapanExpo] Fix bridge, HTTPS, thumbnails
- Fix getSimpleHTMLDOMCached call
- Upgrade to HTTPS as JE now offers HTTPS
- Restore thumbnails as enclosures
* [LeMondeInformatique] Fix bridge, HTTPS
- Upgrade to HTTPS as LMI now offers HTTPS
- Restore thumbnails using small images
- Fix content extraction
- Fix text encoding issue
* [Nextgov] Fix content extraction
- Restore thumbnail and use small image
- Field extraction fixes
* [NextInpact] Add categories and filtering by type
- Offer all RSS feeds
- Allow filtering by article type
- Implement extraction for brief articles
- Remove article limit, many brief articles are publied all at once
* [NyaaTorrents] New bridge
Anime torrent tracker
* [Releases3DS] Cache content, restore thumbnail
- Use getSimpleHTMLDOMCached
- Restore thumbnail as enclosure
* [TheHackerNews] Fix bridge
- Fix content extraction including article body
- Restore thumbnail as enclosure
* [WeLiveSecurity] HTTPS, Fix content extraction
- Upgrade to HTTPS as WLS now offers HTTPS
- Fix content extraction including article body
* [WordPress] Reduce timeout, more content selectors
- Reduce timeout to use default one (1h)
- Add new content selector (articleBody)
- Find thumbnail and set as enclosure
- Fix <script> cleanup
* [YGGTorrent] Increase limit, use cache
- Increase item limit as uploads are very frequent
- Use getSimpleHTMLDOMCached
* [ZDNet] Rewrite with FeedExpander
- Upgrade to HTTPS as ZD now offers HTTPS
- Use FeedExpander for secondary fields
- Fix content extraction for article body
* [Main] Handle MIME type for enclosures
Many feed readers will ignore enclosures (e.g. thumbnails) with no MIME type. This commit adds automatic MIME type detection based on file extension (which may be inaccurate but is the only way without fetching the content).
One can force enclosure type using #.ext anchor (hacky, needs improving)
* [FeedExpander] Improve field extraction
- Add support for passing enclosures
- Improve author and uri extraction
- Fix 'notice' PHP error messages
* [Pull] Coding style fixes for #802
* [Pull] Implementing changes for #802
- Fix coding style issues with str append
- Remove useless CACHE_TIMEOUT
- Use count() instead of $limit
- Use defaultLinkTo() + handle strings
- Use http_build_query()
- Fix missing </em>
- Remove error_reporting(0)
- warning CSS (@LogMANOriginal)
- Fix typo in FeedExpander comment
* [Main] More documentation for markdownToHtml
See #802 for more details
2018-09-09 22:20:13 +03:00
|
|
|
$content = preg_replace(
|
|
|
|
'/(?iU)<a [^>]+ href="#" role="link" [^>}]+>.+<\/a>/iU',
|
|
|
|
'',
|
|
|
|
$content);
|
|
|
|
|
2018-09-25 19:56:33 +03:00
|
|
|
// Remove html nodes, keep only img, links, basic formatting
|
2017-04-10 14:04:38 +03:00
|
|
|
$content = strip_tags($content, '<a><img><i><u><br><p>');
|
|
|
|
|
2018-09-25 19:56:33 +03:00
|
|
|
$content = $this->unescape_fb_link($content);
|
2017-04-10 14:04:38 +03:00
|
|
|
|
2018-09-25 19:56:33 +03:00
|
|
|
// Clean useless html tag properties and fix link closing tags
|
2017-04-10 14:04:38 +03:00
|
|
|
foreach (array(
|
|
|
|
'onmouseover',
|
|
|
|
'onclick',
|
|
|
|
'target',
|
|
|
|
'ajaxify',
|
|
|
|
'tabindex',
|
|
|
|
'class',
|
|
|
|
'style',
|
|
|
|
'data-[^=]*',
|
|
|
|
'aria-[^=]*',
|
|
|
|
'role',
|
|
|
|
'rel',
|
2018-09-25 19:56:33 +03:00
|
|
|
'id') as $property_name) {
|
|
|
|
$content = preg_replace('/ ' . $property_name . '=\"[^"]*\"/i', '', $content);
|
|
|
|
}
|
|
|
|
|
2017-04-10 14:04:38 +03:00
|
|
|
$content = preg_replace('/<\/a [^>]+>/i', '</a>', $content);
|
|
|
|
|
2018-09-25 19:56:33 +03:00
|
|
|
$this->unescape_fb_emote($content);
|
2017-04-10 14:04:38 +03:00
|
|
|
|
2018-10-16 20:16:51 +03:00
|
|
|
// Restore links in the post before further parsing
|
|
|
|
$post = defaultLinkTo($post, self::URI);
|
|
|
|
|
|
|
|
// Restore links in the content before adding to the item
|
|
|
|
$content = defaultLinkTo($content, self::URI);
|
|
|
|
|
2018-11-06 18:58:58 +03:00
|
|
|
$content = $this->remove_tracking_codes($content);
|
|
|
|
|
2018-09-25 19:56:33 +03:00
|
|
|
// Retrieve date of the post
|
2018-06-30 00:55:33 +03:00
|
|
|
$date = $post->find('abbr')[0];
|
2018-09-25 19:56:33 +03:00
|
|
|
|
2017-07-29 20:28:00 +03:00
|
|
|
if(isset($date) && $date->hasAttribute('data-utime')) {
|
2017-04-10 14:04:38 +03:00
|
|
|
$date = $date->getAttribute('data-utime');
|
|
|
|
} else {
|
|
|
|
$date = 0;
|
|
|
|
}
|
|
|
|
|
2018-11-16 17:33:54 +03:00
|
|
|
// Build title from content
|
|
|
|
$title = strip_tags($post->find('.userContent', 0)->innertext);
|
2017-04-10 14:04:38 +03:00
|
|
|
if(strlen($title) > 64)
|
|
|
|
$title = substr($title, 0, strpos(wordwrap($title, 64), "\n")) . '...';
|
|
|
|
|
2018-09-09 18:31:15 +03:00
|
|
|
$uri = $post->find('abbr')[0]->parent()->getAttribute('href');
|
|
|
|
|
2019-12-01 15:24:11 +03:00
|
|
|
// Extract fbid and patch link
|
|
|
|
if (strpos($uri, '?') !== false) {
|
|
|
|
$query = substr($uri, strpos($uri, '?') + 1);
|
|
|
|
parse_str($query, $query_params);
|
|
|
|
if (isset($query_params['story_fbid'])) {
|
|
|
|
$uri = self::URI . $query_params['story_fbid'];
|
|
|
|
} else {
|
|
|
|
$uri = substr($uri, 0, strpos($uri, '?'));
|
|
|
|
}
|
2018-09-09 18:31:15 +03:00
|
|
|
}
|
2017-08-04 22:12:43 +03:00
|
|
|
|
2017-04-10 14:04:38 +03:00
|
|
|
//Build and add final item
|
2018-11-16 17:25:58 +03:00
|
|
|
$item['uri'] = htmlspecialchars_decode($uri, ENT_QUOTES);
|
|
|
|
$item['content'] = htmlspecialchars_decode($content, ENT_QUOTES);
|
|
|
|
$item['title'] = htmlspecialchars_decode($title, ENT_QUOTES);
|
|
|
|
$item['author'] = htmlspecialchars_decode($author, ENT_QUOTES);
|
2017-04-10 14:04:38 +03:00
|
|
|
$item['timestamp'] = $date;
|
2018-09-25 19:56:33 +03:00
|
|
|
|
|
|
|
if(strpos($item['content'], '<img') === false) {
|
Catching up | [Main] Debug mode, parse utils, MIME | [Bridges] Add/Improve 20 bridges (#802)
* Debug mode improvements
- Improve debug warning message
- Restore error reporting in debug mode
- Fix 'notice' messages for unset fields
* Add parsing utility functions
html.php
- extractFromDelimiters
- stripWithDelimiters
- stripRecursiveHTMLSection
- markdownToHtml (partial)
bridges
- remove now-duplicate functions
- call functions from html.php instead
* [Anidex] New bridge
Anime torrent tracker
* [Anime-Ultime] Restore thumbnail
* [CNET] Recreate bridge
Full rewrite as the previous one was broken
* [Dilbert] Minor URI fix
Use new self::URI property
* [EstCeQuonMetEnProd] Fix content extraction
Bridge was broken
* [Facebook] Fix "SpSonsSoriSsés" label
... which was taking space in item title
* [Futura-Sciences] Use HTTPS, More cleanup
Use HTTPS as FS now offer HTTPS
Clean additional useless HTML elements
* [GBATemp] Multiple fixes
- Fix categories: missing "break" statements
- Restore thumbnail as enclosure
- Fix date extraction
- Fix user blog post extraction
- Use getSimpleHTMLDOMCached
* [JapanExpo] Fix bridge, HTTPS, thumbnails
- Fix getSimpleHTMLDOMCached call
- Upgrade to HTTPS as JE now offers HTTPS
- Restore thumbnails as enclosures
* [LeMondeInformatique] Fix bridge, HTTPS
- Upgrade to HTTPS as LMI now offers HTTPS
- Restore thumbnails using small images
- Fix content extraction
- Fix text encoding issue
* [Nextgov] Fix content extraction
- Restore thumbnail and use small image
- Field extraction fixes
* [NextInpact] Add categories and filtering by type
- Offer all RSS feeds
- Allow filtering by article type
- Implement extraction for brief articles
- Remove article limit, many brief articles are publied all at once
* [NyaaTorrents] New bridge
Anime torrent tracker
* [Releases3DS] Cache content, restore thumbnail
- Use getSimpleHTMLDOMCached
- Restore thumbnail as enclosure
* [TheHackerNews] Fix bridge
- Fix content extraction including article body
- Restore thumbnail as enclosure
* [WeLiveSecurity] HTTPS, Fix content extraction
- Upgrade to HTTPS as WLS now offers HTTPS
- Fix content extraction including article body
* [WordPress] Reduce timeout, more content selectors
- Reduce timeout to use default one (1h)
- Add new content selector (articleBody)
- Find thumbnail and set as enclosure
- Fix <script> cleanup
* [YGGTorrent] Increase limit, use cache
- Increase item limit as uploads are very frequent
- Use getSimpleHTMLDOMCached
* [ZDNet] Rewrite with FeedExpander
- Upgrade to HTTPS as ZD now offers HTTPS
- Use FeedExpander for secondary fields
- Fix content extraction for article body
* [Main] Handle MIME type for enclosures
Many feed readers will ignore enclosures (e.g. thumbnails) with no MIME type. This commit adds automatic MIME type detection based on file extension (which may be inaccurate but is the only way without fetching the content).
One can force enclosure type using #.ext anchor (hacky, needs improving)
* [FeedExpander] Improve field extraction
- Add support for passing enclosures
- Improve author and uri extraction
- Fix 'notice' PHP error messages
* [Pull] Coding style fixes for #802
* [Pull] Implementing changes for #802
- Fix coding style issues with str append
- Remove useless CACHE_TIMEOUT
- Use count() instead of $limit
- Use defaultLinkTo() + handle strings
- Use http_build_query()
- Fix missing </em>
- Remove error_reporting(0)
- warning CSS (@LogMANOriginal)
- Fix typo in FeedExpander comment
* [Main] More documentation for markdownToHtml
See #802 for more details
2018-09-09 22:20:13 +03:00
|
|
|
$item['enclosures'] = array($profilePic);
|
2018-09-25 19:56:33 +03:00
|
|
|
}
|
Catching up | [Main] Debug mode, parse utils, MIME | [Bridges] Add/Improve 20 bridges (#802)
* Debug mode improvements
- Improve debug warning message
- Restore error reporting in debug mode
- Fix 'notice' messages for unset fields
* Add parsing utility functions
html.php
- extractFromDelimiters
- stripWithDelimiters
- stripRecursiveHTMLSection
- markdownToHtml (partial)
bridges
- remove now-duplicate functions
- call functions from html.php instead
* [Anidex] New bridge
Anime torrent tracker
* [Anime-Ultime] Restore thumbnail
* [CNET] Recreate bridge
Full rewrite as the previous one was broken
* [Dilbert] Minor URI fix
Use new self::URI property
* [EstCeQuonMetEnProd] Fix content extraction
Bridge was broken
* [Facebook] Fix "SpSonsSoriSsés" label
... which was taking space in item title
* [Futura-Sciences] Use HTTPS, More cleanup
Use HTTPS as FS now offer HTTPS
Clean additional useless HTML elements
* [GBATemp] Multiple fixes
- Fix categories: missing "break" statements
- Restore thumbnail as enclosure
- Fix date extraction
- Fix user blog post extraction
- Use getSimpleHTMLDOMCached
* [JapanExpo] Fix bridge, HTTPS, thumbnails
- Fix getSimpleHTMLDOMCached call
- Upgrade to HTTPS as JE now offers HTTPS
- Restore thumbnails as enclosures
* [LeMondeInformatique] Fix bridge, HTTPS
- Upgrade to HTTPS as LMI now offers HTTPS
- Restore thumbnails using small images
- Fix content extraction
- Fix text encoding issue
* [Nextgov] Fix content extraction
- Restore thumbnail and use small image
- Field extraction fixes
* [NextInpact] Add categories and filtering by type
- Offer all RSS feeds
- Allow filtering by article type
- Implement extraction for brief articles
- Remove article limit, many brief articles are publied all at once
* [NyaaTorrents] New bridge
Anime torrent tracker
* [Releases3DS] Cache content, restore thumbnail
- Use getSimpleHTMLDOMCached
- Restore thumbnail as enclosure
* [TheHackerNews] Fix bridge
- Fix content extraction including article body
- Restore thumbnail as enclosure
* [WeLiveSecurity] HTTPS, Fix content extraction
- Upgrade to HTTPS as WLS now offers HTTPS
- Fix content extraction including article body
* [WordPress] Reduce timeout, more content selectors
- Reduce timeout to use default one (1h)
- Add new content selector (articleBody)
- Find thumbnail and set as enclosure
- Fix <script> cleanup
* [YGGTorrent] Increase limit, use cache
- Increase item limit as uploads are very frequent
- Use getSimpleHTMLDOMCached
* [ZDNet] Rewrite with FeedExpander
- Upgrade to HTTPS as ZD now offers HTTPS
- Use FeedExpander for secondary fields
- Fix content extraction for article body
* [Main] Handle MIME type for enclosures
Many feed readers will ignore enclosures (e.g. thumbnails) with no MIME type. This commit adds automatic MIME type detection based on file extension (which may be inaccurate but is the only way without fetching the content).
One can force enclosure type using #.ext anchor (hacky, needs improving)
* [FeedExpander] Improve field extraction
- Add support for passing enclosures
- Improve author and uri extraction
- Fix 'notice' PHP error messages
* [Pull] Coding style fixes for #802
* [Pull] Implementing changes for #802
- Fix coding style issues with str append
- Remove useless CACHE_TIMEOUT
- Use count() instead of $limit
- Use defaultLinkTo() + handle strings
- Use http_build_query()
- Fix missing </em>
- Remove error_reporting(0)
- warning CSS (@LogMANOriginal)
- Fix typo in FeedExpander comment
* [Main] More documentation for markdownToHtml
See #802 for more details
2018-09-09 22:20:13 +03:00
|
|
|
|
2017-04-10 14:04:38 +03:00
|
|
|
$this->items[] = $item;
|
|
|
|
}
|
2015-09-02 14:49:36 +03:00
|
|
|
}
|
|
|
|
}
|
2015-08-31 23:59:08 +03:00
|
|
|
}
|
2016-01-23 23:53:23 +03:00
|
|
|
}
|
2020-01-31 16:30:31 +03:00
|
|
|
|
2018-09-25 19:56:33 +03:00
|
|
|
#endregion (User)
|
2018-07-08 18:16:00 +03:00
|
|
|
|
2015-08-31 23:59:08 +03:00
|
|
|
}
|