Instructions

When this installation script runs for the first time . . .

after entering and testing the required data, it will install the calendar(s) with the specified name and title.

After successful installation:

When you launch this installation script a subsequent time . . .

it will list the installed calendar(s) (name/title pairs) and will offer the possibility to create more calendars and to change the database and administrator data.

When saving the data:


Note: The administrator credentials can be changed later by the calendar administrator for each individual calendar.


Description of form fields:


Database server, username, password and database name

The database server is the name of the database server and could for example be 'localhost'. The username, password and database name are the values used when you created the database on the server. If the entered values are incorrect, the installation script cannot create the calendar tables and the installation will fail.


New to install calendar(s)

Calendar name/title pairs (format: 'name = title', one per line) of new calendars to be created. The initially proposed calendar name = title pair is 'mycal = is My Web Calendar'. If multiple calendars are installed, then - when starting a calendar - the calendar name is used to select a specific calendar.


Default calendar

The name of the default calendar. In case of multiple calendars, this will be the default calendar when no explicit calendar is selected. The specified name must be present in the New to install or in the Installed calendar list.


Installed calendar(s)

List with the currently installed calendars in the specified database folder


Administrator Name, Email and Password

These values must be remembered as they are required later to log in to the calendar. When, in case of multiple calendars, the administrator name, email or password are changed, the values will be changed for all calendars.

EOT; $saveOk = <<Saving Data Successful
  1. The calendar tables have been checked and completed if necessary.
  2. The administrator credentials have been successfully updated in the admin user account of (each of) the calendar(s).
  3. The LuxCal version number, the SQLite database folder and the name of the default calendar have been saved in the file lcconfig.php in the calendar's root folder.

Please note that it is good practice to directly . . .


If needed, you can install/start the lctools.php file to further configure your calendar installation.

EOT; $installOk = <<Installation Successful
  1. The calendar(s) has(have) been created / configured successfully and the default calendar settings have been saved in the settings table of the / each calendar.
  2. A user account for the 'public user' and for the 'administrator', with the specified administrator credentials, has been created in the users table.
  3. The LuxCal version number and the SQLite database folder have been saved in the file lcconfig.php in the calendar's root directory.

Please note that it is good practice to directly . . .

