+ } else {
+ // Maybe deleted?
+ $admin = "<div class=\"admin_note\">".sprintf(getMessage('ADMIN_ID_404'), $aid)."</div>";
+ }
+ } // END - if
+
+ // Return result
+ return $admin;
+}
+
+// Compile characters which are allowed in URLs
+function compileUriCode ($code, $simple = true) {
+ // Compile constants
+ if (!$simple) $code = str_replace('{--', '".', str_replace('--}', '."', $code));
+
+ // Compile QUOT and other non-HTML codes
+ $code = str_replace('{DOT}', '.',
+ str_replace('{SLASH}', '/',
+ str_replace('{QUOT}', "'",
+ str_replace('{DOLLAR}', '$',
+ str_replace('{OPEN_ANCHOR}', '(',
+ str_replace('{CLOSE_ANCHOR}', ')',
+ str_replace('{OPEN_SQR}', '[',
+ str_replace('{CLOSE_SQR}', ']',
+ str_replace('{PER}', '%',
+ $code
+ )))))))));
+
+ // Return compiled code
+ return $code;
+}
+
+// Function taken from user comments on www.php.net / function eregi()
+function isUrlValidSimple ($url) {
+ // Prepare URL
+ $url = strip_tags(str_replace("\\", '', COMPILE_CODE(urldecode($url))));
+
+ // Allows http and https
+ $http = "(http|https)+(:\/\/)";
+ // Test domain
+ $domain1 = "([[:alnum:]]([-[:alnum:]])*\.)?([[:alnum:]][-[:alnum:]\.]*[[:alnum:]])(\.[[:alpha:]]{2,5})?";
+ // Test double-domains (e.g. .de.vu)
+ $domain2 = "([-[:alnum:]])?(\.[[:alnum:]][-[:alnum:]\.]*[[:alnum:]])(\.[[:alpha:]]{2,5})(\.[[:alpha:]]{2,5})?";
+ // Test IP number
+ $ip = "([[:digit:]]{1,3})\.([[:digit:]]{1,3})\.([[:digit:]]{1,3})\.([[:digit:]]{1,3})";
+ // ... directory
+ $dir = "((/)+([-_\.[:alnum:]])+)*";
+ // ... page
+ $page = "/([-_[:alnum:]][-\._[:alnum:]]*\.[[:alnum:]]{2,5})?";
+ // ... and the string after and including question character
+ $getstring1 = "([\?/]([[:alnum:]][-\._%[:alnum:]]*(=)?([-\@\._:%[:alnum:]])+)(&([[:alnum:]]([-_%[:alnum:]])*(=)?([-\@\[\._:%[:alnum:]])+(\])*))*)?";
+ // Pattern for URLs like http://url/dir/doc.html?var=value
+ $pattern['d1dpg1'] = $http . $domain1 . $dir . $page . $getstring1;
+ $pattern['d2dpg1'] = $http . $domain2 . $dir . $page . $getstring1;
+ $pattern['ipdpg1'] = $http . $ip . $dir . $page . $getstring1;
+ // Pattern for URLs like http://url/dir/?var=value
+ $pattern['d1dg1'] = $http . $domain1 . $dir.'/' . $getstring1;
+ $pattern['d2dg1'] = $http . $domain2 . $dir.'/' . $getstring1;
+ $pattern['ipdg1'] = $http . $ip . $dir.'/' . $getstring1;
+ // Pattern for URLs like http://url/dir/page.ext
+ $pattern['d1dp'] = $http . $domain1 . $dir . $page;
+ $pattern['d1dp'] = $http . $domain2 . $dir . $page;
+ $pattern['ipdp'] = $http . $ip . $dir . $page;
+ // Pattern for URLs like http://url/dir
+ $pattern['d1d'] = $http . $domain1 . $dir;
+ $pattern['d2d'] = $http . $domain2 . $dir;
+ $pattern['ipd'] = $http . $ip . $dir;
+ // Pattern for URLs like http://url/?var=value
+ $pattern['d1g1'] = $http . $domain1 . '/' . $getstring1;
+ $pattern['d2g1'] = $http . $domain2 . '/' . $getstring1;
+ $pattern['ipg1'] = $http . $ip . '/' . $getstring1;
+ // Pattern for URLs like http://url?var=value
+ $pattern['d1g12'] = $http . $domain1 . $getstring1;
+ $pattern['d2g12'] = $http . $domain2 . $getstring1;
+ $pattern['ipg12'] = $http . $ip . $getstring1;
+ // Test all patterns
+ $reg = false;
+ foreach ($pattern as $key => $pat) {
+ // Debug regex?
+ if (isDebugRegExpressionEnabled()) {
+ // @TODO Are these convertions still required?
+ $pat = str_replace('.', "\.", $pat);
+ $pat = str_replace('@', "\@", $pat);
+ echo $key."= " . $pat . "<br />";