From: <dai...@us...> - 2011-07-31 01:31:47
|
Revision: 4645 http://web-erp.svn.sourceforge.net/web-erp/?rev=4645&view=rev Author: daintree Date: 2011-07-31 01:31:41 +0000 (Sun, 31 Jul 2011) Log Message: ----------- Modified Paths: -------------- trunk/UpgradeDatabase.php trunk/doc/Change.log Added Paths: ----------- trunk/BackupDatabase.php Added: trunk/BackupDatabase.php =================================================================== --- trunk/BackupDatabase.php (rev 0) +++ trunk/BackupDatabase.php 2011-07-31 01:31:41 UTC (rev 4645) @@ -0,0 +1,48 @@ +<?php +/* $Id BackupDatabase.php 4183 2010-12-14 09:30:20Z daintree $ */ + +$PageSecurity = 15; //hard coded in case database is old and PageSecurity stuff cannot be retrieved + +include('includes/session.inc'); +$title = _('Backup webERP Database'); +include('includes/header.inc'); + +if (isset($_GET['BackupFile'])){ + unlink($_SERVER['DOCUMENT_ROOT'] . $_GET['BackupFile']); + prnMsg(_('The backup file has been deleted'),'success'); +} else { + + $BackupFile = $rootpath . '/companies/' . $_SESSION['DatabaseName'] .'/' . _('Backup') . '_' . Date('Y-m-d-H-i-s') . '.sql.gz'; + $Command = 'mysqldump --opt -h' . $host . ' -u' . $dbuser . ' -p' . $dbpassword . ' ' . $_SESSION['DatabaseName'] . '| gzip > ' . + $_SERVER['DOCUMENT_ROOT'] . $BackupFile; + + + $CommandOutput = array(); + exec($Command,$CommandOutput, $ReturnValue); + + if ($ReturnValue ==0) { + prnMsg(_('The backup file has now been created. You must now download this to your computer because in case the web-server has a disk failure the backup would then not on the same machine. Use the link below') . '<br /><br /><a href="' . $BackupFile . '">' . _('Download the backup file to your locale machine') . '</a>','success'); + prnMsg(_('Once you have downloaded the database backup file to your local machine you should use the link below to delete it - backup files can consume a lot of space on your hosting account and will accumulate if not deleted - they also contain sensitive information which would otherwise be available for others to download!'),'info'); + echo '<br /> + <br /> + <a href="'. $_SERVER['PHP_SELF'] . '?BackupFile=' .$BackupFile .'">' . _('Delete the backup file off the server') . '</a>'; + } else { + prnMsg(_('There was some problem producing a backup using mysqldump. Normally this relates to a permissions issue - the web-server user must have permission to write to the companies directory'),'error'); + } +} +/* +//this could be a weighty file attachment!! +include('includes/htmlMimeMail.php'); +$mail = new htmlMimeMail(); +$attachment = $mail->getFile( $BackupFile); +$mail->setText(_('webERP backup file attached')); +$mail->addAttachment($attachment, $BackupFile, 'application/gz'); +$mail->setSubject(_('Database Backup')); +$mail->setFrom($_SESSION['CompanyRecord']['coyname'] . '<' . $_SESSION['CompanyRecord']['email'] . '>'); +$result = $mail->send(array('"' . $_SESSION['UsersRealName'] . '" <' . $_SESSION['UserEmail'] . '>')); + +prnMsg(_('A backup of the database has been taken and emailed to you'), 'info'); +unlink($BackupFile); // would be a security issue to leave it there for all to download/see +*/ +include('includes/footer.inc'); +?> \ No newline at end of file Modified: trunk/UpgradeDatabase.php =================================================================== --- trunk/UpgradeDatabase.php 2011-07-30 06:58:14 UTC (rev 4644) +++ trunk/UpgradeDatabase.php 2011-07-31 01:31:41 UTC (rev 4645) @@ -9,7 +9,6 @@ if (!isset($_POST['DoUpgrade'])){ - prnMsg(_('This script will perform any modifications to the database required to allow the additional functionality in later scripts.') . '<br />' . _('You should do a backup now before proceeding!'),'info'); echo '<p><form method="post" action="' . $_SERVER['PHP_SELF'] . '">'; echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; @@ -35,11 +34,16 @@ if ($_SESSION['VersionNumber']=='4.00RC1'){ $_SESSION['VersionNumber']='3.12'; } - prnMsg(_('The webERP code is version') . ' ' . $Version . ' ' . _('and the database version is') . ' ' . $_SESSION['VersionNumber'],'info'); - echo '<input type="hidden" name="OldVersion" value="' . $_SESSION['VersionNumber'] . '" />'; + if ( $_SESSION['VersionNumber'] == $Version){ + prnMsg(_('The database is up to date, there are no upgrades to perform'),'info'); + } else { + prnMsg(_('This script will perform any modifications to the database required to allow the additional functionality in later scripts.') . '<br />' . _('The webERP code is version') . ' ' . $Version . ' ' . _('and the database version is') . ' ' . $_SESSION['VersionNumber'] . '<br /><a target="_blank" href="' . $rootpath . '/BackupDatabase.php">' ._('Click to do a database backup now before proceeding!') . '</a>','info'); + + echo '<input type="hidden" name="OldVersion" value="' . $_SESSION['VersionNumber'] . '" />'; + echo '<div class="centre"><input type="submit" name="DoUpgrade" value="' . _('Perform Database Upgrade') . '" /></div>'; + } } - - echo '<div class="centre"><input type="submit" name="DoUpgrade" value="' . _('Perform Database Upgrade') . '" /></div>'; + echo '</form>'; } @@ -47,26 +51,6 @@ if ($dbType=='mysql' OR $dbType =='mysqli'){ - /* First do a backup - $BackupFile = $PathPrefix . './companies/' . $_SESSION['DatabaseName'] .'/' . _('Backup') . '_' . Date('Y-m-d-H-i-s') . '.sql.gz'; - $Command = 'mysqldump --opt -h' . $host . ' -u' . $dbuser . ' -p' . $dbpassword . ' ' . $_SESSION['DatabaseName'] . '| gzip > ' . $BackupFile; - system($Command); - - //this could be a weighty file attachment!! - include('includes/htmlMimeMail.php'); - $mail = new htmlMimeMail(); - $attachment = $mail->getFile( $BackupFile); - $mail->setText(_('webERP backup file attached')); - $mail->addAttachment($attachment, $BackupFile, 'application/gz'); - $mail->setSubject(_('Database Backup')); - $mail->setFrom($_SESSION['CompanyRecord']['coyname'] . '<' . $_SESSION['CompanyRecord']['email'] . '>'); - $result = $mail->send(array('"' . $_SESSION['UsersRealName'] . '" <' . $_SESSION['UserEmail'] . '>')); - - prnMsg(_('A backup of the database has been taken and emailed to you'), 'info'); - unlink($BackupFile); // would be a security issue to leave it there for all to download/see - - */ - $SQLScripts = array(); if ($_POST['OldVersion']=='Manual') { Modified: trunk/doc/Change.log =================================================================== --- trunk/doc/Change.log 2011-07-30 06:58:14 UTC (rev 4644) +++ trunk/doc/Change.log 2011-07-31 01:31:41 UTC (rev 4645) @@ -1,5 +1,6 @@ webERP Change Log +31/7/11 Phil: BackupDatabase.php script 30/7/11 Phil: SelectCreditItems.php made it so if several sessions creating a credit note they no longer over-write each other. 30/7/11 Ricard: POItems.php now checks for return of more than 1 purchasing data from the supplier and takes the newest record This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |