<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="icon" href="./includes/images/favicon.ico" type="image/x-icon">
<script type="text/javascript" language="javascript" src="includes/validation_modul.js"></script>
<script type="text/javascript" language="javascript" src="includes/js/jquery-1.5.1.js"></script>
<link type="text/css" href="includes/css/custom-theme/jquery-ui-1.8.10.custom.css" rel="Stylesheet" />
<script type="text/javascript" src="includes/js/jquery-ui-1.8.10.custom.min.js"></script>

<script type="text/javascript" language="javascript">

var activated=false;

var req = false;

//AJAX Request nach dem reboot
function setRequest() {
	// Request erzeugen
		if (window.XMLHttpRequest) {
			req = new XMLHttpRequest(); // Mozilla, Safari, Opera
		} else if (window.ActiveXObject) {
			try {
				req = new ActiveXObject('Msxml2.XMLHTTP'); // IE 5
			} catch (e) {
				try {
					req = new ActiveXObject('Microsoft.XMLHTTP'); // IE 6
				} catch (e) {}
			}
		}


	// überprüfen, ob Request erzeugt wurde
	if (!req) {
		alert('Can not create an XMLHTTP instance');
		return false;
	} else {
		var url = 'index.php';
		// Request öffnen
		req.open('GET', url, true);
		// Requestheader senden
		// Request senden
		req.send(null);
		// Request auswerten
		req.onreadystatechange = interpretRequest;
	}
}

// Request auswerten
function interpretRequest() {
	switch (req.readyState) {
		// wenn der readyState 4 und der request.status 200 ist, dann ist alles korrekt gelaufen
		case 4:
			if (req.status != 200) {
				//Request senden solange die karte down ist.
				setRequest();
			} else {
				// Die karte wurde schon neugestartet
				window.location='./index.php';
			}
			break;
		default:
			break;
	}
}
//AJAX Request Ende

//Erzeugt die Netmaske anhand der IP Adresse
function makeNetMask(IPvalue){
	var ipPattern = /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;
	var ipArray = IPvalue.match(ipPattern);

	if (ipArray != null){
		if (ipArray[1]>=0 && ipArray[1]<=127) return "255.0.0.0";
		if (ipArray[1]>=128 && ipArray[1]<=191) return "255.255.0.0";
		if (ipArray[1]>=192 && ipArray[1]<=223) return "255.255.255.0";
	}
	return "";
}

//Popup Fenster öffnen
function new_window(URL){
	left_pos=((screen.width-750)/2);
	height_pos=((screen.height-400)/2);
	window.open(URL,"beroAri","width=750, height=400, left=" + left_pos + ", top=" + height_pos + " , menubar=no, location=no, resizable=yes, scrollbars=yes, status=no");
}

//Erzeugt der Farbeneffekt in der Tabellen
function paint(){
	$(document).ready(function() {
		$(".contenttoc").each(function() {
			try{
				for(var i=0;i<$(this).attr("rows").length;i++){
					color(i,$(this).attr("rows"));
				}
			}catch(e){

			}
		});

	});



}

function color(b,_rows){
	if(b%2==0){
		_rows[b].style.backgroundColor="#ebdfdf";
	}else{
		_rows[b].style.backgroundColor="#F0F0EC";
	}
}

//Anzeige der verschiedene "activate" knöpfe
function aktivieren(aktiv,m,option,text){

	if (m=="callprogress_ent") m="callprogress";
	if (aktiv==1 && activated==false){
		if (option==2){
			document.getElementById('aktiv').innerHTML= '<a href="javascript:window.location=(\'./includes/create_files.php?m='+ m +'\');" onclick="if(confirm(\'With this action you go to finish all the calls\') == false){return false;}else{document.getElementById(\'aktivieren2\').disabled=true;}"><input type=\'button\' id=\'aktivieren2\' value=\''+text+'\'></a>';
		}else if  (option==3){
			document.getElementById('aktiv').innerHTML= '<a href="javascript:window.location=(\'./includes/create_files.php?m='+ m +'\');" onclick="if(confirm(\'With this action you go to finish all the calls and the system will reboot\') == false){return false;}else{document.getElementById(\'aktivieren3\').disabled=true;}"><input type=\'button\' id=\'aktivieren3\' value=\''+text+'\'></a>';
		}else{
			document.getElementById('aktiv').innerHTML= '<a href="javascript:window.location=(\'./includes/create_files.php?m='+ m +'\');" onclick="document.getElementById(\'aktivieren1\').disabled=true";><input type=\'button\' id=\'aktivieren1\' value=\''+text+'\'></a>';
		}
		activated=true;
	}
}

//Der Button "Easy Configuration Wizard" wird angezeigt
//wenn die Datenbank sich in einem leeren Zustand befindet
function wizard(check,text){
	if (check==1)
			document.getElementById('wiz').innerHTML= '<a onclick="javascript:window.location.href=\'./index.php?m=wizard\';" ><input type=\'button\' id=\'wizzard\' value=\''+text+'\'></a>';
}




</script>
<link rel="stylesheet" type="text/css" href="./includes/template_css.css" />
<title>bero*fix</title>
</head>
<?php
$ba=new beroAri();
if ($_POST['lang']=="de")
	$ba->set("lang","de");
if ($_POST['lang']=="en")
	$ba->set("lang","en");

