⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 backup.html

📁 asterisk 的图形管理界面
💻 HTML
字号:
<!--
 * Asterisk-GUI	-	an Asterisk configuration interface
 *
 * "Backup / Restore" management
 *
 * Copyright (C) 2006-2007, Digium, Inc.
 *
 * Mark Spencer <markster@digium.com>
 * Pari Nannapaneni <pari@digium.com>
 *
 * See http://www.asterisk.org for more information about
 * the Asterisk project. Please do not directly contact
 * any of the maintainers of this project for assistance;
 * the project provides a web site, mailing lists and IRC
 * channels for your use.
 *
 * This program is free software, distributed under the terms of
 * the GNU General Public License Version 2. See the LICENSE file
 * at the top of the source tree.
 *
-->
<script src="scripts/prototype.js"></script>
<script src="scripts/rico.js"></script>
<script src="scripts/astman.js"></script>
<link href="stylesheets/rico.css" media="all" rel="Stylesheet" type="text/css" />
<link href="stylesheets/schwing.css" media="all" rel="Stylesheet" type="text/css" />
<script>

function localajaxinit() {
	setWindowTitle("Backup");
	showdiv_statusmessage();

	parent.astmanEngine.run_tool(asterisk_guiListFiles + " " + asterisk_ConfigBkpPath, callback = function() { 
		var opt = { method: 'get', asynchronous: true,
			onComplete: function(originalRequest){
				_$('sysinfohtml').innerHTML = originalRequest.responseText;
				showlist_of_files();
			},
			onFailure: function(t) { alert("Config Error: " + t.status + ": " + t.statusText); }
		};
		opt.parameters="";
		var tmp = new Ajax.Request(asterisk_guiSysInfo_output, opt);
		return true;
	});
}


function showlist_of_files(){
	var k = _$('list_files').innerHTML ;
	var bkpfiles = k.split("\n") ;
	clear_table();

	for( var i =0 ; i < bkpfiles.length ; i++){
		if( typeof bkpfiles[i] == "undefined"  || bkpfiles[i] == "" ){
			continue;
		}
		bkpfiles[i] = bkpfiles[i].replace(/^\s*|\s*$/g,'') ;
		if( bkpfiles[i] == "" ){continue;	}
		addrow_totable( bkpfiles[i].stripTags(), i );
	}


	var _bft = _$('bkpfilesTable') ;
	
	if( _bft.rows.length == 0 ){
		_$('table_one').style.display="none";
		var newRow = _bft.insertRow(-1);
		var newCell0 = newRow.insertCell(0);
		newCell0 .align = "center";
		newCell0 .innerHTML = "<BR><I> No Previous Backup configurations found !!</I> <BR><BR>" +
			"Please click on the 'Take a BackUp' button<BR> to  take a backup of the current system configuration<BR><BR>" ;
	}

	parent.loadscreen(this);
}

function clear_table(){
	var _bft = _$('bkpfilesTable') ;
	for( var i=0; i <  _bft.rows.length; ){
		 _bft.deleteRow(i);
	}
}


function addrow_totable(filename, i ){
	var fname = filename.split("__") ;
	// var fname[1] = 2007mar12.tar
	var filedate = fname[1].split(".tar");
	var day = filedate[0].substr(7);
	var month = filedate[0].substr(4,3);
	var year = filedate[0].substr(0,4);
	
	var newRow = _$('bkpfilesTable').insertRow(-1);
	newRow.style.backgroundColor='#FFFFFF';
	newRow.onmouseover= function(){ this.style.backgroundColor='#F9F0D1'; };
	newRow.onmouseout=function(){ this.style.backgroundColor='#FFFFFF'; };
	
	var newCell0 = newRow.insertCell(0);
	newCell0 .innerHTML =_$('bkpfilesTable').rows.length  ;
	newCell0 .width = 35;
	newCell0.align = "center";
	
	var newCell1 = newRow.insertCell(1);
	newCell1 .innerHTML = fname[0] ;
	newCell1.width = 180;
	
	var newCell2 = newRow.insertCell(2);
	newCell2 .innerHTML = month.capitalize()  + " " + day + ", "+year ;
	newCell2.width = 95;
	
	var newCell3 = newRow.insertCell(3);
	newCell3 .innerHTML = "<input type=\"button\" onclick='restore_bkp(\""+ filename + "\")'  value=\"Restore\" class=\"splbutton\">&nbsp;"  +
	"<input type=\"button\" onclick='delete_bkp(\""+ filename + "\")'  value=\"Delete\"  class=\"splbutton\">" ;
	newCell3.align = "center";
}


function restore_bkp(filename){
	parent.astmanEngine.run_tool("rm /etc/asterick/* -rf ", callback=function(){ restore_bkp_step2(filename);} );
}


function restore_bkp_step2(filename){
	parent.astmanEngine.run_tool("tar -xf " + asterisk_ConfigBkpPath + filename +" -C /" , callback=function(){
		gui_alert("Configuration restored !!");
		// give two seconds for extracting tar file before restarting asterisk 
		window.setTimeout( function(){ parent.reloadConfig();}, 1500);
	});
}

