Page 2 of 2

funzt jetzt

Posted: Tue 2. Jan 2007, 14:50
by phalancs
So ich habe es hinbekommen, es funzt. So ganz verorten kann ich den ursrünglichen Fehler dennoch leider nicht, aber Du hattest mich irgendwie in die richtige Richtung geleitet. :)

Durch Deinen Tipp konnte ich schonmal sehen dass die Variablen korrekt ausgelesen wurden. Nann habe ich egtl. nur an der Outputzeile gedreht.

Dann hab ich nochmal vorsichtshalber in die link.txt geschaut und geprüft ob da noch irgendwelche unsichtbaren Zeichen drin waren, war aber nicht.

Ich habe das Gefühl das diese Output-Zeile nicht richtig funzt wenn der Inhalt nicht als Variable anfängt, macht irgendwie keinen Sinn aber mit meinem Workaround funzt es.. :S

Crazy...

Hier das Ergebnis:

global_replacer.php [put into frontend_render]

Hey Marcus, wolln wa das als hack in einen eigenen thread posten, könnte ja bei vorsichtiger Anwendung sehr nützlich sein und geht in diesem Thema hier mglw. etwas unter.

Code: Select all

<?php 
$datei = "cms/config/links.txt"; 
$wordlist = file($datei); 

for ($i = 0; $i < count($wordlist); $i++) { 
$wordlist[$i] = explode(";" , $wordlist[$i]); 

$wordlist[$i]['keyword']=$wordlist[$i][0]; 
$wordlist[$i]['link']=$wordlist[$i][1]; 
} 

function mytag($keyword,$link) { 
//$output="<a href=\"http://" . $link . "\" target=\"_blank\">" . $keyword . "</a>"; 
//$output='<a href="http://' . $link . '" target="_blank">' . $keyword . '</a>'; 

//what should the keywords be replaced with? Change here:
$linker = '<a href="http://'.$link.'" target="_blank">'.$keyword.'</a>';

$output = $linker; 

return $output; 
} 


$i=0; 
while ($i <= count($wordlist)) { 
$content['all'] = str_replace($wordlist[$i]['keyword'],mytag($wordlist[$i]['keyword'],$wordlist[$i]['link']),$content['all']); 
$i++; 
} 
?> 
links.txt

Code: Select all

x_enym;www.enym.com
x_videos;www.phorce.de

INSTALL:

If you want to replace certain words sitewide:

1. Create a php file in the frontend_render folder
2. create a file with the keywords and the links in config folder

done!

BE CAREFUL! ONLY USE UNIQUE WORDS as keywords. Do only use this script if you know what to do!

Posted: Fri 5. Jan 2007, 00:38
by iriechaos
hi sry war lang nicht online.

Der Markus hatte mir noch eine preg_replace() funktion geschrieben. Sie funktioniert eigtl ganz gut. Beim java script verursacht sie nen fehler den ich nicht ganz nachvollziehen kann. Muss aber gestehen das ich die preg_replace() funktion noch nicht so ganz verstehe.

hier der code
<?
$datei = "config/links.txt";
$wordlist = file($datei);

for ($i = 0; $i < count($wordlist); $i++) {
$wordlist[$i] = explode(";" , $wordlist[$i]);

$wordlist[$i]['keyword']=$wordlist[$i][0];
$wordlist[$i]['link']=$wordlist[$i][1];
}

function mytag($keyword,$link) {
$output="<a href=\"http://" . $link . "\" target=\"_blank\">" . $keyword . "</a>";
return $output;
}


