Mailinglisten-Archive |
harald_hanek at hotmail.com wrote:
> Ich hab ins replace noch eine Funktion eingebaut und dann klappts:
>
> <?php
>
> $pattern = ',<a([^>]+)href="([^>"\s]+)",ie';
> $replace = '"<a\1href=\"" . make_SID("\2") . "\""';
> $content = preg_replace($pattern, $replace, $content);
Erzeugt das nicht doppelt "" am ende?
und ein '>', ebenso wie ein ' ', würde den das href-Attribut nicht
schließen (IMHO)
ein href="seite.php?para=zwei worte"
oder href="seite.php?para=<alt>"
ist durchaus möglich
und warum ersetzt du immer den ganzen Link ?
$pattern = ',<a[^>]+href="([^"]+),ie';
$replace = 'make_SID("\1")';
$content = preg_replace($pattern, $replace, $content);
> function make_SID($link)
> {
> global $cms_conf;
>
> if(substr_count($link, 'content.php') >= 1 && substr_count($link, SID)
> == 0) $link = $link."&".SID;
> return $link;
> }
>
> ?>
wenn du nur content.php und nur ohne SID haben willst, dann pack das
doch mit ins regex
$pattern = ',<a[^>]+href="[^"]*content\.php([^"]*),ie';
$replace = '"\1&" . SID';
oder
$pattern = ',<a[^>]+href="[^"]*content\.php[^"]+(?<!' . SID .
')[^"]*("),ie';
$replace = '"&" . SID . "\""';
...
--
Sebastian Mendel
www.sebastianmendel.de
www.sf.net/projects/phpdatetime | www.sf.net/projects/phptimesheet
php::bar PHP Wiki - Listenarchive