Scleppel
03-18-2005, 03:12 PM
Ok, this is a small example of what happens in my script.
Sorry if the code errors because of unescaped quotes.
<?php
$p_domain = 'localhost'; //These variables are made by the script
$real_url_dir = 'domain.net'; //this variable sometimes has a directory aswell
$html = 'href="http://localhost/?domain.net/dir/style.css"' . "\n" .
'href=\\'http://localhost/?domain.net/dir/style.css\\'' . "\n" .
'href=http://localhost/?domain.net/dir/style.css' . "\n" .
'href="dir/style.css"' . "\n" .
'href=\\'dir/style.css\\'' . "\n" .
'href=dir/style.css' . "\n";
$search = array("'href=\\"[^(http://{$p_domain}/?http://)]'si",
"'href=\\'[^(http://{$p_domain}/?http://)]'si",
"'href=[^(\"|\\'|)(http://{$p_domain}/?http://)]'si");
$replace = array("href=\\"http://{$p_domain}/?{$real_url_dir}/",
"href='http://{$p_domain}/?{$real_url_dir}/",
"href=http://{$p_domain}/?{$real_url_dir}/");
$clean_html = preg_replace($search, $replace, $html);
echo $clean_html;
?>
The output is
href="http://localhost/?domain.net/dir/style.css"
href='http://localhost/?domain.net/dir/style.css'
href=http://localhost/?domain.net/dir/style.css
href="http://localhost/?domain.net/ir/style.css"
href='http://localhost/?domain.net/ir/style.css'
href=http://localhost/?domain.net/ir/style.css
The problem is that the second block of urls have the d of dir missing. Does anyone know how to stop them from disapearing?
Sorry if the code errors because of unescaped quotes.
<?php
$p_domain = 'localhost'; //These variables are made by the script
$real_url_dir = 'domain.net'; //this variable sometimes has a directory aswell
$html = 'href="http://localhost/?domain.net/dir/style.css"' . "\n" .
'href=\\'http://localhost/?domain.net/dir/style.css\\'' . "\n" .
'href=http://localhost/?domain.net/dir/style.css' . "\n" .
'href="dir/style.css"' . "\n" .
'href=\\'dir/style.css\\'' . "\n" .
'href=dir/style.css' . "\n";
$search = array("'href=\\"[^(http://{$p_domain}/?http://)]'si",
"'href=\\'[^(http://{$p_domain}/?http://)]'si",
"'href=[^(\"|\\'|)(http://{$p_domain}/?http://)]'si");
$replace = array("href=\\"http://{$p_domain}/?{$real_url_dir}/",
"href='http://{$p_domain}/?{$real_url_dir}/",
"href=http://{$p_domain}/?{$real_url_dir}/");
$clean_html = preg_replace($search, $replace, $html);
echo $clean_html;
?>
The output is
href="http://localhost/?domain.net/dir/style.css"
href='http://localhost/?domain.net/dir/style.css'
href=http://localhost/?domain.net/dir/style.css
href="http://localhost/?domain.net/ir/style.css"
href='http://localhost/?domain.net/ir/style.css'
href=http://localhost/?domain.net/ir/style.css
The problem is that the second block of urls have the d of dir missing. Does anyone know how to stop them from disapearing?