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

Revision 5830, 26.9 kB (checked in by p_lindheimer, 4 years ago)

#2694 display problem with any all selection

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