Parcourir la source

Merge pull request #255 from causefx/develop

Develop
causefx il y a 9 ans
Parent
commit
930cb7bb06
28 fichiers modifiés avec 946 ajouts et 832 suppressions
  1. 8 1
      .gitignore
  2. 76 1
      ajax.php
  3. 0 8
      ajax_remove_file.php
  4. 0 35
      ajax_upload_file.php
  5. 2 2
      check.php
  6. 0 5
      config/configDefaults.php
  7. 3 9
      error.php
  8. 462 265
      functions.php
  9. 9 10
      homepage.php
  10. 0 50
      image.php
  11. BIN
      images/gear.png
  12. BIN
      images/mail.png
  13. BIN
      images/paint.png
  14. BIN
      images/security.png
  15. 50 57
      index.php
  16. 2 2
      js/custom.js
  17. 4 2
      lang/de.ini
  18. 4 2
      lang/en.ini
  19. 4 2
      lang/es.ini
  20. 4 2
      lang/fr.ini
  21. 4 2
      lang/it.ini
  22. 4 2
      lang/nl.ini
  23. 4 2
      lang/pl.ini
  24. 291 249
      settings.php
  25. 0 29
      submitCSS.php
  26. 0 3
      translate.php
  27. 2 2
      updatedb.php
  28. 13 90
      user.php

+ 8 - 1
.gitignore

@@ -54,4 +54,11 @@ homepageSettings.ini.php
 loginLog.json
 loginLog.json
 custom.css
 custom.css
 _config.yml
 _config.yml
-test.php
+test.php
+users.db
+config/config.php
+config/users/
+config/users
+config/users.db
+
+

+ 76 - 1
ajax.php

@@ -1,9 +1,84 @@
 <?php
 <?php
+// Include functions if not already included
+require_once('functions.php');
+
+// Upgrade environment
+upgradeCheck();
+
+// Define Version
+ define('INSTALLEDVERSION', '1.31');
+
+// Lazyload settings
+$databaseConfig = configLazy('config/config.php');
+
 // Authorization
 // Authorization
 	# Check if user is currently active and allowed to access resource
 	# Check if user is currently active and allowed to access resource
+	//require_once("user.php");
+	# ^^ I think adding this does that?
 	
 	
-// Process Request
+// Get Action
+if (isset($_POST['submit'])) { $action = $_POST['submit']; }
+if (isset($_POST['action'])) { $action = $_POST['action']; }
+if (isset($_GET['action'])) { $action = $_GET['action']; }
+if (isset($_GET['a'])) { $action = $_GET['a']; }
+
+// No Action
+if (!isset($action)) {
+	debug_out('No Action Specified!',1);
+}
 
 
+// Process Request
+switch ($_SERVER['REQUEST_METHOD']) {
+	case 'GET':
+		switch ($action) {
+			case 'emby-image':
+				getEmbyImage();
+				break;
+			case 'plex-image':
+				getPlexImage();
+				break;
+			case 'emby-streams':
+				echo getEmbyStreams(12);
+				break;
+			case 'plex-streams':
+				echo getPlexStreams(12);
+				break;
+			case 'emby-recent':
+				echo getEmbyRecent($_GET['type'], 12);
+				break;
+			case 'plex-recent':
+				echo getPlexRecent($_GET['type'], 12);
+				break;
+			
+			default:
+				debug_out('Unsupported Action!',1);
+		}
+		break;
+	case 'POST':
+		switch ($action) {
+			case 'upload-images':
+				uploadFiles('images/', array('jpg', 'png', 'svg', 'jpeg', 'bmp'));
+				break;
+			case 'remove-images':
+				removeFiles('images/'.(isset($_POST['file'])?$_POST['file']:''));
+				break;
+			case 'editCSS':
+				write_ini_file($_POST["css-show"], "custom.css");
+				echo '<script>window.top.location = window.top.location.href.split(\'#\')[0];</script>';
+				break;
+			default:
+				debug_out('Unsupported Action!',1);
+		}
+		break;
+	case 'PUT':
+		
+		break;
+	case 'DELETE':
+		
+		break;
+	default:
+		debug_out('Unknown Request Type!',1);
+}
 
 
 
 
 
 

+ 0 - 8
ajax_remove_file.php

@@ -1,8 +0,0 @@
-<?php
-if(isset($_POST['file'])){
-    $file = 'images/' . $_POST['file'];
-    if(file_exists($file)){
-        unlink($file);
-    }
-}
-?>

+ 0 - 35
ajax_upload_file.php

@@ -1,35 +0,0 @@
-<?php
-    include('class.uploader.php');
-
-    $uploader = new Uploader();
-    $data = $uploader->upload($_FILES['files'], array(
-        'limit' => 10, //Maximum Limit of files. {null, Number}
-        'maxSize' => 1, //Maximum Size of files {null, Number(in MB's)}
-        'extensions' => array('jpg', 'png', 'svg'), //Whitelist for file extension. {null, Array(ex: array('jpg', 'png'))}
-        'required' => false, //Minimum one file is required for upload {Boolean}
-        'uploadDir' => 'images/', //Upload directory {String}
-        'title' => array('name'), //New file name {null, String, Array} *please read documentation in README.md
-        'removeFiles' => true, //Enable file exclusion {Boolean(extra for jQuery.filer), String($_POST field name containing json data with file names)}
-        'replace' => true, //Replace the file if it already exists  {Boolean}
-        'perms' => null, //Uploaded file permisions {null, Number}
-        'onCheck' => null, //A callback function name to be called by checking a file for errors (must return an array) | ($file) | Callback
-        'onError' => null, //A callback function name to be called if an error occured (must return an array) | ($errors, $file) | Callback
-        'onSuccess' => null, //A callback function name to be called if all files were successfully uploaded | ($files, $metas) | Callback
-        'onUpload' => null, //A callback function name to be called if all files were successfully uploaded (must return an array) | ($file) | Callback
-        'onComplete' => null, //A callback function name to be called when upload is complete | ($file) | Callback
-        'onRemove' => null //A callback function name to be called by removing files (must return an array) | ($removed_files) | Callback
-    ));
-
-    if($data['isComplete']){
-        $files = $data['data'];
-
-        echo json_encode($files['metas'][0]['name']);
-    }
-
-    if($data['hasErrors']){
-        $errors = $data['errors'];
-        echo json_encode($errors);
-    }
-
-    exit;
-?>

+ 2 - 2
check.php

@@ -116,7 +116,7 @@ function getFilePermission($file) {
     endif;
     endif;
 }
 }
 
 
-$db = DATABASE_LOCATION  . constant('User::DATABASE_NAME') . ".db";
+$db = DATABASE_LOCATION.'users.db';
 $folder = USER_HOME;
 $folder = USER_HOME;
 
 
 ?>
 ?>
@@ -192,4 +192,4 @@ $folder = USER_HOME;
 
 
     </body>
     </body>
 
 
-</html>
+</html>

+ 0 - 5
config/configDefaults.php

@@ -4,14 +4,12 @@ return array(
 	"user_home" => false,
 	"user_home" => false,
 	"timezone" => "",
 	"timezone" => "",
 	"plexURL" => "",
 	"plexURL" => "",
-	"plexPort" => "",
 	"plexToken" => "",
 	"plexToken" => "",
 	"plexRecentMovie" => "false",
 	"plexRecentMovie" => "false",
 	"plexRecentTV" => "false",
 	"plexRecentTV" => "false",
 	"plexRecentMusic" => "false",
 	"plexRecentMusic" => "false",
 	"plexPlayingNow" => "false",
 	"plexPlayingNow" => "false",
 	"embyURL" => "",
 	"embyURL" => "",
-	"embyPort" => "",
 	"embyToken" => "",
 	"embyToken" => "",
 	"embyRecentMovie" => "false",
 	"embyRecentMovie" => "false",
 	"embyRecentTV" => "false",
 	"embyRecentTV" => "false",
@@ -24,14 +22,11 @@ return array(
 	"radarrURL" => "",
 	"radarrURL" => "",
 	"radarrKey" => "",
 	"radarrKey" => "",
 	"nzbgetURL" => "",
 	"nzbgetURL" => "",
-	"nzbgetPort" => "",
 	"nzbgetUsername" => "",
 	"nzbgetUsername" => "",
 	"nzbgetPassword" => "",
 	"nzbgetPassword" => "",
 	"sabnzbdURL" => "",
 	"sabnzbdURL" => "",
-	"sabnzbdPort" => "",
 	"sabnzbdKey" => "",
 	"sabnzbdKey" => "",
 	"headphonesURL" => "",
 	"headphonesURL" => "",
-	"headphonesPort" => "",
 	"headphonesKey" => "",
 	"headphonesKey" => "",
 	"calendarStart" => "0",
 	"calendarStart" => "0",
 	"calendarView" => "basicWeek",
 	"calendarView" => "basicWeek",

+ 3 - 9
error.php

@@ -45,17 +45,11 @@ $data = false;
 ini_set("display_errors", 1);
 ini_set("display_errors", 1);
 ini_set("error_reporting", E_ALL | E_STRICT);
 ini_set("error_reporting", E_ALL | E_STRICT);
 
 
-function registration_callback($username, $email, $userdir)
-{
-    global $data;
-    $data = array($username, $email, $userdir);
-}
-
 require_once("user.php");
 require_once("user.php");
-require_once("translate.php");
+require_once("functions.php");
 $USER = new User("registration_callback");
 $USER = new User("registration_callback");
 
 
-$dbfile = DATABASE_LOCATION  . constant('User::DATABASE_NAME') . ".db";
+$dbfile = DATABASE_LOCATION.'users.db';
 
 
 $file_db = new PDO("sqlite:" . $dbfile);
 $file_db = new PDO("sqlite:" . $dbfile);
 $file_db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
 $file_db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
@@ -191,4 +185,4 @@ endif;
 
 
     </body>
     </body>
 
 
-</html>
+</html>

+ 462 - 265
functions.php

@@ -8,17 +8,20 @@ function debug_out($variable, $die = false) {
 }
 }
 
 
 // ==== Auth Plugins START ====
 // ==== Auth Plugins START ====
-// Pass credentials to LDAP backend
-function plugin_auth_ldap($username, $password) {
-	// returns true or false
-	$ldap = ldap_connect(AUTHBACKENDHOST.(AUTHBACKENDPORT?':'.AUTHBACKENDPORT:'389'));
-	if ($bind = ldap_bind($ldap, AUTHBACKENDDOMAIN.'\\'.$username, $password)) {
-		return true;
-	} else {
+
+if (function_exists('ldap_connect')) :
+	// Pass credentials to LDAP backend
+	function plugin_auth_ldap($username, $password) {
+		// returns true or false
+		$ldap = ldap_connect(AUTHBACKENDHOST.(AUTHBACKENDPORT?':'.AUTHBACKENDPORT:'389'));
+		if ($bind = ldap_bind($ldap, AUTHBACKENDDOMAIN.'\\'.$username, $password)) {
+			return true;
+		} else {
+			return false;
+		}
 		return false;
 		return false;
 	}
 	}
-	return false;
-}
+endif;
 
 
 // Pass credentials to FTP backend
 // Pass credentials to FTP backend
 function plugin_auth_ftp($username, $password) {
 function plugin_auth_ftp($username, $password) {
@@ -44,60 +47,6 @@ function plugin_auth_ftp($username, $password) {
 	return false;
 	return false;
 }
 }
 
 
-// Authenticate Against Emby Local (first) and Emby Connect
-function plugin_auth_emby_all($username, $password) {
-	return plugin_auth_emby_local($username, $password) || plugin_auth_emby_connect($username, $password);
-}
-
-// Authenicate against emby connect
-function plugin_auth_emby_connect($username, $password) {
-	$urlCheck = stripos(AUTHBACKENDHOST, "http");
-	if ($urlCheck === false) {
-		$embyAddress = "http://" . AUTHBACKENDHOST;
-	} else {
-		$embyAddress = AUTHBACKENDHOST;	
-	}
-	if(AUTHBACKENDPORT !== "") { $embyAddress .= ":" . AUTHBACKENDPORT; }
-	
-	// Get A User
-	$connectId = '';
-	$userIds = json_decode(file_get_contents($embyAddress.'/Users?api_key='.EMBYTOKEN),true);
-	if (is_array($userIds)) {
-		foreach ($userIds as $key => $value) { // Scan for this user
-			if (isset($value['ConnectUserName']) && isset($value['ConnectUserId'])) { // Qualifty as connect account
-				if ($value['ConnectUserName'] == $username || $value['Name'] == $username) {
-					$connectId = $value['ConnectUserId'];
-					break;
-				}
-				
-			}
-		}
-		
-		if ($connectId) {
-			$connectURL = 'https://connect.emby.media/service/user/authenticate';
-			$headers = array(
-				'Accept'=> 'application/json',
-				'Content-Type' => 'application/x-www-form-urlencoded',
-			);
-			$body = array(
-				'nameOrEmail' => $username,
-				'rawpw' => $password,
-			);
-			
-			$result = curl_post($connectURL, $body, $headers);
-			
-			if (isset($result['content'])) {
-				$json = json_decode($result['content'], true);
-				if (is_array($json) && isset($json['AccessToken']) && isset($json['User']) && $json['User']['Id'] == $connectId) {
-					return true;
-				}
-			}
-		}
-	}
-	
-	return false;
-}
-
 // Pass credentials to Emby Backend
 // Pass credentials to Emby Backend
 function plugin_auth_emby_local($username, $password) {
 function plugin_auth_emby_local($username, $password) {
 	$urlCheck = stripos(AUTHBACKENDHOST, "http");
 	$urlCheck = stripos(AUTHBACKENDHOST, "http");
@@ -134,47 +83,113 @@ function plugin_auth_emby_local($username, $password) {
 	return false;
 	return false;
 }
 }
 
 
-// Pass credentials to Plex Backend
-function plugin_auth_plex($username, $password) {
-    //Get User List
-    $approvedUsers = array();
-    $userURL = 'https://plex.tv/pms/friends/all';
-    $userHeaders = array(
-        'Authorization' => 'Basic '.base64_encode(PLEXUSERNAME.':'.PLEXPASSWORD), 
-    );
-    $userXML = simplexml_load_string(curl_get($userURL, $userHeaders));
-    //Build User List array
-    foreach($userXML AS $child) {
-        if(isset($child['username']) && $child['username'] != ""){
-            array_push($approvedUsers, $child['username']);
-        }
-    }
-    //Check If User Is Approved
-    if(!in_arrayi("$username", $approvedUsers)){
-        return false;
-    }
-    //Login User
-    $connectURL = 'https://plex.tv/users/sign_in.json';
-    $headers = array(
-        'Accept'=> 'application/json',
-        'Content-Type' => 'application/x-www-form-urlencoded',
-        'X-Plex-Product' => 'Organizr',
-        'X-Plex-Version' => '1.0',
-        'X-Plex-Client-Identifier' => '01010101-10101010',
-    );
-    $body = array(
-        'user[login]' => $username,
-        'user[password]' => $password,
-    );
-    $result = curl_post($connectURL, $body, $headers);
-    if (isset($result['content'])) {
-        $json = json_decode($result['content'], true);
-        if (is_array($json) && isset($json['user']) && isset($json['user']['username']) && $json['user']['username'] == $username) {
-            return true;
-        }
-    }
-    return false;
-}
+if (function_exists('curl_version')) :
+	// Authenticate Against Emby Local (first) and Emby Connect
+	function plugin_auth_emby_all($username, $password) {
+		return plugin_auth_emby_local($username, $password) || plugin_auth_emby_connect($username, $password);
+	}
+	
+	// Authenicate against emby connect
+	function plugin_auth_emby_connect($username, $password) {
+		$urlCheck = stripos(AUTHBACKENDHOST, "http");
+		if ($urlCheck === false) {
+			$embyAddress = "http://" . AUTHBACKENDHOST;
+		} else {
+			$embyAddress = AUTHBACKENDHOST;	
+		}
+		if(AUTHBACKENDPORT !== "") { $embyAddress .= ":" . AUTHBACKENDPORT; }
+		
+		// Get A User
+		$connectId = '';
+		$userIds = json_decode(file_get_contents($embyAddress.'/Users?api_key='.EMBYTOKEN),true);
+		if (is_array($userIds)) {
+			foreach ($userIds as $key => $value) { // Scan for this user
+				if (isset($value['ConnectUserName']) && isset($value['ConnectUserId'])) { // Qualifty as connect account
+					if ($value['ConnectUserName'] == $username || $value['Name'] == $username) {
+						$connectId = $value['ConnectUserId'];
+						break;
+					}
+					
+				}
+			}
+			
+			if ($connectId) {
+				$connectURL = 'https://connect.emby.media/service/user/authenticate';
+				$headers = array(
+					'Accept'=> 'application/json',
+					'Content-Type' => 'application/x-www-form-urlencoded',
+				);
+				$body = array(
+					'nameOrEmail' => $username,
+					'rawpw' => $password,
+				);
+				
+				$result = curl_post($connectURL, $body, $headers);
+				
+				if (isset($result['content'])) {
+					$json = json_decode($result['content'], true);
+					if (is_array($json) && isset($json['AccessToken']) && isset($json['User']) && $json['User']['Id'] == $connectId) {
+						return true;
+					}
+				}
+			}
+		}
+		
+		return false;
+	}
+
+	// Pass credentials to Plex Backend
+	function plugin_auth_plex($username, $password) {
+		// Quick out
+		if ((strtolower(PLEXUSERNAME) == strtolower($username)) && $password == PLEXPASSWORD) {
+			return true;
+		}
+		
+		//Get User List
+		$approvedUsers = array();
+		$userURL = 'https://plex.tv/pms/friends/all';
+		$userHeaders = array(
+			'Authorization' => 'Basic '.base64_encode(PLEXUSERNAME.':'.PLEXPASSWORD), 
+		);
+		$userXML = simplexml_load_string(curl_get($userURL, $userHeaders));
+		
+		if (is_array($userXML) || is_object($userXML)) {
+			//Build User List array
+			$isUser = false;
+			$usernameLower = strtolower($username);
+			foreach($userXML AS $child) {
+				if(isset($child['username']) && strtolower($child['username']) == $usernameLower) {
+					$isUser = true;
+					break;
+				}
+			}
+			
+			if ($isUser) {
+				//Login User
+				$connectURL = 'https://plex.tv/users/sign_in.json';
+				$headers = array(
+					'Accept'=> 'application/json',
+					'Content-Type' => 'application/x-www-form-urlencoded',
+					'X-Plex-Product' => 'Organizr',
+					'X-Plex-Version' => '1.0',
+					'X-Plex-Client-Identifier' => '01010101-10101010',
+				);
+				$body = array(
+					'user[login]' => $username,
+					'user[password]' => $password,
+				);
+				$result = curl_post($connectURL, $body, $headers);
+				if (isset($result['content'])) {
+					$json = json_decode($result['content'], true);
+					if (is_array($json) && isset($json['user']) && isset($json['user']['username']) && $json['user']['username'] == $username) {
+						return true;
+					}
+				}
+			}
+		}
+		return false;
+	}
+endif;
 // ==== Auth Plugins END ====
 // ==== Auth Plugins END ====
 // ==== General Class Definitions START ====
 // ==== General Class Definitions START ====
 class setLanguage { 
 class setLanguage { 
@@ -231,62 +246,66 @@ function post_router($url, $data, $headers = array(), $referer='') {
 	}
 	}
 }
 }
 
 
-// Curl Post
-function curl_post($url, $data, $headers = array(), $referer='') {
-	// Initiate cURL
-	$curlReq = curl_init($url);
-	// As post request
-	curl_setopt($curlReq, CURLOPT_CUSTOMREQUEST, "POST"); 
-	curl_setopt($curlReq, CURLOPT_RETURNTRANSFER, true);
-	// Format Data
-	switch (isset($headers['Content-Type'])?$headers['Content-Type']:'') {
-		case 'application/json': 
-			curl_setopt($curlReq, CURLOPT_POSTFIELDS, json_encode($data));
-			break;
-		case 'application/x-www-form-urlencoded';
-			curl_setopt($curlReq, CURLOPT_POSTFIELDS, http_build_query($data));
-			break;
-		default:
-			$headers['Content-Type'] = 'application/x-www-form-urlencoded';
-			curl_setopt($curlReq, CURLOPT_POSTFIELDS, http_build_query($data));
-	}
-	// Format Headers
-	$cHeaders = array();
-	foreach ($headers as $k => $v) {
-		$cHeaders[] = $k.': '.$v;
+if (function_exists('curl_version')) :
+	// Curl Post
+	function curl_post($url, $data, $headers = array(), $referer='') {
+		// Initiate cURL
+		$curlReq = curl_init($url);
+		// As post request
+		curl_setopt($curlReq, CURLOPT_CUSTOMREQUEST, "POST"); 
+		curl_setopt($curlReq, CURLOPT_RETURNTRANSFER, true);
+		// Format Data
+		switch (isset($headers['Content-Type'])?$headers['Content-Type']:'') {
+			case 'application/json': 
+				curl_setopt($curlReq, CURLOPT_POSTFIELDS, json_encode($data));
+				break;
+			case 'application/x-www-form-urlencoded';
+				curl_setopt($curlReq, CURLOPT_POSTFIELDS, http_build_query($data));
+				break;
+			default:
+				$headers['Content-Type'] = 'application/x-www-form-urlencoded';
+				curl_setopt($curlReq, CURLOPT_POSTFIELDS, http_build_query($data));
+		}
+		// Format Headers
+		$cHeaders = array();
+		foreach ($headers as $k => $v) {
+			$cHeaders[] = $k.': '.$v;
+		}
+		if (count($cHeaders)) {
+			curl_setopt($curlReq, CURLOPT_HTTPHEADER, $cHeaders);
+		}
+		// Execute
+		$result = curl_exec($curlReq);
+		// Close
+		curl_close($curlReq);
+		// Return
+		return array('content'=>$result);
 	}
 	}
-	if (count($cHeaders)) {
-		curl_setopt($curlReq, CURLOPT_HTTPHEADER, $cHeaders);
+
+	//Curl Get Function
+	function curl_get($url, $headers = array()) {
+		// Initiate cURL
+		$curlReq = curl_init($url);
+		// As post request
+		curl_setopt($curlReq, CURLOPT_CUSTOMREQUEST, "GET"); 
+		curl_setopt($curlReq, CURLOPT_RETURNTRANSFER, true);
+		// Format Headers
+		$cHeaders = array();
+		foreach ($headers as $k => $v) {
+			$cHeaders[] = $k.': '.$v;
+		}
+		if (count($cHeaders)) {
+			curl_setopt($curlReq, CURLOPT_HTTPHEADER, $cHeaders);
+		}
+		// Execute
+		$result = curl_exec($curlReq);
+		// Close
+		curl_close($curlReq);
+		// Return
+		return $result;
 	}
 	}
-	// Execute
-	$result = curl_exec($curlReq);
-	// Close
-	curl_close($curlReq);
-	// Return
-	return array('content'=>$result);
-}
-//Curl Get Function
-function curl_get($url, $headers = array()) {
-    // Initiate cURL
-    $curlReq = curl_init($url);
-    // As post request
-    curl_setopt($curlReq, CURLOPT_CUSTOMREQUEST, "GET"); 
-    curl_setopt($curlReq, CURLOPT_RETURNTRANSFER, true);
-    // Format Headers
-    $cHeaders = array();
-    foreach ($headers as $k => $v) {
-        $cHeaders[] = $k.': '.$v;
-    }
-    if (count($cHeaders)) {
-        curl_setopt($curlReq, CURLOPT_HTTPHEADER, $cHeaders);
-    }
-    // Execute
-    $result = curl_exec($curlReq);
-    // Close
-    curl_close($curlReq);
-    // Return
-    return $result;
-}
+endif;
+
 //Case-Insensitive Function
 //Case-Insensitive Function
 function in_arrayi($needle, $haystack) {
 function in_arrayi($needle, $haystack) {
     return in_array(strtolower($needle), array_map('strtolower', $haystack));
     return in_array(strtolower($needle), array_map('strtolower', $haystack));
@@ -408,7 +427,7 @@ function resolveEmbyItem($address, $token, $item) {
 	}
 	}
 	
 	
 	// Assemble Item And Cache Into Array 
 	// Assemble Item And Cache Into Array 
-	return '<div class="item"><a href="'.$address.'/web/itemdetails.html?id='.$item['Id'].'" target="_blank"><img alt="'.$item['Name'].'" class="'.$image.'" src="image.php?source=emby&img='.$imageId.'&height='.$height.'&width='.$width.'"></a><div class="carousel-caption" style="'.$style.'"><h4>'.$title.'</h4><small><em>'.$itemDetails['Overview'].'</em></small></div></div>';
+	return '<div class="item"><a href="'.$address.'/web/itemdetails.html?id='.$item['Id'].'" target="_blank"><img alt="'.$item['Name'].'" class="'.$image.'" src="ajax.php?a=emby-image&img='.$imageId.'&height='.$height.'&width='.$width.'"></a><div class="carousel-caption" style="'.$style.'"><h4>'.$title.'</h4><small><em>'.$itemDetails['Overview'].'</em></small></div></div>';
 }
 }
 
 
 // Format item from Plex for Carousel
 // Format item from Plex for Carousel
@@ -447,11 +466,11 @@ function resolvePlexItem($server, $token, $item) {
 	}
 	}
 	
 	
 	// Assemble Item And Cache Into Array 
 	// Assemble Item And Cache Into Array 