require_once("./includes/lang.php");
require_once("./includes/Helper.php");

function name($name){
	switch($name){
		case "": return STATE_TITLE_DIS;
		case "state": return STATE_TITLE_DIS;
		case "state_calls": return ACTIVE_CHANNELS_TITLE_DIS;
		case "state_statistic": return PORTS_STAT_TITLE_DIS;
		case "ddebug": return DIALPLAN_DEBUG_TITLE_DIS;
		case "ftrace": return FULL_TRACE_TITLE_DIS;
		case "pstn_hw": return HARDWARE_TITLE_DIS;
		case "net_conf": return NETWORK_TITLE_DIS;
		case "time": return TIME_TITLE_DIS;
		case "dialplan": return DIALPLAN_TITLE_DIS;
		case "sec": return SECURITY_TITLE_DIS;
		case "firewall": return FIREWALL_TITLE_DIS;
		case "up_tool": return UPDATE_TOOL_TITLE_DIS;
		case "prov": return PROVISIONING_TITLE_DIS;
		case "info": return INFO_TITLE_DIS;
		case "rebres": return REBOOT_RESET_TITLE_DIS;
		case "gen": return LOGGING_TITLE_DIS;
		case "sipg": return SIP_GENERAL_TITLE_DIS;
		case "shell": return "SHELL";
		case "remoteM": return REMOTE_MANAGEMENT_TITLE_DIS;
		case "isdn-pri": return ISDN_PRI_TITLE_DIS;
		case "isdn-bri": return ISDN_BRI_TITLE_DIS;
		case "analog-fxo": return ANALOG_FXO_TITLE_DIS;
		case "analog-fxs": return ANALOG_FXS_TITLE_DIS;
		case "gsm": return GSM_TITLE_DIS;
		case "gsmGen": return GSM_GENERAL_TITLE_DIS;
		case "sms": return SMS_TITLE_DIS;
		case "sip": return SIP_TITLE_DIS;
		case "cdr": return CDR_TITLE_DIS;
		case "berofos": return BEROFOS_TITLE_DIS;
		case "back_res": return BACKUP_RESTORE_TITLE_DIS;
		case "causes": return ISGW_CAUSES_TITLE_DIS;
		case "callprogress": return CALL_PROGRESS_TITLE_DIS;
		case "callprogress_ent": return CALL_PROGRESS_TITLE_DIS;
		case "uninstall": return UNINSTALL_TITLE_DIS;

	}
}
	$query=$ba->select("select option from activate where id='activate'");
	while($entry = $ba->fetch_array($query)){
		$option=$entry['option'];
		if ($entry['option']!=0) $aktiv='1';
		else $aktiv=0;
	}

//Aufbau des HTML Codes
$ret.= "<body onload=\"aktivieren(".$aktiv.",'".$_GET['m']."',".$option.",'".ACTIVATE."'); paint(); wizard(".check().",'".WIZARD."');\">
	<script type=\"text/javascript\" src=\"./includes/notes/wz_tooltip.js\"></script>
	<div id='wait_div' align='center' style='display:none;	padding-top:100px;	position:absolute;	width:100%;	height:100%;	z-index:110;	background-color: rgb(255, 255, 255);'><p>".UPLOAD_WAIT."</p><br/>
	<img src='./includes/images/waitlogo1.gif'/>
	</div>
	<br>
	<table align=\"center\" bgcolor=\"#f0f0ec\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"900\">
	    <colgroup>
	    	<col width=\"39\"></col>
	    </colgroup>
		<tbody>
			<tr>
				<td colspan=\"2\"><img src=\"./includes/images/bg_topindex.png\"></td>
			</tr>
			<tr>
			<td background=\"./includes/images/bg_left.png\" style='background-repeat:repeat-y;' width=\"30\">
				<img src=\"./includes/images/trans.gif\" height=\"10\" width=\"39\">
			</td>
			<td style='text-align: center;'>
				<table border='0' align='left' width='100%'>
					<tr>
						<td align='left'><img src=\"./includes/images/berofixlogo.png\"/></td>

						<td>
							<table border='0' align='right'>
							    <tr>
							        <td>
							        	".LANGUAGES.":
							        </td>
				        			<td>
				        				<form action='' method='POST'>
											<input type='hidden' name='lang' value='en'>
											<input type='image' src=\"./includes/images/englisch.gif\" height='15px' width='22px'/>
										</form>
				        			</td>
				        			<td>
							        	<form action='' method='POST'>
											<input type='hidden' name='lang' value='de'>
											<input type='image' src=\"./includes/images/deutsch.gif\" height='15px' width='22px'/>
										</form>
							        </td>
							    </tr>
							</table>
						</td>
					</tr>
				</table>

				<br><br>
				<br><br>

				<hr size=\"1\" noshade>
				<p><center>
					<font size='5' color='#918e8c' face='Loma,Sans,Arial'>" .name($_GET['m'])."</font>
				</p>
				<br>
				<br>";
				include "includes/menu.php";
				$ret.= "<br><div id='reset_jumper' style='color:red; font-size:13px;'></div>
				<div id='hardware_ch' style='color:red; font-size:13px;'></div>
				<div id='wiz' style='margin-top:5px;'></div>
				<div id='aktiv' style='margin-top:5px;'></div>";
?>
