function processTweet($tweet) { // who wrote the tweet? $contents = strtolower($tweet->text); // if we're testing, only allow test tweets through // (if we're not testing, don't allow test tweets through!) global $testing; if ($testing == true && strpos($contents, "#test") === false || $testing != true && strpos($contents, "#test") !== false) { return $tweet->id_str; } loginfo("Processing tweet " . $tweet->id_str . " from user " . $tweet->user->screen_name . "\n" . $contents); // Or we can adjust it, which basically just performs a delete // followed by a new insert $tweet->information = getTweetInformation($tweet); // If we're registering a new challenger! $processed = false; $register = strpos($contents, "#register"); if ($register !== false) { processRegistration($tweet); $processed = true; } // We can "delete" a tweet with the undo tag $undo = strposa($contents, array("#undo", "#delete")); if (!$processed && $undo !== false) { // basically change the 'inc_' to 'del_' processUndo($tweet); $processed = true; } // We can edit an existing tweet $edit = strposa($contents, array("#edit", "#update")); if (!$processed && $edit !== false) { processEdit($tweet); $processed = true; } // filter now for ID/Events - we can only run the following on single events if (!$processed && findEntryId($tweet) < 0) { // we count errors as processing, because we've replied replyEntryErrorTweet($tweet); $processed = true; } // If we're removing an entry $giveup = strpos($contents, "#giveup"); if (!$processed && $giveup !== false) { processGiveup($tweet); $processed = true; } // If we're processing content if (!$processed && $tweet->information->contenttype) { processContent($tweet); $processed = true; } // If we got this far and still didn't process it, there's something wrong if (!$processed) { } // After processing, return the ID if (!$testing) { return $tweet->id_str; } }
@author Joseph Fehrman */ include_once "../db/connection.php"; // Collection of post variables $firstName = $_POST['first_name']; $lastName = $_POST['last_name']; $username = $_POST['username']; $password = $_POST['password']; $passwordConfirmation = $_POST['re_password']; $email = $_POST['email']; // Validation function $validation = validateRegistration($username, $password, $passwordConfirmation, $email, $conn); if ($validation == "success") { // If content is valid processRegistration($firstName, $lastName, $username, $password, $email, $conn); } /** Function that validates user input on registration page. @param $user - requested username @param $pass - requested password @param $repass - password confirmation @param $email - requested email @param $connection - database connection */ function validateRegistration($user, $pass, $rePass, $email, $connection) { //Check if username already exist. $validationError = ""; $sqlUsernameCheck = "SELECT Username FROM todo_user WHERE Username = '******'";