Explorar o código

Core update (Nibreh remix)

markseu %!s(int64=10) %!d(string=hai) anos
pai
achega
d509829f24

+ 1 - 1
README.md

@@ -1,4 +1,4 @@
-Yellow 0.5.6
+Yellow 0.5.7
 ============
 [![Yellow](https://raw.githubusercontent.com/wiki/datenstrom/yellow/images/yellow.jpg)](http://datenstrom.se/yellow)
 

+ 1 - 0
system/config/language-en.ini

@@ -23,4 +23,5 @@ webinterfaceEdit			= Edit page
 webinterfaceNew				= +
 webinterfaceUserHelp		= Help
 webinterfaceUserHelpUrl		= https://github.com/datenstrom/yellow/wiki
+webinterfaceUserAccountUrl	= https://github.com/datenstrom/yellow/wiki/How-to-add-a-user-account
 webinterfaceUserLogout		= Logout

+ 1 - 1
system/config/page-error-401.txt

@@ -1,4 +1,4 @@
 ---
 Title: Unauthorised
 ---
-You are not authorised on this server. Please log in.
+You are not authorised on this server. [Please log in](javascript:yellow.action('login');).

+ 1 - 1
system/core/core-webinterface.css

@@ -1,4 +1,4 @@
-/* Yellow web interface 0.5.3 */
+/* Yellow web interface 0.5.7 */
 
 .yellow-bar { position:relative; overflow:hidden; line-height:2em; margin-bottom:10px; }
 .yellow-bar-left { display:block; float:left; }

+ 3 - 2
system/core/core-webinterface.js

@@ -4,7 +4,7 @@
 // Yellow main API
 var yellow =
 {
-	version: "0.5.3",
+	version: "0.5.7",
 	action: function(text) { yellow.webinterface.action(text); },
 	onClick: function(e) { yellow.webinterface.hidePanesOnClick(yellow.toolbox.getEventElement(e)); },
 	onKeydown: function(e) { yellow.webinterface.hidePanesOnKeydown(yellow.toolbox.getEventKeycode(e)); },
@@ -48,7 +48,7 @@ yellow.webinterface =
 			} else {
 				this.createBar("yellow-bar", false, body.firstChild);
 				this.createPane("yellow-pane-login", false, body.firstChild);
-				this.showPane("yellow-pane-login");
+				if(yellow.config.login) this.showPane("yellow-pane-login");
 			}
 			clearInterval(this.intervalId);
 		}
@@ -64,6 +64,7 @@ yellow.webinterface =
 			case "user":	this.togglePane("yellow-pane-user"); break;
 			case "send":	this.sendPane(this.paneId, this.paneType); break;
 			case "cancel":	this.hidePane(this.paneId); break;
+			case "login":	this.togglePane("yellow-pane-login"); break;
 			case "logout":	yellow.toolbox.submitForm({"action":"logout"}); break;
 		}
 	},

+ 18 - 2
system/core/core-webinterface.php

@@ -5,7 +5,7 @@
 // Web interface core plugin
 class YellowWebinterface
 {
-	const Version = "0.5.6";
+	const Version = "0.5.7";
 	var $yellow;				//access to API
 	var $active;				//web interface is active? (boolean)
 	var $userLoginFailed;		//web interface login failed? (boolean)
@@ -168,7 +168,16 @@ class YellowWebinterface
 		if($statusCode == 0)
 		{
 			$statusCode = $this->yellow->processRequest($serverScheme, $serverName, $base, $location, $fileName, false);
-			if($this->userLoginFailed) $this->yellow->page->error(401);
+			if($this->userLoginFailed)
+			{
+				if(!$this->users->getNumber())
+				{
+					$url = $this->yellow->text->get("webinterfaceUserAccountUrl");
+					$this->yellow->page->error(500, "You are not authorised on this server, [please add a user account]($url)!");
+				} else {
+					$this->yellow->page->error(401);
+				}
+			}
 		}
 		return $statusCode;
 	}
@@ -477,6 +486,7 @@ class YellowWebinterface
 			$data["serverName"] = $this->yellow->config->get("serverName");
 			$data["serverBase"] = $this->yellow->config->get("serverBase");
 		} else {
+			$data["login"] = $this->yellow->page->statusCode==200;
 			$data["loginEmail"] = $this->yellow->config->get("loginEmail");
 			$data["loginPassword"] = $this->yellow->config->get("loginPassword");
 		}
@@ -638,6 +648,12 @@ class YellowWebinterfaceUsers
 		return $this->isExisting($email) ? $this->users[$email]["home"] : "";
 	}
 	
+	// Return number of users
+	function getNumber()
+	{
+		return count($this->users);
+	}
+	
 	// Check if user exists
 	function isExisting($email)
 	{

+ 2 - 2
system/core/core.php

@@ -5,7 +5,7 @@
 // Yellow main class
 class Yellow
 {
-	const Version = "0.5.6";
+	const Version = "0.5.7";
 	var $page;				//current page
 	var $pages;				//pages from file system
 	var $files;				//files from file system
@@ -421,7 +421,7 @@ class YellowPage
 		$this->rawData = $rawData;
 		$this->parser = NULL;
 		$this->parserData = "";
-		$this->parserSafeMode = $this->yellow->config->get("parserSafeMode");
+		$this->parserSafeMode = intval($this->yellow->config->get("parserSafeMode"));
 		$this->available = true;
 		$this->visible = $this->yellow->lookup->isVisibleLocation($this->location, $this->fileName);
 		$this->active = $this->yellow->lookup->isActiveLocation($this->location, $this->yellow->page->location);