<?

require('./conf/config.php');
require('./ctrl.php');
require('./libDisplay.php');



if ( !empty($_GET['section']) ) {
	if ( $_GET['section'] == "checkAuth" )
	{
		
		
		
		$result = auth ($_POST['textIdLogin'], $_POST['textPasswd']) ;
		if ( $result == 1 )  {
			
			$buffer = "<TABLE>";
			$_SESSION['login']=$_POST['textIdLogin'];
			$_SESSION['passwd']=$_POST['textPasswd'];
			
			$buffer .= "<TR><TD>" . contentdefault() . "</TD></TR>"  ;
			//header('Refresh: 2; url=./index.php');
			$buffer .= "</TABLE>" ;
		}else{
			$buffer = "<h1>Authentification</h1>";
			$buffer .= "<TABLE>";
			$buffer .= "<TR><TD>$result</TD></TR>" ;
			$buffer .= "</TABLE>" ;
		}
		
		echo $buffer ;
	}else{
	   if ( empty($_SESSION['login'])) {
			echo "ACCESS DENIED";
			return;
	   }   
	   if ( $_GET['section'] =="addUser") {
			echo displayAddUser();
	   }else{
		   if (    $_GET['section'] =="addService" ) {
			   echo displayAddService();
			}else{
				if ( $_GET['section'] =="addSwitch" ) {
					echo displayAddSwitch();
				}else{
					if ( $_GET['section'] =="addPower" ) {
						echo displayAddPower();
					}else{
						if ( $_GET['section'] =="addPowerUser" ) {
							echo displayAddUserPower();
						}else{
							if ( $_GET['section'] =="addUserService" ) {
								echo displayAddUserService();
							}else{
								if ( $_GET['section'] =="addSwitchService" ) {
								echo displayAddSwitchService();
								}else{
									if ( $_GET['section'] =="addPowerService" ) {
										echo displayAddPowerService();
									}else{
										
										if ( $_GET['section'] =="allService" ) {
											echo displayAllService();
										}else{
											if ( $_GET['section'] =="allSwitch" ) {
												echo displayAllSwitch();
											}else{
												if ( $_GET['section'] =="powerUser" ) {
													echo displayPowerUser("","");
												}else{
													if ( $_GET['section'] =="powerService" ) {
														echo displayPowerService("","");
													}else{
														 if ( $_GET['section'] =="delUser") {
															echo displayDelUser();
														}else{
															if ( $_GET['section'] =="delPower" ) {
																echo displayDelPower();
															}else{
																if ( $_GET['section'] =="delService" ) {
																	echo displayDelService();
																}else{
																	if ( $_GET['section'] =="delSwitch" ) {
																		echo displayDelSwitch();
																	}else{
																		if ( $_GET['section'] =="addNetwork" ) {
																			echo displayAddNetwork();
																		}else{
																			
																			if ( $_GET['section'] =="addDevice" ) {
																				echo displayAddDevice();
																			}else{
																				if ( $_GET['section'] =="allDevice" ) {
																					echo displayAllDevice();
																				}else{
																					if ( $_GET['section'] =="allNetwork" ) {
																						echo displayAllNetwork();
																					}else{
																						if ( $_GET['section'] =="delDevice" ) {
																							echo displayDelDevice();
																						}else{
																							if ( $_GET['section'] =="delNetwork" ) {
																								echo displayDelNetwork();
																							}else{
																								
																								if ( $_GET['section'] =="genKlaskConf" ) {
																									echo displayGenKlaskConf();
																								}else{
																									
																									if ( $_GET['section'] =="klaskExportdb" ) {
																										echo displayKlaskExportdb();
																									}else{
																										if ( $_GET['section'] =="klaskUpdatesw" ) {
																											echo displayKlaskUpdateSw() ;
																										}else{
																											if ( $_GET['section'] =="klaskUpdatedb" ) {
																												echo displayKlaskUpdateDb() ;
																											}else{
																												
																												if ( $_GET['section'] =="klaskExportsw" ) {
																													echo displayKlaskExportSw() ;
																												}else{
																													if ( $_GET['section'] =="klaskGenmap" ) {
																														echo displayKlaskGenMap() ;
																													}else{
																														if ( $_GET['section'] =="updateSwitch" ) {
																															echo displayUpdateSwitch($_GET['switch']); 
																														}else{
																															if ( $_GET['section'] =="klaskSearch" ) {
																																echo displaySearch(); 
																															}else{
																																if ( ctrlAuth() == 0 ) {
																																	echo displayAuthUser();
																																}
																															}
																														}
																													}
																												}
																											}
																										}
																									}
																								}
																							}
																						}
																					}
																				}
																			}
																		}
																	}
																}
															}
														}
													}
												}
											}
										}
									}
								}
							}
						}
					}
				}
		   }   
	    }
	   
	}

}else{
	echo contentdefault();
}






?>
