root/modules/branches/2.2/backup/schedule_functions.php

Revision 4752, 26.1 kB (checked in by p_lindheimer, 6 years ago)

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

........

r4751 | p_lindheimer | 2007-08-07 18:31:32 -0700 (Tue, 07 Aug 2007) | 1 line


#2231 restore astdb as part of configuration restore choice

........

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 <?php
2 // schedule_functions.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 function Get_Tar_Files($dir="", $display="", $file="")
16 {
17     global $type;
18     global $asterisk_conf;
19         if (is_dir($dir)) {
20             if (($file!=".") && ($file!="..") && ($file!="")){
21                     echo "<li><a class=\"info\" href=\"javascript:decision('Are you sure you want to delete this File Set?','config.php?type=$type&display=$display&action=deletedataset&dir=$dir')\">";
22             echo _("DELETE ALL THE DATA IN THIS SET"); echo "<span>"; echo _("Delete this backup set and all data associated with this backup set..");echo "</span></a><br></li>";
23                     echo "<br>";
24         }
25                 if ($dh = opendir($dir)){
26                         while (($file = readdir($dh)) !== false)
27                         {
28                                 if (($file!=".") && ($file!="..") && ($dir==$asterisk_conf['astvarlibdir']."/backups/"))
29                                         echo "<li><a href=\"config.php?type=$type&display=$display&action=restore&dir=$dir/$file\">$file</a><br></li>";
30                                 else if (($file!=".") && ($file!="..") )
31                                         echo "<li><a href=\"config.php?type=$type&display=$display&action=restore&dir=$dir/$file&file=$file\">$file</a><br></li>";
32                         }
33                         closedir($dh);
34                 }
35         }
36         else if (substr($dir, -6)=="tar.gz" ){
37                 echo "<li><a class=\"info\" href=\"javascript:decision('Are you sure you want to delete this File Set?','config.php?type=$type&display=$display&action=deletefileset&dir=$dir&file=$file')\">";
38         echo _("Delete File Set"); echo "<span>"; echo _("Delete this backup set."); echo "</span></a><br></li>";
39                 echo "<br>";
40                 $tar_string="tar tfz \"$dir\" | cut -d'/' -f4";
41                 exec($tar_string,$restore_files,$error);
42                 echo "<li><a class=\"info\" href=\"javascript:decision('Are you sure you want to restore this COMPLETE file set?\nDoing so will permanently over-write all freePBX and Asterisk files\n You will loose all Your Call Detail Records and any Voicemail that was recorded between the BACKUP DATE and NOW.','config.php?type=$type&display=$display&action=restored&dir=$dir&filetype=ALL&file=$file')\">";
43         echo _("Restore Entire Backup Set"); echo "<span>"; echo _("Restore your Complete Backup set overwriting all files."); echo "</span></a><br></li>";
44                 echo "<br>";
45                 if (array_search('voicemail.tar.gz',$restore_files)){
46                         echo "<li><a class=\"info\" href=\"javascript:decision('Are you sure you want to Restore this file set?\nDoing so will permanently delete any new voicemail you have in your mailbox\n since this backup on $file?','config.php?type=$type&display=$display&action=restored&dir=$dir&filetype=VoiceMail&file=$file')\">";
47             echo _("Restore VoiceMail Files");echo "<span>"; echo _("Restore your Voicemail files from this backup set.  NOTE! This will delete any voicemail currently in the voicemail boxes.");
48             echo "</span></a><br></li>";
49                         echo "<br>";
50                 }
51
52                 if (array_search('recordings.tar.gz',$restore_files)){
53                         echo "<li><a class=\"info\" href=\"config.php?type=$type&display=$display&action=restored&dir=$dir&filetype=Recordings&file=$file\">";
54             echo _("Restore System Recordings Files"); echo "<span>"; echo _("Restore your system Voice Recordings including AutoAttendent files from this backup set.  NOTE! This will OVERWRITE any voicerecordings  currently on the system. It will NOT delete new files not currently in the backup set"); echo "</span></a><br></li>";
55                         echo "<br>";
56                 }
57                 if (array_search('configurations.tar.gz',$restore_files)){
58                         echo "<li><a class=\"info\" href=\"javascript:decision('Are you sure you want to Restore this File Set\nDoing so will Permanently Over-Write all AMP and Asterisk Files?','config.php?type=$type&display=$display&action=restored&dir=$dir&filetype=Configurations&file=$file')\">";
59             echo _("Restore System Configuration"); echo "<span>"; echo _("Restore your system configuration from this backup set.  NOTE! This will OVERWRITE any System changes you have made since this backup... ALL Itemes will be reset to what they were at the time of this backup set.."); echo "</span></a><br></li>";
60                         echo "<br>";
61                 }
62                 if (array_search('fop.tar.gz',$restore_files)){
63                         echo "<li><a class=\"info\" href=\"javascript:decision('Are you sure you want to Restore the Operator Panel Files\nDoing so will Permanently Over-Write all Operator Panel Files?','config.php?type=$type&display=$display&action=restored&dir=$dir&filetype=FOP&file=$file')\">";
64             echo _("Restore Operator Panel"); echo "<span>"; echo _("Restore the Operator Panel from this backup set.  NOTE! This will OVERWRITE any Operator Panel Changes you have made since this backup... ALL Itemes will be reset to what they were at the time of this backup set.."); echo "</span></a><br></li>";
65                         echo "<br>";
66                 }
67                 if (array_search('cdr.tar.gz',$restore_files)){
68                         echo "<li><a class=\"info\" href=\"javascript:decision('Are you sure you want to Restore the CALL DETAIL FILES \nDoing so will Permanently DELETE  all CALL RECORDS.?','config.php?type=$type&display=$display&action=restored&dir=$dir&filetype=CDR&file=$file')\">";
69             echo _("Restore Call Detail Report"); echo "<span>"; echo _("Restore the Call Detail Records from this backup set.  NOTE! This will DELETE ALL CALL RECORDS that have been saved since this backup set.."); echo "</span></a><br></li>";
70                         echo "<br>";
71                 }
72         }
73         else{
74                 echo "<h2>"; echo _("ERROR its not a BACKUP SET file");echo "</h2>";
75     }
76 }
77 function Restore_Tar_Files($dir="", $file="",$filetype="", $display="") {
78     global $asterisk_conf;
79     global $amp_conf;
80     $Message="Restore Failed";
81
82     if($filetype=="ALL") {
83         $Message="Restored All Files in BackupSet";
84         $fileholder=substr($file, 0,-7);
85         exec('/bin/rm -rf /tmp/ampbackups.$fileholder');
86
87         // First restore voicemial (for some reason if you do it all at once these don't get restored
88         //
89         exec('/bin/rm -rf '.$asterisk_conf['astspooldir'].'/voicemail');
90         $tar_cmd="tar -PxvOz -f \"$dir\" /tmp/ampbackups.$fileholder/voicemail.tar.gz | tar -Pxvz";
91         exec($tar_cmd);
92
93         // Next, recordings cause same issue as above
94         //
95         $tar_cmd="tar -PxvOz -f \"$dir\" /tmp/ampbackups.$fileholder/recordings.tar.gz | tar -Pxvz";
96         exec($tar_cmd);
97
98         // Now the rest and then we'll get on with the databases
99         //
100         $tar_cmd="tar -PxvOz -f \"$dir\" /tmp/ampbackups.$fileholder/configurations.tar.gz | tar -Pxvz";
101         exec($tar_cmd);
102         $tar_cmd="tar -PxvOz -f \"$dir\" /tmp/ampbackups.$fileholder/fop.tar.gz /tmp/ampbackups.$fileholder/cdr.tar.gz  | tar -Pxvz";
103         exec($tar_cmd);
104         $tar_cmd="tar -Pxvz -f \"$dir\" /tmp/ampbackups.$fileholder/asterisk.sql /tmp/ampbackups.$fileholder/asteriskcdr.sql /tmp/ampbackups.$fileholder/astdb.dump";
105         exec($tar_cmd);
106
107         $sql_cmd="mysql -u $amp_conf[AMPDBUSER] -p$amp_conf[AMPDBPASS] < /tmp/ampbackups.$fileholder/asterisk.sql";
108         exec($sql_cmd);
109         $sql_cmd="mysql -u $amp_conf[AMPDBUSER] -p$amp_conf[AMPDBPASS] < /tmp/ampbackups.$fileholder/asteriskcdr.sql";
110         exec($sql_cmd);
111         exec($asterisk_conf['astvarlibdir']."/bin/restoreastdb.php $fileholder");
112         exec('/bin/rm -rf /tmp/ampbackups.$fileholder');
113     } else if($filetype=="VoiceMail") {
114         $Message="Restored VoiceMail";
115         $fileholder=substr($file, 0,-7);
116         exec('/bin/rm -rf /tmp/ampbackups.$fileholder');
117         exec('/bin/rm -rf '.$asterisk_conf['astspooldir'].'/voicemail');
118         $tar_cmd="tar -PxvOz -f \"$dir\" /tmp/ampbackups.$fileholder/voicemail.tar.gz | tar -Pxvz";
119         exec($tar_cmd);
120         exec('/bin/rm -rf /tmp/ampbackups.$fileholder');
121     } else if($filetype=="Recordings") {
122         $Message="Restored System Recordings";
123         $fileholder=substr($file, 0,-7);
124         exec('/bin/rm -rf /tmp/ampbackups.$fileholder');
125         $tar_cmd="tar -PxvOz -f \"$dir\" /tmp/ampbackups.$fileholder/recordings.tar.gz | tar -Pxvz";
126         exec($tar_cmd);
127         exec('/bin/rm -rf /tmp/ampbackups.$fileholder');
128     } else if($filetype=="Configurations"){
129         $Message="Restored System Configuration";
130         $fileholder=substr($file, 0,-7);
131         exec('/bin/rm -rf /tmp/ampbackups.$fileholder');
132         $tar_cmd="tar -PxvOz -f \"$dir\" /tmp/ampbackups.$fileholder/configurations.tar.gz | tar -Pxvz";
133         exec($tar_cmd);
134         $tar_cmd="tar -Pxvz -f \"$dir\" /tmp/ampbackups.$fileholder/asterisk.sql /tmp/ampbackups.$fileholder/astdb.dump";
135         exec($tar_cmd);
136         $sql_cmd="mysql -u $amp_conf[AMPDBUSER] -p$amp_conf[AMPDBPASS] < /tmp/ampbackups.$fileholder/asterisk.sql";
137         exec($sql_cmd);
138         exec($asterisk_conf['astvarlibdir']."/bin/restoreastdb.php $fileholder");
139         exec('/bin/rm -rf /tmp/ampbackups.$fileholder');
140     } else if($filetype=="FOP"){
141         $Message="Restored Operator Panel";
142         $fileholder=substr($file, 0,-7);
143         exec('/bin/rm -rf /tmp/ampbackups.$fileholder');
144         $tar_cmd="tar -PxvOz -f \"$dir\" /tmp/ampbackups.$fileholder/fop.tar.gz | tar -Pxvz";
145         exec($tar_cmd);
146         exec('/bin/rm -rf /tmp/ampbackups.$fileholder');
147     } else if($filetype=="CDR"){
148         $Message="Restored CDR logs";
149         $fileholder=substr($file, 0,-7);
150         exec('/bin/rm -rf /tmp/ampbackups.$fileholder');
151         $tar_cmd="tar -PxvOz -f \"$dir\" /tmp/ampbackups.$fileholder/cdr.tar.gz | tar -Pxvz";
152         exec($tar_cmd);
153         $tar_cmd="tar -Pxvz -f \"$dir\" /tmp/ampbackups.$fileholder/asteriskcdr.sql";
154         exec($tar_cmd);
155         $sql_cmd="mysql -u $amp_conf[AMPDBUSER] -p$amp_conf[AMPDBPASS] < /tmp/ampbackups.$fileholder/asteriskcdr.sql";
156         exec($sql_cmd);
157         exec('/bin/rm -rf /tmp/ampbackups.$fileholder');
158     }
159      return ($Message);
160 }
161 function Get_Backup_Sets() {
162         global $db;
163         $sql = "SELECT * FROM Backup";
164         $results = $db->getAll($sql);
165         if(DB::IsError($results)) {
166                 $results = null;
167         }
168         return $results;
169 }
170 function Delete_Backup_Set($ID="") {
171         global $db;
172     global $asterisk_conf;
173     $sql = "DELETE FROM Backup  WHERE ID = '$ID'";
174         $result = $db->query($sql);
175         if(DB::IsError($result)) {
176                 die($result->getMessage());
177         }
178     $Cron_Script=$asterisk_conf['astvarlibdir']."/bin/retrieve_backup_cron_from_mysql.pl";
179     exec($Cron_Script);
180 }
181 function Save_Backup_Schedule($Backup_Parms, $backup_options )
182 {
183         global $db;
184     global $asterisk_conf;
185     if ($Backup_Parms[1]=="now")
186     {
187         $Cron_Script=$asterisk_conf['astvarlibdir']."/bin/ampbackup.pl '$Backup_Parms[0]' $backup_options[0] $backup_options[1] $backup_options[2] $backup_options[3] $backup_options[4]";
188         //echo "$Cron_Script";
189         exec($Cron_Script);
190     }
191     $sql = "INSERT INTO Backup (Name, Voicemail, Recordings, Configurations, CDR, FOP, Minutes, Hours, Days, Months,Weekdays, Command, Method ) VALUES (";
192         $sql .= "'".$Backup_Parms[0]."',";
193         $sql .= "'".$backup_options[0]."',";
194         $sql .= "'".$backup_options[1]."',";
195         $sql .= "'".$backup_options[2]."',";
196         $sql .= "'".$backup_options[3]."',";
197         $sql .= "'".$backup_options[4]."',";
198         $sql .= "'".$Backup_Parms[2]."',";
199         $sql .= "'".$Backup_Parms[3]."',";
200         $sql .= "'".$Backup_Parms[4]."',";
201         $sql .= "'".$Backup_Parms[5]."',";
202         $sql .= "'".$Backup_Parms[6]."',";
203         $sql .= "'".$Backup_Parms[7]."',";
204         $sql .= "'".$Backup_Parms[1]."');";
205         $result = $db->query($sql);
206         if(DB::IsError($result)) {
207                 die($result->getMessage().'<hr>'.$sql);
208         }
209     $Cron_Script=$asterisk_conf['astvarlibdir']."/bin/retrieve_backup_cron_from_mysql.pl";
210     exec($Cron_Script);
211     
212 }
213 function Get_Backup_String($name, $backup_schedule, $ALL_days, $ALL_months, $ALL_weekdays, $mins="", $hours="", $days="", $months="", $weekdays="") {
214     global $asterisk_conf;
215     if ($backup_schedule=="hourly")
216         $Cron_String="0 * * * * ".$asterisk_conf['astvarlibdir']."/bin/ampbackup.pl";
217     else if ($backup_schedule=="daily")
218         $Cron_String="0 0 * * * ".$asterisk_conf['astvarlibdir']."/bin/ampbackup.pl";
219     else if ($backup_schedule=="weekly")
220         $Cron_String="0 0 * * 0 ".$asterisk_conf['astvarlibdir']."/bin/ampbackup.pl";
221     else if ($backup_schedule=="monthly")
222         $Cron_String="0 0 1 * * ".$asterisk_conf['astvarlibdir']."/bin/ampbackup.pl";
223     else if ($backup_schedule=="yearly")
224         $Cron_String="0 0 1 1 * ".$asterisk_conf['astvarlibdir']."/bin/ampbackup.pl";
225     else if ($backup_schedule=="follow_schedule")
226     {
227         
228         if (count($mins)<1)
229                 $mins_string=":0:";
230         else{
231             foreach ($mins as $value)
232                     $mins_string.=":$value:";
233         }
234         if (count($hours)<1)
235                 $hours_string=":0:";
236         else{
237             foreach ($hours as $value)
238                     $hours_string.=":$value:";
239         }
240         if(($ALL_days=="1")||(count($days)<1))
241             $days_string="*";
242         else{
243             foreach ($days as $value)
244                     $days_string.=":$value:";
245         }
246         if(($ALL_months=="1")||(count($months)<1))
247             $months_string="*";
248         else{
249             foreach ($months as $value)
250                     $months_string.=":$value:";
251         }
252         if($ALL_weekdays=="1"||(count($weekdays)<1))
253             $weekdays_string="*";
254         else{
255             foreach ($weekdays as $value)
256                     $weekdays_string.=":$value:";
257         }
258
259                $cron_mins_string=trim($mins_string,":");
260         $cron_hours_string=trim($hours_string,":");
261         $cron_days_string=trim($days_string,":");
262         $cron_months_string=trim($months_string,":");
263         $cron_weekdays_string=trim($weekdays_string,":");
264         $Cron_String=str_replace("::", ",", "$cron_mins_string $cron_hours_string $cron_days_string $cron_months_string $cron_weekdays_string ".$asterisk_conf['astvarlibdir']."/bin/ampbackup.pl");
265     }
266     else if ($backup_schedule=="now")
267         $Cron_String="0 0 0 0 0 ".$asterisk_conf['astvarlibdir']."/bin/ampbackup.pl";
268     $Backup_String[]="$name";
269     $Backup_String[]="$backup_schedule";
270     $Backup_String[]="$mins_string";
271     $Backup_String[]="$hours_string";
272     $Backup_String[]="$days_string";
273     $Backup_String[]="$months_string";
274     $Backup_String[]="$weekdays_string";
275     $Backup_String[]="$Cron_String";
276
277     return ($Backup_String);
278 }
279 function Get_Backup_Times($BackupID)
280 {
281         global $db;
282         $sql = "SELECT Minutes, Hours, Days, Months, Weekdays, Method From Backup where ID=\"$BackupID\"";
283         $results = $db->getAll($sql);
284         if(DB::IsError($results)) {
285                 $results = Array(null, null, null, null, null, null);
286         }
287         return $results;
288 }
289 function Get_Backup_Options($BackupID)
290 {
291         global $db;
292         $sql = "SELECT Name, Voicemail, Recordings, Configurations, CDR, FOP FROM Backup where ID=\"$BackupID\"";
293         $results = $db->getAll($sql);
294         if(DB::IsError($results)) {
295                 $results = Array(null, null, null, null, null, null);
296         }
297         return $results;
298 }
299 function Show_Backup_Options($ID="")
300 {
301     if ($ID==""){
302         $name=""; $voicemail="no"; $sysrecordings="no"; $sysconfig="no"; $cdr="no"; $fop="no";}
303     else{
304         $backup_options=Get_Backup_Options($ID);
305         foreach ($backup_options as $bk_options)
306             $name="$bk_options[0]";$voicemail="$bk_options[1]"; $sysrecordings="$bk_options[2]"; $sysconfig="$bk_options[3]"; $cdr="$bk_options[4]"; $fop="$bk_options[5]";
307     }
308     ?>
309         <tr>
310                 <td><a href="#" class="info"><?php echo _("Schedule Name:")?><span><?php echo _("Give this Backup Schedule a brief name to help you identify it.");?></span></a></td>
311                 <td><input type="text" name="name" value="<?php echo (isset($name) ? $name : ''); ?>"></td>
312         </tr>
313
314     <tr>
315          <td><a href="#" class="info"><?php echo _("VoiceMail");?><span><?php echo _("Backup the System VoiceMail Boxes... CAUTION: Could result in large file");?></span></a>: </td>
316          <?php if ($voicemail == "yes"){?>
317              <td><input type="radio" name="bk_voicemail" value="yes" checked=checked/> <?php echo _("yes");?> &nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" name="bk_voicemail" value="no"/> <?php echo _("no");?></td>
318          <?php } else{ ?>
319              <td><input type="radio" name="bk_voicemail" value="yes" /> <?php echo _("yes");?> &nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" name="bk_voicemail" value="no" checked=checked/> <?php echo _("no");?></td>
320          <?php } ?>
321      </tr>
322     <tr>
323          <td><a href="#" class="info"><?php echo _("System Recordings");?><span><?php echo _("Backup the System Recordings (AutoAttendent, Music On Hold, System Recordings)");?></span></a>: </td>
324          <?php if ($sysrecordings == "yes"){?>
325              <td><input type="radio" name="bk_sysrecordings" value="yes" checked=checked/> <?php echo _("yes");?> &nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" name="bk_sysrecordings" value="no"/> <?php echo _("no");?></td>
326          <?php } else{ ?>
327              <td><input type="radio" name="bk_sysrecordings" value="yes" /> <?php echo _("yes");?> &nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" name="bk_sysrecordings" value="no" checked=checked/> <?php echo _("no");?></td>
328          <?php } ?>
329      </tr>
330     <tr>
331          <td><a href="#" class="info"><?php echo _("System Configuration");?><span><?php echo _("Backup the System Configurations (Database, etc files, SQL Database, astdb)");?></span></a>: </td>
332          <?php if ($sysconfig == "yes"){?>
333              <td><input type="radio" name="bk_sysconfig" value="yes" checked=checked/> <?php echo _("yes");?> &nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" name="bk_sysconfig" value="no"/> <?php echo _("no");?></td>
334          <?php } else{ ?>
335              <td><input type="radio" name="bk_sysconfig" value="yes" /> <?php echo _("yes");?> &nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" name="bk_sysconfig" value="no" checked=checked/> <?php echo _("no");?></td>
336          <?php } ?>
337      </tr>
338     <tr>
339          <td><a href="#" class="info"><?php echo _("CDR");?><span><?php echo _("Backup the System Call Detail Reporting (HTML and Database)");?></span></a>: </td>
340          <?php if ($cdr == "yes"){?>
341              <td><input type="radio" name="bk_cdr" value="yes" checked=checked/> <?php echo _("yes");?> &nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" name="bk_cdr" value="no"/> <?php echo _("no");?></td>
342          <?php } else{ ?>
343              <td><input type="radio" name="bk_cdr" value="yes" /> <?php echo _("yes");?> &nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" name="bk_cdr" value="no" checked=checked/> <?php echo _("no");?></td>
344          <?php } ?>
345      </tr>
346     <tr>
347          <td><a href="#" class="info"><?php echo _("Operator Panel");?><span><?php echo _("Backup the Operator Panel (HTML and Database)");?></span></a>: </td>
348          <?php if ($fop == "yes"){?>
349              <td><input type="radio" name="bk_fop" value="yes" checked=checked/> <?php echo _("yes");?> &nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" name="bk_fop" value="no"/> <?php echo _("no");?></td>
350          <?php } else{ ?>
351              <td><input type="radio" name="bk_fop" value="yes" /> <?php echo _("yes");?> &nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" name="bk_fop" value="no" checked=checked/> <?php echo _("no");?></td>
352          <?php } ?>
353      </tr>
354     <?php
355 }
356 function Schedule_Show_Minutes($Minutes_Set="")
357 {
358     echo "<br><br><table> <tr>";
359     echo "<td valign=top><select multiple size=12 name=mins[]>";
360     for ($minutes=0; $minutes<=59; $minutes++)
361     {
362 /*        if (($minutes==12)||($minutes==24)||($minutes==36)||($minutes==48))
363         {
364             echo "</select></td>";
365             echo "<td width=2 valign=top><select multiple size=12 name=mins[]>";
366         }
367 */        if (strstr($Minutes_Set,":$minutes:"))
368             echo "<option value=\"$minutes\" selected>$minutes";
369         else
370             echo "<option value=\"$minutes\" >$minutes";
371     }
372     echo "</select></td>";
373     echo "</tr></table></td>";
374 }
375 function Schedule_Show_Hours($Hours_Set="")
376 {
377     echo "<br><br><table> <tr>";
378     echo "<td valign=top><select multiple size=12 name=hours[]>";
379     for ($hours=0; $hours<=23; $hours++)
380     {
381 /*        if ($hours==12)
382         {
383             echo "</select></td>";
384             echo "<td valign=top><select multiple size=12 name=hours[]>";
385         }
386 */        if (strstr($Hours_Set,":$hours:"))
387             echo "<option value=\"$hours\" selected>$hours";
388         else
389             echo "<option value=\"$hours\" >$hours";
390     }
391     echo "</select></td>";
392     echo "</tr></table></td>";
393 }
394
395 function Schedule_Show_Days($Days_Set="")
396 {
397     if ($Days_Set==""){
398     echo "<input type=radio name=all_days value=1 checked>"; echo _("All"); echo "<br>";
399     echo "<input type=radio name=all_days value=0 >"; echo _("Selected"); echo "<br>";
400     }
401     else{
402     echo "<input type=radio name=all_days value=1 >"; echo _("All"); echo "<br>";
403     echo "<input type=radio name=all_days value=0 checked>"; echo _("Selected"); echo "<br>";
404     }
405
406     echo "<table> <tr>";
407     echo "<td valign=top><select multiple size=12 name=days[]>";
408     for ($days=1; $days<=31; $days++)
409     {
410 /*        if (($days==13)||($days==25))
411         {
412             echo "</select></td>";
413             echo "<td valign=top><select multiple size=12 name=days[]>";
414         }
415 */        if (strstr($Days_Set,":$days:"))
416             echo "<option value=\"$days\" selected>$days";
417         else
418             echo "<option value=\"$days\" >$days";
419     }
420     echo "</select></td>";
421     echo "</tr></table></td>";
422 }
423
424 function Schedule_Show_Months($Months_Set="")
425 {
426     if ($Months_Set==""){
427     echo "<input type=radio name=all_months value=1 checked>"; echo _("All"); echo "<br>";
428     echo "<input type=radio name=all_months value=0 >"; echo _("Selected"); echo "<br>";
429     }
430     else{
431     echo "<input type=radio name=all_months value=1 >"; echo _("All"); echo "<br>";
432     echo "<input type=radio name=all_months value=0 checked>"; echo _("Selected"); echo "<br>";
433     }
434     echo "<table> <tr>";
435     echo "<td valign=top><select multiple size=12 name=months[]>";
436     echo (strstr($Months_Set,":1:") ? '<option value="1" selected>'._("January"):'<option value="1" >'._("January"));
437      echo (strstr($Months_Set,":2:") ? '<option value="2" selected>'._("February"):'<option value="2" >'._("February"));
438      echo (strstr($Months_Set,":3:") ? '<option value="3" selected>'._("March"):'<option value="3" >'._("March"));
439      echo (strstr($Months_Set,":4:") ? '<option value="4" selected>'._("April"):'<option value="4" >'._("April"));
440      echo (strstr($Months_Set,":5:") ? '<option value="5" selected>'._("May"):'<option value="5" >'._("May"));
441      echo (strstr($Months_Set,":6:") ? '<option value="6" selected>'._("June"):'<option value="6" >'._("June"));
442      echo (strstr($Months_Set,":7:") ? '<option value="7" selected>'._("July"):'<option value="7" >'._("July"));
443      echo (strstr($Months_Set,":8:") ? '<option value="8" selected>'._("August"):'<option value="8" >'._("August"));
444      echo (strstr($Months_Set,":9:") ? '<option value="9" selected>'._("September"):'<option value="9" >'._("September"));
445      echo (strstr($Months_Set,":10:") ? '<option value="10" selected>'._("October"):'<option value="10" >'._("October"));
446      echo (strstr($Months_Set,":11:") ? '<option value="11" selected>'._("November"):'<option value="11" >'._("November"));
447      echo (strstr($Months_Set,":12:") ? '<option value="12" selected>'._("December"):'<option value="12" >'._("December"));
448
449     echo "</select></td>";
450     echo "</tr></table></td>";
451 }
452
453 function Schedule_Show_Weekdays($Weekdays_Set="")
454 {
455     if ($Weekdays_Set==""){
456     echo "<input type=radio name=all_weekdays value=1 checked>";echo _("All"); echo "<br>";
457     echo "<input type=radio name=all_weekdays value=0 >";echo _("Selected"); echo "<br>";
458     }
459     else{
460     echo "<input type=radio name=all_weekdays value=1 >";echo _("All"); echo "<br>";
461     echo "<input type=radio name=all_weekdays value=0 checked>";echo _("Selected"); echo "<br>";
462     }
463     echo "<table> <tr>";
464     echo "<td valign=top><select multiple size=12 name=weekdays[]>";
465     echo (strstr($Weekdays_Set,":1:") ? '<option value="1" selected>'._("Monday"):'<option value="1" >'._("Monday"));
466     echo (strstr($Weekdays_Set,":2:") ? '<option value="2" selected>'._("Tuesday"):'<option value="2" >'._("Tuesday"));
467     echo (strstr($Weekdays_Set,":3:") ? '<option value="3" selected>'._("Wednesday"):'<option value="3" >'._("Wednesday"));
468     echo (strstr($Weekdays_Set,":4:") ? '<option value="4" selected>'._("Thursday"):'<option value="4" >'._("Thursday"));
469     echo (strstr($Weekdays_Set,":5:") ? '<option value="5" selected>'._("Friday"):'<option value="5" >'._("Friday"));
470     echo (strstr($Weekdays_Set,":6:") ? '<option value="6" selected>'._("Saturday"):'<option value="6" >'._("Saturday"));
471     echo (strstr($Weekdays_Set,":0:") ? '<option value="0" selected>'._("Sunday"):'<option value="0" >'._("Sunday"));
472
473     echo "</select></td>";
474     echo "</tr></table></td>";
475 }
476 function show_quickbar($Method="")
477 {
478 ?>
479     <tr bgcolor=#b7b7b7> <td colspan=6><?php echo _("Run Backup");?>
480     <select name=backup_schedule>
481     <option value=follow_schedule <?php echo ($Method == "follow_schedule" ? "SELECTED" : "")?>><?php echo _("Follow Schedule Below");?>
482     <option value=now <?php echo ($Method == "now" ? "SELECTED" : "")?>><?php echo _("Now");?>
483     <option value=daily <?php echo ($Method == "daily" ? "SELECTED" : "")?>><?php echo _("Daily (at midnight)");?>
484     <option value=weekly <?php echo ($Method == "weekly" ? "SELECTED" : "")?>><?php echo _("Weekly (on Sunday)");?>
485     <option value=monthly <?php echo ($Method == "monthly" ? "SELECTED" : "")?>><?php echo _("Monthly (on the 1st)");?>
486     <option value=yearly <?php echo ($Method == "yearly" ? "SELECTED" : "")?>><?php echo _("Yearly (on 1st Jan)");?>
487     </select>
488     </td></tr>
489 <?php
490 }
491 function show_schedule($quickbar="no", $BackupID="")
492 {
493     if ($BackupID==""){
494         $Minutes="";
495         $Hours="";
496         $Days="";
497         $Months="";
498         $Weekdays="";
499         $Method="follow_schedule";
500     }
501     else{
502         $backup_times=Get_Backup_Times($BackupID);
503         foreach ($backup_times as $bk_times)
504             $Minutes="$bk_times[0]"; $Hours="$bk_times[1]"; $Days="$bk_times[2]"; $Months="$bk_times[3]"; $Weekdays="$bk_times[4]"; $Method="$bk_times[5]";
505         
506     }
507     if ($quickbar=="yes")
508         show_quickbar($Method);
509     else
510         echo "<tr bgcolor=#7f7f7f>";
511     echo "<td><b>"._("Minutes")."</b></td> <td><b>"._("Hours")."</b></td> <td><b>"._("Days")."</b></td> <td><b>"._("Months")."</b></td><td><b>"._("Weekdays")."</b></td> </tr> <tr bgcolor=#b7b7b7>";
512     echo "<td valign=top>";
513     Schedule_Show_Minutes($Minutes);
514     echo "<td valign=top>";
515     Schedule_Show_Hours($Hours);
516     echo "<td valign=top>";
517     Schedule_Show_Days($Days);
518     echo "<td valign=top>";
519     Schedule_Show_Months($Months);
520     echo "<td valign=top>";
521     Schedule_Show_Weekdays($Weekdays);
522 }
523
524
Note: See TracBrowser for help on using the browser.