<?php
require_once("misc/database.php");
$db=new beroAri();
if ($_SESSION['beroari_group']=='admin'){
	$ret.= "<table border='0' style='text-align:center;'>
			<tr>
				<td>
					<ul id=\"navmenu-h\">
						<li><a href=index.php?m=dialplan id='di'>".MENU_DIALPLAN."</a></li>
						<li><a href=# id='sip'>".MENU_SIP_CAT."</a>
							<ul>
								<li><a href=index.php?m=sip id='s'>".MENU_SIP."</a></li>
								<li><a href=index.php?m=sipg id='sg'>".MENU_SIP_GENERAL."</a></li>
							</ul>
						</li>
						<li><a href='#' id='pstn'>".MENU_PSTN_CAT."</a>
						<ul>";
						if (sqlite_num_rows($db->select("SELECT * from isdn where port_type='PRI'"))>0) $ret.="<li><a href=index.php?m=isdn-pri id='isdn-pri'>".MENU_ISDN_PRI."</a></li>";
						if (sqlite_num_rows($db->select("SELECT * from isdn where port_type='BRI'"))>0) $ret.="<li><a href=index.php?m=isdn-bri id='isdn-bri'>".MENU_ISDN_BRI."</a></li>";
						if (sqlite_num_rows($db->select("SELECT * from analog where port_type='FXS'"))>0) $ret.="<li><a href=index.php?m=analog-fxs id='analog-fxs'>".MENU_ANALOG_FXS."</a></li>";
						if (sqlite_num_rows($db->select("SELECT * from analog where port_type='FXO'"))>0) $ret.="<li><a href=index.php?m=analog-fxo id='analog-fxo'>".MENU_ANALOG_FXO."</a></li>";
						if (sqlite_num_rows($db->select("SELECT * from gsm "))>0){ $ret.="<li>
						<a href=index.php?m=gsm id='gsm'>".MENU_GSM."</a></li>
						<li><a href=index.php?m=gsmGen id='gsmGen'>".MENU_GSM_GENERAL."</a></li>
						<li><a href=index.php?m=sms id='sms'>".MENU_SMS."</a></li>
						";
						}
						$ret.="</ul>
						</li>
						<li><a href=index.php?m=pstn_hw id='ih'>".MENU_HARDWARE."</a></li>
						<li><a href='#' id='p'>".MENU_PREFERENCES_CAT."</a>
							<ul>
								<li><a href=index.php?m=net_conf id='net'>".MENU_NETWORK."</a></li>
								<li><a href=index.php?m=time id='time'>".MENU_TIME."</a></li>
								<li><a href=index.php?m=prov id='prov'>".MENU_PROVISIONING."</a></li>
								<li><a href=index.php?m=berofos id='berofos'>".MENU_BEROFOS."</a></li>
								<li><a href=index.php?m=gen id='gen'>".MENU_LOGGING."</a></li>
								<li><a href=index.php?m=sec id='sec'>".MENU_SECURITY."</a></li>
								<li><a href=index.php?m=causes id='causes'>".MENU_ISGW_CAUSES."</a></li>
								<li><a href=index.php?m=callprogress id='callprogress'>".MENU_CALL_PROGRESS."</a></li>
							</ul>
						</li>
						<li><a href='#' id='ma'>".MENU_MANAGEMENT_CAT."</a>
							<ul>
								<li><a href=index.php?m=state id='state'>".MENU_STATE."</a></li>
								<li><a href=index.php?m=state_calls id='sc'>".MENU_ACTIVE_CALLS."</a></li>
								<li><a href=index.php?m=state_statistic id='ss'>".MENU_PORTS_STAT."</a></li>
								<li><a href=index.php?m=back_res id='br'>".MENU_BACKUP_RES."</a></li>
								<li><a href=index.php?m=up_tool id='up_tool'>".MENU_UPDATE_TOOL."</a></li>
								<li><a href=index.php?m=ddebug id='ddebug'>".MENU_DIALPLAN_DEBUG."</a></li>
								<li><a href=index.php?m=ftrace id='ftrace'>".MENU_FULL_TRACE."</a></li>
								<li><a href=index.php?m=info id='info'>".MENU_INFO."</a></li>
								<li><a href=index.php?m=cdr id='cdr'>".MENU_CDR."</a></li>
								<li><a href=index.php?m=rebres id='rebres'>".MENU_REBOOT_RESET."</a></li>
								<li><a href=index.php?m=remoteM id='remoteM'>".MENU_REMOTE_MANAGEMENT."</a></li>";
								if ($_SESSION['beroari_username']=="beroAdmin"){
									$ret.= "<li><a href=index.php?m=shell id='shell'>".MENU_SHELL."</a></li>";

								}
					$ret.= "</ul></li>";

					$directory_not_empty = FALSE;
					if ($dh = @opendir("/home/admin/apps/")) {
                        while (($file = readdir($dh)) !== false) {
                            if($file != "." && $file != "..")
								$directory_not_empty = TRUE;
						}
                        closedir($dh);
                    }


                                    if ($directory_not_empty) {
                                    $ret.="<li><a href=# id='apps'>APPS +</a><ul>";
                                        if ($dh = @opendir("/home/admin/apps/")) {
                                            while (($file = readdir($dh)) !== false) {
                                                //$ret.="found file: $file";
                                                if($file != "." && $file != "..")
                                                    $ret.="<li><a href=/userapp/$file/index.php>".$file."</a></li>";
                                            }
                                            closedir($dh);
                                        }
									$ret.="<li><a href=index.php?m=uninstall id='uninstall'>".MENU_UNINSTALL."</a></li>";
                                    $ret.="</ul></li>";
                    }


						$ret.="<li><a href='includes/logout.php'>".MENU_LOGOUT."</a></li>
					</ul>
					<br>
				</td>
			</tr>
		</table>";

}
if ($_GET['m']=='sip'){
	$ret.= "<script>document.getElementById(\"s\").id=\"aktiv_men\";</script>";
	$ret.= "<script>document.getElementById(\"sip\").id=\"aktiv_men\";</script>";
}
if ($_GET['m']=='sipg'){
	$ret.= "<script>document.getElementById(\"sg\").id=\"aktiv_men\";</script>";
	$ret.= "<script>document.getElementById(\"sip\").id=\"aktiv_men\";</script>";
}
if ($_GET['m']=='isdn-pri'){
	$ret.= "<script>document.getElementById(\"pstn\").id=\"aktiv_men\";</script>";
	$ret.= "<script>document.getElementById(\"isdn-pri\").id=\"aktiv_men\";</script>";
}
if ($_GET['m']=='isdn-bri'){
	$ret.= "<script>document.getElementById(\"pstn\").id=\"aktiv_men\";</script>";
	$ret.= "<script>document.getElementById(\"isdn-bri\").id=\"aktiv_men\";</script>";
}
if ($_GET['m']=='analog-fxs'){
	$ret.= "<script>document.getElementById(\"pstn\").id=\"aktiv_men\";</script>";
	$ret.= "<script>document.getElementById(\"analog-fxs\").id=\"aktiv_men\";</script>";
}
if ($_GET['m']=='analog-fxo'){
	$ret.= "<script>document.getElementById(\"pstn\").id=\"aktiv_men\";</script>";
	$ret.= "<script>document.getElementById(\"analog-fxo\").id=\"aktiv_men\";</script>";
}
if ($_GET['m']=='gsm'){
	$ret.= "<script>document.getElementById(\"pstn\").id=\"aktiv_men\";</script>";
	$ret.= "<script>document.getElementById(\"gsm\").id=\"aktiv_men\";</script>";
}
if ($_GET['m']=='gsmGen'){
	$ret.= "<script>document.getElementById(\"pstn\").id=\"aktiv_men\";</script>";
	$ret.= "<script>document.getElementById(\"gsmGen\").id=\"aktiv_men\";</script>";
}
if ($_GET['m']=='dialplan'){
	$ret.= "<script>document.getElementById(\"di\").id=\"aktiv_men\";</script>";
}
if ($_GET['m']=='pstn_hw'){
	$ret.= "<script>document.getElementById(\"ih\").id=\"aktiv_men\";</script>";
}
if ($_GET['m']=='net_conf'){
	$ret.= "<script>document.getElementById(\"p\").id=\"aktiv_men\";</script>";
	$ret.= "<script>document.getElementById(\"net\").id=\"aktiv_men\";</script>";
}
if ($_GET['m']=='time'){
	$ret.= "<script>document.getElementById(\"p\").id=\"aktiv_men\";</script>";
	$ret.= "<script>document.getElementById(\"time\").id=\"aktiv_men\";</script>";
}
if ($_GET['m']=='sec'){
	$ret.= "<script>document.getElementById(\"p\").id=\"aktiv_men\";</script>";
	$ret.= "<script>document.getElementById(\"sec\").id=\"aktiv_men\";</script>";
}
if ($_GET['m']=='causes'){
	$ret.= "<script>document.getElementById(\"p\").id=\"aktiv_men\";</script>";
	$ret.= "<script>document.getElementById(\"causes\").id=\"aktiv_men\";</script>";
}
if ($_GET['m']=='callprogress'){
	$ret.= "<script>document.getElementById(\"p\").id=\"aktiv_men\";</script>";
	$ret.= "<script>document.getElementById(\"callprogress\").id=\"aktiv_men\";</script>";
}
if ($_GET['m']=='rebres'){
	$ret.= "<script>document.getElementById(\"ma\").id=\"aktiv_men\";</script>";
	$ret.= "<script>document.getElementById(\"rebres\").id=\"aktiv_men\";</script>";
}
if ($_GET['m']=='back_res'){
	$ret.= "<script>document.getElementById(\"ma\").id=\"aktiv_men\";</script>";
	$ret.= "<script>document.getElementById(\"br\").id=\"aktiv_men\";</script>";
}
if ($_GET['m']=='gen'){
	$ret.= "<script>document.getElementById(\"p\").id=\"aktiv_men\";</script>";
	$ret.= "<script>document.getElementById(\"gen\").id=\"aktiv_men\";</script>";
}
if ($_GET['m']=='up_tool'){
	$ret.= "<script>document.getElementById(\"ma\").id=\"aktiv_men\";</script>";
	$ret.= "<script>document.getElementById(\"up_tool\").id=\"aktiv_men\";</script>";
}
if ($_GET['m']=='prov'){
	$ret.= "<script>document.getElementById(\"p\").id=\"aktiv_men\";</script>";
	$ret.= "<script>document.getElementById(\"prov\").id=\"aktiv_men\";</script>";
}
if ($_GET['m']=='state'){
	$ret.= "<script>document.getElementById(\"ma\").id=\"aktiv_men\";</script>";
	$ret.= "<script>document.getElementById(\"state\").id=\"aktiv_men\";</script>";
}
if ($_GET['m']=='state_calls'){
	$ret.= "<script>document.getElementById(\"ma\").id=\"aktiv_men\";</script>";
	$ret.= "<script>document.getElementById(\"sc\").id=\"aktiv_men\";</script>";
}
if ($_GET['m']=='state_statistic'){
	$ret.= "<script>document.getElementById(\"ma\").id=\"aktiv_men\";</script>";
	$ret.= "<script>document.getElementById(\"ss\").id=\"aktiv_men\";</script>";
}