EOT; //sanity check foreach ($_REQUEST as $key => $value) { if (is_string($value)) $_REQUEST[$key] = htmlspecialchars(strip_tags(trim($value)),ENT_QUOTES,'UTF-8'); } //set error reporting error_reporting(E_ALL); //errors and notices ini_set('display_errors',1); ini_set('log_errors',1); //get current LuxCal version $lcV = implode('.',str_split(substr(basename(__FILE__),7,-4))).'M'; //init $test = !empty($_POST['test']) ? true : false; //test configuration $install = !empty($_POST['install']) ? true : false; //save/install calendars $newCals = !empty($_POST['newCals']) ? trim($_POST['newCals']) : ''; //name = title pairs $newCals = preg_replace(array('~ +~','~ *= *~','~( *[\r\n] *)+~'),array(' ',' = ',"\r\n",),$newCals); //clean up $defCal = !empty($_POST['defCal']) ? trim($_POST['defCal']) : ''; //default calendar $dbHost = !empty($_POST['dbHost']) ? $_POST['dbHost'] : ''; //db host name $dbUnam = !empty($_POST['dbUnam']) ? $_POST['dbUnam'] : ''; //db user name $dbPwrd = !empty($_POST['dbPwrd']) ? $_POST['dbPwrd'] : ''; //db password $dbName = !empty($_POST['dbName']) ? $_POST['dbName'] : ''; //db name $adName = !empty($_POST['adNameP']) ? trim($_POST['adNameP']) : ''; //admin name $adMail = !empty($_POST['adMailP']) ? trim($_POST['adMailP']) : ''; //admin mail address $adPwrd = !empty($_POST['adPwrdP']) ? $_POST['adPwrdP'] : ''; //admin password $adPwMd5 = !empty($_POST['adPwMd5']) ? $_POST['adPwMd5'] : ''; //md5 password $clNerror = $clDerror = $dbHerror = $dbUerror = $dbPerror = $dbNerror = $dbFerror = $adNerror = $adEerror = $adPerror = ''; //prepare PHP session test $calPath = './'.basename(__DIR__); session_set_cookie_params(600,$calPath); //set cookie path session_start(); if (!$install and !$test) { //save session test variables $_SESSION['lcSess1'] = 42; $_SESSION['lcSess2'] = 'hitchhiker'; } //if present, get config data if (file_exists('./lcconfig.php')) { include './lcconfig.php'; } if (empty($dbSel)) { $dbSel = 1; } if (empty($dbType)) { $dbType = 'MySQL'; } //get calendar tools require './common/toolbox.php'; require './common/toolboxd.php'; //database tools require './common/toolboxx.php'; //admin tools //connect to db and get admin credentials if (!empty($dbDef)) { //default calendar specified if (!$defCal) { $defCal = $dbDef; } $calID = $dbDef; if ($dbH = dbConnect('void',0)) { //connect to db if ($stH = dbQuery("SELECT `name`, `email`, `password` FROM `users` WHERE ID = 2",0)) { //get admin user data $row = $stH->fetch(PDO::FETCH_ASSOC); $stH = null; //release statement handle! if (!empty($row)) { //found if (!$adName) { $adName = $row['name']; } if (!$adMail) { $adMail = $row['email']; } $adPwMd5 = $row['password']; if ($adPwMd5 and !$adPwrd) { $adPwrd = '********'; } } } } } //get installed calendars $curCals = getCals(); if (empty($curCals)) { $curCalList = 'No calendars installed yet.'; if (empty($newCals)) { $newCals = 'mycal = My Web Calendar'; $defCal = 'mycal'; } } else { $curCalList = ''; foreach($curCals as $name=>$title) { $curCalList .= $name.' = '.$title.($name == $defCal ? " (default)" : '')."
"; } $curCalList = substr($curCalList,0,-4); } ?> LuxCal Event Calendar - Installation
LuxCal Event Calendar
LuxCal version: ".$lcV."Your PHP version: ".PHP_VERSION."Calendar Installation and Configuration\n"; echo "
\n"; $errMsg = $okiMsg = array(); if ($test or $install) { //test PHP version if (version_compare(PHP_VERSION,'5.3.0') >= 0) { $okiMsg[] = "PHP version ".PHP_VERSION." Ok\n"; } else { $errMsg[] = "PHP version ".PHP_VERSION." too low. The calendar needs PHP version 5.3 or higher\n"; } //test if PDO-mysql extension enabled if (extension_loaded('pdo_mysql')) { $okiMsg[] = "PHP PDO-MySQL extension Ok\n"; } else { $errMsg[] = "PHP PDO-MySQL extension NOT enabled
Ask your ISP to enable this extension\n"; } //test session variables if (!empty($_SESSION) and $_SESSION['lcSess1'] == 42 and $_SESSION['lcSess2'] == 'hitchhiker') { $okiMsg[] = "PHP sessions Ok\n"; } else { $errMsg[] = "PHP sessions not working
Check PHP installation on your server\n"; } //check for missing/invalid form fields $regEx = "~^(\w{1,20} = [^<>?%$@{}\\^=\r\n]{1,60}([\r\n]|$)+)+$~"; $clNerror = (!empty($newCals) and !preg_match($regEx,$newCals."\n")) ? ' class="hilite"' : ''; $clDerror = (!preg_match('~^\w{1,20}$~i',$defCal)) ? ' class="hilite"' : ''; $dbHerror = !$dbHost ? ' class="hilite"' : ''; $dbUerror = !$dbUnam ? ' class="hilite"' : ''; $dbPerror = !$dbPwrd ? ' class="hilite"' : ''; $dbNerror = !$dbName ? ' class="hilite"' : ''; $adNerror = !$adName ? ' class="hilite"' : ''; $adEerror = (!preg_match($rxEmailX,$adMail)) ? ' class="hilite"' : ''; $adPerror = !$adPwrd ? ' class="hilite"' : ''; if (!$clNerror) { $allCals = $curCals; //currently installed calendars if ($newCals) { $newCalPairs = preg_split('~[\r\n]+~m',$newCals); foreach ($newCalPairs as $newCalPair) { //get cal from newCals list($calID,$calTitle) = explode(' = ',$newCalPair); $allCals[$calID] = $calTitle; //add/replace into $allCals } } if (!$clDerror and !array_key_exists($defCal,$allCals)) { $defCal = substr($newCals,0,strpos($newCals,' = ')); //set to first newcalendar } } else { $errMsg[] = "Error: No or invalid calendar name = title pair(s) (highlighted)"; } if ($clDerror or $dbHerror or $dbHerror or $dbUerror or $dbPerror or $dbNerror or $adNerror or $adEerror or $adPerror) { $errMsg[] = "Error: Missing or invalid form fields (highlighted)"; } else { $okiMsg[] = "Form fields OK"; } } if ($test) { if (@file_put_contents('./lctest.dat','LuxCal') === false) { //write test file $errMsg[] = "Writing to the calendar's root folder
Check file permissions on your server\n"; } else { unlink('./lctest.dat'); //delete test file $okiMsg[] = "Writing to the calendar's root folder\n"; } if (@file_put_contents('./files/lctest.dat','LuxCal') === false) { //write test file $errMsg[] = "Writing to the 'files' folder
Check file permissions on your server\n"; } else { unlink('./files/lctest.dat'); //delete test file $okiMsg[] = "Writing to the 'files' folder\n"; } //create empty sql.log if (@file_put_contents('./logs/sql.log','') === false) { $errMsg[] = "Writing an empty sql.log file to the 'logs' folder
Check file permissions on your server\n"; } else { $okiMsg[] = "Writing an empty sql.log file to the 'logs' folder\n"; } //create empty luxcal.log if (@file_put_contents('./logs/luxcal.log','') === false) { $errMsg[] = "Writing an empty luxcal.log file to the 'logs' folder
Check file permissions on your server\n"; } else { $okiMsg[] = "Writing an empty luxcal.log file to the 'logs' folder\n"; } } if ($install and empty($errMsg)) { //prepare db data $adPwMd5 = trim($adPwrd) == '********' ? $adPwMd5 : md5($adPwrd); //connect to db if (!$dbH = dbConnect('void',0)) { //0: return on error ($dbH false) $errMsg[] = "Database $dbName - Problem connecting to database
Check your database credentials/permissions\n"; } else { dbQuery("SET NAMES utf8 COLLATE utf8_unicode_ci; SET CHARACTER SET utf8;"); //set character set and collation foreach ($allCals as $name => $title) { //check / create calendar tables $calID = $name; //select calendar //create tables, if not exist createDbTable('events'); createDbTable('categories'); createDbTable('users'); createDbTable('groups'); createDbTable('settings'); createDbTable('styles'); //insert initial data in groups, users, cats and settings tables initGroups(); initUsers($adName,$adMail,$adPwMd5); initCats(); initStyles(); $dbSet = array(); $dbSet['calendarTitle'] = $title; $dbSet['calendarUrl'] = calBaseUrl().'?cal='.$name; $dbSet['calendarEmail'] = $adMail; checkSettings($dbSet); saveSettings($dbSet); } } $dbH = null; //close db if (empty($errMsg)) { //save configuration $dbDef = $defCal; saveConfig(); //save LuxCal version and db data session_unset(); //force retrieve of settings and selection of default calendar $htaccess = htaccess(); //check .htaccess file for blocking access to .cdb, .log and .txt files //installation successful echo "
\n"; echo "
\n"; echo ($newCals ? $installOk : $saveOk); if ($htaccess) { echo "\n
\n

