NOW() LIMIT 1"); // Failed if (mysqli_num_rows($sql) !== 1) { // Invalid Key header(WORDING_UNAUTHORIZED); mysqli_query($mysqli, "INSERT INTO logs SET log_type = 'API', log_action = 'Failed', log_description = 'Incorrect or expired Key', log_ip = '$ip', log_user_agent = '$user_agent', log_created_at = NOW()"); $return_arr['success'] = "False"; $return_arr['message'] = "API Key authentication failure or expired."; header(WORDING_UNAUTHORIZED); echo json_encode($return_arr); exit(); } // Success else { // Set client ID, company ID & key name $row = mysqli_fetch_array($sql); $api_key_name = $row['api_key_name']; $client_id = $row['api_key_client_id']; $company_id = $row['company_id']; // Set limit & offset for queries if (isset($_GET['limit'])) { $limit = intval($_GET['limit']); } elseif (isset($_POST['limit'])) { $limit = intval($_POST['limit']); } else { $limit = 50; } if (isset($_GET['offset'])) { $offset = intval($_GET['offset']); } elseif (isset($_POST['offset'])) { $offset = intval($_POST['offset']); } else { $offset = 0; } } }