Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> PHP
Author Message
hitwalker
Sells PC To Pay For Divorce



Joined:
Posts: 5661

PostPosted: Sat Jan 01, 2005 12:33 pm Reply with quote

Ok here a nice chalenge to any phpfreak....

I was using a bandwidth speedtest on my site for some time untill a member maild and said its not working.
So suprised as i was he was right... Sad

Yep maild the author,but no respons...
Then i searched for other sites who are using the script and i did found a few.
Strange to see that their versions were also dead.
Then i realised it had to do with the new php version.
So for some reason there was a change and now its dead.

So i was hoping if someone can see why its not working anymore....

THIS IS THE FILE THAT DOES THE WORK

Code:


<?php include_once("config.inc.php"); ?>
<html>
<head>
<title><?php echo $isp_name; ?> - Bandwidth Meter</title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<META HTTP-EQUIV="Expires" CONTENT="Fri, Jun 12 1981 08:20:00 GMT">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
<link rel="stylesheet" href="style.css">
</head>
<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<center>
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td><?php echo $header; ?></td>
 </tr>
</table>
<table border=0 cellpadding=0 cellspacing=0>
<tr>
<td><br><br><br><br><br><br><font size=+1>
Conducting bandwidth tests...</font></td>
</tr>
</table>
<script>
<!--
time      = new Date();
starttime = time.getTime();
// -->
</scr   ipt>
<?php
$data_file = "payload.bin";
$fd = fopen ($data_file, "rb");
if (isset($_GET['kbps'])) {
$test_kbytes = ($_GET['kbps'] / 8) * 10;  //set the download to take 10 seconds
if ($test_kbytes > 3000) {
$test_kbytes = 3000;
}
} else {
$test_kbytes = $default_kbyte_test_size;
}
$contents = fread ($fd, $test_kbytes * 1024);
echo "<!-- $contents -->";
fclose ($fd);
?>
<sc     ript>
<!--
time          = new Date();
endtime       = time.getTime();
if (endtime == starttime)
{downloadtime = 0
}
else
{downloadtime = (endtime - starttime)/1000;
}
kbytes_of_data = <?php echo $test_kbytes; ?>;
linespeed     = kbytes_of_data/downloadtime;
kbps          = (Math.round((linespeed*8)*10*1.024))/10;
<?php
$nexturl = "results.php?kbps=' + kbps + '&downloadtime=' + downloadtime + '&KB=' + kbytes_of_data + '&recorded=1";
?>
nextpage='<?php echo $nexturl; ?>';
document.location.href=nextpage
// -->
</sc      ript>
<center>
</body>
</html>


So whatever the change was in the new php ,the above doesnt work anymore...

Anybody ?
 
View user's profile Send private message
Raven
Site Admin/Owner



Joined: Aug 27, 2002
Posts: 17088

PostPosted: Sat Jan 01, 2005 1:44 pm Reply with quote

If you mean 4.3.10 most problems are in the fact that the Zend Engine has changed a bit and requires that you be using the latest release of the Zend Optimizer.
 
View user's profile Send private message
hitwalker







PostPosted: Sat Jan 01, 2005 2:03 pm Reply with quote

oh ok,but at what point in the script do you see or have an idea where it goes wrong ?
 
Raven







PostPosted: Sat Jan 01, 2005 2:20 pm Reply with quote

Please post the config.inc.php code.
 
hitwalker







PostPosted: Sat Jan 01, 2005 2:23 pm Reply with quote

Thats this...

Code:


<?php
$mysql = True;
$database = array ( "host" => "localhost", "login" => "username", "password" => "userpassword", "database" => "dbname" );
/*******************************************************************************
 * The following options allow simple customization.  $isp_name shows up in the
 * title bar.
 ******************************************************************************/
$isp_name = getenv(SERVER_NAME);
$header = ""; //"Here is an optional header";
$footer = ""; //"Here is an optional footer";
/*******************************************************************************
 * Modify the following settings if you would like to change the name/speed of
 * services the meter compares the current connection to.
 ******************************************************************************/
 $services = array( "28.8" =>  array ( "name" => "modem", "image" => "1.gif")
                 , "33.6" =>  array ( "name" => "modem", "image" => "1.gif")
                 , "53.3" =>  array ( "name" => "modem", "image" => "1.gif")
                 , "56" =>    array ( "name" => "RNIS", "image" => "2.gif")
                 , "128"  =>  array ( "name" => "RNIS", "image" => "2.gif")
                 , "384"  =>  array ( "name" => "DSL", "image" => "3.gif")
                 , "768"  =>  array ( "name" => "DSL", "image" => "3.gif")
                 , "1000"  => array ( "name" => "DSL", "image" => "4.gif")
                 , "1500"  => array ( "name" => "DSL/T1/Modem Cable", "image" => "5.gif")
);
/*******************************************************************************
 * Determines the bar image that is shown for the current test.
 ******************************************************************************/
