[WhydBridge] remove useless code

Signed-off-by: Pierre Mazière <pierre.maziere@gmx.com>
This commit is contained in:
Pierre Mazière 2016-08-27 18:25:24 +02:00
parent 341ce2bf3e
commit 0de4fce41d

View file

@ -1,9 +1,6 @@
<?php
class WhydBridge extends BridgeAbstract{
private $request;
public $name;
public function loadMetadatas() {
$this->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);