if ($_GET['m']=='info'){
	$ret.= "<script>document.getElementById(\"ma\").id=\"aktiv_men\";</script>";
	$ret.= "<script>document.getElementById(\"info\").id=\"aktiv_men\";</script>";
}

if ($_GET['m']=='cdr'){
	$ret.= "<script>document.getElementById(\"ma\").id=\"aktiv_men\";</script>";
	$ret.= "<script>document.getElementById(\"cdr\").id=\"aktiv_men\";</script>";
}

if ($_GET['m']=='berofos'){
	$ret.= "<script>document.getElementById(\"ma\").id=\"aktiv_men\";</script>";
	$ret.= "<script>document.getElementById(\"berofos\").id=\"aktiv_men\";</script>";
}

if (($_GET['m']=='shell') && ($_SESSION['beroari_username']=="beroAdmin")){
	$ret.= "<script>document.getElementById(\"ma\").id=\"aktiv_men\";</script>";
	$ret.= "<script>document.getElementById(\"shell\").id=\"aktiv_men\";</script>";
}

if ($_GET['m']=='remoteM'){
	$ret.= "<script>document.getElementById(\"ma\").id=\"aktiv_men\";</script>";
	$ret.= "<script>document.getElementById(\"remoteM\").id=\"aktiv_men\";</script>";
}

if ($_GET['m']=='ddebug'){
	$ret.= "<script>document.getElementById(\"ma\").id=\"aktiv_men\";</script>";
	$ret.= "<script>document.getElementById(\"ddebug\").id=\"aktiv_men\";</script>";
}
if ($_GET['m']=='ftrace'){
	$ret.= "<script>document.getElementById(\"ma\").id=\"aktiv_men\";</script>";
	$ret.= "<script>document.getElementById(\"ftrace\").id=\"aktiv_men\";</script>";
}
if ($_GET['m']=='uninstall'){
	$ret.= "<script>document.getElementById(\"apps\").id=\"aktiv_men\";</script>";
	$ret.= "<script>document.getElementById(\"uninstall\").id=\"aktiv_men\";</script>";
}
if ($_GET['m']==''){
	$ret.= "<script>document.getElementById(\"state\").id=\"aktiv_men\";</script>";
}
?>
