<?php
/**
*
* Geschreven door	: David Herregat a.k.a. Darklandz (www.darklandz.be)
*
*/
 
/**
* Veiligheid controle 
*/
 
if (!defined('dArKCMS')) {	die("Hacking Poging!"); }

/**
* Gebruikersinfo van ingelogde gebruiker 
*/
 
function coreGebruikerStats($Taal){
	
	global $vrtl;	
	echo '<div id="gebruikerStats"><span>&nbsp;&nbsp;&nbsp;'.$vrtl['welkom'].'&nbsp;'.$_SESSION['username'].', '.coreDatum($Taal).'</span></div>';
	
}
 
/**
* Laad de modules uit de DB en maakt het tabpaneel
*/
 
function coreModules ($aktieveModule,$taal) {
	
	global $vrtl;
		
	$dbconnect	= mysql_connect (DBhost,DBgebruiker,DBwachtwoord) or die ("Kan niet verbinden: " . mysql_error());
	$dbselect 	= mysql_select_db (DBnaam,$dbconnect);
	
	$sql_result = mysql_query ("SELECT * FROM CoreModules WHERE moduleStatus = 1 ORDER by ModOrder ASC");
	
	echo '<div id="tabsJ"><ul>';
	
	if ($aktieveModule == '0'){
				
		echo '<li id="current"><a href="'.CORE_Path.'index.php?tl='.$taal.'"><span>'.$vrtl['tabAlgemeen'].'</span></a></li>';
	} else {
		echo '<li><a href="'.CORE_Path.'index.php?tl='.$taal.'"><span>'.$vrtl['tabAlgemeen'].'</span></a></li>';
	}
	  					

	while ($row=mysql_fetch_array ($sql_result)) {
		
		if ($row['moduleId']==$aktieveModule){
			$tmpdata = '<li id="current">';
		} else {
			$tmpdata = '<li>';
		}
		echo $tmpdata.'<a href="'.CORE_Path.''.$row['moduleLink'].'index.php?tl='.$taal.'"><span>'.$row['moduleTitel'.$taal].'</span></a></li>';
	}

	
	echo '
					</ul>
				</div>';
	
	mysql_close($dbconnect);
}

/**
* Tabbalk generator
*/

function coreTabbalk($tabs,$tablinks,$aktief){

	global $vrtl;
	
	$tabArray 	= explode('|',$tabs);
	$linkArray 	= explode('|',$tablinks);


	$teller 		= 0;	
	
	echo '<div id="tabsJ"><ul>';

	foreach ($tabArray as $tabNaam){
	
		if ($teller == $aktief){ $tmphtml='<li id="current">'; } else { $tmphtml='<li>'; }
		echo $tmphtml.'<a href="'.$linkArray[$teller].'"><span>'.$tabNaam.'</span></a></li>';
		$teller++;
	} 
	
	echo '</ul></div><div id="wis"></div>';
	
}

/**
 * Taalbalk generator =======================================================================================
 */

function coreTaalbalk($tabs,$tablinks,$aktief){

	$tabArray 	= explode('|',$tabs);
	$linkArray 	= explode('|',$tablinks);


	$teller 		= 0;	
	
	echo '<div id="tabsTaal"><ul>';

	foreach ($tabArray as $tabNaam){
	
		if ($teller == $aktief){ $tmphtml='<li id="current">'; } else { $tmphtml='<li>'; }
		echo $tmphtml.'<a href="'.$linkArray[$teller].'"><span><img src="'.CORE_Path.'images/fl_'.$tabNaam.'.png" border="0" width="16" height="16">
		</span></a></li>';
		$teller++;
	} 
	
	echo '</ul></div><div id="wis"></div>';
	
}

/**
 * detailbalk generator =======================================================================================
 */
