Seite 2 von 3

Verfasst: 17.03.2003 21:02
von saerdnaer
achso... dazu müsste man des userlevel des posters mit an die funktion übergeben... oder die funktion nur ausführen wenn ein poster das entsprechende level hat...

ah

Verfasst: 17.03.2003 21:45
von Syco23
ja und weiter?.. bin kein php-noob, sonder noch schlimmer: php-analphabet, wäre nett wenn mir wer erklären würde wie das geht.

Falls das zu schwierig ist, dann so:

Alle urls -> "Es wurde versucht eine urls zu posten!

http://www.... -> ebenfalls "es wurde versucht.."

[irgendwas]www..[/irgendwas] -> normales Klickbarmachen (dieses Tag habe ich mir schon definiert, geht auch bestens, sag nur nicht wie ichs genannt hab :D )

Ich glaub das habe ich eh schon gepostet, also wie gesagt: es wäre toll, wenn dann auch noch am Ende der Nachricht, wo die Url entfernt wurde zusätzlich was erscheinen würde. Wenn wirs so machen ist das Userleven eglal, weil ich eh mein eigenes Tag habe..

Verfasst: 18.03.2003 14:59
von saerdnaer
achso die urls sollen garnicht mehr angezeigt werden... außer du gibst eine ein oder?

ah

Verfasst: 18.03.2003 15:53
von Syco23
Ja, genau so, is wohl am einfachsten. Also: url alleine wird mit Text ersetzt und [irgendwas]url[/irgendwas] funktioniert. Wenn wir das haben komm ich eventuell noch mit weiteren Fragen :D

Editieren müssen wir:

Code: Alles auswählen

function make_clickable($text)
{ 
		// pad it with a space so we can match things at the start of the 1st line.
		$ret = ' ' . $text;

		// matches an "xxxx://yyyy" URL at the start of a line, or after a space.
		// xxxx can only be alpha characters.
		// yyyy is anything up to the first space, newline, comma, double quote or <
		$ret = preg_replace("#([\t\r\n ])([a-z0-9]+?){1}://([\w\-]+\.([\w\-]+\.)*[\w]+(:[0-9]+)?(/[^ \"\n\r\t<]*)?)#i", '\1<a href="\2://\3" target="_blank">\2://\3</a>', $ret);

		// matches a "www|ftp.xxxx.yyyy[/zzzz]" kinda lazy URL thing
		// Must contain at least 2 dots. xxxx contains either alphanum, or "-"
		// zzzz is optional.. will contain everything up to the first space, newline, 
		// comma, double quote or <.
		$ret = preg_replace("#([\t\r\n ])(www|ftp)\.(([\w\-]+\.)*[\w]+(:[0-9]+)?(/[^ \"\n\r\t<]*)?)#i", '\1<a href="http://\2.\3" target="_blank">\2.\3</a>', $ret);
	
		// matches an email@domain type address at the start of a line, or after a space.
		// Note: Only the followed chars are valid; alphanums, "-", "_" and or ".".
		$ret = preg_replace("#([\n ])([a-z0-9\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)*[\w]+)#i", "\\1<a href=\"mailto:\\2@\\3\">\\2@\\3</a>", $ret);

		// Remove our padding..
		$ret = substr($ret, 1);
	
		return($ret);
}

Verfasst: 19.03.2003 19:07
von saerdnaer
okay... probier mal:

Code: Alles auswählen

function make_clickable($text) 
{ 
      // pad it with a space so we can match things at the start of the 1st line. 
      $ret = ' ' . $text; 

      // matches an "xxxx://yyyy" URL at the start of a line, or after a space. 
      // xxxx can only be alpha characters. 
      // yyyy is anything up to the first space, newline, comma, double quote or < 
      $ret = preg_replace("#([\t\r\n ])([a-z0-9]+?){1}://([\w\-]+\.([\w\-]+\.)*[\w]+(:[0-9]+)?(/[^ \"\n\r\t<]*)?)#i", 'Es wurde versucht eine URL zu posten', $ret); 

      // matches a "www|ftp.xxxx.yyyy[/zzzz]" kinda lazy URL thing 
      // Must contain at least 2 dots. xxxx contains either alphanum, or "-" 
      // zzzz is optional.. will contain everything up to the first space, newline, 
      // comma, double quote or <. 
      $ret = preg_replace("#([\t\r\n ])(www|ftp)\.(([\w\-]+\.)*[\w]+(:[0-9]+)?(/[^ \"\n\r\t<]*)?)#i", 'Es wurde versucht eine URL zu posten', $ret); 
    
      // matches an email@domain type address at the start of a line, or after a space. 
      // Note: Only the followed chars are valid; alphanums, "-", "_" and or ".". 
      $ret = preg_replace("#([\n ])([a-z0-9\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)*[\w]+)#i", "\\1<a href=\"mailto:\\2@\\3\">\\2@\\3</a>", $ret); 

      // Remove our padding.. 
      $ret = substr($ret, 1); 
    
      return($ret); 
}
email werden aber trotzdem klickbar gemacht...

ah

Verfasst: 20.03.2003 15:08
von Syco23
Sorry, aber ich seh da absout keinen Unterschied..

Verfasst: 21.03.2003 15:24
von saerdnaer
oh.. da hab ich was vegessen... beitrag editert...

ah

Verfasst: 21.03.2003 20:32
von Syco23
ah super, danke :D

werd ich gleich testen.

Verfasst: 21.03.2003 20:56
von Syco23
o.k. ohne Kommentar.. keine Ahunge was diese Mysteriöse Programmiersprache da jez macht:

Test1:
Ergebnis:
gojhjkglEs wurde versucht eine URL zu posten
Es wurde versucht eine URL zu posten
Test2:
Erbegnis:
s wurde versucht eine URL zu posten
Es wurde versucht eine URL zu posten
:o Code habe ich Exakt Kopiert wie du ihn gepostet hast..

Verfasst: 23.03.2003 15:47
von saerdnaer
warum passt doch... oder meinst du das mit den leerzeichen?

ah