$user_graph_image = "you.gif";
/*******************************************************************************
 * Determines the heights of the bars (in pixels) in the graph display.
 ******************************************************************************/
$bar_height = 10;
/*******************************************************************************
 * When set to true, the bandwidthmeter performs a quick check then sends a
 * payload based on the estimated pipe size.
 ******************************************************************************/
$use_initialmeter = True;
/*******************************************************************************
 * When not using the initialmeter.php to calculate the payload size,
 * $default_kbyte_test_size will be used.  When linking to meter.php directly,
 * this file size is used.  When linking to initialmeter.php, initialmeter
 * decides the file size to send based on its estimate of the pipe size.
 ******************************************************************************/
$default_kbyte_test_size = 512;
?>
 
Raven







PostPosted: Sat Jan 01, 2005 2:26 pm Reply with quote

It's very hard to test when you don't include the entire script. It also requires these files:

payload.bin
results.php
 
Raven







PostPosted: Sat Jan 01, 2005 2:27 pm Reply with quote

Why don't you package the application, zip it, and provide a link?
 
hitwalker







PostPosted: Sat Jan 01, 2005 2:28 pm Reply with quote

yeah your right,

this is the file ,direct download link..
http://gambitdesign.com/bandwidthmeter/bandwidthmeter-0.72.zip
 
Raven







PostPosted: Sat Jan 01, 2005 2:39 pm Reply with quote

It runs perfectly on my servers (php v4.3.10)
 
hitwalker







PostPosted: Sat Jan 01, 2005 2:45 pm Reply with quote

well thats weird,but i also have 4.3.10.
does it have anything to do with the few functions that are disabled on the server....(on other topic)
 
hitwalker







PostPosted: Sat Jan 01, 2005 3:44 pm Reply with quote

gone again ?
 
hitwalker







PostPosted: Sat Jan 01, 2005 4:18 pm Reply with quote

and what is weird is that if i run the initialmeter.php instead of the meter.php it shows..

bandwidthmeter/meter.php?kbps=3530.6 in the address bar.
But no images...
Any clue?
 
Raven







PostPosted: Sat Jan 01, 2005 4:19 pm Reply with quote

None at all since it works here.
 
hitwalker







PostPosted: Sat Jan 01, 2005 4:22 pm Reply with quote

well how come suddenly the whole image part doesnt work anymore ?
thats why i asked if it has anything to do with the 4 php functions that are disabled on the server...?

These..

system
exec
shell_exec
passthru
chown
 
Raven







PostPosted: Sat Jan 01, 2005 4:28 pm Reply with quote

None of those are used afaik. I can't answer your question since I can't reproduce it.
 
hitwalker







PostPosted: Sat Jan 01, 2005 4:39 pm Reply with quote

ok thanks,then il wait if that gambit idiot responds.
 
VinDSL
Life Cycles Becoming CPU Cycles



Joined: Jul 11, 2004
Posts: 614
Location: Arizona (USA) Admin: NukeCops.com Admin: Disipal Designs Admin: Lenon.com

PostPosted: Sun Jan 02, 2005 6:22 am Reply with quote

Hrm... Interesting script!

I got it working on my site, without much difficulty. The only thing I had to change was the path to the graphics.

Code:


<snip>

/*******************************************************************************
 * Modify the following settings if you would like to change the name/speed of
 * services the meter compares the current connection to.
 ******************************************************************************/
$services = array( "28.8" =>  array ( "name" => "dial-up"
                                   , "image" => "images/1.gif"
                                   )
                 , "33.6" =>  array ( "name" => "dial-up"
                                    , "image" => "images/1.gif"
                                   )
                 , "53.3" =>  array ( "name" => "dial-up"
                                    , "image" => "images/1.gif"
                                   )
                 , "56" =>    array ( "name" => "ISDN"
                                    , "image" => "images/2.gif"
                                   )
                 , "128"  =>  array ( "name" => "ISDN"
                                    , "image" => "images/2.gif"
                                   )
                 , "384"  =>  array ( "name" => "DSL"
                                    , "image" => "images/3.gif"
                                   )
                 , "768"  =>  array ( "name" => "DSL"
                                    , "image" => "images/3.gif"
                                   )
                 , "1000"  => array ( "name" => "DSL"
                                    , "image" => "images/4.gif"
                                   )
                 , "1500"  => array ( "name" => "DSL/T1/Cable"
                                    , "image" => "images/5.gif"
                                   )
          );

/*******************************************************************************
 * Determines the bar image that is shown for the current test.
 ******************************************************************************/
$user_graph_image = "images/you.gif";

<snip>



Here's a link, if you wanna check it out: http://www.lenon.com/modules.php?name=Bandwidth_Meter_DSL

I'm running PHP: 4.3.10 ...

_________________
.:: "The further in you go, the bigger it gets!" ::.
.:: Only registered users can see links on this board! Get registered or login! | Only registered users can see links on this board! Get registered or login! ::.

Last edited by VinDSL on Sun Jan 16, 2005 7:14 am; edited 1 time in total 
View user's profile Send private message Visit poster's website ICQ Number
VinDSL







