|
Posted by shimmyshack on 02/22/07 18:10
On 21 Feb, 00:55, "Alred Wallace" <p...@free.Fr> wrote:
> Does anybody knows where i can find a phpscript making all link in a web
> page (http://thehost/thepage.html) absolute:
> images, script, styles, href...
>
> images being the most important:
> src=http://hosturl...
> replacing <img src="../imzgd/sdf/myimage.jpg".. in thepage.html. source.
>
> I think it can be done with regular expression, but i much prefer to find
> something more "complete" and unbugy.
>
> Thk for your help.
in what context?
1. opening a prewritten webpage, parsing it for relative links and
correcting them
2. or within a php script so that you can write your links in the form
1.
$html .= '<img src="' . IMAGES_ROOT . 'myimage.jpg" />';
this is best done with a regular expression, and will have already
been done by someone else, you will have to parse for HREF, SRC,
URL( with single and double quotes, perhaps javascript,
2.
if the latter, then a very useful method is to have a config.inc.php
file which has all your paths set inside it when you install the app,
or on a per request basis.
$arrConfig['selected_theme'] = 'big_brash_blue_design';
define( FS_APP_ROOT, dirname( __FILE__ ) );
define( WEB_APP_ROOT, str_replace( FS_APP_ROOT, '',
dirname($_SERVER['REQUEST_URI']) . '/' ) );
define( WEB_THEMES_ROOT, WEB_APP_ROOT . 'themes/' .
$arrConfig['selected_theme'] . '/' );
define( WEB_IMAGES_ROOT, WEB_THEMES_ROOT . '/images/' );
echo '<pre>' , FS_APP_ROOT, "\n", WEB_APP_ROOT, "\n", WEB_THEMES_ROOT,
"\n", WEB_IMAGES_ROOT , '</pre>';
where some of the configs can be chosen from a selection and stored as
a user preference in a cookie... as in the case of the theme here
This way your environment is set up, and whenever you have a
Navigation:
[Reply to this message]
|