commit a461c117c395ab54c79096f6e909811cf922031a
parent 119d173abe3909837463e9c91e3cd9e3d9e0c2ff
Author: markseu <mark2011@mayberg.se>
Date: Tue, 16 Aug 2016 10:16:13 +0200
System update (software update)
Diffstat:
9 files changed, 172 insertions(+), 50 deletions(-)
diff --git a/content/9-about/page.txt b/content/9-about/page.txt
@@ -3,4 +3,4 @@ Title: About
---
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna pizza. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
-[yellow server]
-\ No newline at end of file
+This website is made with [yellow]
+\ No newline at end of file
diff --git a/system/plugins/commandline.php b/system/plugins/commandline.php
@@ -5,7 +5,7 @@
// Command line plugin
class YellowCommandline
{
- const VERSION = "0.6.14";
+ const VERSION = "0.6.15";
var $yellow; //access to API
var $files; //number of files
var $errors; //number of errors
@@ -66,7 +66,7 @@ class YellowCommandline
$this->files = 0; $this->errors = 1;
$fileName = $this->yellow->config->get("configDir").$this->yellow->config->get("configFile");
echo "ERROR building files: Please configure ServerScheme, ServerName, ServerBase, ServerTime in file '$fileName'!\n";
- echo "ERROR building files: To see your web server configuration, open your website in a web browser!\n";
+ echo "ERROR building files: Open your website in a web browser, if you want to see your server settings!\n";
}
echo "Yellow $command: $this->files file".($this->files!=1 ? 's' : '');
echo ", $this->errors error".($this->errors!=1 ? 's' : '');
@@ -319,7 +319,7 @@ class YellowCommandline
{
echo "$key $value\n";
} else {
- echo "$key $value - Update available\n";
+ echo "$key $dataLatest[$key] - Update available\n";
++$updates;
}
}
diff --git a/system/plugins/language-de.txt b/system/plugins/language-de.txt
@@ -3,7 +3,7 @@
Language: de
LanguageDescription: Deutsch
LanguageAuthor: David Fehrmann
-LanguageVersion: 0.6.7
+LanguageVersion: 0.6.8
BlogBy: von
BlogFilter: Blog:
@@ -58,7 +58,7 @@ WebinterfaceRecoverStatusWeak: Bitte eine anderes Kennwort angeben.
WebinterfaceRecoverStatusNext: Benutzerkonto wird wiederhergestellt, bitte überprüfe deine E-Mails.
WebinterfaceSettingsTitle: Einstellungen
WebinterfaceSettingsStatusInvalid: Bitte eine gültige E-Mail angeben.
-WebinterfaceSettingsStatusExists: Bitte eine andere E-Mail angeben.
+WebinterfaceSettingsStatusTaken: Bitte eine andere E-Mail angeben.
WebinterfaceSettingsStatusWeak: Bitte eine anderes Kennwort angeben.
WebinterfaceSettingsStatusNext: Benutzerkonto wird geändert, bitte überprüfe deine E-Mails.
WebinterfaceConfirmSubject: Benutzerkonto bestätigen
@@ -85,11 +85,11 @@ WebinterfaceWelcomeSubject: Willkommen
WebinterfaceWelcomeMessage: Hallo @usershort, dein Benutzerkonto wurde erstellt. Viel Spass beim Bearbeiten der Webseite.
WebinterfaceInformationSubject: Willkommen zurück
WebinterfaceInformationMessage: Hallo @usershort, dein Benutzerkonto wurde geändert. Du kannst dich jetzt anmelden.
-WebinterfaceUpdateTitle: Aktualisierung
-WebinterfaceUpdateCheck: Nach Aktualisierung suchen
-WebinterfaceUpdateStatusNone: Nach Aktualisierung suchen…
-WebinterfaceUpdateStatusEmpty: Keine Aktualisierung verfügbar.
-WebinterfaceUpdateButton: Aktualisieren
+WebinterfaceVersionTitle: Über diese Webseite
+WebinterfaceVersionStatusNone: Nach Aktualiserung suchen…
+WebinterfaceVersionStatusLatest: Keine Aktualisierung verfügbar.
+WebinterfaceVersionStatusUpdates: Aktualiserung verfügbar, bitte an den Webmaster wenden.
+WebinterfaceVersionUpdate: Aktualisieren
WebinterfaceOkButton: Ok
WebinterfaceCancelButton: Abbruch
WebinterfaceCreateButton: Erzeugen
diff --git a/system/plugins/language-en.txt b/system/plugins/language-en.txt
@@ -3,7 +3,7 @@
Language: en
LanguageDescription: English
LanguageAuthor: Mark Seuffert
-LanguageVersion: 0.6.7
+LanguageVersion: 0.6.8
BlogBy: by
BlogFilter: Blog:
@@ -58,7 +58,7 @@ WebinterfaceRecoverStatusWeak: Please enter a different password.
WebinterfaceRecoverStatusNext: User account will be recovered, please check your emails.
WebinterfaceSettingsTitle: Settings
WebinterfaceSettingsStatusInvalid: Please enter a valid email.
-WebinterfaceSettingsStatusExists: Please enter a different email.
+WebinterfaceSettingsStatusTaken: Please enter a different email.
WebinterfaceSettingsStatusWeak: Please enter a different password.
WebinterfaceSettingsStatusNext: User account will be changed, please check your emails.
WebinterfaceConfirmSubject: Confirm user account
@@ -85,11 +85,11 @@ WebinterfaceWelcomeSubject: Welcome
WebinterfaceWelcomeMessage: Hi @usershort, your user account has been created. Have fun editing the website.
WebinterfaceInformationSubject: Welcome back
WebinterfaceInformationMessage: Hi @usershort, your user account has been changed. You can now log in.
-WebinterfaceUpdateTitle: Updates
-WebinterfaceUpdateCheck: Check for updates
-WebinterfaceUpdateStatusNone: Checking for updates…
-WebinterfaceUpdateStatusEmpty: No updates available.
-WebinterfaceUpdateButton: Update
+WebinterfaceVersionTitle: About this website
+WebinterfaceVersionStatusNone: Checking for updates…
+WebinterfaceVersionStatusLatest: No updates available.
+WebinterfaceVersionStatusUpdates: Updates available, please contact the webmaster.
+WebinterfaceVersionUpdate: Update
WebinterfaceOkButton: Ok
WebinterfaceCancelButton: Cancel
WebinterfaceCreateButton: Create
diff --git a/system/plugins/language-fr.txt b/system/plugins/language-fr.txt
@@ -3,7 +3,7 @@
Language: fr
LanguageDescription: Français
LanguageAuthor: Juh Nibreh
-LanguageVersion: 0.6.7
+LanguageVersion: 0.6.8
BlogBy: par
BlogFilter: Blog:
@@ -58,7 +58,7 @@ WebinterfaceRecoverStatusWeak: S'il vous plaît, choisissez un mot de passe diff
WebinterfaceRecoverStatusNext: Votre compte est à nouveau disponible, vérifiez vos emails.
WebinterfaceSettingsTitle: Paramètres
WebinterfaceSettingsStatusInvalid: S'il vous plaît, veuillez entrer une adresse email valide.
-WebinterfaceSettingsStatusExists: S'il vous plaît, veuillez entrer une adresse email différent.
+WebinterfaceSettingsStatusTaken: S'il vous plaît, veuillez entrer une adresse email différent.
WebinterfaceSettingsStatusWeak: S'il vous plaît, choisissez un mot de passe différent.
WebinterfaceSettingsStatusNext: Votre compte a été changé, vérifiez vos emails.
WebinterfaceConfirmSubject: Confirmation d'un compte utilisateur
@@ -85,11 +85,11 @@ WebinterfaceWelcomeSubject: Bienvenue
WebinterfaceWelcomeMessage: Bonjour @usershort, votre compte utilisateur a bien été créé. Amusez-vous bien en éditant le site web.
WebinterfaceInformationSubject: Bienvenue à nouveau
WebinterfaceInformationMessage: Bonjour @usershort, votre compte utilisateur a bien été changé. Vous pouvez maintenant vous connecter.
-WebinterfaceUpdateTitle: Mises à jour
-WebinterfaceUpdateCheck: Vérifier les mises à jour
-WebinterfaceUpdateStatusNone: Vérification des mises à jour…
-WebinterfaceUpdateStatusEmpty: Aucune mise à jour disponible.
-WebinterfaceUpdateButton: Mettre à jour
+WebinterfaceVersionTitle: A propos de ce site
+WebinterfaceVersionStatusNone: Vérification des mises à jour…
+WebinterfaceVersionStatusLatest: Aucune mise à jour disponible.
+WebinterfaceVersionStatusUpdates: Mises à jour disponibles, s'il vous plaît contacter le webmestre.
+WebinterfaceVersionUpdate: Mettre à jour
WebinterfaceOkButton: Ok
WebinterfaceCancelButton: Annuler
WebinterfaceCreateButton: Créer
diff --git a/system/plugins/language.php b/system/plugins/language.php
@@ -5,7 +5,7 @@
// Language plugin
class YellowLanguage
{
- const VERSION = "0.6.7";
+ const VERSION = "0.6.8";
var $yellow; //access to API
// Handle initialisation
diff --git a/system/plugins/webinterface.css b/system/plugins/webinterface.css
@@ -1,4 +1,4 @@
-/* Yellow web interface 0.6.11 */
+/* Yellow web interface 0.6.12 */
.yellow-bar { position:relative; overflow:hidden; height:2em; margin-bottom:10px; }
.yellow-bar-left { display:block; float:left; }
@@ -109,6 +109,13 @@
#yellow-pane-settings-fields { width:15em; text-align:left; margin:0 auto; }
#yellow-pane-settings-buttons { margin-top:-0.5em; }
+#yellow-pane-version { text-align:center; white-space:nowrap; }
+#yellow-pane-version h1 { margin:0 1em; font-size:2em; }
+#yellow-pane-version .yellow-btn { width:15em; margin:1em 1em 0.5em 0; }
+#yellow-pane-version-status { margin:0.5em 0; display:inline-block; }
+#yellow-pane-version-fields { width:20em; text-align:left; margin:0 auto; }
+#yellow-pane-version-buttons { margin-top:-0.5em; }
+
#yellow-pane-edit { }
#yellow-pane-edit h1 { margin:0 0 10px 0; font-size:1.5em; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
#yellow-pane-edit-page { padding:5px; outline:none; resize:none; }
diff --git a/system/plugins/webinterface.js b/system/plugins/webinterface.js
@@ -4,7 +4,7 @@
// Yellow API
var yellow =
{
- version: "0.6.11",
+ version: "0.6.12",
action: function(action) { yellow.webinterface.action(action, "none"); },
onLoad: function() { yellow.webinterface.loadInterface(); },
onClick: function(e) { yellow.webinterface.hidePanesOnClick(yellow.toolbox.getEventElement(e)); },
@@ -36,6 +36,8 @@ yellow.webinterface =
case "settings": this.showPane("yellow-pane-settings", action, status); break;
case "reconfirm": this.showPane("yellow-pane-settings", action, status); break;
case "change": this.showPane("yellow-pane-settings", action, status); break;
+ case "version": this.showPane("yellow-pane-version", action, status); break;
+ case "update": this.sendPane("yellow-pane-version", action); break;
case "create": this.showPane("yellow-pane-edit", action, status, true); break;
case "edit": this.showPane("yellow-pane-edit", action, status, true); break;
case "delete": this.showPane("yellow-pane-edit", action, status, true); break;
@@ -134,7 +136,7 @@ yellow.webinterface =
"<form method=\"post\">"+
"<a href=\"#\" onclick=\"yellow.action('close'); return false;\" class=\"yellow-close\">x</a>"+
"<h1>"+this.getText("SignupTitle")+"</h1>"+
- "<div id=\"yellow-pane-signup-status\" class=\""+paneStatus+"\">"+this.getText(paneAction+"Status", "webinterface", paneStatus)+"</div>"+
+ "<div id=\"yellow-pane-signup-status\" class=\""+paneStatus+"\">"+this.getText(paneAction+"Status", "", paneStatus)+"</div>"+
"<div id=\"yellow-pane-signup-fields\">"+
"<input type=\"hidden\" name=\"action\" value=\"signup\" />"+
"<p><label for=\"yellow-pane-signup-name\">"+this.getText("SignupName")+"</label><br /><input class=\"yellow-form-control\" name=\"name\" id=\"yellow-pane-signup-name\" maxlength=\"64\" value=\""+yellow.toolbox.encodeHtml(this.getRequest("name"))+"\" /></p>"+
@@ -152,7 +154,7 @@ yellow.webinterface =
"<form method=\"post\">"+
"<a href=\"#\" onclick=\"yellow.action('close'); return false;\" class=\"yellow-close\">x</a>"+
"<h1>"+this.getText("RecoverTitle")+"</h1>"+
- "<div id=\"yellow-pane-recover-status\" class=\""+paneStatus+"\">"+this.getText("RecoverStatus", "", paneStatus)+"</div>"+
+ "<div id=\"yellow-pane-recover-status\" class=\""+paneStatus+"\">"+this.getText(paneAction+"Status", "", paneStatus)+"</div>"+
"<div id=\"yellow-pane-recover-fields-first\">"+
"<input type=\"hidden\" name=\"action\" value=\"recover\" />"+
"<p><label for=\"yellow-pane-recover-email\">"+this.getText("RecoverEmail")+"</label><br /><input class=\"yellow-form-control\" name=\"email\" id=\"yellow-pane-recover-email\" maxlength=\"64\" value=\""+yellow.toolbox.encodeHtml(this.getRequest("email"))+"\" /></p>"+
@@ -172,7 +174,7 @@ yellow.webinterface =
"<form method=\"post\">"+
"<a href=\"#\" onclick=\"yellow.action('close'); return false;\" class=\"yellow-close\">x</a>"+
"<h1 id=\"yellow-pane-settings-title\">"+this.getText("SettingsTitle")+"</h1>"+
- "<div id=\"yellow-pane-settings-status\" class=\""+paneStatus+"\">"+this.getText(paneAction+"Status", "webinterface", paneStatus)+"</div>"+
+ "<div id=\"yellow-pane-settings-status\" class=\""+paneStatus+"\">"+this.getText(paneAction+"Status", "", paneStatus)+"</div>"+
"<div id=\"yellow-pane-settings-fields\">"+
"<input type=\"hidden\" name=\"action\" value=\"settings\" />"+
"<p><label for=\"yellow-pane-settings-name\">"+this.getText("SignupName")+"</label><br /><input class=\"yellow-form-control\" name=\"name\" id=\"yellow-pane-settings-name\" maxlength=\"64\" value=\""+yellow.toolbox.encodeHtml(this.getRequest("name"))+"\" /></p>"+
@@ -185,6 +187,24 @@ yellow.webinterface =
"</div>"+
"</form>";
break;
+ case "yellow-pane-version":
+ elementDiv.innerHTML =
+ "<form method=\"post\">"+
+ "<a href=\"#\" onclick=\"yellow.action('close'); return false;\" class=\"yellow-close\">x</a>"+
+ "<h1 id=\"yellow-pane-version-title\">"+yellow.toolbox.encodeHtml(yellow.config.serverVersion)+"</h1>"+
+ "<div id=\"yellow-pane-version-status\" class=\""+paneStatus+"\">"+this.getText("VersionStatus", "", paneStatus)+"</div>"+
+ "<div id=\"yellow-pane-version-fields\">"+
+ "<p>"+yellow.page.rawDataOutput+"</p><hr />"+
+ "<p>ServerScheme: "+yellow.toolbox.encodeHtml(yellow.config.serverScheme)+"<br />"+
+ "ServerName: "+yellow.toolbox.encodeHtml(yellow.config.serverName)+"<br />"+
+ "ServerBase: "+yellow.toolbox.encodeHtml(yellow.config.serverBase)+"<br />"+
+ "ServerTime: "+yellow.toolbox.encodeHtml(yellow.config.serverTime)+"</p>"+
+ "</div>"+
+ "<div id=\"yellow-pane-version-buttons\">"+
+ "<p><input class=\"yellow-btn\" type=\"button\" onclick=\"yellow.action('close'); return false;\" value=\""+this.getText("OkButton")+"\" /></p>"+
+ "</div>"+
+ "</form>";
+ break;
case "yellow-pane-edit":
elementDiv.innerHTML =
"<form method=\"post\">"+
@@ -246,12 +266,24 @@ yellow.webinterface =
yellow.toolbox.setVisible(document.getElementById("yellow-pane-settings-buttons"), !showFields);
if(paneStatus=="none")
{
- document.getElementById("yellow-pane-settings-status").innerHTML = yellow.toolbox.encodeHtml(yellow.config.serverVersion);
+ document.getElementById("yellow-pane-settings-status").innerHTML = "<a href=\"#\" onclick=\"yellow.action('version'); return false;\">"+yellow.toolbox.encodeHtml(yellow.config.serverVersion)+"</a>";
document.getElementById("yellow-pane-settings-name").value = yellow.config.userName;
document.getElementById("yellow-pane-settings-email").value = yellow.config.userEmail;
document.getElementById("yellow-pane-settings-"+yellow.config.userLanguage).checked = true;
}
break;
+ case "yellow-pane-version":
+ if(paneStatus=="none")
+ {
+ document.getElementById("yellow-pane-version-status").innerHTML = this.getText("VersionStatus", "", paneStatus);
+ document.getElementById("yellow-pane-version-fields").innerHTML = "";
+ setTimeout("yellow.action('send');", 100);
+ }
+ if(paneStatus=="updates" && yellow.config.userWebmaster)
+ {
+ document.getElementById("yellow-pane-version-status").innerHTML = "<a href=\"#\" onclick=\"yellow.action('update'); return false;\">"+this.getText("VersionUpdate")+"</a>";
+ }
+ break;
case "yellow-pane-edit":
if(init)
{
@@ -295,6 +327,7 @@ yellow.webinterface =
case "yellow-pane-signup":
case "yellow-pane-recover":
case "yellow-pane-settings":
+ case "yellow-pane-version":
yellow.toolbox.setOuterTop(document.getElementById(paneId), paneTop);
yellow.toolbox.setOuterWidth(document.getElementById(paneId), paneWidth);
break;
diff --git a/system/plugins/webinterface.php b/system/plugins/webinterface.php
@@ -5,7 +5,7 @@
// Web interface plugin
class YellowWebinterface
{
- const VERSION = "0.6.11";
+ const VERSION = "0.6.12";
var $yellow; //access to API
var $response; //web interface response
var $users; //web interface users
@@ -188,6 +188,8 @@ class YellowWebinterface
case "settings": $statusCode = $this->processRequestSettings($serverScheme, $serverName, $base, $location, $fileName); break;
case "reconfirm": $statusCode = $this->processRequestReconfirm($serverScheme, $serverName, $base, $location, $fileName); break;
case "change": $statusCode = $this->processRequestChange($serverScheme, $serverName, $base, $location, $fileName); break;
+ case "version": $statusCode = $this->processRequestVersion($serverScheme, $serverName, $base, $location, $fileName); break;
+ case "update": $statusCode = $this->processRequestUpdate($serverScheme, $serverName, $base, $location, $fileName); break;
case "create": $statusCode = $this->processRequestCreate($serverScheme, $serverName, $base, $location, $fileName); break;
case "edit": $statusCode = $this->processRequestEdit($serverScheme, $serverName, $base, $location, $fileName); break;
case "delete": $statusCode = $this->processRequestDelete($serverScheme, $serverName, $base, $location, $fileName); break;
@@ -277,7 +279,7 @@ class YellowWebinterface
if(empty($name) || empty($email) || empty($password)) $this->response->status = "incomplete";
if($this->response->status=="ok") $this->response->status = $this->getUserAccount($email, $password, $this->response->action);
if($this->response->status=="ok" && $this->response->isLoginRestrictions()) $this->response->status = "next";
- if($this->response->status=="ok" && $this->users->isExisting($email)) $this->response->status = "next";
+ if($this->response->status=="ok" && $this->users->isTaken($email)) $this->response->status = "next";
if($this->response->status=="ok")
{
$fileNameUser = $this->yellow->config->get("configDir").$this->yellow->config->get("webinterfaceUserFile");
@@ -393,19 +395,19 @@ class YellowWebinterface
{
if(empty($email)) $this->response->status = "invalid";
if($this->response->status=="ok") $this->response->status = $this->getUserAccount($email, $password, $this->response->action);
- if($this->response->status=="ok" && $email!=$emailSource && $this->users->isExisting($email)) $this->response->status = "exists";
+ if($this->response->status=="ok" && $email!=$emailSource && $this->users->isTaken($email)) $this->response->status = "taken";
if($this->response->status=="ok" && $email!=$emailSource)
{
$pending = $emailSource;
$fileNameUser = $this->yellow->config->get("configDir").$this->yellow->config->get("webinterfaceUserFile");
- $this->response->status = $this->users->update($fileNameUser, $email, "no", $name, $language, "unconfirmed", $pending) ? "ok" : "error";
+ $this->response->status = $this->users->update($fileNameUser, $email, "no", $name, $language, "unconfirmed", "", $pending) ? "ok" : "error";
if($this->response->status=="error") $this->yellow->page->error(500, "Can't write file '$fileNameUser'!");
}
if($this->response->status=="ok")
{
$pending = $email.':'.(empty($password) ? $this->users->getHash($emailSource) : $this->users->createHash($password));
$fileNameUser = $this->yellow->config->get("configDir").$this->yellow->config->get("webinterfaceUserFile");
- $this->response->status = $this->users->update($fileNameUser, $emailSource, "", $name, $language, "", $pending) ? "ok" : "error";
+ $this->response->status = $this->users->update($fileNameUser, $emailSource, "", $name, $language, "", "", $pending) ? "ok" : "error";
if($this->response->status=="error") $this->yellow->page->error(500, "Can't write file '$fileNameUser'!");
}
if($this->response->status=="ok")
@@ -443,7 +445,7 @@ class YellowWebinterface
if($this->response->status=="ok")
{
$emailSource = $this->users->getPending($email);
- if(!$this->users->isExisting($emailSource) || $this->users->getStatus($emailSource)!="active") $this->response->status = "done";
+ if($this->users->getStatus($emailSource)!="active") $this->response->status = "done";
}
if($this->response->status=="ok")
{
@@ -498,6 +500,59 @@ class YellowWebinterface
return $statusCode;
}
+ // Process request to show version
+ function processRequestVersion($serverScheme, $serverName, $base, $location, $fileName)
+ {
+ $this->response->action = "version";
+ $this->response->status = "ok";
+ if($this->yellow->plugins->isExisting("update"))
+ {
+ list($statusCode, $dataCurrent) = $this->yellow->plugins->get("update")->getSoftwareVersion();
+ list($statusCode, $dataLatest) = $this->yellow->plugins->get("update")->getSoftwareVersion(true);
+ foreach($dataCurrent as $key=>$value)
+ {
+ if(strnatcasecmp($dataCurrent[$key], $dataLatest[$key])<0)
+ {
+ if(!empty($this->response->rawDataOutput)) $this->response->rawDataOutput .= "<br />\n";
+ $this->response->rawDataOutput .= "$key $dataLatest[$key]";
+ ++$updates;
+ ++$count; if($count>=4) { $this->response->rawDataOutput .= "…"; break; }
+ }
+ }
+ $this->response->status = $updates ? "updates" : "latest";
+ if($statusCode!=200)
+ {
+ $this->yellow->page->statusCode = 500;
+ $this->yellow->page->set("pageError", "Can't check for updates on this server!");
+ $this->response->status = "error";
+ }
+ }
+ $statusCode = $this->yellow->processRequest($serverScheme, $serverName, $base, $location, $fileName, false);
+ return $statusCode;
+ }
+
+ // Process request to update software
+ function processRequestUpdate($serverScheme, $serverName, $base, $location, $fileName)
+ {
+ $statusCode = 0;
+ if($this->response->isUserWebmaster())
+ {
+ $statusCode = $this->yellow->command("update");
+ if($statusCode==200)
+ {
+ $statusCode = 303;
+ $location = $this->yellow->lookup->normaliseUrl($serverScheme, $serverName, $base, $location);
+ $this->yellow->sendStatus($statusCode, $location);
+ } else {
+ $statusCode = 500;
+ $this->yellow->page->statusCode = 500;
+ $this->yellow->page->set("pageError", "Can't install updates on this server!");
+ $this->yellow->processRequest($serverScheme, $serverName, $base, $location, $fileName, false);
+ }
+ }
+ return $statusCode;
+ }
+
// Process request to create page
function processRequestCreate($serverScheme, $serverName, $base, $location, $fileName)
{
@@ -689,6 +744,7 @@ class YellowResponse
var $active; //web interface is active? (boolean)
var $rawDataSource; //raw data of page for comparison
var $rawDataEdit; //raw data of page for editing
+ var $rawDataOutput; //raw data of dynamic output
var $language; //response language
var $action; //response action
var $status; //response status
@@ -734,6 +790,7 @@ class YellowResponse
preg_match("/^([\d\-\_\.]*)(.*)$/", $page->get("title"), $matches);
if(preg_match("/\d$/", $matches[1])) $matches[1] .= '-';
$page->fileName = $this->yellow->lookup->findFilePageNew($fileName, $matches[1]);
+ $page->location = $this->yellow->lookup->findLocationFromFile($page->fileName);
}
if($this->webinterface->getUserRestrictions($this->userEmail, $page->location, $page->fileName))
{
@@ -789,6 +846,7 @@ class YellowResponse
$data["rawDataSource"] = $this->rawDataSource;
$data["rawDataEdit"] = $this->rawDataEdit;
$data["rawDataNew"] = $this->getRawDataNew();
+ $data["rawDataOutput"] = strval($this->rawDataOutput);
$data["pageFile"] = $this->yellow->page->get("pageFile");
$data["parserSafeMode"] = $this->yellow->page->parserSafeMode;
}
@@ -1009,9 +1067,10 @@ class YellowUsers
preg_match("/^\s*(.*?)\s*:\s*(.*?)\s*$/", $line, $matches);
if(!empty($matches[1]) && !empty($matches[2]))
{
- list($hash, $name, $language, $status, $pending, $home) = explode(',', $matches[2]);
+ list($hash, $name, $language, $status, $modified, $pending, $home) = explode(',', $matches[2]);
+ if(!is_numeric($modified)) { $home = $pending; $pending = $modified; $modified = 946684800; } //TODO: remove later, converts old file format
$home = empty($home) ? $pending : $home; //TODO: remove later, converts old file format
- $this->set($matches[1], $hash, $name, $language, $status, $pending, $home);
+ $this->set($matches[1], $hash, $name, $language, $status, $modified, $pending, $home);
if(defined("DEBUG") && DEBUG>=3) echo "YellowUsers::load email:$matches[1]<br/>\n";
}
}
@@ -1026,12 +1085,13 @@ class YellowUsers
preg_match("/^\s*(.*?)\s*:\s*(.*?)\s*$/", $line, $matches);
if(!empty($matches[1]) && !empty($matches[2]))
{
- list($hash, $name, $language, $status, $pending, $home) = explode(',', $matches[2]);
+ list($hash, $name, $language, $status, $modified, $pending, $home) = explode(',', $matches[2]);
if($status=="active" || $status=="inactive")
{
+ if(!is_numeric($modified)) { $home = $pending; $pending = $modified; $modified = 946684800; } //TODO: remove later, converts old file format
$home = empty($home) ? $pending : $home; //TODO: remove later, converts old file format
$pending = $this->yellow->config->get("webinterfaceUserPending");
- $fileDataNew .= "$matches[1]: $hash,$name,$language,$status,$pending,$home\n";
+ $fileDataNew .= "$matches[1]: $hash,$name,$language,$status,$modified,$pending,$home\n";
}
} else {
$fileDataNew .= $line;
@@ -1041,7 +1101,7 @@ class YellowUsers
}
// Update users in file
- function update($fileName, $email, $password = "", $name = "", $language = "", $status = "", $pending = "", $home = "")
+ function update($fileName, $email, $password = "", $name = "", $language = "", $status = "", $modified = "", $pending = "", $home = "")
{
if(!empty($password)) $hash = $this->createHash($password);
if($this->isExisting($email))
@@ -1051,6 +1111,7 @@ class YellowUsers
$name = strreplaceu(',', '-', empty($name) ? $this->users[$email]["name"] : $name);
$language = strreplaceu(',', '-', empty($language) ? $this->users[$email]["language"] : $language);
$status = strreplaceu(',', '-', empty($status) ? $this->users[$email]["status"] : $status);
+ $modified = strreplaceu(',', '-', empty($modified) ? time() : $modified);
$pending = strreplaceu(',', '-', empty($pending) ? $this->users[$email]["pending"] : $pending);
$home = strreplaceu(',', '-', empty($home) ? $this->users[$email]["home"] : $home);
} else {
@@ -1059,28 +1120,29 @@ class YellowUsers
$name = strreplaceu(',', '-', empty($name) ? $this->yellow->config->get("sitename") : $name);
$language = strreplaceu(',', '-', empty($language) ? $this->yellow->config->get("language") : $language);
$status = strreplaceu(',', '-', empty($status) ? $this->yellow->config->get("webinterfaceUserStatus") : $status);
+ $modified = strreplaceu(',', '-', empty($modified) ? time() : $modified);
$pending = strreplaceu(',', '-', empty($pending) ? $this->yellow->config->get("webinterfaceUserPending") : $pending);
$home = strreplaceu(',', '-', empty($home) ? $this->yellow->config->get("webinterfaceUserHome") : $home);
}
- $this->set($email, $hash, $name, $language, $status, $pending, $home);
+ $this->set($email, $hash, $name, $language, $status, $modified, $pending, $home);
$fileData = $this->yellow->toolbox->readFile($fileName);
foreach($this->yellow->toolbox->getTextLines($fileData) as $line)
{
preg_match("/^\s*(.*?)\s*:\s*(.*?)\s*$/", $line, $matches);
if(!empty($matches[1]) && $matches[1]==$email)
{
- $fileDataNew .= "$email: $hash,$name,$language,$status,$pending,$home\n";
+ $fileDataNew .= "$email: $hash,$name,$language,$status,$modified,$pending,$home\n";
$found = true;
} else {
$fileDataNew .= $line;
}
}
- if(!$found) $fileDataNew .= "$email: $hash,$name,$language,$status,$pending,$home\n";
+ if(!$found) $fileDataNew .= "$email: $hash,$name,$language,$status,$modified,$pending,$home\n";
return $this->yellow->toolbox->createFile($fileName, $fileDataNew);
}
// Set user data
- function set($email, $hash, $name, $language, $status, $pending, $home)
+ function set($email, $hash, $name, $language, $status, $modified, $pending, $home)
{
$this->users[$email] = array();
$this->users[$email]["email"] = $email;
@@ -1088,6 +1150,7 @@ class YellowUsers
$this->users[$email]["name"] = $name;
$this->users[$email]["language"] = $language;
$this->users[$email]["status"] = $status;
+ $this->users[$email]["modified"] = $modified;
$this->users[$email]["pending"] = $pending;
$this->users[$email]["home"] = $home;
}
@@ -1125,7 +1188,7 @@ class YellowUsers
{
$serverScheme = $this->yellow->config->get("webinterfaceServerScheme");
$location = $this->yellow->config->get("serverBase").$this->yellow->config->get("webinterfaceLocation");
- setcookie($cookieName, "", time()-3600, $location, "", $serverScheme=="https");
+ setcookie($cookieName, "", time()-60*60, $location, "", $serverScheme=="https");
}
// Create password hash
@@ -1188,6 +1251,12 @@ class YellowUsers
return $this->isExisting($email) ? $this->users[$email]["status"] : "";
}
+ // Return user modified
+ function getModified($email = "")
+ {
+ return $this->isExisting($email) ? $this->users[$email]["modified"] : "";
+ }
+
// Return user pending
function getPending($email = "")
{
@@ -1218,7 +1287,20 @@ class YellowUsers
usort($data, strnatcasecmp);
return $data;
}
-
+
+ // Check if user is taken
+ function isTaken($email)
+ {
+ $taken = false;
+ if($this->isExisting($email))
+ {
+ $status = $this->users[$email]["status"];
+ $reserved = $this->users[$email]["modified"] + 60*60*24;
+ if($status=="active" || $status=="inactive" || $reserved>time()) $taken = true;
+ }
+ return $taken;
+ }
+
// Check if user exists
function isExisting($email)
{