Core update (user restriction)

This commit is contained in:
markseu 2015-09-06 17:59:14 +02:00
parent 5de9c6df47
commit f5a6f712eb
5 changed files with 23 additions and 19 deletions

View file

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

View file

@ -23,6 +23,7 @@ templateDir = system/themes/templates/
mediaDir = media/
imageDir = media/images/
staticDir = cache/
staticAccessFile = .htaccess
staticDefaultFile = index.html
staticErrorFile = error.html
contentDir = content/
@ -42,12 +43,11 @@ sidebar = sidebar
parser = markdown
parserSafeMode = 0
multiLanguageMode = 0
commandlineIgnoreLocation =
commandlineSystemFile = .htaccess
webinterfaceLocation = /edit/
webinterfaceServerScheme = http
webinterfaceUserHashAlgorithm = bcrypt
webinterfaceUserHashCost = 10
webinterfaceUserHome = /
webinterfaceUserFile = user.ini
webinterfaceNewFile = page-new-(.*).txt
webinterfaceMetaFilePrefix = published

View file

@ -5,7 +5,7 @@
// Command line core plugin
class YellowCommandline
{
const Version = "0.5.4";
const Version = "0.5.5";
var $yellow; //access to API
var $content; //number of content pages
var $media; //number of media files
@ -18,8 +18,6 @@ class YellowCommandline
function onLoad($yellow)
{
$this->yellow = $yellow;
$this->yellow->config->setDefault("commandlineIgnoreLocation", "");
$this->yellow->config->setDefault("commandlineSystemFile", ".htaccess");
}
// Handle command
@ -332,7 +330,7 @@ class YellowCommandline
if(!empty($path))
{
if($path == rtrim($this->yellow->config->get("staticDir"), '/')) $ok = true;
if(is_file("$path/".$this->yellow->config->get("commandlineSystemFile"))) $ok = true;
if(is_file("$path/".$this->yellow->config->get("staticAccessFile"))) $ok = true;
if(is_file("$path/yellow.php")) $ok = false;
}
return $ok;
@ -346,14 +344,12 @@ class YellowCommandline
$serverName = $this->yellow->config->get("serverName");
$serverBase = $this->yellow->config->get("serverBase");
$this->yellow->page->setRequestInformation($serverScheme, $serverName, $serverBase, "", "");
if($this->yellow->config->isExisting("commandlineIgnoreLocation"))
{
$regex = "#^".$this->yellow->config->get("commandlineIgnoreLocation")."#";
}
foreach($this->yellow->pages->index(true, true) as $page)
{
if(!empty($regex) && preg_match($regex, $page->location)) continue;
array_push($locations, $page->location);
if($page->get("status")!="ignore" && $page->get("status")!="draft")
{
array_push($locations, $page->location);
}
}
if(!$this->yellow->pages->find("/") && $this->yellow->config->get("multiLanguageMode")) array_unshift($locations, "/");
return $locations;
@ -386,7 +382,7 @@ class YellowCommandline
$files[$fileName] = $path.$this->yellow->config->get("themeLocation").basename($fileName);
}
$fileNames = array();
array_push($fileNames, $this->yellow->config->get("commandlineSystemFile"));
array_push($fileNames, $this->yellow->config->get("staticAccessFile"));
array_push($fileNames, $this->yellow->config->get("configDir").$this->yellow->config->get("robotsFile"));
foreach($fileNames as $fileName) $files[$fileName] = "$path/".basename($fileName);
return $files;

View file

@ -5,7 +5,7 @@
// Web interface core plugin
class YellowWebinterface
{
const Version = "0.5.22";
const Version = "0.5.23";
var $yellow; //access to API
var $active; //web interface is active? (boolean)
var $userLoginFailed; //web interface login failed? (boolean)
@ -26,6 +26,7 @@ class YellowWebinterface
$this->yellow->config->setDefault("webinterfaceServerName", $this->yellow->config->get("serverName"));
$this->yellow->config->setDefault("webinterfaceUserHashAlgorithm", "bcrypt");
$this->yellow->config->setDefault("webinterfaceUserHashCost", "10");
$this->yellow->config->setDefault("webinterfaceUserHome", "/");
$this->yellow->config->setDefault("webinterfaceUserFile", "user.ini");
$this->yellow->config->setDefault("webinterfaceNewFile", "page-new-(.*).txt");
$this->yellow->config->setDefault("webinterfaceMetaFilePrefix", "published");
@ -397,14 +398,20 @@ class YellowWebinterface
// Return permission to change page
function getUserPermission($location, $fileName)
{
$userPermission = is_dir(dirname($fileName)) && strlenu(basename($fileName))<128;
$userPermission = NULL;
foreach($this->yellow->plugins->plugins as $key=>$value)
{
if(method_exists($value["obj"], "onUserPermission"))
{
$userPermission &= $value["obj"]->onUserPermission($location, $fileName, $this->users);
$userPermission = $value["obj"]->onUserPermission($location, $fileName, $this->users);
if(!is_null($userPermission)) break;
}
}
if(is_null($userPermission))
{
$userPermission = is_dir(dirname($fileName)) && strlenu(basename($fileName))<128;
$userPermission &= substru($location, 0, strlenu($this->users->getHome())) == $this->users->getHome();
}
return $userPermission;
}
@ -635,7 +642,7 @@ class YellowWebinterfaceUsers
{
$name = strreplaceu(',', '-', empty($name) ? $this->yellow->config->get("sitename") : $name);
$language = strreplaceu(',', '-', empty($language) ? $this->yellow->config->get("language") : $language);
$home = strreplaceu(',', '-', empty($home) ? "/" : $home);
$home = strreplaceu(',', '-', empty($home) ? $this->yellow->config->get("webinterfaceUserHome") : $home);
$fileDataNew .= "$email,$hash,$name,$language,$home\n";
}
return $this->yellow->toolbox->createFile($fileName, $fileDataNew);

View file

@ -5,7 +5,7 @@
// Yellow main class
class Yellow
{
const Version = "0.5.32";
const Version = "0.5.33";
var $page; //current page
var $pages; //pages from file system
var $files; //files from file system
@ -46,6 +46,7 @@ class Yellow
$this->config->setDefault("mediaDir", "media/");
$this->config->setDefault("imageDir", "media/images/");
$this->config->setDefault("staticDir", "cache/");
$this->config->setDefault("staticAccessFile", ".htaccess");
$this->config->setDefault("staticDefaultFile", "index.html");
$this->config->setDefault("staticErrorFile", "error.html");
$this->config->setDefault("contentDir", "content/");