function coreDetailbalk($tabs,$tablinks,$aktief){

	$tabArray 	= explode('|',$tabs);
	$linkArray 	= explode('|',$tablinks);


	$teller 		= 0;	
	
	echo '<div id="tabsTaal"><ul>';

	foreach ($tabArray as $tabNaam){
	
		if ($teller == $aktief){ $tmphtml='<li id="current">'; } else { $tmphtml='<li>'; }
		echo $tmphtml.'<a href="'.$linkArray[$teller].'"><span>'.$tabNaam.'</span></a></li>';
		$teller++;
	} 
	
	echo '</ul></div><div id="wis"></div>';
	
}




/**
 *  Datumweergave ===========================================================================================
 */

function coreDatum($taal){

	$dag 				= date('j');
	$maand 			= date('n');
	$jaar 			= date('Y');
	$dagvdweek 	= date('w');

	$dagen_array['NL'] 		= array("zondag", "maandag", "dinsdag", "woensdag", "donderdag", "vrijdag", "zaterdag"); 
	$maanden_array['NL'] 	= array("januari", "februari", "maart", "april","mei", "juni", "juli", "augustus", "september",
																 "oktober", "november", "december"); 
	$dagen_array['FR'] 		= array("dimanche", "lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi"); 
	$maanden_array['FR'] 	= array("janvier", "fevrier", "mars", "avril", "mai", "juin", "julliet", "augustus", "september",
																 "oktober", "november", "december"); 

	$dag_naam 	= $dagen_array[$taal][$dagvdweek]; 
	$maand_naam = $maanden_array[$taal][$maand-1];
	
	if ($taal == 'NL'){
		$tmp ='We zijn '.$dag_naam.' '.$dag.' '.$maand_naam.' '.$jaar.'.';
	}
	if ($taal == 'FR'){
		$tmp ='On est le '.$dag_naam.' '.$dag.' '.$maand_naam.' '.$jaar.'.';
	}
	
	return $tmp;
}

/**
* Algemeen TAB onderdelen
*/

function coreAlgemeen(){
	
	echo '<div id="wis">&nbsp;</div>
				<div id="plaatsHouder">';
	coreSydneyInfo();
	coreServerMonitor();
	coreModuleMonitor();
	echo '</div>';
	
}

/**
*  Server Monitor
*/

