From 51c342b5e309544cd6f4f3ae0997dc9fcbe199bb Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Wed, 21 Jul 2021 15:24:17 +0200 Subject: [PATCH 01/26] replace tab with spaces --- install/create_tables-sqlite3.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install/create_tables-sqlite3.sql b/install/create_tables-sqlite3.sql index f98deb501..2a5eadba5 100644 --- a/install/create_tables-sqlite3.sql +++ b/install/create_tables-sqlite3.sql @@ -431,7 +431,7 @@ CREATE TABLE `tblSessions` ( `theme` varchar(30) NOT NULL default '', `language` varchar(30) NOT NULL default '', `clipboard` text default NULL, - `su` INTEGER DEFAULT NULL, + `su` INTEGER DEFAULT NULL, `splashmsg` text default NULL ) ; From c1e794dc4f519614ba9c34aa53e181a33b9504c3 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Wed, 21 Jul 2021 15:24:50 +0200 Subject: [PATCH 02/26] fix updating tblDocumentFiles --- install/update-5.1.0/update-sqlite3.sql | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/install/update-5.1.0/update-sqlite3.sql b/install/update-5.1.0/update-sqlite3.sql index ed9b14600..89e75a366 100644 --- a/install/update-5.1.0/update-sqlite3.sql +++ b/install/update-5.1.0/update-sqlite3.sql @@ -51,7 +51,9 @@ ALTER TABLE `new_tblDocumentContent` RENAME TO `tblDocumentContent`; CREATE TABLE `new_tblDocumentFiles` ( `id` INTEGER PRIMARY KEY AUTOINCREMENT, `document` INTEGER NOT NULL default 0 REFERENCES `tblDocuments` (`id`), + `version` INTEGER unsigned NOT NULL default '0', `userID` INTEGER NOT NULL default 0 REFERENCES `tblUsers` (`id`), + `public` INTEGER NOT NULL default '0', `comment` text, `name` varchar(150) default NULL, `date` INTEGER default NULL, @@ -61,16 +63,12 @@ CREATE TABLE `new_tblDocumentFiles` ( `mimeType` varchar(100) NOT NULL default '' ) ; -INSERT INTO `new_tblDocumentFiles` SELECT * FROM `tblDocumentFiles`; +INSERT INTO `new_tblDocumentFiles` SELECT `id`, `document`, 0, `userID`, 0, `comment`, `name`, `date`, `dir`, `orgFileName`, `fileType`, `mimeType` FROM `tblDocumentFiles`; DROP TABLE `tblDocumentFiles`; ALTER TABLE `new_tblDocumentFiles` RENAME TO `tblDocumentFiles`; -ALTER TABLE `tblDocumentFiles` ADD COLUMN `version` INTEGER unsigned NOT NULL DEFAULT '0'; - -ALTER TABLE `tblDocumentFiles` ADD COLUMN `public` INTEGER unsigned NOT NULL DEFAULT '0'; - CREATE TABLE `new_tblUsers` ( `id` INTEGER PRIMARY KEY AUTOINCREMENT, `login` varchar(50) default NULL, From f1358317eadb5c08a57c0a67847b50d60b1ec815 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Wed, 21 Jul 2021 15:45:24 +0200 Subject: [PATCH 03/26] remove all old methods not longer used --- inc/inc.ClassUI_Default.php | 1085 ----------------------------------- 1 file changed, 1085 deletions(-) diff --git a/inc/inc.ClassUI_Default.php b/inc/inc.ClassUI_Default.php index 4bbab1a4b..e67cd6562 100644 --- a/inc/inc.ClassUI_Default.php +++ b/inc/inc.ClassUI_Default.php @@ -27,1089 +27,4 @@ class UI_Default { $this->theme = $theme; } - static function __getStyles() { /* {{{ */ - global $settings; - - $themes = array(); - $path = $settings->_rootDir . "styles/"; - $handle = opendir($path); - - while ($entry = readdir($handle) ) { - if ($entry == ".." || $entry == ".") - continue; - else if (is_dir($path . $entry)) - array_push($themes, $entry); - } - closedir($handle); - return $themes; - } /* }}} */ - - function htmlStartPage($title="", $bodyClass="") { /* {{{ */ - global $theme, $settings; - - if(file_exists("../themes/".$theme."/HTMLHead.html")) { - include("../themes/".$theme."/HTMLHead.html"); - } else { - echo "\n"; - echo "\n\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "".(strlen($settings->_siteName)>0 ? $settings->_siteName : "SeedDMS").(strlen($title)>0 ? ": " : "").htmlspecialchars($title)."\n"; - echo "\n"; - echo "0 ? " class=\"".$bodyClass."\"" : "").">\n"; - } - } /* }}} */ - - function htmlEndPage() { /* {{{ */ - global $theme; - - UI::footNote(); - if(file_exists("../themes/".$theme."/HTMLFoot.html")) { - include("../themes/".$theme."/HTMLFoot.html"); - } else { - echo "\n\n"; - } - } /* }}} */ - - function footNote() { /* {{{ */ - global $settings; - - echo "
\n"; - echo '
'."\n"; - echo '
'."\n"; - echo '
'."\n"; - if ($settings->_printDisclaimer){ - echo "
".getMLText("disclaimer")."
"; - } - - if (isset($settings->_footNote) && strlen((string)$settings->_footNote)>0) { - echo "
".(string)$settings->_footNote."
"; - } - echo "
\n"; - echo "
\n"; - echo "
\n"; - echo "
\n"; - - return; - } /* }}} */ - - function contentStart() { /* {{{ */ - echo "
\n"; - echo "
\n"; - } /* }}} */ - - function contentEnd() { /* {{{ */ - echo "
\n"; - echo "
\n"; - } /* }}} */ - - function globalBanner() { /* {{{ */ - global $settings; - - echo "
\n"; - echo "
\n"; - echo " \n"; - echo "
\n"; - echo "
\n"; - - return; - } /* }}} */ - - function __globalNavigation($folder=null) { /* {{{ */ - - global $settings, $user; - - echo "
\n"; - echo "
\n"; - echo "\n"; - echo "
\n"; - echo "
". - (strlen($settings->_siteName)>0 ? $settings->_siteName : "SeedDMS"). - "
\n"; - echo "\n"; - echo "
".getMLText("signed_in_as")." ".htmlspecialchars($user->getFullName()). - " (".getMLText("sign_out").").
\n"; - echo "
 
\n". - "
\n"; - return; - } /* }}} */ - - function __pageNavigation($pageTitle, $pageType=null, $extra=null) { /* {{{ */ - global $settings, $user; - - echo "
\n"; - // This spacer span is an awful hack, but it is the only way I know to - // get the spacer to match the mainheading content's size. - echo "".($settings->_titleDisplayHack ? $pageTitle : "")."\n"; - echo "
".$pageTitle."
\n"; - echo "
\n
\n"; - - if ($pageType!=null && strcasecmp($pageType, "noNav")) { - echo "
\n"; - switch ($pageType) { - case "view_folder": - UI::folderNavigationBar($extra); - break; - case "view_document": - UI::documentNavigationBar(); - break; - case "my_documents": - UI::myDocumentsNavigationBar(); - break; - case "my_account": - UI::accountNavigationBar(); - break; - case "admin_tools": - UI::adminToolsNavigationBar(); - break; - case "calendar"; - UI::calendarNavigationBar($extra); - break; - } - echo "
\n
\n"; - } - - return; - } /* }}} */ - - function __folderNavigationBar($folder) { /* {{{ */ - - global $user, $settings, $theme; - - if (!is_object($folder) || strcasecmp(get_class($folder), "SeedDMS_Core_Folder")) { - echo "
    \n"; - echo "
\n"; - return; - } - $accessMode = $folder->getAccessMode($user); - $folderID = $folder->getID(); - echo "\n"; - return; - } /* }}} */ - - function __documentNavigationBar() { /* {{{ */ - - global $user, $settings, $document; - - $accessMode = $document->getAccessMode($user); - $docid=".php?documentid=" . $document->getID(); - - echo "\n"; - return; - } /* }}} */ - - function __accountNavigationBar() { /* {{{ */ - - global $settings,$user; - - echo "\n"; - return; - } /* }}} */ - - function __myDocumentsNavigationBar() { /* {{{ */ - - echo "\n"; - return; - } /* }}} */ - - function __adminToolsNavigationBar() { /* {{{ */ - - global $settings; - - echo "\n"; - return; - } /* }}} */ - - function __calendarNavigationBar($d){ /* {{{ */ - - global $settings,$user; - - $ds="&day=".$d[0]."&month=".$d[1]."&year=".$d[2]; - - echo "\n"; - return; - - } /* }}} */ - - function __pageList($pageNumber, $totalPages, $baseURI, $params) { /* {{{ */ - - if (!is_numeric($pageNumber) || !is_numeric($totalPages) || $totalPages<2) { - return; - } - - // Construct the basic URI based on the $_GET array. One could use a - // regular expression to strip out the pg (page number) variable to - // achieve the same effect. This seems to be less haphazard though... - $resultsURI = $baseURI; - $first=true; - foreach ($params as $key=>$value) { - // Don't include the page number in the basic URI. This is added in - // during the list display loop. - if (!strcasecmp($key, "pg")) { - continue; - } - if (is_array($value)) { - foreach ($value as $subvalue) { - $resultsURI .= ($first ? "?" : "&").$key."%5B%5D=".$subvalue; - $first = false; - } - } - else { - $resultsURI .= ($first ? "?" : "&").$key."=".$value; - } - $first = false; - } - - echo "
"; - echo getMLText("results_page").": "; - for ($i = 1; $i <= $totalPages; $i++) { - if ($i == $pageNumber) echo "".$i." "; - else echo "".$i.""." "; - } - if ($totalPages>1) { - echo "".getMLText("all_pages").""." "; - } - echo "
"; - - return; - } /* }}} */ - - function __contentContainer($content) { /* {{{ */ - echo "
\n"; - echo "
\n"; - echo "
\n"; - echo $content; - echo "
\n
\n
\n"; - return; - } /* }}} */ - - function contentContainerStart($class="") { /* {{{ */ - - echo "
\n"; - return; - } /* }}} */ - - function contentContainerEnd() { /* {{{ */ - - echo "
\n"; - return; - } /* }}} */ - - function contentHeading($heading, $noescape=false) { /* {{{ */ - - if($noescape) - echo "".$heading."\n"; - else - echo "".htmlspecialchars($heading)."\n"; - return; - } /* }}} */ - - function contentSubHeading($heading, $first=false) { /* {{{ */ - - echo "
".$heading."
"; - return; - } /* }}} */ - - function __getMimeIcon($fileType) { /* {{{ */ - // for extension use LOWER CASE only - $icons = array(); - $icons["txt"] = "txt.png"; - $icons["text"] = "txt.png"; - $icons["doc"] = "word.png"; - $icons["dot"] = "word.png"; - $icons["docx"] = "word.png"; - $icons["dotx"] = "word.png"; - $icons["rtf"] = "document.png"; - $icons["xls"] = "excel.png"; - $icons["xlt"] = "excel.png"; - $icons["xlsx"] = "excel.png"; - $icons["xltx"] = "excel.png"; - $icons["ppt"] = "powerpoint.png"; - $icons["pot"] = "powerpoint.png"; - $icons["pptx"] = "powerpoint.png"; - $icons["potx"] = "powerpoint.png"; - $icons["exe"] = "binary.png"; - $icons["html"] = "html.png"; - $icons["htm"] = "html.png"; - $icons["gif"] = "image.png"; - $icons["jpg"] = "image.png"; - $icons["jpeg"] = "image.png"; - $icons["bmp"] = "image.png"; - $icons["png"] = "image.png"; - $icons["tif"] = "image.png"; - $icons["tiff"] = "image.png"; - $icons["log"] = "log.png"; - $icons["midi"] = "midi.png"; - $icons["pdf"] = "pdf.png"; - $icons["wav"] = "sound.png"; - $icons["mp3"] = "sound.png"; - $icons["c"] = "source_c.png"; - $icons["cpp"] = "source_cpp.png"; - $icons["h"] = "source_h.png"; - $icons["java"] = "source_java.png"; - $icons["py"] = "source_py.png"; - $icons["tar"] = "tar.png"; - $icons["gz"] = "gz.png"; - $icons["7z"] = "gz.png"; - $icons["bz"] = "gz.png"; - $icons["bz2"] = "gz.png"; - $icons["tgz"] = "gz.png"; - $icons["zip"] = "gz.png"; - $icons["rar"] = "gz.png"; - $icons["mpg"] = "video.png"; - $icons["avi"] = "video.png"; - $icons["tex"] = "tex.png"; - $icons["ods"] = "x-office-spreadsheet.png"; - $icons["ots"] = "x-office-spreadsheet.png"; - $icons["sxc"] = "x-office-spreadsheet.png"; - $icons["stc"] = "x-office-spreadsheet.png"; - $icons["odt"] = "x-office-document.png"; - $icons["ott"] = "x-office-document.png"; - $icons["sxw"] = "x-office-document.png"; - $icons["stw"] = "x-office-document.png"; - $icons["odp"] = "ooo_presentation.png"; - $icons["otp"] = "ooo_presentation.png"; - $icons["sxi"] = "ooo_presentation.png"; - $icons["sti"] = "ooo_presentation.png"; - $icons["odg"] = "ooo_drawing.png"; - $icons["otg"] = "ooo_drawing.png"; - $icons["sxd"] = "ooo_drawing.png"; - $icons["std"] = "ooo_drawing.png"; - $icons["odf"] = "ooo_formula.png"; - $icons["sxm"] = "ooo_formula.png"; - $icons["smf"] = "ooo_formula.png"; - $icons["mml"] = "ooo_formula.png"; - - $icons["default"] = "default.png"; - - $ext = strtolower(substr($fileType, 1)); - if (isset($icons[$ext])) { - return $icons[$ext]; - } - else { - return $icons["default"]; - } - } /* }}} */ - - function __printDateChooser($defDate = -1, $varName) { /* {{{ */ - - if ($defDate == -1) - $defDate = mktime(); - $day = date("d", $defDate); - $month = date("m", $defDate); - $year = date("Y", $defDate); - - print " \n"; - print " \n"; - print ""; - } /* }}} */ - - function __printSequenceChooser($objArr, $keepID = -1) { /* {{{ */ - if (count($objArr) > 0) { - $max = $objArr[count($objArr)-1]->getSequence() + 1; - $min = $objArr[0]->getSequence() - 1; - } - else { - $max = 1.0; - } - print ""; - } /* }}} */ - - function __printDocumentChooser($formName) { /* {{{ */ - global $settings; - ?> - - "; - print ""; - print "  "; - } /* }}} */ - - function __printFolderChooser($formName, $accessMode, $exclude = -1, $default = false) { /* {{{ */ - global $settings; - ?> - - getID() : "") ."\">"; - print "getName()) : "") ."\">"; - print "  "; - } /* }}} */ - - function __printCategoryChooser($formName, $categories=array()) { /* {{{ */ - global $settings; -?> - -getId(); - $names[] = htmlspecialchars($cat->getName()); - } - } - print ""; - print ""; - print "  \"\""; - print "  "; - } /* }}} */ - - function __printAttributeEditField($attrdef, $objvalue, $fieldname='attributes') { /* {{{ */ - if($valueset = $attrdef->getValueSetAsArray()) { - echo ""; - } else { - echo "getId()."]\" value=\"".htmlspecialchars($objvalue)."\" />"; - } - } /* }}} */ - - function __getImgPath($img) { /* {{{ */ - global $theme; - - if ( is_file("../styles/$theme/images/$img") ) { - return "../styles/$theme/images/$img"; - } - else if ( is_file("../styles/$theme/img/$img") ) { - return "../styles/$theme/img/$img"; - } - return "../out/images/$img"; - } /* }}} */ - - function __printImgPath($img) { /* {{{ */ - print UI::getImgPath($img); - } /* }}} */ - - function errorMsg($msg) { /* {{{ */ - echo "
\n"; - echo $msg; - echo "
\n"; - } /* }}} */ - - static function exitError($pagetitle,$error) { /* {{{ */ - - UI::htmlStartPage($pagetitle); - UI::globalNavigation(); - - print "
"; - print htmlspecialchars($error); - print "
"; - - UI::htmlEndPage(); - - add_log_line(" UI::exitError error=".$error." pagetitle=".$pagetitle); - - exit; - } /* }}} */ - - // navigation flag is used for items links (navigation or selection) - function __printFoldersTree($accessMode, $exclude, $folderID, $currentFolderID=-1, $navigation=false) { /* {{{ */ - global $dms, $user, $form, $settings; - - if ($settings->_expandFolderTree==2){ - - // folder completely open - $is_open=true; - - }else if ($settings->_expandFolderTree==1 && $folderID==$settings->_rootFolderID ){ - - $is_open=true; - - }else{ - // open the tree until the current folder - $is_open=false; - - if ($currentFolderID!=-1){ - - $currentFolder=$dms->getFolder($currentFolderID); - - if (is_object($currentFolder)){ - - $parent=$currentFolder->getParent(); - - while (is_object($parent)){ - if ($parent->getID()==$folderID){ - $is_open=true; - break; - } - $parent=$parent->getParent(); - } - } - } - } - - $folder = $dms->getFolder($folderID); - if (!is_object($folder)) return; - - $subFolders = $folder->getSubFolders(); - $subFolders = SeedDMS_Core_DMS::filterAccess($subFolders, $user, M_READ); - - if ($folderID == $settings->_rootFolderID) print "
    \n"; - - print "
  • \n"; - - if (count($subFolders) > 0){ - print "\n"; - } - else{ - print "\n"; - } - - if ($folder->getAccessMode($user) >= $accessMode) { - - if ($folderID != $currentFolderID){ - - if ($navigation) print ""; - else print "getName())) . "')\">"; - - }else print ""; - - if ($is_open) print "".htmlspecialchars($folder->getName()); - else print "".htmlspecialchars($folder->getName()); - - if ($folderID != $currentFolderID) print "\n"; - else print ""; - - } - else print "".htmlspecialchars($folder->getName())."\n"; - - if ($is_open) print "
      \n"; - else print "\n"; - - if ($folderID == $settings->_rootFolderID) print "
    \n"; - } /* }}} */ - - function __printTreeNavigation($folderid,$showtree){ /* {{{ */ - global $settings; - -?> - -"; - - if ($showtree==1){ - - print ""; - - UI::contentHeading("", true); - UI::contentContainerStart(); - UI::printFoldersTree(M_READ, -1, $settings->_rootFolderID, $folderid, true); - UI::contentContainerEnd(); - - }else{ - - print ""; - - UI::contentHeading("", true); - UI::contentContainerStart(); - UI::contentContainerEnd(); - } - - print ""; - } /* }}} */ - - /** - * Output HTML Code for jumploader - * - * @param string $uploadurl URL where post data is send - * @param integer $folderid id of folder where document is saved - * @param integer $maxfiles maximum number of files allowed to upload - * @param array $fields list of post fields - */ - function __printUploadApplet($uploadurl, $attributes, $maxfiles=0, $fields=array()){ /* {{{ */ - global $settings; -?> - - - - - - - - - - - - - - - - - - -
    -

    -
    -

    -

    - Date: Wed, 21 Jul 2021 15:46:01 +0200 Subject: [PATCH 04/26] no longer use old static methods in UI_Default --- install/class.Install.php | 439 ++++++++++++++++++++++++++++++++++++++ install/index.php | 25 ++- install/install.php | 341 ++--------------------------- install/update.php | 93 +------- 4 files changed, 467 insertions(+), 431 deletions(-) create mode 100644 install/class.Install.php diff --git a/install/class.Install.php b/install/class.Install.php new file mode 100644 index 000000000..b688c9591 --- /dev/null +++ b/install/class.Install.php @@ -0,0 +1,439 @@ +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() { /* {{{ */ + $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)) + echo "
    ".$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 (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 = printCheckError( $settings->check(substr(str_replace('.', '', SEEDDMS_VERSION), 0,2))); + + if (!$hasError) { + // Create database + if (isset($_POST["createDatabase"])) { + $createOK = false; + $errorMsg = ""; + + $connTmp =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 =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(); + } /* }}} */ +} diff --git a/install/index.php b/install/index.php index d796ee502..1015bd572 100644 --- a/install/index.php +++ b/install/index.php @@ -1,23 +1,22 @@ version()); + include("../inc/inc.Settings.php"); $settings = new Settings(); $rootDir = realpath (".."); -$settings->_rootDir = $rootDir.'/'; +if(file_exists($rootDir.'/../www')) + $rootDir = realpath($rootDir.'/..').'/www'; +$settings->_rootDir = str_replace("\\", "/" , $rootDir).'/'; +$settings->_language = 'en_GB'; $theme = "bootstrap"; include("../inc/inc.Language.php"); +include "../languages/en_GB/lang.inc"; include("../inc/inc.ClassUI.php"); +include("class.Install.php"); -UI::htmlStartPage("INSTALL"); -UI::globalBanner(); -UI::contentStart(); -UI::contentHeading("SeedDMS Installation..."); -UI::contentContainerStart(); -echo "

    ".getMLText('settings_install_welcome_title')."

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

    ' . getMLText("settings_start_install") . '

    '; -UI::contentContainerEnd(); -UI::contentEnd(); -UI::htmlEndPage(); -?> +$view = new SeedDMS_View_Install(array('settings'=>$settings, 'session'=>null, 'sitename'=>'SeedDMS', 'printdisclaimer'=>0, 'showmissingtranslations'=>0, 'absbaseprefix'=>'/', 'enabledropfolderlist'=>0, 'enablemenutasks'=>0)); +$view->intro(); diff --git a/install/install.php b/install/install.php index ccc4abcee..c196bbaeb 100644 --- a/install/install.php +++ b/install/install.php @@ -140,7 +140,7 @@ if (!$configDir) { } if (!file_exists($configDir."/ENABLE_INSTALL_TOOL")) { - echo "For installation of SeedDMS, you must create the file conf/ENABLE_INSTALL_TOOL"; + echo "For installation of SeedDMS, you must create the file ".$configDir."ENABLE_INSTALL_TOOL"; exit; } @@ -156,21 +156,24 @@ $settings = new Settings(); $settings->load($configDir."/settings.xml"); $rootDir = realpath (".."); -$rootDir = str_replace ("\\", "/" , $rootDir) . "/"; $installPath = realpath ("install.php"); $installPath = str_replace ("\\", "/" , $installPath); $tmpToDel = str_replace ($rootDir, "" , $installPath); -$httpRoot = str_replace ($tmpToDel, "" , $_SERVER["REQUEST_URI"]); +$httpRoot = str_replace ($tmpToDel, "" , $_SERVER["SCRIPT_NAME"]).'/'; +/* Correct rootDir to ensure it points to 'www' instead of the versioned + * seeddms dir. + */ +if(file_exists($rootDir.'/../www')) + $rootDir = realpath($rootDir.'/..').'/www'; +$rootDir = str_replace ("\\", "/" , $rootDir) . "/"; do { $httpRoot = str_replace ("//", "/" , $httpRoot, $count); } while ($count<>0); -if(!$settings->_rootDir) - $settings->_rootDir = $rootDir; -elseif(realpath ("..") != realpath($settings->_rootDir)) { // Fix rootDir if required +if($rootDir != $settings->_rootDir) { $msg = "Your Root directory has been modified to fit your installation path!"; - $settings->_rootDir = realpath ("..")."/"; } +$settings->_rootDir = $rootDir; if(!$settings->_contentDir) { $settings->_contentDir = realpath($settings->_rootDir."..") . '/data/'; @@ -195,327 +198,9 @@ $theme = "bootstrap"; include("../inc/inc.Language.php"); include "../languages/en_GB/lang.inc"; include("../inc/inc.ClassUI.php"); +include("class.Install.php"); +$view = new SeedDMS_View_Install(array('settings'=>$settings, 'session'=>null, 'sitename'=>'SeedDMS', 'printdisclaimer'=>0, 'showmissingtranslations'=>0, 'absbaseprefix'=>'/', 'enabledropfolderlist'=>0, 'enablemenutasks'=>0, 'configdir'=>$configDir)); +$view->install(); -UI::htmlStartPage("INSTALL"); -UI::globalBanner(); -UI::contentStart(); -UI::contentHeading("SeedDMS Installation for version ".SEEDDMS_VERSION); -if(isset($msg)) - echo "
    ".$msg."
    "; -UI::contentContainerStart(); - - -/** - * Show phpinfo - */ -if (isset($_GET['phpinfo'])) { - echo '' . getMLText("back") . ''; - phpinfo(); - UI::contentContainerEnd(); - UI::contentEnd(); - UI::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") . ''; - } - UI::contentContainerEnd(); - UI::contentEnd(); - UI::htmlEndPage(); - exit(); -} /* }}} */ - -/** - * Check System - */ -if (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 = printCheckError( $settings->check(substr(str_replace('.', '', SEEDDMS_VERSION), 0,2))); - - if (!$hasError) { - // Create database - if (isset($_POST["createDatabase"])) { - $createOK = false; - $errorMsg = ""; - - $connTmp =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 =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 -UI::contentContainerEnd(); -UI::contentEnd(); -UI::htmlEndPage(); ?> diff --git a/install/update.php b/install/update.php index d25a48b71..b0ef88f78 100644 --- a/install/update.php +++ b/install/update.php @@ -37,94 +37,7 @@ $theme = "bootstrap"; require_once("../inc/inc.Language.php"); include "../languages/en_GB/lang.inc"; require_once("../inc/inc.ClassUI.php"); +include("class.Install.php"); -UI::htmlStartPage('Database update'); -UI::globalBanner(); -UI::contentStart(); -UI::contentHeading("SeedDMS Installation for version ".$_GET['version']); -UI::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 -UI::contentContainerEnd(); -UI::contentEnd(); -UI::htmlEndPage(); -?> +$view = new SeedDMS_View_Install(array('settings'=>$settings, 'session'=>null, 'sitename'=>'SeedDMS', 'printdisclaimer'=>0, 'showmissingtranslations'=>0, 'absbaseprefix'=>'/', 'enabledropfolderlist'=>0, 'enablemenutasks'=>0)); +$view->update(); From 79292956c5eb2ab9c48375d2900904867776b4c0 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Wed, 21 Jul 2021 15:48:42 +0200 Subject: [PATCH 05/26] better error checking --- views/bootstrap/class.Bootstrap.php | 5 +++-- views/bootstrap4/class.Bootstrap4.php | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/views/bootstrap/class.Bootstrap.php b/views/bootstrap/class.Bootstrap.php index c6a02bf0c..ed97c1432 100644 --- a/views/bootstrap/class.Bootstrap.php +++ b/views/bootstrap/class.Bootstrap.php @@ -178,7 +178,8 @@ background-image: linear-gradient(to bottom, #882222, #111111);; $tmp['action'] = 'webrootjs'; if(isset($tmp['formtoken'])) unset($tmp['formtoken']); - echo ''."\n"; + if(!empty($this->params['class'])) + echo ''."\n"; echo ''."\n"; if($this->params['enablemenutasks'] && isset($this->params['user']) && $this->params['user']) { $this->addFooterJS('SeedDMSTask.run();'); @@ -285,7 +286,7 @@ background-image: linear-gradient(to bottom, #882222, #111111);; echo "
    \n"; echo " \n"; diff --git a/views/bootstrap4/class.Bootstrap4.php b/views/bootstrap4/class.Bootstrap4.php index d7e668aa7..2104311d2 100644 --- a/views/bootstrap4/class.Bootstrap4.php +++ b/views/bootstrap4/class.Bootstrap4.php @@ -181,7 +181,8 @@ background-image: linear-gradient(to bottom, #882222, #111111);; $tmp['action'] = 'webrootjs'; if(isset($tmp['formtoken'])) unset($tmp['formtoken']); - echo ''."\n"; + if(!empty($this->params['class'])) + echo ''."\n"; echo ''."\n"; if($this->params['enablemenutasks'] && isset($this->params['user']) && $this->params['user']) { $this->addFooterJS('SeedDMSTask.run();'); From c16246fcfbe315091b7d0fabdafa161763027c98 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Fri, 23 Jul 2021 12:06:50 +0200 Subject: [PATCH 06/26] nicer formatting --- doc/README.Install.md | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/doc/README.Install.md b/doc/README.Install.md index 42541f21e..05ddf21fc 100644 --- a/doc/README.Install.md +++ b/doc/README.Install.md @@ -41,8 +41,18 @@ The fastes way to get SeedDMS running is by unpacking the archive Let's assume you use seeddms-quickstart-5.1.10.tar.gz. It will create a new directory `seeddms51x` containing everything you need to run SeedDMS with sqlite3. + +Setting up the web server +-------------------------- + +First you will need to set up your web server. Here, we will only focus +on apache. Either let the document root of your web server point to the directory `www` -below `seeddms51x` or add an alias. For apache this could be like +below `seeddms51x` + +DocumentRoot /var/www/seeddms51x/www + +or add an alias. For apache this could be like Alias /seeddms51x //seeddms51x/www @@ -52,11 +62,16 @@ Alias /mydms //seeddms51x/www Do not set the DocumentRoot or Alias to the `seeddms51x` directory, because this will allow anybody to access -your `data` and `conf` directory. This is a major security risk. +your `data` and `conf` directory if it is not secured by a .htaccess file. +This is a major security risk. Make sure that the subdirectory `seeddms51x/data` and the configuration file `seeddms51/conf/settings.xml` is writeable by your web server. All other -directories must just be readable by your web server. +directories can be just readable by your web server, though it is advisable +to even protect them from writing. + +Adjusting the configuration of SeedDMS +--------------------------------------- In the next step you need to adjust the configuration file in `seeddms51x/conf/settings.xml`. Open the file in your favorite text editor @@ -71,7 +86,7 @@ It will first ask to unlock the installer by creating a file `ENABLE_INSTALL_TOOL` in the diretory `seeddms51x/conf/`. Change all paths by replacing `/home/www-data` with your base directory where you put seeddms51x. Set httpRoot to '/' (if the document root points to`seeddms51x/www`) or -'/seeddms51x' (if you have set an alias like described above). +'/seeddms51x' (if you have set an alias `seeddms51x` like described above). Once your configuration is done, save it, remove the file `ENABLE_INSTALL_TOOL` and point your browser to From e29976bf25c306995f64b5b4ea53e5e6af387195 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Fri, 23 Jul 2021 12:07:30 +0200 Subject: [PATCH 07/26] check for more php modules and > 7.2.5 --- inc/inc.ClassSettings.php | 56 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 53 insertions(+), 3 deletions(-) diff --git a/inc/inc.ClassSettings.php b/inc/inc.ClassSettings.php index fddfe052d..e8ee320c5 100644 --- a/inc/inc.ClassSettings.php +++ b/inc/inc.ClassSettings.php @@ -1273,6 +1273,7 @@ class Settings { /* {{{ */ // TODO // $this->_coreDir +/* if($this->_coreDir) { if (!file_exists($this->_coreDir ."Core.php")) { $result["coreDir"] = array( @@ -1293,7 +1294,7 @@ class Settings { /* {{{ */ ); } } - +*/ // $this->_httpRoot $tmp = $this->curPageURL(); $tmp = str_replace ("install.php", "" , $tmp); @@ -1444,7 +1445,7 @@ class Settings { /* {{{ */ if(!empty($this->_coreDir)) require_once($this->_coreDir.'/Core.php'); else - require_once('SeedDMS/Core.php'); + require_once($this->_rootDir.'../pear/SeedDMS/Core.php'); $tmpcore = new SeedDMS_Core_DMS(null, $this->_contentDir); $db = new SeedDMS_Core_DatabaseAccess($this->_dbDriver, $this->_dbHostname, $this->_dbUser, $this->_dbPass, $this->_dbDatabase); if(!$db->connect()) { @@ -1507,7 +1508,7 @@ class Settings { /* {{{ */ } // Check PHP version - if (version_compare(PHP_VERSION, '5.6.38') < 0) { + if (version_compare(PHP_VERSION, '7.2.5') < 0) { $result["php_version"] = array( "status" => "versiontolow", "type" => "error", @@ -1517,6 +1518,15 @@ class Settings { /* {{{ */ // Check PHP configuration $loaded_extensions = get_loaded_extensions(); + // xml + if (!in_array("xml", $loaded_extensions)) { + $result["php_xml"] = array( + "status" => "notfound", + "type" => "error", + "suggestion" => "activate_php_extension" + ); + } + // gd2 if (!in_array("gd", $loaded_extensions)) { $result["php_gd2"] = array( @@ -1535,6 +1545,42 @@ class Settings { /* {{{ */ ); } + // json + if (!in_array("json", $loaded_extensions)) { + $result["php_json"] = array( + "status" => "notfound", + "type" => "error", + "suggestion" => "activate_php_extension" + ); + } + + // zip + if (!in_array("zip", $loaded_extensions)) { + $result["php_zip"] = array( + "status" => "notfound", + "type" => "error", + "suggestion" => "activate_php_extension" + ); + } + + // fileinfo + if (!in_array("fileinfo", $loaded_extensions)) { + $result["php_fileinfo"] = array( + "status" => "notfound", + "type" => "error", + "suggestion" => "activate_php_extension" + ); + } + + // sqlite3 + if (!in_array("sqlite3", $loaded_extensions)) { + $result["php_sqlite3"] = array( + "status" => "notfound", + "type" => "error", + "suggestion" => "activate_php_extension" + ); + } + // database if (!in_array('pdo_'.$this->_dbDriver, $loaded_extensions)) { $result["php_dbDriver"] = array( @@ -1558,6 +1604,7 @@ class Settings { /* {{{ */ */ // Check for HTTP/WebDAV/Server.php + /* if (!Settings::findInIncPath('HTTP/WebDAV/Server.php')) { $result["pear_webdav"] = array( "status" => "notfound", @@ -1565,8 +1612,10 @@ class Settings { /* {{{ */ "suggestion" => "install_pear_package_webdav" ); } + */ // Check for Zend/Search/Lucene.php + /* if (!Settings::findInIncPath('Zend/Search/Lucene.php')) { $result["zendframework"] = array( "status" => "notfound", @@ -1574,6 +1623,7 @@ class Settings { /* {{{ */ "suggestion" => "install_zendframework" ); } + */ return $result; } /* }}} */ From 6a72b3c0fa735743caa1a0d38ee8eef29bc8d738 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Fri, 23 Jul 2021 12:08:26 +0200 Subject: [PATCH 08/26] extra _extraPath if not empty, add rootDir.'../pear' to include path --- inc/inc.Settings.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/inc/inc.Settings.php b/inc/inc.Settings.php index df11ccada..1e7d8876a 100644 --- a/inc/inc.Settings.php +++ b/inc/inc.Settings.php @@ -35,11 +35,12 @@ if(!trim($settings->_encryptionKey)) { $settings->save(); } -if(isset($settings->_extraPath)) +ini_set('include_path', $settings->_rootDir.'pear'. PATH_SEPARATOR .ini_get('include_path')); +if(!empty($settings->_extraPath)) { ini_set('include_path', $settings->_extraPath. PATH_SEPARATOR .ini_get('include_path')); - +} /* composer is installed in pear directory */ -require_once 'vendor/autoload.php'; +require_once $settings->_rootDir.'../pear/vendor/autoload.php'; if(isset($settings->_maxExecutionTime)) { if (php_sapi_name() !== "cli") { @@ -67,3 +68,7 @@ if (function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc()) { * relative to it. */ ini_set('include_path', $settings->_rootDir. PATH_SEPARATOR .ini_get('include_path')); +/* Add root Dir.'../pear'. Needed because the SeedDMS_Core, etc. are included + * relative to it. + */ +ini_set('include_path', $settings->_rootDir.'../pear'. PATH_SEPARATOR .ini_get('include_path')); From a26916243caae9bf746c8da6beb79bd8cf66edd6 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Fri, 23 Jul 2021 12:09:07 +0200 Subject: [PATCH 09/26] move lots of functions into view --- install/class.Install.php | 540 +++++++++++++++++++++----------------- install/install.php | 61 ----- 2 files changed, 297 insertions(+), 304 deletions(-) diff --git a/install/class.Install.php b/install/class.Install.php index b688c9591..a853e65ea 100644 --- a/install/class.Install.php +++ b/install/class.Install.php @@ -2,6 +2,62 @@ include("../views/bootstrap/class.Bootstrap.php"); class SeedDMS_View_Install extends SeedDMS_Theme_Style { + protected function printError($error) { /* {{{ */ + print "
    \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(); @@ -66,278 +122,276 @@ echo '

    ' . getMLText("settings_start_install") . '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 = printCheckError( $settings->check(substr(str_replace('.', '', SEEDDMS_VERSION), 0,2))); - - if (!$hasError) { - // Create database - if (isset($_POST["createDatabase"])) { - $createOK = false; - $errorMsg = ""; - - $connTmp =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] . "
    "; - } - } - } + /** + * Check System + */ + if ($this->printCheckError( $settings->checkSystem())) { /* {{{ */ + if (function_exists("apache_get_version")) { + echo "
    Apache version: " . apache_get_version(); } - // error ? - if (empty($errorMsg)) - $createOK = true; + echo "
    PHP version: " . phpversion(); - $connTmp = null; + echo "
    PHP include path: " . ini_get('include_path'); - // Show error - if (!$createOK) { - echo $errorMsg; - $hasError = true; - } - } // create database + echo '
    '; + echo '
    '; + echo '' . getMLText("refresh") . ''; + echo ' - '; + echo '' . getMLText("version_info") . ''; - if (!$hasError) { + exit; + } /* }}} */ - // Save settings - $settings->save(); + if (isset($_POST["action"])) $action=$_POST["action"]; + else if (isset($_GET["action"])) $action=$_GET["action"]; + else $action=NULL; - $needsupdate = false; - $connTmp =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(); + $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"]; - 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(isset($settings->_extraPath)) + ini_set('include_path', $settings->_extraPath. PATH_SEPARATOR .ini_get('include_path')); - 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.

    "; + /** + * 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] . "
    "; } } - } 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; + // 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.

    "; + } } - } else { - print "

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

    "; } } - } - } - // Back link - echo '
    '; - echo '
    '; -// echo '' . getMLText("back") . ''; + // Back link + echo '
    '; + echo '
    '; + // echo '' . getMLText("back") . ''; -} + } /* }}} */ -if($showform) { + if($showform) { /* {{{ */ - /** - * Set parameters - */ - ?> + /** + * Set parameters + */ + ?>
    - - - - "> - - - - "> - - - - "> - - - - "> - - - - "> - - - - "> - - - - "> - - - - "> - - - - "> - - - +
    :
    :
    :
    :
    :
    :
    :
    :
    :
    + + + "> + + + + "> + + + + "> + + + + "> + + + + "> + + + + "> + + + + + "> + + + - - - "> - - - - "> - - - - "> - - - - "> - - - - "> - - - - - - - - - - - - - -
    :
    :
    :
    :
    :
    :
    :
    :
    :
    :
    :
    :
    :
    " />
    + + + "> + : + + + "> + : + + + "> + : + + + "> + : + + + "> + : + + + + + + : + + + + + " /> + +
    - _printDisclaimer = false; + $settings->_footNote = false; -*/ - -// just remove info for web page installation -$settings->_printDisclaimer = false; -$settings->_footNote = false; -// end of the page + // end of the page $this->contentContainerEnd(); $this->contentEnd(); $this->htmlEndPage(); diff --git a/install/install.php b/install/install.php index c196bbaeb..ea43f076f 100644 --- a/install/install.php +++ b/install/install.php @@ -46,66 +46,6 @@ if (!file_exists("settings.xml.template_install")) { exit; } -/** - * Functions - */ -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; -} /* }}} */ - -function printError($error) { /* {{{ */ - print "
    \n"; - print $error; - print "
    "; -} /* }}} */ - -function printWarning($error) { /* {{{ */ - print "
    "; - print "Warning
    "; - print $error; - print "
    "; -} /* }}} */ - -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') - printError($errorMes); - else - printWarning($errorMes); - } - - return $hasError; -} /* }}} */ - function fileExistsInIncludePath($file) { /* {{{ */ $paths = explode(PATH_SEPARATOR, get_include_path()); $found = false; @@ -203,4 +143,3 @@ include("class.Install.php"); $view = new SeedDMS_View_Install(array('settings'=>$settings, 'session'=>null, 'sitename'=>'SeedDMS', 'printdisclaimer'=>0, 'showmissingtranslations'=>0, 'absbaseprefix'=>'/', 'enabledropfolderlist'=>0, 'enablemenutasks'=>0, 'configdir'=>$configDir)); $view->install(); -?> From cc9835e3a6b3ddf9fedbd1c5a3d30d441e873866 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Fri, 23 Jul 2021 13:39:59 +0200 Subject: [PATCH 10/26] add pear dir to include path --- inc/inc.Settings.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/inc/inc.Settings.php b/inc/inc.Settings.php index 1e7d8876a..047432df9 100644 --- a/inc/inc.Settings.php +++ b/inc/inc.Settings.php @@ -39,8 +39,9 @@ ini_set('include_path', $settings->_rootDir.'pear'. PATH_SEPARATOR .ini_get('inc if(!empty($settings->_extraPath)) { ini_set('include_path', $settings->_extraPath. PATH_SEPARATOR .ini_get('include_path')); } -/* composer is installed in pear directory */ -require_once $settings->_rootDir.'../pear/vendor/autoload.php'; +/* composer is installed in pear directory, but install tool does not need it */ +if(!defined("SEEDDMS_INSTALL")) + require_once $settings->_rootDir.'../pear/vendor/autoload.php'; if(isset($settings->_maxExecutionTime)) { if (php_sapi_name() !== "cli") { From 9c7ce4116388aeaa53588ab06945dd1db04aa87d Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Fri, 23 Jul 2021 13:40:16 +0200 Subject: [PATCH 11/26] msg can be passed to install method --- install/class.Install.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install/class.Install.php b/install/class.Install.php index a853e65ea..97db1873b 100644 --- a/install/class.Install.php +++ b/install/class.Install.php @@ -72,7 +72,7 @@ echo '

    ' . getMLText("settings_start_install") . 'htmlEndPage(); } /* }}} */ - public function install() { /* {{{ */ + public function install($msg) { /* {{{ */ $settings = $this->params['settings']; $configDir = $this->params['configdir']; @@ -81,7 +81,7 @@ echo '

    ' . getMLText("settings_start_install") . 'contentStart(); $this->contentHeading("SeedDMS Installation for version ".SEEDDMS_VERSION); if(isset($msg)) - echo "

    ".$msg."
    "; + $this->warningMsg($msg); $this->contentContainerStart(); From a027f1f70dd29c339af1f21a979d353d3e177652 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Fri, 23 Jul 2021 13:40:42 +0200 Subject: [PATCH 12/26] check if sqlite db has propper path --- install/install.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/install/install.php b/install/install.php index ea43f076f..a016048a9 100644 --- a/install/install.php +++ b/install/install.php @@ -110,12 +110,13 @@ do { $httpRoot = str_replace ("//", "/" , $httpRoot, $count); } while ($count<>0); +$msg = ''; if($rootDir != $settings->_rootDir) { $msg = "Your Root directory has been modified to fit your installation path!"; } $settings->_rootDir = $rootDir; -if(!$settings->_contentDir) { +if(!$settings->_contentDir || !is_dir($settings->_contentDir)) { $settings->_contentDir = realpath($settings->_rootDir."..") . '/data/'; $settings->_luceneDir = $settings->_contentDir . 'lucene/'; $settings->_stagingDir = $settings->_contentDir . 'staging/'; @@ -126,6 +127,11 @@ if(!$settings->_contentDir) { $settings->_cacheDir = $settings->_contentDir . 'cache/'; } } +if($settings->_dbDriver == 'sqlite') { + if(!$settings->_dbDatabase || !file_exists($settings->_dbDatabase)) { + $settings->_dbDatabase = $settings->_contentDir.'content.db'; + } +} $settings->_httpRoot = $httpRoot; if(isset($settings->_extraPath)) @@ -141,5 +147,5 @@ include("../inc/inc.ClassUI.php"); include("class.Install.php"); $view = new SeedDMS_View_Install(array('settings'=>$settings, 'session'=>null, 'sitename'=>'SeedDMS', 'printdisclaimer'=>0, 'showmissingtranslations'=>0, 'absbaseprefix'=>'/', 'enabledropfolderlist'=>0, 'enablemenutasks'=>0, 'configdir'=>$configDir)); -$view->install(); +$view->install($msg); From 03eb842f8ef5e75138d0ba16df9499aeb57a2b84 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Fri, 23 Jul 2021 13:41:04 +0200 Subject: [PATCH 13/26] remove extra '/' in referuri --- op/op.Login.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/op/op.Login.php b/op/op.Login.php index d6d1dde6a..541ccb936 100644 --- a/op/op.Login.php +++ b/op/op.Login.php @@ -97,7 +97,7 @@ if(!$controller->run()) { $user = $controller->getUser(); if (isset($referuri) && strlen($referuri)>0) { - header("Location: " . getBaseUrl() . "/" . $referuri); + header("Location: " . getBaseUrl() . $referuri); } else { header("Location: ".$settings->_httpRoot.(isset($settings->_siteDefaultPage) && strlen($settings->_siteDefaultPage)>0 ? $settings->_siteDefaultPage : "out/out.ViewFolder.php?folderid=".($user->getHomeFolder() ? $user->getHomeFolder() : $settings->_rootFolderID))); From b9f4d7b0ba8f3519bf9994fea5fa143dc54bb353 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Fri, 23 Jul 2021 14:03:44 +0200 Subject: [PATCH 14/26] issue a message if no attributes are defined --- views/bootstrap/class.EditAttributes.php | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/views/bootstrap/class.EditAttributes.php b/views/bootstrap/class.EditAttributes.php index 45be4b2ba..6a969236b 100644 --- a/views/bootstrap/class.EditAttributes.php +++ b/views/bootstrap/class.EditAttributes.php @@ -52,8 +52,8 @@ class SeedDMS_View_EditAttributes extends SeedDMS_Theme_Style { contentContainerStart(); if($attrdefs) { + $this->contentContainerStart(); foreach($attrdefs as $attrdef) { $arr = $this->callHook('editDocumentContentAttribute', $version, $attrdef); if(is_array($arr)) { @@ -66,17 +66,19 @@ class SeedDMS_View_EditAttributes extends SeedDMS_Theme_Style { $this->formField(htmlspecialchars($attrdef->getName()), $this->getAttributeEditField($attrdef, $version->getAttribute($attrdef))); } } - } - $arrs = $this->callHook('addDocumentContentAttributes', $version); - if(is_array($arrs)) { - foreach($arrs as $arr) { - $this->formField($arr[0], $arr[1], isset($arr[2]) ? $arr[2] : null); + $arrs = $this->callHook('addDocumentContentAttributes', $version); + if(is_array($arrs)) { + foreach($arrs as $arr) { + $this->formField($arr[0], $arr[1], isset($arr[2]) ? $arr[2] : null); + } + } elseif(is_string($arrs)) { + echo $arrs; } - } elseif(is_string($arrs)) { - echo $arrs; + $this->contentContainerEnd(); + $this->formSubmit(" ".getMLText('save')); + } else { + $this->warningMsg(getMLText('no_attributes_defined')); } - $this->contentContainerEnd(); - $this->formSubmit(" ".getMLText('save')); ?> Date: Wed, 4 Aug 2021 14:19:11 +0200 Subject: [PATCH 15/26] get dir of config file even if config file is set in environment --- inc/inc.ClassSettings.php | 7 +++++++ inc/inc.Settings.php | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/inc/inc.ClassSettings.php b/inc/inc.ClassSettings.php index e8ee320c5..249401409 100644 --- a/inc/inc.ClassSettings.php +++ b/inc/inc.ClassSettings.php @@ -23,6 +23,7 @@ class Settings { /* {{{ */ // Config File Path var $_configFilePath = null; + var $_configFileDir = ''; // Fields not shown in gui var $_hiddenConfFields = ''; @@ -348,6 +349,8 @@ class Settings { /* {{{ */ exit; } } + $this->_configFileDir = dirname($this->_configFilePath); + if(!$this->load($configFilePath)) { echo "Your configuration contains errors."; exit; @@ -1167,6 +1170,10 @@ class Settings { /* {{{ */ * @return NULL|string config directory */ static function getConfigDir() { /* {{{ */ + if(defined("SEEDDMS_CONFIG_FILE")) + return dirname(SEEDDMS_CONFIG_FILE); + elseif(getenv("SEEDDMS_CONFIG_FILE")) + return dirname(getenv("SEEDDMS_CONFIG_FILE")); $_tmp = dirname($_SERVER['SCRIPT_FILENAME']); $_arr = preg_split('/\//', rtrim(str_replace('\\', '/', $_tmp))); $configDir = null; diff --git a/inc/inc.Settings.php b/inc/inc.Settings.php index 047432df9..659653cd0 100644 --- a/inc/inc.Settings.php +++ b/inc/inc.Settings.php @@ -25,7 +25,7 @@ elseif(getenv("SEEDDMS_CONFIG_FILE")) $settings = new Settings(getenv("SEEDDMS_CONFIG_FILE")); else $settings = new Settings(); -if(!defined("SEEDDMS_INSTALL") && file_exists(dirname($settings->_configFilePath)."/ENABLE_INSTALL_TOOL")) { +if(!defined("SEEDDMS_INSTALL") && file_exists($settings->_configFileDir."/ENABLE_INSTALL_TOOL")) { die("SeedDMS won't run unless your remove the file ENABLE_INSTALL_TOOL from your configuration directory."); } From cd9d1fe25f3f37d061d61f37a92e0130c9eb0036 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Thu, 5 Aug 2021 08:39:39 +0200 Subject: [PATCH 16/26] fix hard coded version number --- SeedDMS_Core/Core/inc.ClassDMS.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SeedDMS_Core/Core/inc.ClassDMS.php b/SeedDMS_Core/Core/inc.ClassDMS.php index 3988f2b08..58171e8d1 100644 --- a/SeedDMS_Core/Core/inc.ClassDMS.php +++ b/SeedDMS_Core/Core/inc.ClassDMS.php @@ -404,7 +404,7 @@ class SeedDMS_Core_DMS { $this->lasterror = ''; $this->version = '@package_version@'; if($this->version[0] == '@') - $this->version = '5.1.21'; + $this->version = '5.1.23'; } /* }}} */ /** From 62d92412760a899cdb52b174e92c09ede54aa215 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Thu, 5 Aug 2021 08:40:13 +0200 Subject: [PATCH 17/26] catch exeption when opening database connection --- SeedDMS_Core/Core/inc.DBAccessPDO.php | 34 +++++++++++++++------------ 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/SeedDMS_Core/Core/inc.DBAccessPDO.php b/SeedDMS_Core/Core/inc.DBAccessPDO.php index e48f5f3d5..09b797e28 100644 --- a/SeedDMS_Core/Core/inc.DBAccessPDO.php +++ b/SeedDMS_Core/Core/inc.DBAccessPDO.php @@ -283,22 +283,26 @@ class SeedDMS_Core_DatabaseAccess { $dsn = $this->_driver.":".$this->_database; break; } - /** @noinspection PhpUndefinedVariableInspection */ - $this->_conn = new PDO($dsn, $this->_user, $this->_passw); - if (!$this->_conn) - return false; + try { + /** @noinspection PhpUndefinedVariableInspection */ + $this->_conn = new PDO($dsn, $this->_user, $this->_passw); + if (!$this->_conn) + return false; - switch($this->_driver) { - case 'mysql': - $this->_conn->exec('SET NAMES utf8'); - /* Turn this on if you want strict checking of default values, etc. */ -// $this->_conn->exec("SET SESSION sql_mode = 'STRICT_TRANS_TABLES'"); - /* The following is the default on Ubuntu 16.04 */ -// $this->_conn->exec("SET SESSION sql_mode = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'"); - break; - case 'sqlite': - $this->_conn->exec('PRAGMA foreign_keys = ON'); - break; + switch($this->_driver) { + case 'mysql': + $this->_conn->exec('SET NAMES utf8'); + /* Turn this on if you want strict checking of default values, etc. */ + /* $this->_conn->exec("SET SESSION sql_mode = 'STRICT_TRANS_TABLES'"); */ + /* The following is the default on Ubuntu 16.04 */ + /* $this->_conn->exec("SET SESSION sql_mode = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'"); */ + break; + case 'sqlite': + $this->_conn->exec('PRAGMA foreign_keys = ON'); + break; + } + } catch (Exception $e) { + return false; } if($this->_useviews) { $tmp = $this->ViewList(); From 817433638b64508ef7f73ba086d3ae67f966fceb Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Thu, 5 Aug 2021 08:40:49 +0200 Subject: [PATCH 18/26] doNotCheckVersion must be doNotCheckDBVersion --- inc/inc.ClassSettings.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/inc.ClassSettings.php b/inc/inc.ClassSettings.php index 249401409..a6907b4f1 100644 --- a/inc/inc.ClassSettings.php +++ b/inc/inc.ClassSettings.php @@ -1001,7 +1001,7 @@ class Settings { /* {{{ */ $this->setXMLAttributValue($node, "dbDatabase", $this->_dbDatabase); $this->setXMLAttributValue($node, "dbUser", $this->_dbUser); $this->setXMLAttributValue($node, "dbPass", $this->_dbPass); - $this->setXMLAttributValue($node, "doNotCheckVersion", $this->_doNotCheckDBVersion); + $this->setXMLAttributValue($node, "doNotCheckDBVersion", $this->_doNotCheckDBVersion); // XML Path: /configuration/system/smtp $node = $this->getXMLNode($xml, '/configuration/system', 'smtp'); From 0f792340123b97e9c88d65c3ef97dea03b4e4fa2 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Thu, 5 Aug 2021 08:41:16 +0200 Subject: [PATCH 19/26] show versions if database version doesn't match seeddms version --- inc/inc.DBInit.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/inc/inc.DBInit.php b/inc/inc.DBInit.php index 4dad2c87d..3a44c2612 100644 --- a/inc/inc.DBInit.php +++ b/inc/inc.DBInit.php @@ -49,6 +49,9 @@ $dms = new SeedDMS_Core_DMS($db, $settings->_contentDir.$settings->_contentOffse if(!$settings->_doNotCheckDBVersion && !$dms->checkVersion()) { echo "Database update needed."; + if($v = $dms->getDBVersion()) { + echo " Database has version ".$v['major'].".".$v['minor'].".".$v['subminor']." but this is SeedDMS ".$dms->version."."; + } exit; } From bb77e2d62d35a111ca2c7ef92ba7d9eaf787b5d5 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Thu, 5 Aug 2021 08:41:51 +0200 Subject: [PATCH 20/26] fix typo in echo --- install/install.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install/install.php b/install/install.php index a016048a9..24c5e0cf6 100644 --- a/install/install.php +++ b/install/install.php @@ -80,7 +80,7 @@ if (!$configDir) { } if (!file_exists($configDir."/ENABLE_INSTALL_TOOL")) { - echo "For installation of SeedDMS, you must create the file ".$configDir."ENABLE_INSTALL_TOOL"; + echo "For installation of SeedDMS, you must create the file ".$configDir."/ENABLE_INSTALL_TOOL"; exit; } From 8b34c4f82e039109a539753207e4fd79166e9a66 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Fri, 6 Aug 2021 08:33:34 +0200 Subject: [PATCH 21/26] fix width in task for creating preview --- inc/inc.Tasks.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/inc.Tasks.php b/inc/inc.Tasks.php index d0a7d688b..6063b9039 100644 --- a/inc/inc.Tasks.php +++ b/inc/inc.Tasks.php @@ -410,7 +410,7 @@ class SeedDMS_Task_Preview_Process_Folder { /* {{{ */ } $files = $document->getDocumentFiles(); foreach($files as $file) { - $this->previewer->createPreview($file, $width['detail'], $isnew); + $this->previewer->createPreview($file, $width, $isnew); if($isnew){ $this->logger->log('Task \'preview\': created preview ('.$width.'px) for attachment of document '.$document->getId().':'.$file->getId(), PEAR_LOG_INFO); } From 46040dce7eff0501e98037f4fe85455dcb442fd8 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Fri, 6 Aug 2021 08:34:19 +0200 Subject: [PATCH 22/26] add '/www' to $myincpath --- utils/schedulercli.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/schedulercli.php b/utils/schedulercli.php index 1d55247c3..1161fe6de 100644 --- a/utils/schedulercli.php +++ b/utils/schedulercli.php @@ -1,7 +1,7 @@ Date: Fri, 6 Aug 2021 08:58:03 +0200 Subject: [PATCH 23/26] fix adding of multiple favicons or logos --- views/bootstrap/class.Bootstrap.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/views/bootstrap/class.Bootstrap.php b/views/bootstrap/class.Bootstrap.php index ed97c1432..849faef0a 100644 --- a/views/bootstrap/class.Bootstrap.php +++ b/views/bootstrap/class.Bootstrap.php @@ -148,7 +148,10 @@ background-image: linear-gradient(to bottom, #882222, #111111);; } /* }}} */ function htmlAddHeader($head, $type='js') { /* {{{ */ - $this->extraheader[$type] .= $head; + if($type == 'logo' || $type == 'favicon') + $this->extraheader[$type] = $head; + else + $this->extraheader[$type] .= $head; } /* }}} */ function htmlAddJsHeader($script) { /* {{{ */ From 749f7a2fb1e4cac25da144d9c6fab11af6a61b7d Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Fri, 6 Aug 2021 09:19:54 +0200 Subject: [PATCH 24/26] revert change of $myincpath --- utils/schedulercli.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/schedulercli.php b/utils/schedulercli.php index 1161fe6de..1d55247c3 100644 --- a/utils/schedulercli.php +++ b/utils/schedulercli.php @@ -1,7 +1,7 @@ Date: Tue, 17 Aug 2021 17:55:55 +0200 Subject: [PATCH 25/26] include Previewer --- views/bootstrap/class.RemoveUserFromProcesses.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/views/bootstrap/class.RemoveUserFromProcesses.php b/views/bootstrap/class.RemoveUserFromProcesses.php index e76f3bffe..ce9c28ac8 100644 --- a/views/bootstrap/class.RemoveUserFromProcesses.php +++ b/views/bootstrap/class.RemoveUserFromProcesses.php @@ -16,6 +16,11 @@ */ //require_once("class.Bootstrap.php"); +/** + * Include class to preview documents + */ +require_once("SeedDMS/Preview.php"); + /** * Class which outputs the html page for RemoveUserFromProcesses view * From 73d27bc82bba0c0a2e33dc5bb312c18d11a88260 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Tue, 17 Aug 2021 20:54:57 +0200 Subject: [PATCH 26/26] schedule next run before executing current run --- utils/schedulercli.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/utils/schedulercli.php b/utils/schedulercli.php index 1d55247c3..e0f0ef6c6 100644 --- a/utils/schedulercli.php +++ b/utils/schedulercli.php @@ -84,10 +84,14 @@ foreach($tasks as $task) { if(method_exists($taskobj, 'execute')) { if(!$task->getDisabled() && $task->isDue()) { if($mode == 'run') { - echo get_class($task); + /* Schedule the next run right away to prevent a second execution + * of the task when the cron job of the scheduler is called before + * the last run was finished. The task itself can still be scheduled + * to fast, but this is up to the admin of seeddms. + */ + $task->updateLastNextRun(); if($taskobj->execute($task)) { add_log_line("Execution of task ".$task->getExtension()."::".$task->getTask()." successful."); - $task->updateLastNextRun(); } else { add_log_line("Execution of task ".$task->getExtension()."::".$task->getTask()." failed, task has been disabled.", PEAR_LOG_ERR); $task->setDisabled(1);