Преглед на файлове

rtorrent check if array

CauseFX преди 5 години
родител
ревизия
185ef04a3a
променени са 1 файла, в които са добавени 31 реда и са изтрити 29 реда
  1. 31 29
      api/homepage/rtorrent.php

+ 31 - 29
api/homepage/rtorrent.php

@@ -308,35 +308,37 @@ trait RTorrentHomepageItem
 			$response = Requests::post($url, array(), $data, $options);
 			if ($response->success) {
 				$torrentList = xmlrpc_decode(str_replace('i8>', 'string>', $response->body));
-				foreach ($torrentList as $key => $value) {
-					$tempStatus = $this->rTorrentStatus($value[13], $value[10], $value[6]);
-					if ($tempStatus == 'Seeding' && $this->config['rTorrentHideSeeding']) {
-						//do nothing
-					} elseif ($tempStatus == 'Finished' && $this->config['rTorrentHideCompleted']) {
-						//do nothing
-					} else {
-						$torrents[$key] = array(
-							'name' => $value[0],
-							'base' => $value[1],
-							'upTotal' => $value[2],
-							'size' => $value[3],
-							'downTotal' => $value[4],
-							'downloaded' => $value[5],
-							'connectionState' => $value[6],
-							'leech' => $value[7],
-							'seed' => $value[8],
-							'date' => $value[9],
-							'state' => ($value[10]) ? 'on' : 'off',
-							'group' => $value[11],
-							'hash' => $value[12],
-							'complete' => ($value[13]) ? 'yes' : 'no',
-							'ratio' => $value[14],
-							'label' => $value[20],
-							'status' => $tempStatus,
-							'temp' => $value[16] . ' - ' . $value[17] . ' - ' . $value[18],
-							'custom' => $value[19] . ' - ' . $value[20] . ' - ' . $value[21],
-							'custom2' => $value[22] . ' - ' . $value[23] . ' - ' . $value[24],
-						);
+				if (is_array($torrentList)) {
+					foreach ($torrentList as $key => $value) {
+						$tempStatus = $this->rTorrentStatus($value[13], $value[10], $value[6]);
+						if ($tempStatus == 'Seeding' && $this->config['rTorrentHideSeeding']) {
+							//do nothing
+						} elseif ($tempStatus == 'Finished' && $this->config['rTorrentHideCompleted']) {
+							//do nothing
+						} else {
+							$torrents[$key] = array(
+								'name' => $value[0],
+								'base' => $value[1],
+								'upTotal' => $value[2],
+								'size' => $value[3],
+								'downTotal' => $value[4],
+								'downloaded' => $value[5],
+								'connectionState' => $value[6],
+								'leech' => $value[7],
+								'seed' => $value[8],
+								'date' => $value[9],
+								'state' => ($value[10]) ? 'on' : 'off',
+								'group' => $value[11],
+								'hash' => $value[12],
+								'complete' => ($value[13]) ? 'yes' : 'no',
+								'ratio' => $value[14],
+								'label' => $value[20],
+								'status' => $tempStatus,
+								'temp' => $value[16] . ' - ' . $value[17] . ' - ' . $value[18],
+								'custom' => $value[19] . ' - ' . $value[20] . ' - ' . $value[21],
+								'custom2' => $value[22] . ' - ' . $value[23] . ' - ' . $value[24],
+							);
+						}
 					}
 				}
 				if (count($torrents) !== 0) {