<?php/********************************************************************************************
* BlueShoes Framework; This file is part of the php application framework.
* NOTE: This code is stripped (obfuscated). To get the clean documented code goto 
*       www.blueshoes.org and register for the free open source *DEVELOPER* version or 
*       buy the commercial version.
*       
*       In case you've already got the developer version, then this is one of the few 
*       packages/classes that is only available to *PAYING* customers.
*       To get it go to www.blueshoes.org and buy a commercial version.
* 
* @copyright www.blueshoes.org
* @author    Samuel Blume <sam at blueshoes dot org>
* @author    Andrej Arn <andrej at blueshoes dot org>
*/?><?php 
define('BS_FILEUTIL_VERSION',   '4.5.$Revision: 1.3 $');if (!@$APP) require_once($_SERVER['DOCUMENT_ROOT'] . $GLOBALS['APP']['path']['diffFromDocRootToGlobalConf'] . 'global.conf.php');require_once($APP['path']['core'] . 'util/Bs_System.class.php');require_once($APP['path']['core'] . 'file/Bs_Dir.class.php');class Bs_FileUtil extends Bs_Object {function Bs_FileUtil() {parent::Bs_Object();$this->_Bs_System = &$GLOBALS['Bs_System'];}
function encodeFilename($filename, $e='_') {$replFrom = array($e,    "\\r",  "\r",   "\\n",  "\n",   ' ',    "\\t",  "\t",   '/',    'Ä',     'Ö',     'Ü',    'ä',     'ö',     'ü',     "\\");$replTo   = array($e.$e, $e.'r', $e.'r', $e.'n', $e.'n', $e.'e', $e.'t', $e.'t', $e.'s', $e.'AE', $e.'OE', $e.'UE', $e.'ae', $e.'oe', $e.'ue', $e.'b');$filename = str_replace($replFrom, $replTo, $filename);$ret      = '';for ($i=0; $i<strlen($filename); $i++) {if ($filename[$i] == $e) {$ret .= $filename[$i];continue;}
$ord = ord($filename[$i]);if (($ord < 48) || ($ord > 122) || (($ord > 57) && ($ord < 65)) || (($ord > 90) && ($ord < 97))) {if ($ord < 10) {$ret .= $e . '00' . $ord;} elseif ($ord < 100) {$ret .= $e . '0' . $ord;} else {$ret .= $e . $ord;}
} else {$ret .= $filename[$i];}
}
return $ret;}
function decodeFilename($filename, $e='_') {$ret = '';for ($i=0; $i<strlen($filename); $i++) {if ($filename[$i] == $e) {$chr = substr($filename, $i+1, 3);if (is_numeric($chr)) {$ret .= chr($chr);$i += 3;} else {$ret .= $filename[$i];}
} else {$ret .= $filename[$i];}
}
$replFrom = array($e.$e, $e.'r', $e.'n', $e.'e', $e.'t', $e.'s', $e.'b', $e.'AE', $e.'OE', $e.'UE', $e.'ae', $e.'oe', $e.'ue');$replTo   = array($e,    "\r",   "\n",   ' ',    "\t",   '/',    "\\",   'Ä',     'Ö',     'Ü',     'ä',     'ö',     'ü');$ret      = str_replace($replFrom, $replTo, $ret);return $ret;}
function removeEmptyLines($fullPath) {$fileContent = @file($fullPath);if (!$fileContent) return FALSE;$new = '';while (list($k, $line) = each($fileContent)) {$line = str_replace("\r", "", $line);$line = str_replace("\n", "", $line);if (!empty($line)) $new .= $line . "\n";}
$fp = fopen ($fullPath, 'w');fputs($fp, $new);return TRUE;}
function countLinesFile($fullPath) {if (!is_file($fullPath)) return 0;if (!is_readable($fullPath)) return 0;$t = file($fullPath);return sizeOf($t);}
function countLinesDir($fullPath, $regExp=NULL, $recursive=FALSE) {$params = array();if (!is_null($regExp)) $params['regEx'] = $regExp;$d =& new Bs_Dir($fullPath);$fList = $d->getFileList($params);$lines = 0;while (list(,$fileFullPath) = each($fList)) {$lines += $this->countLinesFile($fileFullPath);}
return $lines;}
function getMimeType($param) {if (!isSet($mimeTypes)) {static $mimeTypes = array();$mimeTypes['ez'] = 'application/andrew-inset';$mimeTypes['hqx'] = 'application/mac-binhex40';$mimeTypes['cpt'] = 'application/mac-compactpro';$mimeTypes['doc'] = 'application/msword';$mimeTypes['bin'] = 'application/octet-stream';$mimeTypes['dms'] = 'application/octet-stream';$mimeTypes['lha'] = 'application/octet-stream';$mimeTypes['lzh'] = 'application/octet-stream';$mimeTypes['exe'] = 'application/octet-stream';$mimeTypes['class'] = 'application/octet-stream';$mimeTypes['oda'] = 'application/oda';$mimeTypes['pdf'] = 'application/pdf';$mimeTypes['ai'] = 'application/postscript';$mimeTypes['eps'] = 'application/postscript';$mimeTypes['ps'] = 'application/postscript';$mimeTypes['smi'] = 'application/smil';$mimeTypes['smil'] = 'application/smil';$mimeTypes['mif'] = 'application/vnd.mif';$mimeTypes['xls'] = 'application/vnd.ms-excel';$mimeTypes['ppt'] = 'application/vnd.ms-powerpoint';$mimeTypes['wbxml'] = 'application/vnd.wap.wbxml';$mimeTypes['wmlc'] = 'application/vnd.wap.wmlc';$mimeTypes['wmlsc'] = 'application/vnd.wap.wmlscriptc';$mimeTypes['bcpio'] = 'application/x-bcpio';$mimeTypes['vcd'] = 'application/x-cdlink';$mimeTypes['pgn'] = 'application/x-chess-pgn';$mimeTypes['cpio'] = 'application/x-cpio';$mimeTypes['csh'] = 'application/x-csh';$mimeTypes['dcr'] = 'application/x-director';$mimeTypes['dir'] = 'application/x-director';$mimeTypes['dxr'] = 'application/x-director';$mimeTypes['dvi'] = 'application/x-dvi';$mimeTypes['spl'] = 'application/x-futuresplash';$mimeTypes['gtar'] = 'application/x-gtar';$mimeTypes['hdf'] = 'application/x-hdf';$mimeTypes['js'] = 'application/x-javascript';$mimeTypes['skp'] = 'application/x-koan';$mimeTypes['skd'] = 'application/x-koan';$mimeTypes['skt'] = 'application/x-koan';$mimeTypes['skm'] = 'application/x-koan';$mimeTypes['latex'] = 'application/x-latex';$mimeTypes['nc'] = 'application/x-netcdf';$mimeTypes['cdf'] = 'application/x-netcdf';$mimeTypes['sh'] = 'application/x-sh';$mimeTypes['shar'] = 'application/x-shar';$mimeTypes['swf'] = 'application/x-shockwave-flash';$mimeTypes['sit'] = 'application/x-stuffit';$mimeTypes['sv4cpio'] = 'application/x-sv4cpio';$mimeTypes['sv4crc'] = 'application/x-sv4crc';$mimeTypes['tar'] = 'application/x-tar';$mimeTypes['tcl'] = 'application/x-tcl';$mimeTypes['tex'] = 'application/x-tex';$mimeTypes['texinfo'] = 'application/x-texinfo';$mimeTypes['texi'] = 'application/x-texinfo';$mimeTypes['t'] = 'application/x-troff';$mimeTypes['tr'] = 'application/x-troff';$mimeTypes['roff'] = 'application/x-troff';$mimeTypes['man'] = 'application/x-troff-man';$mimeTypes['me'] = 'application/x-troff-me';$mimeTypes['ms'] = 'application/x-troff-ms';$mimeTypes['ustar'] = 'application/x-ustar';$mimeTypes['src'] = 'application/x-wais-source';$mimeTypes['zip'] = 'application/zip';$mimeTypes['au'] = 'audio/basic';$mimeTypes['snd'] = 'audio/basic';$mimeTypes['mid'] = 'audio/midi';$mimeTypes['midi'] = 'audio/midi';$mimeTypes['kar'] = 'audio/midi';$mimeTypes['mpga'] = 'audio/mpeg';$mimeTypes['mp2'] = 'audio/mpeg';$mimeTypes['mp3'] = 'audio/mpeg';$mimeTypes['aif'] = 'audio/x-aiff';$mimeTypes['aiff'] = 'audio/x-aiff';$mimeTypes['aifc'] = 'audio/x-aiff';$mimeTypes['ram'] = 'audio/x-pn-realaudio';$mimeTypes['rm'] = 'audio/x-pn-realaudio';$mimeTypes['rpm'] = 'audio/x-pn-realaudio-plugin';$mimeTypes['ra'] = 'audio/x-realaudio';$mimeTypes['wav'] = 'audio/x-wav';$mimeTypes['pdb'] = 'chemical/x-pdb';$mimeTypes['xyz'] = 'chemical/x-xyz';$mimeTypes['bmp'] = 'image/bmp';$mimeTypes['gif'] = 'image/gif';$mimeTypes['ief'] = 'image/ief';$mimeTypes['jpeg'] = 'image/jpeg';$mimeTypes['jpg'] = 'image/jpeg';$mimeTypes['jpe'] = 'image/jpeg';$mimeTypes['png'] = 'image/png';$mimeTypes['tiff'] = 'image/tiff';$mimeTypes['tif'] = 'image/tiff';$mimeTypes['wbmp'] = 'image/vnd.wap.wbmp';$mimeTypes['ras'] = 'image/x-cmu-raster';$mimeTypes['pnm'] = 'image/x-portable-anymap';$mimeTypes['pbm'] = 'image/x-portable-bitmap';$mimeTypes['pgm'] = 'image/x-portable-graymap';$mimeTypes['ppm'] = 'image/x-portable-pixmap';$mimeTypes['rgb'] = 'image/x-rgb';$mimeTypes['xbm'] = 'image/x-xbitmap';$mimeTypes['xpm'] = 'image/x-xpixmap';$mimeTypes['xwd'] = 'image/x-xwindowdump';$mimeTypes['igs'] = 'model/iges';$mimeTypes['iges'] = 'model/iges';$mimeTypes['msh'] = 'model/mesh';$mimeTypes['mesh'] = 'model/mesh';$mimeTypes['silo'] = 'model/mesh';$mimeTypes['wrl'] = 'model/vrml';$mimeTypes['vrml'] = 'model/vrml';$mimeTypes['css'] = 'text/css';$mimeTypes['html'] = 'text/html';$mimeTypes['htm'] = 'text/html';$mimeTypes['asc'] = 'text/plain';$mimeTypes['txt'] = 'text/plain';$mimeTypes['rtx'] = 'text/richtext';$mimeTypes['rtf'] = 'text/rtf';$mimeTypes['sgml'] = 'text/sgml';$mimeTypes['sgm'] = 'text/sgml';$mimeTypes['tsv'] = 'text/tab-separated-values';$mimeTypes['wml'] = 'text/vnd.wap.wml';$mimeTypes['wmls'] = 'text/vnd.wap.wmlscript';$mimeTypes['etx'] = 'text/x-setext';$mimeTypes['xml'] = 'text/xml';$mimeTypes['mpeg'] = 'video/mpeg';$mimeTypes['mpg'] = 'video/mpeg';$mimeTypes['mpe'] = 'video/mpeg';$mimeTypes['qt'] = 'video/quicktime';$mimeTypes['mov'] = 'video/quicktime';$mimeTypes['avi'] = 'video/x-msvideo';$mimeTypes['movie'] = 'video/x-sgi-movie';$mimeTypes['ice'] = 'x-conference/x-cooltalk';}
if (isSet($mimeTypes[strToLower($param)])) return $mimeTypes[strToLower($param)];return FALSE;}
} $GLOBALS['Bs_FileUtil'] =& new Bs_FileUtil; ?>