\n"; print $error; print ""; } /* }}} */ protected function printWarning($error) { /* {{{ */ print "
"; print $error; print "
"; } /* }}} */ protected function printCheckError($resCheck) { /* {{{ */ $hasError = false; foreach($resCheck as $keyRes => $paramRes) { if(isset($paramRes['type']) && $paramRes['type'] == 'error') $hasError = true; $errorMes = getMLText("settings_$keyRes"). " : " . getMLText("settings_".$paramRes["status"]); if (isset($paramRes["currentvalue"])) $errorMes .= "
=> " . getMLText("settings_currentvalue") . " : " . $paramRes["currentvalue"]; if (isset($paramRes["suggestionvalue"])) $errorMes .= "
=> " . getMLText("settings_suggestionvalue") . " : " . $paramRes["suggestionvalue"]; if (isset($paramRes["suggestion"])) $errorMes .= "
=> " . getMLText("settings_".$paramRes["suggestion"]); if (isset($paramRes["systemerror"])) $errorMes .= "
=> " . $paramRes["systemerror"]; if(isset($paramRes['type']) && $paramRes['type'] == 'error') $this->printError($errorMes); else $this->printWarning($errorMes); } return $hasError; } /* }}} */ protected function openDBConnection($settings) { /* {{{ */ switch($settings->_dbDriver) { case 'mysql': case 'mysqli': case 'mysqlnd': case 'pgsql': $tmp = explode(":", $settings->_dbHostname); $dsn = $settings->_dbDriver.":dbname=".$settings->_dbDatabase.";host=".$tmp[0]; if(isset($tmp[1])) $dsn .= ";port=".$tmp[1]; break; case 'sqlite': $dsn = $settings->_dbDriver.":".$settings->_dbDatabase; break; } $connTmp = new PDO($dsn, $settings->_dbUser, $settings->_dbPass); return $connTmp; } /* }}} */ public function intro() { /* {{{ */ $this->htmlStartPage("INSTALL"); $this->globalBanner(); $this->contentStart(); $this->contentHeading("SeedDMS Installation for version ".SEEDDMS_VERSION); $this->contentContainerStart(); echo "

".getMLText('settings_install_welcome_title')."

"; echo "
".getMLText('settings_install_welcome_text')."
"; echo '

' . getMLText("settings_start_install") . '

'; $this->contentContainerEnd(); $this->contentEnd(); $this->htmlEndPage(); } /* }}} */ public function install($msg) { /* {{{ */ $settings = $this->params['settings']; $configDir = $this->params['configdir']; $this->htmlStartPage("INSTALL"); $this->globalBanner(); $this->contentStart(); $this->contentHeading("SeedDMS Installation for version ".SEEDDMS_VERSION); if(isset($msg)) $this->warningMsg($msg); $this->contentContainerStart(); /** * Show phpinfo */ if (isset($_GET['phpinfo'])) { echo '' . getMLText("back") . ''; phpinfo(); $this->contentContainerEnd(); $this->contentEnd(); $this->htmlEndPage(); exit(); } /** * check if ENABLE_INSTALL_TOOL shall be removed */ if (isset($_GET['disableinstall'])) { /* {{{ */ if(file_exists($configDir."/ENABLE_INSTALL_TOOL")) { if(unlink($configDir."/ENABLE_INSTALL_TOOL")) { echo getMLText("settings_install_disabled"); echo "

"; echo '' . getMLText("settings_more_settings") .''; } else { echo getMLText("settings_cannot_disable"); echo "

"; echo '' . getMLText("back") . ''; } } else { echo getMLText("settings_cannot_disable"); echo "

