PHP Code:
if (!function_exists('is_binary')) {
/**
* Determine if a file is binary. Useful for doing file content editing
*
* @access public
* @param mixed $link Complete path to file (/path/to/file)
* @return boolean
* @see link user notes regarding this created function
*/
function is_binary($link) {
$tmpStr = '';
$fp = @fopen($link, 'rb');
$tmpStr = @fread($fp, 256);
@fclose($fp);
if ($tmpStr) {
$tmpStr = str_replace(chr(10), '', $tmpStr);
$tmpStr = str_replace(chr(13), '', $tmpStr);
$tmpInt = 0;
for ($i = 0; $i < strlen($tmpStr); $i++) {
if (extension_loaded('ctype')) {
if(!ctype_print($tmpStr[$i])) $tmpInt++;
} elseif (!eregi("[
-- This message may have been cut off and the rest will only be shown to members. To become a member, click here --