forked from kamba4/sunders
		
	
		
			
				
	
	
		
			30 lines
		
	
	
	
		
			838 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			30 lines
		
	
	
	
		
			838 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
  error_reporting(0);
 | 
						|
  include $pathToWebFolder.'config.php';
 | 
						|
 | 
						|
  try {
 | 
						|
    $mysqli = new mysqli(MYSQL_HOST, MYSQL_USER, MYSQL_PASSWORD, MYSQL_DB);
 | 
						|
    if($mysqli->connect_errno) {
 | 
						|
      throw new Exception("Could not connect to database");
 | 
						|
    }
 | 
						|
 | 
						|
    $syncstate_querry = $mysqli->query("SELECT * FROM sync_state WHERE k = 'sequenceNumber'");
 | 
						|
 | 
						|
    while($row = $syncstate_querry->fetch_assoc()) {
 | 
						|
        $syncstate = array('sequenceNumber' => $row["v"]);
 | 
						|
      }
 | 
						|
 | 
						|
    $result = json_encode($syncstate);
 | 
						|
 | 
						|
    $mysqli->close();
 | 
						|
 | 
						|
    header('Content-type: application/json; Charset : utf-8');
 | 
						|
    echo $result;
 | 
						|
    mysqli_report(MYSQLI_REPORT_OFF);
 | 
						|
  } catch (Exception $e) {
 | 
						|
      http_response_code(503);
 | 
						|
      header('Content-type: application/json');
 | 
						|
      $result = '{"error":"Database unavailable"}';
 | 
						|
      echo $result;
 | 
						|
  }
 | 
						|
?>
 |