diff --git a/gencode.php b/gencode.php new file mode 100644 index 0000000..b289e27 --- /dev/null +++ b/gencode.php @@ -0,0 +1,30 @@ + "; +$num = trim(fgets(STDIN)); +$conn = mysqli_connect($_config['db_host'], $_config['db_user'], $_config['db_pass'], $_config['db_name'], $_config['db_port']); +if(preg_match("/^[\d]{1,8}$/", $num)) { + $num = Intval($num); + for($i = 0;$i < $num;$i++) { + $code = getRandomText(32); + mysqli_query($conn, "INSERT INTO `invitecode` (`code`, `user`) VALUES ('{$code}', NULL)"); + echo "已添加:{$code}\n"; + } + exit("已生成指定数量激活码至数据库!\n"); +} else { + exit("数量不合法\n"); +}