Jelajahi Sumber

add options to homepage framework classes

CauseFX 4 tahun lalu
induk
melakukan
da74a34086

+ 21 - 6
api/classes/deluge.class.php

@@ -5,12 +5,28 @@ class deluge
 	private $ch;
 	private $url;
 	private $request_id;
+	public $options;
 	
-	public function __construct($host, $password)
+	public function __construct($host, $password, $options)
 	{
+		$verify = (isset($options['verify'])) ? $options['verify'] : false;
 		$this->url = $host . (substr($host, -1) == "/" ? "" : "/") . "json";
 		$this->request_id = 0;
 		$this->ch = curl_init($this->url);
+		switch (gettype($options['verify'])) {
+			case 'string':
+				$cert = $options['custom_cert'];
+				$verify = 2;
+				break;
+			case 'NULL':
+				$cert = $options['organizr_cert'];
+				$verify = 2;
+				break;
+			default:
+				$cert = $options['organizr_cert'];
+				$verify = false;
+				break;
+		}
 		$curl_options = array(
 			CURLOPT_RETURNTRANSFER => true,
 			CURLOPT_HTTPHEADER => array("Accept: application/json", "Content-Type: application/json"),
@@ -18,10 +34,9 @@ class deluge
 			CURLOPT_COOKIEJAR => "",
 			CURLOPT_CONNECTTIMEOUT => 10,
 			CURLOPT_TIMEOUT => 10,
-			CURLOPT_CAINFO => getCert(),
-			CURLOPT_SSL_VERIFYHOST => localURL($host) ? 0 : 2,
-			CURLOPT_SSL_VERIFYPEER => localURL($host) ? 0 : 2,
-			//CURLOPT_SSL_VERIFYPEER => false, THIS IS INSECURE!! However, deluge appears not to send intermediate certificates, so it can be necessary. Use with caution!
+			CURLOPT_CAINFO => $cert,
+			CURLOPT_SSL_VERIFYHOST => $verify,
+			CURLOPT_SSL_VERIFYPEER => $verify,
 		);
 		curl_setopt_array($this->ch, $curl_options);
 		//Log in and get cookies
@@ -569,4 +584,4 @@ class deluge
 		$this->request_id++;
 		return $result->result;
 	}
-}
+}

+ 5 - 3
api/vendor/kryptonit3/couchpotato/src/CouchPotato.php

@@ -11,13 +11,15 @@ class CouchPotato
     protected $apiKey;
     protected $httpAuthUsername;
     protected $httpAuthPassword;
+    public $options;
 
-    public function __construct($url, $apiKey, $httpAuthUsername = null, $httpAuthPassword = null)
+    public function __construct($url, $apiKey, $httpAuthUsername = null, $httpAuthPassword = null, $options = [])
     {
         $this->url = rtrim($url, '/\\'); // Example: http://127.0.0.1:5050 (no trailing forward-backward slashes)
         $this->apiKey = $apiKey;
         $this->httpAuthUsername = $httpAuthUsername;
-        $this->httpAuthPassword = $httpAuthPassword;
+	    $this->httpAuthPassword = $httpAuthPassword;
+	    $this->options = $options;
     }
 
     /**
@@ -1226,7 +1228,7 @@ class CouchPotato
      */
     protected function _request(array $params)
     {
-        $client = new Client();
+	    $client = new Client($this->options);
 
         if ( $params['type'] == 'get' ) {
             $url = $this->url . '/api/' . $this->apiKey . '/' . $params['uri'] . '?' . http_build_query($params['data']);

+ 6 - 4
api/vendor/kryptonit3/sickrage/src/SickRage.php

@@ -11,13 +11,15 @@ class SickRage
     protected $apiKey;
     protected $httpAuthUsername;
     protected $httpAuthPassword;
+    public $options;
 
-    public function __construct($url, $apiKey, $httpAuthUsername = null, $httpAuthPassword = null)
+    public function __construct($url, $apiKey, $httpAuthUsername = null, $httpAuthPassword = null, $options = [])
     {
         $this->url = rtrim($url, '/\\'); // Example: http://127.0.0.1:8081 (no trailing forward-backward slashes)
         $this->apiKey = $apiKey;
         $this->httpAuthUsername = $httpAuthUsername;
-        $this->httpAuthPassword = $httpAuthPassword;
+	    $this->httpAuthPassword = $httpAuthPassword;
+	    $this->options = $options;
     }
 
     /**
@@ -1258,7 +1260,7 @@ class SickRage
      */
     protected function _request(array $params)
     {
-        $client = new Client();
+	    $client = new Client($this->options);
 
         if ( $params['type'] == 'get' ) {
             $url = $this->url . '/api/' . $this->apiKey . '/?cmd=' . $params['uri'] . '&' . http_build_query($params['data']);
@@ -1273,4 +1275,4 @@ class SickRage
             return $client->get($url, $options);
         }
     }
-}
+}

+ 5 - 3
api/vendor/kryptonit3/sonarr/src/Sonarr.php

@@ -11,14 +11,16 @@ class Sonarr
     protected $apiKey;
     protected $httpAuthUsername;
     protected $httpAuthPassword;
+    public $options;
 
-    public function __construct($url, $apiKey, $type = 'sonarr', $httpAuthUsername = null, $httpAuthPassword = null)
+    public function __construct($url, $apiKey, $type = 'sonarr', $httpAuthUsername = null, $httpAuthPassword = null, $options = [])
     {
         $this->url = rtrim($url, '/\\'); // Example: http://127.0.0.1:8989 (no trailing forward-backward slashes)
 	    $this->apiKey = $apiKey;
 	    $this->type = strtolower($type);
         $this->httpAuthUsername = $httpAuthUsername;
-        $this->httpAuthPassword = $httpAuthPassword;
+	    $this->httpAuthPassword = $httpAuthPassword;
+	    $this->options = $options;
     }
 
     /**
@@ -596,7 +598,7 @@ class Sonarr
      */
     protected function _request(array $params)
     {
-        $client = new Client(['verify' => getCert()]);
+        $client = new Client($this->options);
         $options = [
             'headers' => [
                 'X-Api-Key' => $this->apiKey