AlexWebDevelop

Untitled

Jun 2nd, 2020
469
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.60 KB | None | 0 0
  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. }
Add Comment
Please, Sign In to add comment