public function createEditor($strUser, $strPassword, $strEmail, $strComments) { $query = "SELECT editor_id FROM editors WHERE name = '{$strUser}' LIMIT 1"; if (mysql_fetch_array(Module::query($query))) { return new returnData(4, NULL, 'user exists'); } $query = "SELECT editor_id FROM editors WHERE email = '{$strEmail}' LIMIT 1"; if (mysql_fetch_array(Module::query($query))) { return new returnData(5, NULL, 'email exists'); } $strComments = addslashes($strComments); $query = "INSERT INTO editors (name, password, email, comments, created, read_write_token) \n VALUES ('{$strUser}',MD5('{$strPassword}'),'{$strEmail}','{$strComments}', NOW(), '" . Utils::rand_string(64) . "')"; Module::query($query); if (mysql_error()) { return new returnData(3, NULL, 'SQL Error'); } $subject = "Welcome to the ARIS Alpha Editor!"; $body = "<p><strong>You signed up to become an editor for ARIS!</strong> To get things started well, we wanted to make sure you knew about a few things and had places to look for help.</p>\n <p>For starters, there are demo videos and documentation at http://arisgames.org/make/training-videos/.</p>\n <p>If you have questions and want to talk with other users, join our google group at http://groups.google.com/group/arisgames. You can post a new discussion there or send an email to arisgames@googlegroups.com.</p>\n <p>If you discover bugs or have new ideas, please tell us at http://arisgames.lighthouseapp.com.</p>\n <p>Just so you don't forget, your username is {$strUser} and your password is {$strPassword}</p>\n <p>Good luck making games!</p>"; Module::sendEmail($strEmail, $subject, $body); return Editors::getToken($strUser, $strPassword, "read_write"); }
public static function linkV1EditorToV2User($editorName, $editorPass = false, $v2UserId = false, $v2Key = false) { /*Huge hack to allow for either v1 style access or v2 access*/ if (!$editorPass) { $data = file_get_contents("php://input"); $glob = json_decode($data); $editorName = $glob->v1_name; $editorPass = $glob->v1_pass; $v2UserId = $glob->auth->user_id; $v2Key = $glob->auth->key; } /*End huge hack*/ $Players = new Players(); $Editors = new Editors(); $v1Player = $Players->getLoginPlayerObject($editorName, $editorPass)->data; $v1Editor = $Editors->getToken($editorName, $editorPass, "read_write")->data; //v1 player optional, v1 editor not if (!$v1Editor) { return new migration_return_package(1, NULL, "Editor Credentials Invalid"); } $loginPack = new stdClass(); $loginPack->auth = new stdClass(); $loginPack->auth->user_id = $v2UserId; $loginPack->auth->key = $v2Key; $loginPack->no_auto_migrate = true; //negative var name because it's a hack and we want the default to be nonexistant $v2User = bridgeService("v2", "users", "logIn", "", $loginPack); if ($v2User->returnCode != 0) { return new migration_return_package(1, NULL, "Invalid v2 credentials"); } $v2User = $v2User->data; //clear out existing links to v1 data if ($v1Player && ($mig = migration_dbconnection::queryObject("SELECT * FROM user_migrations WHERE v1_player_id = '{$v1Player->player_id}'"))) { $v1Player = false; //v1 player migrated under diff account- don't try to link } if ($v1Editor && migration_dbconnection::queryObject("SELECT * FROM user_migrations WHERE v1_editor_id = '{$v1Editor->editor_id}'")) { if (!$mig->v1_player_id) { migration_dbconnection::query("DELETE FROM user_migrations WHERE v1_editor_id = '{$v1Editor->editor_id}'"); } else { migration_dbconnection::query("UPDATE user_migrations SET v1_editor_id = '0' WHERE v1_editor_id = '{$v1Editor->editor_id}'"); } } if (!$v1Player) { $v1Player = new stdClass(); $v1Player->player_id = 0; } if (!$v1Editor) { $v1Editor = new stdClass(); $v1Editor->editor_id = 0; } migration_dbconnection::query("DELETE FROM user_migrations WHERE v2_user_id = '{$v2User->user_id}'"); //clear out any previous migration data for v2 user migration_dbconnection::query("INSERT INTO user_migrations (v2_user_id, v2_read_write_key, v1_player_id, v1_editor_id, v1_read_write_token) VALUES ('{$v2User->user_id}', '{$v2User->read_write_key}', '{$v1Player->player_id}', '{$v1Editor->editor_id}', '{$v1Editor->read_write_token}')"); return new migration_return_package(0, true); }