#1 6. September 2008 Zuletzt von einem Moderator bearbeitet: 15. April 2017 hi ich hab mir das mal angesehen und auch so eingebaut wie es in diesem thread beschrieben ist WBB und externe Links - RR:Board nun meine frage ist wie muss ich das umändern das davon nur externe links betroffen sind also mit irgendeinem ausnahmecode oder sowas wenn wir jetzt das board hier hernehmen das alle links die mit http://board.raidrush anfangen nicht umgeleitet werden. hoffe es ist noch verständlich was ich will. wäre echt super wenn mir dabei wer behilflich sein kann + Multi-Zitat Zitieren
#2 6. September 2008 AW: externe links im wbb so, hab dir mal die funktion erweitert PHP: function formaturl ( $url , $title = '' , $maxwidth = 60 , $width1 = 40 , $width2 = - 15 ) { static $referer = 'http://anonym.to/?' ; static $except = array( array( 'host' => 'raidrush' , 'subdomain' => array( 'board' , 'toplist' ), 'tld' => 'ws' ), array( 'host' => 'google' , 'tld' => array( 'de' , 'com' ), 'scheme' => array( 'ftp' , 'http' ), 'file' => 'search' , 'query' => 'hl=de' ) ); if(! preg_match ( "/[a-z]:\/\//si" , $url )) $url = "http:// $url " ; if(! wbb_trim ( $title )) { $title = rehtmlconverter ( $url ); if( $this -> cuturls == 1 && wbb_strlen ( $title ) > $maxwidth ) $title = wbb_substr ( $title , 0 , $width1 ). "..." . wbb_substr ( $title , $width2 ); $link = array( 'url' => $url , 'title' => htmlconverter ( $this -> stripSlashes ( $title ))); } else $link = array( 'url' => $url , 'title' => $title ); //$split = parse_url($link['url']); $split = array(); $ipPattern = '(?:[0-9]{1,3}+\.){3}+[0-9]{1,3}' ; //ip syntax $domainPattern = '((?P<subdomain>[-\w\.]+)\.)?(?P<domain>[-\w]+)\.(?P<tld>\w+)' ; //do.ma.in syntax //add interal url to $except $host = getEnv ( 'HTTP_HOST' ); $addReferer = ( $host != 'localhost' && $host != '127.0.0.1' ); if( preg_match ( '~' . $ipPattern . '~' , $host )) { $except [] = array( 'host' => $host ); } else { $host = explode ( '.' , $host ); $count = count ( $host ); if( $count == 2 ) $except [] = array( 'host' => $host [ 0 ], 'tld' => $host [ 1 ]); else { $subdomain = $host [ 0 ]; unset( $host [ 0 ]); if( count ( $host ) > 2 ) { $first = 1 ; while( count ( $host ) > 2 ) { $subdomain .= $host [ $first ]; unset( $host [ $first ]); $first ++; } } list( $domain , $tld ) = $host ; $except [] = array( 'subdomain' => $subdomain , 'host' => $domain , 'tld' => $tld ); } } //split url preg_match ( '~^ #scheme (?:(?P<scheme>\w+)://)? #login (?:(?P<login>\w+):(?P<pass>\w+)@)? #host [subdomain,domain,tld]|ip (?P<host>(?(?=' . $ipPattern . ') (?P<ip>' . $ipPattern . ') | (?:' . $domainPattern . ') )) #port (?::(?P<port>\d+))? #path (?P<path>[\w/]*/(?P<file>\w+(?:\.\w+)?)?)? #query (?:\?(?P<query>[\w=&]+))? #anchor (?:\#(?P<anchor>\w+))? ~x' , $link [ 'url' ], $split ); foreach( $except as $e ) { $check = (!empty( $split [ 'ip' ])) ? 'ip' : 'domain' ; if(( is_array ( $e [ 'host' ]) && in_array ( $split [ $check ], $e [ 'host' ])) || ( is_string ( $e [ 'host' ]) && $split [ $check ] == $e [ 'host' ])) { //check domain if( $check == 'domain' ) { //check subdomain if(!empty( $e [ 'subdomain' ]) && (empty( $split [ 'subdomain' ]) || (( is_array ( $e [ 'subdomain' ]) && ! in_array ( $split [ 'subdomain' ], $e [ 'subdomain' ])) || ( is_string ( $e [ 'subdomain' ]) && $split [ 'subdomain' ] != $e [ 'subdomain' ])))) break; //check tld if(!empty( $e [ 'tld' ]) && ( is_array ( $e [ 'tld' ]) && ! in_array ( $split [ 'tld' ], $e [ 'tld' ])) || ( is_string ( $e [ 'tld' ]) && $split [ 'tld' ] != $e [ 'tld' ])) break; } //check scheme if(isset( $e [ 'scheme' ]) && (( is_array ( $e [ 'scheme' ]) && ! in_array ( $split [ 'scheme' ], $e [ 'scheme' ])) || ( is_string ( $e [ 'scheme' ]) && $split [ 'scheme' ] != $e [ 'scheme' ]))) break; //check login $login = ((!empty( $split [ 'login' ])) ? $split [ 'login' ] : '' ) . ((!empty( $split [ 'pass' ])) ? $split [ 'pass' ] : '' ); if(!empty( $e [ 'login' ])) { if(empty( $login ) || (( is_array ( $e [ 'login' ]) && ! in_array ( $login , $e [ 'login' ])) || ( is_string ( $e [ 'login' ]) && $login != $e [ 'login' ]))) break; } //check port if(!empty( $e [ 'port' ])) { if(empty( $split [ 'port' ]) || (( is_array ( $e [ 'port' ]) && ! in_array ( $split [ 'port' ], $e [ 'port' ])) || ( is_string ( $e [ 'port' ]) && $split [ 'port' ] != $e [ 'port' ]))) break; } //check path if(!empty( $e [ 'path' ])) { if(empty( $split [ 'path' ]) || (( is_array ( $e [ 'path' ]) && ! in_array ( $split [ 'path' ], $e [ 'path' ])) || ( is_string ( $e [ 'path' ]) && $split [ 'path' ] != $e [ 'path' ]))) break; } //check file if(!empty( $e [ 'file' ])) { //empty file can be index too if(empty( $split [ 'file' ])) $split [ 'file' ] = 'index' ; if(( is_array ( $e [ 'file' ]) && ! in_array ( $split [ 'file' ], $e [ 'file' ])) || ( is_string ( $e [ 'file' ]) && $split [ 'file' ] != $e [ 'file' ])) break; } //validate query-string if(!empty( $e [ 'query' ])) { if(empty( $split [ 'query' ])) break; if( is_array ( $e [ 'query' ])) { $matched = false ; foreach( $e [ 'query' ] as $q ) { if(@ preg_match ( '~' . $q . '~' , $split [ 'query' ])) { $matched = true ; break; } } if(! $matched ) break; } elseif(!@ preg_match ( '~' . $e [ 'query' ] . '~' , $split [ 'query' ])) break; } //check anchor (optional) if(!empty( $split [ 'anchor' ]) && !empty( $e [ 'anchor' ])) { if(( is_array ( $e [ 'anchor' ]) && ! in_array ( $split [ 'anchor' ], $e [ 'anchor' ])) || ( is_string ( $e [ 'anchor' ]) && $split [ 'anchor' ] != $e [ 'anchor' ])) break; } $addReferer = false ; break; } } return '<a href="' . (( $addReferer === true ) ? $referer . $link [ 'url' ] : $link [ 'url' ]) . '" target="_blank">' . $link [ 'title' ] . '</a>' ;} du kannst links auf - host (domainname oder ip), - subdomain, - scheme (http, https, ftp [...]), - tld (.de, .com [...]), - pfad (foo/bar/) - file (index.php) - query (/?blah=gnaa) *1, und anker (#blah) überprüfen *1) hier musst du reguläre ausdrücke verwenden deine eigene url is mit dabei. ps: 2 stunden dafür gebraucht! + Multi-Zitat Zitieren
#3 7. September 2008 AW: externe links im wbb Ich habe nur kurz über dein Snippet geschaut, aber was hast du, was parse_url fehlt? + Multi-Zitat Zitieren
#4 7. September 2008 AW: externe links im wbb kurz: subdomains und filename zusätzlich zum pfad + Multi-Zitat Zitieren
#5 7. September 2008 AW: externe links im wbb he vielen dank das du das so schnell gemacht hast für mich dann mach ich mich mal an die arbeit das ich das auch alles richtig einbaue vielen vielen dank nochmal für deine mühe + Multi-Zitat Zitieren