Files
fdesk/app/command/TbCommand.php
T

49 lines
1.5 KiB
PHP
Raw Normal View History

2025-07-28 18:49:33 +08:00
<?php
namespace app\command;
use app\common\model\User;
use app\common\model\UserSn;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Helper\Table;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use support\Db;
class TbCommand extends Command
{
protected static $defaultName = 'tb-db';
protected static $defaultDescription = '';
protected function execute(InputInterface $input, OutputInterface $output): int
{
$user = new User();
$list = $user->all();
foreach ($list as $item) {
// UserSn::where('user_sn', $item->sn)->update(['user_id' => $item->id]);
}
return self::SUCCESS;
}
}
function replaceRichTextUrls($input) {
// 匹配旧域名及其引号包裹情况(包含http/https协议)
$pattern = '#(https?://server\.xyh\.hnzhwlkj\.club|["\']https?://server\.xyh\.hnzhwlkj\.club)(/[^\s"\'<>]*)?#iu';
$replacement = function ($matches) {
$originalQuote = '';
$path = $matches[2] ?? '';
// 检测是否以引号开头
if (isset($matches[0][0]) && in_array($matches[0][0], ['"', "'"])) {
$originalQuote = $matches[0][0];
}
// 构建新URL(强制使用http协议)
return $originalQuote . 'http://219.157.255.213:25326' . $path;
};
return preg_replace_callback($pattern, $replacement, $input);
}