Merge branch 'mongoose' of github.com:jeromeschneider/Baikal into mongoose

Conflicts:
	CoreVersions/0.2.0/Frameworks/BaikalAdmin/Controller/Navigation/Topbar.php
	CoreVersions/0.2.0/Frameworks/BaikalAdmin/WWWRoot/index.php
This commit is contained in:
Jérôme Schneider 2012-05-08 23:51:22 +02:00
commit ba986e8f56
122 changed files with 1453 additions and 674 deletions

0
.gitignore vendored Normal file → Executable file
View file

View file

@ -1,155 +0,0 @@
<?php
/***************************************************************
* Copyright notice
*
* (c) 2012 Jérôme Schneider <mail@jeromeschneider.fr>
* All rights reserved
*
* http://baikal.codr.fr
*
* This script is part of the Baïkal Server project. The Baïkal
* Server project is free software; you can redistribute it
* and/or modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
function rmBeginSlash($sString) {
if(substr($sString, 0, 1) === "/") {
$sString = substr($sString, 1);
}
return $sString;
}
function rmEndSlash($sString) {
if(substr($sString, -1) === "/") {
$sString = substr($sString, 0, -1);
}
return $sString;
}
function appendSlash($sString) {
if(substr($sString, -1) !== "/") {
$sString .= "/";
}
return $sString;
}
function prependSlash($sString) {
if(substr($sString, 0, 1) !== "/") {
$sString = "/" . $sString;
}
return $sString;
}
function installTool() {
if(defined("BAIKAL_CONTEXT_INSTALL") && BAIKAL_CONTEXT_INSTALL === TRUE) {
return;
} else {
$sInstallToolUrl = BAIKAL_URI . "admin/install/";
header("Location: " . $sInstallToolUrl);
exit(0);
}
}
# Asserting PHP 5.3.0+
if(version_compare(PHP_VERSION, '5.3.0', '<')) {
die('Baikal Fatal Error: Baikal requires PHP 5.3.0+ to run properly. You version is: ' . PHP_VERSION . '.');
}
# Registering Baikal classloader
define("BAIKAL_PATH_FRAMEWORKROOT", dirname(dirname(__FILE__)) . "/");
require_once(BAIKAL_PATH_FRAMEWORKROOT . '/Core/ClassLoader.php');
\Baikal\Core\ClassLoader::register();
\Baikal\Core\Tools::assertEnvironmentIsOk();
# determine Baïkal install root path
# not using realpath here to avoid symlinks resolution
define("BAIKAL_PATH_ROOT", dirname(dirname(dirname(dirname(dirname(dirname(__FILE__)))))) . "/"); # ../../../../../
define("BAIKAL_PATH_CORE", BAIKAL_PATH_ROOT . "Core/");
define("BAIKAL_PATH_SPECIFIC", BAIKAL_PATH_ROOT . "Specific/");
define("BAIKAL_PATH_FRAMEWORKS", BAIKAL_PATH_CORE . "Frameworks/");
define("BAIKAL_PATH_WWWROOT", BAIKAL_PATH_CORE . "WWWRoot/");
# Define path to Baïkal SQLite file
define("BAIKAL_SQLITE_FILE", BAIKAL_PATH_SPECIFIC . "db/baikal.sqlite");
require_once(BAIKAL_PATH_CORE . "Distrib.php");
# Determine BAIKAL_URI
$sScript = substr($_SERVER["SCRIPT_FILENAME"], strlen($_SERVER["DOCUMENT_ROOT"]));
$sDirName = appendSlash(dirname($sScript));
$sBaseUrl = appendSlash(substr($sDirName, 0, -1 * strlen(BAIKAL_CONTEXT_BASEURI)));
$aParts = explode("/", $_SERVER["SERVER_PROTOCOL"]);
$sProtocol = strtolower(array_shift($aParts));
define("BAIKAL_BASEURI", $sBaseUrl);
define("BAIKAL_URI", $sProtocol . "://" . rmEndSlash($_SERVER["HTTP_HOST"]) . $sBaseUrl);
unset($sScript); unset($sDirName); unset($sBaseUrl); unset($sProtocol); unset($aParts);
# Bootstrap Flake
require_once(BAIKAL_PATH_FRAMEWORKS . "Flake/Core/Bootstrap.php");
# Check that a config file exists
if(
!file_exists(BAIKAL_PATH_SPECIFIC . "config.php") ||
!file_exists(BAIKAL_PATH_SPECIFIC . "config.system.php")
) {
installTool();
} else {
require_once(BAIKAL_PATH_SPECIFIC . "config.php");
require_once(BAIKAL_PATH_SPECIFIC . "config.system.php");
date_default_timezone_set(BAIKAL_TIMEZONE);
# Check that Baïkal is already configured
if(!defined("BAIKAL_CONFIGURED_VERSION")) {
installTool();
} else {
# Check that running version matches configured version
if(version_compare(BAIKAL_VERSION, BAIKAL_CONFIGURED_VERSION) > 0) {
installTool();
} else {
# Check that admin password is set
if(!defined("BAIKAL_ADMIN_PASSWORDHASH")) {
installTool();
}
\Baikal\Core\Tools::assertBaikalIsOk();
# Establishing connection with database
$GLOBALS["DB"] = new \Flake\Core\Database\Sqlite(BAIKAL_SQLITE_FILE);
# Mapping PHP errors to exceptions; needed by SabreDAV
function exception_error_handler($errno, $errstr, $errfile, $errline) {
throw new \ErrorException($errstr, 0, $errno, $errfile, $errline);
}
set_error_handler("exception_error_handler");
unset($bShouldCheckEnv);
# SabreDAV Autoloader
require_once(BAIKAL_PATH_SABREDAV . 'autoload.php');
}
}
}

View file

27
CoreVersions/0.2.0/Frameworks/Baikal/Core/Tools.php Normal file → Executable file
View file

@ -48,50 +48,59 @@ class Tools {
}
}
public static function configureEnvironment() {
set_exception_handler('\Baikal\Core\Tools::handleException');
ini_set("error_reporting", E_ALL);
}
public static function handleException($exception) {
echo "<pre>" . $exception . "<pre>";
}
public static function assertBaikalIsOk() {
# Asserting DB file exists
if(!file_exists(BAIKAL_SQLITE_FILE)) {
if(!file_exists(PROJECT_SQLITE_FILE)) {
throw new \Exception("DB file does not exist. To create it, please copy 'Core/Resources/baikal.empty.sqlite' to 'Specific/db/baikal.sqlite'.");
}
# Asserting DB file is readable
if(!is_readable(BAIKAL_SQLITE_FILE)) {
if(!is_readable(PROJECT_SQLITE_FILE)) {
throw new \Exception("DB file is not readable. Please give read permissions to httpd user on file 'Specific/db/baikal.sqlite'.");
}
# Asserting DB file is writable
if(!is_writable(BAIKAL_SQLITE_FILE)) {
if(!is_writable(PROJECT_SQLITE_FILE)) {
throw new \Exception("DB file is not writable. Please give write permissions to httpd user on file 'Specific/db/baikal.sqlite'.");
}
# Asserting config file exists
if(!file_exists(BAIKAL_PATH_SPECIFIC . "config.php")) {
if(!file_exists(PROJECT_PATH_SPECIFIC . "config.php")) {
throw new \Exception("Specific/config.php does not exist. Please use the Install tool to create it.");
}
# Asserting config file is readable
if(!is_readable(BAIKAL_PATH_SPECIFIC . "config.php")) {
if(!is_readable(PROJECT_PATH_SPECIFIC . "config.php")) {
throw new \Exception("Specific/config.php is not readable. Please give read permissions to httpd user on file 'Specific/config.php'.");
}
# Asserting config file is writable
if(!is_writable(BAIKAL_PATH_SPECIFIC . "config.php")) {
if(!is_writable(PROJECT_PATH_SPECIFIC . "config.php")) {
throw new \Exception("Specific/config.php is not writable. Please give write permissions to httpd user on file 'Specific/config.php'.");
}
# Asserting system config file exists
if(!file_exists(BAIKAL_PATH_SPECIFIC . "config.system.php")) {
if(!file_exists(PROJECT_PATH_SPECIFIC . "config.system.php")) {
throw new \Exception("Specific/config.system.php does not exist. Please use the Install tool to create it.");
}
# Asserting system config file is readable
if(!is_readable(BAIKAL_PATH_SPECIFIC . "config.system.php")) {
if(!is_readable(PROJECT_PATH_SPECIFIC . "config.system.php")) {
throw new \Exception("Specific/config.system.php is not readable. Please give read permissions to httpd user on file 'Specific/config.system.php'.");
}
# Asserting system config file is writable
if(!is_writable(BAIKAL_PATH_SPECIFIC . "config.system.php")) {
if(!is_writable(PROJECT_PATH_SPECIFIC . "config.system.php")) {
throw new \Exception("Specific/config.system.php is not writable. Please give write permissions to httpd user on file 'Specific/config.system.php'.");
}
}

View file

@ -0,0 +1,97 @@
<?php
/***************************************************************
* Copyright notice
*
* (c) 2012 Jérôme Schneider <mail@jeromeschneider.fr>
* All rights reserved
*
* http://baikal.codr.fr
*
* This script is part of the Baïkal Server project. The Baïkal
* Server project is free software; you can redistribute it
* and/or modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
namespace Baikal;
class Framework extends \Flake\Core\Framework {
public static function installTool() {
if(defined("BAIKAL_CONTEXT_INSTALL") && BAIKAL_CONTEXT_INSTALL === TRUE) {
# Install tool has been launched and we're already on the install page
return;
} else {
# Install tool has been launched; redirecting user
$sInstallToolUrl = PROJECT_URI . "admin/install/";
header("Location: " . $sInstallToolUrl);
exit(0);
}
}
public static function bootstrap() {
# Registering Baikal classloader
define("BAIKAL_PATH_FRAMEWORKROOT", dirname(__FILE__) . "/");
require_once(BAIKAL_PATH_FRAMEWORKROOT . '/Core/ClassLoader.php');
\Baikal\Core\ClassLoader::register();
\Baikal\Core\Tools::assertEnvironmentIsOk();
\Baikal\Core\Tools::configureEnvironment();
# Check that a config file exists
if(
!file_exists(PROJECT_PATH_SPECIFIC . "config.php") ||
!file_exists(PROJECT_PATH_SPECIFIC . "config.system.php")
) {
self::installTool();
} else {
require_once(PROJECT_PATH_SPECIFIC . "config.php");
require_once(PROJECT_PATH_SPECIFIC . "config.system.php");
date_default_timezone_set(BAIKAL_TIMEZONE);
# Check that Baïkal is already configured
if(!defined("BAIKAL_CONFIGURED_VERSION")) {
self::installTool();
} else {
# Check that running version matches configured version
if(version_compare(BAIKAL_VERSION, BAIKAL_CONFIGURED_VERSION) > 0) {
self::installTool();
} else {
# Check that admin password is set
if(!defined("BAIKAL_ADMIN_PASSWORDHASH")) {
self::installTool();
}
\Baikal\Core\Tools::assertBaikalIsOk();
set_error_handler("\Baikal\Framework::exception_error_handler");
# SabreDAV Autoloader
require_once(BAIKAL_PATH_SABREDAV . 'autoload.php');
}
}
}
}
# Mapping PHP errors to exceptions; needed by SabreDAV
public static function exception_error_handler($errno, $errstr, $errfile, $errline) {
throw new \ErrorException($errstr, 0, $errno, $errfile, $errline);
}
}

View file

View file

View file

View file

0
CoreVersions/0.2.0/Frameworks/Baikal/Model/Config.php Normal file → Executable file
View file

View file

@ -32,13 +32,16 @@ class Standard extends \Baikal\Model\Config {
"BAIKAL_TIMEZONE" => array(
"type" => "string",
),
"BAIKAL_CARD_ENABLED" => array(
"BAIKAL_ADMIN_ENABLED" => array(
"type" => "boolean",
),
"BAIKAL_ADMIN_AUTOLOCKENABLED" => array(
"type" => "boolean",
),
"BAIKAL_CAL_ENABLED" => array(
"type" => "boolean",
),
"BAIKAL_ADMIN_ENABLED" => array(
"BAIKAL_CARD_ENABLED" => array(
"type" => "boolean",
),
"BAIKAL_ADMIN_PASSWORDHASH" => array(
@ -54,6 +57,7 @@ class Standard extends \Baikal\Model\Config {
"BAIKAL_CARD_ENABLED" => "",
"BAIKAL_CAL_ENABLED" => "",
"BAIKAL_ADMIN_ENABLED" => "",
"BAIKAL_ADMIN_AUTOLOCKENABLED" => "",
"BAIKAL_ADMIN_PASSWORDHASH" => ""
);
@ -69,8 +73,21 @@ class Standard extends \Baikal\Model\Config {
)));
$oMorpho->add(new \Formal\Element\Checkbox(array(
"prop" => "BAIKAL_CARD_ENABLED",
"label" => "Enable CardDAV"
"prop" => "BAIKAL_ADMIN_ENABLED",
"label" => "Enable Web Admin",
"popover" => array(
"title" => "Warning !",
"content" => "If disabled, you'll lose access to this very admin interface !",
),
)));
$oMorpho->add(new \Formal\Element\Checkbox(array(
"prop" => "BAIKAL_ADMIN_AUTOLOCKENABLED",
"label" => "Enable Web Admin autolock",
"popover" => array(
"title" => "Web admin autolock",
"content" => "If enabled, you'll have to create a file named ENABLE_ADMIN in Specific/ prior to every admin use."
)
)));
$oMorpho->add(new \Formal\Element\Checkbox(array(
@ -79,12 +96,8 @@ class Standard extends \Baikal\Model\Config {
)));
$oMorpho->add(new \Formal\Element\Checkbox(array(
"prop" => "BAIKAL_ADMIN_ENABLED",
"label" => "Enable Web Admin",
"popover" => array(
"title" => "Warning !",
"content" => "If disabled, you'll lose access to this very admin interface !",
),
"prop" => "BAIKAL_CARD_ENABLED",
"label" => "Enable CardDAV"
)));
$oMorpho->add(new \Formal\Element\Password(array(

View file

View file

0
CoreVersions/0.2.0/Frameworks/Baikal/Model/User.php Normal file → Executable file
View file

View file

@ -32,17 +32,31 @@ class Dashboard extends \Flake\Core\Controller {
}
public function render() {
$sLinkUsers = \BaikalAdmin\Controller\Users::link();
$oView = new \BaikalAdmin\View\Dashboard();
$oView->setData("BAIKAL_VERSION", BAIKAL_VERSION);
$sMessage =<<<MESSAGE
Ici, infos sur:<br />
* Nombre d'utilisateurs<br />
* Nombre de calendriers<br />
* Nombre d'évènements<br />
* Version + Mise à jour de baikal<br />
* <a href='{$sLinkUsers}'>Lien vers liste des utilisateurs</a><br />
* Lien vers paramétrage<br />
MESSAGE;
return $sMessage;
# Services status
$oView->setData("BAIKAL_CAL_ENABLED", BAIKAL_CAL_ENABLED);
$oView->setData("BAIKAL_CARD_ENABLED", BAIKAL_CARD_ENABLED);
# Statistics: Users
$iNbUsers = \Baikal\Model\User::getBaseRequester()->count();
$oView->setData("nbusers", $iNbUsers);
# Statistics: CalDAV
$iNbCalendars = \Baikal\Model\Calendar::getBaseRequester()->count();
$oView->setData("nbcalendars", $iNbCalendars);
$iNbEvents = \Baikal\Model\Calendar\Event::getBaseRequester()->count();
$oView->setData("nbevents", $iNbEvents);
# Statistics: CardDAV
$iNbBooks = \Baikal\Model\AddressBook::getBaseRequester()->count();
$oView->setData("nbbooks", $iNbBooks);
$iNbContacts = \Baikal\Model\AddressBook\Contact::getBaseRequester()->count();
$oView->setData("nbcontacts", $iNbContacts);
return $oView->render();
}
}

View file

@ -1,71 +0,0 @@
<?php
/***************************************************************
* Copyright notice
*
* (c) 2012 Jérôme Schneider <mail@jeromeschneider.fr>
* All rights reserved
*
* http://baikal.codr.fr
*
* This script is part of the Baïkal Server project. The Baïkal
* Server project is free software; you can redistribute it
* and/or modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
namespace BaikalAdmin\Controller\Install;
class AdminPassword extends \Flake\Core\Controller {
protected $aMessages = array();
protected $oModel; # \BaikalAdmin\Model\Install
protected $oForm; # \Formal\Form
/* public function __construct() {
parent::__construct();
$this->oModel = new \BaikalAdmin\Model\Install();
$this->oForm = $this->oModel->formForThisModelInstance(array(
"close" => FALSE
));
}
public function execute() {
if($this->oForm->submitted()) {
$this->oForm->execute();
}
}*/
public function execute() {
}
public function render() {
$sBigIcon = \BaikalAdmin\Model\Install::bigicon();
$sBaikalVersion = BAIKAL_VERSION;
$sHtml = <<<HTML
<header class="jumbotron subhead" id="overview">
<h1><i class="{$sBigIcon}"></i>Baïkal maintainance wizard</h1>
<p class="lead">Maintaining Baïkal <strong>{$sBaikalVersion}</strong></p>
</header>
HTML;
$sHtml .= <<<HTML
<p>You have to set a password for the <strong>admin</strong> user.</p>
HTML;
return $sHtml;
}
}

