瀏覽代碼

Small Fixes

Fix Ajax POST to have non admin functions
Fix PLEX error logs
More PLEX Search work
Added close tab on org
Changed text editor for homepage message
causefx 9 年之前
父節點
當前提交
74212bb561
共有 4 個文件被更改,包括 110 次插入86 次删除
  1. 65 62
      ajax.php
  2. 20 7
      functions.php
  3. 13 5
      index.php
  4. 12 12
      settings.php

+ 65 - 62
ajax.php

@@ -72,68 +72,71 @@ switch ($_SERVER['REQUEST_METHOD']) {
 		}
 		}
 		break;
 		break;
 	case 'POST':
 	case 'POST':
-		// Check if the user is an admin and is allowed to commit values
-		qualifyUser('admin', true);
-		switch ($action) {
-   case 'search-plex':
-    $response = searchPlex($_POST['searchtitle']);
-    break;
-   case 'check-url':
-				sendResult(frameTest($_POST['checkurl']), "flask", $_POST['checkurl'], "IFRAME_CAN_BE_FRAMED", "IFRAME_CANNOT_BE_FRAMED");
-				break;
-			case 'upload-images':
-				uploadFiles('images/', array('jpg', 'png', 'svg', 'jpeg', 'bmp'));
-				sendNotification(true);
-				break;
-			case 'remove-images':
-				removeFiles('images/'.(isset($_POST['file'])?$_POST['file']:''));
-				sendNotification(true);
-				break;
-			case 'update-config':
-				sendNotification(updateConfig($_POST));
-				break;
-			case 'update-appearance':
-				// Custom CSS Special Case START
-				if (isset($_POST['customCSS'])) {
-					if ($_POST['customCSS']) {
-						write_ini_file($_POST['customCSS'], 'custom.css');
-					} else {
-						unlink('custom.css');
-					}
-					$response['parent']['reload'] = true;
-				}
-				unset($_POST['customCSS']);
-				// Custom CSS Special Case END
-				$response['notify'] = sendNotification(updateDBOptions($_POST),false,false);
-				break;
-			case 'deleteDB':
-				deleteDatabase();
-				sendNotification(true, 'Database Deleted!');
-				break;
-			case 'upgradeInstall':
-				upgradeInstall();
-				$response['notify'] = sendNotification(true, 'Performing Checks', false);
-				$response['tab']['goto'] = 'updatedb.php';
-				break;
-			case 'forceBranchInstall':
-				upgradeInstall(GIT_BRANCH);
-				$response['notify'] = sendNotification(true, 'Performing Checks', false);
-				$response['tab']['goto'] = 'updatedb.php';
-				break;
-			case 'deleteLog':
-				sendNotification(unlink(FAIL_LOG));
-				break;
-   case 'deleteOrgLog':
-				sendNotification(unlink("org.log"));
-				break;
-			case 'submit-tabs':
-				$response['notify'] = sendNotification(updateTabs($_POST) , false, false);
-				$response['show_apply'] = true;
-				break;
-			default:
-				sendNotification(false, 'Unsupported Action!');
-		}
-		break;
+        // Check if the user is an admin and is allowed to commit values
+        switch ($action) {
+            case 'search-plex':
+			 	$response = searchPlex($_POST['searchtitle']);
+			 	break;
+            default: // Stuff that you need admin for
+                qualifyUser('admin', true);
+                switch ($action) {
+                    case 'check-url':
+                        sendResult(frameTest($_POST['checkurl']), "flask", $_POST['checkurl'], "IFRAME_CAN_BE_FRAMED", "IFRAME_CANNOT_BE_FRAMED");
+                        break;
+                    case 'upload-images':
+                        uploadFiles('images/', array('jpg', 'png', 'svg', 'jpeg', 'bmp'));
+                        sendNotification(true);
+                        break;
+                    case 'remove-images':
+                        removeFiles('images/'.(isset($_POST['file'])?$_POST['file']:''));
+                        sendNotification(true);
+                        break;
+                    case 'update-config':
+                        sendNotification(updateConfig($_POST));
+                        break;
+                    case 'update-appearance':
+                        // Custom CSS Special Case START
+                        if (isset($_POST['customCSS'])) {
+                            if ($_POST['customCSS']) {
+                                write_ini_file($_POST['customCSS'], 'custom.css');
+                            } else {
+                                unlink('custom.css');
+                            }
+                            $response['parent']['reload'] = true;
+                        }
+                        unset($_POST['customCSS']);
+                        // Custom CSS Special Case END
+                        $response['notify'] = sendNotification(updateDBOptions($_POST),false,false);
+                        break;
+                    case 'deleteDB':
+                        deleteDatabase();
+                        sendNotification(true, 'Database Deleted!');
+                        break;
+                    case 'upgradeInstall':
+                        upgradeInstall();
+                        $response['notify'] = sendNotification(true, 'Performing Checks', false);
+                        $response['tab']['goto'] = 'updatedb.php';
+                        break;
+                    case 'forceBranchInstall':
+                        upgradeInstall(GIT_BRANCH);
+                        $response['notify'] = sendNotification(true, 'Performing Checks', false);
+                        $response['tab']['goto'] = 'updatedb.php';
+                        break;
+                    case 'deleteLog':
+                        sendNotification(unlink(FAIL_LOG));
+                        break;
+                    case 'deleteOrgLog':
+                        sendNotification(unlink("org.log"));
+                        break;
+                    case 'submit-tabs':
+                        $response['notify'] = sendNotification(updateTabs($_POST) , false, false);
+                        $response['show_apply'] = true;
+                        break;
+                    default:
+                        sendNotification(false, 'Unsupported Action!');
+                }
+        }
+        break;
 	case 'PUT':
 	case 'PUT':
 		sendNotification(false, 'Unsupported Action!');
 		sendNotification(false, 'Unsupported Action!');
 		break;
 		break;