function coreServerMonitor(){
	
	global $vrtl;
	?>
			<div id="serverMonitorTitel" onclick="switchMenu('serverMonitorInhoud','testje2');">
				<table width="840" border="0" cellspacing="0" cellpadding="0">
  				<tr>
    				<td width="40" height="38" align="left" valign="top">
							<div class="titelImage"><img src="<? echo CORE_Path; ?>images/serverInfo.png" border="0" width="32" height="32"></div>
						</td>
						<td width="500" height="38" align="left" valign="top">
							<div class="titelTekst" align="left">
								<?php echo $vrtl['serverInformatie'];?></div>
						</td>
    				<td width="300" height="20" align="right" valign="top">
							<div class="sluitTekst" align="right">
							<img id="testje2" src="<? echo CORE_Path; ?>images/expandall.png" border="0" width="13" height="13" onclick="switchMenu('serverMonitorInhoud','testje2');" />
							</div>
						</td>
  				</tr>
				</table>
			
			</div>	
			<div id="serverMonitorInhoud" style="display:none">
				<table cellspacing="3" cellpadding="3">
					
						<tr>
							<td bgcolor="#2E3B56" width="150" align="right" class="celTitel"><?php echo $vrtl['serverNaam'];?> :</td>
							<td bgcolor="#dddddd" width="660" align="left" class="tekst_normaal"><?php echo $_SERVER['SERVER_NAME']; ?></td>
						</tr>
						<tr>
				<td bgcolor="#2E3B56" width="150" align="right" class="celTitel"><?php echo $vrtl['serverSoftware'];?> :</td>
				<td bgcolor="#dddddd" width="650" align="left" class="tekst_normaal"><?php echo $_SERVER['SERVER_SOFTWARE']; ?></td>
			</tr>
			<tr>
				<td bgcolor="#2E3B56" width="140" align="right" class="celTitel"><?php echo $vrtl['serverApath'];?> :</td>
				<td bgcolor="#dddddd" width="650" align="left" class="tekst_normaal"><?php echo $_SERVER['DOCUMENT_ROOT']; ?></td>
			</tr>
			<tr>
				<td bgcolor="#2E3B56" width="150" align="right" class="celTitel"><?php echo $vrtl['serverCgi'];?> :</td>
				<td bgcolor="#dddddd" width="650" align="left" class="tekst_normaal"><?php echo $_SERVER['GATEWAY_INTERFACE']; ?></td>
			</tr>
			
			</table>
<?php			
	
	$test = new status;
	// Enable logging?
	$test->log = FALSE; // Default is false
	$test->AddService('localhost', 21, 'FTP', 'tcp');
	$test->AddService('localhost', 2222, 'SSH', 'tcp');
	$test->AddService('localhost', 23, 'Telnet', 'tcp');
	$test->AddService('localhost', 25, 'SMTP', 'tcp');
	$test->AddService('localhost', 80, 'HTTP', 'tcp');
	$test->AddService('localhost', 110, 'POP3', 'tcp');
	$test->AddService('localhost', 3306, 'MySQL', 'tcp');
	$test->AddService('localhost', 8443, 'CP', 'tcp');
	$test->CheckStatus(1);
	$data = $test->GetStatus();

echo '<table width="100%" border="0" cellspacing="0" cellpadding="0">
				<tr>';

for($i = 0; $i <= count($data) - 1; $i++) {

	if($data[$i]['status']) {
		$img = '<img src="images/online.gif" width=34 height=21>';
	} else {
  	$img = '<img src="images/offline.gif" width=34 height=21>';
	}

	echo '<td align="center"><p class="date">'.$img.'<br>'.$data[$i]['service'].'</p></td>';
}	

echo '	</tr>
			</table>';

$uptime = @exec('uptime'); //Gegevens ophalen
preg_match("/averages?: ([0-9\.]+),[\s]+([0-9\.]+),[\s]+([0-9\.]+)/",$uptime,$gem);
  $uptime = explode(' up ', $uptime); //Uptime eruithalen
  $uptime = explode(',', $uptime[1]);
  $uptime = $uptime[0];
  $start=mktime(0, 0, 0, 1, 1, date("Y"), 0);
$einde=mktime(0, 0, 0, date("m"), date("j"), date("y"), 0);
$verschil=$einde-$start; //Totale uptime berkenen
$dagen=$verschil/86400;
$percent=($uptime/$dagen) * 100;
$load=($gem[1] + $gem[2] +  $gem[3])/3; //Serverload berkenen
$uptime = str_replace("days","dagen",$uptime); //Uptime staat standaard in het Engels, days naar dagen omzetten
echo '<center><p class="date">Server Uptime : '.$uptime.'&nbsp;&nbsp;-&nbsp;&nbsp;Server Load : '.round($load,3).' %</p></center>';

	echo '</div><br>';
	
}

/**
 *  Module Monitor
 */
 