View file

@ -35,8 +35,13 @@ class Initialize extends \Flake\Core\Controller {
public function __construct() {
parent::__construct();
# Assert that /Specific is writable
if(!file_exists(PROJECT_PATH_SPECIFIC) || !is_dir(PROJECT_PATH_SPECIFIC) || !is_writable(PROJECT_PATH_SPECIFIC)) {
throw new \Exception("Specific/ dir is readonly. Baïkal Admin requires write permissions on this dir.");
}
$this->createDefaultConfigFilesIfNeeded();
$this->oModel = new \Baikal\Model\Config\Standard(BAIKAL_PATH_SPECIFIC . "config.php");
$this->oModel = new \Baikal\Model\Config\Standard(PROJECT_PATH_SPECIFIC . "config.php");
# Assert that config file is writable
if(!$this->oModel->writable()) {
@ -53,7 +58,7 @@ class Initialize extends \Flake\Core\Controller {
$this->oForm->execute();
if($this->oForm->persisted()) {
$sContent = file_get_contents(BAIKAL_PATH_SPECIFIC . "config.system.php");
$sContent = file_get_contents(PROJECT_PATH_SPECIFIC . "config.system.php");
$sBaikalVersion = BAIKAL_VERSION;
$sEncryptionKey = md5(microtime() . rand());
@ -68,53 +73,52 @@ define("BAIKAL_CONFIGURED_VERSION", "{$sBaikalVersion}");
PHP;
# Writing results to file
file_put_contents(BAIKAL_PATH_SPECIFIC . "config.system.php", $sContent . "\n\n" . $sNewConstants);
file_put_contents(PROJECT_PATH_SPECIFIC . "config.system.php", $sContent . "\n\n" . $sNewConstants);
}
}
}
public function render() {
$sBigIcon = \BaikalAdmin\Model\Install::bigicon();
$sBigIcon = "glyph2x-magic";
$sBaikalVersion = BAIKAL_VERSION;
$sHtml = <<<HTML
<header class="jumbotron subhead" id="overview">
<h1><i class="{$sBigIcon}"></i>Baïkal initialization wizard</h1>
<p class="lead">Configure your new Baïkal <strong>{$sBaikalVersion}</strong> installation.</p>
</header>
HTML;
$oView = new \BaikalAdmin\View\Install\Initialize();
$oView->setData("baikalversion", BAIKAL_VERSION);
if($this->oForm->persisted()) {
$sHtml .= "<p>Baïkal is now configured. You may now <a class='btn btn-success' href='" . BAIKAL_URI . "admin/'>Access the Baïkal admin</a></h2>";
$sMessage = "<p>Baïkal is now configured. You may now <a class='btn btn-success' href='" . PROJECT_URI . "admin/'>Access the Baïkal admin</a></h2>";
$sForm = "";
} else {
# Display the config form
$sHtml .= $this->oForm->render();
$sMessage = "";
$sForm = $this->oForm->render();
}
return $sHtml;
$oView->setData("message", $sMessage);
$oView->setData("form", $sForm);
return $oView->render();
}
protected function tagConfiguredVersion() {
file_put_contents(BAIKAL_PATH_SPECIFIC . "config.php", $sContent);
file_put_contents(PROJECT_PATH_SPECIFIC . "config.php", $sContent);
}
protected function createDefaultConfigFilesIfNeeded() {
# Create empty config.php if needed
if(!file_exists(BAIKAL_PATH_SPECIFIC . "config.php")) {
@touch(BAIKAL_PATH_SPECIFIC . "config.php");
if(!file_exists(PROJECT_PATH_SPECIFIC . "config.php")) {
@touch(PROJECT_PATH_SPECIFIC . "config.php");
$sContent = "<?php\n" . \Baikal\Core\Tools::getCopyrightNotice() . "\n\n";
$sContent .= $this->getDefaultConfig();
file_put_contents(BAIKAL_PATH_SPECIFIC . "config.php", $sContent);
file_put_contents(PROJECT_PATH_SPECIFIC . "config.php", $sContent);
}
# Create empty config.system.php if needed
if(!file_exists(BAIKAL_PATH_SPECIFIC . "config.system.php")) {
@touch(BAIKAL_PATH_SPECIFIC . "config.system.php");
if(!file_exists(PROJECT_PATH_SPECIFIC . "config.system.php")) {
@touch(PROJECT_PATH_SPECIFIC . "config.system.php");
$sContent = "<?php\n" . \Baikal\Core\Tools::getCopyrightNotice() . "\n\n";
$sContent .= $this->getDefaultSystemConfig();
file_put_contents(BAIKAL_PATH_SPECIFIC . "config.system.php", $sContent);
file_put_contents(PROJECT_PATH_SPECIFIC . "config.system.php", $sContent);
}
}
@ -138,6 +142,9 @@ define("BAIKAL_CAL_ENABLED", TRUE);
# Baïkal Web Admin ON/OFF switch; default TRUE
define("BAIKAL_ADMIN_ENABLED", TRUE);
# Baïkal Web Admin autolock ON/OFF switch; default TRUE
define("BAIKAL_ADMIN_AUTOLOCKENABLED", TRUE);
# Baïkal Web admin password hash; Set by Core/Scripts/adminpassword.php or via Baïkal Web Admin
define("BAIKAL_ADMIN_PASSWORDHASH", "");
CODE;
@ -163,16 +170,16 @@ define("BAIKAL_STANDALONE_ALLOWED", FALSE);
define("BAIKAL_STANDALONE_PORT", 8888);
# PATH to SabreDAV
define("BAIKAL_PATH_SABREDAV", BAIKAL_PATH_FRAMEWORKS . "SabreDAV/lib/Sabre/");
define("BAIKAL_PATH_SABREDAV", PROJECT_PATH_FRAMEWORKS . "SabreDAV/lib/Sabre/");
# If you change this value, you'll have to re-generate passwords for all your users
define("BAIKAL_AUTH_REALM", "BaikalDAV");
# Should begin and end with a "/"
define("BAIKAL_CARD_BASEURI", BAIKAL_BASEURI . "card.php/");
define("BAIKAL_CARD_BASEURI", PROJECT_BASEURI . "card.php/");
# Should begin and end with a "/"
define("BAIKAL_CAL_BASEURI", BAIKAL_BASEURI . "cal.php/");
define("BAIKAL_CAL_BASEURI", PROJECT_BASEURI . "cal.php/");
CODE;
$sCode = trim($sCode);
return $sCode;

View file

@ -36,7 +36,7 @@ class VersionUpgrade extends \Flake\Core\Controller {
}
public function render() {
$sBigIcon = \BaikalAdmin\Model\Install::bigicon();
$sBigIcon = "glyph2x-magic";
$sBaikalVersion = BAIKAL_VERSION;
$sBaikalConfiguredVersion = BAIKAL_CONFIGURED_VERSION;
@ -47,15 +47,6 @@ class VersionUpgrade extends \Flake\Core\Controller {
</header>
HTML;
/* $sHtml .= <<<HTML
<h2>What is this ?</h2>
<p>
This is the Baïkal Install Tool.<br />
It's displayed because you just installed or upgraded your Baïkal installation.<br />
<strong>Baïkal requires some maintenance in order to ensure everything works as expected.</strong>
</p>
HTML;
*/
return $sHtml;
}
}

View file

@ -0,0 +1,77 @@
<?php
/***************************************************************
* Copyright notice
*
* (c) 2012 Jérôme Schneider <mail@jeromeschneider.fr>
* All rights reserved
*
* http://baikal.codr.fr
*
* This script is part of the Baïkal Server project. The Baïkal
* Server project is free software; you can redistribute it
* and/or modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
namespace BaikalAdmin\Controller;
class Login extends \Flake\Core\Controller {
public function execute() {
}
public function render() {
$sActionUrl = \Flake\Util\Tools::getCurrentUrl();
$sSubmittedFlagName = "auth";
$sMessage = "";
if(self::isSubmitted() && !\BaikalAdmin\Core\Auth::isAuthenticated()) {
$sMessage = \Formal\Core\Message::error(
"The login/password you provided is invalid. Please retry.",
"Authentication error"
);
} elseif(self::justLoggedOut()) {
$sMessage = \Formal\Core\Message::notice(
"You have been disconnected from your session.",
"Session ended",
FALSE
);
}
$sLogin = htmlspecialchars(\Flake\Util\Tools::POST("login"));
$sPassword = htmlspecialchars(\Flake\Util\Tools::POST("password"));
if(trim($sLogin) === "") {
$sLogin = "admin";
}
$oView = new \BaikalAdmin\View\Login();
$oView->setData("message", $sMessage);
$oView->setData("actionurl", $sActionUrl);
$oView->setData("submittedflagname", $sSubmittedFlagName);
$oView->setData("login", $sLogin);
$oView->setData("password", $sPassword);
return $oView->render();
}
protected static function isSubmitted() {
return (intval(\Flake\Util\Tools::POST("auth")) === 1);
}
protected static function justLoggedOut() {
$aParams = $GLOBALS["ROUTER"]::getURLParams();
return (!empty($aParams) && $aParams[0] === "loggedout");
}
}

View file

@ -0,0 +1,43 @@
<?php
/***************************************************************
* Copyright notice
*
* (c) 2012 Jérôme Schneider <mail@jeromeschneider.fr>
* All rights reserved
*
* http://baikal.codr.fr
*
* This script is part of the Baïkal Server project. The Baïkal
* Server project is free software; you can redistribute it
* and/or modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
namespace BaikalAdmin\Controller;
class Logout extends \Flake\Core\Controller {
public function execute() {
\BaikalAdmin\Core\Auth::unAuthenticate();
$sControllerForDefaultRoute = $GLOBALS["ROUTER"]::getControllerForRoute("default");
# debug($sControllerForDefaultRoute);
# die();
$sLink = $GLOBALS["ROUTER"]::buildRouteForController($sControllerForDefaultRoute, "loggedout");
\Flake\Util\Tools::redirect($sLink);
}
public function render() {
}
}

View file

@ -33,6 +33,8 @@ class Topbar extends \Flake\Core\Controller {
public function render() {
$oView = new \BaikalAdmin\View\Navigation\Topbar();
$sCurrentRoute = $GLOBALS["ROUTER"]::getCurrentRoute();
$sActiveHome = $sActiveUsers = $sActiveSettingsStandard = $sActiveSettingsSystem = "";
@ -41,6 +43,7 @@ class Topbar extends \Flake\Core\Controller {
$sUsersLink = \BaikalAdmin\Controller\Users::link();
$sSettingsStandardLink = \BaikalAdmin\Controller\Settings\Standard::link();
$sSettingsSystemLink = \BaikalAdmin\Controller\Settings\System::link();
$sLogoutLink = \BaikalAdmin\Controller\Logout::link();
if($sCurrentRoute === "default") {
$sActiveHome = "active";
@ -61,6 +64,7 @@ class Topbar extends \Flake\Core\Controller {
$sActiveSettingsSystem = "active";
}
<<<<<<< HEAD
$sHtml =<<<HTML
<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
@ -84,5 +88,18 @@ class Topbar extends \Flake\Core\Controller {
</div>
HTML;
return $sHtml;
=======
$oView->setData("activehome", $sActiveHome);
$oView->setData("activeusers", $sActiveUsers);
$oView->setData("activesettingsstandard", $sActiveSettingsStandard);
$oView->setData("activesettingssystem", $sActiveSettingsSystem);
$oView->setData("homelink", $sHomeLink);
$oView->setData("userslink", $sUsersLink);
$oView->setData("settingsstandardlink", $sSettingsStandardLink);
$oView->setData("settingssystemlink", $sSettingsSystemLink);
$oView->setData("logoutlink", $sLogoutLink);
return $oView->render();
>>>>>>> 140b415248d6a98d9f3aa37815964b3a4456cfd6
}
}

View file

@ -0,0 +1,38 @@
<?php
/***************************************************************
* Copyright notice
*
* (c) 2012 Jérôme Schneider <mail@jeromeschneider.fr>
* All rights reserved
*
* http://baikal.codr.fr
*
* This script is part of the Baïkal Server project. The Baïkal
* Server project is free software; you can redistribute it
* and/or modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
namespace BaikalAdmin\Controller\Navigation\Topbar;
class Anonymous extends \Flake\Core\Controller {
public function execute() {
}
public function render() {
$oView = new \BaikalAdmin\View\Navigation\Topbar\Anonymous();
return $oView->render();
}
}

View file

@ -32,16 +32,7 @@ class Install extends \Flake\Core\Controller {
}
public function render() {
$sHtml =<<<HTML
<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<a class="brand">Baïkal Install Tool</a>
</div>
</div>
</div>
HTML;
return $sHtml;
$oView = new \BaikalAdmin\View\Navigation\Topbar\Install();
return $oView->render();
}
}

View file

@ -30,7 +30,7 @@ class Standard extends \Flake\Core\Controller {
public function __construct() {
parent::__construct();
$this->oModel = new \Baikal\Model\Config\Standard(BAIKAL_PATH_SPECIFIC . "config.php");
$this->oModel = new \Baikal\Model\Config\Standard(PROJECT_PATH_SPECIFIC . "config.php");
# Assert that config file is writable
if(!$this->oModel->writable()) {
@ -49,6 +49,10 @@ class Standard extends \Flake\Core\Controller {
}
public function render() {
return $this->oForm->render();
$oView = new \BaikalAdmin\View\Settings\Standard();
$oView->setData("form", $this->oForm->render());
return $oView->render();
}
}

View file

@ -30,7 +30,7 @@ class System extends \Flake\Core\Controller {
public function __construct() {
parent::__construct();
$this->oModel = new \Baikal\Model\Config\System(BAIKAL_PATH_SPECIFIC . "config.system.php");
$this->oModel = new \Baikal\Model\Config\System(PROJECT_PATH_SPECIFIC . "config.system.php");
# Assert that config file is writable
if(!$this->oModel->writable()) {
@ -49,11 +49,16 @@ class System extends \Flake\Core\Controller {
}
public function render() {
$sMessage = \Formal\Core\Message::notice(
$oView = new \BaikalAdmin\View\Settings\System();
$oView->setData("message", \Formal\Core\Message::notice(
"Do not change anything on this page unless you really know what you are doing.<br />You might break Baïkal if you misconfigure something here.",
"Warning !",
FALSE
);
return $sMessage . $this->oForm->render();
));
$oView->setData("form", $this->oForm->render());
return $oView->render();
}
}

View file

@ -118,29 +118,28 @@ class AddressBooks extends \Flake\Core\Controller {
public function render() {
$sHtml = "";
$oView = new \BaikalAdmin\View\User\AddressBooks();
# Render list of users
$oAddressBooks = $this->oUser->getAddressBooksBaseRequester()->execute();
$oView = new \BaikalAdmin\View\AddressBooks\Listing();
# User
$oView->setData("user", $this->oUser);
$oView->setData("addressbooks", $oAddressBooks);
$sHtml .= $oView->render();
# Render form
$sHtml .= "<a id='form'></a>";
# Render list of address books
$oAddressBooks = $this->oUser->getAddressBooksBaseRequester()->execute();
$oView->setData("addressbooks", $oAddressBooks);
# Messages
$sMessages = implode("\n", $this->aMessages);
$oView->setData("messages", $sMessages);
if(self::newRequested() || self::editRequested()) {
# We have to display the User form
$sHtml .= $this->oForm->render();
$sForm = $this->oForm->render();
} else {
# No form is displayed; simply display messages, if any
$sHtml .= $sMessages;
$sForm = "";
}
$oView->setData("form", $sForm);
return $sHtml;
return $oView->render();
}
protected function initForm() {

View file

@ -123,29 +123,28 @@ class Calendars extends \Flake\Core\Controller {
public function render() {
$sHtml = "";
$oView = new \BaikalAdmin\View\User\Calendars();
# Render list of users
$oCalendars = $this->oUser->getCalendarsBaseRequester()->execute();
$oView = new \BaikalAdmin\View\Calendars\Listing();
# User
$oView->setData("user", $this->oUser);
$oView->setData("calendars", $oCalendars);
$sHtml .= $oView->render();
# Render form
$sHtml .= "<a id='form'></a>";
# List of calendars
$oCalendars = $this->oUser->getCalendarsBaseRequester()->execute();
$oView->setData("calendars", $oCalendars);
# Messages
$sMessages = implode("\n", $this->aMessages);
$oView->setData("messages", $sMessages);
if(self::newRequested() || self::editRequested()) {
# We have to display the User form
$sHtml .= $this->oForm->render();
$sForm = $this->oForm->render();
} else {
# No form is displayed; simply display messages, if any
$sHtml .= $sMessages;
$sForm = "";
}
$oView->setData("form", $sForm);
return $sHtml;
return $oView->render();
}
protected function initForm() {

View file

@ -98,28 +98,27 @@ class Users extends \Flake\Core\Controller {
}
public function render() {
$sHtml = "";
# Render list of users
$oView = new \BaikalAdmin\View\Users();
# List of users
$oUsers = \Baikal\Model\User::getBaseRequester()->execute();
$oView = new \BaikalAdmin\View\Users\Listing();
$oView->setData("users", $oUsers);
$sHtml .= $oView->render();
# Render form
$sHtml .= "<a id='form'></a>";
# Messages
$sMessages = implode("\n", $this->aMessages);
$oView->setData("messages", $sMessages);
# Form
if(self::newRequested() || self::editRequested()) {
# We have to display the User form
$sHtml .= $this->oForm->render();
$sForm = $this->oForm->render();
} else {
# No form is displayed; simply display messages, if any
$sHtml .= $sMessages;
$sForm = "";
}
return $sHtml;
$oView->setData("form", $sForm);
return $oView->render();
}
protected function initForm() {

57
CoreVersions/0.2.0/Frameworks/BaikalAdmin/Core/Auth.php Normal file → Executable file
View file

@ -27,7 +27,7 @@
namespace BaikalAdmin\Core;
class Auth {
static function assertEnabled() {
public static function assertEnabled() {
if(!defined("BAIKAL_ADMIN_ENABLED") || BAIKAL_ADMIN_ENABLED !== TRUE) {
die("<h1>Ba&iuml;kal Admin is disabled.</h1>To enable it, set BAIKAL_ADMIN_ENABLED to TRUE in <b>Specific/config.php</b>");
}
@ -35,7 +35,11 @@ class Auth {
self::assertUnlocked();
}
static function assertUnlocked() {
public static function assertUnlocked() {
if(defined("BAIKAL_ADMIN_AUTOLOCKENABLED") && BAIKAL_ADMIN_AUTOLOCKENABLED === FALSE) {
return TRUE;
}
if(defined("BAIKAL_CONTEXT_INSTALL") && BAIKAL_CONTEXT_INSTALL === TRUE) {
$sToolName = "Ba&iuml;kal Install Tool";
@ -44,7 +48,7 @@ class Auth {
}
$bLocked = TRUE;
$sEnableFile = BAIKAL_PATH_SPECIFIC . "ENABLE_ADMIN";
$sEnableFile = PROJECT_PATH_SPECIFIC . "ENABLE_ADMIN";
if(file_exists($sEnableFile)) {
clearstatcache();
@ -68,41 +72,40 @@ class Auth {
die("<h1>" . $sToolName . " is locked.</h1>To unlock it, create an empty file named ENABLE_ADMIN in <b>Specific/</b>");
}
}
static function assertAuthentified() {
if(!self::isAuthentified()) {
header(utf8_decode('WWW-Authenticate: Basic realm="Baïkal admin"'));
header('HTTP/1.0 401 Unauthorized');
die("Please authenticate.");
public static function isAuthenticated() {
if(isset($_SESSION["baikaladminauth"]) && $_SESSION["baikaladminauth"] === md5(BAIKAL_ADMIN_PASSWORDHASH)) {
return TRUE;
}
return TRUE;
return FALSE;
}
static function isAuthentified() {
if(array_key_exists("PHP_AUTH_USER", $_SERVER)) {
$sUser = $_SERVER["PHP_AUTH_USER"];
} else {
$sUser = FALSE;
public static function authenticate() {
if(intval(\Flake\Util\Tools::POST("auth")) !== 1) {
return FALSE;
}
if(array_key_exists("PHP_AUTH_PW", $_SERVER)) {
$sPass = $_SERVER["PHP_AUTH_PW"];
} else {
$sPass = FALSE;
}
$sUser = \Flake\Util\Tools::POST("login");
$sPass = \Flake\Util\Tools::POST("password");
$sPassHash = self::hashAdminPassword($sPass);
if($sUser === "admin" && $sPassHash === BAIKAL_ADMIN_PASSWORDHASH) {
$_SESSION["baikaladminauth"] = md5(BAIKAL_ADMIN_PASSWORDHASH);
return TRUE;
}
return FALSE;
}
public static function unAuthenticate() {
unset($_SESSION["baikaladminauth"]);
}
static function hashAdminPassword($sPassword) {
public static function hashAdminPassword($sPassword) {
return md5('admin:' . BAIKAL_AUTH_REALM . ':' . $sPassword);
}
}

View file

@ -1,44 +0,0 @@
<?php
/***************************************************************
* Copyright notice
*
* (c) 2012 Jérôme Schneider <mail@jeromeschneider.fr>
* All rights reserved
*
* http://baikal.codr.fr
*
* This script is part of the Baïkal Server project. The Baïkal
* Server project is free software; you can redistribute it
* and/or modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
define("BAIKALADMIN_PATH_ROOT", dirname(dirname(__FILE__)) . "/");
# Bootstrap Baïkal Core
require_once(dirname(dirname(dirname(__FILE__))) . "/Baikal/Core/Bootstrap.php"); # ../../, symlink-safe
# Bootstrap Formal
require_once(dirname(dirname(dirname(__FILE__))) . "/Formal/Core/Bootstrap.php");
# Registering BaikalAdmin classloader
require_once(dirname(__FILE__) . '/ClassLoader.php');
\BaikalAdmin\Core\ClassLoader::register();
# Relative to BAIKAL_URI; so that BAIKAL_URI . BAIKALADMIN_URIPATH corresponds to the full URL to Baïkal admin
define("BAIKALADMIN_URIPATH", "admin/");
$GLOBALS["ROUTER"]::setURIPath(BAIKALADMIN_URIPATH);
# Include BaikalAdmin Framework config
require_once(BAIKALADMIN_PATH_ROOT . "config.php");

View file

View file

View file

@ -0,0 +1,46 @@
<?php
/***************************************************************
* Copyright notice
*
* (c) 2012 Jérôme Schneider <mail@jeromeschneider.fr>
* All rights reserved
*
* http://baikal.codr.fr
*
* This script is part of the Baïkal Server project. The Baïkal
* Server project is free software; you can redistribute it
* and/or modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
namespace BaikalAdmin;
class Framework extends \Flake\Core\Framework {
public static function bootstrap() {
define("BAIKALADMIN_PATH_ROOT", PROJECT_PATH_ROOT . "Core/Frameworks/BaikalAdmin/"); # ./
\Baikal\Framework::bootstrap();
\Formal\Framework::bootstrap();
# Registering BaikalAdmin classloader
require_once(BAIKALADMIN_PATH_ROOT . '/Core/ClassLoader.php');
\BaikalAdmin\Core\ClassLoader::register();
$GLOBALS["ROUTER"]::setURIPath("admin/");
# Include BaikalAdmin Framework config
require_once(BAIKALADMIN_PATH_ROOT . "config.php");
}
}

View file

@ -1,75 +0,0 @@
<?php
/***************************************************************
* Copyright notice
*
* (c) 2012 Jérôme Schneider <mail@jeromeschneider.fr>
* All rights reserved
*
* http://baikal.codr.fr
*
* This script is part of the Baïkal Server project. The Baïkal
* Server project is free software; you can redistribute it
* and/or modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
namespace BaikalAdmin\Model;
class Install extends \Flake\Core\Model\NoDb {
protected $aData = array(
"test" => "",
);
public function persist() {
}
public function destroy() {
}
public function floating() {
return FALSE;
}
public function formMorphologyForThisModelInstance() {
$oMorpho = new \Formal\Form\Morphology();
$oMorpho->add(new \Formal\Element\Text(array(
"prop" => "test",
"label" => "Test"
)));
return $oMorpho;
}
public static function icon() {
return "icon-cog";
}
public static function mediumicon() {
return "glyph-magic";
}
public static function bigicon() {
return "glyph2x-magic";
}
public function label() {
return "Baïkal";
}
public static function humanName() {
return "Parameters";
}
}

View file

Before

Width:  |  Height:  |  Size: 104 KiB

After

Width:  |  Height:  |  Size: 104 KiB

View file

Before

Width:  |  Height:  |  Size: 227 KiB

After

Width:  |  Height:  |  Size: 227 KiB

View file

@ -0,0 +1,111 @@
<header class="jumbotron subhead" id="overview">
<h1><i class="glyph2x-circle-info"></i>Dashboard</h1>
</header>
<section id="about">
<div class="page-header">
<h1>About this system</h1>
</div>
<div class="row">
<div class="span3">
<h2>Version</h2>
<p>This systems runs Baïkal <span class="label label-info"><?= $BAIKAL_VERSION ?></span></p>
</div>
<div class="span3">
<h2>Services</h2>
<?
if($BAIKAL_CAL_ENABLED === TRUE) {
$sCalDAVClass = "label-success";
$sCalDAVText = "On";
} else {
$sCalDAVClass = "label-important";
$sCalDAVText = "Off";
}
if($BAIKAL_CARD_ENABLED === TRUE) {
$sCardDAVClass = "label-success";
$sCardDAVText = "On";
} else {
$sCardDAVClass = "label-important";
$sCardDAVText = "Off";
}
?>
<table class="table">
<tbody>
<tr>
<td>Web admin</td>
<td><span class="label label-success">On</span></p></td>
</tr>
<tr>
<td>CalDAV</td>
<td><span class="label <?= $sCalDAVClass ?>"><?= $sCalDAVText ?></span></td>
</tr>
<tr>
<td>CardDAV</td>
<td><span class="label <?= $sCardDAVClass ?>"><?= $sCardDAVText ?></span></td>
</tr>
</tbody>
</table>
</div>
<div class="span6">
<h2>License and credits</h2>
<?
$sUrl = "http://baikal.codr.fr/version/" . $BAIKAL_VERSION . "/about";
?>
<p>Baïkal is open source software, and released under the terms of the GNU GPL v3.</p>
<p>Baïkal is developped by Jérôme Schneider. You can contact him at <a href="mailto:mail@jeromeschneider.fr">mail@jeromeschneider.fr</a>.</p>
<p>Baïkal is based upon other open source projects. Read the README.md file to learn about that.</p>
<p><a href="<?= $sUrl ?>"><?= $sUrl ?></a></p>
</div>
</div>
</section>
<section id="statistics">
<div class="page-header">
<h1>Statistics</h1>
</div>
<div class="row">
<div class="span4">
<h2>Users</h2>
<table class="table">
<tbody>
<tr>
<td>Registered users</td>
<td><span class="badge"><?= $nbusers ?></span></td>
</tr>
</tbody>
</table>
</div>
<div class="span4">
<h2>CalDAV</h2>
<table class="table">
<tbody>
<tr>
<td>Number of calendars</td>
<td><span class="badge"><?= $nbcalendars ?></span></td>
</tr>
<tr>
<td>Number of events</td>
<td><span class="badge"><?= $nbevents ?></span></td>
</tr>
</tbody>
</table>
</div>
<div class="span4">
<h2>CardDAV</h2>
<table class="table">
<tbody>
<tr>
<td>Number of address books</td>
<td><span class="badge"><?= $nbbooks ?></span></td>
</tr>
<tr>
<td>Number of contacts</td>
<td><span class="badge"><?= $nbcontacts ?></span></td>
</tr>
</tbody>
</table>
</div>
</div>
</section>

View file

@ -0,0 +1,8 @@
<header class="jumbotron subhead" id="overview">
<h1><i class="glyph2x-magic"></i>Baïkal initialization wizard</h1>
<p class="lead">Configure your new Baïkal <strong><?= $baikalversion ?></strong> installation.</p>
</header>
<a id="formid"></a>
<?= $message ?>
<?= $form ?>

View file

@ -0,0 +1,25 @@
<header class="jumbotron subhead" id="overview">
<h1><i class="glyph2x-lock"></i>Authentication</h1>
<p class="lead">Please authenticate to access Baïkal Web Admin.</p>
</header>
<?= $message ?>
<form class="form-horizontal" action="<?= $actionurl ?>" method="post" enctype="multipart/formdata">
<input type="hidden" name="<?= $submittedflagname ?>" value="1" />
<fieldset>
<p>
<label for="login">Login</label>
<input type="text" name="login" value="<?= $login ?>" />
</p>
<p>
<label for="password">Password</label>
<input type="password" name="password" value="<?= $password ?>" />
</p>
<div class="form-actions">
<button type="submit" class="btn btn-primary">Authenticate</button>
</div>
</fieldset>
</form>

View file

@ -0,0 +1,21 @@
<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
<a class="brand" href="<?= $homelink ?>">Baïkal Web Admin</a>
<div class="nav-collapse">
<ul class="nav">
<li class="<?= $activehome ?>"> <a href="<?= $homelink ?>">Dashboard</a></li>
<li class="<?= $activeusers ?>"> <a href="<?= $userslink ?>">Users and resources</a></li>
<li class="<?= $activesettingsstandard ?>"> <a href="<?= $settingsstandardlink ?>">Settings</a></li>
<li class="<?= $activesettingssystem ?>"> <a href="<?= $settingssystemlink ?>">System settings</a></li>
<li> <a href="<?= $logoutlink ?>"><i class="icon-eject icon-white"></i> Logout</a></li>
</ul>
</div><!--/.nav-collapse -->
</div>
</div>
</div>

View file

@ -0,0 +1,7 @@
<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<a class="brand">Baïkal Web Admin</a>
</div>
</div>
</div>

View file

@ -0,0 +1,7 @@
<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<a class="brand">Baïkal Install Tool</a>
</div>
</div>
</div>

View file

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

View file

Before

Width:  |  Height:  |  Size: 4.9 KiB

After

Width:  |  Height:  |  Size: 4.9 KiB

View file

@ -0,0 +1,5 @@
<header class="jumbotron subhead" id="overview">
<h1><i class="glyph2x-adjust"></i>Baïkal settings</h1>
</header>
<?= $form ?>

View file

@ -0,0 +1,6 @@
<header class="jumbotron subhead" id="overview">
<h1><i class="glyph2x-adjust"></i>Baïkal system settings</h1>
</header>
<?= $message ?>
<?= $form ?>

View file

@ -33,4 +33,8 @@
<? endforeach ?>
</tbody>
</table>
</table>
<a id='form'></a>
<?= $messages ?>
<?= $form ?>

View file

@ -33,4 +33,8 @@
<? endforeach ?>
</tbody>
</table>
</table>
<a id='form'></a>
<?= $messages ?>
<?= $form ?>

View file

@ -31,4 +31,8 @@
</tr>
<? endforeach ?>
</table>
</table>
<a id='form'></a>
<?= $messages ?>
<?= $form ?>

View file

View file

View file

@ -0,0 +1,34 @@
<?php
/***************************************************************
* Copyright notice
*
* (c) 2012 Jérôme Schneider <mail@jeromeschneider.fr>
* All rights reserved
*
* http://baikal.codr.fr
*
* This script is part of the Baïkal Server project. The Baïkal
* Server project is free software; you can redistribute it
* and/or modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
namespace BaikalAdmin\Route;
class Logout {
public static function execute(\Flake\Core\Render\Container &$oRenderContainer) {
$oRenderContainer->zone("Payload")->addBlock(new \BaikalAdmin\Controller\Logout());
}
}

View file

View file

View file

View file

View file

View file

@ -24,7 +24,8 @@
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
namespace BaikalAdmin\View\Users;
namespace BaikalAdmin\View;
class Listing extends \BaikalAdmin\Core\View {
class Dashboard extends \BaikalAdmin\Core\View {
}

View file

@ -24,7 +24,7 @@
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
namespace BaikalAdmin\View\AddressBooks;
namespace BaikalAdmin\View\Install;
class Listing extends \BaikalAdmin\Core\View {
class Initialize extends \BaikalAdmin\Core\View {
}

View file

@ -24,7 +24,8 @@
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
namespace BaikalAdmin\View\Calendars;
namespace BaikalAdmin\View;
class Listing extends \BaikalAdmin\Core\View {
class Login extends \BaikalAdmin\Core\View {
}

View file

@ -24,8 +24,8 @@
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
define("FORMAL_PATH_ROOT", dirname(dirname(__FILE__)) . "/");
namespace BaikalAdmin\View\Navigation;
# Registering BaikalAdmin classloader
require_once(dirname(__FILE__) . '/ClassLoader.php');
\Formal\Core\ClassLoader::register();
class Topbar extends \BaikalAdmin\Core\View {
}

View file

@ -0,0 +1,31 @@
<?php
/***************************************************************
* Copyright notice
*
* (c) 2012 Jérôme Schneider <mail@jeromeschneider.fr>
* All rights reserved
*
* http://baikal.codr.fr
*
* This script is part of the Baïkal Server project. The Baïkal
* Server project is free software; you can redistribute it
* and/or modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
namespace BaikalAdmin\View\Navigation\Topbar;
class Anonymous extends \BaikalAdmin\Core\View {
}

View file

@ -0,0 +1,31 @@
<?php
/***************************************************************
* Copyright notice
*
* (c) 2012 Jérôme Schneider <mail@jeromeschneider.fr>
* All rights reserved
*
* http://baikal.codr.fr
*
* This script is part of the Baïkal Server project. The Baïkal
* Server project is free software; you can redistribute it
* and/or modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
namespace BaikalAdmin\View\Navigation\Topbar;
class Install extends \BaikalAdmin\Core\View {
}

View file

@ -0,0 +1,31 @@
<?php
/***************************************************************
* Copyright notice
*
* (c) 2012 Jérôme Schneider <mail@jeromeschneider.fr>
* All rights reserved
*
* http://baikal.codr.fr
*
* This script is part of the Baïkal Server project. The Baïkal
* Server project is free software; you can redistribute it
* and/or modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
namespace BaikalAdmin\View\Settings;
class Standard extends \BaikalAdmin\Core\View {
}

View file

@ -0,0 +1,31 @@
<?php
/***************************************************************
* Copyright notice
*
* (c) 2012 Jérôme Schneider <mail@jeromeschneider.fr>
* All rights reserved
*
* http://baikal.codr.fr
*
* This script is part of the Baïkal Server project. The Baïkal
* Server project is free software; you can redistribute it
* and/or modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
namespace BaikalAdmin\View\Settings;
class System extends \BaikalAdmin\Core\View {
}

View file

@ -0,0 +1,30 @@
<?php
/***************************************************************
* Copyright notice
*
* (c) 2012 Jérôme Schneider <mail@jeromeschneider.fr>
* All rights reserved
*
* http://baikal.codr.fr
*
* This script is part of the Baïkal Server project. The Baïkal
* Server project is free software; you can redistribute it
* and/or modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
namespace BaikalAdmin\View\User;
class AddressBooks extends \BaikalAdmin\Core\View {
}

View file

@ -0,0 +1,30 @@
<?php
/***************************************************************
* Copyright notice
*
* (c) 2012 Jérôme Schneider <mail@jeromeschneider.fr>
* All rights reserved
*
* http://baikal.codr.fr
*
* This script is part of the Baïkal Server project. The Baïkal
* Server project is free software; you can redistribute it
* and/or modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
namespace BaikalAdmin\View\User;
class Calendars extends \BaikalAdmin\Core\View {
}

View file

@ -0,0 +1,30 @@
<?php
/***************************************************************
* Copyright notice
*
* (c) 2012 Jérôme Schneider <mail@jeromeschneider.fr>
* All rights reserved
*
* http://baikal.codr.fr
*
* This script is part of the Baïkal Server project. The Baïkal
* Server project is free software; you can redistribute it
* and/or modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
namespace BaikalAdmin\View;
class Users extends \BaikalAdmin\Core\View {
}

View file

@ -26,28 +26,42 @@
ini_set("display_errors", 1);
error_reporting(E_ALL);
define("BAIKAL_CONTEXT_BASEURI", "/admin/");
define("BAIKAL_CONTEXT", TRUE);
define("BAIKAL_CONTEXT_ADMIN", TRUE);
define("PROJECT_CONTEXT_BASEURI", "/admin/");
define("PROJECT_PATH_ROOT", dirname(dirname(getcwd())) . "/"); #../../
# Bootstraping Flake
require_once(PROJECT_PATH_ROOT . "Core/Frameworks/Flake/Framework.php"); # ../../
\Flake\Framework::bootstrap();
# Bootstrap BaikalAdmin
require_once(dirname(dirname(__FILE__)) . "/Core/Bootstrap.php"); # ../
\BaikalAdmin\Framework::bootstrap();
# Evaluate assertions
# Assert that BaikalAdmin is enabled
\BaikalAdmin\Core\Auth::assertEnabled();
\BaikalAdmin\Core\Auth::assertAuthentified();
# Create and setup a page object
$oPage = new \Flake\Controller\Page(BAIKALADMIN_PATH_TEMPLATES . "Page/index.html");
$oPage->injectHTTPHeaders();
$oPage->setTitle("Baïkal " . BAIKAL_VERSION . " Web Admin");
$oPage->setBaseUrl(BAIKAL_URI);
$oPage->setBaseUrl(PROJECT_URI);
$oPage->zone("navbar")->addBlock(new \BaikalAdmin\Controller\Navigation\Topbar());
# Authentication
if(
\BaikalAdmin\Core\Auth::isAuthenticated() === FALSE &&
\BaikalAdmin\Core\Auth::authenticate() === FALSE
) {
$oPage->zone("navbar")->addBlock(new \BaikalAdmin\Controller\Navigation\Topbar\Anonymous());
$oPage->zone("Payload")->addBlock(new \BaikalAdmin\Controller\Login());
} else {
$oPage->zone("navbar")->addBlock(new \BaikalAdmin\Controller\Navigation\Topbar());
# Route the request
$GLOBALS["ROUTER"]::route($oPage);
# Route the request
$GLOBALS["ROUTER"]::route($oPage);
}
# Render the page
echo $oPage->render();
echo $oPage->render();

View file

@ -26,13 +26,19 @@
ini_set("display_errors", 1);
error_reporting(E_ALL);
define("BAIKAL_CONTEXT_BASEURI", "/admin/install/");
define("BAIKAL_CONTEXT", TRUE);
define("BAIKAL_CONTEXT_INSTALL", TRUE);
define("PROJECT_CONTEXT_BASEURI", "/admin/install/");
define("PROJECT_PATH_ROOT", dirname(dirname(dirname(getcwd()))) . "/"); # ../../../
# Bootstraping Flake
require_once(PROJECT_PATH_ROOT . "Core/Frameworks/Flake/Framework.php");
\Flake\Framework::bootstrap();
# Bootstrap BaikalAdmin
require_once(dirname(dirname(dirname(__FILE__))) . "/Core/Bootstrap.php"); # ../../
\BaikalAdmin\Framework::bootstrap();
# Evaluate assertions
\BaikalAdmin\Core\Auth::assertUnlocked();
@ -41,7 +47,7 @@ require_once(dirname(dirname(dirname(__FILE__))) . "/Core/Bootstrap.php"); # ../
$oPage = new \Flake\Controller\Page(BAIKALADMIN_PATH_TEMPLATES . "Page/index.html");
$oPage->injectHTTPHeaders();
$oPage->setTitle("Baïkal Maintainance");
$oPage->setBaseUrl(BAIKAL_URI);
$oPage->setBaseUrl(PROJECT_URI);
$oPage->zone("navbar")->addBlock(new \BaikalAdmin\Controller\Navigation\Topbar\Install());
@ -51,15 +57,11 @@ if(!defined("BAIKAL_CONFIGURED_VERSION")) {
} elseif(!defined("BAIKAL_ADMIN_PASSWORDHASH")) {
# we have to set an admin password
$oPage->zone("Payload")->addBlock(new \BaikalAdmin\Controller\Install\AdminPassword());
$oPage->zone("Payload")->addBlock(new \BaikalAdmin\Controller\Install\Initialize());
} else {
# we have to initialize Baïkal (new installation)
$oPage->zone("Payload")->addBlock(new \BaikalAdmin\Controller\Install\VersionUpgrade());
}
# Route the request
//$GLOBALS["ROUTER"]::route($oPage);
# Render the page
echo $oPage->render();

3
CoreVersions/0.2.0/Frameworks/BaikalAdmin/config.php Normal file → Executable file
View file

@ -33,5 +33,6 @@ $GLOBALS["ROUTES"] = array(
"users/addressbooks" => "\BaikalAdmin\Route\User\AddressBooks",
"install" => "\BaikalAdmin\Route\Install",
"settings/standard" => "\BaikalAdmin\Route\Settings\Standard",
"settings/system" => "\BaikalAdmin\Route\Settings\System"
"settings/system" => "\BaikalAdmin\Route\Settings\System",
"logout" => "\BaikalAdmin\Route\Logout"
);

View file

@ -1,89 +0,0 @@
<?php
/***************************************************************
* Copyright notice
*
* (c) 2012 Jérôme Schneider <mail@jeromeschneider.fr>
* All rights reserved
*
* http://baikal.codr.fr
*
* This script is part of the Baïkal Server project. The Baïkal
* Server project is free software; you can redistribute it
* and/or modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
if(!defined('LF')) {
define('LF', chr(10));
}
if(!defined('CR')) {
define('CR', chr(13));
}
if(array_key_exists("SERVER_NAME", $_SERVER) && $_SERVER["SERVER_NAME"] === "mongoose") {
define("MONGOOSE_SERVER", TRUE);
} else {
define("MONGOOSE_SERVER", FALSE);
}
define("FLAKE_PATH_ROOT", dirname(dirname(__FILE__)) . "/"); # ../
# Display errors messages, except notices
#ini_set("display_errors", 1);
#ini_set("error_reporting", E_ALL & ~E_NOTICE);
if(!function_exists("appendSlash")) {
function appendSlash($sPath) {
if($sPath{strlen($sPath) - 1} !== "/") {
$sPath .= "/";
}
return $sPath;
}
}
if(!function_exists("debug")) {
function debug($mVar, $sHeader=0) {
\Flake\Util\Tools::debug($mVar, $sHeader);
}
}
require_once(FLAKE_PATH_ROOT . 'Core/ClassLoader.php');
\Flake\Core\ClassLoader::register();
# Include Flake Framework config
require_once(FLAKE_PATH_ROOT . "config.php");
# Determine Router class
$GLOBALS["ROUTER"] = \Flake\Util\Tools::router();
if(!\Flake\Util\Tools::isCliPhp()) {
ini_set("html_errors", TRUE);
session_start();
}
setlocale(LC_ALL, FLAKE_LOCALE);
date_default_timezone_set(FLAKE_TIMEZONE);
if(defined("FLAKE_DB_FILEPATH") && file_exists(FLAKE_DB_FILEPATH) && is_readable(FLAKE_DB_FILEPATH) && !isset($GLOBALS["DB"])) {
$GLOBALS["DB"] = new \Flake\Core\Database\Sqlite(FLAKE_DB_FILEPATH);
}
$GLOBALS["TEMPLATESTACK"] = array();
$aUrlInfo = parse_url(FLAKE_URI);
define("FLAKE_DOMAIN", $_SERVER["HTTP_HOST"]);
define("FLAKE_URIPATH", \Flake\Util\Tools::stripBeginSlash($aUrlInfo["path"]));
unset($aUrlInfo);

View file

@ -34,34 +34,50 @@ class ClassLoader {
public static function loadClass($sFullClassName) {
$sClassPath = FALSE;
$aParts = explode("\\", $sFullClassName);
if(count($aParts) === 1) {
return;
}
if($aParts[0] !== "Flake" && $aParts[0] !== "Specific" && $aParts[0] !== "Frameworks") {
# Extracting the Radical
$sRadical = $aParts[0];
if(in_array($sRadical, array("Flake", "Specific", "Frameworks"))) {
if($sRadical === "Flake") {
$sRootPath = FLAKE_PATH_ROOT;
} elseif($sRadical === "Specific") {
$sRootPath = FLAKE_PATH_SPECIFIC;
} else {
$sRootPath = PROJECT_PATH_FRAMEWORKS;
}
# Stripping radical
array_shift($aParts);
# Classname is the last part
$sClassName = array_pop($aParts);
# Path to class
$sClassPath = $sRootPath . implode("/", $aParts) . "/" . $sClassName . ".php";
} elseif(count($aParts) > 1) {
if($aParts[1] === "Framework") {
# It must be a Flake Framework
$sClassPath = PROJECT_PATH_FRAMEWORKS . $sRadical . "/Framework.php";
}
}
if($sClassPath === FALSE) {
return;
}
// ejecting the Radical
$sRadical = array_shift($aParts);
if($sRadical === "Flake") {
$sRootPath = FLAKE_PATH_ROOT;
} elseif($sRadical === "Specific") {
$sRootPath = FLAKE_PATH_SPECIFIC; # When prefix does not point another namespaced framework, we use "Specific"
} elseif($sRadical === "Frameworks") {
$sRootPath = FLAKE_PATH_FRAMEWORKS;
}
$sClassName = array_pop($aParts);
$sBasePath = $sRootPath . implode("/", $aParts) . "/";
$sClassPath = $sBasePath . $sClassName . ".php";
if(file_exists($sClassPath) && is_readable($sClassPath)) {
require_once($sClassPath);
} else {
echo '<h1>PHP Autoload Error. Cannot find ' . $sFullClassName . '</h1>';
echo '<h1>PHP Autoload Error. Cannot find ' . $sFullClassName . ' in ' . $sClassPath . '</h1>';
echo "<pre>" . print_r(debug_backtrace(), TRUE) . "</pre>";
die();
}

View file

@ -0,0 +1,83 @@
<?php
/***************************************************************
* Copyright notice
*
* (c) 2012 Jérôme Schneider <mail@jeromeschneider.fr>
* All rights reserved
*
* http://baikal.codr.fr
*
* This script is part of the Baïkal Server project. The Baïkal
* Server project is free software; you can redistribute it
* and/or modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
namespace Flake\Core;
class DocumentedException extends \Exception {
protected $aMarkers = array();
# Redefine the exception signature
public function __construct($message, $aMarkers = array()) {
$this->aMarkers = $aMarkers;
parent::__construct($message, 0, null);
}
# custom string representation of object
public function __toString() {
$aDoc = $this->getDocumentation();
\Flake\Util\Tools::debug($aDoc);
return "<span style='color: red;'>" . htmlspecialchars($this->message) . "</span>";
}
protected function getSoftrefPath() {
$sSoftRef = $this->getMessage();
$aTrace = $this->getTrace();
if($sSoftRef{0} === "\\") {
# An absolute softref has been given
return $sSoftRef;
}
if(isset($aTrace[0]["class"])) {
return "\\" . $aTrace[0]["class"] . "#" . $sSoftRef;
}
return $sSoftRef;
}
protected function getDocumentation() {
# Determine the documentation softref
$sSoftRefPath = $this->getSoftrefPath();
return $sSoftRefPath;
/*
$aParts = explode("#", \Flake\Util\Tools::trimStrings($sSoftRefPath, "\\"));
$aSegments = explode("\\", $aParts[0]);
$sKey = $aParts[1];
# Is it a Framework ?
if(\Flake\Util\Frameworks::isAFramework($aSegments[0])) {
$sPath = \Flake\Util\Frameworks::getPath($aSegments[0]);
die($sPath);
}
debug($aParts);
return $sSoftRefPath;
*/
}
}

View file

@ -0,0 +1,31 @@
<?php
/***************************************************************
* Copyright notice
*
* (c) 2012 Jérôme Schneider <mail@jeromeschneider.fr>
* All rights reserved
*
* http://baikal.codr.fr
*
* This script is part of the Baïkal Server project. The Baïkal
* Server project is free software; you can redistribute it
* and/or modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
namespace Flake\Core;
class Framework {
}

1
CoreVersions/0.2.0/Frameworks/Flake/Core/Requester.php Normal file → Executable file
View file

@ -45,4 +45,5 @@ abstract class Requester extends \Flake\Core\FLObject {
}
public abstract function execute();
public abstract function count();
}

View file

@ -170,7 +170,7 @@ class Sql extends \Flake\Core\FLObject {
return $this->bHasBeenExecuted;
}
public function getQuery() {
public function getQuery($sFields = "*") {
$sWhere = "1=1";
$sOrderBy = "";
$sLimit = "";
@ -194,7 +194,7 @@ class Sql extends \Flake\Core\FLObject {
}
return $GLOBALS["DB"]->SELECTquery(
"*",
$sFields,
$this->sDataTable,
$sWhere,
"",
@ -202,6 +202,10 @@ class Sql extends \Flake\Core\FLObject {
$sLimit
);
}
public function getCountQuery() {
return $this->getQuery("count(*) as nbitems");
}
public function execute() {
$oCollection = new \Flake\Core\CollectionTyped($this->sModelClass);
@ -218,4 +222,15 @@ class Sql extends \Flake\Core\FLObject {
return $oCollection;
}
public function count() {
$sSql = $this->getCountQuery();
$rSql = $GLOBALS["DB"]->query($sSql);
if(($aRs = $rSql->fetch()) !== FALSE) {
return intval($aRs["nbitems"]);
}
return 0;
}
}

View file

@ -0,0 +1,155 @@
<?php
/***************************************************************
* Copyright notice
*
* (c) 2012 Jérôme Schneider <mail@jeromeschneider.fr>
* All rights reserved
*
* http://baikal.codr.fr
*
* This script is part of the Baïkal Server project. The Baïkal
* Server project is free software; you can redistribute it
* and/or modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
namespace Flake;
require_once(PROJECT_PATH_ROOT . "Core/Frameworks/Flake/Core/Framework.php"); # Manual require as Classloader not included yet
if(!function_exists("debug")) {
function debug($mVar, $sHeader=0) {
\Flake\Util\Tools::debug($mVar, $sHeader);
}
}
class Framework extends \Flake\Core\Framework {
function rmBeginSlash($sString) {
if(substr($sString, 0, 1) === "/") {
$sString = substr($sString, 1);
}
return $sString;
}
function rmEndSlash($sString) {
if(substr($sString, -1) === "/") {
$sString = substr($sString, 0, -1);
}
return $sString;
}
function appendSlash($sString) {
if(substr($sString, -1) !== "/") {
$sString .= "/";
}
return $sString;
}
function prependSlash($sString) {
if(substr($sString, 0, 1) !== "/") {
$sString = "/" . $sString;
}
return $sString;
}
public static function bootstrap() {
# Asserting PHP 5.3.0+
if(version_compare(PHP_VERSION, '5.3.0', '<')) {
die('Flake Fatal Error: Flake requires PHP 5.3.0+ to run properly. Your version is: ' . PHP_VERSION . '.');
}
# Define absolute server path to Flake Framework
define("FLAKE_PATH_ROOT", PROJECT_PATH_ROOT . "Core/Frameworks/Flake/"); # ./
if(!defined('LF')) {
define('LF', chr(10));
}
if(!defined('CR')) {
define('CR', chr(13));
}
if(array_key_exists("SERVER_NAME", $_SERVER) && $_SERVER["SERVER_NAME"] === "mongoose") {
define("MONGOOSE_SERVER", TRUE);
} else {
define("MONGOOSE_SERVER", FALSE);
}
# Display errors messages, except notices
#ini_set("display_errors", 1);
#ini_set("error_reporting", E_ALL & ~E_NOTICE);
#################################################################################################
# determine Flake install root path
# not using realpath here to avoid symlinks resolution
define("PROJECT_PATH_CORE", PROJECT_PATH_ROOT . "Core/");
define("PROJECT_PATH_SPECIFIC", PROJECT_PATH_ROOT . "Specific/");
define("PROJECT_PATH_FRAMEWORKS", PROJECT_PATH_CORE . "Frameworks/");
define("PROJECT_PATH_WWWROOT", PROJECT_PATH_CORE . "WWWRoot/");
# Define path to Baïkal SQLite file
define("PROJECT_SQLITE_FILE", PROJECT_PATH_SPECIFIC . "db/baikal.sqlite");
define("PROJECT_SAFEHASH_SALT", "une-clef-super-secrete");
require_once(PROJECT_PATH_CORE . "Distrib.php");
# Determine PROJECT_URI
$sScript = substr($_SERVER["SCRIPT_FILENAME"], strlen($_SERVER["DOCUMENT_ROOT"]));
$sDirName = self::appendSlash(dirname($sScript));
$sBaseUrl = self::appendSlash(substr($sDirName, 0, -1 * strlen(PROJECT_CONTEXT_BASEURI)));
$aParts = explode("/", $_SERVER["SERVER_PROTOCOL"]);
$sProtocol = strtolower(array_shift($aParts));
define("PROJECT_BASEURI", $sBaseUrl);
define("PROJECT_URI", $sProtocol . "://" . self::rmEndSlash($_SERVER["HTTP_HOST"]) . $sBaseUrl);
unset($sScript); unset($sDirName); unset($sBaseUrl); unset($sProtocol); unset($aParts);
#################################################################################################
require_once(FLAKE_PATH_ROOT . 'Core/ClassLoader.php');
\Flake\Core\ClassLoader::register();
# Include Flake Framework config
require_once(FLAKE_PATH_ROOT . "config.php");
# Determine Router class
$GLOBALS["ROUTER"] = \Flake\Util\Tools::router();
if(!\Flake\Util\Tools::isCliPhp()) {
ini_set("html_errors", TRUE);
session_start();
}
setlocale(LC_ALL, FLAKE_LOCALE);
date_default_timezone_set(FLAKE_TIMEZONE);
if(defined("PROJECT_SQLITE_FILE") && file_exists(PROJECT_SQLITE_FILE) && is_readable(PROJECT_SQLITE_FILE) && !isset($GLOBALS["DB"])) {
$GLOBALS["DB"] = new \Flake\Core\Database\Sqlite(PROJECT_SQLITE_FILE);
}
$GLOBALS["TEMPLATESTACK"] = array();
$aUrlInfo = parse_url(PROJECT_URI);
define("FLAKE_DOMAIN", $_SERVER["HTTP_HOST"]);
define("FLAKE_URIPATH", \Flake\Util\Tools::stripBeginSlash($aUrlInfo["path"]));
unset($aUrlInfo);
}
}

19
CoreVersions/0.2.0/Frameworks/Flake/Util/Frameworks.php Normal file → Executable file
View file

@ -30,7 +30,26 @@ class Frameworks extends \Flake\Core\FLObject {
private function __construct() { # private constructor to force static class
}
public function isAFramework($sName) {
$sName = trim(\Flake\Util\Tools::trimSlashes($sName));
if($sName === "" || $sName === "." || $sName === "..") {
return FALSE;
}
$sFrameworkPath = PROJECT_PATH_FRAMEWORKS . $sName;
return file_exists($sFrameworkPath) && is_dir($sFrameworkPath);
}
public static function enabled($sFramework) {
return FALSE;
}
# TODO: Create a 'Framework' Model
public function getPath($sName) {
if(self::isAFramework($sName)) {
throw new \Flake\Core\Exception(htmlspecialchars($$sName) . " is not a framework.", $sName);
}
return \Flake\Util\Tools::appendSlash(PROJECT_PATH_FRAMEWORKS . $sName);
}
}

View file

@ -65,7 +65,7 @@ class Tools extends \Flake\Core\FLObject {
}
public static function serverToRelativeWebPath($sAbsPath) {
return "/" . str_replace(FLAKE_PATH_WWWROOT, "", $sAbsPath);
return "/" . str_replace(PROJECT_PATH_WWWROOT, "", $sAbsPath);
}
public static function view_array($array_in) {
@ -192,7 +192,7 @@ class Tools extends \Flake\Core\FLObject {
}
public static function safelock($sString) {
return substr(md5(FLAKE_SAFEHASH_SALT . ":" . $sString), 0, 5);
return substr(md5(PROJECT_SAFEHASH_SALT . ":" . $sString), 0, 5);
}
public static function redirect($sUrl) {
@ -568,42 +568,65 @@ TEST;
return $_SERVER['HTTP_USER_AGENT'];
}
###########
public static function appendSlash($sString) {
if(substr($sString, -1) !== "/") {
$sString .= "/";
}
return $sString;
return self::appendString($sString, "/");
}
public static function prependSlash($sString) {
if(substr($sString, 0, 1) !== "/") {
$sString = "/" . $sString;
}
return $sString;
return self::prependString($sString, "/");
}
public static function stripBeginSlash($sString) {
if(substr($sString, 0, 1) === "/") {
$sString = substr($sString, 1);
}
return $sString;
return self::stripBeginString($sString, "/");
}
public static function stripEndSlash($sString) {
if(substr($sString, -1) === "/") {
$sString = substr($sString, 0, -1);
}
return $sString;
return self::stripEndString($sString, "/");
}
public static function trimSlashes($sString) {
return self::stripBeginSlash(self::stripEndSlash($sString));
}
###########
public static function appendString($sString, $sAppend) {
if(substr($sString, -1 * strlen($sAppend)) !== $sAppend) {
$sString .= $sAppend;
}
return $sString;
}
public static function prependString($sString, $sAppend) {
if(substr($sString, 0, 1 * strlen($sAppend)) !== $sAppend) {
$sString = $sAppend . $sString;
}
return $sString;
}
public static function stripBeginString($sString, $sAppend) {
if(substr($sString, 0, 1 * strlen($sAppend)) === $sAppend) {
$sString = substr($sString, strlen($sAppend));
}
return $sString;
}
public static function stripEndString($sString, $sAppend) {
if(substr($sString, -1 * strlen($sAppend)) === $sAppend) {
$sString = substr($sString, 0, -1 * strlen($sAppend));
}
return $sString;
}
public static function trimStrings($sString, $sAppend) {
return self::stripBeginString(self::stripEndString($sString, $sAppend), $sAppend);
}
###########
public static function router() {
return "\Flake\Util\Router\QuestionMarkRewrite";
}

6
CoreVersions/0.2.0/Frameworks/Flake/config.php Normal file → Executable file
View file

@ -24,12 +24,6 @@
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
define("FLAKE_URI", BAIKAL_URI);
define("FLAKE_DB_FILEPATH", BAIKAL_SQLITE_FILE);
define("FLAKE_PATH_FRAMEWORKS", BAIKAL_PATH_FRAMEWORKS);
define("FLAKE_PATH_WWWROOT", BAIKAL_PATH_WWWROOT);
define("FLAKE_SAFEHASH_SALT", "une-clef-super-secrete");
define("FLAKE_LOCALE", "fr_FR.UTF-8");
if(defined("BAIKAL_TIMEZONE")) {

View file

0
CoreVersions/0.2.0/Frameworks/Formal/Core/Message.php Normal file → Executable file
View file

0
CoreVersions/0.2.0/Frameworks/Formal/Element.php Normal file → Executable file
View file

View file

View file

View file

0
CoreVersions/0.2.0/Frameworks/Formal/Element/Text.php Normal file → Executable file
View file

0
CoreVersions/0.2.0/Frameworks/Formal/Form.php Normal file → Executable file
View file

View file

View file

@ -0,0 +1,37 @@
<?php
/***************************************************************
* Copyright notice
*
* (c) 2012 Jérôme Schneider <mail@jeromeschneider.fr>
* All rights reserved
*
* http://baikal.codr.fr
*
* This script is part of the Baïkal Server project. The Baïkal
* Server project is free software; you can redistribute it
* and/or modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
namespace Formal;
class Framework extends \Flake\Core\Framework {
public static function bootstrap() {
define("FORMAL_PATH_ROOT", PROJECT_PATH_ROOT . "Core/Frameworks/Formal/");
require_once(FORMAL_PATH_ROOT . 'Core/ClassLoader.php');
\Formal\Core\ClassLoader::register();
}
}

View file

Some files were not shown because too many files have changed in this diff Show more