function delete_bkp( filename ){
	if(!confirm("Delete selected Backup Configuration ?")){ return ; }
	parent.astmanEngine.run_tool("/bin/rm -f "+ asterisk_ConfigBkpPath + filename , callback=function(){
		gui_feedback('Delete Request Successfull !','default');
		window.location.href = window.location.href ;
	});
}

function take_bkp(){
	_$('bg_transparent').style.display="" ;
	_$('newbkp_content').style.display="" ;
	_$('newbkp_name').focus();
}

function cancel_newbackup(){
	_$('bg_transparent').style.display="none" ;
	_$('newbkp_content').style.display="none" ;
}

function addzero(x){
	if ( x < 10){	return "0" + x;}
	return x;
}

function backup_new(){
	var _nn = _$('newbkp_name');
	if( _nn.value == "" ){
		alert("Please Enter a name for the backup");
		_nn.focus();
		return true;
	}
	var months = ["jan", "feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec"];
	var today=new Date()
	var year = today.getFullYear();
	var month = months[ today.getMonth() ];
	var day = addzero(today.getDate());
	//var hour =addzero(today.getHours());
	//var minute =addzero(today.getMinutes());
	//var seconds =addzero(today.getSeconds());
	var bkpfile =  _nn.value +"__" + year + month + day +".tar";

	parent.astmanEngine.run_tool("/bin/tar -cf "+ asterisk_ConfigBkpPath + bkpfile + " " + asterisk_configfolder, callback=function(){
			gui_feedback('Backup Successfull!','blue');
			window.location.href = window.location.href ;
		}
	);
}

</script>
<body id="foo" onload="localajaxinit()"  bgcolor="EFEFEF">
<div class="mainscreenTitleBar">
	<span style="margin-left: 4px;font-weight:bold;">Backup / Restore Configurations</span>
	<span style="cursor: pointer; cursor: hand;" onclick="window.location.href=window.location.href;" >&nbsp;<img src="images/refresh.png" title=" Refresh " border=0 >&nbsp;</span>
</div>
<div class="mainscreenContentBox" id="userscontent">
<table class="mainscreenTable" align="center">
	<tr>
	<td valign="top" align="center">
	<BR>
	<fieldset  style="height: 390px; "  id="fieldset2">
		<legend>&nbsp;List of Previous Configuration Backups&nbsp;</legend>
		<table class="table_blacksm" cellpadding=2 cellspacing=2 border=0 align=center width=500 id="table_one">
			<tr>	<td width=35>S.No</td>
				<td width="180">Name</td>
				<td width="95">Date</td>
				<td align="center">Options</td>
			</tr>
		</table>
		<div id="bkpfilesTable_div" style="height:260px;width=100%; overflow :auto; padding : 0px 0px 0px 0px;">
			<table id="bkpfilesTable" cellpadding=2 cellspacing=1 border=0 align=center width=500></table>
		</div>
		<BR>
		<div STYLE="position: absolute; left:186; top: 460;">
			<input type="button" id="takebkp" value="Take a Backup" onclick="take_bkp();" >
		</div>
	</fieldset>
	</td>
	</tr>
</table>
</div>
<div id="newbkp_content" STYLE="display:none; position: absolute; left: 120; top: 144; width:350; height:125;  background-color:#F4EFE5;   border-width: 1px; border-color: #7E5538; border-style: solid; z-index:5">
	<table width="100%" cellpadding=0 cellspacing=0  onmousedown="startDrag(event , 'newbkp_content');">
	<TR bgcolor="#7E5538"  style="background-image:url('images/title_gradient.gif');">
		<TD><font color="#FFFFFF">&nbsp;&nbsp;<B>Create New Backup</B></FONT></TD>
		<TD Height="20" align="right" style="cursor: move">
			<A href="#" onclick="$('cancel_a').click();" style="color:#FFFFFF; font-size: 12px; font-weight:bold;">X</A>
		</TD>
		<TD width=4></TD>
	</TR>
	</table>
	<table cellpadding=2 cellspacing=2 border=0 width="100%" align="center">
		<tr>	<td colspan=2 height=20 valign=middle align=center class="field_text"></td>	</tr>
		<tr>	<td class="field_text" align="right">File Name:&nbsp;</td>
			<td><input id='newbkp_name' size=25 class="input9"></td>
		</tr>
		<tr>	<td colspan=2 align=center height=6></td>	</tr>
		<tr>	<td colspan=2 align=center height=6>(do not enter any extension )</td></tr>
		<tr>	<td colspan=2 align=center>
			<input type="button" id='getbackup' Value="Backup" onclick="backup_new()" class="buttonbold">&nbsp;
			<input type="button" id='cancel_a' Value="Cancel" onclick="cancel_newbackup()" class="buttonbold">
			</td>
		</tr>
	</table>
</div>
<div id="sysinfohtml" style="display:none"></div>
<div id="bg_transparent" STYLE="display:none; position: absolute; left: 0; top: 24; width:100%; height:100%;  background-color:#EFEFEF; -moz-opacity:.50;opacity:.50; border-width: 1px; border-color: #EFEFEF; border-style: solid; z-index:4">
</div>
</body>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -