2 if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3 /*********************************************************************************
4 * SugarCRM Community Edition is a customer relationship management program developed by
5 * SugarCRM, Inc. Copyright (C) 2004-2012 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 class ViewBackups extends SugarView
42 * @see SugarView::_getModuleTitleParams()
44 protected function _getModuleTitleParams($browserTitle = false)
49 "<a href='index.php?module=Administration&action=index'>".$mod_strings['LBL_MODULE_NAME']."</a>",
50 $mod_strings['LBL_BACKUPS_TITLE']
55 * @see SugarView::preDisplay()
57 public function preDisplay()
61 if (!is_admin($current_user)) {
62 sugar_die("Unauthorized access to administration.");
67 * @see SugarView::display()
69 public function display()
71 require_once('include/utils/zip_utils.php');
73 $form_action = "index.php?module=Administration&action=Backups";
82 // process "run" commands
83 if( isset( $_REQUEST['run'] ) && ($_REQUEST['run'] != "") ){
84 $run = $_REQUEST['run'];
86 $backup_dir = $_REQUEST['backup_dir'];
87 $backup_zip = $_REQUEST['backup_zip'];
89 if( $run == "confirm" ){
90 if( $backup_dir == "" ){
91 $errors[] = $mod_strings['LBL_BACKUP_DIRECTORY_ERROR'];
93 if( $backup_zip == "" ){
94 $errors[] = $mod_strings['LBL_BACKUP_FILENAME_ERROR'];
97 if( sizeof($errors) > 0 ){
101 if( !is_dir( $backup_dir ) ){
102 if( !mkdir_recursive( $backup_dir ) ){
103 $errors[] = $mod_strings['LBL_BACKUP_DIRECTORY_EXISTS'];
107 if( !is_writable( $backup_dir ) ){
108 $errors[] = $mod_strings['LBL_BACKUP_DIRECTORY_NOT_WRITABLE'];
111 if( is_file( "$backup_dir/$backup_zip" ) ){
112 $errors[] = $mod_strings['LBL_BACKUP_FILE_EXISTS'];
114 if( is_dir( "$backup_dir/$backup_zip" ) ){
115 $errors[] = $mod_strings['LBL_BACKUP_FILE_AS_SUB'];
117 if( sizeof( $errors ) == 0 ){
119 $input_disabled = "readonly";
122 else if( $run == "confirmed" ){
123 ini_set( "memory_limit", "-1" );
124 ini_set( "max_execution_time", "0" );
125 zip_dir( ".", "$backup_dir/$backup_zip" );
129 if( sizeof($errors) > 0 ){
130 foreach( $errors as $error ){
131 print( "<font color=\"red\">$error</font><br>" );
134 if( $run == "done" ){
135 $size = filesize( "$backup_dir/$backup_zip" );
136 print( $mod_strings['LBL_BACKUP_FILE_STORED'] . " $backup_dir/$backup_zip ($size bytes).<br>\n" );
137 print( "<a href=\"index.php?module=Administration&action=index\">" . $mod_strings['LBL_BACKUP_BACK_HOME']. "</a>\n" );
143 echo getClassicModuleTitle(
146 "<a href='index.php?module=Administration&action=index'>".translate('LBL_MODULE_NAME','Administration')."</a>",
147 $mod_strings['LBL_BACKUPS_TITLE'],
151 echo $mod_strings['LBL_BACKUP_INSTRUCTIONS_1']; ?>
153 <?php echo $mod_strings['LBL_BACKUP_INSTRUCTIONS_2']; ?><br>
154 <form action="<?php print( $form_action );?>" method="post">
157 <td><?php echo $mod_strings['LBL_BACKUP_DIRECTORY']; ?><br><i><?php echo $mod_strings['LBL_BACKUP_DIRECTORY_WRITABLE']; ?></i></td>
158 <td><input size="100" type="input" name="backup_dir" <?php print( $input_disabled );?> value="<?php print( $backup_dir );?>"/></td>
161 <td><?php echo $mod_strings['LBL_BACKUP_FILENAME']; ?></td>
162 <td><input type="input" name="backup_zip" <?php print( $input_disabled );?> value="<?php print( $backup_zip );?>"/></td>
165 <input type=hidden name="run" value="<?php print( $run );?>" />
171 <input type="submit" value="<?php echo $mod_strings['LBL_BACKUP_CONFIRM']; ?>" />
176 <?php echo $mod_strings['LBL_BACKUP_CONFIRMED']; ?><br>
177 <input type="submit" value="<?php echo $mod_strings['LBL_BACKUP_RUN_BACKUP']; ?>" />
186 } // end if/else of $run options
187 $GLOBALS['log']->info( "Backups" );