diff --git a/bridges/FurAffinityUserBridge.php b/bridges/FurAffinityUserBridge.php index e61eb640519..d9214b84b35 100644 --- a/bridges/FurAffinityUserBridge.php +++ b/bridges/FurAffinityUserBridge.php @@ -3,6 +3,7 @@ class FurAffinityUserBridge extends BridgeAbstract { const NAME = 'FurAffinity User Gallery'; const URI = 'https://www.furaffinity.net'; const MAINTAINER = 'CyberJacob'; + const DESCRIPTION = 'See https://rss-bridge.github.io/rss-bridge/Bridge_Specific/Furaffinityuser.html for explanation'; const PARAMETERS = array( array( 'searchUsername' => array( @@ -12,13 +13,13 @@ class FurAffinityUserBridge extends BridgeAbstract { 'title' => 'Username to fetch the gallery for', 'exampleValue' => 'armundy', ), - 'loginUsername' => array( - 'name' => 'Login Username', + 'aCookie' => array( + 'name' => 'Login cookie \'a\'', 'type' => 'text', 'required' => true ), - 'loginPassword' => array( - 'name' => 'Login Password', + 'bCookie' => array( + 'name' => 'Login cookie \'b\'', 'type' => 'text', 'required' => true ) @@ -26,10 +27,12 @@ class FurAffinityUserBridge extends BridgeAbstract { ); public function collectData() { - $cookies = self::login(); + $opt = array(CURLOPT_COOKIE => 'b=' . $this->getInput('bCookie') . '; a=' . $this->getInput('aCookie')); + $url = self::URI . '/gallery/' . $this->getInput('searchUsername'); - $html = getSimpleHTMLDOM($url, $cookies); + $html = getSimpleHTMLDOM($url, array(), $opt) + or returnServerError('Could not load the user\'s gallery page.'); $submissions = $html->find('section[id=gallery-gallery]', 0)->find('figure'); foreach($submissions as $submission) { @@ -52,59 +55,4 @@ public function getName() { public function getURI() { return self::URI . '/user/' . $this->getInput('searchUsername'); } - - private function login() { - $ch = curl_init(self::URI . '/login/'); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); - - curl_setopt($ch, CURLOPT_USERAGENT, ini_get('user_agent')); - curl_setopt($ch, CURLOPT_ENCODING, ''); - curl_setopt($ch, CURLOPT_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS); - - $fields = implode('&', array( - 'action=login', - 'retard_protection=1', - 'name=' . urlencode($this->getInput('loginUsername')), - 'pass=' . urlencode($this->getInput('loginPassword')), - 'login=Login to Faraffinity' - )); - - curl_setopt($ch, CURLOPT_POST, 5); - curl_setopt($ch, CURLOPT_POSTFIELDS, $fields); - - if(defined('PROXY_URL') && !defined('NOPROXY')) { - curl_setopt($ch, CURLOPT_PROXY, PROXY_URL); - } - - curl_setopt($ch, CURLOPT_HEADER, true); - curl_setopt($ch, CURLINFO_HEADER_OUT, true); - - $data = curl_exec($ch); - - $errorCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); - - $curlError = curl_error($ch); - $curlErrno = curl_errno($ch); - $curlInfo = curl_getinfo($ch); - - if($data === false) - fDebug::log("Cant't download {$url} cUrl error: {$curlError} ({$curlErrno})"); - - curl_close($ch); - - if($errorCode != 200) { - returnServerError(error_get_last()); - } else { - preg_match_all('/^Set-Cookie:\s*([^;]*)/mi', $data, $matches); - $cookies = array(); - - foreach($matches[1] as $item) { - parse_str($item, $cookie); - $cookies = array_merge($cookies, $cookie); - } - - return $cookies; - } - } }