Procházet zdrojové kódy

1.61 Bug fix release

causefx před 8 roky
rodič
revize
389f332f6b
2 změnil soubory, kde provedl 53 přidání a 6 odebrání
  1. 25 5
      api.php
  2. 28 1
      functions.php

+ 25 - 5
api.php

@@ -1,14 +1,16 @@
 <?php
 // Include functions
 require_once('user.php');
-$USER = new User('registration_callback');
+$USER = new User();
 // Get Action
 if (isset($_POST['a'])) { $action = $_POST['a']; }
 if (isset($_POST['k'])) { $key = $_POST['k']; }
 if (isset($_POST['v'])) { $values = $_POST['v']; }
 if (isset($_GET['a'])) { $action = $_GET['a']; }
 if (isset($_GET['k'])) { $key = $_GET['k']; }
-if (isset($_GET['v'])) { $values = explode('|',$_GET['v']); }
+if (isset($_GET['v'])) {
+    $values = (strpos($_GET['v'], '|') !== false ? explode('|',$_GET['v']) : $_GET['v']);
+}
 unset($_POST['a']);
 unset($_POST['k']);
 unset($_POST['v']);
@@ -35,6 +37,7 @@ if (isset($action)) {
 					$email = $values[1];
                     $server = $values[2];
                 }
+                //$USER = new User();
                 $USER->invite_user("chris", "causefx@me.com", "plex");
                 $result['data'] = "User has been invited";
                 //$result['data'] = "user = $user | email = $email | server = $server";
@@ -42,8 +45,25 @@ if (isset($action)) {
             	$result['error'] = "No Values Were Set For Function";
             }
             break;
-        case "2":
-            $result = "other test";
+        case "ombi":
+			if($values){
+				switch ($values) {
+					case 'plex-update':
+						$ombi = ombiAPI('plex-cache');
+						if($ombi){
+							$result['data'] = "Plex Content Cache Successful";
+						}else{
+							$result['error'] = "Plex Content Cache Error";
+						}
+						break;
+					default:
+                        $result['error'] = "$values is not a valid Ombi function";
+						break;
+				}
+			}else{
+                $result['error'] = "No Ombi Action Supplied";
+            }
+
             break;
         default:
             $result = "$action Not Defined As API Function";
@@ -57,4 +77,4 @@ if(!$result){
 }
 //return JSON array
 exit(json_encode($result));
-?>
+?>

+ 28 - 1
functions.php

@@ -2,7 +2,7 @@
 
 // ===================================
 // Define Version
- define('INSTALLEDVERSION', '1.603');
+ define('INSTALLEDVERSION', '1.61');
 // ===================================
 $debugOrganizr = true;
 if($debugOrganizr == true && file_exists('debug.php')){ require_once('debug.php'); }
@@ -5149,6 +5149,33 @@ function outputOmbiRequests($header = "Requested Content", $items, $script = fal
     }
 }
 
+function ombiAPI($action){
+	$headers = array(
+		"Accept" => "application/json",
+		"Content-Type" => "application/json",
+		"Apikey" => OMBIKEY
+	);
+	$body = array();
+	switch ($action) {
+		case 'plex-cache':
+			$api = curl_post(OMBIURL."/api/v1/Job/plexcontentcacher", $body, $headers);
+			break;
+		default:
+			break;
+	}
+	if(is_array($api) || is_object($api)){
+		switch ($api['http_code']['http_code']){
+			case 200:
+				return true;
+				break;
+			default:
+				return false;
+		}
+	}else{
+		return false;
+	}
+}
+
 function loadIcons(){
 	$dirname = "images/";
 	$images = scandir($dirname);