Jelajahi Sumber

[WhydBridge] remove useless code

Signed-off-by: Pierre Mazière <pierre.maziere@gmx.com>
Pierre Mazière 7 tahun lalu
induk
melakukan
0de4fce41d
1 mengubah file dengan 20 tambahan dan 23 penghapusan
  1. 20 23
      bridges/WhydBridge.php

+ 20 - 23
bridges/WhydBridge.php

@@ -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);