Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[TUTORIAL] Sphere web status
Author Message
Kanibal
Master
**

Posts: 255
Likes Given: 6
Likes Received: 30 in 28 posts
Joined: Jun 2012
Reputation: 0



Post: #6
RE: [TUTORIAL] Sphere web status
Create somewhere (not in www directory) php script, and launch it every N hours/minutes/seconds from command line
Code:
<?php
$link = mysqli_connect("127.0.0.1", "user", "password", "db_name");

if (!$link) {
    echo "Error: Unable to connect to MySQL." . PHP_EOL;
    echo "Debugging errno: " . mysqli_connect_errno() . PHP_EOL;
    echo "Debugging error: " . mysqli_connect_error() . PHP_EOL;
    exit;
}

$fp = @fsockopen("127.0.0.1", 2593, $errno, $errstr, 10);
if (!$fp) {
  $result = mysqli_query($link, "UPDATE `server_status` SET online='Offline'");
}else{
  $result = mysqli_query($link, "UPDATE `server_status` SET online='Online'");
  fclose($fp);
}
mysqli_close($link);
?>

P.S. You can use crontab (see attachment) or use .bat file
Code:
start "C:\PHP\php.exe" -f C:\scripts\sphere_status_update.php

P.P.S. I cant add attachment something is wrong with forum? Confused

Grandmaster Localhost Admin
(This post was last modified: 12-27-2016 11:57 PM by Kanibal.)
12-27-2016 11:04 PM
Visit this user's website Find all posts by this user Like Post Quote this message in a reply
Post Reply 


Messages In This Thread
[TUTORIAL] Sphere web status - Kanibal - 12-09-2016, 10:09 PM
RE: [TUTORIAL] Sphere web status - Kanibal - 12-27-2016, 09:24 AM
RE: [TUTORIAL] Sphere web status - Kanibal - 12-27-2016 11:04 PM
RE: [TUTORIAL] Sphere web status - anexity - 04-28-2017, 08:00 AM
RE: [TUTORIAL] Sphere web status - Kanibal - 05-11-2017, 07:23 PM
RE: [TUTORIAL] Sphere web status - golfin - 10-06-2018, 10:51 PM
RE: [TUTORIAL] Sphere web status - Kanibal - 10-20-2018, 08:47 AM
RE: [TUTORIAL] Sphere web status - golfin - 10-21-2018, 01:22 PM

Forum Jump:


User(s) browsing this thread: 3 Guest(s)