false, 'reason' => '입력값이 설정되지 않았습니다.' ]); } if (strlen((string) $password) != 128) { Json::die([ 'result' => false, 'reason' => '올바르지 않은 비밀번호 해시 포맷입니다.' ]); } if (!class_exists('\\sammo\\RootDB')) { Json::die([ 'result' => false, 'reason' => 'DB 설정이 완료되지 않았습니다.' ]); } $rootDB = RootDB::db(); //초기 관리자 계정은 딱 하나만 있어야하므로, 중요함. $rootDB->query('LOCK TABLES member WRITE, member_log WRITE'); $memberCnt = $rootDB->queryFirstField('SELECT count(`NO`) from member'); if ($memberCnt > 0) { Json::die([ 'result' => 'false', 'reason' => '이미 계정이 생성되어 있습니다' ]); } $userSalt = bin2hex(random_bytes(8)); $finalPassword = Util::hashPassword($userSalt, $password); $nowDate = TimeUtil::now(); $rootDB->insert('member', [ 'oauth_type' => 'NONE', 'id' => $username, 'email' => null, 'token_valid_until' => '2999-01-01 00:00:00', 'pw' => $finalPassword, 'salt' => $userSalt, 'grade' => 7, 'name' => $nickname, 'reg_date' => $nowDate ]); $userID = $rootDB->insertId(); $rootDB->insert('member_log', [ 'member_no' => $userID, 'date' => $nowDate, 'action_type' => 'reg', 'action' => Json::encode([ 'type' => 'none', 'aux' => 'admin', 'id' => $username, 'name' => $nickname ]) ]); Json::die([ 'result' => true, 'reason' => 'success' ]);