View difference between Paste ID: LDVPbtwt and asRwNX2H
SHOW: | | - or go back to the newest paste.
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
}