Пример #1
0
function Show_Backup_Options($ID = "")
{
    if ($ID == "") {
        $name = "";
        $voicemail = "no";
        $sysrecordings = "no";
        $sysconfig = "no";
        $cdr = "no";
        $fop = "no";
    } else {
        $backup_options = Get_Backup_Options($ID);
        foreach ($backup_options as $bk_options) {
            $name = "{$bk_options['0']}";
        }
        $voicemail = "{$bk_options['1']}";
        $sysrecordings = "{$bk_options['2']}";
        $sysconfig = "{$bk_options['3']}";
        $cdr = "{$bk_options['4']}";
        $fop = "{$bk_options['5']}";
    }
    ?>
	<tr>
 		<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>
 		<?php 
    if ($voicemail == "yes") {
        ?>
 			<td><input type="radio" name="bk_voicemail" value="yes" checked=checked/> yes &nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" name="bk_voicemail" value="no"/> no</td>
 		<?php 
    } else {
        ?>
 			<td><input type="radio" name="bk_voicemail" value="yes" /> yes &nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" name="bk_voicemail" value="no" checked=checked/> no</td>
 		<?php 
    }
    ?>
 	</tr>
	<tr>
 		<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>
 		<?php 
    if ($sysrecordings == "yes") {
        ?>
 			<td><input type="radio" name="bk_sysrecordings" value="yes" checked=checked/> yes &nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" name="bk_sysrecordings" value="no"/> no</td>
 		<?php 
    } else {
        ?>
 			<td><input type="radio" name="bk_sysrecordings" value="yes" /> yes &nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" name="bk_sysrecordings" value="no" checked=checked/> no</td>
 		<?php 
    }
    ?>
 	</tr>
	<tr>
 		<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>
 		<?php 
    if ($sysconfig == "yes") {
        ?>
 			<td><input type="radio" name="bk_sysconfig" value="yes" checked=checked/> yes &nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" name="bk_sysconfig" value="no"/> no</td>
 		<?php 
    } else {
        ?>
 			<td><input type="radio" name="bk_sysconfig" value="yes" /> yes &nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" name="bk_sysconfig" value="no" checked=checked/> no</td>
 		<?php 
    }
    ?>
 	</tr>
	<tr>
 		<td><a href="#" class="info"><?php 
    echo _("CDR");
    ?>
<span><?php 
    echo _("Backup the System Call Detail Reporting (HTML and Database)");
    ?>
</span></a>: </td>
 		<?php 
    if ($cdr == "yes") {
        ?>
 			<td><input type="radio" name="bk_cdr" value="yes" checked=checked/> yes &nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" name="bk_cdr" value="no"/> no</td>
 		<?php 
    } else {
        ?>
 			<td><input type="radio" name="bk_cdr" value="yes" /> yes &nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" name="bk_cdr" value="no" checked=checked/> no</td>
 		<?php 
    }
    ?>
 	</tr>
	<tr>
 		<td><a href="#" class="info"><?php 
    echo _("Operator Panel");
    ?>
<span><?php 
    echo _("Backup the Operator Panel (HTML and Database)");
    ?>
</span></a>: </td>
 		<?php 
    if ($fop == "yes") {
        ?>
 			<td><input type="radio" name="bk_fop" value="yes" checked=checked/> yes &nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" name="bk_fop" value="no"/> no</td>
 		<?php 
    } else {
        ?>
 			<td><input type="radio" name="bk_fop" value="yes" /> yes &nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" name="bk_fop" value="no" checked=checked/> no</td>
 		<?php 
    }
    ?>
 	</tr>
	<?php 
}
Пример #2
0
function backup_showopts($id = '')
{
    global $amp_conf;
    $tabindex = 0;
    if ($id == '') {
        $opts = array('name', 'voicemail', 'recordings', 'configurations', 'cdr', 'fop');
        foreach ($opts as $o) {
            $opts[$o] = '';
        }
        //set defaults to ''
    } else {
        $opts = Get_Backup_Options($id);
    }
    $files = $opts['include'] || $opts['exclude'];
    $ftp = $opts['ftpuser'] || $opts['ftppass'] || $opts['ftphost'] || $opts['ftpdir'];
    $ssh = $opts['sshuser'] || $opts['sshkey'] || $opts['sshhost'] || $opts['sshdir'];
    $email = $opts['emailaddr'];
    $remote = $opts['remotesshhost'] || $opts['remotesshuser'] || $opts['remotesshkey'] || $opts['remoterestore'];
    $advanced = $amp_conf['AMPBACKUPADVANCED'] || $opts['sudo'];
    ?>
	<style type="text/css">
		tr .tog{cursor:pointer;}
		tr .tog span{color:black}
		<?php 
    $sections = array('files', 'ftp', 'ssh', 'email', 'remote', 'advanced');
    foreach ($sections as $sec) {
        if (!${$sec}) {
            echo '.hide.' . $sec . '{display:none}' . "\n";
        }
    }
    if (!$advanced) {
        echo '.advanced{display:none}' . "\n";
    }
    ?>
		h5{margin-top:10px;margin-bottom:10px}
	</style>
	<script language="javascript" type="text/javascript">
		$(document).ready(function() {
   		$('.tog').click(function(){
   			var tclass = $(this).attr('class'); tclass = tclass.replace('tog ', '');
   			var togspan = $(this).find('span');
   			if(togspan.text()=='+'){
   				togspan.text('- ');
		 			$('.'+tclass).show();
		 		}else{
		 			togspan.text('+');
		 			$('.'+tclass).not('.tog').hide();
		 		}
			 });
			 $('.sysconfigdep').click(function(){
			 		if($(this).is(':checked')){
			 			$('.sysconfig').attr('checked', true);
			 		}
			 })
			 $('.sysconfig').click(function(){
			 		if(!$(this).is(':checked')){
			 			$('.sysconfigdep').attr('checked', false);
			 		}
			 })
		});
	</script>
	<table>
	<tr><td colspan="2"><h5><?php 
    echo _("Basic Settings");
    ?>
<hr></h5></td></tr>
  <tr>
      <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>
      <td><input type="text" name="name" value="<?php 
    echo isset($opts['name']) ? $opts['name'] : '';
    ?>
" tabindex="<?php 
    echo ++$tabindex;
    ?>
"></td>
  </tr>
	<tr>
 		<td><a href="#" class="info"><?php 
    echo _("Admin Web Directory");
    ?>
<span><?php 
    echo _("Backup the admin web directory (i.e. the static FreePBX web files). This is useful to have during a restore to prevent a version mismatch, but can dramatically increase the backup size.");
    ?>
</span></a>: </td>
 		<td><input type="checkbox" name="admin" value="yes" class="sysconfigdep" <?php 
    echo $opts['admin'] == 'yes' ? 'checked' : '';
    ?>
/></td>
 	</tr>
 	<tr>
 		<td><a href="#" class="info"><?php 
    echo _("CDR");
    ?>
<span><?php 
    echo _("Backup the System Call Detail Reporting (HTML and Database)");
    ?>
</span></a>: </td>
 		<td><input type="checkbox" name="cdr" value="yes" <?php 
    echo $opts['cdr'] == 'yes' ? 'checked' : '';
    ?>
/></td>
 	</tr>
	<tr>
 		<td><a href="#" class="info"><?php 
    echo _("Operator Panel");
    ?>
<span><?php 
    echo _("Backup the Operator Panel (HTML and Database)");
    ?>
</span></a>: </td>
 		<td><input type="checkbox" name="fop" value="yes" <?php 
    echo $opts['fop'] == 'yes' ? 'checked' : '';
    ?>
/></td>
	</tr>
	<tr>
 		<td><a href="#" class="info"><?php 
    echo _("Overwrite Backup Settings");
    ?>
<span><?php 
    echo _("When restoring the backup, if this option is selected, all saved backups and their schedules will be overwriten. Leaving this unchecked will restore all other configurations EXCEPT for those related to backup. When doing a remote backup and restore, this option is always forced to no.");
    ?>
</span></a>: </td>
 		<td><input type="checkbox" name="overwritebackup" value="yes" class="sysconfigdep" <?php 
    echo $opts['overwritebackup'] == 'yes' ? 'checked' : '';
    ?>
/></td>
 	</tr>	
	<tr>
 		<td><a href="#" class="info"><?php 
    echo _("System Recordings");
    ?>
<span><?php 
    echo _("Backup the System Recordings (AutoAttendant, Music On Hold, System Recordings)");
    ?>
</span></a>: </td>
 		<td><input type="checkbox" name="recordings" value="yes" <?php 
    echo $opts['recordings'] == 'yes' ? 'checked' : '';
    ?>
 /></td>
 	</tr>
	<tr>
 		<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>
 		<td><input type="checkbox" name="voicemail"  tabindex="<?php 
    echo ++$tabindex;
    ?>
" value="yes" <?php 
    echo $opts['voicemail'] == 'yes' ? 'checked' : '';
    ?>
 /></td>
 	</tr>
 	<tr>
 		<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>
 		<td><input type="checkbox" name="configurations" value="yes" class="sysconfig" <?php 
    echo $opts['configurations'] == 'yes' ? 'checked' : '';
    ?>
/></td>
 	</tr>

	<tr><td colspan="2" class="tog files"><h5><span><?php 
    echo $files ? '-' : '+';
    ?>
</span><?php 
    echo _(' Additional Files');
    ?>
<hr></h5></td></tr>
	<tr class="hide files">
 		<td><a href="#" class="info"><?php 
    echo _("Additional files and folders");
    ?>
<span><?php 
    echo _("Backup any additional files and folders listed here.");
    ?>
</span></a>: </td>
 		<td><textarea name="include" style="width: 400px" /><?php 
    echo $opts['include'];
    ?>
</textarea></td>
	</tr>
	<tr class="hide files">
 		<td><a href="#" class="info"><?php 
    echo _("Exclude files and folders");
    ?>
<span><?php 
    echo _("Exclude any files and folders from the include listed above.");
    ?>
</span></a>: </td>
 		<td><textarea name="exclude" style="width: 400px" /><?php 
    echo $opts['exclude'];
    ?>
</textarea></td>
	</tr>
	
	<tr><td colspan="2" class="tog ftp"><h5><span><?php 
    echo $ftp ? '-' : '+';
    ?>
</span><?php 
    echo _(' FTP Settings');
    ?>
<hr></h5></td></tr>
	<tr class="hide ftp">
 		<td><a href="#" class="info"><?php 
    echo _("FTP User Name");
    ?>
<span><?php 
    echo _('Enter your FTP user name');
    ?>
</span></a>: </td>
 		<td><input type="text" name="ftpuser" value="<?php 
    echo $opts['ftpuser'];
    ?>
" /></td>
	</tr>
	<tr class="hide ftp">
 		<td><a href="#" class="info"><?php 
    echo _("FTP Password");
    ?>
<span><?php 
    echo _('Enter your FTP password');
    ?>
</span></a>: </td>
 		<td><input type="text" name="ftppass" value="<?php 
    echo $opts['ftppass'];
    ?>
" /></td>
	</tr>
	<tr class="hide ftp">
 		<td><a href="#" class="info"><?php 
    echo _("FTP Hostname");
    ?>
<span><?php 
    echo _('IP address or FQDN of FTP server');
    ?>
</span></a>: </td>
 		<td><input type="text" name="ftphost" value="<?php 
    echo $opts['ftphost'];
    ?>
" /></td>
	</tr>
	<tr class="hide ftp">
 		<td><a href="#" class="info"><?php 
    echo _("FTP Directory");
    ?>
<span><?php 
    echo _('Directory on FTP server where the backup should be copied to');
    ?>
</span></a>: </td>
 		<td><input type="text" name="ftpdir" value="<?php 
    echo $opts['ftpdir'];
    ?>
" /></td>
	</tr>
	
	<tr><td colspan="2" class="tog ssh"><h5><span><?php 
    echo $ssh ? '-' : '+';
    ?>
</span><?php 
    echo _(' SSH Settings');
    ?>
<hr></h5></td></tr>
	<tr class="hide ssh">
 		<td><a href="#" class="info"><?php 
    echo _("SSH User Name");
    ?>
<span><?php 
    echo _('Enter your SSH user name');
    ?>
</span></a>: </td>
 		<td><input type="text" name="sshuser" value="<?php 
    echo $opts['sshuser'];
    ?>
" /></td>
	</tr>
	<tr class="hide ssh">
 		<td><a href="#" class="info"><?php 
    echo _("SSH Key");
    ?>
<span><?php 
    echo _('Location of ssh private key to be used when connect to a host');
    ?>
</span></a>: </td>
 		<td><input type="text" name="sshkey" value="<?php 
    echo $opts['sshkey'];
    ?>
" /></td>
	</tr>
	<tr class="hide ssh">
 		<td><a href="#" class="info"><?php 
    echo _("SSH Hostname");
    ?>
<span><?php 
    echo _('IP address or FQDN of remote ssh host');
    ?>
</span></a>: </td>
 		<td><input type="text" name="sshhost" value="<?php 
    echo $opts['sshhost'];
    ?>
" /></td>
	</tr>
	<tr class="hide ssh">
 		<td><a href="#" class="info"><?php 
    echo _("SSH Directory");
    ?>
<span><?php 
    echo _('Directory on remote server where the backup should be copied to');
    ?>
</span></a>: </td>
 		<td><input type="text" name="sshdir" value="<?php 
    echo $opts['sshdir'];
    ?>
" /></td>
	</tr>	
	
	<tr><td colspan="2" class="tog email"><h5><span><?php 
    echo $email ? '-' : '+';
    ?>
</span><?php 
    echo _(' Email Settings');
    ?>
<hr></h5></td></tr>
	<tr class="hide email">
 		<td><a href="#" class="info"><?php 
    echo _("Email Address");
    ?>
<span><?php 
    echo _('Email address where backups should be emailed to');
    ?>
</span></a>: </td>
 		<td><input type="text" name="emailaddr" value="<?php 
    echo $opts['emailaddr'];
    ?>
" /></td>
	</tr>	
	<tr class="hide email">
 		<td><a href="#" class="info"><?php 
    echo _("Max email size");
    ?>
<span><?php 
    echo _('The maximum size a backup can be and still be emailed. Some email servers limit the size of email attachments, this will make sure that files larger than the max size are not sent. Valid options include: xB, xKB, xMB');
    ?>
</span></a>: </td>
 		<td><select name="emailmaxsize">
 				<?php 
    if ($opts['emailmaxsize'] == '') {
        $opts['emailmaxsize'] = 25;
    }
    //default max email size to 25
    for ($i = 1; $i < 21; $i++) {
        echo '<option value="' . $i . '" ' . ($opts['emailmaxsize'] == $i ? 'selected' : '') . ' >' . $i . '</option>';
    }
    for ($i = 25; $i < 51; $i += 5) {
        echo '<option value="' . $i . '" ' . ($opts['emailmaxsize'] == $i ? 'selected' : '') . ' >' . $i . '</option>';
    }
    for ($i = 60; $i < 101; $i += 10) {
        echo '<option value="' . $i . '" ' . ($opts['emailmaxsize'] == $i ? 'selected' : '') . ' >' . $i . '</option>';
    }
    ?>
				</select>
				<select name="emailmaxtype">
 				<?php 
    if ($opts['emailmaxtype'] == '') {
        $opts['emailmaxtype'] = 'MB';
    }
    //default max type to MB
    $maxtypes = array('B', 'KB', 'MB');
    foreach ($maxtypes as $max) {
        echo '<option value="' . $max . '" ' . ($opts['emailmaxtype'] == $max ? 'selected' : '') . ' >' . $max . '</option>';
    }
    ?>
			</select>
 			</td>
	</tr>
	
	<tr><td colspan="2" class="tog remote"><h5><span><?php 
    echo $remote ? '-' : '+';
    ?>
</span><?php 
    echo _(' Remote Backup Options');
    ?>
<hr></h5></td></tr>
	<tr class="hide remote">
		<td><a href="#" class="info"><?php 
    echo _('Remote SSH Hostname');
    ?>
<span><?php 
    echo _('Run this backup on a remote server. The backup will then be copied over to this server');
    ?>
</span></a>: </td>
 		<td><input type="input" name="remotesshhost"  tabindex="<?php 
    echo ++$tabindex;
    ?>
" value="<?php 
    echo $opts['remotesshhost'];
    ?>
"/></td>
	</tr>
	<tr class="hide remote">
		<td><a href="#" class="info"><?php 
    echo _('Remote SSH User');
    ?>
<span><?php 
    echo _('Username to use when connecting to remote server. Defaults to the user apache is running as on this system.');
    ?>
</span></a>: </td>
 		<td><input type="input" name="remotesshuser"  tabindex="<?php 
    echo ++$tabindex;
    ?>
" value="<?php 
    echo $opts['remotesshuser'];
    ?>
"/></td>
	</tr>
	<tr class="hide remote">
 		<td><a href="#" class="info"><?php 
    echo _('Remote SSH Key');
    ?>
<span><?php 
    echo _('Location of ssh private key to be used when connecting to a host');
    ?>
</span></a>: </td>
 		<td><input type="text" name="remotesshkey" tabindex="<?php 
    echo ++$tabindex;
    ?>
" value="<?php 
    echo $opts['remotesshkey'];
    ?>
" /></td>
	</tr>
	<tr class="hide remote">
 		<td><a href="#" class="info"><?php 
    echo _('Restore to this server');
    ?>
<span><?php 
    echo _('Restore the backup to this server. Use this option to create a delayed time backup of another server on this one.');
    ?>
</span></a>: </td>
 		<td><input type="checkbox" name="remoterestore" tabindex="<?php 
    echo ++$tabindex;
    ?>
" value="yes" <?php 
    echo $opts['remoterestore'] == 'yes' ? 'checked' : '';
    ?>
 /></td>
	</tr>
	<tr class="advanced"><td colspan="2" class="tog advanced" ><h5><span><?php 
    echo $advanced ? '-' : '+';
    ?>
</span><?php 
    echo _(' Advanced Options');
    ?>
<hr></h5></td></tr>
	<tr  class="hide advanced">
		<td><a href="#" class="info"><?php 
    echo _("Sudo");
    ?>
<span><?php 
    echo _('Use sudo when performing a backup. NOTE: THIS HAS SEVERE SECURITY IMPLICATIONS!');
    ?>
</span></a>: </td>
 		<td><input type="checkbox" name="sudo"  tabindex="<?php 
    echo ++$tabindex;
    ?>
" value="yes" <?php 
    echo $opts['sudo'] == 'yes' ? 'checked' : '';
    ?>
 /></td>
	</tr>
	<?php 
}