function coreModuleMonitor(){
	
	global $vrtl,$CoreTaal;
	
	$dbconnect			= mysql_connect (DBhost,DBgebruiker,DBwachtwoord) or die ("Kan niet verbinden: " . mysql_error());
	$dbselect 			= mysql_select_db (DBnaam,$dbconnect);
	$sql_result 		= mysql_query ("SELECT * FROM CoreModules");
	$aantalRecords	= mysql_num_rows($sql_result);
	$sql_result 		= mysql_query ("SELECT * FROM CoreModules WHERE moduleStatus='1'");
	$aantalAktieve	= mysql_num_rows($sql_result);
	//mysql_close($dbconnect);	
	$sql_result 		= mysql_query ("SELECT * FROM CoreModules");

	?>
	
	<div id="moduleStatsTitel" onclick="switchMenu('moduleStatsInhoud','modStat');">
		<table width="840" border="0" cellspacing="0" cellpadding="0">
  		<tr>
    				<td width="40" height="38" align="left" valign="top">
							<div class="titelImage"><img src="<? echo CORE_Path; ?>images/moduleInfo.png" border="0" width="32" height="32"></div>
						</td>
						<td width="500" height="38" align="left" valign="top">
							<div class="titelTekst" align="left">
								<?php echo $vrtl['moduleInformatie'];?></div>
						</td>
    				<td width="300" height="20" align="right" valign="top">
							<div class="sluitTekst" align="right">
							<img id="modStat" src="<? echo CORE_Path; ?>images/expandall.png" border="0" width="13" height="13" onclick="switchMenu('moduleStatsInhoud','modStat');" />
							</div>
						</td>
  				</tr>
  	
		</table>
	</div>	
	
	<div id="moduleStatsInhoud" style="display:none">
		<table cellspacing="3" cellpadding="3">
			<tr>
				<td bgcolor="#2E3B56" width="200" align="right" class="celTitel"><?php echo $vrtl['totaalModules'];?> :</td>
				<td bgcolor="#dddddd" width="620" align="left" class="tekst_normaal"><?php echo $aantalRecords; ?></td>
			</tr>
			<tr>
				<td bgcolor="#2E3B56" width="200" align="right" class="celTitel"><?php echo $vrtl['aktieveModules'];?> :</td>
				<td bgcolor="#dddddd" width="620" align="left" class="tekst_normaal"><?php echo $aantalAktieve; ?></td>
			</tr>
			<tr>
				<td colspan="2" align="center"><?php echo $vrtl['overzichtModules'];?></td>
			</tr>
		</table>
		
	<?php
	
	while ($row=mysql_fetch_array ($sql_result)) { 

	?>
		<table cellspacing="0" cellpadding="3" border="0">
			<tr>
				<td bgcolor="#2E3B56" width="100" align="right" class="celTitel"><?php echo $vrtl['moduleNaam'];?> :</td>
				<td bgcolor="#dddddd" width="400" align="left" class="tekst_normaal"><?php echo $row['moduleTitel'.$CoreTaal]; ?></td>
				<td bgcolor="#2E3B56" width="80" align="right" class="celTitel"><?php echo $vrtl['moduleVersie'];?> :</td>
				<td bgcolor="#dddddd" width="50" align="left" class="tekst_normaal"><?php echo $row['moduleVersie']; ?></td>
				<td bgcolor="#2E3B56" width="80" align="right" class="celTitel"><?php echo $vrtl['moduleStatus'];?> :</td>
				<td bgcolor="#dddddd" width="100" align="left" class="tekst_normaal">
					<?php 
					
					if ($row['moduleStatus'] == '1') {
						echo $vrtl['online'];
					} else {
						echo $vrtl['offline'];
					}
					
					?>
				</td>
			</tr>
			
		</table>
		<br>


	<?php		
	}
	
	echo '</div>';
}

/**
* Sydney Informatie 
*/

