Core update (fika remix)
This commit is contained in:
parent
ee5b9ff185
commit
c6cf750609
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 2.4 KiB |
|
@ -1,53 +1,52 @@
|
|||
// Yellow site configuration
|
||||
# Yellow main configuration
|
||||
|
||||
sitename = Yellow
|
||||
author = Yellow
|
||||
language = en
|
||||
theme = flatsite
|
||||
Sitename: Yellow
|
||||
Author: Yellow
|
||||
Language: en
|
||||
Theme: flatsite
|
||||
|
||||
// timeZone = UTC
|
||||
// serverScheme = http
|
||||
// serverName = your.domain.name
|
||||
// serverBase =
|
||||
# ServerScheme: http
|
||||
# ServerName: your.domain.name
|
||||
# ServerBase:
|
||||
# ServerTime: UTC
|
||||
|
||||
imageLocation = /media/images/
|
||||
pluginLocation = /media/plugins/
|
||||
themeLocation = /media/themes/
|
||||
systemDir = system/
|
||||
configDir = system/config/
|
||||
coreDir = system/core/
|
||||
pluginDir = system/plugins/
|
||||
themeDir = system/themes/
|
||||
snippetDir = system/themes/snippets/
|
||||
templateDir = system/themes/templates/
|
||||
mediaDir = media/
|
||||
imageDir = media/images/
|
||||
staticDir = cache/
|
||||
staticAccessFile = .htaccess
|
||||
staticDefaultFile = index.html
|
||||
staticErrorFile = error.html
|
||||
contentDir = content/
|
||||
contentRootDir = default/
|
||||
contentHomeDir = home/
|
||||
contentDefaultFile = page.txt
|
||||
contentPagination = page
|
||||
contentExtension = .txt
|
||||
configExtension = .ini
|
||||
textFile = language-(.*).ini
|
||||
errorFile = page-error-(.*).txt
|
||||
robotsFile = robots.txt
|
||||
iconFile = icon.png
|
||||
template = default
|
||||
navigation = navigation
|
||||
sidebar = sidebar
|
||||
parser = markdown
|
||||
parserSafeMode = 0
|
||||
multiLanguageMode = 0
|
||||
webinterfaceLocation = /edit/
|
||||
webinterfaceServerScheme = http
|
||||
webinterfaceUserHashAlgorithm = bcrypt
|
||||
webinterfaceUserHashCost = 10
|
||||
webinterfaceUserHome = /
|
||||
webinterfaceUserFile = user.ini
|
||||
webinterfaceNewFile = page-new-(.*).txt
|
||||
webinterfaceMetaFilePrefix = published
|
||||
ImageLocation: /media/images/
|
||||
PluginLocation: /media/plugins/
|
||||
ThemeLocation: /media/themes/
|
||||
SystemDir: system/
|
||||
ConfigDir: system/config/
|
||||
PluginDir: system/plugins/
|
||||
ThemeDir: system/themes/
|
||||
SnippetDir: system/themes/snippets/
|
||||
TemplateDir: system/themes/templates/
|
||||
MediaDir: media/
|
||||
ImageDir: media/images/
|
||||
StaticDir: cache/
|
||||
StaticAccessFile: .htaccess
|
||||
StaticDefaultFile: index.html
|
||||
StaticErrorFile: error.html
|
||||
ContentDir: content/
|
||||
ContentRootDir: default/
|
||||
ContentHomeDir: home/
|
||||
ContentDefaultFile: page.txt
|
||||
ContentPagination: page
|
||||
ContentExtension: .txt
|
||||
ConfigExtension: .ini
|
||||
TextFile: language-(.*).ini
|
||||
ErrorFile: page-error-(.*).txt
|
||||
RobotsFile: robots.txt
|
||||
IconFile: icon.png
|
||||
Template: default
|
||||
Navigation: navigation
|
||||
Sidebar: sidebar
|
||||
Parser: markdown
|
||||
ParserSafeMode: 0
|
||||
MultiLanguageMode: 0
|
||||
WebinterfaceLocation: /edit/
|
||||
WebinterfaceServerScheme: http
|
||||
WebinterfaceUserHashAlgorithm: bcrypt
|
||||
WebinterfaceUserHashCost: 10
|
||||
WebinterfaceUserHome: /
|
||||
WebinterfaceUserFile: user.ini
|
||||
WebinterfaceNewFile: page-new-(.*).txt
|
||||
WebinterfaceMetaFilePrefix: published
|
||||
|
|
|
@ -1,31 +1,54 @@
|
|||
// Yellow text strings
|
||||
# Yellow text strings
|
||||
|
||||
language = en
|
||||
languageDescription = English
|
||||
languageAuthor = Mark Seuffert
|
||||
languageVersion = 0.5.0
|
||||
Language: en
|
||||
LanguageDescription: English
|
||||
LanguageAuthor: Mark Seuffert
|
||||
LanguageVersion: 0.6.1
|
||||
|
||||
dateMonths = January, February, March, April, May, June, July, August, September, October, November, December
|
||||
dateWeekdays = Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday
|
||||
dateFormatShort = F Y
|
||||
dateFormatMedium = Y-m-d
|
||||
dateFormatLong = Y-m-d H:i
|
||||
paginationPrevious = ← Previous
|
||||
paginationNext = Next →
|
||||
webinterfaceLoginText = Yellow login
|
||||
webinterfaceLoginEmail = Email:
|
||||
webinterfaceLoginPassword = Password:
|
||||
webinterfaceLoginButton = Login
|
||||
webinterfaceCreateButton = Create
|
||||
webinterfaceEditButton = Save
|
||||
webinterfaceDeleteButton = Delete
|
||||
webinterfaceCancelButton = Cancel
|
||||
webinterfaceEdit = Edit page
|
||||
webinterfaceCreate = +
|
||||
webinterfaceDelete = -
|
||||
webinterfaceCreateTitle = New page
|
||||
webinterfaceDeleteTitle = Delete page
|
||||
webinterfaceUserHelp = Help
|
||||
webinterfaceUserHelpUrl = https://github.com/datenstrom/yellow/wiki
|
||||
webinterfaceUserAccountUrl = https://github.com/datenstrom/yellow/wiki/How-to-add-a-user-account
|
||||
webinterfaceUserLogout = Logout
|
||||
DateMonths: January, February, March, April, May, June, July, August, September, October, November, December
|
||||
DateWeekdays: Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday
|
||||
DateFormatShort: F Y
|
||||
DateFormatMedium: Y-m-d
|
||||
DateFormatLong: Y-m-d H:i
|
||||
PaginationPrevious: ← Previous
|
||||
PaginationNext: Next →
|
||||
|
||||
WebinterfaceLoginText: Yellow login
|
||||
WebinterfaceLoginEmail: Email:
|
||||
WebinterfaceLoginPassword: Password:
|
||||
WebinterfaceLoginButton: Log in
|
||||
WebinterfaceSignupButton: Sign up
|
||||
WebinterfaceCreateButton: Create
|
||||
WebinterfaceEditButton: Save
|
||||
WebinterfaceDeleteButton: Delete
|
||||
WebinterfaceCancelButton: Cancel
|
||||
WebinterfaceEdit: Edit page
|
||||
WebinterfaceCreate: +
|
||||
WebinterfaceDelete: -
|
||||
WebinterfaceCreateTitle: New page
|
||||
WebinterfaceDeleteTitle: Delete page
|
||||
WebinterfaceUserHelp: Help
|
||||
WebinterfaceUserHelpUrl: https://github.com/datenstrom/yellow/wiki
|
||||
WebinterfaceUserAccountUrl: https://github.com/datenstrom/yellow/wiki/How-to-add-a-user-account
|
||||
WebinterfaceUserLogout: Logout
|
||||
|
||||
BlogBy: by
|
||||
BlogFilter: Blog:
|
||||
BlogTag: Tags:
|
||||
BlogMore: Read more…
|
||||
WikiFilter: Wiki:
|
||||
WikiTag: Tags:
|
||||
WikiSpecialChanges: Recent changes
|
||||
SearchQuery: Search:
|
||||
SearchResultsNone: Enter a search term.
|
||||
SearchResultsEmpty: No results found.
|
||||
SearchButton: Search
|
||||
ContactName: Name:
|
||||
ContactEmail: Email:
|
||||
ContactMessage: Message:
|
||||
ContactButton: Send message
|
||||
ContactStatusNone: Say hello. Your feedback is very welcome.
|
||||
ContactStatusIncomplete: Please fill out all fields.
|
||||
ContactStatusInvalid: Please enter a valid email.
|
||||
ContactStatusDone: You have sucessfully sent an email. Thank you!
|
||||
ContactStatusError: Email could not be sent, please try again later!
|
|
@ -1,4 +0,0 @@
|
|||
---
|
||||
Title: Unauthorised
|
||||
---
|
||||
You are not authorised on this server. [Please log in](javascript:yellow.action('login');).
|
|
@ -1,3 +1,2 @@
|
|||
// Yellow user accounts
|
||||
// Format: Email, password hash, name, language, home
|
||||
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
// Copyright (c) 2013-2015 Datenstrom, http://datenstrom.se
|
||||
// This file may be used and distributed under the terms of the public license.
|
||||
|
||||
// Command line core plugin
|
||||
// Command line plugin
|
||||
class YellowCommandline
|
||||
{
|
||||
const Version = "0.5.5";
|
||||
const Version = "0.6.1";
|
||||
var $yellow; //access to API
|
||||
var $content; //number of content pages
|
||||
var $media; //number of media files
|
||||
|
@ -18,6 +18,7 @@ class YellowCommandline
|
|||
function onLoad($yellow)
|
||||
{
|
||||
$this->yellow = $yellow;
|
||||
$this->yellow->config->setDefault("commandlineVersionUrl", "https://github.com/datenstrom/yellow-extensions");
|
||||
}
|
||||
|
||||
// Handle command
|
||||
|
@ -27,7 +28,7 @@ class YellowCommandline
|
|||
switch($command)
|
||||
{
|
||||
case "": $statusCode = $this->helpCommand(); break;
|
||||
case "version": $statusCode = $this->versionCommand(); break;
|
||||
case "version": $statusCode = $this->versionCommand($args); break;
|
||||
case "build": $statusCode = $this->buildCommand($args); break;
|
||||
case "clean": $statusCode = $this->cleanCommand($args); break;
|
||||
default: $statusCode = $this->pluginCommand($args);
|
||||
|
@ -52,19 +53,41 @@ class YellowCommandline
|
|||
// Show available commands
|
||||
function helpCommand()
|
||||
{
|
||||
echo "Yellow ".Yellow::Version."\n";
|
||||
echo "Yellow ".YellowCore::Version."\n";
|
||||
foreach($this->getCommandHelp() as $line) echo (++$lineCounter>1 ? " " : "Syntax: ")."yellow.php $line\n";
|
||||
return 200;
|
||||
}
|
||||
|
||||
// Show software version
|
||||
function versionCommand()
|
||||
function versionCommand($args)
|
||||
{
|
||||
echo "Yellow ".Yellow::Version."\n";
|
||||
foreach($this->getPluginVersion() as $line) echo "$line\n";
|
||||
return 200;
|
||||
$statusCode = 0;
|
||||
echo "Yellow ".YellowCore::Version."\n";
|
||||
$url = $this->yellow->config->get("commandlineVersionUrl");
|
||||
list($dummy, $command) = $args;
|
||||
list($statusCode, $versionCurrent) = $this->getPluginVersion();
|
||||
list($statusCode, $versionLatest) = $this->getPluginVersion($url);
|
||||
foreach($versionCurrent as $key=>$value)
|
||||
{
|
||||
if($versionCurrent[$key] >= $versionLatest[$key])
|
||||
{
|
||||
echo "$key $value\n";
|
||||
} else {
|
||||
echo "$key $value - Update available\n";
|
||||
++$updates;
|
||||
}
|
||||
}
|
||||
if($statusCode != 200) echo "ERROR checking updates at $url, $versionLatest[error]\n";
|
||||
if(!$this->yellow->config->isExisting("sitename"))
|
||||
{
|
||||
$fileNames = $this->yellow->toolbox->getDirectoryEntries(
|
||||
$this->yellow->config->get("configDir"), "/^.*\.ini$/", true, false);
|
||||
foreach($fileNames as $fileName) $statusCode = max($statusCode, $this->updateConfigFile($fileName));
|
||||
}
|
||||
if($updates) echo "Yellow $command: $updates update".($updates==1 ? "":"s")." available at $url\n";
|
||||
return $statusCode;
|
||||
}
|
||||
|
||||
|
||||
// Build static pages
|
||||
function buildCommand($args)
|
||||
{
|
||||
|
@ -79,7 +102,7 @@ class YellowCommandline
|
|||
$statusCode = 500;
|
||||
list($this->content, $this->media, $this->system, $this->error) = array(0, 0, 0, 1);
|
||||
$fileName = $this->yellow->config->get("configDir").$this->yellow->config->get("configFile");
|
||||
echo "ERROR bulding pages: Please configure serverScheme, serverName and serverBase in file '$fileName'!\n";
|
||||
echo "ERROR bulding pages: Please configure ServerScheme, ServerName, ServerBase, ServerTime in file '$fileName'!\n";
|
||||
}
|
||||
echo "Yellow $command: $this->content content, $this->media media, $this->system system";
|
||||
echo ", $this->error error".($this->error!=1 ? 's' : '');
|
||||
|
@ -297,6 +320,43 @@ class YellowCommandline
|
|||
return $statusCode;
|
||||
}
|
||||
|
||||
// Update configuration file if necessary
|
||||
function updateConfigFile($fileName)
|
||||
{
|
||||
$statusCode = 200;
|
||||
$fileData = @file($fileName);
|
||||
if($fileData)
|
||||
{
|
||||
foreach($fileData as $line)
|
||||
{
|
||||
if(preg_match("/^\/\/(.*)$/", $line, $matches))
|
||||
{
|
||||
if(!$found) $matches[1] .= " (updated)";
|
||||
$line = "#$matches[1]\n";
|
||||
$found = true;
|
||||
}
|
||||
if(preg_match("/^\s*(.*?)\s*=\s*(.*?)\s*$/", $line, $matches))
|
||||
{
|
||||
$line = ucfirst($matches[1]).": $matches[2]\n";
|
||||
}
|
||||
if(preg_match("/^([^,:]+),([^,]+),([^,]+),([^,]+),([^,\n]+)$/", $line, $matches))
|
||||
{
|
||||
$line = "$matches[1]: $matches[2],$matches[3],$matches[4],active,$matches[5]\n";
|
||||
}
|
||||
$fileDataNew .= $line;
|
||||
}
|
||||
}
|
||||
if($found)
|
||||
{
|
||||
if(!$this->yellow->toolbox->createFile($fileName, $fileDataNew))
|
||||
{
|
||||
$statusCode = 500;
|
||||
echo "ERROR updating configuration: Can't write file '$fileName'!\n";
|
||||
}
|
||||
}
|
||||
return $statusCode;
|
||||
}
|
||||
|
||||
// Forward plugin command
|
||||
function pluginCommand($args)
|
||||
{
|
||||
|
@ -411,6 +471,63 @@ class YellowCommandline
|
|||
return $output;
|
||||
}
|
||||
|
||||
// Return plugin version
|
||||
function getPluginVersion($url = "")
|
||||
{
|
||||
$version = array();
|
||||
if(empty($url))
|
||||
{
|
||||
$statusCode = 200;
|
||||
$version["YellowCore"] = YellowCore::Version;
|
||||
foreach($this->yellow->plugins->plugins as $key=>$value) $version[$value["class"]] = $value[version];
|
||||
} else {
|
||||
if(extension_loaded("curl"))
|
||||
{
|
||||
$pluginVersionUrl = $this->getPluginVersionUrl($url);
|
||||
$curlHandle = curl_init();
|
||||
curl_setopt($curlHandle, CURLOPT_URL, $pluginVersionUrl);
|
||||
curl_setopt($curlHandle, CURLOPT_USERAGENT, "Mozilla/5.0 (compatible; YellowCore/".YellowCore::Version).")";
|
||||
curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($curlHandle, CURLOPT_CONNECTTIMEOUT, 30);
|
||||
$rawData = curl_exec($curlHandle);
|
||||
$statusCode = curl_getinfo($curlHandle, CURLINFO_HTTP_CODE);
|
||||
curl_close($curlHandle);
|
||||
if($statusCode == 200)
|
||||
{
|
||||
if(defined("DEBUG") && DEBUG>=2) echo "YellowCommandline::getPluginVersion file:$pluginVersionUrl\n";
|
||||
foreach($this->yellow->toolbox->getTextLines($rawData) as $line)
|
||||
{
|
||||
if(preg_match("/^(\w+)\s*:\s*([0-9\.]+)/", $line, $matches))
|
||||
{
|
||||
$version[$matches[1]] = $matches[2];
|
||||
if(defined("DEBUG") && DEBUG>=3) echo "YellowCommandline::getPluginVersion $matches[1]:$matches[2]\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
if($statusCode == 0) $statusCode = 444;
|
||||
$version["error"] = $this->yellow->toolbox->getHttpStatusFormatted($statusCode);
|
||||
} else {
|
||||
$statusCode = 500;
|
||||
$version["error"] = "Plugin 'commandline' requires cURL library!";
|
||||
}
|
||||
}
|
||||
uksort($version, strnatcasecmp);
|
||||
return array($statusCode, $version);
|
||||
}
|
||||
|
||||
// Return plugin version URL from repository
|
||||
function getPluginVersionUrl($url)
|
||||
{
|
||||
if(!$this->yellow->lookup->isFileLocation($url))
|
||||
{
|
||||
if(preg_match("#^https://github.com/(.+)$#", $url, $matches))
|
||||
{
|
||||
$url = "https://raw.githubusercontent.com/".$matches[1]."/master/version.ini";
|
||||
}
|
||||
}
|
||||
return $url;
|
||||
}
|
||||
|
||||
// Return command help
|
||||
function getCommandHelp()
|
||||
{
|
||||
|
@ -429,15 +546,6 @@ class YellowCommandline
|
|||
uksort($data, strnatcasecmp);
|
||||
return $data;
|
||||
}
|
||||
|
||||
// Return plugin version
|
||||
function getPluginVersion()
|
||||
{
|
||||
$data = array();
|
||||
foreach($this->yellow->plugins->plugins as $key=>$value) $data[$key] = "$value[class] $value[version]";
|
||||
usort($data, strnatcasecmp);
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
$yellow->plugins->register("commandline", "YellowCommandline", YellowCommandline::Version);
|
|
@ -2,10 +2,10 @@
|
|||
// Copyright (c) 2013-2015 Datenstrom, http://datenstrom.se
|
||||
// This file may be used and distributed under the terms of the public license.
|
||||
|
||||
// Yellow main class
|
||||
class Yellow
|
||||
// Yellow core
|
||||
class YellowCore
|
||||
{
|
||||
const Version = "0.5.33";
|
||||
const Version = "0.6.1";
|
||||
var $page; //current page
|
||||
var $pages; //pages from file system
|
||||
var $files; //files from file system
|
||||
|
@ -29,16 +29,15 @@ class Yellow
|
|||
$this->config->setDefault("author", "Yellow");
|
||||
$this->config->setDefault("language", "en");
|
||||
$this->config->setDefault("theme", "default");
|
||||
$this->config->setDefault("timeZone", $this->toolbox->getTimeZone());
|
||||
$this->config->setDefault("serverScheme", $this->toolbox->getServerScheme());
|
||||
$this->config->setDefault("serverName", $this->toolbox->getServerName());
|
||||
$this->config->setDefault("serverBase", $this->toolbox->getServerBase());
|
||||
$this->config->setDefault("serverTime", $this->toolbox->getServerTime());
|
||||
$this->config->setDefault("imageLocation", "/media/images/");
|
||||
$this->config->setDefault("pluginLocation", "/media/plugins/");
|
||||
$this->config->setDefault("themeLocation", "/media/themes/");
|
||||
$this->config->setDefault("systemDir", "system/");
|
||||
$this->config->setDefault("configDir", "system/config/");
|
||||
$this->config->setDefault("coreDir", "system/core/");
|
||||
$this->config->setDefault("pluginDir", "system/plugins/");
|
||||
$this->config->setDefault("themeDir", "system/themes/");
|
||||
$this->config->setDefault("snippetDir", "system/themes/snippets/");
|
||||
|
@ -46,7 +45,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("staticAccessFile", ".htaccess");
|
||||
$this->config->setDefault("staticDefaultFile", "index.html");
|
||||
$this->config->setDefault("staticErrorFile", "error.html");
|
||||
$this->config->setDefault("contentDir", "content/");
|
||||
|
@ -76,11 +75,11 @@ class Yellow
|
|||
if(defined("DEBUG") && DEBUG>=3)
|
||||
{
|
||||
$serverSoftware = $this->toolbox->getServerSoftware();
|
||||
echo "Yellow ".Yellow::Version.", PHP ".PHP_VERSION.", $serverSoftware<br>\n";
|
||||
echo "Yellow ".YellowCore::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"));
|
||||
date_default_timezone_set($this->config->get("serverTime"));
|
||||
list($pathRoot, $pathHome) = $this->lookup->getContentInformation();
|
||||
$this->config->set("contentRootDir", $pathRoot);
|
||||
$this->config->set("contentHomeDir", $pathHome);
|
||||
|
@ -111,8 +110,8 @@ class Yellow
|
|||
if($this->page->isError()) $statusCode = $this->processRequestError();
|
||||
$this->toolbox->timerStop($time);
|
||||
ob_end_flush();
|
||||
if(defined("DEBUG") && DEBUG>=1) echo "Yellow::request status:$statusCode location:$location<br/>\n";
|
||||
if(defined("DEBUG") && DEBUG>=1) echo "Yellow::request time:$time ms<br/>\n";
|
||||
if(defined("DEBUG") && DEBUG>=1) echo "YellowCore::request status:$statusCode location:$location<br/>\n";
|
||||
if(defined("DEBUG") && DEBUG>=1) echo "YellowCore::request time:$time ms<br/>\n";
|
||||
return $statusCode;
|
||||
}
|
||||
|
||||
|
@ -153,7 +152,7 @@ class Yellow
|
|||
if(defined("DEBUG") && DEBUG>=1)
|
||||
{
|
||||
$handler = $this->getRequestHandler();
|
||||
echo "Yellow::processRequest file:$fileName handler:$handler<br/>\n";
|
||||
echo "YellowCore::processRequest file:$fileName handler:$handler<br/>\n";
|
||||
}
|
||||
return $statusCode;
|
||||
}
|
||||
|
@ -169,7 +168,7 @@ class Yellow
|
|||
if(defined("DEBUG") && DEBUG>=1)
|
||||
{
|
||||
$handler = $this->getRequestHandler();
|
||||
echo "Yellow::processRequestError file:$fileName handler:$handler<br/>\n";
|
||||
echo "YellowCore::processRequestError file:$fileName handler:$handler<br/>\n";
|
||||
}
|
||||
return $statusCode;
|
||||
}
|
||||
|
@ -208,11 +207,11 @@ class Yellow
|
|||
}
|
||||
if(defined("DEBUG") && DEBUG>=1)
|
||||
{
|
||||
foreach($this->page->headerData as $key=>$value) echo "Yellow::sendPage $key: $value<br/>\n";
|
||||
foreach($this->page->headerData as $key=>$value) echo "YellowCore::sendPage $key: $value<br/>\n";
|
||||
$fileNameTheme = $this->config->get("themeDir").$this->page->get("theme").".css";
|
||||
$templateName = $this->page->get("template");
|
||||
$parserName = $this->page->get("parser");
|
||||
echo "Yellow::sendPage theme:$fileNameTheme template:$templateName parser:$parserName<br/>\n";
|
||||
echo "YellowCore::sendPage theme:$fileNameTheme template:$templateName parser:$parserName<br/>\n";
|
||||
}
|
||||
return $statusCode;
|
||||
}
|
||||
|
@ -243,7 +242,7 @@ class Yellow
|
|||
foreach($this->page->headerData as $key=>$value) @header("$key: $value");
|
||||
if(defined("DEBUG") && DEBUG>=1)
|
||||
{
|
||||
foreach($this->page->headerData as $key=>$value) echo "Yellow::sendStatus $key: $value<br/>\n";
|
||||
foreach($this->page->headerData as $key=>$value) echo "YellowCore::sendStatus $key: $value<br/>\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -259,10 +258,7 @@ class Yellow
|
|||
{
|
||||
$pluginLocationLength = strlenu($this->config->get("pluginLocation"));
|
||||
$themeLocationLength = strlenu($this->config->get("themeLocation"));
|
||||
if(substru($location, 0, $pluginLocationLength+5) == $this->config->get("pluginLocation")."core-")
|
||||
{
|
||||
$fileName = $this->config->get("coreDir").substru($location, $pluginLocationLength);
|
||||
} else if(substru($location, 0, $pluginLocationLength) == $this->config->get("pluginLocation")) {
|
||||
if(substru($location, 0, $pluginLocationLength) == $this->config->get("pluginLocation")) {
|
||||
$fileName = $this->config->get("pluginDir").substru($location, $pluginLocationLength);
|
||||
} else if(substru($location, 0, $themeLocationLength) == $this->config->get("themeLocation")) {
|
||||
$fileName = $this->config->get("themeDir").substru($location, $themeLocationLength);
|
||||
|
@ -1518,13 +1514,6 @@ class YellowPlugins
|
|||
// Load plugins
|
||||
function load()
|
||||
{
|
||||
$path = $this->yellow->config->get("coreDir");
|
||||
foreach($this->yellow->toolbox->getDirectoryEntries($path, "/^core-.*\.php$/", true, false) as $entry)
|
||||
{
|
||||
$this->modified = max($this->modified, filemtime($entry));
|
||||
global $yellow;
|
||||
require_once($entry);
|
||||
}
|
||||
$path = $this->yellow->config->get("pluginDir");
|
||||
foreach($this->yellow->toolbox->getDirectoryEntries($path, "/^.*\.php$/", true, false) as $entry)
|
||||
{
|
||||
|
@ -1596,12 +1585,12 @@ class YellowConfig
|
|||
$this->modified = filemtime($fileName);
|
||||
foreach($fileData as $line)
|
||||
{
|
||||
if(preg_match("/^\//", $line)) continue;
|
||||
preg_match("/^\s*(.*?)\s*=\s*(.*?)\s*$/", $line, $matches);
|
||||
if(preg_match("/^\#/", $line)) continue;
|
||||
preg_match("/^\s*(.*?)\s*:\s*(.*?)\s*$/", $line, $matches);
|
||||
if(!empty($matches[1]) && !strempty($matches[2]))
|
||||
{
|
||||
$this->set($matches[1], $matches[2]);
|
||||
if(defined("DEBUG") && DEBUG>=3) echo "YellowConfig::load key:$matches[1] $matches[2]<br/>\n";
|
||||
$this->set(lcfirst($matches[1]), $matches[2]);
|
||||
if(defined("DEBUG") && DEBUG>=3) echo "YellowConfig::load ".lcfirst($matches[1]).":$matches[2]<br/>\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1697,17 +1686,17 @@ class YellowText
|
|||
$language = "";
|
||||
foreach($fileData as $line)
|
||||
{
|
||||
preg_match("/^\s*(.*?)\s*=\s*(.*?)\s*$/", $line, $matches);
|
||||
if($matches[1]=="language" && !strempty($matches[2])) { $language = $matches[2]; break; }
|
||||
preg_match("/^\s*(.*?)\s*:\s*(.*?)\s*$/", $line, $matches);
|
||||
if(lcfirst($matches[1])=="language" && !strempty($matches[2])) { $language = $matches[2]; break; }
|
||||
}
|
||||
foreach($fileData as $line)
|
||||
{
|
||||
if(preg_match("/^\//", $line)) continue;
|
||||
preg_match("/^\s*(.*?)\s*=\s*(.*?)\s*$/", $line, $matches);
|
||||
if(preg_match("/^\#/", $line)) continue;
|
||||
preg_match("/^\s*(.*?)\s*:\s*(.*?)\s*$/", $line, $matches);
|
||||
if(!empty($language) && !empty($matches[1]) && !strempty($matches[2]))
|
||||
{
|
||||
$this->setText($matches[1], $matches[2], $language);
|
||||
if(defined("DEBUG") && DEBUG>=3) echo "YellowText::load key:$matches[1] $matches[2]<br/>\n";
|
||||
$this->setText(lcfirst($matches[1]), $matches[2], $language);
|
||||
if(defined("DEBUG") && DEBUG>=3) echo "YellowText::load ".lcfirst($matches[1]).":$matches[2]<br/>\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2397,15 +2386,15 @@ class YellowToolbox
|
|||
return $text;
|
||||
}
|
||||
|
||||
// Return time zone
|
||||
function getTimeZone()
|
||||
// Return server time zone
|
||||
function getServerTime()
|
||||
{
|
||||
$timeZone = @date_default_timezone_get();
|
||||
if(PHP_OS=="Darwin" && $timeZone=="UTC")
|
||||
$serverTime = @date_default_timezone_get();
|
||||
if(PHP_OS=="Darwin" && $serverTime=="UTC")
|
||||
{
|
||||
if(preg_match("#zoneinfo/(.*)#", @readlink("/etc/localtime"), $matches)) $timeZone = $matches[1];
|
||||
if(preg_match("#zoneinfo/(.*)#", @readlink("/etc/localtime"), $matches)) $serverTime = $matches[1];
|
||||
}
|
||||
return $timeZone;
|
||||
return $serverTime;
|
||||
}
|
||||
|
||||
// Return human readable HTTP server status
|
||||
|
@ -2422,9 +2411,9 @@ class YellowToolbox
|
|||
case 303: $text = "$serverProtocol $statusCode Reload please"; break;
|
||||
case 304: $text = "$serverProtocol $statusCode Not modified"; break;
|
||||
case 400: $text = "$serverProtocol $statusCode Bad request"; break;
|
||||
case 401: $text = "$serverProtocol $statusCode Unauthorised"; break;
|
||||
case 404: $text = "$serverProtocol $statusCode Not found"; break;
|
||||
case 424: $text = "$serverProtocol $statusCode Not existing"; break;
|
||||
case 444: $text = "$serverProtocol $statusCode No response"; break;
|
||||
case 500: $text = "$serverProtocol $statusCode Server error"; break;
|
||||
default: $text = "$serverProtocol $statusCode Unknown status";
|
||||
}
|
|
@ -5,7 +5,7 @@
|
|||
// Markdown plugin
|
||||
class YellowMarkdown
|
||||
{
|
||||
const Version = "0.5.8";
|
||||
const Version = "0.6.1";
|
||||
var $yellow; //access to API
|
||||
|
||||
// Handle initialisation
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* Yellow web interface 0.5.20 */
|
||||
/* Yellow web interface 0.6.1 */
|
||||
|
||||
.yellow-bar { position:relative; overflow:hidden; height:2em; margin-bottom:10px; }
|
||||
.yellow-bar-left { display:block; float:left; }
|
||||
|
@ -89,11 +89,12 @@
|
|||
}
|
||||
.yellow-btn-delete:hover, .yellow-btn-delete:focus, .yellow-btn-delete:active { color:#ffffff; }
|
||||
|
||||
#yellow-pane-login { text-align:center; }
|
||||
#yellow-pane-login { text-align:center; white-space:nowrap; }
|
||||
#yellow-pane-login h1 { margin:0 1em; font-size:2em; }
|
||||
#yellow-pane-login-fields { width:12em; text-align:left; margin:0 auto; }
|
||||
#yellow-pane-login input { width:12em; box-sizing:border-box; }
|
||||
#yellow-pane-login .yellow-btn { margin:0.5em 0; }
|
||||
#yellow-pane-login-status { display:inline-block; }
|
||||
#yellow-pane-login-fields { width:15em; text-align:left; margin:0 auto; }
|
||||
#yellow-pane-login input { width:15em; box-sizing:border-box; }
|
||||
#yellow-pane-login .yellow-btn { width:15em; margin:1em 1em 0.5em 0; }
|
||||
#yellow-pane-edit { }
|
||||
#yellow-pane-edit h1 { margin:0 0 10px 0; font-size:1.5em; }
|
||||
#yellow-pane-edit-page { padding:5px; outline:none; resize:none; }
|
|
@ -1,10 +1,10 @@
|
|||
// Copyright (c) 2013-2015 Datenstrom, http://datenstrom.se
|
||||
// This file may be used and distributed under the terms of the public license.
|
||||
|
||||
// Yellow main API
|
||||
// Yellow API
|
||||
var yellow =
|
||||
{
|
||||
version: "0.5.20",
|
||||
version: "0.6.1",
|
||||
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)); },
|
||||
|
@ -138,7 +138,7 @@ yellow.webinterface =
|
|||
} else if(paneId == "yellow-pane-user") {
|
||||
elementDiv.innerHTML =
|
||||
"<p>"+yellow.config.userEmail+"</p>"+
|
||||
"<p><a href=\""+this.getText("UserHelpUrl")+"\" target=\"_blank\" onclick=\"yellow.action('user'); return true;\">"+this.getText("UserHelp")+"</a></p>" +
|
||||
"<p><a href=\""+this.getText("UserHelpUrl")+"\" onclick=\"yellow.action('user'); return true;\">"+this.getText("UserHelp")+"</a></p>" +
|
||||
"<p><a href=\"#\" onclick=\"yellow.action('logout'); return false;\">"+this.getText("UserLogout")+"</a></p>";
|
||||
}
|
||||
elementPane.appendChild(elementDiv);
|
||||
|
@ -162,6 +162,7 @@ yellow.webinterface =
|
|||
}
|
||||
document.getElementById("yellow-pane-edit-title").innerHTML = yellow.toolbox.encodeHtml(title);
|
||||
document.getElementById("yellow-pane-edit-page").value = string;
|
||||
yellow.toolbox.setCursorPosition(document.getElementById("yellow-pane-edit-page"), 0);
|
||||
}
|
||||
var action = this.getPaneAction(paneId, paneType)
|
||||
if(action)
|
||||
|
@ -258,11 +259,11 @@ yellow.webinterface =
|
|||
// Hide all panes on mouse click outside
|
||||
hidePanesOnClick: function(element)
|
||||
{
|
||||
while(element = element.parentNode)
|
||||
for(;element; element=element.parentNode)
|
||||
{
|
||||
if(element.className)
|
||||
{
|
||||
if(element.className.indexOf("yellow-pane")>=0 || element.className.indexOf("yellow-bar")>=0) return;
|
||||
if(element.className.indexOf("yellow-pane")>=0 || element.className.indexOf("yellow-bar-")>=0) return;
|
||||
}
|
||||
}
|
||||
this.hidePanes();
|
||||
|
@ -381,6 +382,13 @@ yellow.toolbox =
|
|||
else element.attachEvent('on'+type, handler);
|
||||
},
|
||||
|
||||
// Remove event handler
|
||||
removeEvent: function(element, type, handler)
|
||||
{
|
||||
if(element.removeEventListener) element.removeEventListener(type, handler, false);
|
||||
else element.detachEvent('on'+type, handler);
|
||||
},
|
||||
|
||||
// Return element of event
|
||||
getEventElement: function(e)
|
||||
{
|
||||
|
@ -531,6 +539,37 @@ yellow.toolbox =
|
|||
return { "width":width, "height":height };
|
||||
},
|
||||
|
||||
// Set input cursor position
|
||||
setCursorPosition: function(element, pos)
|
||||
{
|
||||
if(element.setSelectionRange)
|
||||
{
|
||||
element.focus();
|
||||
element.setSelectionRange(pos, pos);
|
||||
} else if(element.createTextRange) {
|
||||
var range = element.createTextRange();
|
||||
range.move('character', pos);
|
||||
range.select();
|
||||
}
|
||||
},
|
||||
|
||||
// Get input cursor position
|
||||
getCursorPosition: function(element)
|
||||
{
|
||||
var pos = 0;
|
||||
if(element.setSelectionRange)
|
||||
{
|
||||
pos = element.selectionStart;
|
||||
} else if(document.selection) {
|
||||
var range = document.selection.createRange();
|
||||
var rangeDuplicate = range.duplicate();
|
||||
rangeDuplicate.moveToElementText(element);
|
||||
rangeDuplicate.setEndPoint('EndToEnd', range);
|
||||
pos = rangeDuplicate.text.length - range.text.length;
|
||||
}
|
||||
return pos;
|
||||
},
|
||||
|
||||
// Check if element exists and is visible
|
||||
isVisible: function(element)
|
||||
{
|
|
@ -2,10 +2,10 @@
|
|||
// Copyright (c) 2013-2015 Datenstrom, http://datenstrom.se
|
||||
// This file may be used and distributed under the terms of the public license.
|
||||
|
||||
// Web interface core plugin
|
||||
// Web interface plugin
|
||||
class YellowWebinterface
|
||||
{
|
||||
const Version = "0.5.23";
|
||||
const Version = "0.6.1";
|
||||
var $yellow; //access to API
|
||||
var $active; //web interface is active? (boolean)
|
||||
var $userLoginFailed; //web interface login failed? (boolean)
|
||||
|
@ -19,8 +19,8 @@ class YellowWebinterface
|
|||
function onLoad($yellow)
|
||||
{
|
||||
$this->yellow = $yellow;
|
||||
$this->users = new YellowWebinterfaceUsers($yellow);
|
||||
$this->merge = new YellowWebinterfaceMerge($yellow);
|
||||
$this->users = new YellowUsers($yellow);
|
||||
$this->merge = new YellowMerge($yellow);
|
||||
$this->yellow->config->setDefault("webinterfaceLocation", "/edit/");
|
||||
$this->yellow->config->setDefault("webinterfaceServerScheme", "http");
|
||||
$this->yellow->config->setDefault("webinterfaceServerName", $this->yellow->config->get("serverName"));
|
||||
|
@ -89,9 +89,12 @@ class YellowWebinterface
|
|||
if(empty($text))
|
||||
{
|
||||
$serverSoftware = $this->yellow->toolbox->getServerSoftware();
|
||||
$output .= "Yellow ".Yellow::Version.", PHP ".PHP_VERSION.", $serverSoftware\n";
|
||||
$output .= "Yellow ".YellowCore::Version.", PHP ".PHP_VERSION.", $serverSoftware\n";
|
||||
} else {
|
||||
foreach($this->yellow->config->getData($text) as $key=>$value) $output .= htmlspecialchars("$key = $value")."<br />\n";
|
||||
foreach($this->yellow->config->getData($text) as $key=>$value)
|
||||
{
|
||||
$output .= htmlspecialchars(ucfirst($key).": ".$value)."<br />\n";
|
||||
}
|
||||
if($page->parserSafeMode) $page->error(500, "Debug '$text' is not allowed!");
|
||||
}
|
||||
$output .= "</div>\n";
|
||||
|
@ -107,7 +110,7 @@ class YellowWebinterface
|
|||
{
|
||||
if($this->users->getNumber())
|
||||
{
|
||||
$location = $this->yellow->config->get("serverBase").$this->yellow->config->get("pluginLocation")."core-webinterface";
|
||||
$location = $this->yellow->config->get("serverBase").$this->yellow->config->get("pluginLocation")."webinterface";
|
||||
$output = "<link rel=\"stylesheet\" type=\"text/css\" media=\"all\" href=\"".htmlspecialchars($location).".css\" />\n";
|
||||
$output .= "<script type=\"text/javascript\" src=\"".htmlspecialchars($location).".js\"></script>\n";
|
||||
$output .= "<script type=\"text/javascript\">\n";
|
||||
|
@ -127,7 +130,7 @@ class YellowWebinterface
|
|||
$language = $this->isUser() ? $this->users->getLanguage() : $this->yellow->page->get("language");
|
||||
if(!$this->yellow->text->isLanguage($language)) $language = $this->yellow->config->get("language");
|
||||
$output .= "yellow.text = ".json_encode($this->yellow->text->getData("webinterface", $language)).";\n";
|
||||
if(defined("DEBUG")) $output .= "yellow.debug = ".json_encode(DEBUG).";\n";
|
||||
if(defined("DEBUG") && DEBUG>=1) $output .= "yellow.debug = ".json_encode(DEBUG).";\n";
|
||||
$output .= "// ]]>\n";
|
||||
$output .= "</script>\n";
|
||||
}
|
||||
|
@ -150,40 +153,34 @@ class YellowWebinterface
|
|||
// Handle command help
|
||||
function onCommandHelp()
|
||||
{
|
||||
return "user [EMAIL PASSWORD NAME LANGUAGE HOME]\n";
|
||||
return "user [EMAIL PASSWORD NAME LANGUAGE STATUS HOME]\n";
|
||||
}
|
||||
|
||||
// Update user account
|
||||
function userCommand($args)
|
||||
{
|
||||
$statusCode = 0;
|
||||
list($dummy, $command, $email, $password, $name, $language, $home) = $args;
|
||||
if(empty($home) || $home[0]=='/')
|
||||
list($dummy, $command, $email, $password, $name, $language, $status, $home) = $args;
|
||||
if(!empty($email) && !empty($password))
|
||||
{
|
||||
if(!empty($email) && !empty($password))
|
||||
$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))
|
||||
{
|
||||
$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";
|
||||
$statusCode = 500;
|
||||
echo "ERROR creating hash: Algorithm '$algorithm' not supported!\n";
|
||||
} else {
|
||||
$statusCode = 200;
|
||||
foreach($this->getUserData() as $line) echo "$line\n";
|
||||
if(!$this->users->getNumber()) echo "Yellow $command: No user accounts\n";
|
||||
$statusCode = $this->users->createUser($fileName, $email, $hash, $name, $language, $status, $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 {
|
||||
echo "Yellow $command: Invalid arguments\n";
|
||||
$statusCode = 400;
|
||||
$statusCode = 200;
|
||||
foreach($this->getUserData() as $line) echo "$line\n";
|
||||
if(!$this->users->getNumber()) echo "Yellow $command: No user accounts\n";
|
||||
}
|
||||
return $statusCode;
|
||||
}
|
||||
|
@ -209,7 +206,7 @@ class YellowWebinterface
|
|||
$statusCode = $this->yellow->processRequest($serverScheme, $serverName, $base, $location, $fileName, false);
|
||||
if($this->users->getNumber())
|
||||
{
|
||||
if($this->userLoginFailed) $this->yellow->page->error(401);
|
||||
if($this->userLoginFailed) $this->yellow->page->error(500, "Login failed, [please log in](javascript:yellow.action('login');)!");
|
||||
} else {
|
||||
$url = $this->yellow->text->get("webinterfaceUserAccountUrl");
|
||||
$this->yellow->page->error(500, "You are not authorised on this server, [please add a user account]($url)!");
|
||||
|
@ -419,7 +416,10 @@ class YellowWebinterface
|
|||
function getUserData()
|
||||
{
|
||||
$data = array();
|
||||
foreach($this->users->users as $key=>$value) $data[$key] = "$value[email] - $value[name] $value[language] $value[home]";
|
||||
foreach($this->users->users as $key=>$value)
|
||||
{
|
||||
$data[$key] = "$value[email] - $value[name] $value[language] $value[status] $value[home]";
|
||||
}
|
||||
usort($data, strnatcasecmp);
|
||||
return $data;
|
||||
}
|
||||
|
@ -544,6 +544,7 @@ class YellowWebinterface
|
|||
$data["userEmail"] = $this->users->email;
|
||||
$data["userName"] = $this->users->getName();
|
||||
$data["userLanguage"] = $this->users->getLanguage();
|
||||
$data["userStatus"] = $this->users->getStatus();
|
||||
$data["userHome"] = $this->users->getHome();
|
||||
$data["serverScheme"] = $this->yellow->config->get("serverScheme");
|
||||
$data["serverName"] = $this->yellow->config->get("serverName");
|
||||
|
@ -569,8 +570,8 @@ class YellowWebinterface
|
|||
}
|
||||
}
|
||||
|
||||
// Yellow web interface users
|
||||
class YellowWebinterfaceUsers
|
||||
// Yellow users
|
||||
class YellowUsers
|
||||
{
|
||||
var $yellow; //access to API
|
||||
var $users; //registered users
|
||||
|
@ -588,32 +589,35 @@ class YellowWebinterfaceUsers
|
|||
$fileData = @file($fileName);
|
||||
if($fileData)
|
||||
{
|
||||
if(defined("DEBUG") && DEBUG>=2) echo "YellowUsers::load file:$fileName<br/>\n";
|
||||
foreach($fileData as $line)
|
||||
{
|
||||
if(preg_match("/^\//", $line)) continue;
|
||||
preg_match("/^(.*?),\s*(.*?),\s*(.*?),\s*(.*?),\s*(.*?)\s*$/", $line, $matches);
|
||||
if(!empty($matches[1]) && !empty($matches[2]) && !empty($matches[3]) && !empty($matches[4]))
|
||||
if(preg_match("/^\#/", $line)) continue;
|
||||
preg_match("/^(.*?)\s*:\s*(.*?),\s*(.*?),\s*(.*?),\s*(.*?),\s*(.*?)\s*$/", $line, $matches);
|
||||
if(!empty($matches[1]) && !empty($matches[2]) && !empty($matches[3]) && !empty($matches[4]) &&
|
||||
!empty($matches[5]) && !empty($matches[6]))
|
||||
{
|
||||
$this->set($matches[1], $matches[2], $matches[3], $matches[4], $matches[5]);
|
||||
if(defined("DEBUG") && DEBUG>=3) echo "YellowWebinterfaceUsers::load email:$matches[1] $matches[3]<br/>\n";
|
||||
$this->set($matches[1], $matches[2], $matches[3], $matches[4], $matches[5], $matches[6]);
|
||||
if(defined("DEBUG") && DEBUG>=3) echo "YellowUsers::load email:$matches[1] $matches[5]<br/>\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Set user data
|
||||
function set($email, $hash, $name, $language, $home)
|
||||
function set($email, $hash, $name, $language, $status, $home)
|
||||
{
|
||||
$this->users[$email] = array();
|
||||
$this->users[$email]["email"] = $email;
|
||||
$this->users[$email]["hash"] = $hash;
|
||||
$this->users[$email]["name"] = $name;
|
||||
$this->users[$email]["language"] = $language;
|
||||
$this->users[$email]["status"] = $status;
|
||||
$this->users[$email]["home"] = $home;
|
||||
}
|
||||
|
||||
// Create or update user in file
|
||||
function createUser($fileName, $email, $hash, $name, $language, $home)
|
||||
function createUser($fileName, $email, $hash, $name, $language, $status, $home)
|
||||
{
|
||||
$email = strreplaceu(',', '-', $email);
|
||||
$hash = strreplaceu(',', '-', $hash);
|
||||
|
@ -622,15 +626,16 @@ class YellowWebinterfaceUsers
|
|||
{
|
||||
foreach($fileData as $line)
|
||||
{
|
||||
preg_match("/^(.*?),\s*(.*?),\s*(.*?),\s*(.*?),\s*(.*?)\s*$/", $line, $matches);
|
||||
preg_match("/^(.*?)\s*:\s*(.*?),\s*(.*?),\s*(.*?),\s*(.*?)\s*$/", $line, $matches);
|
||||
if(!empty($matches[1]) && !empty($matches[2]) && !empty($matches[3]) && !empty($matches[4]))
|
||||
{
|
||||
if($matches[1] == $email)
|
||||
{
|
||||
$name = strreplaceu(',', '-', empty($name) ? $matches[3] : $name);
|
||||
$language = strreplaceu(',', '-', empty($language) ? $matches[4] : $language);
|
||||
$home = strreplaceu(',', '-', empty($home) ? $matches[5] : $home);
|
||||
$fileDataNew .= "$email,$hash,$name,$language,$home\n";
|
||||
$status = strreplaceu(',', '-', empty($status) ? $matches[5] : $status);
|
||||
$home = strreplaceu(',', '-', empty($home) ? $matches[6] : $home);
|
||||
$fileDataNew .= "$email: $hash,$name,$language,$status,$home\n";
|
||||
$found = true;
|
||||
continue;
|
||||
}
|
||||
|
@ -642,8 +647,9 @@ class YellowWebinterfaceUsers
|
|||
{
|
||||
$name = strreplaceu(',', '-', empty($name) ? $this->yellow->config->get("sitename") : $name);
|
||||
$language = strreplaceu(',', '-', empty($language) ? $this->yellow->config->get("language") : $language);
|
||||
$status = strreplaceu(',', '-', empty($status) ? "active" : $status);
|
||||
$home = strreplaceu(',', '-', empty($home) ? $this->yellow->config->get("webinterfaceUserHome") : $home);
|
||||
$fileDataNew .= "$email,$hash,$name,$language,$home\n";
|
||||
$fileDataNew .= "$email: $hash,$name,$language,$status,$home\n";
|
||||
}
|
||||
return $this->yellow->toolbox->createFile($fileName, $fileDataNew);
|
||||
}
|
||||
|
@ -652,7 +658,8 @@ class YellowWebinterfaceUsers
|
|||
function checkUser($email, $password)
|
||||
{
|
||||
$algorithm = $this->yellow->config->get("webinterfaceUserHashAlgorithm");
|
||||
return $this->isExisting($email) && $this->yellow->toolbox->verifyHash($password, $algorithm, $this->users[$email]["hash"]);
|
||||
return $this->isExisting($email) && $this->users[$email]["status"]=="active" &&
|
||||
$this->yellow->toolbox->verifyHash($password, $algorithm, $this->users[$email]["hash"]);
|
||||
}
|
||||
|
||||
// Create browser cookie
|
||||
|
@ -690,7 +697,8 @@ class YellowWebinterfaceUsers
|
|||
// Check user login from browser cookie
|
||||
function checkCookie($email, $session)
|
||||
{
|
||||
return $this->isExisting($email) && $this->yellow->toolbox->verifyHash($this->users[$email]["hash"], "sha256", $session);
|
||||
return $this->isExisting($email) && $this->users[$email]["status"]=="active" &&
|
||||
$this->yellow->toolbox->verifyHash($this->users[$email]["hash"], "sha256", $session);
|
||||
}
|
||||
|
||||
// Retun user login information
|
||||
|
@ -705,8 +713,9 @@ class YellowWebinterfaceUsers
|
|||
$hash = strreplaceu(',', '-', $hash);
|
||||
$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);
|
||||
$user = "$email,$hash,$name,$language,$home\n";
|
||||
$status = strreplaceu(',', '-', empty($status) ? "active" : $status);
|
||||
$home = strreplaceu(',', '-', empty($home) ? $this->yellow->config->get("webinterfaceUserHome") : $home);
|
||||
$user = "$email: $hash,$name,$language,$status,$home\n";
|
||||
}
|
||||
return $user;
|
||||
}
|
||||
|
@ -724,7 +733,14 @@ class YellowWebinterfaceUsers
|
|||
if(empty($email)) $email = $this->email;
|
||||
return $this->isExisting($email) ? $this->users[$email]["language"] : "";
|
||||
}
|
||||
|
||||
|
||||
// Return user status
|
||||
function getStatus($email = "")
|
||||
{
|
||||
if(empty($email)) $email = $this->email;
|
||||
return $this->isExisting($email) ? $this->users[$email]["status"] : "";
|
||||
}
|
||||
|
||||
// Return user home
|
||||
function getHome($email = "")
|
||||
{
|
||||
|
@ -745,8 +761,8 @@ class YellowWebinterfaceUsers
|
|||
}
|
||||
}
|
||||
|
||||
// Yellow web interface merge
|
||||
class YellowWebinterfaceMerge
|
||||
// Yellow merge
|
||||
class YellowMerge
|
||||
{
|
||||
var $yellow; //access to API
|
||||
const Add = '+'; //merge types
|
||||
|
@ -789,37 +805,37 @@ class YellowWebinterfaceMerge
|
|||
{
|
||||
--$sourceEnd; --$otherEnd;
|
||||
}
|
||||
for($pos=0; $pos<$textStart; ++$pos) array_push($diff, array(YellowWebinterfaceMerge::Same, $textSource[$pos], false));
|
||||
for($pos=0; $pos<$textStart; ++$pos) array_push($diff, array(YellowMerge::Same, $textSource[$pos], false));
|
||||
$lcs = $this->buildDiffLCS($textSource, $textOther, $textStart, $sourceEnd-$textStart, $otherEnd-$textStart);
|
||||
for($x=0,$y=0,$xEnd=$otherEnd-$textStart,$yEnd=$sourceEnd-$textStart; $x<$xEnd || $y<$yEnd;)
|
||||
{
|
||||
$max = $lcs[$y][$x];
|
||||
if($y<$yEnd && $lcs[$y+1][$x]==$max)
|
||||
{
|
||||
array_push($diff, array(YellowWebinterfaceMerge::Remove, $textSource[$textStart+$y], false));
|
||||
array_push($diff, array(YellowMerge::Remove, $textSource[$textStart+$y], false));
|
||||
if($lastRemove == -1) $lastRemove = count($diff)-1;
|
||||
++$y;
|
||||
continue;
|
||||
}
|
||||
if($x<$xEnd && $lcs[$y][$x+1]==$max)
|
||||
{
|
||||
if($lastRemove==-1 || $diff[$lastRemove][0]!=YellowWebinterfaceMerge::Remove)
|
||||
if($lastRemove==-1 || $diff[$lastRemove][0]!=YellowMerge::Remove)
|
||||
{
|
||||
array_push($diff, array(YellowWebinterfaceMerge::Add, $textOther[$textStart+$x], false));
|
||||
array_push($diff, array(YellowMerge::Add, $textOther[$textStart+$x], false));
|
||||
$lastRemove = -1;
|
||||
} else {
|
||||
$diff[$lastRemove] = array(YellowWebinterfaceMerge::Modify, $textOther[$textStart+$x], false);
|
||||
$diff[$lastRemove] = array(YellowMerge::Modify, $textOther[$textStart+$x], false);
|
||||
++$lastRemove; if(count($diff)==$lastRemove) $lastRemove = -1;
|
||||
}
|
||||
++$x;
|
||||
continue;
|
||||
}
|
||||
array_push($diff, array(YellowWebinterfaceMerge::Same, $textSource[$textStart+$y], false));
|
||||
array_push($diff, array(YellowMerge::Same, $textSource[$textStart+$y], false));
|
||||
$lastRemove = -1;
|
||||
++$x;
|
||||
++$y;
|
||||
}
|
||||
for($pos=$sourceEnd;$pos<$sourceSize; ++$pos) array_push($diff, array(YellowWebinterfaceMerge::Same, $textSource[$pos], false));
|
||||
for($pos=$sourceEnd;$pos<$sourceSize; ++$pos) array_push($diff, array(YellowMerge::Same, $textSource[$pos], false));
|
||||
return $diff;
|
||||
}
|
||||
|
||||
|
@ -851,29 +867,29 @@ class YellowWebinterfaceMerge
|
|||
{
|
||||
$typeMine = $diffMine[$posMine][0];
|
||||
$typeYours = $diffYours[$posYours][0];
|
||||
if($typeMine==YellowWebinterfaceMerge::Same)
|
||||
if($typeMine==YellowMerge::Same)
|
||||
{
|
||||
array_push($diff, $diffYours[$posYours]);
|
||||
} else if($typeYours==YellowWebinterfaceMerge::Same) {
|
||||
} else if($typeYours==YellowMerge::Same) {
|
||||
array_push($diff, $diffMine[$posMine]);
|
||||
} else if($typeMine==YellowWebinterfaceMerge::Add && $typeYours==YellowWebinterfaceMerge::Add) {
|
||||
} else if($typeMine==YellowMerge::Add && $typeYours==YellowMerge::Add) {
|
||||
$this->mergeConflict($diff, $diffMine[$posMine], $diffYours[$posYours], false);
|
||||
} else if($typeMine==YellowWebinterfaceMerge::Modify && $typeYours==YellowWebinterfaceMerge::Modify) {
|
||||
} else if($typeMine==YellowMerge::Modify && $typeYours==YellowMerge::Modify) {
|
||||
$this->mergeConflict($diff, $diffMine[$posMine], $diffYours[$posYours], false);
|
||||
} else if($typeMine==YellowWebinterfaceMerge::Remove && $typeYours==YellowWebinterfaceMerge::Remove) {
|
||||
} else if($typeMine==YellowMerge::Remove && $typeYours==YellowMerge::Remove) {
|
||||
array_push($diff, $diffMine[$posMine]);
|
||||
} else if($typeMine==YellowWebinterfaceMerge::Add) {
|
||||
} else if($typeMine==YellowMerge::Add) {
|
||||
array_push($diff, $diffMine[$posMine]);
|
||||
} else if($typeYours==YellowWebinterfaceMerge::Add) {
|
||||
} else if($typeYours==YellowMerge::Add) {
|
||||
array_push($diff, $diffYours[$posYours]);
|
||||
} else {
|
||||
$this->mergeConflict($diff, $diffMine[$posMine], $diffYours[$posYours], true);
|
||||
}
|
||||
if(defined("DEBUG") && DEBUG>=2) echo "YellowWebinterfaceMerge::mergeDiff $typeMine $typeYours pos:$posMine\t$posYours<br/>\n";
|
||||
if($typeMine==YellowWebinterfaceMerge::Add || $typeYours==YellowWebinterfaceMerge::Add)
|
||||
if(defined("DEBUG") && DEBUG>=2) echo "YellowMerge::mergeDiff $typeMine $typeYours pos:$posMine\t$posYours<br/>\n";
|
||||
if($typeMine==YellowMerge::Add || $typeYours==YellowMerge::Add)
|
||||
{
|
||||
if($typeMine==YellowWebinterfaceMerge::Add) ++$posMine;
|
||||
if($typeYours==YellowWebinterfaceMerge::Add) ++$posYours;
|
||||
if($typeMine==YellowMerge::Add) ++$posMine;
|
||||
if($typeYours==YellowMerge::Add) ++$posYours;
|
||||
} else {
|
||||
++$posMine;
|
||||
++$posYours;
|
||||
|
@ -883,13 +899,13 @@ class YellowWebinterfaceMerge
|
|||
{
|
||||
array_push($diff, $diffMine[$posMine]);
|
||||
$typeMine = $diffMine[$posMine][0]; $typeYours = ' ';
|
||||
if(defined("DEBUG") && DEBUG>=2) echo "YellowWebinterfaceMerge::mergeDiff $typeMine $typeYours pos:$posMine\t$posYours<br/>\n";
|
||||
if(defined("DEBUG") && DEBUG>=2) echo "YellowMerge::mergeDiff $typeMine $typeYours pos:$posMine\t$posYours<br/>\n";
|
||||
}
|
||||
for(;$posYours<count($diffYours); ++$posYours)
|
||||
{
|
||||
array_push($diff, $diffYours[$posYours]);
|
||||
$typeYours = $diffYours[$posYours][0]; $typeMine = ' ';
|
||||
if(defined("DEBUG") && DEBUG>=2) echo "YellowWebinterfaceMerge::mergeDiff $typeMine $typeYours pos:$posMine\t$posYours<br/>\n";
|
||||
if(defined("DEBUG") && DEBUG>=2) echo "YellowMerge::mergeDiff $typeMine $typeYours pos:$posMine\t$posYours<br/>\n";
|
||||
}
|
||||
return $diff;
|
||||
}
|
||||
|
@ -914,7 +930,7 @@ class YellowWebinterfaceMerge
|
|||
{
|
||||
for($i=0; $i<count($diff); ++$i)
|
||||
{
|
||||
if($diff[$i][0] != YellowWebinterfaceMerge::Remove) $output .= $diff[$i][1];
|
||||
if($diff[$i][0] != YellowMerge::Remove) $output .= $diff[$i][1];
|
||||
$conflict |= $diff[$i][2];
|
||||
}
|
||||
} else {
|
|
@ -2,16 +2,16 @@
|
|||
// Yellow is for people who make websites. http://datenstrom.se/yellow
|
||||
// This file may be used and distributed under the terms of the public license.
|
||||
|
||||
require_once("system/core/core.php");
|
||||
require_once("system/plugins/core.php");
|
||||
if(PHP_SAPI != "cli")
|
||||
{
|
||||
$yellow = new Yellow();
|
||||
$yellow = new YellowCore();
|
||||
$yellow->plugins->load();
|
||||
$yellow->request();
|
||||
} else {
|
||||
$yellow = new Yellow();
|
||||
$yellow = new YellowCore();
|
||||
$yellow->plugins->load();
|
||||
$statusCode = $yellow->command("commandline", $argv[1], $argv[2], $argv[3], $argv[4], $argv[5], $argv[6]);
|
||||
$statusCode = $yellow->command("commandline", $argv[1], $argv[2], $argv[3], $argv[4], $argv[5], $argv[6], $argv[7]);
|
||||
exit($statusCode<400 ? 0 : 1);
|
||||
}
|
||||
?>
|
Loading…
Reference in a new issue