public function join() { extract($_POST); if ($password != $password_again) { throw new Error("Passwords do not match"); } if (strlen($password) < 6) { throw new Error("Oops, please enter a password at least 6 characters long."); } if (!preg_match('#^[a-zA-Z0-9_.]+$#', $username)) { throw new Error("Oops, please enter a username composed letters, numbers, periods or underscores."); } $userexists = $this->server->db->value($this->sql['checkuser'], array('username' => $username)); if ($userexists) { throw new Error('Sorry, that username has already been taken. Please choose again.'); } $emailexists = $this->server->db->value($this->sql['checkemail'], array('email' => $email)); if ($emailexists) { throw new Error('Sorry, that email has already been used. You can use the password retrieval form to retrieve your username.'); } $user = new User_Object(); $user->set(array('username' => $username, 'display_name' => $username, 'password' => md5($password), 'email' => $email)); $this->server->db->save($user); $this->server->user = $user; }
public function receive() { extract($_REQUEST); $f = fopen(dirname(__FILE__) . "/sms.log", "a"); fwrite($f, "[RECEIVE]\n"); fwrite($f, "Phone: {$phone}\n"); fwrite($f, "Message: {$msg}\n"); fwrite($f, "Action: {$action}\n"); fwrite($f, "=====\n\n"); fflush($f); fclose($f); $artworkid = trim($msg); Artwork::store_artwork_by_id($artworkid); $artwork = $this->server->moma->load("artwork({$artworkid})"); if ($artwork) { list($user, $new) = $this->userByPhone($phone); extract($user); $userid = $id; $args = compact('userid', 'artworkid'); $count = $this->server->moma->value("SELECT COUNT(*) FROM savedartwork WHERE userid=:userid AND artworkid=:artworkid", $args); if ($count == 0) { $savedartwork = new SavedArtWork_Object(); $savedartwork->set(compact('userid', 'artworkid')); $this->server->moma->save($savedartwork); } $artwork = $artwork->get(); $title = $artwork['title']; if (!$dontremind) { $updateuser = new User_Object(); $updateuser->set($user); $updateuser->set('dontremind', 1); $this->server->moma->save($updateuser); if ($username == '') { sendsms($normalized_phone, "Hey there. '{$title}' was just saved for you. Go to moma.org/txt to retrieve it and any other works you collect. See you there!"); } else { sendsms($normalized_phone, "Hey {$username}. '{$title}' was added to your collection. You will find it and any other work you collect on moma.org. See you there!"); } } } else { sendsms($phone, "{$artworkid} does not refer to any item in our database. Please verify the number and try again."); } }