You need version 5.3 or higher Your current version is: '.PHP_VERSION);
}
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 configuration data
date_default_timezone_set(@date_default_timezone_get()); //set time zone
if (file_exists('./lcconfig.php')) {
include './lcconfig.php';
}
$lcVcurr = !empty($lcV) ? $lcV : '0'; //current LuxCal version
if (empty($dbType)) { $dbType = 'MySQL'; } //set database type
$lcV = implode('.',str_split(substr(basename(__FILE__),7,-4))).'M'; //set new LuxCal version
//get calendar tools
require './common/toolbox.php'; //general toolbox
require './common/toolboxd.php'; //database tools
require './common/toolboxx.php'; //admin tools
?>
LuxCal Event Calendar - UpgradeLuxCal Event CalendarLuxCal: {$lcV}Your PHP version: ".PHP_VERSION."Calendar Upgrade to Version {$lcV}\n";
echo "
\n";
do { //start of processing
if (empty($dbHost) OR empty($dbUnam) OR empty($dbName)) { //no db credentials found
$error = "No database credentials found in calendar root (file: lcconfig.php)"; break;
}
if (!isset($dbDef)) { //before v4.1
if (!isset($dbPfix)) { //config data not complete
$error = "Not all configuration data found in calendar root (file: lcconfig.php)"; break;
}
$dbDef = $dbPfix; //set default calendar
}
$calID = $dbDef = rtrim($dbDef,'_'); //remove possible separator "_"
$report[] = "Configuration file 'lcconfig.php' found. Configuration data loaded:";
$report[] = "- Database name: {$dbName}";
$report[] = "- Default calendar: {$dbDef}";
//connect to database
if (!$dbH = dbConnect('void',0)) {
$error = "Could not connect to database"; break;
}
//check/update table prefixes of old versions
$stH = dbQuery("SHOW TABLES LIKE '%settings'");
while ($row = $stH->fetch(PDO::FETCH_NUM)) {
$matches = array();
if (preg_match('~^([a-z\d-]{0,20})settings$~',$row[0],$matches)) { //no prefix or no separator (_)
$fromPf = empty($matches[1]) ? '' : $matches[1];
$toPf = empty($matches[1]) ? 'mycal' : $matches[1]; //no prefix: 'mycal'
$q = "RENAME TABLE
{$fromPf}events TO {$toPf}_events,
{$fromPf}categories TO {$toPf}_categories,
{$fromPf}users TO {$toPf}_users,
{$fromPf}settings TO {$toPf}_settings
";
$stH2 = dbQuery($q);
if ($stH2) { $report[] = "Tables '{$fromPf}xxxxxx' renamed to '{$toPf}_xxxxxx'"; }
$calID = $dbDef = $toPf;
}
}
//get settings of default calendar and set time zone
$dbSet = getSettings();
if ($dbSet === false) {
$error = "Could not retrieve calendar settings from the database"; break;
}
date_default_timezone_set($dbSet['timeZone']);
$report[] = "Default calendar settings retrieved and timezone set to:";
$report[] = "- ".$dbSet['timeZone'];
/* ===== LuxCal 3.1.0 drop table `x_sessdata` (not used anymore) ===== */
dbQuery("DROP TABLE IF EXISTS `x_sessdata`",0);
//get installed calendars
$allCals = getCals();
if (empty($allCals)) {
$error = "No calendars found in the database."; break;
}
$report[] = "Calendar(s) found in the database:";
foreach($allCals as $cID=>$title) {
$report[] = '- '.$cID.' = '.$title.($cID == $dbDef ? " (default)" : '');
}
/*============================= start upgrading ==============================*/
foreach($allCals as $cID=>$title) { //process each installed calendar
$report[] = "Processing calendar: {$cID} - {$title}";
$calID = $cID; //set current calendar
//upgrade db tables to the latest schema, while preserving data
$fromV = upgradeDb();
$report[] = "- V{$fromV} database tables and structures verified/updated.";
//upgrade admin settings
$dbSet = getSettings();
checkSettings($dbSet); //check, complete & save settings
$report[] = "- Administrator settings verified/updated";
}
//Save LuxCal version and config data
if (!saveConfig()) {
$error = "Unable to write the file lcconfig.php to calendar root. Check file permissions (should be 755)."; break;
}
$report[] = "Configuration file 'lcconfig.php' updated and saved to root folder.";
} while (0); //end of processing
echo "