diff --git a/CoreVersions/Baikal_0.1/Distrib.php b/CoreVersions/Baikal_0.1/Distrib.php index 0d47c38..01cc894 100755 --- a/CoreVersions/Baikal_0.1/Distrib.php +++ b/CoreVersions/Baikal_0.1/Distrib.php @@ -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"); \ No newline at end of file diff --git a/CoreVersions/Baikal_0.1/Frameworks/Baikal/Core/Bootstrap.php b/CoreVersions/Baikal_0.1/Frameworks/Baikal/Core/Bootstrap.php index cb16195..76408a9 100644 --- a/CoreVersions/Baikal_0.1/Frameworks/Baikal/Core/Bootstrap.php +++ b/CoreVersions/Baikal_0.1/Frameworks/Baikal/Core/Bootstrap.php @@ -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.
To create it, please copy 'Core/Resources/baikal.empty.sqlite' to 'Specific/db/baikal.sqlite'.
Please note the change in the file name while doing so (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.
To create a user, you can use the helper Core/Scripts/adduser.php (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.
To create it, please copy 'Core/Resources/baikal.empty.sqlite' to 'Specific/db/baikal.sqlite'.
Please note the change in the file name while doing so (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'); + } +} \ No newline at end of file diff --git a/CoreVersions/Baikal_0.1/Frameworks/Baikal/Core/Tools.php b/CoreVersions/Baikal_0.1/Frameworks/Baikal/Core/Tools.php index 14067c4..9fa1f56 100644 --- a/CoreVersions/Baikal_0.1/Frameworks/Baikal/Core/Tools.php +++ b/CoreVersions/Baikal_0.1/Frameworks/Baikal/Core/Tools.php @@ -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; + } } \ No newline at end of file diff --git a/CoreVersions/Baikal_0.1/Frameworks/Baikal/Model/Config.php b/CoreVersions/Baikal_0.1/Frameworks/Baikal/Model/Config.php index 362f8bc..3d6629c 100644 --- a/CoreVersions/Baikal_0.1/Frameworks/Baikal/Model/Config.php +++ b/CoreVersions/Baikal_0.1/Frameworks/Baikal/Model/Config.php @@ -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(""), "", $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; + } } \ No newline at end of file diff --git a/CoreVersions/Baikal_0.1/Frameworks/Baikal/Model/Config/Standard.php b/CoreVersions/Baikal_0.1/Frameworks/Baikal/Model/Config/Standard.php new file mode 100644 index 0000000..0e6b405 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Baikal/Model/Config/Standard.php @@ -0,0 +1,154 @@ + +* 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); + } +} \ No newline at end of file diff --git a/CoreVersions/Baikal_0.1/Frameworks/Baikal/Model/Config/System.php b/CoreVersions/Baikal_0.1/Frameworks/Baikal/Model/Config/System.php new file mode 100644 index 0000000..ce3a5b8 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Baikal/Model/Config/System.php @@ -0,0 +1,120 @@ + +* 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.
Whatever happens, it should begin and end with a slash.", + ) + ))); + + $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.
Whatever happens, it should begin and end with a slash." + ) + ))); + + $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.
Whatever happens, it should begin and end with a slash.", + "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.
If you change this, you'll have to reset all your users passwords.
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.
In other words: you should not change this, unless YKWYD." + ) + ))); + + return $oMorpho; + } + + public function label() { + return "Baïkal Settings"; + } +} \ No newline at end of file diff --git a/CoreVersions/Baikal_0.1/Frameworks/BaikalAdmin/Controller/Install.php b/CoreVersions/Baikal_0.1/Frameworks/BaikalAdmin/Controller/Install.php index 1ef7809..550a671 100644 --- a/CoreVersions/Baikal_0.1/Frameworks/BaikalAdmin/Controller/Install.php +++ b/CoreVersions/Baikal_0.1/Frameworks/BaikalAdmin/Controller/Install.php @@ -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 "

Install

"; + + # 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 = << +

Baïkal initialization (version {$sBaikalVersion})

+

Configure your new Baïkal installation.

+ +HTML; + + $sHtml .= $this->oForm->render(); + + return $sHtml; + } + + protected function render_upgradeInstall() { + $sBigIcon = \BaikalAdmin\Model\Install::bigicon(); + $sBaikalVersion = BAIKAL_VERSION; + $sBaikalConfiguredVersion = BAIKAL_CONFIGURED_VERSION; + + $sHtml = << +

Baïkal upgrade wizard

+

Upgrading Baïkal from version {$sBaikalConfiguredVersion} to version {$sBaikalVersion}.

+ +HTML; + +/* $sHtml .= <<What is this ? +

+ This is the Baïkal Install Tool.
+ It's displayed because you just installed or upgraded your Baïkal installation.
+ Baïkal requires some maintenance in order to ensure everything works as expected. +

+HTML; +*/ + return $sHtml; } } \ No newline at end of file diff --git a/CoreVersions/Baikal_0.1/Frameworks/BaikalAdmin/Controller/Navigation/Bar.php b/CoreVersions/Baikal_0.1/Frameworks/BaikalAdmin/Controller/Navigation/Topbar.php similarity index 75% rename from CoreVersions/Baikal_0.1/Frameworks/BaikalAdmin/Controller/Navigation/Bar.php rename to CoreVersions/Baikal_0.1/Frameworks/BaikalAdmin/Controller/Navigation/Topbar.php index 7447fbd..47b4534 100644 --- a/CoreVersions/Baikal_0.1/Frameworks/BaikalAdmin/Controller/Navigation/Bar.php +++ b/CoreVersions/Baikal_0.1/Frameworks/BaikalAdmin/Controller/Navigation/Topbar.php @@ -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 =<< - Baïkal Admin !!!!! + Baïkal Web Admin diff --git a/CoreVersions/Baikal_0.1/Frameworks/BaikalAdmin/Controller/Navigation/Topbar/Install.php b/CoreVersions/Baikal_0.1/Frameworks/BaikalAdmin/Controller/Navigation/Topbar/Install.php new file mode 100644 index 0000000..0e25499 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/BaikalAdmin/Controller/Navigation/Topbar/Install.php @@ -0,0 +1,47 @@ + +* 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; + return $sHtml; + } +} \ No newline at end of file diff --git a/CoreVersions/Baikal_0.1/Frameworks/BaikalAdmin/Controller/Settings.php b/CoreVersions/Baikal_0.1/Frameworks/BaikalAdmin/Controller/Settings/Standard.php similarity index 89% rename from CoreVersions/Baikal_0.1/Frameworks/BaikalAdmin/Controller/Settings.php rename to CoreVersions/Baikal_0.1/Frameworks/BaikalAdmin/Controller/Settings/Standard.php index d588b7b..d9c2dbc 100644 --- a/CoreVersions/Baikal_0.1/Frameworks/BaikalAdmin/Controller/Settings.php +++ b/CoreVersions/Baikal_0.1/Frameworks/BaikalAdmin/Controller/Settings/Standard.php @@ -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()) { diff --git a/CoreVersions/Baikal_0.1/Frameworks/BaikalAdmin/Controller/Settings/System.php b/CoreVersions/Baikal_0.1/Frameworks/BaikalAdmin/Controller/Settings/System.php new file mode 100644 index 0000000..8063a90 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/BaikalAdmin/Controller/Settings/System.php @@ -0,0 +1,59 @@ + +* 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.
You might break Baïkal if you misconfigure something here.", + "Warning !", + FALSE + ); + return $sMessage . $this->oForm->render(); + } +} \ No newline at end of file diff --git a/CoreVersions/Baikal_0.1/Frameworks/BaikalAdmin/Core/Auth.php b/CoreVersions/Baikal_0.1/Frameworks/BaikalAdmin/Core/Auth.php index 876a317..5fa1221 100644 --- a/CoreVersions/Baikal_0.1/Frameworks/BaikalAdmin/Core/Auth.php +++ b/CoreVersions/Baikal_0.1/Frameworks/BaikalAdmin/Core/Auth.php @@ -31,7 +31,11 @@ class Auth { if(!defined("BAIKAL_ADMIN_ENABLED") || BAIKAL_ADMIN_ENABLED !== TRUE) { die("

Baïkal Admin is disabled.

To enable it, set BAIKAL_ADMIN_ENABLED to TRUE in Specific/config.php"); } - + + 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("

Baïkal Admin is locked.

To unlock it, delete and re-create an empty file named ENABLE_ADMIN in Specific/config.php"); } @@ -52,9 +59,6 @@ class Auth { if($bLocked) { die("

Baïkal Admin is locked.

To unlock it, create an empty file named ENABLE_ADMIN in Specific/"); - } else { - // update filemtime - @touch($sEnableFile); } } diff --git a/CoreVersions/Baikal_0.1/Frameworks/BaikalAdmin/Model/Install.php b/CoreVersions/Baikal_0.1/Frameworks/BaikalAdmin/Model/Install.php new file mode 100644 index 0000000..61429b3 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/BaikalAdmin/Model/Install.php @@ -0,0 +1,75 @@ + +* 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"; + } +} \ No newline at end of file diff --git a/CoreVersions/Baikal_0.1/Frameworks/BaikalAdmin/Resources/Templates/AddressBooks/Listing.html b/CoreVersions/Baikal_0.1/Frameworks/BaikalAdmin/Resources/Templates/AddressBooks/Listing.html index 66eba68..d346217 100644 --- a/CoreVersions/Baikal_0.1/Frameworks/BaikalAdmin/Resources/Templates/AddressBooks/Listing.html +++ b/CoreVersions/Baikal_0.1/Frameworks/BaikalAdmin/Resources/Templates/AddressBooks/Listing.html @@ -1,14 +1,3 @@ - -

