From: Steve Sutton Date: Wed, 10 Feb 2010 21:51:41 +0000 (+0000) Subject: update for short url validation X-Git-Tag: v1.0.0~71 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=22b7a28885feeeb258caed0ea2997b9f039f2c09;p=web%2FTroutCreek.git update for short url validation --- diff --git a/Toolkit/ShortURL.php b/Toolkit/ShortURL.php index 7189021..14c622a 100755 --- a/Toolkit/ShortURL.php +++ b/Toolkit/ShortURL.php @@ -123,5 +123,38 @@ class Toolkit_ShortURL } // }}} + // {{{ isValidUrlName() + /** + * check the short url nam eto make sure it doesn't match any file names in the root + * + * @param mixed $url requested short url name + * + * @access public + * @return string + */ + public function isValidUrlName($url) + { + if (is_dir(BASE)) { + if (file_exists(BASE . $url)) { + return false; + } + if (file_exists(BASE . $url.'.php')) { + return false; + } + if (file_exists(BASE . $url.'.css')) { + return false; + } + if (file_exists(BASE . $url.'.html')) { + return false; + } + if (file_exists(BASE . $url.'.js')) { + return false; + } + return true; + } else { + throw new Exception('Main Web root dir define BASE not set'); + } + } + // }}} } ?>