PostPosted: Sun Jan 02, 2005 10:16 pm Reply with quote

Found another bug...

At the bottom of 'results.php':

Change:
Code:


<?php

if ($mysql == True) {
    $link = mysql_connect($database["host"], $database["login"],
        $database["password"])
        or die("Could not connect");
    mysql_select_db($database["database"])
        or die("Could not select database");

    $ip = $_SERVER['REMOTE_ADDR'];
    $name = gethostbyaddr($ip);
    $query = "INSERT INTO readings (speed, ip, name) VALUES ($kbps, '$REMOTE_ADDR', '$name')";
    $result = mysql_query($query)
        or die("Query failed");
}

?>



To:


Quote:

<?php

if ($mysql == True) {
$link = mysql_connect($database["host"], $database["login"],
$database["password"])
or die("Could not connect");
mysql_select_db($database["database"])
or die("Could not select database");

$ip = $_SERVER['REMOTE_ADDR'];
$name = gethostbyaddr($ip);
$query = "INSERT INTO readings (speed, ip, name) VALUES ($kbps, '$ip', '$name')";
$result = mysql_query($query)
or die("Query failed");
}

?>

 
hitwalker







PostPosted: Mon Jan 03, 2005 7:06 am Reply with quote

thanks...
look into it...
 
VinDSL







PostPosted: Mon Jan 03, 2005 5:57 pm Reply with quote

hitwalker wrote:
thanks...

Thank YOU! I'm having a lot of fun with this script!

I've been playing around with it, for the last couple of days, porting it over to Nuke. At first, I debugged the code, then I made a module out of it using @&$^%! iframe. It looked nice, but once I got it up 'n' running, and a few ppl beta tested it, I looked through the results in the sql db and I found out it was wildly inaccurate (at times), especially after doing a 'retest'. Then, it clicked...

I'm running a highly mod'ed version of PHP-Nuke 6.5 Final, using GZIP compression, caching, et cetera. Looking at the source code that the Bandwidthmeter module was generating in Nuke, I started wondering, "How the hell is this thing supposed to work in a compressed and cached environment?"

So, I tried running it in a stand-alone JavaScript popup window, and bada bing, bada boom, it started turning out consistent and highly accurate results.

I don't know if you're running this as a block, module, or popup, but the popup window is the only way to go, IMHO.

Here's the lastest version:

http://www.lenon.com/modules.php?name=Bandwidth_Meter_DSL

See if it works for you... Wink


Last edited by VinDSL on Sun Jan 16, 2005 7:13 am; edited 1 time in total 
hitwalker







PostPosted: Mon Jan 03, 2005 6:13 pm Reply with quote

hi ,

well it was running on my site...
btw i send you a private message today ?

Anyway....it just stopped working for some weird reason...
in my address bar i se the speed but images simply dont show...

as i wrote ...im beginning to believe this all somehow has to do something with my computer....im not sure...

i have the xp windows firewall off.
all normal configurations in norton 2005 ,never touched anything....

but also weird is that almost at same time i discovered that the database backup function doesnt work for me.

i download a file of 0.0 kb

so im wondering if this is all related...

(and i just tried yours again AND its NOT working...)
 
sixonetonoffun
Spouse Contemplates Divorce



Joined: Jan 02, 2003
Posts: 2496

PostPosted: Mon Jan 03, 2005 6:58 pm Reply with quote

I just used the one at VinDSL got a whopping 45.70kbps which is fairly accurate unfortunetly.

_________________
[b][size=5]openSUSE 11.4-x86 | Linux 2.6.37.1-1.2desktop i686 | KDE: 4.6.41>=4.7 | XFCE 4.8 | AMD Athlon(tm) XP 3000+ | MSI K7N2 Delta-L | 3GB Black Diamond DDR
| GeForce 6200@433Mhz 512MB | Xorg 1.9.3 | NVIDIA 270.30[/size:2b8 
View user's profile Send private message
xfsunolesphp
Regular
Regular



Joined: Aug 23, 2003
Posts: 77

PostPosted: Mon Jan 03, 2005 7:00 pm Reply with quote

look my results is 1295.6 kbps
 
View user's profile Send private message
hitwalker







PostPosted: Mon Jan 03, 2005 7:04 pm Reply with quote

well thats great but it doesnt give any answers to why i doesnt work for me.
i just tried his popup....
the images DONT show but i see at the statusbar that im downloading the file.
and when its done it stays black,and when i right click i get.....

kbps=1048.6

but no images.....
 
xfsunolesphp







PostPosted: Mon Jan 03, 2005 7:09 pm Reply with quote

hitwalker wrote:
well thats great but it doesnt give any answers to why i doesnt work for me.
i just tried his popup....
the images DONT show but i see at the statusbar that im downloading the file.
and when its done it stays black,and when i right click i get.....

kbps=1048.6

but no images.....


have you check path of those image?
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> PHP

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©