root/modules/branches/2.3/backup/page.backup.php

Revision 3467, 7.1 kB (checked in by qldrob, 6 years ago)

Merged revisions 3465 via svnmerge from
https://amportal.svn.sourceforge.net/svnroot/amportal/modules/branches/2.2

........

r3465 | qldrob | 2007-01-02 21:13:40 +1000 (Tue, 02 Jan 2007) | 2 lines


Fix astdb backup issues, add redirect_standard to avoid issues reported in #1454.

........

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 <?php
2 // backup.php Copyright (C) 2005 VerCom Systems, Inc. & Ron Hartmann (rhartmann@vercomsystems.com)
3 // Asterisk Management Portal Copyright (C) 2004 Coalescent Systems Inc. (info@coalescentsystems.ca)
4 //
5 //This program is free software; you can redistribute it and/or
6 //modify it under the terms of the GNU General Public License
7 //as published by the Free Software Foundation; either version 2
8 //of the License, or (at your option) any later version.
9 //
10 //This program is distributed in the hope that it will be useful,
11 //but WITHOUT ANY WARRANTY; without even the implied warranty of
12 //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 //GNU General Public License for more details.
14 ?>
15
16 <?php
17 include_once "schedule_functions.php";
18 global $asterisk_conf;
19 $action = isset($_REQUEST['action'])?$_REQUEST['action']:'';
20 $display='backup';
21 $type = 'tool';
22
23 $dir=isset($_REQUEST['dir'])?$_REQUEST['dir']:'';
24 $extdisplay=isset($_REQUEST['extdisplay'])?$_REQUEST['extdisplay']:'';
25 $file=isset($_REQUEST['file'])?$_REQUEST['file']:'';
26 $filetype=isset($_REQUEST['filetype'])?$_REQUEST['filetype']:'';
27 $ID=isset($_REQUEST['backupid'])?$_REQUEST['backupid']:'';
28 $name=isset($_REQUEST['name'])?$_REQUEST['name']:'backup';
29
30 // Santity check passed params
31 if (strstr($dir, '..') || strpos($dir, '\'') || strpos($dir, '"') || strpos($dir, '\'') || strpos($dir,'\`') ||
32     strstr($file, '..') || strpos($file, '\'') || strpos($file, '"') || strpos($file, '\'') || strpos($file,'\`') ||
33     strpos($ID, '.') || strpos($ID, '\'') || strpos($ID, '"') || strpos($ID, '\'') || strpos($ID,'\`') ||
34     strpos($filetype, '.') || strpos($filetype, '\'') || strpos($filetype, '"') || strpos($filetype, '\'') || strpos($filetype,'\`')) {
35     print "You're trying to use an invalid character. Please don't.\n";
36     exit;
37 }
38
39
40 switch ($action) {
41     case "addednew":
42         $ALL_days=isset($_POST['all_days'])?$_POST['all_days']:'';
43         $ALL_months=isset($_POST['all_months'])?$_POST['all_months']:'';
44         $ALL_weekdays=isset($_POST['all_weekdays'])?$_POST['all_weekdays']:'';
45
46         $backup_schedule=isset($_REQUEST['backup_schedule'])?$_REQUEST['backup_schedule']:'';
47         $name=(empty($_REQUEST['name'])?'backup':$_REQUEST['name']);
48         $mins=isset($_REQUEST['mins'])?$_REQUEST['mins']:'';
49         $hours=isset($_REQUEST['hours'])?$_REQUEST['hours']:'';
50         $days=isset($_REQUEST['days'])?$_REQUEST['days']:'';
51         $months=isset($_REQUEST['months'])?$_REQUEST['months']:'';
52         $weekdays=isset($_REQUEST['weekdays'])?$_REQUEST['weekdays']:'';
53         
54         $backup_options[]=$_REQUEST['bk_voicemail'];
55         $backup_options[]=$_REQUEST['bk_sysrecordings'];
56         $backup_options[]=$_REQUEST['bk_sysconfig'];
57         $backup_options[]=$_REQUEST['bk_cdr'];
58         $backup_options[]=$_REQUEST['bk_fop'];
59     
60         $Backup_Parms=Get_Backup_String($name,$backup_schedule, $ALL_days, $ALL_months, $ALL_weekdays, $mins, $hours, $days, $months, $weekdays);
61         Save_Backup_Schedule($Backup_Parms, $backup_options);
62     break;
63     case "edited":
64         Delete_Backup_set($ID);
65         $ALL_days=$_REQUEST['all_days'];
66         $ALL_months=$_REQUEST['all_months'];
67         $ALL_weekdays=$_REQUEST['all_weekdays'];
68
69         $backup_schedule=$_REQUEST['backup_schedule'];
70         $mins=$_REQUEST['mins'];
71         $hours=$_REQUEST['hours'];
72         $days=$_REQUEST['days'];
73         $months=$_REQUEST['months'];
74         $weekdays=$_REQUEST['weekdays'];
75         
76         $backup_options[]=$_REQUEST['bk_voicemail'];
77         $backup_options[]=$_REQUEST['bk_sysrecordings'];
78         $backup_options[]=$_REQUEST['bk_sysconfig'];
79         $backup_options[]=$_REQUEST['bk_cdr'];
80         $backup_options[]=$_REQUEST['bk_fop'];
81     
82         $Backup_Parms=Get_Backup_String($name,$backup_schedule, $ALL_days, $ALL_months, $ALL_weekdays, $mins, $hours, $days, $months, $weekdays);
83         Save_Backup_Schedule($Backup_Parms, $backup_options);
84     break;
85     case "delete":
86         Delete_Backup_set($ID);
87     break;
88     case "deletedataset":
89         exec("/bin/rm -rf '$dir'");
90     break;
91     case "deletefileset":
92         exec("/bin/rm -rf '$dir'");
93     break;
94     case "restored":
95         $Message=Restore_Tar_Files($dir, $file, $filetype, $display);
96         // Regenerate all the ASTDB stuff. Note, we need a way to do speedials and other astdb stuff here.
97         core_users2astdb();
98         core_devices2astdb();
99         needreload();
100         redirect_standard();
101     break;
102 }
103
104
105 ?>
106 </div>
107 <div class="rnav"><ul>
108     <li><a href="config.php?type=<?php echo urlencode($type)?>&display=<?php echo urlencode($display)?>&action=add"><?php echo _("Add Backup Schedule")?></a></li>
109     <li><a href="config.php?type=<?php echo urlencode($type)?>&display=<?php echo urlencode($display)?>&action=restore"><?php echo _("Restore from Backup")?></a></li>
110
111 <?php
112 //get unique account rows for navigation menu
113 $results = Get_Backup_Sets();
114
115 if (isset($results)) {
116     foreach ($results as $result) {
117         echo "<li><a id=\"".($extdisplay==$result[13] ? 'current':'')."\" href=\"config.php?type=".urlencode($type)."&display=".urlencode($display)."&action=edit&backupid=".urlencode($result[13])."&backupname=".urlencode($result[0])."\">{$result[0]}</a></li>";
118     }
119 }
120 ?>
121 </ul></div>
122
123
124 <div class="content">
125
126 <?php
127 if ($action == 'add')
128 {
129     ?>
130     <h2><?php echo _("System Backup")?></h2>
131     <form name="addbackup" action="<?php $_SERVER['PHP_SELF'] ?>" method="post">
132     <input type="hidden" name="display" value="<?php echo $display?>">
133     <input type="hidden" name="type" value="<?php echo $type?>">
134     <input type="hidden" name="action" value="addednew">
135         <table>
136     <?php Show_Backup_Options(); ?>
137         </table>
138     <h5><?php echo _("Run Schedule")?><hr></h5>
139         <table>
140     <?php show_schedule("yes",""); ?>
141     <tr>
142         <td colspan="5" align="center"><input name="Submit" type="submit" value="<?php echo _("Submit Changes")?>" ></td>
143         </tr>
144         </table>
145     </form>
146     <br><br><br><br><br>
147
148 <?php
149 }
150 else if ($action == 'edit')
151 {
152     ?>
153     <h2><?php echo _("System Backup")?></h2>
154     <p><a href="config.php?type=<?php echo urlencode($type)?>&display=<?php echo urlencode($display) ?>&action=delete&backupid=<?php echo urlencode($_REQUEST['backupid']); ?>"><?php echo _("Delete Backup Schedule")?> <?php echo $_REQUEST['backupname']; ?></a></p>
155     <form name="addbackup" action="<?php $_SERVER['PHP_SELF'] ?>" method="post">
156     <input type="hidden" name="display" value="<?php echo $display?>">
157     <input type="hidden" name="action" value="edited">
158     <input type="hidden" name="backupid" value="<?php echo $_REQUEST['backupid']; ?>">
159     <input type="hidden" name="type" value="<?php echo $type?>">
160         <table>
161     <?php Show_Backup_Options($_REQUEST['backupid']); ?>
162         </table>
163     <h5><?php echo _("Run Schedule")?><hr></h5>
164         <table>
165     <?php show_schedule("yes", "$_REQUEST[backupid]"); ?>
166     <tr>
167         <td colspan="5" align="center"><input name="Submit" type="submit" value="<?php echo _("Submit Changes")?>" ></td>
168         </tr>
169         </table>
170     </form>
171     <br><br><br><br><br>
172
173 <?php
174 }
175 else if ($action == 'restore')
176 {
177 ?>
178     <h2><?php echo _("System Restore")?></h2>
179 <?php
180     if (empty($dir)) {
181         $dir = $asterisk_conf['astvarlibdir']."/backups";
182         if(!is_dir($dir)) mkdir($dir);
183     }
184
185     Get_Tar_Files($dir, $display, $file);
186     echo "<br><br><br><br><br><br><br><br><br><br><br><br>";
187     
188 }
189 else
190 {
191     if (isset($Message)){
192     ?>
193         <h3><?php echo $Message ?></h3>
194     <?php }
195     else{
196     ?>
197         <h2><?php echo _("System Backup") ?></h2>
198     <?php }
199 ?>
200
201    
202
203     <br><br><br><br><br><br>
204     <br><br><br><br><br><br>
205 <?php
206 }
207 ?>
208
Note: See TracBrowser for help on using the browser.