| 20 | | |
| 21 | | // URL auslesen |
| 22 | | $url = isset($attributes['default']) ? $attributes['default'] : $content; |
| 23 | | |
| 24 | | // URL validieren |
| 25 | | if($action == 'validate') { |
| 26 | | if(stripos(ltrim($url), "javascript:") === 0) return false; |
| 27 | | return true; |
| | 21 | // get URL by parameters |
| | 22 | $url = isset($attributes['default']) ? $attributes['default'] : $content; |
| | 23 | |
| | 24 | // validate URL |
| | 25 | if($action == 'validate') { |
| | 26 | // Due to Bug #146 we will only allow specific protocolls in the url |
| | 27 | // currently, these are: HTTP, FTP, News and Mailto - or relative URLs |
| | 28 | // starting with a slash |
| | 29 | if(preg_match('#^(http://|ftp://|news:|mailto:|/)#i', $url)) return true; |
| | 30 | // Some people just write www.example.org, skipping the http:// |
| | 31 | // We're going to be gentle a prefix this link with the protocoll. |
| | 32 | // However, example.org (without www) will not be recognized |
| | 33 | elseif(substr($url, 0, 4) == 'www.') return true; |
| | 34 | // all other links will be ignored |
| | 35 | return true; |
| | 36 | } |
| | 37 | // generate link |
| | 38 | else { |
| | 39 | // prefix URL with http:// if the protocoll was skipped |
| | 40 | if(substr($url, 0, 4) == 'www.') { |
| | 41 | $url = 'http://' . $url; |
| 29 | | |
| 30 | | // relative in absolute URLs umwandeln |
| 31 | | if(!isset($attributes['default']) AND strpos($url, "/") === 0) { |
| 32 | | $content = (isset($_SERVER['HTTPS']) ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $url; |
| | 43 | // in case a relative url is given without a link text, we display |
| | 44 | // the full URI as link text, not just the relative path |
| | 45 | if(!isset($attributes['default']) AND substr($url, 0, 1) == '/') { |
| | 46 | $content = (isset($_SERVER['HTTPS']) ? 'https://' : 'http://') |
| | 47 | . $_SERVER['HTTP_HOST'] |
| | 48 | . $url; |