+ 20 - 7
functions.php

@@ -177,7 +177,7 @@ if (function_exists('curl_version')) :
 	function plugin_auth_plex($username, $password) {
 	function plugin_auth_plex($username, $password) {
 		// Quick out
 		// Quick out
 		if ((strtolower(PLEXUSERNAME) == strtolower($username)) && $password == PLEXPASSWORD) {
 		if ((strtolower(PLEXUSERNAME) == strtolower($username)) && $password == PLEXPASSWORD) {
-   writeLog("success", $username." authenticated by plex");
+   			writeLog("success", $username." authenticated by plex");
 			return true;
 			return true;
 		}
 		}
 		
 		
@@ -194,7 +194,7 @@ if (function_exists('curl_version')) :
 			foreach($userXML AS $child) {
 			foreach($userXML AS $child) {
 				if(isset($child['username']) && strtolower($child['username']) == $usernameLower) {
 				if(isset($child['username']) && strtolower($child['username']) == $usernameLower) {
 					$isUser = true;
 					$isUser = true;
-     writeLog("success", $usernameLower." was found in plex friends list");
+     				writeLog("success", $usernameLower." was found in plex friends list");
 					break;
 					break;
 				}
 				}
 			}
 			}
@@ -217,16 +217,19 @@ if (function_exists('curl_version')) :
 				if (isset($result['content'])) {
 				if (isset($result['content'])) {
 					$json = json_decode($result['content'], true);
 					$json = json_decode($result['content'], true);
 					if (is_array($json) && isset($json['user']) && isset($json['user']['username']) && strtolower($json['user']['username']) == $usernameLower) {
 					if (is_array($json) && isset($json['user']) && isset($json['user']['username']) && strtolower($json['user']['username']) == $usernameLower) {
-         writeLog("success", $json['user']['username']." was logged into plex and pulled credentials");
+						writeLog("success", $json['user']['username']." was logged into organizr using plex credentials");
                         return array(
                         return array(
 							'email' => $json['user']['email'],
 							'email' => $json['user']['email'],
 							'image' => $json['user']['thumb']
 							'image' => $json['user']['thumb']
 						);
 						);
 					}
 					}
 				}
 				}
+			}else{
+				writeLog("error", "$username is not an authorized user or entered invalid password");
 			}
 			}
+		}else{
+  			writeLog("error", "error occured logging into plex might want to check curl.cainfo=/path/to/downloaded/cacert.pem in php.ini");   
 		}
 		}
-  writeLog("error", "error occured logging into plex might want to check curl.cainfo=/path/to/downloaded/cacert.pem in php.ini");   
 		return false;
 		return false;
 	}
 	}
 else :
 else :
