$result = $stmt->execute(); if (!empty($result)) { $result = $result->fetchArray(); $json['phoromatic']['account_id'] = $result['AccountID']; echo json_encode($json); exit; } } } if ($GSID == null && $PTS_MACHINE_SELF_ID == null || $ACCOUNT_ID == null) { $json['phoromatic']['error'] = 'Invalid Credentials'; echo json_encode($json); exit; } // CHECK FOR VALID ACCOUNT if (!phoromatic_server::is_phoromatic_account_path($ACCOUNT_ID)) { $json['phoromatic']['error'] = 'Invalid User'; echo json_encode($json); exit; } define('ACCOUNT_ID', $ACCOUNT_ID); // CHECK IF SYSTEM IS ALREADY CONNECTED TO THE ACCOUNT if ($PTS_MACHINE_SELF_ID != null) { $stmt = phoromatic_server::$db->prepare('SELECT Title, SystemID, Groups, State, MaintenanceMode, LastCommunication FROM phoromatic_systems WHERE AccountID = :account_id AND MachineSelfID = :machine_self_id'); $stmt->bindValue(':account_id', ACCOUNT_ID); $stmt->bindValue(':machine_self_id', $PTS_MACHINE_SELF_ID); $result = $stmt->execute(); $result = $result->fetchArray(); } if (!isset($result) || empty($result)) { // If system was reloaded and MachineSelfID no longer matches but there is existing IP or MAC address claim against it