Working on Web Admin

Former-commit-id: af9727e1ff
This commit is contained in:
Jérôme Schneider 2012-04-23 23:52:23 +02:00
parent 7bf974bc9e
commit 46a3de7109
39 changed files with 1404 additions and 768 deletions

View file

@ -24,5 +24,5 @@
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
define("BAIKAL_VERSION", "0.2");
define("BAIKAL_VERSION", "0.2.0");
define("BAIKAL_HOMEPAGE", "http://baikal.codr.fr");

View file

@ -24,6 +24,49 @@
* 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 = prependSlash($sBaseUrl . "admin/install/");
header("Location: " . $sInstallToolUrl);
exit(0);
}
}
if(!defined("BAIKAL_CONTEXT") || BAIKAL_CONTEXT !== TRUE) {
die("Bootstrap.php may not be included outside the Baikal context");
}
@ -55,41 +98,58 @@ define("BAIKAL_PATH_SPECIFIC", BAIKAL_PATH_ROOT . "Specific/");
define("BAIKAL_PATH_FRAMEWORKS", BAIKAL_PATH_CORE . "Frameworks/");
define("BAIKAL_PATH_WWWROOT", BAIKAL_PATH_CORE . "WWWRoot/");
require_once(BAIKAL_PATH_SPECIFIC . "config.php");
require_once(BAIKAL_PATH_SPECIFIC . "config.system.php");
require_once(BAIKAL_PATH_CORE . "Distrib.php");
date_default_timezone_set(BAIKAL_TIMEZONE);
# Determine BAIKAL_URI
#print_r($_SERVER);
$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_URI", $sProtocol . "://" . rmEndSlash($_SERVER["HTTP_HOST"]) . $sBaseUrl);
unset($sScript); unset($sDirName); unset($sBaseUrl); unset($sProtocol); unset($aParts);
# Check if DB exists
if(!file_exists(BAIKAL_SQLITE_FILE)) {
die("DB file does not exist.<br />To create it, please copy '<b>Core/Resources/baikal.empty.sqlite</b>' to '<b>Specific/db/baikal.sqlite</b>'.<br /><span style='color: red; font-weight: bold'>Please note the change in the file name while doing so</span> (from 'baikal.empty.sqlite' to 'baikal.sqlite').");
}
# Database
$pdo = new PDO('sqlite:' . BAIKAL_SQLITE_FILE);
$pdo->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
$bShouldCheckEnv = ((!defined("BAIKAL_CONTEXT_CLI") || BAIKAL_CONTEXT_CLI === FALSE) && (!defined("BAIKAL_CONTEXT_ADMIN") || BAIKAL_CONTEXT_ADMIN === FALSE));
# Check if at least one user exists
if($bShouldCheckEnv === TRUE) {
if(($iNbUsers = intval($pdo->query('SELECT count(*) FROM users')->fetchColumn())) === 0) {
die("No users are defined.<br />To create a user, you can use the helper <b>Core/Scripts/adduser.php</b> (requires command line access)");
}
}
if($bShouldCheckEnv === TRUE) {
# Mapping PHP errors to exceptions
function exception_error_handler($errno, $errstr, $errfile, $errline) {
throw new ErrorException($errstr, 0, $errno, $errfile, $errline);
}
set_error_handler("exception_error_handler");
# Check that a config file exists
if(
!file_exists(BAIKAL_PATH_SPECIFIC . "config.php") ||
!file_exists(BAIKAL_PATH_SPECIFIC . "config.system.php")
) {
installTool();
} else {
error_reporting(E_ALL ^ E_NOTICE);
}
require_once(BAIKAL_PATH_SPECIFIC . "config.php");
require_once(BAIKAL_PATH_SPECIFIC . "config.system.php");
date_default_timezone_set(BAIKAL_TIMEZONE);
unset($bShouldCheckEnv);
// Autoloader
require_once(BAIKAL_PATH_SABREDAV . 'autoload.php');
if(version_compare(BAIKAL_VERSION, BAIKAL_CONFIGURED_VERSION) > 0) {
installTool();
} else {
# Check if DB exists
if(!file_exists(BAIKAL_SQLITE_FILE)) {
die("DB file does not exist.<br />To create it, please copy '<b>Core/Resources/baikal.empty.sqlite</b>' to '<b>Specific/db/baikal.sqlite</b>'.<br /><span style='color: red; font-weight: bold'>Please note the change in the file name while doing so</span> (from 'baikal.empty.sqlite' to 'baikal.sqlite').");
}
# Database
$pdo = new PDO('sqlite:' . BAIKAL_SQLITE_FILE);
$pdo->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
$bShouldCheckEnv = ((!defined("BAIKAL_CONTEXT_CLI") || BAIKAL_CONTEXT_CLI === FALSE) && (!defined("BAIKAL_CONTEXT_ADMIN") || BAIKAL_CONTEXT_ADMIN === FALSE));
if($bShouldCheckEnv === TRUE) {
# Mapping PHP errors to exceptions
function exception_error_handler($errno, $errstr, $errfile, $errline) {
throw new ErrorException($errstr, 0, $errno, $errfile, $errline);
}
set_error_handler("exception_error_handler");
} else {
error_reporting(E_ALL ^ E_NOTICE);
}
unset($bShouldCheckEnv);
// Autoloader
require_once(BAIKAL_PATH_SABREDAV . 'autoload.php');
}
}

View file