Note:

\n

{$htaccess}

"; } echo "
\n"; echo "\n"; if (file_exists('./lctools.php')) { echo "\n"; } echo "\n"; echo "
\n
\n
\n"; } } if (!$install or !empty($errMsg) ) { //display form //display header echo $instructions; echo "
\n"; if (!empty($errMsg)) { echo "
Tests failed:
\n"; echo "
    \n"; foreach ($errMsg as $msg) { echo "
  • {$msg}
  • \n"; } echo "
\n"; } if ($test and !empty($okiMsg)) { echo "
Tests passed:
\n"; echo "
    \n"; foreach ($okiMsg as $msg) { echo "
  • {$msg}
  • \n"; } echo "
\n
\n"; } if (empty($errMsg)) { if ($test) { echo "

Select 'install/save' to install the calendar(s) and to save the credentials.

\n"; } else { echo "

Complete this form to configure/install the LuxCal Event Calendar.\n"; echo "
Select 'test' to validate the form fields and select 'install/save' to continue.

\n"; } } else { echo "

Correct/solve the errors/failures and test again.

\n"; } //display form echo "
\n"; echo "
\n"; echo "\n"; echo "

= read instructions =

\n"; echo "\n"; echo ""; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "
MySQL Database
Server:
Username:
Password:
Database name:
Calendars
New to install:
(name = title)
{$newCals}
Default calendar:
Installed:
(name = title)
{$curCalList} 

Administrator
Name:
Email:
Password:
\n"; echo "
\n"; echo "
\n"; echo "\n"; if ($test and empty($errMsg)) { echo "\n"; } echo "
\n"; echo "
\n"; echo "
\n"; } ?>

AFTER USE MAKE THE FILE INACCESSIBLE OR REMOVE IT FROM THE SERVER !

design - powered by LuxSoft