@@ -3013,7 +3016,7 @@ function searchPlex($query){
     // Perform API requests
     // Perform API requests
     $api = @curl_get($address."/search?query=".rawurlencode($query)."&X-Plex-Token=".PLEXTOKEN);
     $api = @curl_get($address."/search?query=".rawurlencode($query)."&X-Plex-Token=".PLEXTOKEN);
     $api = simplexml_load_string($api);
     $api = simplexml_load_string($api);
-    $pre = "<table  class=\"table table-hover table-stripped\"><thead><tr><th>Cover</th><th>Title</th><th>Genre</th><th>Year</th><th>Type</th><th>Added</th></tr></thead><tbody>";
+    $pre = "<table  class=\"table table-hover table-stripped\"><thead><tr><th>Cover</th><th>Title</th><th>Genre</th><th>Year</th><th>Type</th><th>Added</th><th>Extra Info</th></tr></thead><tbody>";
     $items = "";
     $items = "";
     $albums = $movies = $shows = 0;
     $albums = $movies = $shows = 0;
     
     
@@ -3030,6 +3033,7 @@ function searchPlex($query){
                 "key" => (string)$child['key'],
                 "key" => (string)$child['key'],
                 "genre" => (string)$child->Genre['tag'],
                 "genre" => (string)$child->Genre['tag'],
                 "added" => $time->format('Y-m-d'),
                 "added" => $time->format('Y-m-d'),
+                "extra" => "",
             );
             );
             switch ($child['type']){
             switch ($child['type']){
                 case "album":
                 case "album":
@@ -3040,19 +3044,28 @@ function searchPlex($query){
                     $albums++;
                     $albums++;
                     break;
                     break;
                 case "movie":
                 case "movie":
+					$push = array(
+                        "extra" => "Content Rating: ".(string)$child['contentRating']."<br/>Movie Rating: ".(string)$child['rating'],
+                    ); 
+			  		$results = array_replace($results,$push);
                     $movies++;
                     $movies++;
                     break;
                     break;
                 case "show":
                 case "show":
+			  		$push = array(
+                        "extra" => "Seasons: ".(string)$child['childCount']."<br/>Episodes: ".(string)$child['leafCount'],
+                    ); 
+			  		$results = array_replace($results,$push);
                     $shows++;
                     $shows++;
                     break;
                     break;
             }
             }
             $items .= '<tr>
             $items .= '<tr>
             <th scope="row"><img src="ajax.php?a=plex-image&img='.$results['image'].'&height=100&width=50&key='.$results['key'].'"></th>
             <th scope="row"><img src="ajax.php?a=plex-image&img='.$results['image'].'&height=100&width=50&key='.$results['key'].'"></th>
-            <td class="col-xs-3 nzbtable nzbtable-row"'.$style.'>'.$results['title'].'</td>
-            <td class="col-xs-4 nzbtable nzbtable-row"'.$style.'>'.$results['genre'].'</td>
+            <td class="col-xs-2 nzbtable nzbtable-row"'.$style.'>'.$results['title'].'</td>
+            <td class="col-xs-3 nzbtable nzbtable-row"'.$style.'>'.$results['genre'].'</td>
             <td class="col-xs-1 nzbtable nzbtable-row"'.$style.'>'.$results['year'].'</td>
             <td class="col-xs-1 nzbtable nzbtable-row"'.$style.'>'.$results['year'].'</td>
             <td class="col-xs-1 nzbtable nzbtable-row"'.$style.'>'.$results['type'].'</td>
             <td class="col-xs-1 nzbtable nzbtable-row"'.$style.'>'.$results['type'].'</td>
             <td class="col-xs-3 nzbtable nzbtable-row"'.$style.'>'.$results['added'].'</td>
             <td class="col-xs-3 nzbtable nzbtable-row"'.$style.'>'.$results['added'].'</td>
+            <td class="col-xs-2 nzbtable nzbtable-row"'.$style.'>'.$results['extra'].'</td>
             </tr>';
             </tr>';
         }
         }
     }
     }

+ 13 - 5
index.php

@@ -640,7 +640,7 @@ endif; ?>
                                 <i class="mdi mdi-window-restore"></i>
                                 <i class="mdi mdi-window-restore"></i>
                             </a>
                             </a>
                         </li>
                         </li>
