Core update (kanelbulle remix)
This commit is contained in:
parent
0fb6ba1b16
commit
e15a8bfabe
3 changed files with 49 additions and 35 deletions
|
@ -1,4 +1,4 @@
|
|||
Yellow 0.5.29
|
||||
Yellow 0.5.30
|
||||
=============
|
||||
[](http://datenstrom.se/yellow)
|
||||
|
||||
|
@ -10,6 +10,4 @@ How do I install this?
|
|||
2. Copy all files to your web hosting.
|
||||
3. Open your website in a web browser. [Learn more](https://github.com/datenstrom/yellow/wiki).
|
||||
|
||||
License
|
||||
-------
|
||||
All files are licensed under [GPLv2](http://opensource.org/licenses/GPL-2.0) unless stated otherwise.
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
// Web interface core plugin
|
||||
class YellowWebinterface
|
||||
{
|
||||
const Version = "0.5.21";
|
||||
const Version = "0.5.22";
|
||||
var $yellow; //access to API
|
||||
var $active; //web interface is active? (boolean)
|
||||
var $userLoginFailed; //web interface login failed? (boolean)
|
||||
|
@ -149,30 +149,37 @@ class YellowWebinterface
|
|||
// Handle command help
|
||||
function onCommandHelp()
|
||||
{
|
||||
return "user EMAIL PASSWORD [NAME LANGUAGE HOME]\n";
|
||||
return "user [EMAIL PASSWORD NAME LANGUAGE HOME]\n";
|
||||
}
|
||||
|
||||
// Create or update user account
|
||||
// Update user account
|
||||
function userCommand($args)
|
||||
{
|
||||
$statusCode = 0;
|
||||
list($dummy, $command, $email, $password, $name, $language, $home) = $args;
|
||||
if(!empty($email) && !empty($password) && (empty($home) || $home[0]=='/'))
|
||||
if(empty($home) || $home[0]=='/')
|
||||
{
|
||||
$fileName = $this->yellow->config->get("configDir").$this->yellow->config->get("webinterfaceUserFile");
|
||||
$algorithm = $this->yellow->config->get("webinterfaceUserHashAlgorithm");
|
||||
$cost = $this->yellow->config->get("webinterfaceUserHashCost");
|
||||
$hash = $this->yellow->toolbox->createHash($password, $algorithm, $cost);
|
||||
if(empty($hash))
|
||||
if(!empty($email) && !empty($password))
|
||||
{
|
||||
$statusCode = 500;
|
||||
echo "ERROR creating hash: Algorithm '$algorithm' not supported!\n";
|
||||
$fileName = $this->yellow->config->get("configDir").$this->yellow->config->get("webinterfaceUserFile");
|
||||
$algorithm = $this->yellow->config->get("webinterfaceUserHashAlgorithm");
|
||||
$cost = $this->yellow->config->get("webinterfaceUserHashCost");
|
||||
$hash = $this->yellow->toolbox->createHash($password, $algorithm, $cost);
|
||||
if(empty($hash))
|
||||
{
|
||||
$statusCode = 500;
|
||||
echo "ERROR creating hash: Algorithm '$algorithm' not supported!\n";
|
||||
} else {
|
||||
$statusCode = $this->users->createUser($fileName, $email, $hash, $name, $language, $home) ? 200 : 500;
|
||||
if($statusCode != 200) echo "ERROR updating configuration: Can't write file '$fileName'!\n";
|
||||
}
|
||||
echo "Yellow $command: User account ".($statusCode!=200 ? "not " : "");
|
||||
echo ($this->users->isExisting($email) ? "updated" : "created")."\n";
|
||||
} else {
|
||||
$statusCode = $this->users->createUser($fileName, $email, $hash, $name, $language, $home) ? 200 : 500;
|
||||
if($statusCode != 200) echo "ERROR updating configuration: Can't write file '$fileName'!\n";
|
||||
$statusCode = 200;
|
||||
foreach($this->getUserData() as $line) echo "$line\n";
|
||||
if(!$this->users->getNumber()) echo "Yellow $command: No user accounts\n";
|
||||
}
|
||||
echo "Yellow $command: User account ".($statusCode!=200 ? "not " : "");
|
||||
echo ($this->users->isExisting($email) ? "updated" : "created")."\n";
|
||||
} else {
|
||||
echo "Yellow $command: Invalid arguments\n";
|
||||
$statusCode = 400;
|
||||
|
@ -401,6 +408,15 @@ class YellowWebinterface
|
|||
return $userPermission;
|
||||
}
|
||||
|
||||
// Return user data
|
||||
function getUserData()
|
||||
{
|
||||
$data = array();
|
||||
foreach($this->users->users as $key=>$value) $data[$key] = "$value[email] - $value[name] $value[language] $value[home]";
|
||||
usort($data, strnatcasecmp);
|
||||
return $data;
|
||||
}
|
||||
|
||||
// Update request information
|
||||
function updateRequestInformation()
|
||||
{
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
// Yellow main class
|
||||
class Yellow
|
||||
{
|
||||
const Version = "0.5.29";
|
||||
const Version = "0.5.30";
|
||||
var $page; //current page
|
||||
var $pages; //pages from file system
|
||||
var $files; //files from file system
|
||||
|
@ -68,6 +68,22 @@ class Yellow
|
|||
$this->load();
|
||||
}
|
||||
|
||||
// Initialise configuration
|
||||
function load()
|
||||
{
|
||||
if(defined("DEBUG") && DEBUG>=3)
|
||||
{
|
||||
$serverSoftware = $this->toolbox->getServerSoftware();
|
||||
echo "Yellow ".Yellow::Version.", PHP ".PHP_VERSION.", $serverSoftware<br>\n";
|
||||
}
|
||||
$this->config->load($this->config->get("configDir").$this->config->get("configFile"));
|
||||
$this->text->load($this->config->get("configDir").$this->config->get("textFile"));
|
||||
date_default_timezone_set($this->config->get("timeZone"));
|
||||
list($pathRoot, $pathHome) = $this->lookup->getContentInformation();
|
||||
$this->config->set("contentRootDir", $pathRoot);
|
||||
$this->config->set("contentHomeDir", $pathHome);
|
||||
}
|
||||
|
||||
// Handle request
|
||||
function request()
|
||||
{
|
||||
|
@ -315,22 +331,6 @@ class Yellow
|
|||
return $ok;
|
||||
}
|
||||
|
||||
// Load configuration and text strings
|
||||
function load()
|
||||
{
|
||||
if(defined("DEBUG") && DEBUG>=3)
|
||||
{
|
||||
$serverSoftware = $this->toolbox->getServerSoftware();
|
||||
echo "Yellow ".Yellow::Version.", PHP ".PHP_VERSION.", $serverSoftware<br>\n";
|
||||
}
|
||||
date_default_timezone_set($this->config->get("timeZone"));
|
||||
$this->config->load($this->config->get("configDir").$this->config->get("configFile"));
|
||||
$this->text->load($this->config->get("configDir").$this->config->get("textFile"));
|
||||
list($pathRoot, $pathHome) = $this->lookup->getContentInformation();
|
||||
$this->config->set("contentRootDir", $pathRoot);
|
||||
$this->config->set("contentHomeDir", $pathHome);
|
||||
}
|
||||
|
||||
// Execute command
|
||||
function command($name, $args = NULL)
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue