public static function Create($post=NULL) { $invite = new Invite($post["code"]); if ( !$invite->Available() ) { throw new Exception("Invite has already been redeemed."); } if ( App::Obj()->UseFacebook() ) { require_once "Tools/Facebook/facebook.php"; $fb = new Facebook( App::Obj()->FacebookSettings() ); $user = $fb->getUser(); if ( $user ) { $data = $fb->api("/me"); $fbId = $data["id"]; if ( ! $fbId ) throw new Exception("FB ID invalid"); $in = array("facebook" => $fbId); DB::zdb()->insert("users", $in); Auth::Obj()->LogIn(); } } else { unset($post["pass2"]); unset($post["code"]); $pass = $post["pass"]; $post["pass"] = md5($post["pass"]); $n = DB::zdb()->insert("users", $post); Auth::Obj()->LogIn($post["user"], $pass); } if ( Auth::Obj()->Authenticated() ) { $invite->Reconcile(); Log::Activity("created their user account"); } }