php - 如何在使用 php 之前更改 url
问题描述
我有一个下载解析器的功能,其中一个站点的 URL 已更改: http: //paste.co到https://controlc.com/
我无法从数据库更改 url,因为 a 已加密。
class download_parser
{
private $container_domains = '(?:tinypaste\\.com|tny\\.cz|controlc\\.com)';
private $base_url = '';
private $package = null;
private $package_passwords = array();
public $current_password = '';
public function __construct()
{
global $phpbb_root_path, $phpEx;
include($phpbb_root_path . 'contributions/dlcapi/dlcapi.class.' . $phpEx);
}
public function set_base_url($url)
{
$this->base_url = preg_replace('#http[s]?://#i', '', $url);
if(substr($this->base_url, -1) != '/')
{
$this->base_url .= '/';
}
return $this;
}
在解密容器之前,我需要帮助将旧网址(pased.co)更改为新网址。
解决方案
利用preg_replace
public function set_base_url($url)
{
$this->base_url = preg_replace('#http[s]?://#i', '', $url);
$this->base_url = preg_replace('#^paste\.co\b#', 'controlc.com', $this->base_url);
if(substr($this->base_url, -1) != '/')
{
$this->base_url .= '/';
}
return $this;
}
推荐阅读
- python - pyqt5冻结问题
- c# - CSScript (oleg-shilo) 调用加载文件的方法 - 可能吗?
- delphi - 将字符串转换为 VKCode:不兼容的类型:“整数”和“字符串”
- documentation - 使用 OpenAPI 规范的 API 文档,在一个中心位置有多个规范
- android - 颤振标签不匹配问题
- transactions - 为什么我们需要渠道?
- django - 在引导模型中始终禁用下拉列表?
- javascript - 将表单从“只读”更改为 PATCH
- jenkins - 用于 Jenkins 的 Kubernetes 云代理在管道执行期间始终离线
- python - 当我尝试通过 for 循环修改数组时,为什么数组没有改变