Address Books

Manage Address Books forlabel() ?>.

@@ -16,7 +5,7 @@

+ Add address book

- +
diff --git a/CoreVersions/Baikal_0.1/Frameworks/BaikalAdmin/Resources/Templates/Calendars/Listing.html b/CoreVersions/Baikal_0.1/Frameworks/BaikalAdmin/Resources/Templates/Calendars/Listing.html index 15617dc..a8603bb 100644 --- a/CoreVersions/Baikal_0.1/Frameworks/BaikalAdmin/Resources/Templates/Calendars/Listing.html +++ b/CoreVersions/Baikal_0.1/Frameworks/BaikalAdmin/Resources/Templates/Calendars/Listing.html @@ -1,14 +1,3 @@ - -

Calendars

Manage Calendars forlabel() ?>.

@@ -16,7 +5,7 @@

+ Add calendar

-
Display name
+
diff --git a/CoreVersions/Baikal_0.1/Frameworks/BaikalAdmin/Resources/Templates/Page/index.html b/CoreVersions/Baikal_0.1/Frameworks/BaikalAdmin/Resources/Templates/Page/index.html index 76c90da..1b7d01b 100644 --- a/CoreVersions/Baikal_0.1/Frameworks/BaikalAdmin/Resources/Templates/Page/index.html +++ b/CoreVersions/Baikal_0.1/Frameworks/BaikalAdmin/Resources/Templates/Page/index.html @@ -8,9 +8,9 @@ - + @@ -25,20 +25,7 @@
{Payload}
- - - -
-
-
-
-
-
-
-
-
-
+ @@ -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' + }); {javascript} diff --git a/CoreVersions/Baikal_0.1/Frameworks/BaikalAdmin/Resources/Templates/Page/style.css b/CoreVersions/Baikal_0.1/Frameworks/BaikalAdmin/Resources/Templates/Page/style.css index af8057a..6a68b33 100644 --- a/CoreVersions/Baikal_0.1/Frameworks/BaikalAdmin/Resources/Templates/Page/style.css +++ b/CoreVersions/Baikal_0.1/Frameworks/BaikalAdmin/Resources/Templates/Page/style.css @@ -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; -} \ No newline at end of file +} + +@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%;} diff --git a/CoreVersions/Baikal_0.1/Frameworks/BaikalAdmin/Resources/Templates/Users/Listing.html b/CoreVersions/Baikal_0.1/Frameworks/BaikalAdmin/Resources/Templates/Users/Listing.html index 3c428fa..e62e666 100644 --- a/CoreVersions/Baikal_0.1/Frameworks/BaikalAdmin/Resources/Templates/Users/Listing.html +++ b/CoreVersions/Baikal_0.1/Frameworks/BaikalAdmin/Resources/Templates/Users/Listing.html @@ -1,20 +1,10 @@ - -

