From: <lin...@us...> - 2010-05-03 13:03:06
|
Revision: 3442 http://web-erp.svn.sourceforge.net/web-erp/?rev=3442&view=rev Author: lindsayh Date: 2010-05-03 13:03:00 +0000 (Mon, 03 May 2010) Log Message: ----------- Updates to installer to recover better from errors by restoring all the user selected values on the initial page when errors are discovered while processing the user's data. Modified Paths: -------------- trunk/doc/Change.log.html trunk/install/index.php trunk/install/save.php trunk/install/timezone.php Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2010-05-03 10:04:20 UTC (rev 3441) +++ trunk/doc/Change.log.html 2010-05-03 13:03:00 UTC (rev 3442) @@ -1,5 +1,6 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p></p> +<p>03/05/10 Lindsay: More installer tweaks: better error handling</p> <p>03/05/10 Tim: PurchData.php - Do not show thousands seperator in price field</p> <p>02/05/10 Tim: Add picking list printing</p> <p>02/05/10 Tim: Updates for case where no internet connection is present</p> Modified: trunk/install/index.php =================================================================== --- trunk/install/index.php 2010-05-03 10:04:20 UTC (rev 3441) +++ trunk/install/index.php 2010-05-03 13:03:00 UTC (rev 3442) @@ -9,6 +9,8 @@ define('SESSION_STARTED', true); } +$_SESSION['MaxLogoSize'] = 10 * 1024; // Limit logo file size. + // Check if the page has been reloaded if(!isset($_GET['sessions_checked']) || $_GET['sessions_checked'] != 'true') { // Set session variable @@ -288,6 +290,7 @@ </td> <td width="180"> + <input type="hidden" name="MAX_FILE_SIZE" <?php echo "value=\"" . $_SESSION['MaxLogoSize'] . "\"" ?> /> <input type="FILE" size="50" ID="LogoFile" name="LogoFile" tabindex="53"> </td> </tr> Modified: trunk/install/save.php =================================================================== --- trunk/install/save.php 2010-05-03 10:04:20 UTC (rev 3441) +++ trunk/install/save.php 2010-05-03 13:03:00 UTC (rev 3442) @@ -10,6 +10,9 @@ session_start(); define('SESSION_STARTED', true); } +if(!isset($_SESSION['MaxLogoSize'])) { + $_SESSION['MaxLogoSize'] = 10 * 1024; // Limit logo file size. +} //deal with check boxes if(!isset($_POST['install_tables'])) { $_POST['install_tables'] = false; @@ -45,7 +48,7 @@ } else { $_SESSION['operating_system'] = $_POST['operating_system']; } - if(!isset($_POST['world_writeable'])) { + if(!isset($_POST['world_writeable'])) { $_SESSION['world_writeable'] = false; } else { $_SESSION['world_writeable'] = true; @@ -53,7 +56,9 @@ $_SESSION['database_host'] = $_POST['database_host']; $_SESSION['database_username'] = Replace_Dodgy_Characters($_POST['database_username']); $_SESSION['database_password'] = $_POST['database_password']; + $_SESSION['install_tables'] = $_POST['install_tables']; $_SESSION['database_name'] = Replace_Dodgy_Characters($_POST['company_name']); + $_SESSION['db_file'] = $_POST['DemoData'] ? 'demo' : 'not'; $_SESSION['timezone'] = $_POST['timezone']; $_SESSION['company_name'] = Replace_Dodgy_Characters($_POST['company_name']); $_SESSION['admin_email'] = $_POST['admin_email']; @@ -265,6 +270,9 @@ set_error('Please make sure you re-enter the password for the Administrator account'); } if ($_POST['admin_password'] != $_POST['admin_repassword']){ + // Zero BOTH passwords before returning form to user. + $_POST['admin_password'] = ''; + $_POST['admin_repassword'] = ''; set_error('The two Administrator account passwords you entered do not match'); } // End admin user details code @@ -274,7 +282,7 @@ // no need to bother if just setting up the demo data $CompanyDir = $path_to_root . '/companies/' . $_POST['company_name']; if ($_POST['DemoData']==false){ - $Result = mkdir($CompanyDir ); + $Result = mkdir($CompanyDir); $Result = mkdir($CompanyDir . '/part_pics'); $Result = mkdir($CompanyDir . '/EDI_Incoming_Orders'); $Result = mkdir($CompanyDir . '/reports'); @@ -284,10 +292,19 @@ $Result = mkdir($CompanyDir . '/pdf_append'); // Now have a destination to place the logo image. - if (isset($_FILES['LogoFile']) && - $_FILES['LogoFile']['error'] == UPLOAD_ERR_OK) { + if (isset($_FILES['LogoFile'])) { + if ($_FILES['LogoFile']['error'] == UPLOAD_ERR_OK) { $result = move_uploaded_file($_FILES['LogoFile']['tmp_name'], $CompanyDir . '/logo.jpg'); + } elseif ($_FILES['LogoFile']['error'] == UPLOAD_ERR_INI_SIZE || + $_FILES['LogoFile']['error'] == UPLOAD_ERR_FORM_SIZE) { + set_error( "Logo file is too big - Limit: " . $_SESSION['MaxLogoSize'] ); + } elseif ($_FILES['LogoFile']['error'] == UPLOAD_ERR_NO_FILE ) { + // No logo file, so use the default. + copy( $path_to_root . '/logo_server.jpg', $CompanyDir . '/logo.jpg'); + } else { + set_error( "Error uploading logo file" ); + } } else { // No logo file, so use the default. copy( $path_to_root . '/logo_server.jpg', $CompanyDir . '/logo.jpg'); Modified: trunk/install/timezone.php =================================================================== --- trunk/install/timezone.php 2010-05-03 10:04:20 UTC (rev 3441) +++ trunk/install/timezone.php 2010-05-03 13:03:00 UTC (rev 3442) @@ -1,44 +1,25 @@ <?php /* $Id$*/ -function stripcomma($str) { //because we're using comma as a delimiter - $str = trim($str); - $str = str_replace('"', '""', $str); - $str = str_replace("\r", "", $str); - $str = str_replace("\n", '\n', $str); - if($str == "" ) - return $str; - else - return '"'.$str.'"'; +if (isset($_SESSION['timezone']) && strlen($_SESSION['timezone']) > 0 ) { + $ltz = $_SESSION['timezone']; +} else { + $ltz = date_default_timezone_get(); } -function NULLToZero( &$Field ) { - if( is_null($Field) ) - return '0'; - else - return $Field; -} - -function NULLToPrice( &$Field ) { - if( is_null($Field) ) - return '-1'; - else - return $Field; -} - $row = 1; $handle = fopen('timezone.csv', "r"); while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { $num = count($data); $row++; - for ($c=0; $c < $num; $c++) { - $timezone=$data[$c]; - $c++; - if ($timezone==date_default_timezone_get()) { - echo "<OPTION selected value='".$timezone."'>".$timezone; - } else { - echo "<OPTION value='".$timezone."'>".$timezone; - } + for ($c=0; $c < $num; $c++) { + $timezone=$data[$c]; + $c++; + if ($timezone==$ltz) { + echo "<OPTION selected value='".$timezone."'>".$timezone; + } else { + echo "<OPTION value='".$timezone."'>".$timezone; } + } } ?> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |