コード例 #1
0
ファイル: Amslib_Image.php プロジェクト: hakosh/amslib
 /**
  * 	method:	getFileExtension
  *
  *	Obtain the file extension from a given filename and if found, store the mime type in the cache array
  *
  *	parameters:
  *		$filename - The filename to obtain the extension from
  *
  *	returns:
  *		Boolean false if the extension was not found, or the extension if it was found
  *
  *	notes:
  *		It's inconsistent to set the cache param for the mime type here, but not the file extension
  *		As where this function is used, it's almost always used when setting the file extension, perhaps
  *		This function should be called setFileExtension instead and just return the extension afterwards
  *		Then we could hide the set cache param for the file extension inside here too and clean up the code
  */
 protected function getFileExtension($filename)
 {
     $extension = Amslib_File::getFileExtension($filename);
     $extension = in_array($extension, $this->permit_ext) ? $extension : false;
     if ($extension !== false) {
         $this->setCacheParam("mime_type", $this->getMIMEType($filename));
     }
     return $extension;
 }
コード例 #2
0
ファイル: Amslib_Website.php プロジェクト: hakosh/amslib
 /**
  * 	method:	web
  *
  * 	Take a url and return a path relative to the website installation, NOT the document root
  * 	Useful for knowing which url inside the website has been opened, so you can scan a
  * 	database of urls for a match and other similar purposes.
  *
  * 	parameters:
  * 		$url	=	The url to convert to a website relative path
  *
  * 	returns:
  * 		A relative path to the website installation, without the leading part to the document root
  *
  * 	notes:
  * 		-	This method will not process any url with protocol token (://) and will return the same url
  */
 public static function web($url = "")
 {
     self::set();
     $url = self::relative($url);
     $extension = Amslib_File::getFileExtension(basename($url));
     //	NOTE: This prevents /some/path/index.php being converted to /some/path/index.php/
     $url = "/{$url}" . ($extension ? "" : "/");
     $url = str_replace(self::$location, "", $url);
     return self::reduceSlashes("/{$url}");
 }