@ -46,7 +46,7 @@ class Tools {
return $aUsers;
}
static function bashPrompt($prompt) {
public static function bashPrompt($prompt) {
print $prompt;
@flush();
@ob_flush();
@ -54,7 +54,7 @@ class Tools {
return $confirmation;
}
static function bashPromptSilent($prompt = "Enter Password:") {
public static function bashPromptSilent($prompt = "Enter Password:") {
$command = "/usr/bin/env bash -c 'echo OK'";
if(rtrim(shell_exec($command)) !== 'OK') {
@ -70,4 +70,419 @@ class Tools {
echo "\n";
return $password;
}
public static function timezones() {
$aZones = array(
"Africa/Abidjan",
"Africa/Accra",
"Africa/Addis_Ababa",
"Africa/Algiers",
"Africa/Asmara",
"Africa/Bamako",
"Africa/Bangui",
"Africa/Banjul",
"Africa/Bissau",
"Africa/Blantyre",
"Africa/Brazzaville",
"Africa/Bujumbura",
"Africa/Cairo",
"Africa/Casablanca",
"Africa/Ceuta",
"Africa/Conakry",
"Africa/Dakar",
"Africa/Dar_es_Salaam",
"Africa/Djibouti",
"Africa/Douala",
"Africa/El_Aaiun",
"Africa/Freetown",
"Africa/Gaborone",
"Africa/Harare",
"Africa/Johannesburg",
"Africa/Juba",
"Africa/Kampala",
"Africa/Khartoum",
"Africa/Kigali",
"Africa/Kinshasa",
"Africa/Lagos",
"Africa/Libreville",
"Africa/Lome",
"Africa/Luanda",
"Africa/Lubumbashi",
"Africa/Lusaka",
"Africa/Malabo",
"Africa/Maputo",
"Africa/Maseru",
"Africa/Mbabane",
"Africa/Mogadishu",
"Africa/Monrovia",
"Africa/Nairobi",
"Africa/Ndjamena",
"Africa/Niamey",
"Africa/Nouakchott",
"Africa/Ouagadougou",
"Africa/Porto-Novo",
"Africa/Sao_Tome",
"Africa/Tripoli",
"Africa/Tunis",
"Africa/Windhoek",
"America/Adak",
"America/Anchorage",
"America/Anguilla",
"America/Antigua",
"America/Araguaina",
"America/Argentina/Buenos_Aires",
"America/Argentina/Catamarca",
"America/Argentina/Cordoba",
"America/Argentina/Jujuy",
"America/Argentina/La_Rioja",
"America/Argentina/Mendoza",
"America/Argentina/Rio_Gallegos",
"America/Argentina/Salta",
"America/Argentina/San_Juan",
"America/Argentina/San_Luis",
"America/Argentina/Tucuman",
"America/Argentina/Ushuaia",
"America/Aruba",
"America/Asuncion",
"America/Atikokan",
"America/Bahia",
"America/Barbados",
"America/Belem",
"America/Belize",
"America/Blanc-Sablon",
"America/Boa_Vista",
"America/Bogota",
"America/Boise",
"America/Cambridge_Bay",
"America/Campo_Grande",
"America/Cancun",
"America/Caracas",
"America/Cayenne",
"America/Cayman",
"America/Chicago",
"America/Chihuahua",
"America/Costa_Rica",
"America/Cuiaba",
"America/Curacao",
"America/Danmarkshavn",
"America/Dawson",
"America/Dawson_Creek",
"America/Denver",
"America/Detroit",
"America/Dominica",
"America/Edmonton",
"America/Eirunepe",
"America/El_Salvador",
"America/Felipe_Carrillo",
"America/Fortaleza",
"America/Glace_Bay",
"America/Godthab",
"America/Goose_Bay",
"America/Grand_Turk",
"America/Grenada",
"America/Guadeloupe",
"America/Guatemala",
"America/Guayaquil",
"America/Guyana",
"America/Halifax",
"America/Havana",
"America/Hermosillo",
"America/Indiana/Indianapolis",
"America/Indiana/Knox",
"America/Indiana/Marengo",
"America/Indiana/Petersburg",
"America/Indiana/Tell_City",
"America/Indiana/Vevay",
"America/Indiana/Vincennes",
"America/Indiana/Winamac",
"America/Inuvik",
"America/Iqaluit",
"America/Jamaica",
"America/Juneau",
"America/Kentucky/Louisville",
"America/Kentucky/Monticello",
"America/La_Paz",
"America/Lima",
"America/Los_Angeles",
"America/Maceio",
"America/Managua",
"America/Manaus",
"America/Marigot",
"America/Martinique",
"America/Matamoros",
"America/Mazatlan",
"America/Menominee",
"America/Merida",
"America/Mexico_City",
"America/Miquelon",
"America/Moncton",
"America/Monterrey",
"America/Montevideo",
"America/Montreal",
"America/Montserrat",
"America/Nassau",
"America/New_York",
"America/Nipigon",
"America/Nome",
"America/Noronha",
"America/North_Dakota/Center",
"America/North_Dakota/New_Salem",
"America/Ojinaga",
"America/Panama",
"America/Pangnirtung",
"America/Paramaribo",
"America/Phoenix",
"America/Port-au-Prince",
"America/Porto_Velho",
"America/Port_of_Spain",
"America/Puerto_Rico",
"America/Rainy_River",
"America/Rankin_Inlet",
"America/Recife",
"America/Regina",
"America/Resolute",
"America/Rio_Branco",
"America/Santarem",
"America/Santa_Isabel",
"America/Santiago",
"America/Santo_Domingo",
"America/Sao_Paulo",
"America/Scoresbysund",
"America/Shiprock",
"America/St_Barthelemy",
"America/St_Johns",
"America/St_Kitts",
"America/St_Lucia",
"America/St_Thomas",
"America/St_Vincent",
"America/Swift_Current",
"America/Tegucigalpa",
"America/Thule",
"America/Thunder_Bay",
"America/Tijuana",
"America/Toronto",
"America/Tortola",
"America/Vancouver",
"America/Whitehorse",
"America/Winnipeg",
"America/Yakutat",
"America/Yellowknife",
"Antarctica/Casey",
"Antarctica/Davis",
"Antarctica/DumontDUrville",
"Antarctica/Mawson",
"Antarctica/McMurdo",
"Antarctica/Palmer",
"Antarctica/Rothera",
"Antarctica/South_Pole",
"Antarctica/Syowa",
"Antarctica/Vostok",
"Arctic/Longyearbyen",
"Asia/Aden",
"Asia/Almaty",
"Asia/Amman",
"Asia/Anadyr",
"Asia/Aqtau",
"Asia/Aqtobe",
"Asia/Ashgabat",
"Asia/Baghdad",
"Asia/Bahrain",
"Asia/Baku",
"Asia/Bangkok",
"Asia/Beirut",
"Asia/Bishkek",
"Asia/Brunei",
"Asia/Choibalsan",
"Asia/Chongqing",
"Asia/Colombo",
"Asia/Damascus",
"Asia/Dhaka",
"Asia/Dili",
"Asia/Dubai",
"Asia/Dushanbe",
"Asia/Gaza",
"Asia/Harbin",
"Asia/Hong_Kong",
"Asia/Hovd",
"Asia/Ho_Chi_Minh",
"Asia/Irkutsk",
"Asia/Jakarta",
"Asia/Jayapura",
"Asia/Jerusalem",
"Asia/Kabul",
"Asia/Kamchatka",
"Asia/Karachi",
"Asia/Kashgar",
"Asia/Kathmandu",
"Asia/Kolkata",
"Asia/Krasnoyarsk",
"Asia/Kuala_Lumpur",
"Asia/Kuching",
"Asia/Kuwait",
"Asia/Macau",
"Asia/Magadan",
"Asia/Makassar",
"Asia/Manila",
"Asia/Muscat",
"Asia/Nicosia",
"Asia/Novokuznetsk",
"Asia/Novosibirsk",
"Asia/Omsk",
"Asia/Oral",
"Asia/Phnom_Penh",
"Asia/Pontianak",
"Asia/Pyongyang",
"Asia/Qatar",
"Asia/Qyzylorda",
"Asia/Rangoon",
"Asia/Riyadh",
"Asia/Sakhalin",
"Asia/Samarkand",
"Asia/Seoul",
"Asia/Shanghai",
"Asia/Singapore",
"Asia/Taipei",
"Asia/Tashkent",
"Asia/Tbilisi",
"Asia/Tehran",
"Asia/Thimphu",
"Asia/Tokyo",
"Asia/Ulaanbaatar",
"Asia/Urumqi",
"Asia/Vientiane",
"Asia/Vladivostok",
"Asia/Yakutsk",
"Asia/Yekaterinburg",
"Asia/Yerevan",
"Atlantic/Azores",
"Atlantic/Bermuda",
"Atlantic/Canary",
"Atlantic/Cape_Verde",
"Atlantic/Faroe",
"Atlantic/Madeira",
"Atlantic/Reykjavik",
"Atlantic/South_Georgia",
"Atlantic/Stanley",
"Atlantic/St_Helena",
"Australia/Adelaide",
"Australia/Brisbane",
"Australia/Broken_Hill",
"Australia/Currie",
"Australia/Darwin",
"Australia/Eucla",
"Australia/Hobart",
"Australia/Lindeman",
"Australia/Lord_Howe",
"Australia/Melbourne",
"Australia/Perth",
"Australia/Sydney",
"Europe/Amsterdam",
"Europe/Andorra",
"Europe/Athens",
"Europe/Belgrade",
"Europe/Berlin",
"Europe/Bratislava",
"Europe/Brussels",
"Europe/Bucharest",
"Europe/Budapest",
"Europe/Chisinau",
"Europe/Copenhagen",
"Europe/Dublin",
"Europe/Gibraltar",
"Europe/Guernsey",
"Europe/Helsinki",
"Europe/Isle_of_Man",
"Europe/Istanbul",
"Europe/Jersey",
"Europe/Kaliningrad",
"Europe/Kiev",
"Europe/Lisbon",
"Europe/Ljubljana",
"Europe/London",
"Europe/Luxembourg",
"Europe/Madrid",
"Europe/Malta",
"Europe/Mariehamn",
"Europe/Minsk",
"Europe/Monaco",
"Europe/Moscow",
"Europe/Oslo",
"Europe/Paris",
"Europe/Podgorica",
"Europe/Prague",
"Europe/Riga",
"Europe/Rome",
"Europe/Samara",
"Europe/San_Marino",
"Europe/Sarajevo",
"Europe/Simferopol",
"Europe/Skopje",
"Europe/Sofia",
"Europe/Stockholm",
"Europe/Tallinn",
"Europe/Tirane",
"Europe/Uzhgorod",
"Europe/Vaduz",
"Europe/Vatican",
"Europe/Vienna",
"Europe/Vilnius",
"Europe/Volgograd",
"Europe/Warsaw",
"Europe/Zagreb",
"Europe/Zaporozhye",
"Europe/Zurich",
"Indian/Antananarivo",
"Indian/Chagos",
"Indian/Christmas",
"Indian/Cocos",
"Indian/Comoro",
"Indian/Kerguelen",
"Indian/Mahe",
"Indian/Maldives",
"Indian/Mauritius",
"Indian/Mayotte",
"Indian/Reunion",
"Pacific/Apia",
"Pacific/Auckland",
"Pacific/Chatham",
"Pacific/Easter",
"Pacific/Efate",
"Pacific/Enderbury",
"Pacific/Fakaofo",
"Pacific/Fiji",
"Pacific/Funafuti",
"Pacific/Galapagos",
"Pacific/Gambier",
"Pacific/Guadalcanal",
"Pacific/Guam",
"Pacific/Honolulu",
"Pacific/Johnston",
"Pacific/Kiritimati",
"Pacific/Kosrae",
"Pacific/Kwajalein",
"Pacific/Majuro",
"Pacific/Marquesas",
"Pacific/Midway",
"Pacific/Nauru",
"Pacific/Niue",
"Pacific/Norfolk",
"Pacific/Noumea",
"Pacific/Pago_Pago",
"Pacific/Palau",
"Pacific/Pitcairn",
"Pacific/Ponape",
"Pacific/Port_Moresby",
"Pacific/Rarotonga",
"Pacific/Saipan",
"Pacific/Tahiti",
"Pacific/Tarawa",
"Pacific/Tongatapu",
"Pacific/Truk",
"Pacific/Wake",
"Pacific/Wallis",
);
reset($aZones);
return $aZones;
}
}

View file

@ -26,49 +26,12 @@
namespace Baikal\Model;
class Config extends \Flake\Core\Model\NoDb {
abstract class Config extends \Flake\Core\Model\NoDb {
protected $sConfigFilePath = "";
protected $aConstants = array(
"BAIKAL_TIMEZONE" => array(
"type" => "string",
),
# "BAIKAL_URI" => array(
# "type" => "string",
# ),
"BAIKAL_CARD_ENABLED" => array(
"type" => "boolean",
),
"BAIKAL_CAL_ENABLED" => array(
"type" => "boolean",
),
"BAIKAL_ADMIN_ENABLED" => array(
"type" => "boolean",
),
"BAIKAL_STANDALONE_ALLOWED" => array(
"type" => "boolean",
),
"BAIKAL_STANDALONE_PORT" => array(
"type" => "integer",
),
"BAIKAL_ADMIN_PASSWORDHASH" => array(
"type" => "string",
)
);
protected $aData = array(
"BAIKAL_TIMEZONE" => "",
"BAIKAL_CARD_ENABLED" => "",
"BAIKAL_CAL_ENABLED" => "",
"BAIKAL_TIMEZONE" => "",
"BAIKAL_CARD_ENABLED" => "",
"BAIKAL_CAL_ENABLED" => "",
"BAIKAL_ADMIN_ENABLED" => "",
"BAIKAL_STANDALONE_ALLOWED" => "",
"BAIKAL_STANDALONE_PORT" => "",
"BAIKAL_ADMIN_PASSWORDHASH" => ""
);
protected $aConstants = array();
protected $aData = array();
public function __construct($sConfigFilePath) {
# Note: no call to parent::__construct() to avoid erasing $this->aData
$this->sConfigFilePath = $sConfigFilePath;
@ -82,32 +45,32 @@ class Config extends \Flake\Core\Model\NoDb {
}
}
}
protected function getConfigAsString() {
$sContent = file_get_contents($this->sConfigFilePath);
return str_replace(LF . CR, LF, $sContent);
}
protected function parseConfig($sString) {
$aRes = array();
foreach(array_keys($this->aConstants) as $sConstant) {
$aConstant = $this->aConstants[$sConstant];
$aMatches = array();
$sPattern = '/\s*define\(\s*["|\']' . $sConstant . '["|\']\s*\,\s*(.*?)\s*\);\s*/ix';
$iNbRes = preg_match_all(
$sPattern,
$sString,
$aMatches
);
if($iNbRes === 1) {
# Exactly one match
# O would be not enough, and > 1, to much to handle properly
$sValue = $aMatches[1][0]; # first capture (.*?), first occurence (anyway, we asserted that there's only one)
switch($aConstant["type"]) {
case "string": {
@ -126,22 +89,26 @@ class Config extends \Flake\Core\Model\NoDb {
}
break;
}
case "litteral": {
$sValue = trim($sValue);
break;
}
default: {
# nothing
break;
}
}
$aRes[$sConstant] = $sValue;
} elseif($iNbRes === 0) {
throw new \Exception("Baikal\Model\Config->parseConfig(): Unable to find constant '" . $prop . "' in config file");
}
}
reset($aRes);
return $aRes;
}
public function writable() {
return (
@file_exists($this->sConfigFilePath) &&
@ -149,103 +116,37 @@ class Config extends \Flake\Core\Model\NoDb {
@is_writable($this->sConfigFilePath)
);
}
public function formMorphologyForThisModelInstance() {
$oMorpho = new \Formal\Form\Morphology();
$oMorpho->add(new \Formal\Element\Listbox(array(
"prop" => "BAIKAL_TIMEZONE",
"label" => "Time zone",
"validation" => "required",
"options" => self::timezones(),
"help" => "Time zone of the server",
"popover" => array(
"title" => "Time zone",
"content" => "Time zone of the server",
),
)));
$oMorpho->add(new \Formal\Element\Checkbox(array(
"prop" => "BAIKAL_CARD_ENABLED",
"label" => "Enable CardDAV"
)));
$oMorpho->add(new \Formal\Element\Checkbox(array(
"prop" => "BAIKAL_CAL_ENABLED",
"label" => "Enable CalDAV"
)));
$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 !",
),
)));
$oMorpho->add(new \Formal\Element\Checkbox(array(
"prop" => "BAIKAL_STANDALONE_ALLOWED",
"label" => "Allow Standalone Baïkal execution"
)));
$oMorpho->add(new \Formal\Element\Text(array(
"prop" => "BAIKAL_STANDALONE_PORT",
"label" => "Standalone Baïkal port"
)));
$sNotice = "-- Leave empty to keep current password --";
$oMorpho->add(new \Formal\Element\Password(array(
"prop" => "BAIKAL_ADMIN_PASSWORDHASH",
"label" => "Web admin password",
"placeholder" => $sNotice,
)));
$oMorpho->add(new \Formal\Element\Password(array(
"prop" => "BAIKAL_ADMIN_PASSWORDHASH_CONFIRM",
"label" => "Web admin password confirmation",
"placeholder" => $sNotice,
"validation" => "sameas:BAIKAL_ADMIN_PASSWORDHASH",
)));
return $oMorpho;
}
public static function icon() {
return "icon-cog";
}
public static function mediumicon() {
return "glyph-cogwheel";
}
public static function bigicon() {
return "glyph2x-cogwheel";
}
public function label() {
return "Baïkal Settings";
}
public function floating() {
return FALSE;
}
public function persist() {
$aLines = explode(LF, $this->getConfigAsString());
foreach(array_keys($this->aData) as $prop) {
$iLines = count($aLines);
$sPattern = '/\s*define\(\s*["|\']' . $prop . '["|\']\s*\,\s*(.*?)\s*\);\s*/ix';
for($k = ($iLines - 1); $k >= 0; $k--) {
if(preg_match($sPattern, $aLines[$k])) {
# Found the last matching line
$sValue = $this->aData[$prop];
$bCalculated = (isset($this->aConstants[$prop]["type"]["calculated"]) && $this->aConstants[$prop]["type"]["calculated"] === TRUE);
switch($this->aConstants[$prop]["type"]) {
case "string": {
$sValue = '"' . addcslashes($sValue, "\"\\\0\n\r") . '"'; # Add quotes, and escape " and all string-termination chars
@ -256,13 +157,17 @@ class Config extends \Flake\Core\Model\NoDb {
break;
}
case "boolean": {
if(intval($sValue) === 1) { # Note as a BOOLEAN PHP constant
$sValue = "TRUE";
} else {
$sValue = "FALSE";
}
break;
}
case "litteral": {
$sValue = trim($sValue);
break;
}
default: {
@ -270,14 +175,14 @@ class Config extends \Flake\Core\Model\NoDb {
break;
}
}
$aLines[$k] = "define(\"" . $prop . "\", " . $sValue . ");";
}
}
}
$sLines = implode("\n", $aLines);
$sSandboxedCode = str_replace(array("<?php", "<?", "?>"), "", $sLines);
$sRand = (string)rand();
$sCode = "if(0) {" . $sSandboxedCode . "}; echo '" . $sRand . "';";
@ -285,7 +190,7 @@ class Config extends \Flake\Core\Model\NoDb {
eval($sCode);
$sRes = ob_get_contents();
ob_end_clean();
if($sRes !== $sRand) {
throw new \Exception("Parse error in new config file. Aborting, nothing has been changed.");
}
@ -294,458 +199,18 @@ class Config extends \Flake\Core\Model\NoDb {
# We now check that all the constants are present, and with the right value
$aNewConfig = $this->parseConfig($sLines);
$aWrittenConfig = $this->aData;
asort($aNewConfig);
asort($aWrittenConfig);
if($aNewConfig != $aWrittenConfig) {
throw new \Exception("New config does not correspond to expected config. Aborting, nothing has been changed.");
}
file_put_contents($this->sConfigFilePath, $sLines);
}
public function set($sProp, $sValue) {
if($sProp === "BAIKAL_ADMIN_PASSWORDHASH" || $sProp === "BAIKAL_ADMIN_PASSWORDHASH_CONFIRM") {
# Special handling for password and passwordconfirm
if($sProp === "BAIKAL_ADMIN_PASSWORDHASH" && $sValue !== "") {
parent::set(
"BAIKAL_ADMIN_PASSWORDHASH",
\BaikalAdmin\Core\Auth::hashAdminPassword($sValue)
);
}
return $this;
}
parent::set($sProp, $sValue);
}
public function get($sProp) {
if($sProp === "BAIKAL_ADMIN_PASSWORDHASH" || $sProp === "BAIKAL_ADMIN_PASSWORDHASH_CONFIRM") {
return "";
}
return parent::get($sProp);
}
public function destroy() {
}
protected static function timezones() {
$aZones = array(
"Africa/Abidjan",
"Africa/Accra",
"Africa/Addis_Ababa",
"Africa/Algiers",
"Africa/Asmara",
"Africa/Bamako",
"Africa/Bangui",
"Africa/Banjul",
"Africa/Bissau",
"Africa/Blantyre",
"Africa/Brazzaville",
"Africa/Bujumbura",
"Africa/Cairo",
"Africa/Casablanca",
"Africa/Ceuta",
"Africa/Conakry",
"Africa/Dakar",
"Africa/Dar_es_Salaam",
"Africa/Djibouti",
"Africa/Douala",
"Africa/El_Aaiun",
"Africa/Freetown",
"Africa/Gaborone",
"Africa/Harare",
"Africa/Johannesburg",
"Africa/Juba",
"Africa/Kampala",
"Africa/Khartoum",
"Africa/Kigali",
"Africa/Kinshasa",
"Africa/Lagos",
"Africa/Libreville",
"Africa/Lome",
"Africa/Luanda",
"Africa/Lubumbashi",
"Africa/Lusaka",
"Africa/Malabo",
"Africa/Maputo",
"Africa/Maseru",
"Africa/Mbabane",
"Africa/Mogadishu",
"Africa/Monrovia",
"Africa/Nairobi",
"Africa/Ndjamena",
"Africa/Niamey",
"Africa/Nouakchott",
"Africa/Ouagadougou",
"Africa/Porto-Novo",
"Africa/Sao_Tome",
"Africa/Tripoli",
"Africa/Tunis",
"Africa/Windhoek",
"America/Adak",
"America/Anchorage",
"America/Anguilla",
"America/Antigua",
"America/Araguaina",
"America/Argentina/Buenos_Aires",
"America/Argentina/Catamarca",
"America/Argentina/Cordoba",
"America/Argentina/Jujuy",
"America/Argentina/La_Rioja",
"America/Argentina/Mendoza",
"America/Argentina/Rio_Gallegos",
"America/Argentina/Salta",
"America/Argentina/San_Juan",
"America/Argentina/San_Luis",
"America/Argentina/Tucuman",
"America/Argentina/Ushuaia",
"America/Aruba",
"America/Asuncion",
"America/Atikokan",
"America/Bahia",
"America/Barbados",
"America/Belem",
"America/Belize",
"America/Blanc-Sablon",
"America/Boa_Vista",
"America/Bogota",
"America/Boise",
"America/Cambridge_Bay",
"America/Campo_Grande",
"America/Cancun",
"America/Caracas",
"America/Cayenne",
"America/Cayman",
"America/Chicago",
"America/Chihuahua",
"America/Costa_Rica",
"America/Cuiaba",
"America/Curacao",
"America/Danmarkshavn",
"America/Dawson",
"America/Dawson_Creek",
"America/Denver",
"America/Detroit",
"America/Dominica",
"America/Edmonton",
"America/Eirunepe",
"America/El_Salvador",
"America/Felipe_Carrillo",
"America/Fortaleza",
"America/Glace_Bay",
"America/Godthab",
"America/Goose_Bay",
"America/Grand_Turk",
"America/Grenada",
"America/Guadeloupe",
"America/Guatemala",
"America/Guayaquil",
"America/Guyana",
"America/Halifax",
"America/Havana",
"America/Hermosillo",
"America/Indiana/Indianapolis",
"America/Indiana/Knox",
"America/Indiana/Marengo",
"America/Indiana/Petersburg",
"America/Indiana/Tell_City",
"America/Indiana/Vevay",
"America/Indiana/Vincennes",
"America/Indiana/Winamac",
"America/Inuvik",
"America/Iqaluit",
"America/Jamaica",
"America/Juneau",
"America/Kentucky/Louisville",
"America/Kentucky/Monticello",
"America/La_Paz",
"America/Lima",
"America/Los_Angeles",
"America/Maceio",
"America/Managua",
"America/Manaus",
"America/Marigot",
"America/Martinique",
"America/Matamoros",
"America/Mazatlan",
"America/Menominee",
"America/Merida",
"America/Mexico_City",
"America/Miquelon",
"America/Moncton",
"America/Monterrey",
"America/Montevideo",
"America/Montreal",
"America/Montserrat",
"America/Nassau",
"America/New_York",
"America/Nipigon",
"America/Nome",
"America/Noronha",
"America/North_Dakota/Center",
"America/North_Dakota/New_Salem",
"America/Ojinaga",
"America/Panama",
"America/Pangnirtung",
"America/Paramaribo",
"America/Phoenix",
"America/Port-au-Prince",
"America/Porto_Velho",
"America/Port_of_Spain",
"America/Puerto_Rico",
"America/Rainy_River",
"America/Rankin_Inlet",
"America/Recife",
"America/Regina",
"America/Resolute",
"America/Rio_Branco",
"America/Santarem",
"America/Santa_Isabel",
"America/Santiago",
"America/Santo_Domingo",
"America/Sao_Paulo",
"America/Scoresbysund",
"America/Shiprock",
"America/St_Barthelemy",
"America/St_Johns",
"America/St_Kitts",
"America/St_Lucia",
"America/St_Thomas",
"America/St_Vincent",
"America/Swift_Current",
"America/Tegucigalpa",
"America/Thule",
"America/Thunder_Bay",
"America/Tijuana",
"America/Toronto",
"America/Tortola",
"America/Vancouver",
"America/Whitehorse",
"America/Winnipeg",
"America/Yakutat",
"America/Yellowknife",
"Antarctica/Casey",
"Antarctica/Davis",
"Antarctica/DumontDUrville",
"Antarctica/Mawson",
"Antarctica/McMurdo",
"Antarctica/Palmer",
"Antarctica/Rothera",
"Antarctica/South_Pole",
"Antarctica/Syowa",
"Antarctica/Vostok",
"Arctic/Longyearbyen",
"Asia/Aden",
"Asia/Almaty",
"Asia/Amman",
"Asia/Anadyr",
"Asia/Aqtau",
"Asia/Aqtobe",
"Asia/Ashgabat",
"Asia/Baghdad",
"Asia/Bahrain",
"Asia/Baku",
"Asia/Bangkok",
"Asia/Beirut",
"Asia/Bishkek",
"Asia/Brunei",
"Asia/Choibalsan",
"Asia/Chongqing",
"Asia/Colombo",
"Asia/Damascus",
"Asia/Dhaka",
"Asia/Dili",
"Asia/Dubai",
"Asia/Dushanbe",
"Asia/Gaza",
"Asia/Harbin",
"Asia/Hong_Kong",
"Asia/Hovd",
"Asia/Ho_Chi_Minh",
"Asia/Irkutsk",
"Asia/Jakarta",
"Asia/Jayapura",
"Asia/Jerusalem",
"Asia/Kabul",
"Asia/Kamchatka",
"Asia/Karachi",
"Asia/Kashgar",
"Asia/Kathmandu",
"Asia/Kolkata",
"Asia/Krasnoyarsk",
"Asia/Kuala_Lumpur",
"Asia/Kuching",
"Asia/Kuwait",
"Asia/Macau",
"Asia/Magadan",
"Asia/Makassar",
"Asia/Manila",
"Asia/Muscat",
"Asia/Nicosia",
"Asia/Novokuznetsk",
"Asia/Novosibirsk",
"Asia/Omsk",
"Asia/Oral",
"Asia/Phnom_Penh",
"Asia/Pontianak",
"Asia/Pyongyang",
"Asia/Qatar",
"Asia/Qyzylorda",
"Asia/Rangoon",
"Asia/Riyadh",
"Asia/Sakhalin",
"Asia/Samarkand",
"Asia/Seoul",
"Asia/Shanghai",
"Asia/Singapore",
"Asia/Taipei",
"Asia/Tashkent",
"Asia/Tbilisi",
"Asia/Tehran",
"Asia/Thimphu",
"Asia/Tokyo",
"Asia/Ulaanbaatar",
"Asia/Urumqi",
"Asia/Vientiane",
"Asia/Vladivostok",
"Asia/Yakutsk",
"Asia/Yekaterinburg",
"Asia/Yerevan",
"Atlantic/Azores",
"Atlantic/Bermuda",
"Atlantic/Canary",
"Atlantic/Cape_Verde",
"Atlantic/Faroe",
"Atlantic/Madeira",
"Atlantic/Reykjavik",
"Atlantic/South_Georgia",
"Atlantic/Stanley",
"Atlantic/St_Helena",
"Australia/Adelaide",
"Australia/Brisbane",
"Australia/Broken_Hill",
"Australia/Currie",
"Australia/Darwin",
"Australia/Eucla",
"Australia/Hobart",
"Australia/Lindeman",
"Australia/Lord_Howe",
"Australia/Melbourne",
"Australia/Perth",
"Australia/Sydney",
"Europe/Amsterdam",
"Europe/Andorra",
"Europe/Athens",
"Europe/Belgrade",
"Europe/Berlin",
"Europe/Bratislava",
"Europe/Brussels",
"Europe/Bucharest",
"Europe/Budapest",
"Europe/Chisinau",
"Europe/Copenhagen",
"Europe/Dublin",
"Europe/Gibraltar",
"Europe/Guernsey",
"Europe/Helsinki",
"Europe/Isle_of_Man",
"Europe/Istanbul",
"Europe/Jersey",
"Europe/Kaliningrad",
"Europe/Kiev",
"Europe/Lisbon",
"Europe/Ljubljana",
"Europe/London",
"Europe/Luxembourg",
"Europe/Madrid",
"Europe/Malta",
"Europe/Mariehamn",
"Europe/Minsk",
"Europe/Monaco",
"Europe/Moscow",
"Europe/Oslo",
"Europe/Paris",
"Europe/Podgorica",
"Europe/Prague",
"Europe/Riga",
"Europe/Rome",
"Europe/Samara",
"Europe/San_Marino",
"Europe/Sarajevo",
"Europe/Simferopol",
"Europe/Skopje",
"Europe/Sofia",
"Europe/Stockholm",
"Europe/Tallinn",
"Europe/Tirane",
"Europe/Uzhgorod",
"Europe/Vaduz",
"Europe/Vatican",
"Europe/Vienna",
"Europe/Vilnius",
"Europe/Volgograd",
"Europe/Warsaw",
"Europe/Zagreb",
"Europe/Zaporozhye",
"Europe/Zurich",
"Indian/Antananarivo",
"Indian/Chagos",
"Indian/Christmas",
"Indian/Cocos",
"Indian/Comoro",
"Indian/Kerguelen",
"Indian/Mahe",
"Indian/Maldives",
"Indian/Mauritius",
"Indian/Mayotte",
"Indian/Reunion",
"Pacific/Apia",
"Pacific/Auckland",
"Pacific/Chatham",
"Pacific/Easter",
"Pacific/Efate",
"Pacific/Enderbury",
"Pacific/Fakaofo",
"Pacific/Fiji",
"Pacific/Funafuti",
"Pacific/Galapagos",
"Pacific/Gambier",
"Pacific/Guadalcanal",
"Pacific/Guam",
"Pacific/Honolulu",
"Pacific/Johnston",
"Pacific/Kiritimati",
"Pacific/Kosrae",
"Pacific/Kwajalein",
"Pacific/Majuro",
"Pacific/Marquesas",
"Pacific/Midway",
"Pacific/Nauru",
"Pacific/Niue",
"Pacific/Norfolk",
"Pacific/Noumea",
"Pacific/Pago_Pago",
"Pacific/Palau",
"Pacific/Pitcairn",
"Pacific/Ponape",
"Pacific/Port_Moresby",
"Pacific/Rarotonga",
"Pacific/Saipan",
"Pacific/Tahiti",
"Pacific/Tarawa",
"Pacific/Tongatapu",
"Pacific/Truk",
"Pacific/Wake",
"Pacific/Wallis",
);
reset($aZones);
return $aZones;
}
}

View file

@ -0,0 +1,154 @@
<?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\Model\Config;
class Standard extends \Baikal\Model\Config {
protected $aConstants = array(
"BAIKAL_TIMEZONE" => array(
"type" => "string",
),
"BAIKAL_CARD_ENABLED" => array(
"type" => "boolean",
),
"BAIKAL_CAL_ENABLED" => array(
"type" => "boolean",
),
"BAIKAL_ADMIN_ENABLED" => array(
"type" => "boolean",
),
"BAIKAL_STANDALONE_ALLOWED" => array(
"type" => "boolean",
),
"BAIKAL_STANDALONE_PORT" => array(
"type" => "integer",
),
"BAIKAL_ADMIN_PASSWORDHASH" => array(
"type" => "string",
)
);
protected $aData = array(
"BAIKAL_TIMEZONE" => "",
"BAIKAL_CARD_ENABLED" => "",
"BAIKAL_CAL_ENABLED" => "",
"BAIKAL_TIMEZONE" => "",
"BAIKAL_CARD_ENABLED" => "",
"BAIKAL_CAL_ENABLED" => "",
"BAIKAL_ADMIN_ENABLED" => "",
"BAIKAL_STANDALONE_ALLOWED" => "",
"BAIKAL_STANDALONE_PORT" => "",
"BAIKAL_ADMIN_PASSWORDHASH" => ""
);
public function formMorphologyForThisModelInstance() {
$oMorpho = new \Formal\Form\Morphology();
$oMorpho->add(new \Formal\Element\Listbox(array(
"prop" => "BAIKAL_TIMEZONE",
"label" => "Time zone",
"validation" => "required",
"options" => \Baikal\Core\Tools::timezones(),
"help" => "Time zone of the server"
)));
$oMorpho->add(new \Formal\Element\Checkbox(array(
"prop" => "BAIKAL_CARD_ENABLED",
"label" => "Enable CardDAV"
)));
$oMorpho->add(new \Formal\Element\Checkbox(array(
"prop" => "BAIKAL_CAL_ENABLED",
"label" => "Enable CalDAV"
)));
$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 !",
),
)));
$oMorpho->add(new \Formal\Element\Checkbox(array(
"prop" => "BAIKAL_STANDALONE_ALLOWED",
"label" => "Allow Standalone Baïkal execution"
)));
$oMorpho->add(new \Formal\Element\Text(array(
"prop" => "BAIKAL_STANDALONE_PORT",
"label" => "Standalone Baïkal port"
)));
$sNotice = "-- Leave empty to keep current password --";
$oMorpho->add(new \Formal\Element\Password(array(
"prop" => "BAIKAL_ADMIN_PASSWORDHASH",
"label" => "Web admin password",
"placeholder" => $sNotice,
)));
$oMorpho->add(new \Formal\Element\Password(array(
"prop" => "BAIKAL_ADMIN_PASSWORDHASH_CONFIRM",
"label" => "Web admin password confirmation",
"placeholder" => $sNotice,
"validation" => "sameas:BAIKAL_ADMIN_PASSWORDHASH",
)));
return $oMorpho;
}
public function label() {
return "Baïkal Settings";
}
public function set($sProp, $sValue) {
if($sProp === "BAIKAL_ADMIN_PASSWORDHASH" || $sProp === "BAIKAL_ADMIN_PASSWORDHASH_CONFIRM") {
# Special handling for password and passwordconfirm
if($sProp === "BAIKAL_ADMIN_PASSWORDHASH" && $sValue !== "") {
parent::set(
"BAIKAL_ADMIN_PASSWORDHASH",
\BaikalAdmin\Core\Auth::hashAdminPassword($sValue)
);
}
return $this;
}
parent::set($sProp, $sValue);
}
public function get($sProp) {
if($sProp === "BAIKAL_ADMIN_PASSWORDHASH" || $sProp === "BAIKAL_ADMIN_PASSWORDHASH_CONFIRM") {
return "";
}
return parent::get($sProp);
}
}

View file

@ -0,0 +1,120 @@
<?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\Model\Config;
class System extends \Baikal\Model\Config {
protected $aConstants = array(
"BAIKAL_PATH_SABREDAV" => array(
"type" => "litteral",
),
"BAIKAL_AUTH_REALM" => array(
"type" => "string",
),
"BAIKAL_CARD_BASEURI" => array(
"type" => "string",
),
"BAIKAL_CAL_BASEURI" => array(
"type" => "string",
),
"BAIKAL_SQLITE_FILE" => array(
"type" => "litteral",
),
);
protected $aData = array(
"BAIKAL_PATH_SABREDAV" => "",
"BAIKAL_AUTH_REALM" => "",
"BAIKAL_CARD_BASEURI" => "",
"BAIKAL_CAL_BASEURI" => "",
"BAIKAL_SQLITE_FILE" => "",
);
public function formMorphologyForThisModelInstance() {
$oMorpho = new \Formal\Form\Morphology();
$oMorpho->add(new \Formal\Element\Text(array(
"prop" => "BAIKAL_CAL_BASEURI",
"label" => "CalDAV base URI",
"validation" => "required",
"help" => "The absolute web path to cal.php",
"popover" => array(
"title" => "CalDAV base URI",
"content" => "If Baïkal is hosted in a subfolder, this path should reflect it.<br /><strong>Whatever happens, it should begin and end with a slash.</strong>",
)
)));
$oMorpho->add(new \Formal\Element\Text(array(
"prop" => "BAIKAL_CARD_BASEURI",
"label" => "CardDAV base URI",
"validation" => "required",
"help" => "The absolute web path to card.php",
"popover" => array(
"title" => "CardDAV base URI",
"content" => "If Baïkal is hosted in a subfolder, this path should reflect it.<br /><strong>Whatever happens, it should begin and end with a slash.</strong>"
)
)));
$oMorpho->add(new \Formal\Element\Text(array(
"prop" => "BAIKAL_PATH_SABREDAV",
"label" => "Path to SabreDAV",
"validation" => "required",
"inputclass" => "input-xxlarge",
"help" => "The absolute server path to SabreDAV API",
"popover" => array(
"title" => "Path to SabreDAV",
"content" => "If Baïkal is hosted in a subfolder, this path should reflect it.<br /><strong>Whatever happens, it should begin and end with a slash.</strong>",
"position" => "top"
)
)));
$oMorpho->add(new \Formal\Element\Text(array(
"prop" => "BAIKAL_SQLITE_FILE",
"label" => "Path to SQLite DB",
"inputclass" => "input-xxlarge",
"validation" => "required",
"help" => "The absolute server path to SQLite database."
)));
$oMorpho->add(new \Formal\Element\Text(array(
"prop" => "BAIKAL_AUTH_REALM",
"label" => "Auth realm",
"validation" => "required",
"help" => "Token used in authentication process.<br />If you change this, you'll have to reset all your users passwords.<br />You'll also loose access to this admin interface.",
"popover" => array(
"title" => "Auth realm",
"content" => "If you change this, you'll loose your access to this interface.<br />In other words: <strong>you should not change this, unless YKWYD.</strong>"
)
)));
return $oMorpho;
}
public function label() {
return "Baïkal Settings";
}
}

View file

@ -27,11 +27,82 @@
namespace BaikalAdmin\Controller;
class Install 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 render() {
return "<h2>Install</h2>";
# Determine in which case we are
# A- Baïkal is not configured yet; new installation
# B- Baïkal is configured, but maintenance tasks have to be achieved; upgrade
if(defined("BAIKAL_CONFIGURED_VERSION")) {
# we have to upgrade Baïkal (existing installation)
$sHtml = $this->render_upgradeInstall();
} else {
# we have to initialize Baïkal (new installation)
$sHtml = $this->render_newInstall();
}
return $sHtml;
}
protected function render_newInstall() {
$sBigIcon = \BaikalAdmin\Model\Install::bigicon();
$sBaikalVersion = BAIKAL_VERSION;
$sHtml = <<<HTML
<header class="jumbotron subhead" id="overview">
<h1><i class="{$sBigIcon}"></i>Baïkal initialization (version {$sBaikalVersion})</h1>
<p class="lead">Configure your new Baïkal installation.</p>
</header>
HTML;
$sHtml .= $this->oForm->render();
return $sHtml;
}
protected function render_upgradeInstall() {
$sBigIcon = \BaikalAdmin\Model\Install::bigicon();
$sBaikalVersion = BAIKAL_VERSION;
$sBaikalConfiguredVersion = BAIKAL_CONFIGURED_VERSION;
$sHtml = <<<HTML
<header class="jumbotron subhead" id="overview">
<h1><i class="{$sBigIcon}"></i>Baïkal upgrade wizard</h1>
<p class="lead">Upgrading Baïkal from version <strong>{$sBaikalConfiguredVersion}</strong> to version <strong>{$sBaikalVersion}</strong>.</p>
</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

@ -26,7 +26,7 @@
namespace BaikalAdmin\Controller\Navigation;
class Bar extends \Flake\Core\Controller {
class Topbar extends \Flake\Core\Controller {
public function execute() {
}
@ -34,12 +34,13 @@ class Bar extends \Flake\Core\Controller {
public function render() {
$sCurrentRoute = $GLOBALS["ROUTER"]::getCurrentRoute();
$sActiveHome = $sActiveUsers = $sActiveSettings = "";
$sActiveHome = $sActiveUsers = $sActiveSettings = $sActiveSystemSettings = "";
$sControllerForDefaultRoute = $GLOBALS["ROUTER"]::getControllerForRoute("default");
$sHomeLink = $sControllerForDefaultRoute::link();
$sUsersLink = \BaikalAdmin\Controller\Users::link();
$sSettingsLink = \BaikalAdmin\Controller\Settings::link();
$sSettingsStandardLink = \BaikalAdmin\Controller\Settings\Standard::link();
$sSettingsSystemLink = \BaikalAdmin\Controller\Settings\System::link();
if($sCurrentRoute === "default") {
$sActiveHome = "active";
@ -52,8 +53,12 @@ class Bar extends \Flake\Core\Controller {
$sActiveUsers = "active";
}
if($sCurrentRoute === $GLOBALS["ROUTER"]::getRouteForController("\BaikalAdmin\Controller\Settings")) {
$sActiveSettings = "active";
if($sCurrentRoute === $GLOBALS["ROUTER"]::getRouteForController("\BaikalAdmin\Controller\Settings\Standard")) {
$sActiveSettingsStandard = "active";
}
if($sCurrentRoute === $GLOBALS["ROUTER"]::getRouteForController("\BaikalAdmin\Controller\Settings\System")) {
$sActiveSettingsSystem = "active";
}
$sHtml =<<<HTML
@ -65,12 +70,13 @@ class Bar extends \Flake\Core\Controller {
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
<a class="brand" href="{$sHomeLink}">Baïkal Admin !!!!!</a>
<a class="brand" href="{$sHomeLink}">Baïkal Web Admin</a>
<div class="nav-collapse">
<ul class="nav">
<li class="{$sActiveHome}"> <a href="{$sHomeLink}">Home</a></li>
<li class="{$sActiveUsers}"> <a href="{$sUsersLink}">Users and resources</a></li>
<li class="{$sActiveSettings}"> <a href="{$sSettingsLink}">Settings</a></li>
<li class="{$sActiveSettingsStandard}"> <a href="{$sSettingsStandardLink}">Settings</a></li>
<li class="{$sActiveSettingsSystem}"> <a href="{$sSettingsSystemLink}">System settings</a></li>
</ul>
</div><!--/.nav-collapse -->
</div>

View file

@ -0,0 +1,47 @@
<?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 Install extends \Flake\Core\Controller {
public function execute() {
}
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;
}
}

View file

@ -24,13 +24,13 @@
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
namespace BaikalAdmin\Controller;
namespace BaikalAdmin\Controller\Settings;
class Settings extends \Flake\Core\Controller {
class Standard extends \Flake\Core\Controller {
public function __construct() {
parent::__construct();
$this->oModel = new \Baikal\Model\Config(BAIKAL_PATH_SPECIFIC . "config.php");
$this->oModel = new \Baikal\Model\Config\Standard(BAIKAL_PATH_SPECIFIC . "config.php");
# Assert that config file is writable
if(!$this->oModel->writable()) {

View file

@ -0,0 +1,59 @@
<?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\Settings;
class System extends \Flake\Core\Controller {
public function __construct() {
parent::__construct();
$this->oModel = new \Baikal\Model\Config\System(BAIKAL_PATH_SPECIFIC . "config.system.php");
# Assert that config file is writable
if(!$this->oModel->writable()) {
throw new \Exception("System config file is not writable;" . __FILE__ . " > " . __LINE__);
}
$this->oForm = $this->oModel->formForThisModelInstance(array(
"close" => FALSE
));
}
public function execute() {
if($this->oForm->submitted()) {
$this->oForm->execute();
}
}
public function render() {
$sMessage = \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();
}
}

View file

@ -31,7 +31,11 @@ class Auth {
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>");
}
self::assertUnlocked();
}
static function assertUnlocked() {
$bLocked = TRUE;
$sEnableFile = BAIKAL_PATH_SPECIFIC . "ENABLE_ADMIN";
if(file_exists($sEnableFile)) {
@ -39,11 +43,14 @@ class Auth {
clearstatcache();
$iTime = intval(filemtime($sEnableFile));
if((time() - $iTime) < 3600) {
// file has been created more than an hour ago
// delete and declare locked
# file has been created/updated less than an hour ago; update it's mtime
if(is_writable($sEnableFile)) {
@touch($sEnableFile);
}
$bLocked = FALSE;
} else {
// file has been created more than an hour ago
// delete and declare locked
if(!@unlink($sEnableFile)) {
die("<h1>Ba&iuml;kal Admin is locked.</h1>To unlock it, delete and re-create an empty file named ENABLE_ADMIN in <b>Specific/config.php</b>");
}
@ -52,9 +59,6 @@ class Auth {
if($bLocked) {
die("<h1>Ba&iuml;kal Admin is locked.</h1>To unlock it, create an empty file named ENABLE_ADMIN in <b>Specific/</b>");
} else {
// update filemtime
@touch($sEnableFile);
}
}

View file

@ -0,0 +1,75 @@
<?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

@ -1,14 +1,3 @@
<style type="text/css">
.no-border-left { border-left: none !important;}
.col-displayname { width: 20%;}
.col-description { width: 55%;}
.col-actions { width: 25%;}
p.lead { line-height: 40px;}
table p {
margin-bottom: 0;
}
</style>
<header class="jumbotron subhead" id="overview">
<h1><i class="<?= \Baikal\Model\AddressBook::bigicon() ?>"></i>Address Books</h1>
<p class="lead">Manage Address Books for<i class="<?= $user->mediumicon() ?>"></i><strong><?= $user->label() ?></strong>.</p>
@ -16,7 +5,7 @@
<p class="pull-right"><a class="btn btn btn-inverse" href="<?= \BaikalAdmin\Controller\User\AddressBooks::linkNew() ?>"><i class="icon-white <?= \Baikal\Model\Calendar::icon() ?>"></i> + Add address book</a></p>
</header>
<table class="table table-bordered table-striped">
<table class="table table-bordered table-striped addressbooks">
<thead>
<tr>
<th>Display name</th>

View file

@ -1,14 +1,3 @@
<style type="text/css">
.no-border-left { border-left: none !important;}
.col-displayname { width: 20%;}
.col-description { width: 55%;}
.col-actions { width: 25%;}
p.lead { line-height: 40px;}
table p {
margin-bottom: 0;
}
</style>
<header class="jumbotron subhead" id="overview">
<h1><i class="<?= \Baikal\Model\Calendar::bigicon() ?>"></i>Calendars</h1>
<p class="lead">Manage Calendars for<i class="<?= $user->mediumicon() ?>"></i><strong><?= $user->label() ?></strong>.</p>
@ -16,7 +5,7 @@
<p class="pull-right"><a class="btn btn btn-inverse" href="<?= \BaikalAdmin\Controller\User\Calendars::linkNew() ?>"><i class="icon-white <?= \Baikal\Model\Calendar::icon() ?>"></i> + Add calendar</a></p>
</header>
<table class="table table-bordered table-striped">
<table class="table table-bordered table-striped calendars">
<thead>
<tr>
<th>Display name</th>

View file

@ -8,9 +8,9 @@
<!-- Le styles -->
<link href="res/core/TwitterBootstrap/css/bootstrap.css" rel="stylesheet" />
<link href="res/core/BaikalAdmin/Templates/Page/style.css" rel="stylesheet" />
<link href="res/core/BaikalAdmin/GlyphiconsPro/glyphpro.css" rel="stylesheet" />
<link href="res/core/BaikalAdmin/GlyphiconsPro/glyphpro-2x.css" rel="stylesheet" />
<link href="res/core/BaikalAdmin/Templates/Page/style.css" rel="stylesheet" />
<link href="res/core/TwitterBootstrap/css/bootstrap-responsive.css" rel="stylesheet" />
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
@ -25,20 +25,7 @@
<div class="container">
{Payload}
</div> <!-- /container -->
<!--a rel="tooltip" title="first tooltip">hello</a>
<a class="popover" title="first popover" data-content="hello&lt;br&gt;World">hello</a-->
<div class="mq0"></div>
<div class="mq1"></div>
<div class="mq2"></div>
<div class="mq3"></div>
<div class="mq4"></div>
<div class="mq5"></div>
<div class="mq6"></div>
<div class="mq7"></div>
<div class="mq8"></div>
<div class="mq9"></div>
<!-- Le javascript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
@ -52,6 +39,14 @@
$(".popover-focus").popover({
trigger: 'focus'
});
$(".popover-focus-top").popover({
trigger: 'focus',
placement: 'top'
});
$(".popover-focus-bottom").popover({
trigger: 'focus',
placement: 'bottom'
});
</script>
{javascript}
</body>

View file

@ -1,6 +1,7 @@
/* generics */
body {
padding-top: 60px; /* 60px to make the container go all the way to the bottom of the topbar */
/* background: url('page-bg.png') repeat center top;*/
}
.table thead th {
@ -12,13 +13,21 @@ body {
background-color: rgb(240, 240, 240);
}
table .no-border-left { border-left: none !important;}
table p {
margin-bottom: 0;
}
p.lead { line-height: 40px;}
/* Jumbotrons
-------------------------------------------------- */
.jumbotron {
position: relative;
}
.jumbotron h1 {
font-size: 70px;
font-size: 40px;
font-weight: bold;
letter-spacing: -1px;
line-height: 90px;
@ -38,4 +47,37 @@ body {
}
.jumbotron .btn-large small {
font-size: 14px;
}
}
@media (max-width: 550px) {
.jumbotron h1 {
font-size: 20px;
font-weight: bold;
letter-spacing: -1px;
line-height: 20px;
}
p.lead {
font-size: 14px;
line-height: 14px;
}
[class^="glyph2x-"],
[class*=" glyph2x-"] {
display: none;
}
}
/* Address books */
table.addressbooks .col-displayname { width: 20%;}
table.addressbooks .col-description { width: 55%;}
table.addressbooks .col-actions { width: 25%;}
/* Calendars */
table.calendars .col-displayname { width: 20%;}
table.calendars .col-description { width: 55%;}
table.calendars .col-actions { width: 25%;}
/* Users */
table.users .col-id { width: 2%;}
table.users .col-username { width: 45%;}

View file

@ -1,20 +1,10 @@
<style type="text/css">
.col-id { width: 2%;}
.col-username { width: 45%;}
.no-border-left { border-left: none !important;}
p.lead { line-height: 40px;}
table p {
margin-bottom: 0;
}
</style>
<header class="jumbotron subhead" id="overview">
<h1><i class="glyph2x-group"></i>Users</h1>
<p class="lead pull-left">Manage Baïkal user accounts, and associated resources.</p>
<p class="lead pull-right"><a class="btn btn btn-inverse" href="<?= \BaikalAdmin\Controller\Users::linkNew() ?>"><i class="icon-white <?= \Baikal\Model\User::icon() ?>"></i> + Add user</a></p>
</header>
<table class="table table-bordered table-striped">
<table class="table table-bordered table-striped users">
<?
foreach($users as $user):

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\Settings;
class Standard {
public static function execute(\Flake\Core\Render\Container &$oRenderContainer) {
$oRenderContainer->zone("Payload")->addBlock(new \BaikalAdmin\Controller\Settings\Standard());
}
}

View file

@ -24,11 +24,11 @@
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
namespace BaikalAdmin\Route;
namespace BaikalAdmin\Route\Settings;
class Settings {
class System {
public static function execute(\Flake\Core\Render\Container &$oRenderContainer) {
$oRenderContainer->zone("Payload")->addBlock(new \BaikalAdmin\Controller\Settings());
$oRenderContainer->zone("Payload")->addBlock(new \BaikalAdmin\Controller\Settings\System());
}
}

View file

@ -26,12 +26,13 @@
ini_set("display_errors", 1);
error_reporting(E_ALL);
define("BAIKAL_CONTEXT_BASEURI", "/admin/");
define("BAIKAL_CONTEXT", TRUE);
define("BAIKAL_CONTEXT_ADMIN", TRUE);
# Bootstrap BaikalAdmin
require_once(dirname(__FILE__) . "/Core/Bootstrap.php");
require_once(dirname(dirname(__FILE__)) . "/Core/Bootstrap.php"); # ../
# Evaluate assertions
\BaikalAdmin\Core\Auth::assertEnabled();
@ -43,7 +44,7 @@ $oPage->injectHTTPHeaders();
$oPage->setTitle("Baïkal Web Admin");
$oPage->setBaseUrl(BAIKAL_URI);
$oPage->zone("navbar")->addBlock(new \BaikalAdmin\Controller\Navigation\Bar());
$oPage->zone("navbar")->addBlock(new \BaikalAdmin\Controller\Navigation\Topbar());
# Route the request
$GLOBALS["ROUTER"]::route($oPage);

View file

@ -0,0 +1,52 @@
<?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!
***************************************************************/
ini_set("display_errors", 1);
error_reporting(E_ALL);
define("BAIKAL_CONTEXT_BASEURI", "/admin/install/");
define("BAIKAL_CONTEXT", TRUE);
define("BAIKAL_CONTEXT_INSTALL", TRUE);
# Bootstrap BaikalAdmin
require_once(dirname(dirname(dirname(__FILE__))) . "/Core/Bootstrap.php"); # ../../
# Evaluate assertions
\BaikalAdmin\Core\Auth::assertUnlocked();
# Create and setup a page object
$oPage = new \Flake\Controller\Page(BAIKALADMIN_PATH_TEMPLATES . "Page/index.html");
$oPage->injectHTTPHeaders();
$oPage->setTitle("Baïkal Install Tool");
$oPage->setBaseUrl(BAIKAL_URI);
$oPage->zone("navbar")->addBlock(new \BaikalAdmin\Controller\Navigation\Topbar\Install());
$oPage->zone("Payload")->addBlock(new \BaikalAdmin\Controller\Install());
# Route the request
//$GLOBALS["ROUTER"]::route($oPage);
# Render the page
echo $oPage->render();

View file

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

View file

@ -25,16 +25,20 @@
# This copyright notice MUST APPEAR in all copies of the script!
#################################################################
UNCONFIGURED_PORT=8888
PATH_SCRIPTFILE=`readlink -f $0`
PATH_SCRIPTDIR=`dirname $PATH_SCRIPTFILE`"/"
PATH_ROOT=`dirname $(dirname $(dirname $(dirname $PATH_SCRIPTDIR)))`"/" # ../../../../
PATH_DOCROOT=$PATH_ROOT"html/"
PATH_CORE=$PATH_ROOT"Core/"
PATH_FRAMEWORKS=$PATH_Core"Frameworks/"
PATH_DISTRIBFILE=$PATH_CORE"Distrib.php"
PATH_SPECIFIC=$PATH_ROOT"Specific/"
PATH_CONFIGFILE=$PATH_SPECIFIC"config.php"
PATH_CONFIGSYSTEMFILE=$PATH_SPECIFIC"config.system.php"
MONGOOSE_BUILDS=$PATH_SCRIPTDIR"builds/"
MONGOOSE_CGI=$PATH_SCRIPTDIR"cgi/"
@ -59,30 +63,79 @@ function whichBINDIST() {
}
function getBaikalConf() {
local CONF=$(php -r "require_once('$PATH_DISTRIBFILE'); require_once('$PATH_CONFIGFILE'); if(!defined(\"$1\")) { echo null; exit;} if(is_bool($1)) { echo intval($1); exit;} else { echo $1; exit;}")
local CONF=$(php -r "define('BAIKAL_PATH_FRAMEWORKS', '$PATH_FRAMEWORKS'); define('BAIKAL_PATH_SPECIFIC', '$PATH_SPECIFIC'); require_once('$PATH_CONFIGFILE'); require_once('$PATH_CONFIGSYSTEMFILE'); if(!defined(\"$1\")) { echo null; exit;} if(is_bool($1)) { echo intval($1); exit;} else { echo $1; exit;}")
echo "$CONF"
}
BAIKAL_VERSION=$(getBaikalConf BAIKAL_VERSION)
function getBaikalDistribVar() {
local CONF=$(php -r "require_once('$PATH_DISTRIBFILE'); if(!defined(\"$1\")) { echo null; exit;} if(is_bool($1)) { echo intval($1); exit;} else { echo $1; exit;}")
echo "$CONF"
}
BAIKAL_STANDALONE_ALLOWED=$(getBaikalConf BAIKAL_STANDALONE_ALLOWED)
if [[ "$BAIKAL_STANDALONE_ALLOWED" == '0' ]]; then
echo "Baïkal Standalone Server is disallowed by config."
echo "To allow it, please set BAIKAL_STANDALONE_ALLOWED to TRUE in $PATH_ROOTSpecific/config.php"
echo "-- Aborting; Baïkal Standalone Server is not running --"
exit 1
fi
BAIKAL_ADMIN_PASSWORDHASH=$(getBaikalConf BAIKAL_ADMIN_PASSWORDHASH)
if [[ "$BAIKAL_ADMIN_PASSWORDHASH" == "" ]]; then
echo "You need to define a password for the 'admin' user."
echo "To define it, please use the given script Core/Scripts/adminpassword.php"
echo "-- Aborting; Baïkal Standalone Server is not running --"
exit 1
function compareVersions() {
local VERSION_CORE=$1
local VERSION_CONFIGURED=$2
local VERSION_DIFF=$(php -r "echo version_compare('$VERSION_CORE', '$VERSION_CONFIGURED');")
echo "$VERSION_DIFF"
}
function needsInstall() {
local CONFIGURED=$(fileExists $PATH_CONFIGFILE)
local SYSTEMCONFIGURED=$(fileExists $PATH_CONFIGSYSTEMFILE)
if [[ $CONFIGURED == 1 && $SYSTEMCONFIGURED == 1 ]]; then
local BAIKAL_VERSION=$(getBaikalDistribVar BAIKAL_VERSION)
local BAIKAL_CONFIGURED_VERSION=$(getBaikalConf BAIKAL_CONFIGURED_VERSION)
if [[ $(compareVersions $BAIKAL_VERSION $BAIKAL_CONFIGURED_VERSION) -gt 0 ]]; then
echo 2
else
echo 0
fi
else
echo 1
fi
}
function fileExists() {
if ls "$1" > /dev/null 2>&1; then
echo 1;
else
echo 0;
fi
}
NEEDSINSTALL=$(needsInstall)
if [[ "$NEEDSINSTALL" != "0" ]]; then
echo "Baïkal needs configuration. Bootstrapping install mode."
BAIKAL_STANDALONE_PORT=$UNCONFIGURED_PORT
else
BAIKAL_STANDALONE_ALLOWED=$(getBaikalConf BAIKAL_STANDALONE_ALLOWED)
if [[ "$BAIKAL_STANDALONE_ALLOWED" == '0' ]]; then
echo "Baïkal Standalone Server is disallowed by config."
echo "To allow it, please set BAIKAL_STANDALONE_ALLOWED to TRUE in $PATH_ROOTSpecific/config.php"
echo "-- Aborting; Baïkal Standalone Server is not running --"
exit 1
fi
BAIKAL_ADMIN_PASSWORDHASH=$(getBaikalConf BAIKAL_ADMIN_PASSWORDHASH)
if [[ "$BAIKAL_ADMIN_PASSWORDHASH" == "" ]]; then
echo "You need to define a password for the 'admin' user."
echo "To define it, please use the given script Core/Scripts/adminpassword.php"
echo "-- Aborting; Baïkal Standalone Server is not running --"
exit 1
fi
BAIKAL_STANDALONE_PORT=$(getBaikalConf BAIKAL_STANDALONE_PORT)
fi
BAIKAL_VERSION=$(getBaikalDistribVar BAIKAL_VERSION)
MONGOOSE_BINDIST=$(whichBINDIST)
BAIKAL_STANDALONE_PORT=$(getBaikalConf BAIKAL_STANDALONE_PORT)
if [[ "$BAIKAL_STANDALONE_PORT" == "" ]]; then
echo "No port number is defined for Baïkal Standalone Server to listen on."

View file

@ -77,18 +77,14 @@ if(!\Flake\Util\Tools::isCliPhp()) {
setlocale(LC_ALL, FLAKE_LOCALE);
date_default_timezone_set(FLAKE_TIMEZONE);
$GLOBALS["DB"] = new \Flake\Core\Database\Sqlite();
$GLOBALS["DB"]->init(FLAKE_DB_FILEPATH);
if(defined("FLAKE_DB_FILEPATH") && file_exists(FLAKE_DB_FILEPATH) && is_readable(FLAKE_DB_FILEPATH)) {
$GLOBALS["DB"] = new \Flake\Core\Database\Sqlite();
$GLOBALS["DB"]->init(FLAKE_DB_FILEPATH);
}
$GLOBALS["TEMPLATESTACK"] = array();
# Determining baikal protocol, domain and uri-path (looking at BAIKAL_URI)
if($GLOBALS["_SERVER"]["SERVER_NAME"] === "mongoose") { # And not using MONGOOSE_SERVER constant, as it will be defined by Flake, later in the process
define("FLAKE_DOMAIN", "");
define("FLAKE_URIPATH", "");
} else {
$aUrlInfo = parse_url(BAIKAL_URI);
define("FLAKE_DOMAIN", $aUrlInfo["host"]);
define("FLAKE_URIPATH", \Flake\Util\Tools::stripBeginSlash($aUrlInfo["path"]));
unset($aUrlInfo);
}
$aUrlInfo = parse_url(FLAKE_URI);
define("FLAKE_DOMAIN", $_SERVER["HTTP_HOST"]);
define("FLAKE_URIPATH", \Flake\Util\Tools::stripBeginSlash($aUrlInfo["path"]));
unset($aUrlInfo);

View file

@ -28,7 +28,9 @@ namespace Flake\Core\Model;
abstract class NoDb extends \Flake\Core\Model {
public function __construct($aData = array()) {
$this->aData = $aData;
public function __construct($aData = FALSE) {
if($aData !== FALSE) {
$this->aData = $aData;
}
}
}

View file

@ -24,6 +24,7 @@
* 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_TIMEZONE", BAIKAL_TIMEZONE);
define("FLAKE_PATH_FRAMEWORKS", BAIKAL_PATH_FRAMEWORKS);

View file

@ -30,20 +30,35 @@ class Message {
private function __construct() {
}
public static function error($sMessage) {
public static function error($sMessage, $sTitle = "") {
if($sTitle !== "") {
$sTitle = '<h3 class="alert-heading">' . $sTitle . '</h3>';
}
$sHtml =<<<HTML
<div id="message" class="alert alert-block alert-error">
<h3 class="alert-heading">Validation error</h3>
{$sTitle}
{$sMessage}
</div>
HTML;
return $sHtml;
}
public static function notice($sMessage) {
public static function notice($sMessage, $sTitle = "", $bClose = TRUE) {
$sClose = "";
if($sTitle !== "") {
$sTitle = '<h3 class="alert-heading">' . $sTitle . '</h3>';
}
if($bClose === TRUE) {
$sClose = '<a class="close" data-dismiss="alert" href="#">&times;</a>';
}
$sHtml =<<<HTML
<div id="message" class="alert alert-info">
<a class="close" data-dismiss="alert" href="#">&times;</a>
{$sClose}
{$sTitle}
{$sMessage}
</div>
HTML;

View file

@ -29,6 +29,8 @@ namespace Formal;
abstract class Element {
protected $aOptions = array(
"class" => "",
"inputclass" => "input-xlarge",
"readonly" => FALSE,
"validation" => "",
"error" => FALSE,

View file

@ -54,6 +54,14 @@ class Text extends \Formal\Element {
$groupclass .= " error";
}
if(trim($this->option("class")) !== "") {
$groupclass .= " " . $this->option("class");
}
if(trim($this->option("inputclass")) !== "") {
$inputclass = $this->option("inputclass");
}
if(($sPlaceHolder = trim($this->option("placeholder"))) !== "") {
$placeholder = " placeholder=\"" . htmlspecialchars($sPlaceHolder) . "\" ";
}
@ -67,7 +75,14 @@ class Text extends \Formal\Element {
}
if(($aPopover = $this->option("popover")) !== "") {
$inputclass .= " popover-focus ";
if(array_key_exists("position", $aPopover)) {
$sPosition = $aPopover["position"];
$inputclass .= " popover-focus-" . $sPosition;
} else {
$inputclass .= " popover-focus ";
}
$popover = " title=\"" . htmlspecialchars($aPopover["title"]) . "\" ";
$popover .= " data-content=\"" . htmlspecialchars($aPopover["content"]) . "\" ";
}
@ -76,7 +91,7 @@ class Text extends \Formal\Element {
<div class="control-group{$groupclass}">
<label class="control-label" for="{$prop}">{$label}</label>
<div class="controls">
<input type="{$sInputType}" class="input-xlarge{$inputclass}" id="{$prop}" name="{$prop}" value="{$clientvalue}"{$disabled}{$placeholder}{$popover}/>
<input type="{$sInputType}" class="{$inputclass}" id="{$prop}" name="{$prop}" value="{$clientvalue}"{$disabled}{$placeholder}{$popover}/>
{$helpblock}
</div>
</div>

View file

@ -187,7 +187,9 @@ class Form {
} else {
$bWasFloating = FALSE;
$this->sDisplayMessage = \Formal\Core\Message::notice(
"Changes on <i class='" . $this->modelInstance()->icon() . "'></i> <strong>" . $this->modelInstance()->label() . "</strong> have been saved."
"Changes on <i class='" . $this->modelInstance()->icon() . "'></i> <strong>" . $this->modelInstance()->label() . "</strong> have been saved.",
FALSE, # No title
FALSE # No close button
);
}
@ -316,8 +318,9 @@ class Form {
}
$this->sDisplayMessage = \Formal\Core\Message::error(
implode("<br />", $aMessages)
);
implode("<br />", $aMessages),
"Validation error"
);
}
}

View file

@ -59,9 +59,6 @@
display: none;
}
@media (max-width: 767px) {
.mq0:after {
content: "(max-width: 767px)" !important;
}
.visible-phone {
display: block;
}
@ -76,9 +73,6 @@
}
}
@media (min-width: 768px) and (max-width: 979px) {
.mq1:after {
content: "(min-width: 768px) and (max-width: 979px)" !important;
}
.visible-tablet {
display: block;
}
@ -93,9 +87,6 @@
}
}
@media (max-width: 480px) {
.mq2:after {
content: "(max-width: 480px)" !important;
}
.nav-collapse {
-webkit-transform: translate3d(0, 0, 0);
}
@ -143,17 +134,14 @@
}
}
@media (max-width: 767px) {
.mq3:after {
content: "(max-width: 767px)" !important;
}
body {
padding-left: 20px;
padding-right: 20px;
}
.navbar-fixed-top {
/* .navbar-fixed-top {
margin-left: -20px;
margin-right: -20px;
}
}*/
.container {
width: auto;
}
@ -195,9 +183,6 @@
}
}
@media (min-width: 768px) and (max-width: 979px) {
.mq4:after {
content: "(min-width: 768px) and (max-width: 979px)" !important;
}
.row {
margin-left: -20px;
*zoom: 1;
@ -388,13 +373,14 @@
width: 32px;
}
}
@media (max-width: 979px) {
.mq5:after {
content: "max-width: 979px" !important;
}
@media (max-width: 550px) {
body {
padding-top: 0;
}
.navbar-fixed-top {
margin-left: -20px;
margin-right: -20px;
}
.navbar-fixed-top {
position: static;
margin-bottom: 18px;
@ -500,18 +486,12 @@
}
}
@media (min-width: 980px) {
.mq6:after {
content: "min-width: 980px" !important;
}
.nav-collapse.collapse {
height: auto !important;
overflow: visible !important;
}
}
@media (min-width: 1200px) {
.mq7:after {
content: "min-width: 1200px" !important;
}
.row {
margin-left: -30px;
*zoom: 1;

View file

@ -25,6 +25,7 @@
***************************************************************/
define("BAIKAL_CONTEXT", TRUE);
define("BAIKAL_CONTEXT_BASEURI", "/");
# Bootstraping Baikal
require_once(dirname(dirname(__FILE__)) . "/Frameworks/Baikal/Core/Bootstrap.php");

View file

@ -25,6 +25,7 @@
***************************************************************/
define("BAIKAL_CONTEXT", TRUE);
define("BAIKAL_CONTEXT_BASEURI", "/");
# Bootstraping Baikal
require_once(dirname(dirname(__FILE__)) . "/Frameworks/Baikal/Core/Bootstrap.php");

View file

@ -23,6 +23,12 @@
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
define("BAIKAL_CONTEXT", TRUE);
define("BAIKAL_CONTEXT_BASEURI", "/");
# Bootstraping Baikal
require_once(dirname(dirname(__FILE__)) . "/Frameworks/Baikal/Core/Bootstrap.php");
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">

View file

@ -32,15 +32,6 @@
# Timezone of your users, if unsure, check http://en.wikipedia.org/wiki/List_of_tz_database_time_zones
define("BAIKAL_TIMEZONE", "Europe/Paris");
# Absolute Baïkal URI; end with slash; includes protocol (http:// or https://), port (optional) and subfolders if any
if(array_key_exists("SERVER_NAME", $_SERVER) && $_SERVER["SERVER_NAME"] === "mongoose") {
define("BAIKAL_URI", "/");
} elseif(array_key_exists("HTTP_HOST", $_SERVER) && $_SERVER["HTTP_HOST"] === "subbaikal.jeromeschneider.fr") {
define("BAIKAL_URI", "http://subbaikal.jeromeschneider.fr/html/");
} else {
define("BAIKAL_URI", "http://baikal.jeromeschneider.fr/");
}
##############################################################################
# In this section: Optional configuration: you *may* customize these settings
#

Binary file not shown.

View file

@ -1 +1 @@
../../Core/Frameworks/BaikalAdmin/index.php
../../Core/Frameworks/BaikalAdmin/WWWRoot/index.php

View file

@ -0,0 +1 @@
../../../Core/Frameworks/BaikalAdmin/WWWRoot/install/index.php