"; $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"); }