-	return '<div class="item"><a href="'.$address.'" target="_blank"><img alt="'.$item['Name'].'" class="'.$image.'" src="image.php?source=plex&img='.$item['thumb'].'&height='.$height.'&width='.$width.'"></a><div class="carousel-caption" style="'.$style.'"><h4>'.$title.'</h4><small><em>'.$summary.'</em></small></div></div>';
+	return '<div class="item"><a href="'.$address.'" target="_blank"><img alt="'.$item['Name'].'" class="'.$image.'" src="image.php?a=plex-image&img='.$item['thumb'].'&height='.$height.'&width='.$width.'"></a><div class="carousel-caption" style="'.$style.'"><h4>'.$title.'</h4><small><em>'.$summary.'</em></small></div></div>';
 }
 }
 
 
 // Create Carousel
 // Create Carousel
-function outputCarousel($header, $size, $type, $items) {
+function outputCarousel($header, $size, $type, $items, $script = false) {
 	// If None Populate Empty Item
 	// If None Populate Empty Item
 	if (!count($items)) {
 	if (!count($items)) {
 		$items = array('<div class="item"><img alt="nada" class="carousel-image movie" src="images/nadaplaying.jpg"><div class="carousel-caption"><h4>Nothing To Show</h4><small><em>Get Some Stuff Going!</em></small></div></div>');
 		$items = array('<div class="item"><img alt="nada" class="carousel-image movie" src="images/nadaplaying.jpg"><div class="carousel-caption"><h4>Nothing To Show</h4><small><em>Get Some Stuff Going!</em></small></div></div>');
@@ -474,90 +493,88 @@ function outputCarousel($header, $size, $type, $items) {
 		<div id="carousel-'.$type.'" class="carousel slide box-shadow white-bg" data-ride="carousel"><div class="carousel-inner" role="listbox">
 		<div id="carousel-'.$type.'" class="carousel slide box-shadow white-bg" data-ride="carousel"><div class="carousel-inner" role="listbox">
 			'.implode('',$items).'
 			'.implode('',$items).'
 		</div>'.$buttons.'
 		</div>'.$buttons.'
-	</div></div>'; 
+	</div></div>'.($script?'<script>'.$script.'</script>':''); 
 }
 }
 
 
 // Get Now Playing Streams From Emby
 // Get Now Playing Streams From Emby
-function getEmbyStreams($url, $port, $token, $size, $header) {
-    if (stripos($url, "http") === false) {
-        $url = "http://" . $url;
-    }
-    
-    if ($port !== "") { 
-		$url = $url . ":" . $port;
-	}
-    
-    $address = $url;
+function getEmbyStreams($size) {
+	$address = qualifyURL(EMBYURL);
 	
 	
-	$api = json_decode(file_get_contents($address.'/Sessions?api_key='.$token),true);
+	$api = json_decode(file_get_contents($address.'/Sessions?api_key='.EMBYTOKEN),true);
 	
 	
 	$playingItems = array();
 	$playingItems = array();
 	foreach($api as $key => $value) {
 	foreach($api as $key => $value) {
 		if (isset($value['NowPlayingItem'])) {
 		if (isset($value['NowPlayingItem'])) {
-			$playingItems[] = resolveEmbyItem($address, $token, $value['NowPlayingItem']);
+			$playingItems[] = resolveEmbyItem($address, EMBYTOKEN, $value['NowPlayingItem']);
 		}
 		}
 	}
 	}
 	
 	
-	return outputCarousel($header, $size, 'streams-emby', $playingItems);
+	return outputCarousel(translate('PLAYING_NOW_ON_EMBY'), $size, 'streams-emby', $playingItems, "
+		setInterval(function() {
+			$('<div></div>').load('ajax.php?a=emby-streams',function() {
+				var element = $(this).find('[id]');
+				var loadedID = 	element.attr('id');
+				$('#'+loadedID).replaceWith(element);
+				console.log('Loaded updated: '+loadedID);
+			});
+		}, 10000);
+	");
 }
 }
 
 
 // Get Now Playing Streams From Plex
 // Get Now Playing Streams From Plex
-function getPlexStreams($url, $port, $token, $size, $header){
-    if (stripos($url, "http") === false) {
-        $url = "http://" . $url;
-    }
-    
-    if ($port !== "") { 
-		$url = $url . ":" . $port;
-	}
-    
-    $address = $url;
+function getPlexStreams($size){
+    $address = qualifyURL(PLEXURL);
     
     
 	// Perform API requests
 	// Perform API requests
-    $api = file_get_contents($address."/status/sessions?X-Plex-Token=".$token);
+    $api = file_get_contents($address."/status/sessions?X-Plex-Token=".PLEXTOKEN);
     $api = simplexml_load_string($api);
     $api = simplexml_load_string($api);
-    $getServer = simplexml_load_string(file_get_contents($address."/?X-Plex-Token=".$token));
+    $getServer = simplexml_load_string(file_get_contents($address."/?X-Plex-Token=".PLEXTOKEN));
     
     
 	// Identify the local machine
 	// Identify the local machine
     $gotServer = $getServer['machineIdentifier'];
     $gotServer = $getServer['machineIdentifier'];
 	
 	
 	$items = array();
 	$items = array();
 	foreach($api AS $child) {
 	foreach($api AS $child) {
-		$items[] = resolvePlexItem($gotServer, $token, $child);
+		$items[] = resolvePlexItem($gotServer, PLEXTOKEN, $child);
 	}
 	}
 	
 	
-	return outputCarousel($header, $size, 'streams-plex', $items);
+	return outputCarousel(translate('PLAYING_NOW_ON_PLEX'), $size, 'streams-plex', $items, "
+		setInterval(function() {
+			$('<div></div>').load('ajax.php?a=plex-streams',function() {
+				var element = $(this).find('[id]');
+				var loadedID = 	element.attr('id');
+				$('#'+loadedID).replaceWith(element);
+				console.log('Loaded updated: '+loadedID);
+			});
+		}, 10000);
+	");
 }
 }
 
 
 // Get Recent Content From Emby
 // Get Recent Content From Emby
-function getEmbyRecent($url, $port, $type, $token, $size, $header) {
-    if (stripos($url, "http") === false) {
-        $url = "http://" . $url;
-    }
-    
-    if ($port !== "") { 
-		$url = $url . ":" . $port;
-	}
-    
-    $address = $url;
+function getEmbyRecent($type, $size) {
+    $address = qualifyURL(EMBYURL);
 	
 	
 	// Resolve Types
 	// Resolve Types
 	switch ($type) {
 	switch ($type) {
 		case 'movie':
 		case 'movie':
 			$embyTypeQuery = 'IncludeItemTypes=Movie&';
 			$embyTypeQuery = 'IncludeItemTypes=Movie&';
+			$header = translate('MOVIES');
 			break;
 			break;
 		case 'season':
 		case 'season':
 			$embyTypeQuery = 'IncludeItemTypes=Episode&';
 			$embyTypeQuery = 'IncludeItemTypes=Episode&';
+			$header = translate('TV_SHOWS');
 			break;
 			break;
 		case 'album':
 		case 'album':
 			$embyTypeQuery = 'IncludeItemTypes=MusicAlbum&';
 			$embyTypeQuery = 'IncludeItemTypes=MusicAlbum&';
+			$header = translate('MUSIC');
 			break;
 			break;
 		default:
 		default:
 			$embyTypeQuery = '';
 			$embyTypeQuery = '';
+			$header = translate('RECENT_CONTENT');
 	}
 	}
 	
 	
 	// Get A User
 	// Get A User
-	$userIds = json_decode(file_get_contents($address.'/Users?api_key='.$token),true);
+	$userIds = json_decode(file_get_contents($address.'/Users?api_key='.EMBYTOKEN),true);
 	foreach ($userIds as $value) { // Scan for admin user
 	foreach ($userIds as $value) { // Scan for admin user
 		$userId = $value['Id'];
 		$userId = $value['Id'];
 		if (isset($value['Policy']) && isset($value['Policy']['IsAdministrator']) && $value['Policy']['IsAdministrator']) {
 		if (isset($value['Policy']) && isset($value['Policy']['IsAdministrator']) && $value['Policy']['IsAdministrator']) {
@@ -566,33 +583,40 @@ function getEmbyRecent($url, $port, $type, $token, $size, $header) {
 	}
 	}
 	
 	
 	// Get the latest Items
 	// Get the latest Items
-	$latest = json_decode(file_get_contents($address.'/Users/'.$userId.'/Items/Latest?'.$embyTypeQuery.'EnableImages=false&api_key='.$token),true);
+	$latest = json_decode(file_get_contents($address.'/Users/'.$userId.'/Items/Latest?'.$embyTypeQuery.'EnableImages=false&api_key='.EMBYTOKEN),true);
 	
 	
 	// For Each Item In Category
 	// For Each Item In Category
 	$items = array();
 	$items = array();
 	foreach ($latest as $k => $v) {
 	foreach ($latest as $k => $v) {
-		$items[] = resolveEmbyItem($address, $token, $v);
+		$items[] = resolveEmbyItem($address, EMBYTOKEN, $v);
 	}
 	}
 	
 	
 	return outputCarousel($header, $size, $type.'-emby', $items);
 	return outputCarousel($header, $size, $type.'-emby', $items);
 }
 }
 
 
 // Get Recent Content From Plex
 // Get Recent Content From Plex
-function getPlexRecent($url, $port, $type, $token, $size, $header){
-    if (stripos($url, "http") === false) {
-        $url = "http://" . $url;
-    }
+function getPlexRecent($type, $size){
+    $address = qualifyURL(PLEXURL);
     
     
-    if ($port !== "") { 
-		$url = $url . ":" . $port;
+	// Resolve Types
+	switch ($type) {
+		case 'movie':
+			$header = translate('MOVIES');
+			break;
+		case 'season':
+			$header = translate('TV_SHOWS');
+			break;
+		case 'album':
+			$header = translate('MUSIC');
+			break;
+		default:
+			$header = translate('RECENT_CONTENT');
 	}
 	}
-    
-    $address = $url;
-    
+	
 	// Perform Requests
 	// Perform Requests
-    $api = file_get_contents($address."/library/recentlyAdded?X-Plex-Token=".$token);
+    $api = file_get_contents($address."/library/recentlyAdded?X-Plex-Token=".PLEXTOKEN);
     $api = simplexml_load_string($api);
     $api = simplexml_load_string($api);
-    $getServer = simplexml_load_string(file_get_contents($address."/?X-Plex-Token=".$token));
+    $getServer = simplexml_load_string(file_get_contents($address."/?X-Plex-Token=".PLEXTOKEN));
 	
 	
 	// Identify the local machine
 	// Identify the local machine
     $gotServer = $getServer['machineIdentifier'];
     $gotServer = $getServer['machineIdentifier'];
@@ -600,13 +624,48 @@ function getPlexRecent($url, $port, $type, $token, $size, $header){
 	$items = array();
 	$items = array();
 	foreach($api AS $child) {
 	foreach($api AS $child) {
 		if($child['type'] == $type){
 		if($child['type'] == $type){
-			$items[] = resolvePlexItem($gotServer, $token, $child);
+			$items[] = resolvePlexItem($gotServer, PLEXTOKEN, $child);
 		}
 		}
 	}
 	}
 	
 	
 	return outputCarousel($header, $size, $type.'-plex', $items);
 	return outputCarousel($header, $size, $type.'-plex', $items);
 }
 }
 
 
+// Get Image From Emby
+function getEmbyImage() {
+	$embyAddress = qualifyURL(EMBYURL);
+	
+	$itemId = $_GET['img'];
+	$imgParams = array();
+	if (isset($_GET['height'])) { $imgParams['height'] = 'maxHeight='.$_GET['height']; }
+	if (isset($_GET['width'])) { $imgParams['width'] = 'maxWidth='.$_GET['width']; }
+
+	if(isset($itemId)) {
+		$image_src = $embyAddress . '/Items/'.$itemId.'/Images/Primary?'.implode('&', $imgParams);
+		header('Content-type: image/jpeg');
+		readfile($image_src);
+	} else {
+		debug_out('Invalid Request',1);
+	}
+}
+
+// Get Image From Plex
+function getPlexImage() {
+	$plexAddress = qualifyURL(PLEXURL);
+	
+	$image_url = $_GET['img'];
+	$image_height = $_GET['height'];
+	$image_width = $_GET['width'];
+	
+	if(isset($image_url) && isset($image_height) && isset($image_width)) {
+		$image_src = $plexAddress . '/photo/:/transcode?height='.$image_height.'&width='.$image_width.'&upscale=1&url=' . $image_url . '&X-Plex-Token=' . PLEXTOKEN;
+		header('Content-type: image/jpeg');
+		readfile($image_src);
+	} else {
+		echo "Invalid Plex Request";	
+	}
+}
+
 // Simplier access to class
 // Simplier access to class
 function translate($string) {
 function translate($string) {
 	if (isset($GLOBALS['language'])) {
 	if (isset($GLOBALS['language'])) {
@@ -627,7 +686,7 @@ function randString($length = 10) {
 }
 }
 
 
 // Create config file in the return syntax
 // Create config file in the return syntax
-function createConfig($array, $path, $nest = 0) {
+function createConfig($array, $path = 'config/config.php', $nest = 0) {
 	$output = array();
 	$output = array();
 	foreach ($array as $k => $v) {
 	foreach ($array as $k => $v) {
 		$allowCommit = true;
 		$allowCommit = true;
@@ -671,7 +730,7 @@ function createConfig($array, $path, $nest = 0) {
 		fwrite($file, $output);
 		fwrite($file, $output);
 		fclose($file);
 		fclose($file);
 		if (file_exists($path)) {
 		if (file_exists($path)) {
-			unlink($path.'.bak');
+			@unlink($path.'.bak');
 			return true;
 			return true;
 		}
 		}
 		
 		
@@ -682,7 +741,7 @@ function createConfig($array, $path, $nest = 0) {
 }
 }
 
 
 // Load a config file written in the return syntax
 // Load a config file written in the return syntax
-function loadConfig($path) {
+function loadConfig($path = 'config/config.php') {
 	// Adapted from http://stackoverflow.com/a/14173339/6810513
 	// Adapted from http://stackoverflow.com/a/14173339/6810513
     if (!is_file($path)) {
     if (!is_file($path)) {
         return null;
         return null;
@@ -693,6 +752,22 @@ function loadConfig($path) {
 	}
 	}
 }
 }
 
 
+// Commit new values to the configuration
+function updateConfig($new, $current = false) {
+	// Get config if not supplied
+	if (!$current) {
+		$current = loadConfig();
+	}
+	
+	// Inject Parts
+	foreach ($new as $k => $v) {
+		$current[$k] = $v;
+	}
+	
+	// Return Create
+	return createConfig($current);
+}
+
 // Inject Defaults As Needed
 // Inject Defaults As Needed
 function fillDefaultConfig($array, $path = 'config/configDefaults.php') {
 function fillDefaultConfig($array, $path = 'config/configDefaults.php') {
 	if (is_string($path)) {
 	if (is_string($path)) {
@@ -701,20 +776,175 @@ function fillDefaultConfig($array, $path = 'config/configDefaults.php') {
 		$loadedDefaults = $path;
 		$loadedDefaults = $path;
 	}
 	}
 	
 	
-	function recurse($current, $defaults) {
-		foreach($defaults as $k => $v) {
-			if (!isset($current[$k])) {
-				$current[$k] = $v;
-			} else if (is_array($current[$k]) && is_array($v)) {
-				$current[$k] = recurse($current[$k], $v);
-			}
+	return (is_array($loadedDefaults) ? fillDefaultConfig_recurse($array, $loadedDefaults) : false);
+}
+
+// support function for fillDefaultConfig()
+function fillDefaultConfig_recurse($current, $defaults) {
+	foreach($defaults as $k => $v) {
+		if (!isset($current[$k])) {
+			$current[$k] = $v;
+		} else if (is_array($current[$k]) && is_array($v)) {
+			$current[$k] = fillDefaultConfig_recurse($current[$k], $v);
+		}
+	}
+	return $current;
+};
+
+// Define Scalar Variables (nest non-secular with underscores)
+function defineConfig($array, $anyCase = true, $nest_prefix = false) {	
+	foreach($array as $k => $v) {
+		if (is_scalar($v) && !defined($nest_prefix.$k)) {
+			define($nest_prefix.$k, $v, $anyCase);
+		} else if (is_array($v)) {
+			defineConfig($v, $anyCase, $nest_prefix.$k.'_');
+		}
+	}
+}
+
+// This function exists only because I am lazy
+function configLazy($path) {
+	$config = fillDefaultConfig(loadConfig($path));
+	if (is_array($config)) {
+		defineConfig($config);
+	}
+	return $config;
+}
+
+// Qualify URL
+function qualifyURL($url) {
+	// Get Digest
+	$digest = parse_url($url);
+	
+	// http/https
+	if (!isset($digest['scheme'])) {
+		if (isset($digest['port']) && in_array($digest['port'], array(80,8080,8096))) {
+			$scheme = 'http';
+		} else {
+			$scheme = 'https';
+		}
+	} else {
+		$scheme = $digest['scheme'];
+	}
+	
+	// Host
+	$host = (isset($digest['host'])?$digest['host']:'');
+	
+	// Port
+	$port = (isset($digest['port'])?':'.$digest['port']:'');
+	
+	// Path
+	$path = (isset($digest['path'])?$digest['path']:'');
+	
+	// Output
+	return $scheme.'://'.$host.$port.$path;
+}
+
+// Function to be called at top of each to allow upgrading environment as the spec changes
+function upgradeCheck() {
+	// Upgrade to 1.31
+	if (file_exists('homepageSettings.ini.php')) {
+		$databaseConfig = parse_ini_file('databaseLocation.ini.php', true);
+		$homepageConfig = parse_ini_file('homepageSettings.ini.php', true);
+		
+		$databaseConfig = array_merge($databaseConfig, $homepageConfig);
+		
+		$databaseData = '; <?php die("Access denied"); ?>' . "\r\n";
+		foreach($databaseConfig as $k => $v) {
+			if(substr($v, -1) == "/") : $v = rtrim($v, "/"); endif;
+			$databaseData .= $k . " = \"" . $v . "\"\r\n";
+		}
+		
+		write_ini_file($databaseData, 'databaseLocation.ini.php');
+		unlink('homepageSettings.ini.php');
+		unset($databaseData);
+		unset($homepageConfig);
+	}
+	
+	// Upgrade to 1.32
+	if (file_exists('databaseLocation.ini.php')) {
+		// Load Existing
+		$config = parse_ini_file('databaseLocation.ini.php', true);
+		
+		// Refactor
+		$config['database_Location'] = str_replace('//','/',$config['databaseLocation'].'/');
+		$config['user_home'] = $config['databaseLocation'].'users/';
+		unset($config['databaseLocation']);
+		
+		// Turn Off Emby And Plex Recent
+		$config["embyURL"] = $config["embyURL"].(!empty($config["embyPort"])?':'.$config["embyPort"]:'');
+		unset($config["embyPort"]);
+		$config["plexURL"] = $config["plexURL"].(!empty($config["plexPort"])?':'.$config["plexPort"]:'');
+		unset($config["plexPort"]);
+		$config["nzbgetURL"] = $config["nzbgetURL"].(!empty($config["nzbgetPort"])?':'.$config["nzbgetPort"]:'');
+		unset($config["nzbgetPort"]);
+		$config["sabnzbdURL"] = $config["sabnzbdURL"].(!empty($config["sabnzbdPort"])?':'.$config["sabnzbdPort"]:'');
+		unset($config["sabnzbdPort"]);
+		$config["headphonesURL"] = $config["headphonesURL"].(!empty($config["headphonesPort"])?':'.$config["headphonesPort"]:'');
+		unset($config["headphonesPort"]);
+		
+		$createConfigSuccess = createConfig($config, 'config/config.php', $nest = 0);
+		
+		// Create new config
+		if ($createConfigSuccess) {
+			// Make Config Dir (this should never happen as the dir and defaults file should be there);
+			@mkdir('config', 0775, true);
+			
+			// Remove Old ini file
+			unlink('databaseLocation.ini.php');
+		} else {
+			debug_out('Couldn\'t create updated configuration.' ,1);
 		}
 		}
-		return $current;
-	};
+	}
 	
 	
-	return (is_array($loadedDefaults) ? recurse($array, $loadedDefaults) : false);
+	return true;
+}
+
+// Check if all software dependancies are met
+function dependCheck() {
+	return true;
+}
+
+// Process file uploads
+function uploadFiles($path, $ext_mask = null) {
+	if (isset($_FILES) && count($_FILES)) {
+		require_once('class.uploader.php');
+
+		$uploader = new Uploader();
+		$data = $uploader->upload($_FILES['files'], array(
+			'limit' => 10,
+			'maxSize' => 10,
+			'extensions' => $ext_mask,
+			'required' => false,
+			'uploadDir' => str_replace('//','/',$path.'/'),
+			'title' => array('name'),
+			'removeFiles' => true,
+			'replace' => true,
+		));
+
+		if($data['isComplete']){
+			$files = $data['data'];
+
+			echo json_encode($files['metas'][0]['name']);
+		}
+
+		if($data['hasErrors']){
+			$errors = $data['errors'];
+			echo json_encode($errors);
+		}
+	} else {
+		echo json_encode('No files submitted!');
+	}
 }
 }
 
 
+// Remove file
+function removeFiles($path) {
+    if(is_file($path)) {
+        unlink($path);
+    } else {
+		echo json_encode('No file specified for removal!');
+	}
+}
 
 
 
 
 // ==============
 // ==============
@@ -1117,18 +1347,7 @@ function getRadarrCalendar($array){
 }
 }
 
 
 function nzbgetConnect($url, $port, $username, $password, $list){
 function nzbgetConnect($url, $port, $username, $password, $list){
-    
-    $urlCheck = stripos($url, "http");
-
-    if ($urlCheck === false) {
-        
-        $url = "http://" . $url;
-    
-    }
-    
-    if($port !== ""){ $url = $url . ":" . $port; }
-    
-    $address = $url;
+    $url = qualifyURL(NZBGETURL);
     
     
     $api = file_get_contents("$url/$username:$password/jsonrpc/$list");
     $api = file_get_contents("$url/$username:$password/jsonrpc/$list");
                     
                     
@@ -1187,18 +1406,7 @@ function nzbgetConnect($url, $port, $username, $password, $list){
 }
 }
 
 
 function sabnzbdConnect($url, $port, $key, $list){
 function sabnzbdConnect($url, $port, $key, $list){
-    
-    $urlCheck = stripos($url, "http");
-
-    if ($urlCheck === false) {
-        
-        $url = "http://" . $url;
-    
-    }
-    
-    if($port !== ""){ $url = $url . ":" . $port; }
-    
-    $address = $url;
+    $url = qualifyURL(SABNZBDURL);
 
 
     $api = file_get_contents("$url/api?mode=$list&output=json&apikey=$key");
     $api = file_get_contents("$url/api?mode=$list&output=json&apikey=$key");
                     
                     
@@ -1247,27 +1455,16 @@ function sabnzbdConnect($url, $port, $key, $list){
 }
 }
 
 
 function getHeadphonesCalendar($url, $port, $key, $list){
 function getHeadphonesCalendar($url, $port, $key, $list){
-
-    $urlCheck = stripos($url, "http");
-
-    if ($urlCheck === false) {
-        
-        $url = "http://" . $url;
+	$url = qualifyURL(HEADPHONESURL);
     
     
-    }
-    
-    if($port !== ""){ $url = $url . ":" . $port; }
-    
-    $address = $url;
+    $api = file_get_contents($url."/api?apikey=".$key."&cmd=$list");
     
     
-    $api = file_get_contents($address."/api?apikey=".$key."&cmd=$list");
-                    
     $api = json_decode($api, true);
     $api = json_decode($api, true);
     
     
     $i = 0;
     $i = 0;
     
     
     $gotCalendar = "";
     $gotCalendar = "";
-
+	
     foreach($api AS $child) {
     foreach($api AS $child) {
 
 
         if($child['Status'] == "Wanted"){
         if($child['Status'] == "Wanted"){

+ 9 - 10
homepage.php

@@ -6,7 +6,6 @@ ini_set("display_errors", 1);
 ini_set("error_reporting", E_ALL | E_STRICT);
 ini_set("error_reporting", E_ALL | E_STRICT);
 
 
 require_once("user.php");
 require_once("user.php");
-require_once("translate.php");
 require_once("functions.php");
 require_once("functions.php");
 use Kryptonit3\Sonarr\Sonarr;
 use Kryptonit3\Sonarr\Sonarr;
 use Kryptonit3\SickRage\SickRage;
 use Kryptonit3\SickRage\SickRage;
@@ -15,7 +14,7 @@ $radarr = new Sonarr(RADARRURL, RADARRKEY);
 $sickrage = new SickRage(SICKRAGEURL, SICKRAGEKEY);
 $sickrage = new SickRage(SICKRAGEURL, SICKRAGEKEY);
 $USER = new User("registration_callback");
 $USER = new User("registration_callback");
 
 
-$dbfile = DATABASE_LOCATION  . constant('User::DATABASE_NAME') . ".db";
+$dbfile = DATABASE_LOCATION.'users.db';
 
 
 $file_db = new PDO("sqlite:" . $dbfile);
 $file_db = new PDO("sqlite:" . $dbfile);
 $file_db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
 $file_db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
@@ -333,10 +332,10 @@ endif; ?>
                     if(PLEXPLAYINGNOW == "true"){ $plexSize++; }
                     if(PLEXPLAYINGNOW == "true"){ $plexSize++; }
                     if($plexSize >= 4){ $plexSize = 3; }elseif($plexSize == 3){ $plexSize = 4; }elseif($plexSize == 2){ $plexSize = 6; }elseif($plexSize == 1){ $plexSize = 12; }
                     if($plexSize >= 4){ $plexSize = 3; }elseif($plexSize == 3){ $plexSize = 4; }elseif($plexSize == 2){ $plexSize = 6; }elseif($plexSize == 1){ $plexSize = 12; }
                     
                     
-                    if(PLEXRECENTMOVIE == "true"){ echo getPlexRecent(PLEXURL, PLEXPORT, "movie", PLEXTOKEN, $plexSize, $language->translate("MOVIES")); }
-                    if(PLEXRECENTTV == "true"){ echo getPlexRecent(PLEXURL, PLEXPORT, "season", PLEXTOKEN, $plexSize, $language->translate("TV_SHOWS")); }
-                    if(PLEXRECENTMUSIC == "true"){ echo getPlexRecent(PLEXURL, PLEXPORT, "album", PLEXTOKEN, $plexSize, $language->translate("MUSIC")); }
-                    if(PLEXPLAYINGNOW == "true"){ echo getPlexStreams(PLEXURL, PLEXPORT, PLEXTOKEN, $plexSize, $language->translate("PLAYING_NOW_ON_PLEX")); }
+                    if(PLEXRECENTMOVIE == "true"){ echo getPlexRecent("movie", $plexSize); }
+                    if(PLEXRECENTTV == "true"){ echo getPlexRecent("season", $plexSize); }
+                    if(PLEXRECENTMUSIC == "true"){ echo getPlexRecent("album", $plexSize); }
+                    if(PLEXPLAYINGNOW == "true"){ echo getPlexStreams($plexSize); }
                     ?>
                     ?>
 
 
                 </div>
                 </div>
@@ -353,10 +352,10 @@ endif; ?>
                     if(EMBYPLAYINGNOW == "true"){ $embySize++; }
                     if(EMBYPLAYINGNOW == "true"){ $embySize++; }
                     if($embySize >= 4){ $embySize = 3; }elseif($embySize == 3){ $embySize = 4; }elseif($embySize == 2){ $embySize = 6; }elseif($embySize == 1){ $embySize = 12; }
                     if($embySize >= 4){ $embySize = 3; }elseif($embySize == 3){ $embySize = 4; }elseif($embySize == 2){ $embySize = 6; }elseif($embySize == 1){ $embySize = 12; }
                     
                     
-                    if(EMBYRECENTMOVIE == "true"){ echo getEmbyRecent(EMBYURL, EMBYPORT, "movie", EMBYTOKEN, $embySize, $language->translate("MOVIES")); }
-                    if(EMBYRECENTTV == "true"){ echo getEmbyRecent(EMBYURL, EMBYPORT, "season", EMBYTOKEN, $embySize, $language->translate("TV_SHOWS")); }
-                    if(EMBYRECENTMUSIC == "true"){ echo getEmbyRecent(EMBYURL, EMBYPORT, "album", EMBYTOKEN, $embySize, $language->translate("MUSIC")); }
-                    if(EMBYPLAYINGNOW == "true"){ echo getEmbyStreams(EMBYURL, EMBYPORT, EMBYTOKEN, $embySize, $language->translate("PLAYING_NOW_ON_EMBY")); }
+                    if(EMBYRECENTMOVIE == "true"){ echo getEmbyRecent("movie", $embySize); }
+                    if(EMBYRECENTTV == "true"){ echo getEmbyRecent("season", $embySize); }
+                    if(EMBYRECENTMUSIC == "true"){ echo getEmbyRecent("album", $embySize); }
+                    if(EMBYPLAYINGNOW == "true"){ echo getEmbyStreams($embySize); }
                     ?>
                     ?>
 
 
                 </div>
                 </div>

+ 0 - 50
image.php

@@ -1,50 +0,0 @@
-<?php
-
-require_once("user.php");
-
-$image_url = $_GET['img'];
-$image_height = $_GET['height'];
-$image_width = $_GET['width'];
-$image_source = (isset($_GET['source']) ? $_GET['source'] : 'plex');
-
-switch ($image_source) {
-	case 'emby':
-		$urlCheck = stripos(EMBYURL, "http");
-
-		if ($urlCheck === false) {
-			$embyAddress = "http://" . EMBYURL;
-		} else {
-			$embyAddress = EMBYURL;	
-		}
-		
-		if(EMBYPORT !== ""){ $embyAddress .= ":" . EMBYPORT; }
-		
-		if(isset($image_url) && isset($image_height) && isset($image_width)) {
-			$image_src = $embyAddress . '/Items/'.$image_url.'/Images/Primary?maxHeight='.$image_height.'&maxWidth='.$image_width;
-			header('Content-type: image/jpeg');
-			readfile($image_src);
-		} else {
-			echo "Invalid Emby Request";	
-		}
-		break;
-	case 'plex':
-	default:
-		$urlCheck = stripos(PLEXURL, "http");
-
-		if ($urlCheck === false) {
-			$plexAddress = "http://" . PLEXURL;
-		} else {
-			$plexAddress = PLEXURL;	
-		}
-		
-		if(PLEXPORT !== ""){ $plexAddress = $plexAddress . ":" . PLEXPORT; }
-		
-		if(isset($image_url) && isset($image_height) && isset($image_width)) {
-			$image_src = $plexAddress . '/photo/:/transcode?height='.$image_height.'&width='.$image_width.'&upscale=1&url=' . $image_url . '&X-Plex-Token=' . PLEXTOKEN;
-			header('Content-type: image/jpeg');
-			readfile($image_src);
-		} else {
-			echo "Invalid Plex Request";	
-		}
-		break;
-}

BIN
images/gear.png


BIN
images/mail.png


BIN
images/paint.png


BIN
images/security.png


+ 50 - 57
index.php

@@ -25,45 +25,40 @@ $loading = "#66D9EF";
 $hovertext = "#000000";
 $hovertext = "#000000";
 $loadingIcon = "images/organizr_logo_d.png";
 $loadingIcon = "images/organizr_logo_d.png";
 $baseURL = "";
 $baseURL = "";
-require_once("translate.php");
+
+// Load functions
 require_once("functions.php");
 require_once("functions.php");
 
 
-                
-if(isset($_POST['action'])) :
+//Upgrade Check
+upgradeCheck();
 
 
+// Get Action
+if(isset($_POST['action'])) {
     $action = $_POST['action'];
     $action = $_POST['action'];
-    
-endif;
-
-if($action == "createLocation") :
-
-    $databaseData = '; <?php die("Access denied"); ?>' . "\r\n";
-
-    foreach ($_POST as $postName => $postValue) {
-            
-        if($postName !== "action") :
-        
-            if(substr($postValue, -1) == "/") : $postValue = rtrim($postValue, "/"); endif;
-    
-            $postValue = str_replace("\\","/", $postValue);
-        
-            $databaseData .= $postName . " = \"" . $postValue . "\"\r\n";
-        
-        endif;
-        
-    }
-
-    write_ini_file($databaseData, $databaseLocation);
-
-endif;
-
-if(!file_exists($databaseLocation)) :
-
-    $configReady = "No";
-    $userpic = "";
-    $showPic = "";
-
-else :
+	unset($_POST['action']);
+}
+
+// Check for config file
+if(!file_exists('config/config.php')) {
+	if($action == "createLocation") {
+		if (isset($_POST['database_Location'])) {
+			$_POST['database_Location'] = str_replace('//','/',$_POST['database_Location'].'/');
+            if(substr($_POST['database_Location'], -1) != "/") : $_POST['database_Location'] = $_POST['database_Location'] . "/"; endif;
+			$_POST['USER_HOME'] = $_POST['database_Location'].'users/';
+		}
+		if (file_exists($_POST['database_Location'])) {
+			updateConfig($_POST);
+		} else {
+			debug_out('Dir doesn\'t exist: '.$_POST['database_Location'],1); // Pretty Up
+		}
+	} else {
+		$configReady = "No";
+		$userpic = "";
+		$showPic = "";
+	}
+}
+
+if (file_exists('config/config.php')) {
 
 
     $configReady = "Yes";
     $configReady = "Yes";
 
 
@@ -182,19 +177,17 @@ else :
 
 
         else: 
         else: 
         
         
-            //$showPic = "<login class='login-btn text-uppercase'>" . $language->translate("MENU") . "</login>";
             $showPic = "<i class=\"mdi mdi-account-box-outline\"></i>";
             $showPic = "<i class=\"mdi mdi-account-box-outline\"></i>";
 
 
         endif;
         endif;
 
 
     else : 
     else : 
 
 
-        //$showPic = "<img style='height: " . $userSize . "px'; src='images/login.png'>"; 
         $showPic = "<login class='login-btn text-uppercase'>" . $language->translate("LOGIN") . "</login>"; 
         $showPic = "<login class='login-btn text-uppercase'>" . $language->translate("LOGIN") . "</login>"; 
 
 
     endif;
     endif;
 
 
-endif;
+}
 
 
 if(!defined('SLIMBAR')) : define('SLIMBAR', 'true'); endif;
 if(!defined('SLIMBAR')) : define('SLIMBAR', 'true'); endif;
 if(!defined('AUTOHIDE')) : define('AUTOHIDE', 'false'); endif;
 if(!defined('AUTOHIDE')) : define('AUTOHIDE', 'false'); endif;
@@ -241,29 +234,29 @@ if(file_exists("images/settings2.png")) : $iconRotate = "false"; $settingsIcon =
 
 
         <title><?=$title;?><?php if($title !== "Organizr") :  echo " - Organizr"; endif; ?></title>
         <title><?=$title;?><?php if($title !== "Organizr") :  echo " - Organizr"; endif; ?></title>
 
 
-        <link rel="stylesheet" href="<?=$baseURL;?>bower_components/bootstrap/dist/css/bootstrap.min.css">
-        <link rel="stylesheet" href="<?=$baseURL;?>bower_components/font-awesome/css/font-awesome.min.css">
-        <link rel="stylesheet" href="<?=$baseURL;?>bower_components/mdi/css/materialdesignicons.min.css">
-        <link rel="stylesheet" href="<?=$baseURL;?>bower_components/metisMenu/dist/metisMenu.min.css">
-        <link rel="stylesheet" href="<?=$baseURL;?>bower_components/Waves/dist/waves.min.css"> 
-        <link rel="stylesheet" href="<?=$baseURL;?>bower_components/malihu-custom-scrollbar-plugin/jquery.mCustomScrollbar.css"> 
+        <link rel="stylesheet" href="<?=$baseURL;?>bower_components/bootstrap/dist/css/bootstrap.min.css?v=<?php echo INSTALLEDVERSION; ?>">
+        <link rel="stylesheet" href="<?=$baseURL;?>bower_components/font-awesome/css/font-awesome.min.css?v=<?php echo INSTALLEDVERSION; ?>">
+        <link rel="stylesheet" href="<?=$baseURL;?>bower_components/mdi/css/materialdesignicons.min.css?v=<?php echo INSTALLEDVERSION; ?>">
+        <link rel="stylesheet" href="<?=$baseURL;?>bower_components/metisMenu/dist/metisMenu.min.css?v=<?php echo INSTALLEDVERSION; ?>">
+        <link rel="stylesheet" href="<?=$baseURL;?>bower_components/Waves/dist/waves.min.css?v=<?php echo INSTALLEDVERSION; ?>">
+        <link rel="stylesheet" href="<?=$baseURL;?>bower_components/malihu-custom-scrollbar-plugin/jquery.mCustomScrollbar.css?v=<?php echo INSTALLEDVERSION; ?>">
 
 
-        <link rel="stylesheet" href="<?=$baseURL;?>js/selects/cs-select.css">
-        <link rel="stylesheet" href="<?=$baseURL;?>js/selects/cs-skin-elastic.css">
-        <link rel="stylesheet" href="<?=$baseURL;?>bower_components/google-material-color/dist/palette.css">
+        <link rel="stylesheet" href="<?=$baseURL;?>js/selects/cs-select.css?v=<?php echo INSTALLEDVERSION; ?>">
+        <link rel="stylesheet" href="<?=$baseURL;?>js/selects/cs-skin-elastic.css?v=<?php echo INSTALLEDVERSION; ?>">
+        <link rel="stylesheet" href="<?=$baseURL;?>bower_components/google-material-color/dist/palette.css?v=<?php echo INSTALLEDVERSION; ?>">
         
         
-        <link rel="stylesheet" href="<?=$baseURL;?>bower_components/sweetalert/dist/sweetalert.css">
-        <link rel="stylesheet" href="<?=$baseURL;?>bower_components/smoke/dist/css/smoke.min.css">
-        <link rel="stylesheet" href="<?=$baseURL;?>js/notifications/ns-style-growl.css">
-        <link rel="stylesheet" href="<?=$baseURL;?>js/notifications/ns-style-other.css">
+        <link rel="stylesheet" href="<?=$baseURL;?>bower_components/sweetalert/dist/sweetalert.css?v=<?php echo INSTALLEDVERSION; ?>">
+        <link rel="stylesheet" href="<?=$baseURL;?>bower_components/smoke/dist/css/smoke.min.css?v=<?php echo INSTALLEDVERSION; ?>">
+        <link rel="stylesheet" href="<?=$baseURL;?>js/notifications/ns-style-growl.css?v=<?php echo INSTALLEDVERSION; ?>">
+        <link rel="stylesheet" href="<?=$baseURL;?>js/notifications/ns-style-other.css?v=<?php echo INSTALLEDVERSION; ?>">
 
 
 
 
-        <script src="<?=$baseURL;?>js/menu/modernizr.custom.js"></script>
-        <script type="text/javascript" src="<?=$baseURL;?>js/sha1.js"></script>
-		<script type="text/javascript" src="<?=$baseURL;?>js/user.js"></script>
+        <script src="<?=$baseURL;?>js/menu/modernizr.custom.js?v=<?php echo INSTALLEDVERSION; ?>"></script>
+        <script type="text/javascript" src="<?=$baseURL;?>js/sha1.js?v=<?php echo INSTALLEDVERSION; ?>"></script>
+		<script type="text/javascript" src="<?=$baseURL;?>js/user.js?v=<?php echo INSTALLEDVERSION; ?>"></script>
 
 
         <link rel="stylesheet" href="<?=$baseURL;?>css/style.css?v=<?php echo INSTALLEDVERSION; ?>">
         <link rel="stylesheet" href="<?=$baseURL;?>css/style.css?v=<?php echo INSTALLEDVERSION; ?>">
-        <link rel="stylesheet" href="bower_components/animate.css/animate.min.css">
+        <link rel="stylesheet" href="bower_components/animate.css/animate.min.css?v=<?php echo INSTALLEDVERSION; ?>">
 
 
         <link rel="icon" type="image/png" href="<?=$baseURL;?>images/favicon/android-chrome-192x192.png" sizes="192x192">
         <link rel="icon" type="image/png" href="<?=$baseURL;?>images/favicon/android-chrome-192x192.png" sizes="192x192">
         <link rel="apple-touch-icon" sizes="180x180" href="<?=$baseURL;?>images/favicon/apple-touch-icon.png">
         <link rel="apple-touch-icon" sizes="180x180" href="<?=$baseURL;?>images/favicon/apple-touch-icon.png">
@@ -896,7 +889,7 @@ endif; ?>
 
 
                                             <div class="form-group">
                                             <div class="form-group">
 
 
-                                                <input type="text" class="form-control material" name="databaseLocation" autofocus value="<?php echo dirname(__DIR__);?>" autocorrect="off" autocapitalize="off" required>
+                                                <input type="text" class="form-control material" name="database_Location" autofocus value="<?php echo dirname(__DIR__);?>" autocorrect="off" autocapitalize="off" required>
                                                 
                                                 
                                                 <h5><?php echo $language->translate("SET_DATABASE_LOCATION");?></h5>
                                                 <h5><?php echo $language->translate("SET_DATABASE_LOCATION");?></h5>
                                                 
                                                 
@@ -906,7 +899,7 @@ endif; ?>
                                                 
                                                 
                                                 <?php 
                                                 <?php 
                                                 
                                                 
-                                                if(file_exists(dirname(__DIR__) . '/users.db') || file_exists(__DIR__ . '/users.db')) : 
+                                                if(file_exists(dirname(__DIR__) . '/users.db') || file_exists(__DIR__ . '/users.db') || file_exists(__DIR__ . '/config/users.db')) : 
                                                 
                                                 
                                                 echo '<h5 class="text-center red">';
                                                 echo '<h5 class="text-center red">';
                                                 echo $language->translate("DONT_WORRY");
                                                 echo $language->translate("DONT_WORRY");

+ 2 - 2
js/custom.js

@@ -80,7 +80,7 @@ $(document).ready(function(){
 			dragContainer: null,
 			dragContainer: null,
 		},
 		},
 		uploadFile: {
 		uploadFile: {
-			url: "./ajax_upload_file.php",
+			url: "./ajax.php?a=upload-images",
 			data: null,
 			data: null,
 			type: 'POST',
 			type: 'POST',
 			enctype: 'multipart/form-data',
 			enctype: 'multipart/form-data',
@@ -122,7 +122,7 @@ $(document).ready(function(){
 			var filerKit = inputEl.prop("jFiler"),
 			var filerKit = inputEl.prop("jFiler"),
 		        file_name = filerKit.files_list[id].name;
 		        file_name = filerKit.files_list[id].name;
 
 
-		    $.post('./ajax_remove_file.php', {file: file_name});
+		    $.post('./ajax.php?a=remove-images', {file: file_name});
 		},
 		},
 		onEmpty: null,
 		onEmpty: null,
 		options: null,
 		options: null,

+ 4 - 2
lang/de.ini

@@ -233,7 +233,9 @@ AUTHBACKENDPORT = "Backend Port (eg 21 for FTP, 389 for LDAP, 8096 for Emby)"
 AUTHBACKENDDOMAIN = "Domain to use for LDAP"
 AUTHBACKENDDOMAIN = "Domain to use for LDAP"
 PLEX_USERNAME = "Plex Username"
 PLEX_USERNAME = "Plex Username"
 PLEX_PASSWORD = "Plex Password"
 PLEX_PASSWORD = "Plex Password"
-BOTH = "Both"
+BOTH = "Plus Other"
 ONLY = "Only"
 ONLY = "Only"
 NO_CREATE = "Do Not Create Accounts"
 NO_CREATE = "Do Not Create Accounts"
-YES_CREATE = "Create Accounts As Needed"
+YES_CREATE = "Create Accounts As Needed"
+RECENT_CONTENT = "Recently Added Content"
+SETTINGS_SAVED = "Settings have been Saved"

+ 4 - 2
lang/en.ini

@@ -233,7 +233,9 @@ AUTHBACKENDPORT = "Backend Port (eg 21 for FTP, 389 for LDAP, 8096 for Emby)"
 AUTHBACKENDDOMAIN = "Domain to use for LDAP"
 AUTHBACKENDDOMAIN = "Domain to use for LDAP"
 PLEX_USERNAME = "Plex Username"
 PLEX_USERNAME = "Plex Username"
 PLEX_PASSWORD = "Plex Password"
 PLEX_PASSWORD = "Plex Password"
-BOTH = "Both"
+BOTH = "Plus Other"
 ONLY = "Only"
 ONLY = "Only"
 NO_CREATE = "Do Not Create Accounts"
 NO_CREATE = "Do Not Create Accounts"
-YES_CREATE = "Create Accounts As Needed"
+YES_CREATE = "Create Accounts As Needed"
+RECENT_CONTENT = "Recently Added Content"
+SETTINGS_SAVED = "Settings have been Saved"

+ 4 - 2
lang/es.ini

@@ -233,7 +233,9 @@ AUTHBACKENDPORT = "Backend Port (eg 21 for FTP, 389 for LDAP, 8096 for Emby)"
 AUTHBACKENDDOMAIN = "Domain to use for LDAP"
 AUTHBACKENDDOMAIN = "Domain to use for LDAP"
 PLEX_USERNAME = "Plex Username"
 PLEX_USERNAME = "Plex Username"
 PLEX_PASSWORD = "Plex Password"
 PLEX_PASSWORD = "Plex Password"
-BOTH = "Both"
+BOTH = "Plus Other"
 ONLY = "Only"
 ONLY = "Only"
 NO_CREATE = "Do Not Create Accounts"
 NO_CREATE = "Do Not Create Accounts"
-YES_CREATE = "Create Accounts As Needed"
+YES_CREATE = "Create Accounts As Needed"
+RECENT_CONTENT = "Recently Added Content"
+SETTINGS_SAVED = "Settings have been Saved"

+ 4 - 2
lang/fr.ini

@@ -233,7 +233,9 @@ AUTHBACKENDPORT = "Backend Port (eg 21 for FTP, 389 for LDAP, 8096 for Emby)"
 AUTHBACKENDDOMAIN = "Domain to use for LDAP"
 AUTHBACKENDDOMAIN = "Domain to use for LDAP"
 PLEX_USERNAME = "Plex Username"
 PLEX_USERNAME = "Plex Username"
 PLEX_PASSWORD = "Plex Password"
 PLEX_PASSWORD = "Plex Password"
-BOTH = "Both"
+BOTH = "Plus Other"
 ONLY = "Only"
 ONLY = "Only"
 NO_CREATE = "Do Not Create Accounts"
 NO_CREATE = "Do Not Create Accounts"
-YES_CREATE = "Create Accounts As Needed"
+YES_CREATE = "Create Accounts As Needed"
+RECENT_CONTENT = "Recently Added Content"
+SETTINGS_SAVED = "Settings have been Saved"

+ 4 - 2
lang/it.ini

@@ -233,7 +233,9 @@ AUTHBACKENDPORT = "Backend Port (eg 21 for FTP, 389 for LDAP, 8096 for Emby)"
 AUTHBACKENDDOMAIN = "Domain to use for LDAP"
 AUTHBACKENDDOMAIN = "Domain to use for LDAP"
 PLEX_USERNAME = "Plex Username"
 PLEX_USERNAME = "Plex Username"
 PLEX_PASSWORD = "Plex Password"
 PLEX_PASSWORD = "Plex Password"
-BOTH = "Both"
+BOTH = "Plus Other"
 ONLY = "Only"
 ONLY = "Only"
 NO_CREATE = "Do Not Create Accounts"
 NO_CREATE = "Do Not Create Accounts"
-YES_CREATE = "Create Accounts As Needed"
+YES_CREATE = "Create Accounts As Needed"
+RECENT_CONTENT = "Recently Added Content"
+SETTINGS_SAVED = "Settings have been Saved"

+ 4 - 2
lang/nl.ini

@@ -233,7 +233,9 @@ AUTHBACKENDPORT = "Backend Port (eg 21 for FTP, 389 for LDAP, 8096 for Emby)"
 AUTHBACKENDDOMAIN = "Domain to use for LDAP"
 AUTHBACKENDDOMAIN = "Domain to use for LDAP"
 PLEX_USERNAME = "Plex Username"
 PLEX_USERNAME = "Plex Username"
 PLEX_PASSWORD = "Plex Password"
 PLEX_PASSWORD = "Plex Password"
-BOTH = "Both"
+BOTH = "Plus Other"
 ONLY = "Only"
 ONLY = "Only"
 NO_CREATE = "Do Not Create Accounts"
 NO_CREATE = "Do Not Create Accounts"
-YES_CREATE = "Create Accounts As Needed"
+YES_CREATE = "Create Accounts As Needed"
+RECENT_CONTENT = "Recently Added Content"
+SETTINGS_SAVED = "Settings have been Saved"

+ 4 - 2
lang/pl.ini

@@ -233,7 +233,9 @@ AUTHBACKENDPORT = "Backend Port (eg 21 for FTP, 389 for LDAP, 8096 for Emby)"
 AUTHBACKENDDOMAIN = "Domain to use for LDAP"
 AUTHBACKENDDOMAIN = "Domain to use for LDAP"
 PLEX_USERNAME = "Plex Username"
 PLEX_USERNAME = "Plex Username"
 PLEX_PASSWORD = "Plex Password"
 PLEX_PASSWORD = "Plex Password"
-BOTH = "Both"
+BOTH = "Plus Other"
 ONLY = "Only"
 ONLY = "Only"
 NO_CREATE = "Do Not Create Accounts"
 NO_CREATE = "Do Not Create Accounts"
-YES_CREATE = "Create Accounts As Needed"
+YES_CREATE = "Create Accounts As Needed"
+RECENT_CONTENT = "Recently Added Content"
+SETTINGS_SAVED = "Settings have been Saved"

+ 291 - 249
settings.php

@@ -8,7 +8,6 @@ ini_set("error_reporting", E_ALL | E_STRICT);
 require_once("user.php");
 require_once("user.php");
 require_once("functions.php");
 require_once("functions.php");
 $USER = new User("registration_callback");
 $USER = new User("registration_callback");
-require_once("translate.php");
 
 
 if(!$USER->authenticated) :
 if(!$USER->authenticated) :
 
 
@@ -20,7 +19,7 @@ elseif($USER->authenticated && $USER->role !== "admin") :
 
 
 endif;
 endif;
 
 
-$dbfile = DATABASE_LOCATION  . constant('User::DATABASE_NAME') . ".db";
+$dbfile = DATABASE_LOCATION.'users.db';
 $databaseLocation = "databaseLocation.ini.php";
 $databaseLocation = "databaseLocation.ini.php";
 $homepageSettings = "homepageSettings.ini.php";
 $homepageSettings = "homepageSettings.ini.php";
 $userdirpath = USER_HOME;
 $userdirpath = USER_HOME;
@@ -277,21 +276,10 @@ if($action == "upgrade") :
 endif;
 endif;
 
 
 if($action == 'createLocation' || $action == 'homepageSettings') {
 if($action == 'createLocation' || $action == 'homepageSettings') {
-	$currentDatabaseConfig = parse_ini_file('databaseLocation.ini.php', true);
-	
-	unset($_POST['action']);
-	foreach ($_POST as $postName => $postValue) {
-		$currentDatabaseConfig[$postName] = $postValue;
-	}
-	
-	$databaseData = '; <?php die("Access denied"); ?>' . "\r\n";
-	foreach($currentDatabaseConfig as $k => $v) {
-		if(substr($v, -1) == "/") : $v = rtrim($v, "/"); endif;
-		$databaseData .= $k . " = \"" . $v . "\"\r\n";
-	}
-	
-    write_ini_file($databaseData, $databaseLocation);
-    echo "<script>window.parent.location.reload(true);</script>";
+    unset($_POST['action']);
+    updateConfig($_POST);
+    echo "<script>parent.notify('<strong>".$language->translate("SETTINGS_SAVED")."</strong>','floppy-o','success','5000', '$notifyExplode[0]', '$notifyExplode[1]');</script>";
+    echo "<script>setTimeout(function() {window.location.href = window.location.href},1500);</script>";
 }
 }
                 
                 
 if(!isset($_POST['op'])) :
 if(!isset($_POST['op'])) :
@@ -669,6 +657,7 @@ if(SLIMBAR == "true") : $slimBar = "30"; $userSize = "25"; else : $slimBar = "56
                 border: solid;
                 border: solid;
                 border-bottom: 0;
                 border-bottom: 0;
                 border-radius: 5px;
                 border-radius: 5px;
+                top: 3px;
 }<?php if(CUSTOMCSS == "true") : 
 }<?php if(CUSTOMCSS == "true") : 
 $template_file = "custom.css";
 $template_file = "custom.css";
 $file_handle = fopen($template_file, "rb");
 $file_handle = fopen($template_file, "rb");
@@ -708,7 +697,7 @@ endif; ?>
 
 
                             <div class="profile-usermenu">
                             <div class="profile-usermenu">
 
 
-                                <ul class="nav">
+                                <ul class="nav" id="settings-list">
 
 
                                     <li class=""><a id="open-tabs"><i class="fa fa-list red-orange"></i>Edit Tabs</a></li>
                                     <li class=""><a id="open-tabs"><i class="fa fa-list red-orange"></i>Edit Tabs</a></li>
                                     <li class=""><a id="open-colors"><i class="fa fa-paint-brush green"></i>Edit Colors</a></li>
                                     <li class=""><a id="open-colors"><i class="fa fa-paint-brush green"></i>Edit Colors</a></li>
@@ -1200,7 +1189,7 @@ endif; ?>
                                         
                                         
                                     </form>
                                     </form>
                                     
                                     
-                                     <form style="display: none" id="editCssForm" method="POST" action="submitCSS.php">
+                                     <form style="display: none" id="editCssForm" method="POST" action="ajax.php">
                                          
                                          
                                          <button class="btn waves btn-labeled btn-warning btn-sm pull-left text-uppercase waves-effect waves-float" type="button" id="backToThemeButton">
                                          <button class="btn waves btn-labeled btn-warning btn-sm pull-left text-uppercase waves-effect waves-float" type="button" id="backToThemeButton">
 
 
@@ -1282,7 +1271,7 @@ endif;?></textarea>
 							    
 							    
                                                         <li class="apps">
                                                         <li class="apps">
 
 
-                                                            <a href="#tab-emby" data-toggle="tab" aria-expanded="true"><img style="height:40px; width:40px;" src="images/emby.png"></a>
+                                                            <a href="#tab-emby" data-toggle="tab" aria-expanded="false"><img style="height:40px; width:40px;" src="images/emby.png"></a>
 
 
                                                         </li>
                                                         </li>
 
 
@@ -1339,14 +1328,7 @@ endif;?></textarea>
                                                             <div class="form-group">
                                                             <div class="form-group">
 
 
                                                                 <input type="text" class="form-control material input-sm" name="plexURL" placeholder="<?php echo $language->translate("PLEX_URL");?>" autocorrect="off" autocapitalize="off" value="<?php echo PLEXURL;?>">
                                                                 <input type="text" class="form-control material input-sm" name="plexURL" placeholder="<?php echo $language->translate("PLEX_URL");?>" autocorrect="off" autocapitalize="off" value="<?php echo PLEXURL;?>">
-                                                                <p class="help-text"><?php echo $language->translate("PLEX_URL");?></p>
-
-                                                            </div>
-
-                                                            <div class="form-group">
-
-                                                                <input type="text" class="form-control material input-sm" name="plexPort" placeholder="<?php echo $language->translate("PLEX_PORT");?>" autocorrect="off" autocapitalize="off" value="<?php echo PLEXPORT;?>">
-                                                                <p class="help-text"><?php echo $language->translate("PLEX_PORT");?></p>
+                                                                <p class="help-text"><?php echo $language->translate("PLEX_URL");?> - i.e. http://hostname:32400</p>
 
 
                                                             </div>
                                                             </div>
 
 
@@ -1404,14 +1386,7 @@ endif;?></textarea>
                                                             <div class="form-group">
                                                             <div class="form-group">
 
 
                                                                 <input type="text" class="form-control material input-sm" name="embyURL" placeholder="<?php echo $language->translate("EMBY_URL");?>" autocorrect="off" autocapitalize="off" value="<?php echo EMBYURL;?>">
                                                                 <input type="text" class="form-control material input-sm" name="embyURL" placeholder="<?php echo $language->translate("EMBY_URL");?>" autocorrect="off" autocapitalize="off" value="<?php echo EMBYURL;?>">
-                                                                <p class="help-text"><?php echo $language->translate("EMBY_URL");?></p>
-
-                                                            </div>
-
-                                                            <div class="form-group">
-
-                                                                <input type="text" class="form-control material input-sm" name="embyPort" placeholder="<?php echo $language->translate("EMBY_PORT");?>" autocorrect="off" autocapitalize="off" value="<?php echo EMBYPORT;?>">
-                                                                <p class="help-text"><?php echo $language->translate("EMBY_PORT");?></p>
+                                                                <p class="help-text"><?php echo $language->translate("EMBY_URL");?> - i.e. http://hostname:8096 | hostname/emby | http://hostname:8096/emby</p>
 
 
                                                             </div>
                                                             </div>
 
 
@@ -1523,14 +1498,7 @@ endif;?></textarea>
                                                             <div class="form-group">
                                                             <div class="form-group">
 
 
                                                                 <input type="text" class="form-control material input-sm" name="nzbgetURL" placeholder="<?php echo $language->translate("NZBGET_URL");?>" autocorrect="off" autocapitalize="off" value="<?php echo NZBGETURL;?>">
                                                                 <input type="text" class="form-control material input-sm" name="nzbgetURL" placeholder="<?php echo $language->translate("NZBGET_URL");?>" autocorrect="off" autocapitalize="off" value="<?php echo NZBGETURL;?>">
-                                                                <p class="help-text"><?php echo $language->translate("NZBGET_URL");?></p>
-
-                                                            </div>
-
-                                                            <div class="form-group">
-
-                                                                <input type="text" class="form-control material input-sm" name="nzbgetPort" placeholder="<?php echo $language->translate("NZBGET_PORT");?>" autocorrect="off" autocapitalize="off" value="<?php echo NZBGETPORT;?>">
-                                                                <p class="help-text"><?php echo $language->translate("NZBGET_PORT");?></p>
+                                                                <p class="help-text"><?php echo $language->translate("NZBGET_URL");?> - i.e. http://hostname:6789</p>
 
 
                                                             </div>
                                                             </div>
 
 
@@ -1555,14 +1523,7 @@ endif;?></textarea>
                                                             <div class="form-group">
                                                             <div class="form-group">
 
 
                                                                 <input type="text" class="form-control material input-sm" name="sabnzbdURL" placeholder="<?php echo $language->translate("SABNZBD_URL");?>" autocorrect="off" autocapitalize="off" value="<?php echo SABNZBDURL;?>">
                                                                 <input type="text" class="form-control material input-sm" name="sabnzbdURL" placeholder="<?php echo $language->translate("SABNZBD_URL");?>" autocorrect="off" autocapitalize="off" value="<?php echo SABNZBDURL;?>">
-                                                                <p class="help-text"><?php echo $language->translate("SABNZBD_URL");?></p>
-
-                                                            </div>
-
-                                                            <div class="form-group">
-
-                                                                <input type="text" class="form-control material input-sm" name="sabnzbdPort" placeholder="<?php echo $language->translate("SABNZBD_PORT");?>" autocorrect="off" autocapitalize="off" value="<?php echo SABNZBDPORT;?>">
-                                                                <p class="help-text"><?php echo $language->translate("SABNZBD_PORT");?></p>
+                                                                <p class="help-text"><?php echo $language->translate("SABNZBD_URL");?> - i.e. http://hostname:8080 | http://hostname/sabnzbd | http://hostname:8080/sabnzbd</p>
 
 
                                                             </div>
                                                             </div>
 
 
@@ -1580,14 +1541,7 @@ endif;?></textarea>
                                                             <div class="form-group">
                                                             <div class="form-group">
 
 
                                                                 <input type="text" class="form-control material input-sm" name="headphonesURL" placeholder="<?php echo $language->translate("HEADPHONES_URL");?>" autocorrect="off" autocapitalize="off" value="<?php echo HEADPHONESURL;?>">
                                                                 <input type="text" class="form-control material input-sm" name="headphonesURL" placeholder="<?php echo $language->translate("HEADPHONES_URL");?>" autocorrect="off" autocapitalize="off" value="<?php echo HEADPHONESURL;?>">
-                                                                <p class="help-text"><?php echo $language->translate("HEADPHONES_URL");?></p>
-
-                                                            </div>
-
-                                                            <div class="form-group">
-
-                                                                <input type="text" class="form-control material input-sm" name="headphonesPort" placeholder="<?php echo $language->translate("HEADPHONES_PORT");?>" autocorrect="off" autocapitalize="off" value="<?php echo HEADPHONESPORT;?>">
-                                                                <p class="help-text"><?php echo $language->translate("HEADPHONES_PORT");?></p>
+                                                                <p class="help-text"><?php echo $language->translate("HEADPHONES_URL");?> - i.e. http://hostname:8181</p>
 
 
                                                             </div>
                                                             </div>
 
 
@@ -1721,214 +1675,281 @@ endif;?></textarea>
                                                 <form class="content-form" name="systemSettings" id="systemSettings" action="" method="POST">
                                                 <form class="content-form" name="systemSettings" id="systemSettings" action="" method="POST">
                         								    
                         								    
                                                     <input type="hidden" name="action" value="createLocation" />
                                                     <input type="hidden" name="action" value="createLocation" />
-							
-                                                    <div class="form-group" style="background-color: #fafafa; border: 2px solid black; border-radius: 5px; padding: 5px; margin: 5px;">
-														<select id="authType" name="authType" class="form-control material input-sm" required>
-															<option value="internal" <?php echo (AUTHTYPE=='internal' || !AUTHTYPE?'selected':''); ?>>Organizr <?php echo $language->translate("ONLY"); ?></option>
-															<!--<option value="external" <?php echo (AUTHTYPE=='external'?'selected':''); ?>>External Only</option>-->
-															<option value="both" <?php echo (AUTHTYPE=='both'?'selected':''); ?>><?php echo $language->translate("BOTH"); ?></option>
-														</select>
-														<p class="help-text"><?php echo $language->translate("AUTHTYPE"); ?></p>
-														
-														<select id="authBackend" name="authBackend" class="form-control material input-sm" required>
-															<?php
-																$backendFunctions = array_filter(get_defined_functions()['user'],function($v) { return strpos($v, 'plugin_auth_') === 0; });
-																foreach ($backendFunctions as $value) {
-																	$name = str_replace('plugin_auth_','',$value);
-																	echo '<option value="'.$name.'" '.(AUTHBACKEND==$name?'selected':'').'>'.ucwords(str_replace('_',' ',$name)).'</option>';
-																}
-															?>
-														</select>
-														<p class="help-text"><?php echo $language->translate("AUTHBACKEND"); ?></p>
-														
-														<select id="authBackendCreate" name="authBackendCreate" class="form-control material input-sm" required>
-															<option value="false" <?php echo (AUTHBACKENDCREATE=='false' || !AUTHBACKENDCREATE?'selected':''); ?>><?php echo $language->translate("NO_CREATE"); ?></option>
-															<option value="true" <?php echo (AUTHBACKENDCREATE=='true'?'selected':''); ?>><?php echo $language->translate("YES_CREATE"); ?></option>
-														</select>
-														<p class="help-text"><?php echo $language->translate("AUTHBACKENDCREATE"); ?></p>
-														
-														<input type="text" class="form-control material input-sm" name="authBackendHost" placeholder="<?php echo $language->translate("AUTHBACKENDHOST");?>" autocorrect="off" autocapitalize="off" value="<?php echo AUTHBACKENDHOST;?>">
-                                                        <p class="help-text"><?php echo $language->translate("AUTHBACKENDHOST");?></p>
-														
-														<input type="text" class="form-control material input-sm" name="authBackendPort" placeholder="<?php echo $language->translate("AUTHBACKENDPORT");?>" autocorrect="off" autocapitalize="off" value="<?php echo AUTHBACKENDPORT;?>">
-                                                        <p class="help-text"><?php echo $language->translate("AUTHBACKENDPORT");?></p>
-														
-														<input type="text" class="form-control material input-sm" name="authBackendDomain" placeholder="<?php echo $language->translate("AUTHBACKENDDOMAIN");?>" autocorrect="off" autocapitalize="off" value="<?php echo AUTHBACKENDDOMAIN;?>">
-                                                        <p class="help-text"><?php echo $language->translate("AUTHBACKENDDOMAIN");?></p>
-														
-														<input type="text" class="form-control material input-sm" name="embyToken" placeholder="<?php echo $language->translate("EMBY_TOKEN");?>" autocorrect="off" autocapitalize="off" value="<?php echo EMBYTOKEN;?>">
-														<p class="help-text"><?php echo $language->translate("EMBY_TOKEN");?></p>
-                                                        
-                                                        <input type="text" class="form-control material input-sm" name="plexUsername" placeholder="<?php echo $language->translate("PLEX_USERNAME");?>" autocorrect="off" autocapitalize="off" value="<?php echo PLEXUSERNAME;?>">
-														<p class="help-text"><?php echo $language->translate("PLEX_USERNAME");?></p>
-                                                        
-                                                        <input type="password" class="form-control material input-sm" name="plexPassword" placeholder="<?php echo $language->translate("PLEX_PASSWORD");?>" autocorrect="off" autocapitalize="off" value="<?php echo PLEXPASSWORD;?>">
-														<p class="help-text"><?php echo $language->translate("PLEX_PASSWORD");?></p>
-                                                    </div>
-							
-                                                    <div class="form-group">
+                                                    
+                                                    <div class="tabbable tabs-with-bg" id="advanced-settings-tabs">
 
 
-                                                        <input type="text" class="form-control material input-sm" name="databaseLocation" placeholder="<?php echo $language->translate("DATABASE_PATH");?>" autocorrect="off" autocapitalize="off" value="<?php echo DATABASE_LOCATION;?>">
-                                                        <p class="help-text"><?php echo $language->translate("DATABASE_PATH");?></p>
+                                                        <ul class="nav nav-tabs apps">
 
 
-                                                    </div>
+                                                            <li class="apps active">
 
 
-                                                    <div class="form-group">
+                                                                <a href="#tab-security" data-toggle="tab" aria-expanded="true"><img style="height:40px; width:40px;" src="images/security.png"></a>
 
 
-                                                        <?php echo gotTimezone();?>
-                                                        <p class="help-text"><?php echo $language->translate("SET_TIMEZONE");?></p>
+                                                            </li>
 
 
-                                                    </div>
+                                                            <li class="apps">
 
 
-                                                    <div class="form-group">
+                                                                <a href="#tab-more-settings" data-toggle="tab" aria-expanded="false"><img style="height:40px; width:40px;" src="images/gear.png"></a>
 
 
-                                                        <input type="text" class="form-control material input-sm" name="titleLogo" placeholder="<?php echo $language->translate("LOGO_URL_TITLE");?>" value="<?php echo TITLELOGO;?>">
-                                                        <p class="help-text"><?php echo $language->translate("LOGO_URL_TITLE");?></p>
+                                                            </li>
 
 
-                                                    </div>
+                                                            <li class="apps">
 
 
-                                                    <div class="form-group">
+                                                                <a href="#tab-mail" data-toggle="tab" aria-expanded="false"><img style="height:40px; width:40px;" src="images/mail.png"></a>
 
 
-                                                        <input type="text" class="form-control material input-sm" name="loadingIcon" placeholder="<?php echo $language->translate("LOADING_ICON_URL");?>" value="<?php echo LOADINGICON;?>">
-                                                        <p class="help-text"><?php echo $language->translate("LOADING_ICON_URL");?></p>
+                                                            </li>
 
 
-                                                    </div>
-                                                    
-                                                    <div class="form-group">
+                                                            <li class="apps">
 
 
-                                                        <input type="text" class="form-control material input-sm" name="cookiePassword" placeholder="<?php echo $language->translate("COOKIE_PASSWORD");?>" value="<?php echo COOKIEPASSWORD;?>">
-                                                        <p class="help-text"><?php echo $language->translate("COOKIE_PASSWORD");?></p>
+                                                                <a href="#tab-more-custom" data-toggle="tab" aria-expanded="false"><img style="height:40px; width:40px;" src="images/paint.png"></a>
 
 
-                                                    </div>
-                                                    
-                                                    <div class="form-group">
+                                                            </li>
 
 
-                                                        <input type="text" class="form-control material input-sm" name="domain" placeholder="<?php echo $language->translate("COOKIE_DOMAIN");?>" value="<?php echo DOMAIN;?>">
-                                                        <p class="help-text"><?php echo $language->translate("COOKIE_DOMAIN");?></p>
+                                                        </ul>
+                                                        
+                                                        <div class="tab-content">
 
 
-                                                    </div>
-                                                    
-                                                    <div class="form-group">
+                                                            <div class="tab-pane big-box fade active in" id="tab-security">
+                                                                
+                                                                <div class="form-group">
+                                                                    <select id="authType" name="authType" class="form-control material input-sm" required>
+                                                                        <option value="internal" <?php echo (AUTHTYPE=='internal' || !AUTHTYPE?'selected':''); ?>>Organizr <?php echo $language->translate("ONLY"); ?></option>
+                                                                        <!--<option value="external" <?php echo (AUTHTYPE=='external'?'selected':''); ?>>External Only</option>-->
+                                                                        <option value="both" <?php echo (AUTHTYPE=='both'?'selected':''); ?>>Organizr <?php echo $language->translate("BOTH"); ?></option>
+                                                                    </select>
+                                                                    <p class="help-text"><?php echo $language->translate("AUTHTYPE"); ?></p>
+                                                                    <group id="host-selected">
+                                                                        <select id="authBackend" name="authBackend" class="form-control material input-sm" required>
+                                                                            <?php
+                                                                                $backendFunctions = array_filter(get_defined_functions()['user'],function($v) { return strpos($v, 'plugin_auth_') === 0; });
+                                                                                foreach ($backendFunctions as $value) {
+                                                                                    $name = str_replace('plugin_auth_','',$value);
+                                                                                    echo '<option value="'.$name.'" '.(AUTHBACKEND==$name?'selected':'').'>'.ucwords(str_replace('_',' ',$name)).'</option>';
+                                                                                }
+                                                                            ?>
+                                                                        </select>
+                                                                        <p class="help-text"><?php echo $language->translate("AUTHBACKEND"); ?></p>
+
+                                                                        <select id="authBackendCreate" name="authBackendCreate" class="form-control material input-sm" required>
+                                                                            <option value="false" <?php echo (AUTHBACKENDCREATE=='false' || !AUTHBACKENDCREATE?'selected':''); ?>><?php echo $language->translate("NO_CREATE"); ?></option>
+                                                                            <option value="true" <?php echo (AUTHBACKENDCREATE=='true'?'selected':''); ?>><?php echo $language->translate("YES_CREATE"); ?></option>
+                                                                        </select>
+                                                                        <p class="help-text"><?php echo $language->translate("AUTHBACKENDCREATE"); ?></p>
+                                                                    </group>
+                                                                    <group id="host-other">
+                                                                        <input type="text" class="form-control material input-sm" name="authBackendHost" placeholder="<?php echo $language->translate("AUTHBACKENDHOST");?>" autocorrect="off" autocapitalize="off" value="<?php echo AUTHBACKENDHOST;?>">
+                                                                        <p class="help-text"><?php echo $language->translate("AUTHBACKENDHOST");?></p>
+
+                                                                        <input type="text" class="form-control material input-sm" name="authBackendPort" placeholder="<?php echo $language->translate("AUTHBACKENDPORT");?>" autocorrect="off" autocapitalize="off" value="<?php echo AUTHBACKENDPORT;?>">
+                                                                        <p class="help-text"><?php echo $language->translate("AUTHBACKENDPORT");?></p>
+                                                                    </group>
+                                                                    <group id="host-ldap">
+                                                                        <input type="text" class="form-control material input-sm" name="authBackendDomain" placeholder="<?php echo $language->translate("AUTHBACKENDDOMAIN");?>" autocorrect="off" autocapitalize="off" value="<?php echo AUTHBACKENDDOMAIN;?>">
+                                                                        <p class="help-text"><?php echo $language->translate("AUTHBACKENDDOMAIN");?></p>
+                                                                    </group>
+                                                                    <group id="host-emby">
+                                                                        <input type="text" class="form-control material input-sm" name="embyToken" placeholder="<?php echo $language->translate("EMBY_TOKEN");?>" autocorrect="off" autocapitalize="off" value="<?php echo EMBYTOKEN;?>">
+                                                                        <p class="help-text"><?php echo $language->translate("EMBY_TOKEN");?></p>
+                                                                    </group>
+                                                                    <group id="host-plex">
+                                                                        <input type="text" class="form-control material input-sm" name="plexUsername" placeholder="<?php echo $language->translate("PLEX_USERNAME");?>" autocorrect="off" autocapitalize="off" value="<?php echo PLEXUSERNAME;?>">
+                                                                        <p class="help-text"><?php echo $language->translate("PLEX_USERNAME");?></p>
+
+                                                                        <input type="password" class="form-control material input-sm" name="plexPassword" placeholder="<?php echo $language->translate("PLEX_PASSWORD");?>" autocorrect="off" autocapitalize="off" value="<?php echo PLEXPASSWORD;?>">
+                                                                        <p class="help-text"><?php echo $language->translate("PLEX_PASSWORD");?></p>
+                                                                    </group>
+                                                                </div>
+                                                                
+                                                                <hr>
+                                                                
+                                                                <div class="form-group">
 
 
-                                                        <input type="text" class="form-control material input-sm" name="registerPassword" placeholder="<?php echo $language->translate("REGISTER_PASSWORD");?>" value="<?php echo REGISTERPASSWORD;?>">
-                                                        <p class="help-text"><?php echo $language->translate("REGISTER_PASSWORD");?></p>
+                                                                    <input type="text" class="form-control material input-sm" name="cookiePassword" placeholder="<?php echo $language->translate("COOKIE_PASSWORD");?>" value="<?php echo COOKIEPASSWORD;?>">
+                                                                    <p class="help-text"><?php echo $language->translate("COOKIE_PASSWORD");?></p>
 
 
-                                                    </div>
-                                                    
-                                                    <div class="form-group">
+                                                                </div>
 
 
-                                                        <input type="text" class="form-control material input-sm" name="smtpHost" placeholder="<?php echo $language->translate("SMTP_HOST");?>" value="<?php echo SMTPHOST;?>">
-                                                        <p class="help-text"><?php echo $language->translate("SMTP_HOST");?></p>
-                                                        
-                                                        <input type="text" class="form-control material input-sm" name="smtpHostPort" placeholder="<?php echo $language->translate("SMTP_HOST_PORT");?>" value="<?php echo SMTPHOSTPORT;?>">
-                                                        <p class="help-text"><?php echo $language->translate("SMTP_HOST_PORT");?></p>
-                                                        
-                                                        <input type="text" class="form-control material input-sm" name="smtpHostAuth" placeholder="<?php echo $language->translate("SMTP_HOST_AUTH");?>" value="<?php echo SMTPHOSTAUTH;?>">
-                                                        <p class="help-text"><?php echo $language->translate("SMTP_HOST_AUTH");?></p>
-                                                        
-                                                        <input type="text" class="form-control material input-sm" name="smtpHostUsername" placeholder="<?php echo $language->translate("SMTP_HOST_USERNAME");?>" value="<?php echo SMTPHOSTUSERNAME;?>">
-                                                        <p class="help-text"><?php echo $language->translate("SMTP_HOST_USERNAME");?></p>
-                                                        
-                                                        <input type="text" class="form-control material input-sm" name="smtpHostPassword" placeholder="<?php echo $language->translate("SMTP_HOST_PASSWORD");?>" value="<?php echo SMTPHOSTPASSWORD;?>">
-                                                        <p class="help-text"><?php echo $language->translate("SMTP_HOST_PASSWORD");?></p>
-                                                        
-                                                        <input type="text" class="form-control material input-sm" name="smtpHostSenderName" placeholder="<?php echo $language->translate("SMTP_HOST_SENDER_NAME");?>" value="<?php echo SMTPHOSTSENDERNAME;?>">
-                                                        <p class="help-text"><?php echo $language->translate("SMTP_HOST_SENDER_NAME");?></p>
-                                                        
-                                                        <input type="text" class="form-control material input-sm" name="smtpHostSenderEmail" placeholder="<?php echo $language->translate("SMTP_HOST_SENDER_EMAIL");?>" value="<?php echo SMTPHOSTSENDEREMAIL;?>">
-                                                        <p class="help-text"><?php echo $language->translate("SMTP_HOST_SENDER_EMAIL");?></p>
+                                                                <div class="form-group">
 
 
-                                                    </div>
+                                                                    <input type="text" class="form-control material input-sm" name="domain" placeholder="<?php echo $language->translate("COOKIE_DOMAIN");?>" value="<?php echo DOMAIN;?>">
+                                                                    <p class="help-text"><?php echo $language->translate("COOKIE_DOMAIN");?></p>
+
+                                                                </div>
+
+                                                                <div class="form-group">
+
+                                                                    <input type="text" class="form-control material input-sm" name="registerPassword" placeholder="<?php echo $language->translate("REGISTER_PASSWORD");?>" value="<?php echo REGISTERPASSWORD;?>">
+                                                                    <p class="help-text"><?php echo $language->translate("REGISTER_PASSWORD");?></p>
+
+                                                                </div>
+                                                                
+                                                                <div class="content-form form-inline">
                                                     
                                                     
-                                                    <div class="content-form form-inline">
-                                                        
-                                                        <div class="form-group">
+                                                                    <div class="form-group">
+                                                                        <?php  if(MULTIPLELOGIN == "true") : $multipleLogin = "checked"; else : $multipleLogin = ""; endif;?>
+                                                                        <input id="" class="switcher switcher-success" value="false" name="multipleLogin" type="hidden">
+                                                                        <input id="multipleLogin" class="switcher switcher-success" value="true" name="multipleLogin" type="checkbox" <?php echo $multipleLogin;?>>
 
 
-                                                        <?php 
-                                                        
-                                                        if($notifyExplode[1] == "slidetop") : $slidetopActive = "selected"; else : $slidetopActive = ""; endif;
-                                                        if($notifyExplode[1] == "exploader") : $exploaderActive = "selected"; else : $exploaderActive = ""; endif;
-                                                        if($notifyExplode[1] == "flip") : $flipActive = "selected"; else : $flipActive = ""; endif;
-                                                        if($notifyExplode[1] == "bouncyflip") : $bouncyflipActive = "selected"; else : $bouncyflipActive = ""; endif;
-                                                        if($notifyExplode[1] == "scale") : $scaleActive = "selected"; else : $scaleActive = ""; endif;
-                                                        if($notifyExplode[1] == "genie") : $genieActive = "selected"; else : $genieActive = ""; endif;
-                                                        if($notifyExplode[1] == "jelly") : $jellyActive = "selected"; else : $jellyActive = ""; endif;
-                                                        if($notifyExplode[1] == "slide") : $slideActive = "selected"; else : $slideActive = ""; endif;
-                                                        if($notifyExplode[1] == "boxspinner") : $boxspinnerActive = "selected"; else : $boxspinnerActive = ""; endif;
-                                                        if($notifyExplode[1] == "thumbslider") : $thumbsliderActive = "selected"; else : $thumbsliderActive = ""; endif;
-                                                        
-                                                        ?>
-                                                            <select id="notifyValue" name="notifyEffect" id="notifyEffect" class="form-control material input-sm" required>
+                                                                        <label for="multipleLogin"></label><?php echo $language->translate("MULTIPLE_LOGINS");?>
+
+                                                                    </div>
+
+                                                                </div>
+                                                                
+                                                            </div>
+                                                            
+                                                            <div class="tab-pane big-box fade" id="tab-more-settings">
+                                                                
+                                                                <div class="form-group">
 
 
-                                                                <option value="bar-slidetop" <?=$slidetopActive;?>>Slide From Top</option>
-                                                                <option value="bar-exploader" <?=$exploaderActive;?>>Exploader From Top</option>
-                                                                <option value="attached-flip" <?=$flipActive;?>>Flip</option>
-                                                                <option value="attached-bouncyflip" <?=$bouncyflipActive;?>>Bouncy Flip</option>
-                                                                <option value="growl-scale" <?=$scaleActive;?>>Growl Scale</option>
-                                                                <option value="growl-genie" <?=$genieActive;?>>Growl Genie</option>
-                                                                <option value="growl-jelly" <?=$jellyActive;?>>Growl Jelly</option>
-                                                                <option value="growl-slide" <?=$slideActive;?>>Growl Slide</option>
-                                                                <option value="other-boxspinner" <?=$boxspinnerActive;?>>Spinning Box</option>
-                                                                <option value="other-thumbslider" <?=$thumbsliderActive;?>>Sliding</option>
+                                                                    <input type="text" class="form-control material input-sm" name="database_Location" placeholder="<?php echo $language->translate("DATABASE_PATH");?>" autocorrect="off" autocapitalize="off" value="<?php echo DATABASE_LOCATION;?>">
+                                                                    <p class="help-text"><?php echo $language->translate("DATABASE_PATH");?></p>
 
 
-                                                            </select>
+                                                                </div>
 
 
-                                                            <button id="notifyTest" type="button" class="class='btn waves btn-labeled btn-success btn btn-sm text-uppercase waves-effect waves-float"><span class="btn-label"><i class="fa fa-flask"></i></span><?php echo $language->translate("TEST");?></button>
+                                                                <div class="form-group">
 
 
-                                                            <p class="help-text"><?php echo $language->translate("NOTIFICATION_TYPE");?></p>
+                                                                    <?php echo gotTimezone();?>
+                                                                    <p class="help-text"><?php echo $language->translate("SET_TIMEZONE");?></p>
 
 
-                                                        </div>
-                                                    
-                                                    </div>
-                                                    
-                                                    <div class="content-form form-inline">
-                                                    
-                                                        <div class="form-group">
-                                                            <?php  if(MULTIPLELOGIN == "true") : $multipleLogin = "checked"; else : $multipleLogin = ""; endif;?>
-                                                            <input id="" class="switcher switcher-success" value="false" name="multipleLogin" type="hidden">
-                                                            <input id="multipleLogin" class="switcher switcher-success" value="true" name="multipleLogin" type="checkbox" <?php echo $multipleLogin;?>>
+                                                                </div>
+                                                                
+                                                            </div>
+                                                            
+                                                            <div class="tab-pane big-box fade" id="tab-mail">
+                                                                
+                                                                <div class="form-group">
 
 
-                                                            <label for="multipleLogin"></label><?php echo $language->translate("MULTIPLE_LOGINS");?>
+                                                                    <input type="text" class="form-control material input-sm" name="smtpHost" placeholder="<?php echo $language->translate("SMTP_HOST");?>" value="<?php echo SMTPHOST;?>">
+                                                                    <p class="help-text"><?php echo $language->translate("SMTP_HOST");?></p>
 
 
-                                                        </div>
-                                                        
-                                                        <div class="form-group">
-                                                            <?php  if(LOADINGSCREEN == "true") : $loadingScreen = "checked"; else : $loadingScreen = ""; endif;?>
-                                                            <input id="" class="switcher switcher-success" value="false" name="loadingScreen" type="hidden">
-                                                            <input id="loadingScreen" class="switcher switcher-success" value="true" name="loadingScreen" type="checkbox" <?php echo $loadingScreen;?>>
+                                                                    <input type="text" class="form-control material input-sm" name="smtpHostPort" placeholder="<?php echo $language->translate("SMTP_HOST_PORT");?>" value="<?php echo SMTPHOSTPORT;?>">
+                                                                    <p class="help-text"><?php echo $language->translate("SMTP_HOST_PORT");?></p>
 
 
-                                                            <label for="loadingScreen"></label><?php echo $language->translate("ENABLE_LOADING_SCREEN");?>
+                                                                    <input type="text" class="form-control material input-sm" name="smtpHostAuth" placeholder="<?php echo $language->translate("SMTP_HOST_AUTH");?>" value="<?php echo SMTPHOSTAUTH;?>">
+                                                                    <p class="help-text"><?php echo $language->translate("SMTP_HOST_AUTH");?></p>
 
 
-                                                        </div>
-                                                        
-                                                        <div class="form-group">
-                                                            <?php  if(ENABLEMAIL == "true") : $enableMail = "checked"; else : $enableMail = ""; endif;?>
-                                                            <input id="" class="switcher switcher-success" value="false" name="enableMail" type="hidden">
-                                                            <input id="enableMail" class="switcher switcher-success" value="true" name="enableMail" type="checkbox" <?php echo $enableMail;?>>
+                                                                    <input type="text" class="form-control material input-sm" name="smtpHostUsername" placeholder="<?php echo $language->translate("SMTP_HOST_USERNAME");?>" value="<?php echo SMTPHOSTUSERNAME;?>">
+                                                                    <p class="help-text"><?php echo $language->translate("SMTP_HOST_USERNAME");?></p>
 
 
-                                                            <label for="enableMail"></label><?php echo $language->translate("ENABLE_MAIL");?>
+                                                                    <input type="text" class="form-control material input-sm" name="smtpHostPassword" placeholder="<?php echo $language->translate("SMTP_HOST_PASSWORD");?>" value="<?php echo SMTPHOSTPASSWORD;?>">
+                                                                    <p class="help-text"><?php echo $language->translate("SMTP_HOST_PASSWORD");?></p>
 
 
-                                                        </div>
-                                                        
-                                                        <div class="form-group">
-                                                            <?php  if(SLIMBAR == "true") : $enableSlimBar = "checked"; else : $enableSlimBar = ""; endif;?>
-                                                            <input id="" class="switcher switcher-success" value="false" name="slimBar" type="hidden">
-                                                            <input id="slimBar" class="switcher switcher-success" value="true" name="slimBar" type="checkbox" <?php echo $enableSlimBar;?>>
+                                                                    <input type="text" class="form-control material input-sm" name="smtpHostSenderName" placeholder="<?php echo $language->translate("SMTP_HOST_SENDER_NAME");?>" value="<?php echo SMTPHOSTSENDERNAME;?>">
+                                                                    <p class="help-text"><?php echo $language->translate("SMTP_HOST_SENDER_NAME");?></p>
 
 
-                                                            <label for="slimBar"></label><?php echo $language->translate("ENABLE_SLIMBAR");?>
+                                                                    <input type="text" class="form-control material input-sm" name="smtpHostSenderEmail" placeholder="<?php echo $language->translate("SMTP_HOST_SENDER_EMAIL");?>" value="<?php echo SMTPHOSTSENDEREMAIL;?>">
+                                                                    <p class="help-text"><?php echo $language->translate("SMTP_HOST_SENDER_EMAIL");?></p>
 
 
-                                                        </div>
+                                                                </div>
+                                                                
+                                                                <div class="content-form form-inline">
+
+                                                                    <div class="form-group">
+                                                                        <?php  if(ENABLEMAIL == "true") : $enableMail = "checked"; else : $enableMail = ""; endif;?>
+                                                                        <input id="" class="switcher switcher-success" value="false" name="enableMail" type="hidden">
+                                                                        <input id="enableMail" class="switcher switcher-success" value="true" name="enableMail" type="checkbox" <?php echo $enableMail;?>>
+
+                                                                        <label for="enableMail"></label><?php echo $language->translate("ENABLE_MAIL");?>
+
+                                                                    </div>
+
+                                                                </div>
+                                                                
+                                                            </div>
+                                                            
+                                                            <div class="tab-pane big-box fade" id="tab-more-custom">
+                                                                
+                                                                <div class="form-group">
+
+                                                                    <input type="text" class="form-control material input-sm" name="titleLogo" placeholder="<?php echo $language->translate("LOGO_URL_TITLE");?>" value="<?php echo TITLELOGO;?>">
+                                                                    <p class="help-text"><?php echo $language->translate("LOGO_URL_TITLE");?></p>
+
+                                                                </div>
+
+                                                                <div class="form-group">
+
+                                                                    <input type="text" class="form-control material input-sm" name="loadingIcon" placeholder="<?php echo $language->translate("LOADING_ICON_URL");?>" value="<?php echo LOADINGICON;?>">
+                                                                    <p class="help-text"><?php echo $language->translate("LOADING_ICON_URL");?></p>
+
+                                                                </div>
+                                                                
+                                                                <div class="content-form form-inline">
                                                         
                                                         
-                                                        <div class="form-group">
-                                                            <?php  if(GRAVATAR == "true") : $enableGravatar = "checked"; else : $enableGravatar = ""; endif;?>
-                                                            <input id="" class="switcher switcher-success" value="false" name="gravatar" type="hidden">
-                                                            <input id="gravatar" class="switcher switcher-success" value="true" name="gravatar" type="checkbox" <?php echo $enableGravatar;?>>
+                                                                    <div class="form-group">
 
 
-                                                            <label for="gravatar"></label><?php echo $language->translate("GRAVATAR");?>
+                                                                    <?php 
+
+                                                                    if($notifyExplode[1] == "slidetop") : $slidetopActive = "selected"; else : $slidetopActive = ""; endif;
+                                                                    if($notifyExplode[1] == "exploader") : $exploaderActive = "selected"; else : $exploaderActive = ""; endif;
+                                                                    if($notifyExplode[1] == "flip") : $flipActive = "selected"; else : $flipActive = ""; endif;
+                                                                    if($notifyExplode[1] == "bouncyflip") : $bouncyflipActive = "selected"; else : $bouncyflipActive = ""; endif;
+                                                                    if($notifyExplode[1] == "scale") : $scaleActive = "selected"; else : $scaleActive = ""; endif;
+                                                                    if($notifyExplode[1] == "genie") : $genieActive = "selected"; else : $genieActive = ""; endif;
+                                                                    if($notifyExplode[1] == "jelly") : $jellyActive = "selected"; else : $jellyActive = ""; endif;
+                                                                    if($notifyExplode[1] == "slide") : $slideActive = "selected"; else : $slideActive = ""; endif;
+                                                                    if($notifyExplode[1] == "boxspinner") : $boxspinnerActive = "selected"; else : $boxspinnerActive = ""; endif;
+                                                                    if($notifyExplode[1] == "thumbslider") : $thumbsliderActive = "selected"; else : $thumbsliderActive = ""; endif;
+
+                                                                    ?>
+                                                                        <select id="notifyValue" name="notifyEffect" id="notifyEffect" class="form-control material input-sm" required>
+
+                                                                            <option value="bar-slidetop" <?=$slidetopActive;?>>Slide From Top</option>
+                                                                            <option value="bar-exploader" <?=$exploaderActive;?>>Exploader From Top</option>
+                                                                            <option value="attached-flip" <?=$flipActive;?>>Flip</option>
+                                                                            <option value="attached-bouncyflip" <?=$bouncyflipActive;?>>Bouncy Flip</option>
+                                                                            <option value="growl-scale" <?=$scaleActive;?>>Growl Scale</option>
+                                                                            <option value="growl-genie" <?=$genieActive;?>>Growl Genie</option>
+                                                                            <option value="growl-jelly" <?=$jellyActive;?>>Growl Jelly</option>
+                                                                            <option value="growl-slide" <?=$slideActive;?>>Growl Slide</option>
+                                                                            <option value="other-boxspinner" <?=$boxspinnerActive;?>>Spinning Box</option>
+                                                                            <option value="other-thumbslider" <?=$thumbsliderActive;?>>Sliding</option>
+
+                                                                        </select>
+
+                                                                        <button id="notifyTest" type="button" class="class='btn waves btn-labeled btn-success btn btn-sm text-uppercase waves-effect waves-float"><span class="btn-label"><i class="fa fa-flask"></i></span><?php echo $language->translate("TEST");?></button>
+
+                                                                        <p class="help-text"><?php echo $language->translate("NOTIFICATION_TYPE");?></p>
+
+                                                                    </div>
+
+                                                                </div>
+                                                                
+                                                                <div class="content-form form-inline">
+
+                                                                    <div class="form-group">
+                                                                        <?php  if(LOADINGSCREEN == "true") : $loadingScreen = "checked"; else : $loadingScreen = ""; endif;?>
+                                                                        <input id="" class="switcher switcher-success" value="false" name="loadingScreen" type="hidden">
+                                                                        <input id="loadingScreen" class="switcher switcher-success" value="true" name="loadingScreen" type="checkbox" <?php echo $loadingScreen;?>>
+
+                                                                        <label for="loadingScreen"></label><?php echo $language->translate("ENABLE_LOADING_SCREEN");?>
+
+                                                                    </div>
+
+                                                                    <div class="form-group">
+                                                                        <?php  if(SLIMBAR == "true") : $enableSlimBar = "checked"; else : $enableSlimBar = ""; endif;?>
+                                                                        <input id="" class="switcher switcher-success" value="false" name="slimBar" type="hidden">
+                                                                        <input id="slimBar" class="switcher switcher-success" value="true" name="slimBar" type="checkbox" <?php echo $enableSlimBar;?>>
+
+                                                                        <label for="slimBar"></label><?php echo $language->translate("ENABLE_SLIMBAR");?>
+
+                                                                    </div>
+
+                                                                    <div class="form-group">
+                                                                        <?php  if(GRAVATAR == "true") : $enableGravatar = "checked"; else : $enableGravatar = ""; endif;?>
+                                                                        <input id="" class="switcher switcher-success" value="false" name="gravatar" type="hidden">
+                                                                        <input id="gravatar" class="switcher switcher-success" value="true" name="gravatar" type="checkbox" <?php echo $enableGravatar;?>>
+
+                                                                        <label for="gravatar"></label><?php echo $language->translate("GRAVATAR");?>
+
+                                                                    </div>
 
 
+                                                                </div>
+                                                                
+                                                            </div>
+                                                            
                                                         </div>
                                                         </div>
                                                         
                                                         
-                                                    </div>
+                                                    </div>                                                    
                                                     
                                                     
                                                     <button type="submit" class="class='btn waves btn-labeled btn-success btn btn-sm pull-right text-uppercase waves-effect waves-float"><span class="btn-label"><i class="fa fa-floppy-o"></i></span>Save</button>
                                                     <button type="submit" class="class='btn waves btn-labeled btn-success btn btn-sm pull-right text-uppercase waves-effect waves-float"><span class="btn-label"><i class="fa fa-floppy-o"></i></span>Save</button>
 
 
@@ -2684,7 +2705,7 @@ endif;?></textarea>
 
 
         <script src="js/jqueri_ui_custom/jquery-ui.min.js"></script>
         <script src="js/jqueri_ui_custom/jquery-ui.min.js"></script>
         <script src="js/jquery.filer.min.js" type="text/javascript"></script>
         <script src="js/jquery.filer.min.js" type="text/javascript"></script>
-	    <script src="js/custom.js" type="text/javascript"></script>
+	    <script src="js/custom.js?v=<?php echo INSTALLEDVERSION; ?>" type="text/javascript"></script>
 	    <script src="js/jquery.mousewheel.min.js" type="text/javascript"></script>
 	    <script src="js/jquery.mousewheel.min.js" type="text/javascript"></script>
         
         
         <!--Data Tables-->
         <!--Data Tables-->
@@ -3349,20 +3370,20 @@ endif;?></textarea>
             $(".email-header .close-button").click(function () {
             $(".email-header .close-button").click(function () {
                 $(".email-content").removeClass("email-active");
                 $(".email-content").removeClass("email-active");
                 $('html').removeClass("overhid");
                 $('html').removeClass("overhid");
-                $(".nav").find("li").removeClass("active");
+                $("#settings-list").find("li").removeClass("active");
             });
             });
             
             
-            $(document).mouseup(function (e)
+             $(document).mouseup(function (e)
 {
 {
                 var container = $(".email-content");
                 var container = $(".email-content");
 
 
                 if (!container.is(e.target) && container.has(e.target).length === 0) {
                 if (!container.is(e.target) && container.has(e.target).length === 0) {
                     $(".email-content").removeClass("email-active");
                     $(".email-content").removeClass("email-active");
                     $('html').removeClass("overhid");
                     $('html').removeClass("overhid");
-                    $(".nav").find("li").removeClass("active");
+                    $("#settings-list").find("li").removeClass("active");
                 }
                 }
                 
                 
-            });
+            }); 
             
             
             $( document ).on( 'keydown', function ( e ) {
             $( document ).on( 'keydown', function ( e ) {
                 if ( e.keyCode === 27 ) { // ESC
                 if ( e.keyCode === 27 ) { // ESC
@@ -3371,7 +3392,7 @@ endif;?></textarea>
                     if (!container.is(e.target) && container.has(e.target).length === 0) {
                     if (!container.is(e.target) && container.has(e.target).length === 0) {
                         $(".email-content").removeClass("email-active");
                         $(".email-content").removeClass("email-active");
                         $('html').removeClass("overhid");
                         $('html').removeClass("overhid");
-                        $(".nav").find("li").removeClass("active");
+                        $("#settings-list").find("li").removeClass("active");
                     }
                     }
                 }
                 }
             });
             });
@@ -3563,33 +3584,53 @@ endif;?></textarea>
         <script>
         <script>
         
         
         $( document ).ready(function() {
         $( document ).ready(function() {
-            
+            //Hide Icon box on load
+            $( "div[class^='jFiler jFiler-theme-dragdropbox']" ).hide();
+            //Set Some Scrollbars
             $(".scroller-body").niceScroll({
             $(".scroller-body").niceScroll({
                 railpadding: {top:0,right:0,left:0,bottom:0}
                 railpadding: {top:0,right:0,left:0,bottom:0}
             });
             });
-            
-            
             $(".email-content").niceScroll({
             $(".email-content").niceScroll({
                 railpadding: {top:0,right:0,left:0,bottom:0}
                 railpadding: {top:0,right:0,left:0,bottom:0}
             });
             });
-            
+            //Stop Div behind From Scrolling
             $( '.email-content' ).on( 'mousewheel', function ( e ) {
             $( '.email-content' ).on( 'mousewheel', function ( e ) {
-          
                 e.preventDefault();
                 e.preventDefault();
-
             }, false);  
             }, false);  
-            
+            //Set Hide Function
+            var authTypeFunc = function() {
+                // Hide Everything
+                $('#host-selected, #host-other, #host-plex, #host-emby, #host-ldap').hide();
+                // Qualify Auth Type
+                if($('#authType').val() !== "internal"){
+                    $( '#host-selected' ).show();
+
+                    // Qualify aithBackend
+                    if($('#authBackend').val() === "plex"){
+                        $('#host-selected, #host-plex').show();
+                    }else if($('#authBackend').val().indexOf("emby")>=0){
+                        $('#host-selected, #host-other, #host-emby').show();
+                    }else if($('#authBackend').val() === "ldap"){
+                        $('#host-selected, #host-other, #host-ldap').show();
+                    }else {
+                        $('#host-selected, #host-other').show();
+                    }
+                }
+            }
+            //Hide Settings on selection
+            $('#authType, #authBackend').on('change', authTypeFunc);
+            //Hide Settings on Load
+            authTypeFunc();
+            //Simulate Edit Tabs Click 
             $("#open-tabs").trigger("click");
             $("#open-tabs").trigger("click");
-            
+            //Append Delete log to User Logs
             $("div[class^='DTTT_container']").append('<form style="display: inline; margin-left: 3px;" id="deletelog" method="post"><input type="hidden" name="action" value="deleteLog" /><button class="btn waves btn-labeled btn-danger text-uppercase waves-effect waves-float" type="submit"><span class="btn-label"><i class="fa fa-trash"></i></span><?php echo $language->translate("PURGE_LOG");?> </button></form>')
             $("div[class^='DTTT_container']").append('<form style="display: inline; margin-left: 3px;" id="deletelog" method="post"><input type="hidden" name="action" value="deleteLog" /><button class="btn waves btn-labeled btn-danger text-uppercase waves-effect waves-float" type="submit"><span class="btn-label"><i class="fa fa-trash"></i></span><?php echo $language->translate("PURGE_LOG");?> </button></form>')
             $("a[id^='ToolTables_datatable_0'] span").html('<?php echo $language->translate("PRINT");?>')
             $("a[id^='ToolTables_datatable_0'] span").html('<?php echo $language->translate("PRINT");?>')
-            
+            //Enable Tooltips
             $('[data-toggle="tooltip"]').tooltip(); 
             $('[data-toggle="tooltip"]').tooltip(); 
-            
-            rememberTabSelection('#settingsTabs', !localStorage);
-            
-            $( "div[class^='jFiler jFiler-theme-dragdropbox']" ).hide();
-        		
+            //Tab save on reload - might need to delete as we changed tab layout
+            //rememberTabSelection('#settingsTabs', !localStorage); 
+        	//AJAX call to github to get version info	
         	$.ajax({
         	$.ajax({
         				
         				
         		type: "GET",
         		type: "GET",
@@ -3651,6 +3692,7 @@ endif;?></textarea>
                 }
                 }
                 
                 
             });
             });
+            //Edit Info tab with Github info
             <?php if(file_exists(FAIL_LOG)) : ?>
             <?php if(file_exists(FAIL_LOG)) : ?>
             goodCount = $('#loginStats').find('#goodCount');
             goodCount = $('#loginStats').find('#goodCount');
             goodPercent = $('#loginStats').find('#goodPercent');
             goodPercent = $('#loginStats').find('#goodPercent');

+ 0 - 29
submitCSS.php

@@ -1,29 +0,0 @@
-<?php
-
-function write_ini_file($content, $path) { 
-    
-    if (!$handle = fopen($path, 'w')) {
-        
-        return false; 
-    
-    }
-    
-    $success = fwrite($handle, $content);
-    
-    fclose($handle); 
-    
-    return $success; 
-
-}
-
-if ($_POST['submit'] == "editCSS" ) {
-
-    $text = $_POST["css-show"];
-    
-    write_ini_file($text, "custom.css");
-
-}
-
-?>
-
-<script>window.top.location = window.top.location.href.split('#')[0];</script>

+ 0 - 3
translate.php

@@ -1,3 +0,0 @@
-<?php
-// Legacy
-?>

+ 2 - 2
updatedb.php

@@ -28,7 +28,7 @@ function checkDatabase($type, $table, $check) {
     
     
     endif;
     endif;
     
     
-    $dbfile = DATABASE_LOCATION  . constant('User::DATABASE_NAME') . ".db";
+    $dbfile = DATABASE_LOCATION.'users.db';
     $file_db = new PDO("sqlite:" . $dbfile);
     $file_db = new PDO("sqlite:" . $dbfile);
     $file_db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
     $file_db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
     $runQuery = $file_db->query($query);
     $runQuery = $file_db->query($query);
@@ -127,4 +127,4 @@ function checkDatabase($type, $table, $check) {
 
 
     </body>
     </body>
 
 
-</html>
+</html>

+ 13 - 90
user.php

@@ -7,95 +7,18 @@
 	 *	entry is assigned a new random token,  which is used in
 	 *	entry is assigned a new random token,  which is used in
 	 * salting subsequent password checks.
 	 * salting subsequent password checks.
 	 */
 	 */
+	
+	// Include functions if not already included
+	require_once('functions.php');
+	
+	// Define Version
+	 define('INSTALLEDVERSION', '1.32');
 	 
 	 
-	// Upgrade Friendly START
-	if (file_exists('homepageSettings.ini.php')) {
-		$databaseConfig = parse_ini_file('databaseLocation.ini.php', true);
-		$homepageConfig = parse_ini_file('homepageSettings.ini.php', true);
-		
-		$databaseConfig = array_merge($databaseConfig, $homepageConfig);
-		
-		$databaseData = '; <?php die("Access denied"); ?>' . "\r\n";
-		foreach($databaseConfig as $k => $v) {
-			if(substr($v, -1) == "/") : $v = rtrim($v, "/"); endif;
-			$databaseData .= $k . " = \"" . $v . "\"\r\n";
-		}
-		
-		write_ini_file($databaseData, 'databaseLocation.ini.php');
-		unlink('homepageSettings.ini.php');
-		unset($databaseData);
-		unset($homepageConfig);
-	}
-	// Upgrade Friendly END
-	 
-    define('INSTALLEDVERSION', '1.31');
-    require __DIR__ . '/vendor/autoload.php';
-    $databaseConfig = parse_ini_file('databaseLocation.ini.php', true);
-    define('USER_HOME', $databaseConfig['databaseLocation'] . '/users/');
-    define('DATABASE_LOCATION', $databaseConfig['databaseLocation'] . '/');
-    if(!empty($databaseConfig['timezone'])) : define('TIMEZONE', $databaseConfig['timezone']); else : define('TIMEZONE', 'America/Los_Angeles'); endif;
-    if(!empty($databaseConfig['titleLogo'])) : define('TITLELOGO', $databaseConfig['titleLogo']); else : define('TITLELOGO', ''); endif;
-    if(!empty($databaseConfig['loadingIcon'])) : define('LOADINGICON', $databaseConfig['loadingIcon']); else : define('LOADINGICON', ''); endif;
-    if(!empty($databaseConfig['multipleLogin'])) : define('MULTIPLELOGIN', $databaseConfig['multipleLogin']); else : define('MULTIPLELOGIN', 'true'); endif;
-    if(!empty($databaseConfig['enableMail'])) : define('ENABLEMAIL', $databaseConfig['enableMail']); else : define('ENABLEMAIL', 'false'); endif;
-    if(!empty($databaseConfig['loadingScreen'])) : define('LOADINGSCREEN', $databaseConfig['loadingScreen']); else : define('LOADINGSCREEN', 'true'); endif;
-    if(!empty($databaseConfig['slimBar'])) : define('SLIMBAR', $databaseConfig['slimBar']); else : define('SLIMBAR', 'true'); endif;
-    if(!empty($databaseConfig['cookiePassword'])) : define('COOKIEPASSWORD', $databaseConfig['cookiePassword']); else : define('COOKIEPASSWORD', ''); endif;
-    if(!empty($databaseConfig['registerPassword'])) : define('REGISTERPASSWORD', $databaseConfig['registerPassword']); else : define('REGISTERPASSWORD', ''); endif;
-    if(!empty($databaseConfig['gravatar'])) : define('GRAVATAR', $databaseConfig['gravatar']); else : define('GRAVATAR', 'true'); endif;
-    if(!empty($databaseConfig['notifyEffect'])) : define('NOTIFYEFFECT', $databaseConfig['notifyEffect']); else : define('NOTIFYEFFECT', 'bar-slidetop'); endif;
-    if(!empty($databaseConfig['domain'])) : define('DOMAIN', $databaseConfig['domain']); else : define('DOMAIN', $_SERVER['HTTP_HOST']); endif;
-    if(!empty($databaseConfig['smtpHost'])) : define('SMTPHOST', $databaseConfig['smtpHost']); else : define('SMTPHOST', ''); endif;
-    if(!empty($databaseConfig['smtpHostPort'])) : define('SMTPHOSTPORT', $databaseConfig['smtpHostPort']); else : define('SMTPHOSTPORT', ''); endif;
-    if(!empty($databaseConfig['smtpHostAuth'])) : define('SMTPHOSTAUTH', $databaseConfig['smtpHostAuth']); else : define('SMTPHOSTAUTH', 'true'); endif;
-    if(!empty($databaseConfig['smtpHostUsername'])) : define('SMTPHOSTUSERNAME', $databaseConfig['smtpHostUsername']); else : define('SMTPHOSTUSERNAME', ''); endif;
-    if(!empty($databaseConfig['smtpHostPassword'])) : define('SMTPHOSTPASSWORD', $databaseConfig['smtpHostPassword']); else : define('SMTPHOSTPASSWORD', ''); endif;
-    if(!empty($databaseConfig['smtpHostSenderName'])) : define('SMTPHOSTSENDERNAME', $databaseConfig['smtpHostSenderName']); else : define('SMTPHOSTSENDERNAME', 'Organizr'); endif;
-    if(!empty($databaseConfig['smtpHostSenderEmail'])) : define('SMTPHOSTSENDEREMAIL', $databaseConfig['smtpHostSenderEmail']); else : define('SMTPHOSTSENDEREMAIL', 'no-reply@Organizr'); endif;
-    if(!empty($databaseConfig['authType'])) : define('AUTHTYPE', $databaseConfig['authType']); else : define('AUTHTYPE', ''); endif;
-    if(!empty($databaseConfig['authBackend'])) : define('AUTHBACKEND', $databaseConfig['authBackend']); else : define('AUTHBACKEND', ''); endif;
-    if(!empty($databaseConfig['authBackendHost'])) : define('AUTHBACKENDHOST', $databaseConfig['authBackendHost']); else : define('AUTHBACKENDHOST', ''); endif;
-    if(!empty($databaseConfig['authBackendPort'])) : define('AUTHBACKENDPORT', $databaseConfig['authBackendPort']); else : define('AUTHBACKENDPORT', ''); endif;
-    if(!empty($databaseConfig['authBackendDomain'])) : define('AUTHBACKENDDOMAIN', $databaseConfig['authBackendDomain']); else : define('AUTHBACKENDDOMAIN', ''); endif;
-    if(!empty($databaseConfig['authBackendCreate'])) : define('AUTHBACKENDCREATE', $databaseConfig['authBackendCreate']); else : define('AUTHBACKENDCREATE', 'false'); endif;      
-	if(!empty($databaseConfig['plexURL'])) : define('PLEXURL', $databaseConfig['plexURL']); else : define('PLEXURL', ''); endif;
-    if(!empty($databaseConfig['plexPort'])) : define('PLEXPORT', $databaseConfig['plexPort']); else : define('PLEXPORT', ''); endif;
-    if(!empty($databaseConfig['plexToken'])) : define('PLEXTOKEN', $databaseConfig['plexToken']); else : define('PLEXTOKEN', ''); endif;
-    if(!empty($databaseConfig['plexRecentMovie'])) : define('PLEXRECENTMOVIE', $databaseConfig['plexRecentMovie']); else : define('PLEXRECENTMOVIE', 'false'); endif;
-    if(!empty($databaseConfig['plexRecentTV'])) : define('PLEXRECENTTV', $databaseConfig['plexRecentTV']); else : define('PLEXRECENTTV', 'false'); endif;
-    if(!empty($databaseConfig['plexRecentMusic'])) : define('PLEXRECENTMUSIC', $databaseConfig['plexRecentMusic']); else : define('PLEXRECENTMUSIC', 'false'); endif;
-    if(!empty($databaseConfig['plexPlayingNow'])) : define('PLEXPLAYINGNOW', $databaseConfig['plexPlayingNow']); else : define('PLEXPLAYINGNOW', 'false'); endif;
-    if(!empty($databaseConfig['embyURL'])) : define('EMBYURL', $databaseConfig['embyURL']); else : define('EMBYURL', ''); endif;
-    if(!empty($databaseConfig['embyPort'])) : define('EMBYPORT', $databaseConfig['embyPort']); else : define('EMBYPORT', ''); endif;
-    if(!empty($databaseConfig['embyToken'])) : define('EMBYTOKEN', $databaseConfig['embyToken']); else : define('EMBYTOKEN', ''); endif;
-    if(!empty($databaseConfig['embyRecentMovie'])) : define('EMBYRECENTMOVIE', $databaseConfig['embyRecentMovie']); else : define('EMBYRECENTMOVIE', 'false'); endif;
-    if(!empty($databaseConfig['embyRecentTV'])) : define('EMBYRECENTTV', $databaseConfig['embyRecentTV']); else : define('EMBYRECENTTV', 'false'); endif;
-    if(!empty($databaseConfig['embyRecentMusic'])) : define('EMBYRECENTMUSIC', $databaseConfig['embyRecentMusic']); else : define('EMBYRECENTMUSIC', 'false'); endif;
-    if(!empty($databaseConfig['embyPlayingNow'])) : define('EMBYPLAYINGNOW', $databaseConfig['embyPlayingNow']); else : define('EMBYPLAYINGNOW', 'false'); endif;    
-    if(!empty($databaseConfig['sonarrKey'])) : define('SONARRKEY', $databaseConfig['sonarrKey']); else : define('SONARRKEY', ''); endif;
-    if(!empty($databaseConfig['sonarrURL'])) : define('SONARRURL', $databaseConfig['sonarrURL']); else : define('SONARRURL', ''); endif;
-    if(!empty($databaseConfig['sonarrPort'])) : define('SONARRPORT', $databaseConfig['sonarrPort']); else : define('SONARRPORT', ''); endif;
-    if(!empty($databaseConfig['radarrKey'])) : define('RADARRKEY', $databaseConfig['radarrKey']); else : define('RADARRKEY', ''); endif;
-    if(!empty($databaseConfig['radarrURL'])) : define('RADARRURL', $databaseConfig['radarrURL']); else : define('RADARRURL', ''); endif;
-    if(!empty($databaseConfig['radarrPort'])) : define('RADARRPORT', $databaseConfig['radarrPort']); else : define('RADARRPORT', ''); endif;
-    if(!empty($databaseConfig['nzbgetURL'])) : define('NZBGETURL', $databaseConfig['nzbgetURL']); else : define('NZBGETURL', ''); endif;
-    if(!empty($databaseConfig['nzbgetPort'])) : define('NZBGETPORT', $databaseConfig['nzbgetPort']); else : define('NZBGETPORT', ''); endif;
-    if(!empty($databaseConfig['nzbgetUsername'])) : define('NZBGETUSERNAME', $databaseConfig['nzbgetUsername']); else : define('NZBGETUSERNAME', ''); endif;
-    if(!empty($databaseConfig['nzbgetPassword'])) : define('NZBGETPASSWORD', $databaseConfig['nzbgetPassword']); else : define('NZBGETPASSWORD', ''); endif;
-    if(!empty($databaseConfig['sabnzbdKey'])) : define('SABNZBDKEY', $databaseConfig['sabnzbdKey']); else : define('SABNZBDKEY', ''); endif;
-    if(!empty($databaseConfig['sabnzbdURL'])) : define('SABNZBDURL', $databaseConfig['sabnzbdURL']); else : define('SABNZBDURL', ''); endif;
-    if(!empty($databaseConfig['sabnzbdPort'])) : define('SABNZBDPORT', $databaseConfig['sabnzbdPort']); else : define('SABNZBDPORT', ''); endif;
-    if(!empty($databaseConfig['headphonesKey'])) : define('HEADPHONESKEY', $databaseConfig['headphonesKey']); else : define('HEADPHONESKEY', ''); endif;
-    if(!empty($databaseConfig['headphonesURL'])) : define('HEADPHONESURL', $databaseConfig['headphonesURL']); else : define('HEADPHONESURL', ''); endif;
-    if(!empty($databaseConfig['headphonesPort'])) : define('HEADPHONESPORT', $databaseConfig['headphonesPort']); else : define('HEADPHONESPORT', ''); endif;
-    if(!empty($databaseConfig['calendarStart'])) : define('CALENDARSTART', $databaseConfig['calendarStart']); else : define('CALENDARSTART', '0'); endif;
-    if(!empty($databaseConfig['calendarView'])) : define('CALENDARVIEW', $databaseConfig['calendarView']); else : define('CALENDARVIEW', 'basicWeek'); endif;
-    if(!empty($databaseConfig['calendarStartDay'])) : define('CALENDARSTARTDAY', $databaseConfig['calendarStartDay']); else : define('CALENDARSTARTDAY', '30'); endif;
-    if(!empty($databaseConfig['calendarEndDay'])) : define('CALENDARENDDAY', $databaseConfig['calendarEndDay']); else : define('CALENDARENDDAY', '30'); endif;
-    if(!empty($databaseConfig['sickrageKey'])) : define('SICKRAGEKEY', $databaseConfig['sickrageKey']); else : define('SICKRAGEKEY', ''); endif;
-    if(!empty($databaseConfig['sickrageURL'])) : define('SICKRAGEURL', $databaseConfig['sickrageURL']); else : define('SICKRAGEURL', ''); endif;
-    if(!empty($databaseConfig['plexUsername'])) : define('PLEXUSERNAME', $databaseConfig['plexUsername']); else : define('PLEXUSERNAME', ''); endif;
-	if(!empty($databaseConfig['plexPassword'])) : define('PLEXPASSWORD', $databaseConfig['plexPassword']); else : define('PLEXPASSWORD', ''); endif;
+    // Autoload frameworks
+	require_once(__DIR__ . '/vendor/autoload.php');
+	
+    // Lazyload settings
+	$databaseConfig = configLazy('config/config.php');
     
     
     if(file_exists('custom.css')) : define('CUSTOMCSS', 'true'); else : define('CUSTOMCSS', 'false'); endif; 
     if(file_exists('custom.css')) : define('CUSTOMCSS', 'true'); else : define('CUSTOMCSS', 'false'); endif; 
     $notifyExplode = explode("-", NOTIFYEFFECT);
     $notifyExplode = explode("-", NOTIFYEFFECT);
@@ -148,7 +71,7 @@
 		// 	You can modify the following values, but they're not security related
 		// 	You can modify the following values, but they're not security related
 		// =======================================================================
 		// =======================================================================
 			// rename this to whatever you like
 			// rename this to whatever you like
-			const DATABASE_NAME = "users";
+			const DATABASE_NAME = "users";  // Obsolete
 			// this is the session timeout. If someone hasn't performed any page requests
 			// this is the session timeout. If someone hasn't performed any page requests
 			// in [timeout] seconds, they're considered logged out.
 			// in [timeout] seconds, they're considered logged out.
 			const time_out = 604800;
 			const time_out = 604800;
@@ -229,7 +152,7 @@
                 $_SESSION["username"] = $_COOKIE['OrganizrU'];
                 $_SESSION["username"] = $_COOKIE['OrganizrU'];
             }
             }
 			// file location for the user database
 			// file location for the user database
-			$dbfile = DATABASE_LOCATION  . User::DATABASE_NAME . ".db";
+			$dbfile = DATABASE_LOCATION.'users.db';
 			// do we need to build a new database?
 			// do we need to build a new database?
 			$rebuild = false;
 			$rebuild = false;
 			if(!file_exists($dbfile)) { $rebuild = true;}
 			if(!file_exists($dbfile)) { $rebuild = true;}