} $flip_active = patcf_flip_is_active($seconds); $deny_issue_based = false; if ($token == "") { $state = "stale"; $message = "No token!"; $comments[] = "No token supplied"; } elseif (empty($product_id)) { $state = "inactive"; $message = "No product requested!"; $comments[] = "No product_id supplied"; } elseif (in_array(strrev($token), array("expiredtoken", "blockedtoken", "alwaysstaletoken"))) { $state = "stale"; $message = "You need to log in again!"; $comments[] = "Your token is no longer valid"; } elseif (patcf_is_active($all_users, $user)) { $state = "active"; if (startsWith($user, "flip")) { $message = "Your subscription will expire in {$seconds} seconds."; } if (startsWith($user, "yes")) { $message = "I've hacked the response to appear active. But I lie."; } else { $message = "Your subscription is active."; } } else { $state = "inactive"; if (startsWith($user, "flip")) { $message = "Your subscription will become active in {$seconds} seconds."; if (!endsWith($user, 'some')) { $deny_issue_based = true;
function patcf_get_test_users($all_users) { $test_users = array(); $test_users[] = array("state" => "UNKNOWN", "username" => "rubbish", "password" => ""); $test_users[] = array("state" => "STALE", "username" => "expiredtoken", "password" => ""); $test_users[] = array("state" => "STALE", "username" => "blockedtoken", "password" => ""); $test_users[] = array("state" => "STALE", "username" => "alwaysstaletoken", "password" => ""); foreach ($all_users as $user) { $active = patcf_is_active($all_users, $user); $test_users[] = array("state" => $active ? "ACTIVE" : "INACTIVE", "username" => $user, "password" => ''); } $test_users[] = array("state" => "ACTIVE", "username" => "peter", "password" => "pan"); return $test_users; }
function patcf_get_test_users($all_users) { $test_users = array(); $test_users[] = array("state" => "UNKNOWN", "username" => "rubbish"); $test_users[] = array("state" => "STALE", "username" => "badtoken"); foreach ($all_users as $user) { $active = patcf_is_active($all_users, $user); $test_users[] = array("state" => $active ? "ACTIVE" : "INACTIVE", "username" => $user); } return $test_users; }