status = true; if (in_array($username,$_SESSION['usernames'])) { $ret->status = false; // make the current username unique $i = 1; $new = $username.$i++; while(in_array($new,$_SESSION['usernames'])) { $new = $username.$i++; } $ret->message = "

Username $username already in use, maybe you could use '$new' instead.

"; } return $ret; } } // Including this sets up the JPSPAN constant require_once 'JPSpan/JPSpan.php'; // Load the PostOffice server require_once JPSPAN . 'Server/PostOffice.php'; // Create the PostOffice server $S = & new JPSpan_Server_PostOffice(); // Register your class with it... $S->addHandler(new username_validator()); // This allows the JavaScript to be seen by // just adding ?client to the end of the // server's URL if (isset($_SERVER['QUERY_STRING']) && strcasecmp($_SERVER['QUERY_STRING'], 'client')==0) { // Compress the output Javascript (e.g. strip whitespace) // turn this off it has performance problems define('JPSPAN_INCLUDE_COMPRESS',false); // Display the Javascript client $S->displayClient(); } else { // This is where the real serving happens... // Include error handler // PHP errors, warnings and notices serialized to JS require_once JPSPAN . 'ErrorHandler.php'; // Start serving requests... $S->serve(); } ?>