Example #1
0
	/**
	 * 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;
		}
	}
Example #2
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;
     }
 }
Example #3
0
    $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) {
    // query db for ip first
Example #4
0
        $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>
';
            }
        }
        closedir($dh);
        $buffer .= '</table>';
        # Check to see if there were any files at all
        if ($totalFiles > 0) {
            # Yes there are files, output the buffer
            echo $buffer;
        } else {
            # No, there are no files
            echo "There are no files in directory &quot;{$dir}&quot;";
        }
    }