From 0de4fce41d92af6963417b1be4fd22ac407230ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Mazi=C3=A8re?= Date: Sat, 27 Aug 2016 18:25:24 +0200 Subject: [PATCH] [WhydBridge] remove useless code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Pierre Mazière --- bridges/WhydBridge.php | 43 ++++++++++++++++++++---------------------- 1 file changed, 20 insertions(+), 23 deletions(-) diff --git a/bridges/WhydBridge.php b/bridges/WhydBridge.php index 5f8fb23..882882c 100644 --- a/bridges/WhydBridge.php +++ b/bridges/WhydBridge.php @@ -1,9 +1,6 @@ maintainer = "kranack"; @@ -23,26 +20,26 @@ class WhydBridge extends BridgeAbstract{ public function collectData(){ $param=$this->parameters[$this->queriedContext]; $html = ''; - if (isset($param['u']['value'])) - { - $this->request = $param['u']['value']; - if (strlen(preg_replace("/[^0-9a-f]/",'', $this->request)) == 24) { // is input the userid ? - $html = $this->getSimpleHTMLDOM('http://www.whyd.com/u/'.preg_replace("/[^0-9a-f]/",'', $this->request)) or $this->returnServerError('No results for this query.'); - } else { // input may be the username - $html = $this->getSimpleHTMLDOM('http://www.whyd.com/search?q='.urlencode($this->request)) or $this->returnServerError('No results for this query.'); - for ($j = 0; $j < 5; $j++) { - if (strtolower($html->find('div.user', $j)->find('a',0)->plaintext) == strtolower($this->request)) { - $html = $this->getSimpleHTMLDOM('http://www.whyd.com' . $html->find('div.user', $j)->find('a', 0)->getAttribute('href')) or $this->returnServerError('No results for this query'); - break; - } - } - } - $this->name = $html->find('div#profileTop', 0)->find('h1', 0)->plaintext; - } - else - { - $this->returnClientError('You must specify username'); - } + if (strlen(preg_replace("/[^0-9a-f]/",'', $param['u']['value'])) == 24){ + // is input the userid ? + $html = $this->getSimpleHTMLDOM( + $this->uri.'u/'.preg_replace("/[^0-9a-f]/",'', $param['u']['value']) + ) or $this->returnServerError('No results for this query.'); + } else { // input may be the username + $html = $this->getSimpleHTMLDOM( + $this->uri.'search?q='.urlencode($param['u']['value']) + ) or $this->returnServerError('No results for this query.'); + + for ($j = 0; $j < 5; $j++) { + if (strtolower($html->find('div.user', $j)->find('a',0)->plaintext) == strtolower($param['u']['value'])) { + $html = $this->getSimpleHTMLDOM( + $this->uri . $html->find('div.user', $j)->find('a', 0)->getAttribute('href') + ) or $this->returnServerError('No results for this query'); + break; + } + } + } + $this->name = $html->find('div#profileTop', 0)->find('h1', 0)->plaintext; for($i = 0; $i < 10; $i++) { $track = $html->find('div.post', $i);