如何在 php 上使用前更改 url
how to change an url before to use on php
我有一个下载解析器的功能,其中一个站点的 url 已更改:
http://paste.co to https://controlc.com/
我无法从数据库中更改 url,因为它们是加密的。
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;
}
在解密容器之前,我需要帮助将旧的 url (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;
}
我有一个下载解析器的功能,其中一个站点的 url 已更改: http://paste.co to https://controlc.com/
我无法从数据库中更改 url,因为它们是加密的。
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;
}
在解密容器之前,我需要帮助将旧的 url (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;
}