2 if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3 /*********************************************************************************
4 * SugarCRM is a customer relationship management program developed by
5 * SugarCRM, Inc. Copyright (C) 2004-2011 SugarCRM Inc.
7 * This program is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU Affero General Public License version 3 as published by the
9 * Free Software Foundation with the addition of the following permission added
10 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
11 * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
12 * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
14 * This program is distributed in the hope that it will be useful, but WITHOUT
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
19 * You should have received a copy of the GNU Affero General Public License along with
20 * this program; if not, see http://www.gnu.org/licenses or write to the Free
21 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
24 * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
25 * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
27 * The interactive user interfaces in modified source and object code versions
28 * of this program must display Appropriate Legal Notices, as required under
29 * Section 5 of the GNU Affero General Public License version 3.
31 * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
32 * these Appropriate Legal Notices must retain the display of the "Powered by
33 * SugarCRM" logo. If the display of the logo is not reasonably feasible for
34 * technical reasons, the Appropriate Legal Notices must display the words
35 * "Powered by SugarCRM".
36 ********************************************************************************/
39 if (!is_admin($GLOBALS['current_user']))
41 sugar_die("Unauthorized access to administration.");
45 require_once('include/utils/zip_utils.php');
47 $form_action = "index.php?module=Administration&action=Backups";
56 // process "run" commands
57 if( isset( $_REQUEST['run'] ) && ($_REQUEST['run'] != "") ){
58 $run = $_REQUEST['run'];
60 $backup_dir = $_REQUEST['backup_dir'];
61 $backup_zip = $_REQUEST['backup_zip'];
63 if( $run == "confirm" ){
64 if( $backup_dir == "" ){
65 $errors[] = $mod_strings['LBL_BACKUP_DIRECTORY_ERROR'];
67 if( $backup_zip == "" ){
68 $errors[] = $mod_strings['LBL_BACKUP_FILENAME_ERROR'];
71 if( sizeof($errors) > 0 ){
75 if( !is_dir( $backup_dir ) ){
76 if( !mkdir_recursive( $backup_dir ) ){
77 $errors[] = $mod_strings['LBL_BACKUP_DIRECTORY_EXISTS'];
81 if( !is_writable( $backup_dir ) ){
82 $errors[] = $mod_strings['LBL_BACKUP_DIRECTORY_NOT_WRITABLE'];
85 if( is_file( "$backup_dir/$backup_zip" ) ){
86 $errors[] = $mod_strings['LBL_BACKUP_FILE_EXISTS'];
88 if( is_dir( "$backup_dir/$backup_zip" ) ){
89 $errors[] = $mod_strings['LBL_BACKUP_FILE_AS_SUB'];
91 if( sizeof( $errors ) == 0 ){
93 $input_disabled = "readonly";
96 else if( $run == "confirmed" ){
97 ini_set( "memory_limit", "-1" );
98 ini_set( "max_execution_time", "0" );
99 zip_dir( ".", "$backup_dir/$backup_zip" );
103 if( sizeof($errors) > 0 ){
104 foreach( $errors as $error ){
105 print( "<font color=\"red\">$error</font><br>" );
108 if( $run == "done" ){
109 $size = filesize( "$backup_dir/$backup_zip" );
110 print( $mod_strings['LBL_BACKUP_FILE_STORED'] . " $backup_dir/$backup_zip ($size bytes).<br>\n" );
111 print( "<a href=\"index.php?module=Administration&action=index\">" . $mod_strings['LBL_BACKUP_BACK_HOME']. "</a>\n" );
117 echo get_module_title($mod_strings['LBL_MODULE_NAME'], $mod_strings['LBL_BACKUPS_TITLE'], true);
118 echo $mod_strings['LBL_BACKUP_INSTRUCTIONS_1']; ?>
120 <?php echo $mod_strings['LBL_BACKUP_INSTRUCTIONS_2']; ?><br>
121 <form action="<?php print( $form_action );?>" method="post">
124 <td><?php echo $mod_strings['LBL_BACKUP_DIRECTORY']; ?><br><i><?php echo $mod_strings['LBL_BACKUP_DIRECTORY_WRITABLE']; ?></i></td>
125 <td><input size="100" type="input" name="backup_dir" <?php print( $input_disabled );?> value="<?php print( $backup_dir );?>"/></td>
128 <td><?php echo $mod_strings['LBL_BACKUP_FILENAME']; ?></td>
129 <td><input type="input" name="backup_zip" <?php print( $input_disabled );?> value="<?php print( $backup_zip );?>"/></td>
132 <input type=hidden name="run" value="<?php print( $run );?>" />
138 <input type="submit" value="<?php echo $mod_strings['LBL_BACKUP_CONFIRM']; ?>" />
143 <?php echo $mod_strings['LBL_BACKUP_CONFIRMED']; ?><br>
144 <input type="submit" value="<?php echo $mod_strings['LBL_BACKUP_RUN_BACKUP']; ?>" />
153 } // end if/else of $run options
154 $GLOBALS['log']->info( "Backups" );