$i=0;
while ($i <= count($wordlist)) {
//echo $wordlist[$i]['keyword'];
//$content['all'] = str_replace($wordlist[$i]['keyword'],mytag($wordlist[$i]['keyword'],$wordlist[$i]['link']),$content['all']);
$wlk=$wordlist[$i]['keyword'];
$wll=$wordlist[$i]['link'];
$content['all'] = preg_replace("/((<[^>]*)|$wlk)/ie", '"\2"=="\1"? "\1":mytag($wlk,$wll)', $content['all']);
$i++;
}
?>
aus diesem java code
<a href="index.php?specials"
onMouseOver="MM_swapImage('events','','images/template_final_s-04_over.jpg',1);MM_swapImage('start','','images/template_final_s-03_events.jpg',1);MM_swapImage('start','','images/template_final_events.jpg',1)"
onMouseOut="MM_swapImage('events','','images/template_final_s-04.jpg',1);MM_swapImage('start','','images/template_final_s-03_start.jpg',1);MM_swapImage('start','','images/news.jpg',1)">
<IMG SRC="images/template_final_s-04.jpg" ALT="" name="events" WIDTH=131 HEIGHT=207 border="0" id="events"></a></TD>
wird das
<a href="index.php?specials"
onMouseOver="MM_swapImage(\\\\\\\\\\\\\\\\\\\\\\\\\\\'events\\\\\\\\\\\\\\\\\\\\\\\\\\\',\\\\\\\\\\\\\\\\\\\\\\\\\\\'\\\\\\\\\\\\\\\\\\\\\\\\\\\',\\\\\\\\\\\\\\\\\\\\\\\\\\\'images/template_final_s-04_over.jpg\\\\\\\\\\\\\\\\\\\\\\\\\\\',1);MM_swapImage(\\\\\\\\\\\\\\\\\\\\\\\\\\\'start\\\\\\\\\\\\\\\\\\\\\\\\\\\',\\\\\\\\\\\\\\\\\\\\\\\\\\\'\\\\\\\\\\\\\\\\\\\\\\\\\\\',\\\\\\\\\\\\\\\\\\\\\\\\\\\'images/template_final_s-03_events.jpg\\\\\\\\\\\\\\\\\\\\\\\\\\\',1);MM_swapImage(\\\\\\\\\\\\\\\\\\\\\\\\\\\'start\\\\\\\\\\\\\\\\\\\\\\\\\\\',\\\\\\\\\\\\\\\\\\\\\\\\\\\'\\\\\\\\\\\\\\\\\\\\\\\\\\\',\\\\\\\\\\\\\\\\\\\\\\\\\\\'images/template_final_events.jpg\\\\\\\\\\\\\\\\\\\\\\\\\\\',1)"
onMouseOut="MM_swapImage(\\\\\\\\\\\\\\\\\\\\\\\\\\\'events\\\\\\\\\\\\\\\\\\\\\\\\\\\',\\\\\\\\\\\\\\\\\\\\\\\\\\\'\\\\\\\\\\\\\\\\\\\\\\\\\\\',\\\\\\\\\\\\\\\\\\\\\\\\\\\'images/template_final_s-04.jpg\\\\\\\\\\\\\\\\\\\\\\\\\\\',1);MM_swapImage(\\\\\\\\\\\\\\\\\\\\\\\\\\\'start\\\\\\\\\\\\\\\\\\\\\\\\\\\',\\\\\\\\\\\\\\\\\\\\\\\\\\\'\\\\\\\\\\\\\\\\\\\\\\\\\\\',\\\\\\\\\\\\\\\\\\\\\\\\\\\'images/template_final_s-03_start.jpg\\\\\\\\\\\\\\\\\\\\\\\\\\\',1);MM_swapImage(\\\\\\\\\\\\\\\\\\\\\\\\\\\'start\\\\\\\\\\\\\\\\\\\\\\\\\\\',\\\\\\\\\\\\\\\\\\\\\\\\\\\'\\\\\\\\\\\\\\\\\\\\\\\\\\\',\\\\\\\\\\\\\\\\\\\\\\\\\\\'images/news.jpg\\\\\\\\\\\\\\\\\\\\\\\\\\\',1)">
<IMG SRC="images/template_final_s-04.jpg" ALT="" name="events" WIDTH=131 HEIGHT=207 border="0" id="events"></a></TD>
verstehe nicht ganz warum.

vlt hilft es euch weiter. Ich bin leider noch am rätseln.

gruß