sobbayi

PHP Daemon control

Apr 12th, 2021
574
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. $daemonName = 'my daemon';
  4. $sleep = 600;
  5. $exit = FALSE;
  6.  
  7. while (!$exit)
  8. {
  9.   sleep($sleep);
  10.  
  11.   $mysqli = mysqli_connect('localhost', 'db_user', 'db_passwd', 'schema');
  12.  
  13.   $query = "SELECT * FROM daemons WHERE name = '" . $mysqli->real_escape_string($daemonName) . "'";
  14.   $result = $mysqli->query($query);
  15.   $row = mysqli_fetch_assoc($result);
  16.  
  17.   $command = $row['command'];
  18.   $run = TRUE;
  19.  
  20.   if ($command == 'exit')
  21.   {
  22.     $exit = TRUE;
  23.     $run = FALSE;
  24.   }
  25.   else if ($command == 'pause')
  26.   {
  27.     $run = FALSE;
  28.   }
  29.  
  30.   if ($run)
  31.   {
  32.      /* Daemon operations... */
  33.   }
  34. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×