Subversion-Projekte lars-tiefland.ci

Revision

Revision 68 | Revision 2049 | Zur aktuellen Revision | Ganze Datei anzeigen | Leerzeichen ignorieren | Details | Blame | Letzte Änderung | Log anzeigen | RSS feed

Revision 68 Revision 1257
Zeile 1081... Zeile 1081...
1081
		if (filesize($file) == 0)
1081
		if (filesize($file) == 0)
1082
		{
1082
		{
1083
			return FALSE;
1083
			return FALSE;
1084
		}
1084
		}
Zeile 1085... Zeile 1085...
1085
 
1085
 
1086
		if (memory_get_usage() && ($memory_limit = ini_get('memory_limit')))
1086
		if (memory_get_usage() && ($memory_limit = ini_get('memory_limit')) > 0)
-
 
1087
		{
1087
		{
1088
			$memory_limit = str_split($memory_limit, strspn($memory_limit, '1234567890'));
1088
			$memory_limit *= 1024 * 1024;
1089
			if ( ! empty($memory_limit[1]))
1089
 
1090
			{
-
 
1091
				switch ($memory_limit[1][0])
-
 
1092
				{
-
 
1093
					case 'g':
1090
			// There was a bug/behavioural change in PHP 5.2, where numbers over one million get output
1094
					case 'G':
-
 
1095
						$memory_limit[0] *= 1024 * 1024 * 1024;
-
 
1096
						break;
-
 
1097
					case 'm':
1091
			// into scientific notation. number_format() ensures this number is an integer
1098
					case 'M':
-
 
1099
						$memory_limit[0] *= 1024 * 1024;
-
 
1100
						break;
-
 
1101
					default:
-
 
1102
						break;
1092
			// http://bugs.php.net/bug.php?id=43053
1103
				}
1093
 
-
 
Zeile -... Zeile 1104...
-
 
1104
			}
1094
			$memory_limit = number_format(ceil(filesize($file) + $memory_limit), 0, '.', '');
1105
 
1095
 
1106
			$memory_limit = (int) ceil(filesize($file) + $memory_limit[0]);
Zeile 1096... Zeile 1107...
1096
			ini_set('memory_limit', $memory_limit); // When an integer is used, the value is measured in bytes. - PHP.net
1107
			ini_set('memory_limit', $memory_limit); // When an integer is used, the value is measured in bytes. - PHP.net
1097
		}
1108
		}
Zeile 1205... Zeile 1216...
1205
	protected function _file_mime_type($file)
1216
	protected function _file_mime_type($file)
1206
	{
1217
	{
1207
		// We'll need this to validate the MIME info string (e.g. text/plain; charset=us-ascii)
1218
		// We'll need this to validate the MIME info string (e.g. text/plain; charset=us-ascii)
1208
		$regexp = '/^([a-z\-]+\/[a-z0-9\-\.\+]+)(;\s.+)?$/';
1219
		$regexp = '/^([a-z\-]+\/[a-z0-9\-\.\+]+)(;\s.+)?$/';
Zeile 1209... Zeile 1220...
1209
 
1220
 
1210
		/* Fileinfo extension - most reliable method
-
 
1211
		 *
1221
		// Fileinfo extension - most reliable method
1212
		 * Unfortunately, prior to PHP 5.3 - it's only available as a PECL extension and the
1222
		$finfo = @finfo_open(FILEINFO_MIME);
1213
		 * more convenient FILEINFO_MIME_TYPE flag doesn't exist.
1223
		if (is_resource($finfo)) // It is possible that a FALSE value is returned, if there is no magic MIME database file found on the system
-
 
1224
		{
1214
		 */
1225
			$mime = @finfo_file($finfo, $file['tmp_name']);
1215
		if (function_exists('finfo_file'))
1226
			finfo_close($finfo);
-
 
1227
 
1216
		{
1228
			/* According to the comments section of the PHP manual page,
1217
			$finfo = @finfo_open(FILEINFO_MIME);
1229
			 * it is possible that this function returns an empty string
-
 
1230
			 * for some files (e.g. if they don't exist in the magic MIME database)
-
 
1231
			 */
1218
			if (is_resource($finfo)) // It is possible that a FALSE value is returned, if there is no magic MIME database file found on the system
1232
			if (is_string($mime) && preg_match($regexp, $mime, $matches))
1219
			{
-
 
1220
				$mime = @finfo_file($finfo, $file['tmp_name']);
-
 
1221
				finfo_close($finfo);
-
 
1222
 
-
 
1223
				/* According to the comments section of the PHP manual page,
-
 
1224
				 * it is possible that this function returns an empty string
-
 
1225
				 * for some files (e.g. if they don't exist in the magic MIME database)
-
 
1226
				 */
-
 
1227
				if (is_string($mime) && preg_match($regexp, $mime, $matches))
-
 
1228
				{
1233
			{
1229
					$this->file_type = $matches[1];
1234
				$this->file_type = $matches[1];
1230
					return;
-
 
1231
				}
1235
				return;
1232
			}
1236
			}
Zeile 1233... Zeile 1237...
1233
		}
1237
		}
1234
 
1238