"; echo '' . getMLText("back") . ''; } $this->contentContainerEnd(); $this->contentEnd(); $this->htmlEndPage(); exit(); } /* }}} */ /** * Check System */ if ($this->printCheckError( $settings->checkSystem())) { /* {{{ */ if (function_exists("apache_get_version")) { echo "
Apache version: " . apache_get_version(); } echo "
PHP version: " . phpversion(); echo "
PHP include path: " . ini_get('include_path'); echo '
'; echo '
'; echo '' . getMLText("refresh") . ''; echo ' - '; echo '' . getMLText("version_info") . ''; exit; } /* }}} */ if (isset($_POST["action"])) $action=$_POST["action"]; else if (isset($_GET["action"])) $action=$_GET["action"]; else $action=NULL; $showform = true; if ($action=="setSettings") { /* {{{ */ /** * Get Parameters */ $settings->_rootDir = $_POST["rootDir"]; $settings->_httpRoot = $_POST["httpRoot"]; $settings->_contentDir = $_POST["contentDir"]; $settings->_luceneDir = $_POST["luceneDir"]; $settings->_stagingDir = $_POST["stagingDir"]; $settings->_cacheDir = $_POST["cacheDir"]; $settings->_extraPath = $_POST["extraPath"]; $settings->_dbDriver = $_POST["dbDriver"]; $settings->_dbHostname = $_POST["dbHostname"]; $settings->_dbDatabase = $_POST["dbDatabase"]; $settings->_dbUser = $_POST["dbUser"]; $settings->_dbPass = $_POST["dbPass"]; $settings->_coreDir = ''; //$_POST["coreDir"]; $settings->_luceneClassDir = ''; //$_POST["luceneClassDir"]; if(isset($settings->_extraPath)) ini_set('include_path', $settings->_extraPath. PATH_SEPARATOR .ini_get('include_path')); /** * Check Parameters, require version 3.3.x */ $hasError = $this->printCheckError( $settings->check(substr(str_replace('.', '', SEEDDMS_VERSION), 0,2))); if (!$hasError) { // Create database if (isset($_POST["createDatabase"])) { $createOK = false; $errorMsg = ""; $connTmp = $this->openDBConnection($settings); if ($connTmp) { // read SQL file if ($settings->_dbDriver=="mysql") $queries = file_get_contents("create_tables-innodb.sql"); elseif($settings->_dbDriver=="sqlite") $queries = file_get_contents("create_tables-sqlite3.sql"); elseif($settings->_dbDriver=="pgsql") $queries = file_get_contents("create_tables-postgres.sql"); else die(); // generate SQL query $queries = explode(";", $queries); // execute queries foreach($queries as $query) { // var_dump($query); $query = trim($query); if (!empty($query)) { $connTmp->exec($query); if ($connTmp->errorCode() != 0) { $errorMsg .= $connTmp->errorInfo()[2] . "
"; } } } } // error ? if (empty($errorMsg)) $createOK = true; $connTmp = null; // Show error if (!$createOK) { echo $errorMsg; $hasError = true; } } // create database if (!$hasError) { // Save settings $settings->save(); $needsupdate = false; $connTmp = $this->openDBConnection($settings); if ($connTmp) { switch($settings->_dbDriver) { case 'mysql': case 'mysqli': case 'mysqlnd': case 'sqlite': $sql = 'select * from `tblVersion`'; break; case 'pgsql': $sql = 'select * from "tblVersion"'; break; } $res = $connTmp->query($sql); if($res) { if($rec = $res->fetch(PDO::FETCH_ASSOC)) { $updatedirs = array(); $d = dir("."); while (false !== ($entry = $d->read())) { if(preg_match('/update-([0-9.]*)/', $entry, $matches)) { $updatedirs[] = $matches[1]; } } $d->close(); echo "Your current database schema has version ".$rec['major'].'.'.$rec['minor'].'.'.$rec['subminor'].". Please run all (if any)
of the update scripts below in the listed order.

"; $connTmp = null; if($updatedirs) { asort($updatedirs); foreach($updatedirs as $updatedir) { if($updatedir > $rec['major'].'.'.$rec['minor'].'.'.$rec['subminor']) { $needsupdate = true; print "

Database update to version ".$updatedir." needed