-                        <li style="display: none" id="splitView" class="dropdown some-btn">
+                        <li style="display: block" id="splitView" class="dropdown some-btn">
                             <a class="spltView">
                             <a class="spltView">
                                 <i class="mdi mdi-window-close"></i>
                                 <i class="mdi mdi-window-close"></i>
                             </a>
                             </a>
@@ -1381,13 +1381,21 @@ endif; ?>
             return false;
             return false;
 
 
         });
         });
-        $('#splitView').on('click tap', function(){
-
-            $('#splitView').hide();
+        $('#splitView').on('contextmenu', function(e){
+			e.stopPropagation();
+            //$('#splitView').hide();
             $("#content").attr("class", "content");
             $("#content").attr("class", "content");
             $("li[class^='tab-item rightActive']").attr("class", "tab-item");
             $("li[class^='tab-item rightActive']").attr("class", "tab-item");
             $("#contentRight").html('');
             $("#contentRight").html('');
-
+			return false;
+        });
+		$('#splitView').on('click tap', function(){
+			var activeFrame = $('#content').find('.active');
+			var getCurrentTab = $("li[class^='tab-item active']");
+			getCurrentTab.removeClass('active');
+			getCurrentTab.find('img').removeClass('TabOpened');
+			$("img[class^='TabOpened']").parents("li").trigger("click");
+			activeFrame.remove();
         });
         });
         <?php if($iconRotate == "true") : ?>   
         <?php if($iconRotate == "true") : ?>   
         $("li[id^='settings.phpx']").on('click tap', function(){
         $("li[id^='settings.phpx']").on('click tap', function(){

+ 12 - 12
settings.php

@@ -1123,6 +1123,7 @@ echo buildSettings(
 					),*/
 					),*/
         array(
         array(
 						'type' => 'custom',
 						'type' => 'custom',
+		 				'labelTranslate' => 'NOTICE_MESSAGE',
 						'html' => '<div class="summernote" name="homepageNoticeMessage">'.HOMEPAGENOTICEMESSAGE.'</div>',
 						'html' => '<div class="summernote" name="homepageNoticeMessage">'.HOMEPAGENOTICEMESSAGE.'</div>',
 					),
 					),
 				),
 				),
@@ -2243,17 +2244,13 @@ echo buildSettings(
                 
                 
                 $('.summernote').summernote({
                 $('.summernote').summernote({
                     height: 120,
                     height: 120,
-                    toolbar: [
-                      //[groupname, [button list]]
-
-                      ['style', ['bold', 'italic', 'underline', 'clear']],
-                      ['font', ['strikethrough', 'superscript', 'subscript']],
-                      ['fontsize', ['fontsize']],
-                      ['color', ['color']],
-                      ['para', ['ul', 'ol', 'paragraph']],
-                      ['height', ['height']],
-                    ]
-                  });
+                    codemirror: { // codemirror options
+						mode: 'text/html',
+						htmlMode: true,
+						lineNumbers: true,
+						theme: 'monokai'
+					}
+				});		
 
 
                 // summernote.change
                 // summernote.change
                 $('.summernote').on('summernote.change', function(we, contents, $editable) {
                 $('.summernote').on('summernote.change', function(we, contents, $editable) {
@@ -2615,7 +2612,7 @@ echo buildSettings(
             });
             });
              $(document).mouseup(function (e)
              $(document).mouseup(function (e)
 {
 {
-                var container = $(".email-content, .checkFrame, #content");
+                var container = $(".email-content, .checkFrame, .scroller-body");
 
 
                 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");
@@ -2719,6 +2716,9 @@ echo buildSettings(
             //Hide Icon box on load
             //Hide Icon box on load
             $( "div[class^='jFiler jFiler-theme-dragdropbox']" ).hide();
             $( "div[class^='jFiler jFiler-theme-dragdropbox']" ).hide();
             //Set Some Scrollbars
             //Set Some Scrollbars
+			$(".note-editable panel-body").niceScroll({
+                railpadding: {top:0,right:0,left:0,bottom:0}
+            });
             $(".scroller-body").niceScroll({
             $(".scroller-body").niceScroll({
                 railpadding: {top:0,right:0,left:0,bottom:0}
                 railpadding: {top:0,right:0,left:0,bottom:0}
             });
             });