Issue
I have a function of a download parser, where the url of one site it's changed: http://paste.co to https://controlc.com/
I can't change the url from a database, because aare encrypted.
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;
}
I need help to change the old url (pased.co) to the new one, before to decrypt the container.
Solution
Use 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;
}
Answered By - Barmar Answer Checked By - Gilberto Lyons (PHPFixing Admin)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.