Users

Manage Baïkal user accounts, and associated resources.

+ Add user

-
Display name
+
+* 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()); + } +} \ No newline at end of file diff --git a/CoreVersions/Baikal_0.1/Frameworks/BaikalAdmin/Route/Settings.php b/CoreVersions/Baikal_0.1/Frameworks/BaikalAdmin/Route/Settings/System.php similarity index 93% rename from CoreVersions/Baikal_0.1/Frameworks/BaikalAdmin/Route/Settings.php rename to CoreVersions/Baikal_0.1/Frameworks/BaikalAdmin/Route/Settings/System.php index 2d925fb..4cc5b4d 100644 --- a/CoreVersions/Baikal_0.1/Frameworks/BaikalAdmin/Route/Settings.php +++ b/CoreVersions/Baikal_0.1/Frameworks/BaikalAdmin/Route/Settings/System.php @@ -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()); } } \ No newline at end of file diff --git a/CoreVersions/Baikal_0.1/Frameworks/BaikalAdmin/index.php b/CoreVersions/Baikal_0.1/Frameworks/BaikalAdmin/WWWRoot/index.php similarity index 91% rename from CoreVersions/Baikal_0.1/Frameworks/BaikalAdmin/index.php rename to CoreVersions/Baikal_0.1/Frameworks/BaikalAdmin/WWWRoot/index.php index 91fe0e3..70d5e83 100644 --- a/CoreVersions/Baikal_0.1/Frameworks/BaikalAdmin/index.php +++ b/CoreVersions/Baikal_0.1/Frameworks/BaikalAdmin/WWWRoot/index.php @@ -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); diff --git a/CoreVersions/Baikal_0.1/Frameworks/BaikalAdmin/WWWRoot/install/index.php b/CoreVersions/Baikal_0.1/Frameworks/BaikalAdmin/WWWRoot/install/index.php new file mode 100644 index 0000000..b12c99c --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/BaikalAdmin/WWWRoot/install/index.php @@ -0,0 +1,52 @@ + +* 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(); \ No newline at end of file diff --git a/CoreVersions/Baikal_0.1/Frameworks/BaikalAdmin/config.php b/CoreVersions/Baikal_0.1/Frameworks/BaikalAdmin/config.php index 70c481a..248ad8a 100644 --- a/CoreVersions/Baikal_0.1/Frameworks/BaikalAdmin/config.php +++ b/CoreVersions/Baikal_0.1/Frameworks/BaikalAdmin/config.php @@ -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" ); \ No newline at end of file diff --git a/CoreVersions/Baikal_0.1/Frameworks/BaikalStandalone/run.sh b/CoreVersions/Baikal_0.1/Frameworks/BaikalStandalone/run.sh index 7ea1896..c428be9 100755 --- a/CoreVersions/Baikal_0.1/Frameworks/BaikalStandalone/run.sh +++ b/CoreVersions/Baikal_0.1/Frameworks/BaikalStandalone/run.sh @@ -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." diff --git a/CoreVersions/Baikal_0.1/Frameworks/Flake/Core/Bootstrap.php b/CoreVersions/Baikal_0.1/Frameworks/Flake/Core/Bootstrap.php index f6efb39..63ce1db 100755 --- a/CoreVersions/Baikal_0.1/Frameworks/Flake/Core/Bootstrap.php +++ b/CoreVersions/Baikal_0.1/Frameworks/Flake/Core/Bootstrap.php @@ -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); -} \ No newline at end of file +$aUrlInfo = parse_url(FLAKE_URI); +define("FLAKE_DOMAIN", $_SERVER["HTTP_HOST"]); +define("FLAKE_URIPATH", \Flake\Util\Tools::stripBeginSlash($aUrlInfo["path"])); +unset($aUrlInfo); \ No newline at end of file diff --git a/CoreVersions/Baikal_0.1/Frameworks/Flake/Core/Model/NoDb.php b/CoreVersions/Baikal_0.1/Frameworks/Flake/Core/Model/NoDb.php index 1a1008f..72b9827 100755 --- a/CoreVersions/Baikal_0.1/Frameworks/Flake/Core/Model/NoDb.php +++ b/CoreVersions/Baikal_0.1/Frameworks/Flake/Core/Model/NoDb.php @@ -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; + } } } \ No newline at end of file diff --git a/CoreVersions/Baikal_0.1/Frameworks/Flake/config.php b/CoreVersions/Baikal_0.1/Frameworks/Flake/config.php index 3089f29..4e762fa 100644 --- a/CoreVersions/Baikal_0.1/Frameworks/Flake/config.php +++ b/CoreVersions/Baikal_0.1/Frameworks/Flake/config.php @@ -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); diff --git a/CoreVersions/Baikal_0.1/Frameworks/Formal/Core/Message.php b/CoreVersions/Baikal_0.1/Frameworks/Formal/Core/Message.php index b8fb35b..cd4aa06 100644 --- a/CoreVersions/Baikal_0.1/Frameworks/Formal/Core/Message.php +++ b/CoreVersions/Baikal_0.1/Frameworks/Formal/Core/Message.php @@ -30,20 +30,35 @@ class Message { private function __construct() { } - public static function error($sMessage) { + public static function error($sMessage, $sTitle = "") { + if($sTitle !== "") { + $sTitle = '

' . $sTitle . '

'; + } + $sHtml =<< -

Validation error

+ {$sTitle} {$sMessage} HTML; return $sHtml; } - public static function notice($sMessage) { + public static function notice($sMessage, $sTitle = "", $bClose = TRUE) { + $sClose = ""; + + if($sTitle !== "") { + $sTitle = '

' . $sTitle . '

'; + } + + if($bClose === TRUE) { + $sClose = '×'; + } + $sHtml =<< - × + {$sClose} + {$sTitle} {$sMessage} HTML; diff --git a/CoreVersions/Baikal_0.1/Frameworks/Formal/Element.php b/CoreVersions/Baikal_0.1/Frameworks/Formal/Element.php index 090d6d8..eaec75c 100644 --- a/CoreVersions/Baikal_0.1/Frameworks/Formal/Element.php +++ b/CoreVersions/Baikal_0.1/Frameworks/Formal/Element.php @@ -29,6 +29,8 @@ namespace Formal; abstract class Element { protected $aOptions = array( + "class" => "", + "inputclass" => "input-xlarge", "readonly" => FALSE, "validation" => "", "error" => FALSE, diff --git a/CoreVersions/Baikal_0.1/Frameworks/Formal/Element/Text.php b/CoreVersions/Baikal_0.1/Frameworks/Formal/Element/Text.php index 2009c8b..662fd37 100644 --- a/CoreVersions/Baikal_0.1/Frameworks/Formal/Element/Text.php +++ b/CoreVersions/Baikal_0.1/Frameworks/Formal/Element/Text.php @@ -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 {
- + {$helpblock}
diff --git a/CoreVersions/Baikal_0.1/Frameworks/Formal/Form.php b/CoreVersions/Baikal_0.1/Frameworks/Formal/Form.php index 717799e..bdd94c2 100644 --- a/CoreVersions/Baikal_0.1/Frameworks/Formal/Form.php +++ b/CoreVersions/Baikal_0.1/Frameworks/Formal/Form.php @@ -187,7 +187,9 @@ class Form { } else { $bWasFloating = FALSE; $this->sDisplayMessage = \Formal\Core\Message::notice( - "Changes on " . $this->modelInstance()->label() . " have been saved." + "Changes on " . $this->modelInstance()->label() . " have been saved.", + FALSE, # No title + FALSE # No close button ); } @@ -316,8 +318,9 @@ class Form { } $this->sDisplayMessage = \Formal\Core\Message::error( - implode("
", $aMessages) - ); + implode("
", $aMessages), + "Validation error" + ); } } diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/TwitterBootstrap.2.0.2/css/bootstrap-responsive.css b/CoreVersions/Baikal_0.1/Frameworks/Versions/TwitterBootstrap.2.0.2/css/bootstrap-responsive.css index 65964ce..7ff4506 100644 --- a/CoreVersions/Baikal_0.1/Frameworks/Versions/TwitterBootstrap.2.0.2/css/bootstrap-responsive.css +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/TwitterBootstrap.2.0.2/css/bootstrap-responsive.css @@ -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; diff --git a/CoreVersions/Baikal_0.1/WWWRoot/cal.php b/CoreVersions/Baikal_0.1/WWWRoot/cal.php index 521c38d..36c3be7 100755 --- a/CoreVersions/Baikal_0.1/WWWRoot/cal.php +++ b/CoreVersions/Baikal_0.1/WWWRoot/cal.php @@ -25,6 +25,7 @@ ***************************************************************/ define("BAIKAL_CONTEXT", TRUE); +define("BAIKAL_CONTEXT_BASEURI", "/"); # Bootstraping Baikal require_once(dirname(dirname(__FILE__)) . "/Frameworks/Baikal/Core/Bootstrap.php"); diff --git a/CoreVersions/Baikal_0.1/WWWRoot/card.php b/CoreVersions/Baikal_0.1/WWWRoot/card.php index 956bb1c..4599a7d 100755 --- a/CoreVersions/Baikal_0.1/WWWRoot/card.php +++ b/CoreVersions/Baikal_0.1/WWWRoot/card.php @@ -25,6 +25,7 @@ ***************************************************************/ define("BAIKAL_CONTEXT", TRUE); +define("BAIKAL_CONTEXT_BASEURI", "/"); # Bootstraping Baikal require_once(dirname(dirname(__FILE__)) . "/Frameworks/Baikal/Core/Bootstrap.php"); diff --git a/CoreVersions/Baikal_0.1/WWWRoot/index.php b/CoreVersions/Baikal_0.1/WWWRoot/index.php index 5506b1d..a7a64fc 100755 --- a/CoreVersions/Baikal_0.1/WWWRoot/index.php +++ b/CoreVersions/Baikal_0.1/WWWRoot/index.php @@ -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"); + ?> diff --git a/Specific/config.php b/Specific/config.php index df199b6..d0cbcdc 100755 --- a/Specific/config.php +++ b/Specific/config.php @@ -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 # diff --git a/Specific/db/baikal.sqlite b/Specific/db/baikal.sqlite index 9c2ce5a..6613bdb 100755 Binary files a/Specific/db/baikal.sqlite and b/Specific/db/baikal.sqlite differ diff --git a/html/admin/index.php b/html/admin/index.php index dac9adc..9882e2a 120000 --- a/html/admin/index.php +++ b/html/admin/index.php @@ -1 +1 @@ -../../Core/Frameworks/BaikalAdmin/index.php \ No newline at end of file +../../Core/Frameworks/BaikalAdmin/WWWRoot/index.php \ No newline at end of file diff --git a/html/admin/install/index.php b/html/admin/install/index.php new file mode 120000 index 0000000..1f9cdfe --- /dev/null +++ b/html/admin/install/index.php @@ -0,0 +1 @@ +../../../Core/Frameworks/BaikalAdmin/WWWRoot/install/index.php \ No newline at end of file