Lid |
|
Ik ben het niet zéker, heb effe gegoogeld:
<?PHP
function serverload() {
// Use:x
// INCLUDE the file in your script (or cut and paste in)
// assign to a variable $serverload = serverload();
// This will ONLY track page counts from pages that call the
// serverload() function. If you want a page counted, but do
// not need the results, simply call the function without
// assigning a variable.
//
// Requirements:
// MySQL database set up with a table (user selectable) in a
// database (user selectable). Table has one field, time, which
// is defined as INT(14) type.
// Define variables
$database = "_nuke"; // Name of MySQL database
$hostname = "localhost"; // Name of database server
$username = "Paul Laudanski"; // MySQL user
$password = "Chris Mospaw"; // Password for user
$tablename = "nuke_serverload"; // Table in database above that
information is stored in
$duration = "300"; // How many seconds load will represent.
// Open MySQL connection and database
mysql_connect($hostname,$username,$password) or
die ( "Could not connet to MySQL" );
mysql_select_db($database) or
die ( "Could not connect to database" );
// Delete old page counts
$sql = "DELETE FROM $tablename WHERE time < " . (time()-$duration);
$result = mysql_query($sql) or
die ("Error:" . mysql_error() );
// Insert the current page count
$sql = "INSERT INTO $tablename (time) VALUES (" . time() . ") ";
$result = mysql_query($sql) or
die ("Error:" . mysql_error() );
// Get page count (number of rows in the table)
$sql = "SELECT time FROM $tablename";
$result = mysql_query($sql) or
die ("Error:" . mysql_error() );
return mysql_num_rows ($result);
} // END FUNCTION serverload
?>
<?PHP function serverload() { // Use:x // INCLUDE the file in your script (or cut and paste in) // assign to a variable $serverload = serverload(); // This will ONLY track page counts from pages that call the // serverload() function. If you want a page counted, but do // not need the results, simply call the function without // assigning a variable. // // Requirements: // MySQL database set up with a table (user selectable) in a // database (user selectable). Table has one field, time, which // is defined as INT(14) type. // Define variables $database = "_nuke"; // Name of MySQL database $hostname = "localhost"; // Name of database server $username = "Paul Laudanski"; // MySQL user $password = "Chris Mospaw"; // Password for user $tablename = "nuke_serverload"; // Table in database above that information is stored in $duration = "300"; // How many seconds load will represent. // Open MySQL connection and database die ( "Could not connet to MySQL" ); die ( "Could not connect to database" ); // Delete old page counts $sql = "DELETE FROM $tablename WHERE time < " . (time()-$duration); // Insert the current page count $sql = "INSERT INTO $tablename (time) VALUES (" . time() . ") "; // Get page count (number of rows in the table) $sql = "SELECT time FROM $tablename"; } // END FUNCTION serverload ?>
|