function coreSydneyInfo(){
	
	global $vrtl;
	?>

			<div id="sydneyInfoTitel" onclick="switchMenu('sydneyInfoInhoud','sydinfo');">
				<table width="840" border="0" cellspacing="0" cellpadding="0">
  				<tr>
    				<td width="40" height="38" align="left" valign="top">
							<div class="titelImage"><img src="<? echo CORE_Path; ?>images/sydneyInfo.png" border="0" width="32" height="32"></div>
						</td>
						<td width="500" height="38" align="left" valign="top">
							<div class="titelTekst" align="left">
								<?php echo $vrtl['sydneyInformatie'];?></div>
						</td>
    				<td width="300" height="20" align="right" valign="top">
							<div class="sluitTekst" align="right">
							<img id="sydinfo" src="<? echo CORE_Path; ?>images/collapseall.png" border="0" width="13" height="13" onclick="switchMenu('sydneyInfoInhoud','sydinfo');" />
							</div>
						</td>
  				</tr>
				</table>
			
			</div>	
			<div id="sydneyInfoInhoud">
				<div class="tekstnormaal">
				<table width="100%" cellpadding="5" cellspacing="5">
					<tr>
						<td>De <strong>Basic licentie</strong> is toegewezen aan <strong>Brasserie Het Kompas</strong>. Geldig vanaf 1 Juni 2008 </td>
					<tr>
						<td>Westdesign biedt het CMS onder licentie aan. Er zijn drie soorten licenties, die weergegeven worden in onderstaande tabel. De licentie voorwaarden vallen onder de <a href="http://westdesign.be/voorwaarden.php" target="_blank">algemene voorwaarden</a> van Westdesign.</td>
					</tr>
				</table>
				<fieldset>
	<legend><strong>CMS Licenties</strong></legend>
	<table width="100%" cellpadding="5" cellspacing="5">
		<tr>
			<td width="25%" bgcolor="#2E3B56" class="celTitel" align="center">CMS-licentie:</td>
			<td width="25%" bgcolor="#2E3B56" class="celTitel" align="center">Basic Licentie</td>
			<td width="25%" bgcolor="#2E3B56" class="celTitel" align="center">Support Licentie</td>
			<td width="25%" bgcolor="#2E3B56" class="celTitel" align="center">Full Licentie</td>
		</tr>
		<tr>
			<td bgcolor="#2E3B56" class="celTitel">Support:</td>
			<td align="center" bgcolor="#dddddd" class="tekst_normaal">Nee&sup1; </td>
			<td align="center" bgcolor="#dddddd" class="tekst_normaal">Ja</td>
			<td align="center" bgcolor="#dddddd" class="tekst_normaal">Ja</td>
		</tr>
		<tr>
			<td bgcolor="#2E3B56" class="celTitel">Updates</td>
			<td align="center" bgcolor="#dddddd" class="tekst_normaal">Nee&sup2; </td>
			<td align="center" bgcolor="#dddddd" class="tekst_normaal">Nee&sup2; </td>
			<td align="center" bgcolor="#dddddd" class="tekst_normaal">Ja</td>
		</tr>
		<tr>
		  <td bgcolor="#2E3B56" class="celTitel">Geldigheid</td>
		  <td align="center" bgcolor="#dddddd" class="tekst_normaal">Onbeperkt</td>
		  <td align="center" bgcolor="#dddddd" class="tekst_normaal">Onbeperkt</td>
		  <td align="center" bgcolor="#dddddd" class="tekst_normaal">1 jaar&sup3;</td>
	  </tr>
		<tr>
		  <td  bgcolor="#2E3B56" class="celTitel">Kosten </td>
		  <td align="center" bgcolor="#dddddd" class="tekst_normaal">Gratis</td>
		  <td align="center" bgcolor="#dddddd" class="tekst_normaal">Eenmalig: &euro; 150,00</td>
		  <td align="center" bgcolor="#dddddd" class="tekst_normaal">Jaarlijks: &euro; 150,00 </td>
	  </tr>
</table>
<table width="100%" cellpadding="5" cellspacing="5">
	<tr>
		<td><p>1) Gewenste support wordt onder deze licentie gefactureerd, op basis van werkuren<br />
	    2) Gewenste updates worden onder deze licentie gefactureerd, op basis van nader te bepalen bedrag.<br />
	  	3) Indien deze licentie verlopen is, krijgt u automatisch de CMS Basic licentie.</td>
	</tr>
</table>
</fieldset>

				</div>
			</div><br>
	
	<?php
	
}

?>