$val ) { $lcaseHtmlExtensions[$key] = strtolower( $val ) ; } return in_array( $ext, $lcaseHtmlExtensions ) ; } /** * Detect HTML in the first KB to prevent against potential security issue with * IE/Safari/Opera file type auto detection bug. * Returns true if file contain insecure HTML code at the beginning. * * @param string $filePath absolute path to file * @return boolean */ function DetectHtml( $filePath ) { $fp = @fopen( $filePath, 'rb' ) ; //open_basedir restriction, see #1906 if ( $fp === false || !flock( $fp, LOCK_SH ) ) { return -1 ; } $chunk = fread( $fp, 1024 ) ; flock( $fp, LOCK_UN ) ; fclose( $fp ) ; $chunk = strtolower( $chunk ) ; if (!$chunk) { return false ; } $chunk = trim( $chunk ) ; if ( preg_match( "/= 4.0.7 if ( function_exists( 'version_compare' ) ) { $sCurrentVersion = phpversion(); if ( version_compare( $sCurrentVersion, "4.2.0" ) >= 0 ) { $imageCheckExtensions[] = "tiff"; $imageCheckExtensions[] = "tif"; } if ( version_compare( $sCurrentVersion, "4.3.0" ) >= 0 ) { $imageCheckExtensions[] = "swc"; } if ( version_compare( $sCurrentVersion, "4.3.2" ) >= 0 ) { $imageCheckExtensions[] = "jpc"; $imageCheckExtensions[] = "jp2"; $imageCheckExtensions[] = "jpx"; $imageCheckExtensions[] = "jb2"; $imageCheckExtensions[] = "xbm"; $imageCheckExtensions[] = "wbmp"; } } if ( !in_array( $extension, $imageCheckExtensions ) ) { return true; } if ( @getimagesize( $filePath ) === false ) { return false ; } return true; } //$Config['isWinStyle'] //$Config['osWindows'] function folder_as_entities($path, $type="abs") { global $Config; if($path == '/') return $path; $filetypes = "(file|image|flash|media)(?!\w)"; if(!preg_match("#$filetypes#", $path, $matches)) { return $path; } $file_type = $matches[1]; if($Config['isWinStyle'] || $Config['osWindows']) { $pat = preg_quote(DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . 'media' . DIRECTORY_SEPARATOR) . '$'; if(preg_match("#$pat#", $path)) { return $path; } } $path = urldecode($path); $path_type['abs'] = 'UserFilesAbsolutePath'; $path_type['url'] = 'UserFilesPath'; $len = strlen($Config[$path_type[$type]]); $rest = substr($path, $len); $rest = preg_replace("#$filetypes#","",$rest); $rest = trim($rest,'\\/'); $folders = preg_split("#[/\\\\]#", $rest); for($i=0; $i < count($folders); $i++) { $folders[$i] = urlencode($folders[$i]); } $path = implode('/', $folders) ; if(isset($file_type) && $file_type != 'image') { if(preg_match('/(file|media|flash)/', $file_type)) { $return_path = $Config[$path_type[$type]] ."$file_type/$path" . '/'; $fname = "other.txt"; } } else { $return_path = $Config[$path_type[$type]] .'image/' . $path . '/'; $fname = "img.txt"; } $return_path = rtrim($return_path, '\\,/') . DIRECTORY_SEPARATOR; // file_put_contents($fname,$return_path); return $return_path; } function util_debug($data) { $handle = fopen('util.dbg', 'a'); fwrite($handle, $data . "\n"); fclose ($handle); } ?>