コード例 #1
0
ファイル: filesystemstorage.php プロジェクト: Jobar87/fabrik
	/**
	 * Get file info using getid3
	 * @param $filepath
	 * return array
	 */
	function getFileInfo($filepath) {
		if ($this->exists($filepath)) {
			// $$$ hugh - turn of E_DEPRECATED to avoid warnings about eregi() in getid3
			// LOL!  E_DEPRECATED only available in 5.3.0+, pitches Notice in anything earlier.  :)
			if (version_compare(PHP_VERSION, '5.3.0') >= 0) {
				$current_level = error_reporting();
	    		error_reporting($current_level & ~E_DEPRECATED);
			}
	    	/*
			require_once(COM_FABRIK_FRONTEND.DS.'libs'.DS.'getid3'.DS.'getid3'.DS.'getid3.php');
			require_once(COM_FABRIK_FRONTEND.DS.'libs'.DS.'getid3'.DS.'getid3'.DS.'getid3.lib.php');

			getid3_lib::IncludeDependency(COM_FABRIK_FRONTEND.DS.'libs'.DS.'getid3'.DS.'getid3'.DS.'extension.cache.mysql.php', __FILE__, true);
			$config =& JFactory::getConfig();
			$host =  $config->getValue('host');
			$database = $config->getValue('db');
			$username = $config->getValue('user');
			$password = $config->getValue('password');
			$getID3 = new getID3_cached_mysql($host, $database, $username, $password);
			$getID3->encoding = 'UTF-8';
			// Analyze file and store returned data in $ThisFileInfo
			$thisFileInfo = $getID3->analyze($filepath);
			*/
			require_once(COM_FABRIK_FRONTEND.DS.'libs'.DS.'phpmimetypeclass'.DS.'class.mime.php');
			$mime = new MIMETypes();
			$thisFileInfo['filesize'] = filesize($filepath);
			$thisFileInfo['filename'] = basename($filepath);
			$thisFileInfo['mime_type'] = $mime->getMimeType($filepath);
			return $thisFileInfo;
		}
		else {
			return false;
		}
	}
コード例 #2
0
ファイル: index.php プロジェクト: spikedviper/FlightGeoIP
Flight::map('getStaticFile', function ($req_path) {
    $req_path = parse_url($req_path, PHP_URL_PATH);
    $filepath = Flight::get('flight.static.path') . $req_path;
    // sometimes relative to root not folder
    if (!realpath($filepath)) {
        $server_path = realpath($_SERVER['DOCUMENT_ROOT']);
        $this_path = realpath(dirname(__FILE__));
        if (strlen($this_path) > strlen($server_path)) {
            $tmp = substr($this_path, strlen($server_path));
            $filepath = Flight::get('flight.static.path') . substr($req_path, strlen($tmp));
        }
    }
    if (file_exists($filepath)) {
        // we don't need MIME id until we need it
        require_once 'includes/phpmimetypeclass-2010-10-19/class.mime.php';
        $mime = new MIMETypes('includes/phpmimetypeclass-2010-10-19/class.types.php');
        $mimetype = $mime->getMimeType($filepath);
        header("Content-Type: {$mimetype}", true);
        readfile($filepath);
    } else {
        // 404 it
        Flight::notFound();
    }
});
/**
 * checkIP
 * Checks the ip of the request for geolocation
 * information, if none is found the information is requested.
 * @param [string] $ip - request IP
 */
Flight::map('checkIP', function ($ip) {
コード例 #3
0
 /**
  * Get file info using getid3
  *
  * @param   string  $filepath  file path
  *
  * @return mixed array|false
  */
 public function getFileInfo($filepath)
 {
     // Suppress notice if open base_dir in effect
     if (!@$this->exists($filepath)) {
         $filepath = $this->getFullPath($filepath);
     }
     $filepath = JPath::clean($filepath);
     if ($this->exists($filepath)) {
         // $$$ hugh - turn of E_DEPRECATED to avoid warnings about eregi() in getid3
         // LOL!  E_DEPRECATED only available in 5.3.0+, pitches Notice in anything earlier.  :)
         if (version_compare(PHP_VERSION, '5.3.0') >= 0) {
             $current_level = error_reporting();
             error_reporting($current_level & ~E_DEPRECATED);
         }
         require_once COM_FABRIK_FRONTEND . '/libs/phpmimetypeclass/class.mime.php';
         $mime = new MIMETypes();
         $thisFileInfo['filesize'] = filesize($filepath);
         $thisFileInfo['filename'] = basename($filepath);
         $thisFileInfo['mime_type'] = $mime->getMimeType($filepath);
         return $thisFileInfo;
     } else {
         return false;
     }
 }
コード例 #4
0
ファイル: example.php プロジェクト: spikedviper/FlightGeoIP
# Set the directory to show files in
$dir = ".";
if (is_dir($dir)) {
    if ($dh = opendir($dir)) {
        $buffer = '
<table width="100%" cellspacing="5" cellpadding="5" border="0">
<tr>
  <td><strong><u>File Name</u></strong></td>
  <td><strong><u>File Size</u></strong></td>
  <td><strong><u>File Type</u></strong></td>
</tr>';
        # Define some variables
        $totalSizes = 0;
        $totalFiles = 0;
        # Define the MIME Type class object
        $mime = new MIMETypes();
        while (($file = readdir($dh)) !== false) {
            # Check to see if the file isn't a directory
            if ($file != "." && $file != ".." && is_file($file) && !is_dir($file)) {
                # Increment total number of files
                $totalFiles++;
                # Increment total file sizes (combined file sizes)
                $totalSizes += filesize($file);
                $buffer .= '
<tr>
  <td>' . $file . '</td>
  <td>' . filesize($file) . ' bytes</td>
  <td>' . $mime->getMimeType($file) . '</td>
</tr>
';
            }
コード例 #5
0
 /**
  * Get the MIME Type for the specified filename.
  * 
  * @param string $filename
  * @return string
  * @access public
  * @since 10/20/04
  */
 function getMIMETypeForFileName($filename)
 {
     // If we have an extension, sniff for it.
     if (preg_match("/.+\\.([^\\.]+)/", $filename, $parts)) {
         $extension = $parts[1];
         return MIMETypes::getMIMETypeForExtension($extension);
     } else {
         return "application/octet-stream";
     }
 }
コード例 #6
0
 /**
  * Determines MIME type
  * @static
  * @param string Filename
  * @return string MIME type
  */
 private static function determineMime($source, $filename = '')
 {
     $getID3 = new getID3();
     $fileInfo = $getID3->analyze($source);
     if (!empty($fileInfo['mime_type'])) {
         return $fileInfo['mime_type'];
     }
     $ext = '';
     if (!empty($filename)) {
         $ext = File::getExtension($filename);
     }
     return MIMETypes::getMIME($ext);
 }