mirror of
https://github.com/wallabag/wallabag.git
synced 2024-12-15 12:16:27 +00:00
commit
4cfbd5d893
47 changed files with 153 additions and 183 deletions
|
@ -8,14 +8,12 @@ use Symfony\Component\HttpFoundation\Request;
|
|||
use Wallabag\CoreBundle\Repository;
|
||||
use Wallabag\CoreBundle\Entity\Entries;
|
||||
use Wallabag\CoreBundle\Service\Extractor;
|
||||
use Wallabag\CoreBundle\Helper\Tools;
|
||||
use Wallabag\CoreBundle\Helper\Url;
|
||||
|
||||
class EntryController extends Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param Request $request
|
||||
* @Route("/new", name="new_entry")
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
|
@ -32,7 +30,6 @@ class EntryController extends Controller
|
|||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isValid()) {
|
||||
|
||||
$content = Extractor::extract($entry->getUrl());
|
||||
|
||||
$entry->setTitle($content->getTitle());
|
||||
|
@ -115,7 +112,7 @@ class EntryController extends Controller
|
|||
/**
|
||||
* Shows entry content
|
||||
*
|
||||
* @param Entries $entry
|
||||
* @param Entries $entry
|
||||
* @Route("/view/{id}", requirements={"id" = "\d+"}, name="view")
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
|
@ -130,8 +127,8 @@ class EntryController extends Controller
|
|||
/**
|
||||
* Changes read status for an entry
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Entries $entry
|
||||
* @param Request $request
|
||||
* @param Entries $entry
|
||||
* @Route("/archive/{id}", requirements={"id" = "\d+"}, name="archive_entry")
|
||||
* @return \Symfony\Component\HttpFoundation\RedirectResponse
|
||||
*/
|
||||
|
@ -151,8 +148,8 @@ class EntryController extends Controller
|
|||
/**
|
||||
* Changes favorite status for an entry
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Entries $entry
|
||||
* @param Request $request
|
||||
* @param Entries $entry
|
||||
* @Route("/star/{id}", requirements={"id" = "\d+"}, name="star_entry")
|
||||
* @return \Symfony\Component\HttpFoundation\RedirectResponse
|
||||
*/
|
||||
|
@ -172,8 +169,8 @@ class EntryController extends Controller
|
|||
/**
|
||||
* Deletes entry
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Entries $entry
|
||||
* @param Request $request
|
||||
* @param Entries $entry
|
||||
* @Route("/delete/{id}", requirements={"id" = "\d+"}, name="delete_entry")
|
||||
* @return \Symfony\Component\HttpFoundation\RedirectResponse
|
||||
*/
|
||||
|
|
|
@ -18,6 +18,7 @@ class SecurityController extends Controller
|
|||
$error = $session->get(SecurityContext::AUTHENTICATION_ERROR);
|
||||
$session->remove(SecurityContext::AUTHENTICATION_ERROR);
|
||||
}
|
||||
|
||||
return $this->render('WallabagCoreBundle:Security:login.html.twig', array(
|
||||
// last username entered by the user
|
||||
'last_username' => $session->get(SecurityContext::LAST_USERNAME),
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
namespace Wallabag\CoreBundle\Controller;
|
||||
|
||||
use Nelmio\ApiDocBundle\Annotation\ApiDoc;
|
||||
use FOS\RestBundle\Controller\Annotations\View;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Wallabag\CoreBundle\Entity\Entries;
|
||||
|
@ -12,7 +11,6 @@ use Wallabag\CoreBundle\Service\Extractor;
|
|||
|
||||
class WallabagRestController extends Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* Retrieve all entries. It could be filtered by many options.
|
||||
*
|
||||
|
@ -44,14 +42,13 @@ class WallabagRestController extends Controller
|
|||
$entries = $this
|
||||
->getDoctrine()
|
||||
->getRepository('WallabagCoreBundle:Entries')
|
||||
->findEntries(1, (int)$isArchived, (int)$isStarred, (int)$isDeleted, $sort, $order);
|
||||
->findEntries(1, (int) $isArchived, (int) $isStarred, (int) $isDeleted, $sort, $order);
|
||||
|
||||
if(!is_array($entries)) {
|
||||
if (!is_array($entries)) {
|
||||
throw $this->createNotFoundException();
|
||||
}
|
||||
|
||||
return $entries;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -119,7 +116,6 @@ class WallabagRestController extends Controller
|
|||
*/
|
||||
public function patchEntriesAction(Entries $entry)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -133,10 +129,8 @@ class WallabagRestController extends Controller
|
|||
*/
|
||||
public function deleteEntriesAction(Entries $entry)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retrieve all tags for an entry
|
||||
*
|
||||
|
@ -146,8 +140,8 @@ class WallabagRestController extends Controller
|
|||
* }
|
||||
* )
|
||||
*/
|
||||
public function getEntriesTagsAction(Entries $entry) {
|
||||
|
||||
public function getEntriesTagsAction(Entries $entry)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -162,8 +156,8 @@ class WallabagRestController extends Controller
|
|||
* }
|
||||
* )
|
||||
*/
|
||||
public function postEntriesTagsAction(Entries $entry) {
|
||||
|
||||
public function postEntriesTagsAction(Entries $entry)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -178,7 +172,6 @@ class WallabagRestController extends Controller
|
|||
*/
|
||||
public function deleteEntriesTagsAction(Entries $entry, Tags $tag)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -187,8 +180,8 @@ class WallabagRestController extends Controller
|
|||
* @ApiDoc(
|
||||
* )
|
||||
*/
|
||||
public function getTagsAction() {
|
||||
|
||||
public function getTagsAction()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -200,8 +193,8 @@ class WallabagRestController extends Controller
|
|||
* }
|
||||
* )
|
||||
*/
|
||||
public function getTagAction(Tags $tag) {
|
||||
|
||||
public function getTagAction(Tags $tag)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -215,6 +208,5 @@ class WallabagRestController extends Controller
|
|||
*/
|
||||
public function deleteTagAction(Tags $tag)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
|
@ -35,8 +35,6 @@ class Config
|
|||
*/
|
||||
private $value;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Get id
|
||||
*
|
||||
|
@ -50,7 +48,7 @@ class Config
|
|||
/**
|
||||
* Set name
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $name
|
||||
* @return Config
|
||||
*/
|
||||
public function setName($name)
|
||||
|
@ -73,7 +71,7 @@ class Config
|
|||
/**
|
||||
* Set value
|
||||
*
|
||||
* @param string $value
|
||||
* @param string $value
|
||||
* @return Config
|
||||
*/
|
||||
public function setValue($value)
|
||||
|
|
|
@ -66,8 +66,6 @@ class Entries
|
|||
*/
|
||||
private $userId;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Get id
|
||||
*
|
||||
|
@ -81,7 +79,7 @@ class Entries
|
|||
/**
|
||||
* Set title
|
||||
*
|
||||
* @param string $title
|
||||
* @param string $title
|
||||
* @return Entries
|
||||
*/
|
||||
public function setTitle($title)
|
||||
|
@ -104,7 +102,7 @@ class Entries
|
|||
/**
|
||||
* Set url
|
||||
*
|
||||
* @param string $url
|
||||
* @param string $url
|
||||
* @return Entries
|
||||
*/
|
||||
public function setUrl($url)
|
||||
|
@ -127,7 +125,7 @@ class Entries
|
|||
/**
|
||||
* Set isRead
|
||||
*
|
||||
* @param string $isRead
|
||||
* @param string $isRead
|
||||
* @return Entries
|
||||
*/
|
||||
public function setIsRead($isRead)
|
||||
|
@ -150,13 +148,14 @@ class Entries
|
|||
public function toggleArchive()
|
||||
{
|
||||
$this->isRead = $this->getIsRead() ^ 1;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set isFav
|
||||
*
|
||||
* @param string $isFav
|
||||
* @param string $isFav
|
||||
* @return Entries
|
||||
*/
|
||||
public function setIsFav($isFav)
|
||||
|
@ -186,7 +185,7 @@ class Entries
|
|||
/**
|
||||
* Set content
|
||||
*
|
||||
* @param string $content
|
||||
* @param string $content
|
||||
* @return Entries
|
||||
*/
|
||||
public function setContent($content)
|
||||
|
@ -209,7 +208,7 @@ class Entries
|
|||
/**
|
||||
* Set userId
|
||||
*
|
||||
* @param string $userId
|
||||
* @param string $userId
|
||||
* @return Entries
|
||||
*/
|
||||
public function setUserId($userId)
|
||||
|
|
|
@ -28,8 +28,6 @@ class Tags
|
|||
*/
|
||||
private $value;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Get id
|
||||
*
|
||||
|
@ -43,7 +41,7 @@ class Tags
|
|||
/**
|
||||
* Set value
|
||||
*
|
||||
* @param string $value
|
||||
* @param string $value
|
||||
* @return Tags
|
||||
*/
|
||||
public function setValue($value)
|
||||
|
|
|
@ -35,8 +35,6 @@ class TagsEntries
|
|||
*/
|
||||
private $tagId;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Get id
|
||||
*
|
||||
|
@ -50,7 +48,7 @@ class TagsEntries
|
|||
/**
|
||||
* Set entryId
|
||||
*
|
||||
* @param integer $entryId
|
||||
* @param integer $entryId
|
||||
* @return TagsEntries
|
||||
*/
|
||||
public function setEntryId($entryId)
|
||||
|
@ -73,7 +71,7 @@ class TagsEntries
|
|||
/**
|
||||
* Set tagId
|
||||
*
|
||||
* @param integer $tagId
|
||||
* @param integer $tagId
|
||||
* @return TagsEntries
|
||||
*/
|
||||
public function setTagId($tagId)
|
||||
|
|
|
@ -4,7 +4,6 @@ namespace Wallabag\CoreBundle\Entity;
|
|||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Security\Core\User\UserInterface;
|
||||
use Symfony\Component\Security\Core\User\EquatableInterface;
|
||||
use Symfony\Component\Security\Core\User\AdvancedUserInterface;
|
||||
|
||||
/**
|
||||
|
@ -81,7 +80,7 @@ class Users implements AdvancedUserInterface, \Serializable
|
|||
/**
|
||||
* Set username
|
||||
*
|
||||
* @param string $username
|
||||
* @param string $username
|
||||
* @return Users
|
||||
*/
|
||||
public function setUsername($username)
|
||||
|
@ -120,7 +119,7 @@ class Users implements AdvancedUserInterface, \Serializable
|
|||
/**
|
||||
* Set password
|
||||
*
|
||||
* @param string $password
|
||||
* @param string $password
|
||||
* @return Users
|
||||
*/
|
||||
public function setPassword($password)
|
||||
|
@ -143,7 +142,7 @@ class Users implements AdvancedUserInterface, \Serializable
|
|||
/**
|
||||
* Set name
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $name
|
||||
* @return Users
|
||||
*/
|
||||
public function setName($name)
|
||||
|
@ -166,7 +165,7 @@ class Users implements AdvancedUserInterface, \Serializable
|
|||
/**
|
||||
* Set email
|
||||
*
|
||||
* @param string $email
|
||||
* @param string $email
|
||||
* @return Users
|
||||
*/
|
||||
public function setEmail($email)
|
||||
|
@ -208,7 +207,7 @@ class Users implements AdvancedUserInterface, \Serializable
|
|||
*/
|
||||
public function unserialize($serialized)
|
||||
{
|
||||
list (
|
||||
list(
|
||||
$this->id,
|
||||
) = unserialize($serialized);
|
||||
}
|
||||
|
|
|
@ -42,8 +42,6 @@ class UsersConfig
|
|||
*/
|
||||
private $value;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Get id
|
||||
*
|
||||
|
@ -57,7 +55,7 @@ class UsersConfig
|
|||
/**
|
||||
* Set userId
|
||||
*
|
||||
* @param string $userId
|
||||
* @param string $userId
|
||||
* @return UsersConfig
|
||||
*/
|
||||
public function setUserId($userId)
|
||||
|
@ -80,7 +78,7 @@ class UsersConfig
|
|||
/**
|
||||
* Set name
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $name
|
||||
* @return UsersConfig
|
||||
*/
|
||||
public function setName($name)
|
||||
|
@ -103,7 +101,7 @@ class UsersConfig
|
|||
/**
|
||||
* Set value
|
||||
*
|
||||
* @param string $value
|
||||
* @param string $value
|
||||
* @return UsersConfig
|
||||
*/
|
||||
public function setValue($value)
|
||||
|
|
|
@ -8,8 +8,8 @@ class Content
|
|||
|
||||
private $body;
|
||||
|
||||
public function __constructor() {
|
||||
|
||||
public function __constructor()
|
||||
{
|
||||
}
|
||||
|
||||
public function getTitle()
|
||||
|
|
|
@ -2,9 +2,6 @@
|
|||
|
||||
namespace Wallabag\CoreBundle\Helper;
|
||||
|
||||
|
||||
class Entries {
|
||||
|
||||
|
||||
|
||||
class Entries
|
||||
{
|
||||
}
|
|
@ -2,9 +2,6 @@
|
|||
|
||||
namespace Wallabag\CoreBundle\Helper;
|
||||
|
||||
use \RecursiveIteratorIterator;
|
||||
use \RecursiveDirectoryIterator;
|
||||
|
||||
final class Tools
|
||||
{
|
||||
/**
|
||||
|
@ -18,7 +15,7 @@ final class Tools
|
|||
$timeout = 15;
|
||||
$useragent = "Mozilla/5.0 (Windows NT 5.1; rv:18.0) Gecko/20100101 Firefox/18.0";
|
||||
|
||||
if (in_array ('curl', get_loaded_extensions())) {
|
||||
if (in_array('curl', get_loaded_extensions())) {
|
||||
# Fetch feed from URL
|
||||
$curl = curl_init();
|
||||
curl_setopt($curl, CURLOPT_URL, $url);
|
||||
|
@ -30,8 +27,8 @@ final class Tools
|
|||
curl_setopt($curl, CURLOPT_HEADER, false);
|
||||
|
||||
# for ssl, do not verified certificate
|
||||
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
|
||||
curl_setopt($curl, CURLOPT_AUTOREFERER, TRUE );
|
||||
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($curl, CURLOPT_AUTOREFERER, true);
|
||||
|
||||
# FeedBurner requires a proper USER-AGENT...
|
||||
curl_setopt($curl, CURL_HTTP_VERSION_1_1, true);
|
||||
|
@ -48,13 +45,13 @@ final class Tools
|
|||
array(
|
||||
'http' => array(
|
||||
'timeout' => $timeout,
|
||||
'header' => "User-Agent: " . $useragent,
|
||||
'follow_location' => true
|
||||
'header' => "User-Agent: ".$useragent,
|
||||
'follow_location' => true,
|
||||
),
|
||||
'ssl' => array(
|
||||
'verify_peer' => false,
|
||||
'allow_self_signed' => true
|
||||
)
|
||||
'allow_self_signed' => true,
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -62,13 +59,12 @@ final class Tools
|
|||
$data = @file_get_contents($url, false, $context, -1, 4000000);
|
||||
|
||||
if (isset($http_response_header) and isset($http_response_header[0])) {
|
||||
$httpcodeOK = isset($http_response_header) and isset($http_response_header[0]) and ((strpos($http_response_header[0], '200 OK') !== FALSE) or (strpos($http_response_header[0], '301 Moved Permanently') !== FALSE));
|
||||
$httpcodeOK = isset($http_response_header) and isset($http_response_header[0]) and ((strpos($http_response_header[0], '200 OK') !== false) or (strpos($http_response_header[0], '301 Moved Permanently') !== false));
|
||||
}
|
||||
}
|
||||
|
||||
# if response is not empty and response is OK
|
||||
if (isset($data) and isset($httpcodeOK) and $httpcodeOK) {
|
||||
|
||||
# take charset of page and get it
|
||||
preg_match('#<meta .*charset=.*>#Usi', $data, $meta);
|
||||
|
||||
|
@ -77,19 +73,20 @@ final class Tools
|
|||
preg_match('#charset="?(.*)"#si', $meta[0], $encoding);
|
||||
# if charset is found set it otherwise, set it to utf-8
|
||||
$html_charset = (!empty($encoding[1])) ? strtolower($encoding[1]) : 'utf-8';
|
||||
if (empty($encoding[1])) $encoding[1] = 'utf-8';
|
||||
if (empty($encoding[1])) {
|
||||
$encoding[1] = 'utf-8';
|
||||
}
|
||||
} else {
|
||||
$html_charset = 'utf-8';
|
||||
$encoding[1] = '';
|
||||
}
|
||||
|
||||
# replace charset of url to charset of page
|
||||
$data = str_replace('charset=' . $encoding[1], 'charset=' . $html_charset, $data);
|
||||
$data = str_replace('charset='.$encoding[1], 'charset='.$html_charset, $data);
|
||||
|
||||
return $data;
|
||||
}
|
||||
else {
|
||||
return FALSE;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -101,7 +98,7 @@ final class Tools
|
|||
*/
|
||||
public static function encodeString($string)
|
||||
{
|
||||
return sha1($string . SALT);
|
||||
return sha1($string.SALT);
|
||||
}
|
||||
|
||||
public static function generateToken()
|
||||
|
@ -113,12 +110,10 @@ final class Tools
|
|||
} else {
|
||||
$token = substr(base64_encode(file_get_contents('/dev/urandom', false, null, 0, 20)), 0, 15);
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$token = substr(base64_encode(uniqid(mt_rand(), true)), 0, 20);
|
||||
}
|
||||
|
||||
return str_replace('+', '', $token);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,20 +6,23 @@ class Url
|
|||
{
|
||||
public $url;
|
||||
|
||||
function __construct($url)
|
||||
public function __construct($url)
|
||||
{
|
||||
$this->url = base64_decode($url);
|
||||
}
|
||||
|
||||
public function getUrl() {
|
||||
public function getUrl()
|
||||
{
|
||||
return $this->url;
|
||||
}
|
||||
|
||||
public function setUrl($url) {
|
||||
public function setUrl($url)
|
||||
{
|
||||
$this->url = $url;
|
||||
}
|
||||
|
||||
public function isCorrect() {
|
||||
return filter_var($this->url, FILTER_VALIDATE_URL) !== FALSE;
|
||||
public function isCorrect()
|
||||
{
|
||||
return filter_var($this->url, FILTER_VALIDATE_URL) !== false;
|
||||
}
|
||||
}
|
|
@ -6,7 +6,6 @@ use Doctrine\ORM\Query;
|
|||
use Doctrine\ORM\EntityRepository;
|
||||
use Doctrine\ORM\Tools\Pagination\Paginator;
|
||||
use Wallabag\CoreBundle\Entity\Entries;
|
||||
use Wallabag\CoreBundle\Service\Extractor;
|
||||
|
||||
class EntriesRepository extends EntityRepository
|
||||
{
|
||||
|
@ -15,7 +14,7 @@ class EntriesRepository extends EntityRepository
|
|||
*
|
||||
* @param $userId
|
||||
* @param $firstResult
|
||||
* @param int $maxResults
|
||||
* @param int $maxResults
|
||||
* @return Paginator
|
||||
*/
|
||||
public function findUnreadByUser($userId, $firstResult, $maxResults = 12)
|
||||
|
@ -38,7 +37,7 @@ class EntriesRepository extends EntityRepository
|
|||
*
|
||||
* @param $userId
|
||||
* @param $firstResult
|
||||
* @param int $maxResults
|
||||
* @param int $maxResults
|
||||
* @return Paginator
|
||||
*/
|
||||
public function findArchiveByUser($userId, $firstResult, $maxResults = 12)
|
||||
|
@ -61,7 +60,7 @@ class EntriesRepository extends EntityRepository
|
|||
*
|
||||
* @param $userId
|
||||
* @param $firstResult
|
||||
* @param int $maxResults
|
||||
* @param int $maxResults
|
||||
* @return Paginator
|
||||
*/
|
||||
public function findStarredByUser($userId, $firstResult, $maxResults = 12)
|
||||
|
|
|
@ -25,5 +25,3 @@
|
|||
</services>
|
||||
|
||||
</container>
|
||||
|
||||
|
||||
|
|
|
@ -37,4 +37,3 @@
|
|||
<script src="{{ asset('themes/_global/js/saveLink.js') }}"></script>
|
||||
<script src="{{ asset('themes/_global/js/popupForm.js') }}"></script>
|
||||
<script src="{{ asset('themes/baggy/js/closeMessage.js') }}"></script>
|
||||
|
||||
|
|
|
@ -12,4 +12,3 @@
|
|||
<li><a href={{ path('about') }}>{% trans %}about{% endtrans %}</a></li>
|
||||
<li><a class="icon icon-power" href="{{ path('logout') }}" title="{% trans %}logout{% endtrans %}">{% trans %}logout{% endtrans %}</a></li>
|
||||
</ul>
|
||||
|
||||
|
|
|
@ -11,4 +11,3 @@
|
|||
</ul>
|
||||
{% include '_pocheit-form.twig' %}
|
||||
{% include '_search-form.twig' %}
|
||||
|
||||
|
|
|
@ -52,7 +52,6 @@ class WsseListener implements ListenerInterface
|
|||
$response = new Response();
|
||||
$response->setStatusCode(403);
|
||||
$event->setResponse($response);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -7,29 +7,30 @@ use Wallabag\CoreBundle\Helper\Url;
|
|||
|
||||
final class Extractor
|
||||
{
|
||||
public static function extract($url) {
|
||||
public static function extract($url)
|
||||
{
|
||||
$pageContent = Extractor::getPageContent(new Url(base64_encode($url)));
|
||||
$title = ($pageContent['rss']['channel']['item']['title'] != '') ? $pageContent['rss']['channel']['item']['title'] : _('Untitled');
|
||||
$body = $pageContent['rss']['channel']['item']['description'];
|
||||
|
||||
$content = new Content();
|
||||
$content->setTitle($title);
|
||||
$content->setBody($body);;
|
||||
$content->setBody($body);
|
||||
|
||||
return $content;
|
||||
}
|
||||
/**
|
||||
* Get the content for a given URL (by a call to FullTextFeed)
|
||||
*
|
||||
* @param Url $url
|
||||
* @param Url $url
|
||||
* @return mixed
|
||||
*/
|
||||
public static function getPageContent(Url $url)
|
||||
{
|
||||
// Saving and clearing context
|
||||
$REAL = array();
|
||||
foreach( $GLOBALS as $key => $value ) {
|
||||
if( $key != 'GLOBALS' && $key != '_SESSION' && $key != 'HTTP_SESSION_VARS' ) {
|
||||
foreach ($GLOBALS as $key => $value) {
|
||||
if ($key != 'GLOBALS' && $key != '_SESSION' && $key != 'HTTP_SESSION_VARS') {
|
||||
$GLOBALS[$key] = array();
|
||||
$REAL[$key] = $value;
|
||||
}
|
||||
|
@ -37,38 +38,39 @@ final class Extractor
|
|||
// Saving and clearing session
|
||||
if (isset($_SESSION)) {
|
||||
$REAL_SESSION = array();
|
||||
foreach( $_SESSION as $key => $value ) {
|
||||
foreach ($_SESSION as $key => $value) {
|
||||
$REAL_SESSION[$key] = $value;
|
||||
unset($_SESSION[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
// Running code in different context
|
||||
$scope = function() {
|
||||
extract( func_get_arg(1) );
|
||||
$scope = function () {
|
||||
extract(func_get_arg(1));
|
||||
$_GET = $_REQUEST = array(
|
||||
"url" => $url->getUrl(),
|
||||
"max" => 5,
|
||||
"links" => "preserve",
|
||||
"exc" => "",
|
||||
"format" => "json",
|
||||
"submit" => "Create Feed"
|
||||
"submit" => "Create Feed",
|
||||
);
|
||||
ob_start();
|
||||
require func_get_arg(0);
|
||||
$json = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
return $json;
|
||||
};
|
||||
|
||||
// Silence $scope function to avoid
|
||||
// issues with FTRSS when error_reporting is to high
|
||||
// FTRSS generates PHP warnings which break output
|
||||
$json = @$scope(__DIR__ . "/../../../../vendor/wallabag/Fivefilters_Libraries/makefulltextfeed.php", array("url" => $url));
|
||||
$json = @$scope(__DIR__."/../../../../vendor/wallabag/Fivefilters_Libraries/makefulltextfeed.php", array("url" => $url));
|
||||
|
||||
// Clearing and restoring context
|
||||
foreach ($GLOBALS as $key => $value) {
|
||||
if($key != "GLOBALS" && $key != "_SESSION" ) {
|
||||
if ($key != "GLOBALS" && $key != "_SESSION") {
|
||||
unset($GLOBALS[$key]);
|
||||
}
|
||||
}
|
||||
|
@ -78,11 +80,11 @@ final class Extractor
|
|||
|
||||
// Clearing and restoring session
|
||||
if (isset($REAL_SESSION)) {
|
||||
foreach($_SESSION as $key => $value) {
|
||||
foreach ($_SESSION as $key => $value) {
|
||||
unset($_SESSION[$key]);
|
||||
}
|
||||
|
||||
foreach($REAL_SESSION as $key => $value) {
|
||||
foreach ($REAL_SESSION as $key => $value) {
|
||||
$_SESSION[$key] = $value;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue