» Quick Links
You can make money on these forums
We Share profits with you
Google
Google Adsense
Google Adwords
YPN
Yahoo
MSN Search
Web Directories
Web Hosting
Web Hosting Offers
Hosting News
Suggestions
Link Building
Domain Names
PHP Forums
MySQL Forums
» More Links
OSP News
Reseller Hosting
Shared Hosting
Dedicated Servers
Google Adsense
Search Engine Marketing
Link Development
Affiliate Marketing


» Advertising
Multiple DC PR Check

Free SEO Tools


Go Back   Webmaster Forums > Website Developement / Programming > PHP Programming and Tips

PHP Programming and Tips Discuss about PHP programming and Share Tips. Ask questions about Scripting and Errors.

Reply
 
Thread Tools Display Modes
  #1  
Old 12-08-2005, 03:51 AM
carri carri is offline
OSP Starters
 
Join Date: Dec 2005
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
carri is on a distinguished road
Default File is binary in PHP 4+ min ??

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 --
Reply With Quote
Revenue Sharing Ads ( ?):
  #2  
Old 12-08-2005, 05:08 AM
Deur Deur is offline
OSP Starters
 
Join Date: Dec 2005
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
Deur is on a distinguished road
Default ASCII files are binary

Well, ASCII files are binary. All files are binary. It's in the nature of files to be binary.

If you're wanting to identify when a file contains only ASCII characters, all ASCII bytes are <0x80. That includes the control characters <0x20 (particularly HT, LF, CR, but also includes BEL, NUL, and others). If you want to allow those, then the character class would be
Code:
[\x09\x0d\x10\x20-\x7f]Any character that doesn't match that (i.e. matches
Code:
[^\x09\x0d\x10\x20-\x7f]would indicate that the file it's in is not ASCII (by these criteria). -- This message may have been cut off and the rest will only be shown to members. To become a member, click here --
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Free File Storage Hosts vishnuthegreat Domains For Sale - Fixed Price/Offer 1 03-06-2007 08:31 AM
limiting binary log file size! Portter MySQL Forums 1 08-21-2006 04:22 AM
wanna execute php in a file like test.jpg. savy PHP Programming and Tips 2 06-07-2006 02:18 PM
Optimising Database using PHP file lardy PHP Programming and Tips 0 12-07-2005 07:24 AM
include asp file in php moneymachine PHP Programming and Tips 1 12-05-2005 07:55 AM


All times are GMT. The time now is 11:58 PM.