public static function getProximusUniqueUser() { $MAC_ADDR = Util::getCONNECTED_MAC(); // line format is MAC,last_session_id,first_seen,last_seen,times_seen // if the last_session_id is not the current one, then we know it's a new session // and we will increment the session count and update last_seen $file_containing_users = "/home/proximus/config/php_unique_users.txt"; if (is_readable($file_containing_users)) { $file_handle = @fopen($file_containing_users, 'r'); while (!feof($file_handle) && !$found) { $line = fgets($file_handle); $entry = explode(",", $line); if ($entry[0] == $MAC_ADDR) { $found = true; fclose($file_handle); $user = ProximusUniqueUser::fromString($line); Proximus::writeProximusUniqueUser($user); return $user; } } } // if we get here, either the user is unknown or the file doesn't exist $user = ProximusUniqueUser::withMac($MAC_ADDR); Proximus::writeProximusUniqueUser($user); return $user; }
public static function fromString($line) { $entry = explode(",", $line); $instance = ProximusUniqueUser::withData($entry[0], $entry[1], $entry[2], $entry[3], $entry[4]); return $instance; }