From: <al...@us...> - 2007-08-18 22:00:42
|
Revision: 499 http://sciret.svn.sourceforge.net/sciret/?rev=499&view=rev Author: alpeb Date: 2007-08-18 14:46:38 -0700 (Sat, 18 Aug 2007) Log Message: ----------- killed ConfigNotWritable view. Show missing requirements in the view where the db credentials are shown. Also have additional checks: for db version and check if upload dirs are writable Modified Paths: -------------- branches/release-candidates/sciret-1.2/actions/Install.php Modified: branches/release-candidates/sciret-1.2/actions/Install.php =================================================================== --- branches/release-candidates/sciret-1.2/actions/Install.php 2007-08-18 21:45:35 UTC (rev 498) +++ branches/release-candidates/sciret-1.2/actions/Install.php 2007-08-18 21:46:38 UTC (rev 499) @@ -17,13 +17,6 @@ function dispatch() { - // is_writable() not working under windows - if (!$fp = @fopen(dirname(__FILE__).'/../config.php', 'a')) { - Library::redirect(Library::getLink(array('view' => 'ConfigNotWritable'))); - } else { - fclose($fp); - } - if (!isset($_GET['step'])) { $_GET['step'] = 0; } @@ -35,17 +28,35 @@ case 1: $this->db =& DB::DBFactory(DB_ENGINE, $_POST['host'], $_POST['username'], $_POST['password'], true); if (!$this->db->connect()) { - Library::redirect(Library::getLink(array('view' => 'InstallEnterCredentials', 'error' => urlencode($this->user->lang('Couldn\'t connect to database'))))); + Library::redirect(Library::getLink(array('view' => 'InstallEnterCredentials', 'error' => urlencode($this->user->lang('Couldn\'t connect to database, please check your credentials.'))))); } + + $errors = array(); + if (!$this->_isConfigWritable()) { + $errors[] = $this->user->lang('The config.php file must be writable'); + } + if (!$this->_areUploadDirsWritable()) { + $errors[] = $this->user->lang('All directories under the "uploads" and "uploads/editor" directories must be writable'); + } + if ($this->db->isLowerThan41()) { + $errors[] = $this->user->lang('You need a MySQL version no lower than 4.1'); + } + if (!$this->db->selectDb($_POST['database'])) { if (!$result = $this->db->createDB($_POST['database'])) { - Library::redirect(Library::getLink(array('view' => 'InstallEnterCredentials', 'error' => urlencode($this->user->lang('Couldn\'t create database. Please create it manually and try again.'))))); + $errors[] = $this->user->lang('Couldn\'t create database. Please create it manually and try again.'); + } else { + $this->db->selectDb($_POST['database']); } - $this->db->selectDb($_POST['database']); } + + if ($errors) { + Library::redirect(Library::getLink(array('view' => 'InstallEnterCredentials', 'error' => urlencode(implode('<br />', $errors))))); + } + $this->_writeConfig(DB_ENGINE, $_POST['host'], $_POST['database'], $_POST['username'], $_POST['password']); $this->_runSQLFILE('final.sql'); - if (isset($_POST['demodata'])) { + if (isset($_POST['demodata']) && $_POST['demodata']) { $this->_runSQLFILE('sampleData.sql'); } Library::redirect(Library::getLink(array('view' => 'InstallOk'))); @@ -101,6 +112,31 @@ } fclose($fp); } + + function _isConfigWritable() { + // is_writable() not working under windows + if (!$fp = @fopen(dirname(__FILE__).'/../config.php', 'a')) { + return false; + } + fclose($fp); + + return true; + } + + function _areUploadDirsWritable() { + foreach (array('files', 'icons', 'editor/File', 'editor/Flash', 'editor/Image', 'editor/Media') as $folder) { + // is_writable() not working under windows + if (!$fp = @fopen(dirname(__FILE__)."/../uploads/$folder/eraseme.txt", 'a')) { + return false; + } else { + fclose($fp); + unlink(dirname(__FILE__)."/../uploads/$folder/eraseme.txt"); + } + + } + + return true; + } } ?> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |