Browse Source

Added rtorrent test and fix images.

causefx 7 years ago
parent
commit
938cf0737a
2 changed files with 38 additions and 2 deletions
  1. 22 0
      api/functions/homepage-connect-functions.php
  2. 16 2
      api/functions/homepage-functions.php

+ 22 - 0
api/functions/homepage-connect-functions.php

@@ -2135,6 +2135,28 @@ function testAPIConnection($array)
 				return 'URL and/or Password not setup';
 			}
 			break;
+		case 'rTorrent':
+			if (!empty($GLOBALS['rTorrentURL'])) {
+				try {
+					$digest = qualifyURL($GLOBALS['rTorrentURL'], true);
+					$url = $digest['scheme'] . '://' . $digest['host'] . $digest['port'] . $digest['path'] . '/RPC2';
+					$options = (localURL($url)) ? array('verify' => false) : array();
+					$data = xmlrpc_encode_request("system.listMethods", null);
+					$response = Requests::post($url, array(), $data, $options);
+					if ($response->success) {
+						$methods = xmlrpc_decode(str_replace('i8>', 'i4>', $response->body));
+						if (count($methods) !== 0) {
+							return true;
+						}
+					}
+					return false;
+				} catch
+				(Requests_Exception $e) {
+					writeLog('error', 'rTorrent Connect Function - Error: ' . $e->getMessage(), 'SYSTEM');
+					return $e->getMessage();
+				};
+			}
+			break;
 		default :
 			return false;
 	}

+ 16 - 2
api/functions/homepage-functions.php

@@ -1120,7 +1120,7 @@ function getHomepageList()
 		array(
 			'name' => 'rTorrent',
 			'enabled' => (strpos('personal', $GLOBALS['license']) !== false) ? true : false,
-			'image' => 'plugins/images/tabs/rtorrent.png',
+			'image' => 'plugins/images/tabs/rTorrent.png',
 			'category' => 'Downloader',
 			'settings' => array(
 				'FYI' => array(
@@ -1208,6 +1208,20 @@ function getHomepageList()
 						'value' => $GLOBALS['homepageDownloadRefresh'],
 						'options' => optionTime()
 					)
+				),
+				'Test Connection' => array(
+					array(
+						'type' => 'blank',
+						'label' => 'Please Save before Testing'
+					),
+					array(
+						'type' => 'button',
+						'label' => '',
+						'icon' => 'fa fa-flask',
+						'class' => 'pull-right',
+						'text' => 'Test Connection',
+						'attr' => 'onclick="testAPIConnection(\'rtorrent\')"'
+					),
 				)
 			)
 		),
@@ -1965,7 +1979,7 @@ function buildHomepageSettings()
 				break;
 			case 'homepageOrderrTorrent':
 				$class = 'bg-qbit';
-				$image = 'plugins/images/tabs/ruTorrent.png';
+				$image = 'plugins/images/tabs/rTorrent.png';
 				if (!$GLOBALS['homepagerTorrentEnabled']) {
 					$class .= ' faded';
 				}