اعددت بعجالة هذا الكائن ان شاء الله ينفعك
كود PHP:
<?php
/*
*@filename : bw.class.php
*/
class CheckBW{
var $User;
var $Password;
var $SiteUrl;
var $Limit;
var $Diference;
function down(){
echo "You can Download the program";
}
function notdown(){
echo "You can't Download the program";
}
function getinfo($user,$pass,$siteurl,$limit){
$this->User = $user;
$this->Password = $pass;
$this->SiteUrl = $siteurl;
$this->Limit = $limit;
$url = @file_get_contents("http://".$this->User.":".$this->Password."@".$this->SiteUrl.":2082/frontend/x/index.html","r");
$found = preg_match("/(current month).*?<\/tr>/is",$url, $bvar);
if($found) {
$bvar[0] = strip_tags($bvar[0]);
$bvar[0] = str_replace("current month)",'',$bvar[0]);
$bvar[0] = str_replace("Megabytes",'',$bvar[0]);
$diff = $this->Diference;
$this->Diference = $this->Limit-$bvar[0];
if($this->Diference>0){
$this->down();
}
else if($this->Diference<0){
$this->notdown();
}
else{
$this->notdown();
}
}
else {
echo "لا يمكن معرفة الباندويدث";
}
}
}
?>
طريقة الإستعمال ( مثلا اذا اردت تحدد انه لا يمكن التحميل اذا الباندويث عندك اكثر من 8 جيجا )
كود PHP:
<?
include("bw.class.php");
$check = new checkBW;
// 8000 = is 8 Giga byte ( mean : Stop download if my current bandwidth is more then 8 Giga byte )
$show = $check->getinfo("hachem","qs4@sd1>s4//@>33","www.hachem.com","8000");
?>