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EwKTAA8y3DQ0KaAAIMAMT7yQX8mAkuAAAAAElFTkSuQmCC');
header('Content-type: image/png'); }
// If your file is called 'index.php', you can leave this blank too
$filename = 'index.php';
// Do not touch these constants!
// Users
'gebruikersnaam' => array('md5 hash', SHOW_PASSWORDS
), );
// Adsl accounts
'login1' => 'pass1',
'login2' => 'pass2'
);
// This part is the preloader
if(!isset($_GET['load'])) { ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-Type" content="text/html; charset=iso-8859-1" />
<title>Murfy's ADSL Monitor</title>
<link rel="stylesheet" href="/css/default/global.css" type="text/css" />
<style type="text/css">
body {
background-color: #000000;
color: #FFFFFF;
font-family: Verdana;
font-size: 10pt;
}
h1 {
margin-left: auto;
margin-right: auto;
padding: 5px;
border: 1px solid #CCCCCC;
background-color: #333333;
}
h2 {
margin: 0;
}
.account {
float: left;
width: 460px;
padding: 5px;
margin: 10px;
border: 1px solid #777777;
background-color: #222222;
}
.account table {
width: 440px;
}
.free {
border: 1px solid #CCCCCC;
border-left: none;
float: right;
}
.used {
border: 1px solid #CCCCCC;
background-color: #eeca4d;
float: right;
}
</style>
<script type="text/javascript">
function loadMeter() {
var req;
if(window.XMLHttpRequest){
req = new XMLHttpRequest();
} else if(window.ActiveXObject) {
req = new ActiveXObject("Microsoft.XMLHTTP");
} else {
alert('Problem creating the XMLHttpRequest object');
}
req.open('get', '<?=$filename?>?load');
req.onreadystatechange = function() {
if(req.readyState == 4 && req.status == 200){
if(req.responseText) {
document.getElementById('container').innerHTML = req.responseText;
}
}
}
req.send(null);
}
</script>
</head>
<body>
<h1><img src="<?=$filename?>?img=logo" alt="" /> ADSL Monitor</h1>
<div id="container">
The ADSL monitor is loading. This may take some time, please wait while the statistics are being gathered from the server.
</div>
<script type="text/javascript">
loadMeter();
</script>
</body>
</html>
<?php
}
if(!isset($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW'])) { // Niet ingelogged, homo's
header('WWW-Authenticate: Basic realm="Murfy\'s ADSL monitor
"'); header('HTTP/1.0 401 Unauthorized');
echo 'Access denied for '.$_SERVER['PHP_AUTH_USER'].':'.$_SERVER['PHP_AUTH_PW'];
exit();
} else {
// Wel dus
if(!array_key_exists($_SERVER['PHP_AUTH_USER'], $users) || $users[$_SERVER['PHP_AUTH_USER']][0] != md5($_SERVER['PHP_AUTH_PW'])) {
echo 'Access denied for '.$_SERVER['PHP_AUTH_USER'].':'.$_SERVER['PHP_AUTH_PW'];
exit();
} else {
$user = $_SERVER['PHP_AUTH_USER'];
}
}
function strtokb($string) {
/* Mogelijke input:
30 GB
23 GB 830 MB
31 MB
65 MB 297 KB
*/
$num = '([0-9]{1,3})';
$match = array();
if(preg_match('#'.$num.' GB '.$num.' MB#', $string, $match)) {
// 23 GB 830 MB
$ret = $match[1]*1024*1024 + $match[2]*1024;
} elseif(preg_match('#'.$num.' GB#', $string, $match)) {
// 30 GB
$ret = $match[1]*1024*1024;
} elseif(preg_match('#'.$num.' MB '.$num.' KB#', $string, $match)) {
// 65 MB 297 KB
$ret = $match[1]*1024 + $match[2];
} elseif(preg_match('#'.$num.' MB#', $string, $match)) {
// 31 M
$ret = $match[1]*1024;
} else {
$ret = false;
}
return $ret;
}
function getVolume($user, $pass) {
// First logout, just to be sure
file_get_contents('https://e-care.skynet.be/index.cfm?function=login.logoff');
$curl = curl_init('https://e-care.skynet.be/index.cfm?function=connection.getVolume');
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, 'form_login='.$user.'&form_password='.$pass.'&Submit=Inloggen');
$ret = curl_exec($curl);
curl_close($curl);
$ret = str_replace(array("\n", "\r", "\t"), '', $ret);
// Match against:
// Monthly volume used 23 GB 830 MB out of 30 GB
$pattern = '#Monthly volume used <strong>([A-Z0-9 ]+)<\/strong> out of <strong>([A-Z0-9 ]+)<\/strong>#si';
$match = array();
preg_match($pattern, $ret, $match);
$basic_used = strtokb($match[1]);
$basic_total = strtokb($match[2]);
// Match against:
// You used 973 MB out of 5 GB available in the current Volume Pack
$extra = false;
$pattern = '#You used <strong>([A-Z0-9 ]+)<\/strong> out of<strong>([A-Z0-9 ]+)<\/strong>#si';
preg_match($pattern, $ret, $match);
if(count($match) > 0) {
$extra = array('used' => strtokb($match[1]), 'total' => strtokb($match[2]));
}
return array(
'basic' => array('used' => $basic_used, 'total' => $basic_total),
'extra' => $extra
);
}
$total_total = 0;
$total_used = 0;
$max = 170; // Meter
foreach($adsl_accounts as $adsl_user => $adsl_pass) {
$volume = getVolume($adsl_user, $adsl_pass);
$total_total += $volume['basic']['total'];
$total_used += $volume['basic']['used'];
// Meter
$used = $max/$volume['basic']['total']*$volume['basic']['used'];
$free = $max-$used;
?>
<div class="account">
<h2><img src="<?=$filename?>?img=account" alt="" /> <?=$adsl_user?>@SKYNET</h2>
<?php if($users[$user][1] == 1) { echo '<em><small>'.$adsl_pass.'</small></em><br />'; } ?>
<br />
<table>
<tr>
<td>Monthly volume:</td>
<td><?=round($volume['basic']['used']/1024)?> / <?=round($volume['basic']['total']/1024)?> MB</td>
<td>
<div class="free" style="width: <?=$free?>px; "> </div>
<div class="used" style="width: <?=$used?>px; "> </div>
</td>
</tr>
<?php
if($volume['extra'] != false) {
$total_total += $volume['extra']['total'];
$total_used += $volume['extra']['used'];
// Meter
$used = $max/$volume['extra']['total']*$volume['extra']['used'];
$free = $max-$used;
?>
<tr>
<td>Extra volume:</td>
<td><?=round($volume['extra']['used']/1024)?> / <?=round($volume['extra']['total']/1024)?> MB</td>
<td>
<div class="free" style="width: <?=$free?>px; "> </div>
<div class="used" style="width: <?=$used?>px; background-color: #4D7AEE; "> </div>
</td>
</tr>
<?php
} else {
?>
<tr><td colspan="3"><div style="border: 1px solid #222222; "> </div></td></tr>
<?php
}
?>
</table>
</div>
<?php
}
$used = $max/$total_total*$total_used;
$free = $max-$used;
?>
<div class="account">
<h2><img src="<?=$filename?>img=account" alt="" /> Total</h2>
<br />
<table>
<tr>
<td>Overall volume:</td>
<td>
<?=round($total_used/1024/1024,1)?> /
<?=round($total_total/1024/1024,1)?> GB</td>
<td>
<div class="free" style="width: <?=$free?>px; "> </div>
<div class="used" style="width: <?=$used?>px; background-color: #EE4D4D; "> </div>
</td>
</tr>
</table>
</div>
</body>
</html>