Current File : //var/wcp4/wongwais/public_html/scripts/scripts/scripts/scripts/bandwidthmeter/install.php
<?php
/* $Id: install.php,v 1.2 2003/02/23 22:42:03 gambitdis Exp $ */
ini_set('include_path','/var/backend/wcp/scripts/bandwidthmeter/');
$home="/var/backend/wcp/scripts/bandwidthmeter/";
include("config.inc.php");

?>

<html>
<head>
	<title>Bandwidthmeter - Installation Database Check</title>
	<link rel="stylesheet" href="style.css">
</head>

<body>

<h1>Bandwidthmeter</h1>
<h2>Installation Database Check</h2>


<?php

$errored = 0;

function print_message($message, $bad) {
	global $errored;
	
	if ($bad==1) {
		$errored = 1;
		echo "<font color=red><p><b>$message</b></font>";
	} else {
		echo "<font color=green><p><b>$message</b></font>";
	}
}


$data_file = $home . "payload.bin";
if ( $fd = fopen ($data_file, "rb") ) {
	print_message("Payload file successfully found and opened.", 0);
} else {
	print_message("Could not access payload file.", 1);
}

	

if ($mysql == True) {

	if ($link = @mysql_connect($database["host"], $database["login"],
		$database["password"])) {
		print_message("Successfully connected to database.", 0);
	} else {
		print_message("Could not connect to the database.  Make sure that you have
			added the proper user and password.  Also, make sure that the user
			has permission to connect to the host.  You may need to explicitly
			add the host (in some cases localhost) that the user can connect 
			from.", 1);
	}

		if (mysql_select_db($database["database"])) {
			print_message("Successfully selected the database.", 0);

		$query = "INSERT INTO readings (speed, ip, name) VALUES ('12345',
			'10.10.10.10', '123.yourdomain.com')";
		if ($result = mysql_query($query)) {
			print_message("Successfully inserted test record.", 0);
			$query = "DELETE FROM readings WHERE name='123.yourdomain.com'";
			if ($result = mysql_query($query)) {
				print_message("Successfully deleted test record.", 0);
			} else {
  	 		print_message("Unable to delete test record from database.  The user
					may not have been granted the DELETE privilege.", 1);
			}
		} else {
  	 		print_message("Unable to insert test record into database.  The user
					may have not been granted the INSERT privilege.", 1);
		}

	} else {
   	print_message("Could not select database.  The user may not have
			permission to connect to the database or the database may have not
			been created.", 1);
	}


	if ($errored==0) {
		$meter_location = "http://$HTTP_HOST";
		if ($use_initialmeter == True) {
			$meter_location .= ereg_replace("install.php", "initialmeter.php",
				$_SERVER['PHP_SELF']);
		} else {
			$meter_location .= ereg_replace("install.php", "meter.php",
				$_SERVER['PHP_SELF']);
		}
		print_message("SUCCESSFULLY PASSED TESTS.<br>You may now test your
			download speed at <a href=\"$meter_location\">$meter_location</a>", 0);
	}

} else {
	echo "MySQL database support not turned on.  Bandwidthmeter will work
		without a database, but will not log results.  You may turn on MySQL
		support in the config.inc.php file.  Please make sure to configure
		the database properly (directions are in ./docs/INSTALL).  Then reload
		this page to test whether Bandwidthmeter can connect to the database.";
}
	
	
?>
</body>
</html>