"; if(file_exists('update-'.$updatedir.'/update.txt')) { print "

Please read the comments on updating this version. Read now

"; } print "

Run the update script.

"; } } } else { print "

Your current database is up to date.

"; } } if(!$needsupdate) { echo getMLText("settings_install_success"); echo "

"; echo getMLText("settings_delete_install_folder"); echo "

"; echo '' . getMLText("settings_disable_install") . ''; echo "

"; echo '' . getMLText("settings_more_settings") .''; $showform = false; } } else { print "

You does not seem to have a valid database. The table tblVersion is missing.

"; } } } } // Back link echo '
'; echo '
'; // echo '' . getMLText("back") . ''; } /* }}} */ if($showform) { /* {{{ */ /** * Set parameters */ ?>
"> "> "> "> "> "> "> "> "> "> "> ">
:
:
:
:
:
:
:
:
:
:
:
:
:
" />
_printDisclaimer = false; $settings->_footNote = false; // end of the page $this->contentContainerEnd(); $this->contentEnd(); $this->htmlEndPage(); } /* }}} */ public function update() { /* {{{ */ $settings = $this->params['settings']; $this->htmlStartPage('Database update'); $this->globalBanner(); $this->contentStart(); $this->contentHeading("SeedDMS Installation for version ".$_GET['version']); $this->contentContainerStart(); $sqlfile = "update.sql"; switch($settings->_dbDriver) { case 'mysql': case 'mysqli': case 'mysqlnd': $tmp = explode(":", $settings->_dbHostname); $dsn = $settings->_dbDriver.":dbname=".$settings->_dbDatabase.";host=".$tmp[0]; if(isset($tmp[1])) $dsn .= ";port=".$tmp[1]; break; case 'sqlite': $dsn = $settings->_dbDriver.":".$settings->_dbDatabase; if(file_exists('update-'.$_GET['version'].'/update-sqlite3.sql')) $sqlfile = "update-sqlite3.sql"; break; case 'pgsql': $tmp = explode(":", $settings->_dbHostname); $dsn = $settings->_dbDriver.":dbname=".$settings->_dbDatabase.";host=".$tmp[0]; if(isset($tmp[1])) $dsn .= ";port=".$tmp[1]; if(file_exists('update-'.$_GET['version'].'/update-postgres.sql')) $sqlfile = "update-postgres.sql"; } $db = new PDO($dsn, $settings->_dbUser, $settings->_dbPass); if (!$db) { die; } $errorMsg = ''; $res = $db->query('select * from tblVersion'); $recs = $res->fetchAll(PDO::FETCH_ASSOC); if(!empty($recs)) { $rec = $recs[0]; if($_GET['version'] > $rec['major'].'.'.$rec['minor'].'.'.$rec['subminor']) { if(file_exists('update-'.$_GET['version'].'/'.$sqlfile)) { $queries = file_get_contents('update-'.$_GET['version'].'/'.$sqlfile); $queries = explode(";", $queries); // execute queries if($queries) { echo "

Updating database schema

"; foreach($queries as $query) { $query = trim($query); if (!empty($query)) { echo $query."
"; if(false === $db->exec($query)) { $e = $db->ErrorInfo(); $errorMsg .= $e[2] . "
"; } } } } } else { echo "

SQL file for update missing!

"; } } else { echo "

Database schema already up to date.

"; } if(!$errorMsg) { if(file_exists('update-'.$_GET['version'].'/update.php')) { echo "

Running update script

"; include('update-'.$_GET['version'].'/update.php'); } } else { echo "

Error Messages

"; echo $errorMsg; } echo "

Go back to installation and recheck.

"; } else { echo "

Could not determine database schema version.

"; } $db = null; // just remove info for web page installation $settings->_printDisclaimer = false; $settings->_footNote = false; // end of the page $this->contentContainerEnd(); $this->contentEnd(); $this->htmlEndPage(); } /* }}} */ }