Home Private Messages Search
CPG Dragonfly™ CMS Dedicated Server & Bandwidth Sponsored by DedicatedNOW
Toggle Content
 
Forums ⇒ CMS (All) ⇒ CVS Info :: Archives ⇒ New function and remote avatar filesize :: Archived


New function and remote avatar filesize :: Archived
Global information regarding the state of our CVS and changes committed. Members are only allowed to reply to these topics.
Go to page 1, 2, 3, 4  Next
Post new topic    Revive this topic    Printer Friendly Page     Forum Index ⇒  CVS Info

Topic Archived View previous topic :: View next topic  
Author Message
DJ Maze
Developer
Developer

Offline Offline
Joined: Apr 19, 2004
Posts: 5683
Location: http://tinyurl.com/5z8dmv
PostPosted: Thu Oct 14, 2004 5:47 pm
Post subject: New function and remote avatar filesize

Ok as people liked the remote avatar check for dimension (widthxheight) it still lacked the ability to check filesize (bytes)

Also Trevor is building a new downloads module and also wanted to fetch remote filesize.

So i've created a new function get_fileinfo($url)
The function recieves the first 12 lines of a url and tries to fetch the size, type and filedate from those and return them into a array()

$file['size'] in bytes
$file['type'] like: image/jpeg or application/zip
$file['date'] like: Thu, 22 Apr 2004 18:54:07 GMT

This way the avatar system now also checks the remote avatar filesize


DJ Maze's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
Fedora 15 / 2.2.22 / 5.5.20 / 5.3.10 / CVS
Back to top
View user's profile Visit poster's website Yahoo Messenger Photo Gallery
Phoenix
• Many Posts •
• Many Posts •

Offline Offline
Joined: Apr 19, 2004
Posts: 8799
Location: Netizen
PostPosted: Thu Oct 14, 2004 5:51 pm
Post subject: Re: New function and remote avatar filesize

terrific - now, if you could just detect animated gifs........


Phoenix's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
Back to top
View user's profile Visit poster's website Photo Gallery
PerM
Dragonfly addicted
Dragonfly addicted

Offline Offline
Joined: Aug 07, 2004
Posts: 390
Location: Sweden
PostPosted: Fri Oct 15, 2004 11:41 am
Post subject: Re: New function and remote avatar filesize

Oh, very nice indeed.

Two questions:
Will the new download module hide the real URL to prevent direct linking? I.e. provide a link to a temporary file that gets deleted when the download is completed or the temporary fils os older that x hours/minutes?

The twelve lines...is that the result form the HTTP request you are talking about?


PerM's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
Back to top
View user's profile Visit poster's website ICQ Number
PerM
Dragonfly addicted
Dragonfly addicted

Offline Offline
Joined: Aug 07, 2004
Posts: 390
Location: Sweden
PostPosted: Fri Oct 15, 2004 11:42 am
Post subject: Re: New function and remote avatar filesize

Phoenix wrote:
terrific - now, if you could just detect animated gifs........

I guess this is possbile by looking at the raw image data. I'll try to dig something up on this.


PerM's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
Back to top
View user's profile Visit poster's website ICQ Number
DJ Maze
Developer
Developer

Offline Offline
Joined: Apr 19, 2004
Posts: 5683
Location: http://tinyurl.com/5z8dmv
PostPosted: Fri Oct 15, 2004 11:59 am
Post subject: Re: New function and remote avatar filesize

PerM wrote:
Oh, very nice indeed.

Two questions:
Will the new download module hide the real URL to prevent direct linking? I.e. provide a link to a temporary file that gets deleted when the download is completed or the temporary fils os older that x hours/minutes?

The twelve lines...is that the result form the HTTP request you are talking about?
Code::
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://cpgnuke.com/.*$     [NC]
RewriteCond %{HTTP_REFERER} !^http://cpgnuke.com$        [NC]
RewriteCond %{HTTP_REFERER} !^http://www.cpgnuke.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.cpgnuke.com$    [NC]
RewriteRule .*\.(jpg|jpeg|png|bmp|zip|rar)$ - [F,NC]

Yes, it does a HTTP GET request
If the request fails (ie returning something else then "HTMTL/1.x 200 OK") it returns false and throws a E_USER_WARNING error.


DJ Maze's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
Fedora 15 / 2.2.22 / 5.5.20 / 5.3.10 / CVS
Back to top
View user's profile Visit poster's website Yahoo Messenger Photo Gallery
PerM
Dragonfly addicted
Dragonfly addicted

Offline Offline
Joined: Aug 07, 2004
Posts: 390
Location: Sweden
PostPosted: Fri Oct 15, 2004 12:38 pm
Post subject: Re: New function and remote avatar filesize

A quick search on animimated gifs yields that it is quite easy to detect an animated gif. I haven't done any real coding in php yet, as side from a few bugfixes for CPGNuke, but I'll see what I can come up with.


PerM's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
Back to top
View user's profile Visit poster's website ICQ Number
djdevon3
Gold Supporter
Gold Supporter

Offline Offline
Joined: Aug 05, 2004
Posts: 4363

PostPosted: Fri Oct 15, 2004 7:05 pm
Post subject: Re: New function and remote avatar filesize

There are a two major formats of gifs. 87a and 89a. One of the two doesn't support animation I believe. They both show up in browsers as a .gif format. You guys are advanced coders so maybe this is the kind of info you could use.

www.danbbs.dk/~dino/wh...gif89.html


djdevon3's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
Linux/1.3.33/4.4/4.3.11
Back to top
View user's profile Visit poster's website Photo Gallery
DJ Maze
Developer
Developer

Offline Offline
Joined: Apr 19, 2004
Posts: 5683
Location: http://tinyurl.com/5z8dmv
PostPosted: Fri Oct 15, 2004 7:37 pm
Post subject: Re: New function and remote avatar filesize

Devon that document doesn't descibes animation properties, only
Quote::
The Graphics Interchange Format is not intended as a platform for animation, even though it can be done in a limited way.

And yes only 89a supports animation


DJ Maze's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
Fedora 15 / 2.2.22 / 5.5.20 / 5.3.10 / CVS
Back to top
View user's profile Visit poster's website Yahoo Messenger Photo Gallery
PerM
Dragonfly addicted
Dragonfly addicted

Offline Offline
Joined: Aug 07, 2004
Posts: 390
Location: Sweden
PostPosted: Fri Oct 15, 2004 8:10 pm
Post subject: Re: New function and remote avatar filesize

Yep, only 89a supports animations. It seem it'll be quite easy to determine if a gif image is animated or not. All that is needed is to search for the string "NETSCAPE2.0" in the raw data.

I've tested this on some .gif files and it seems to be accurate. Although, to be the 100% accurate it is of course needfull to actually read the data and process it -- there are 'static' animations that only show the first frame of an animation.

So if someone with better knowledge of php than me wants to write a code snippet that reads the raw .gif image data (from file and/or over the HTTP protocol), go ahead and do so. Just remember who said it first Big grin

Gif 89a Specifications
Sample of the animation structure


PerM's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
Back to top
View user's profile Visit poster's website ICQ Number
DJ Maze
Developer
Developer

Offline Offline
Joined: Apr 19, 2004
Posts: 5683
Location: http://tinyurl.com/5z8dmv
PostPosted: Fri Oct 15, 2004 8:23 pm
Post subject: Re: New function and remote avatar filesize

rolleyes.gif wrote:
removed see image below
All data is LZW compressed so it needs to be uncompressed and check how the image "loops"


DJ Maze's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
Fedora 15 / 2.2.22 / 5.5.20 / 5.3.10 / CVS


Last edited by DJ Maze on Fri Oct 15, 2004 10:33 pm; edited 1 time in total
Back to top
View user's profile Visit poster's website Yahoo Messenger Photo Gallery
DJ Maze
Developer
Developer

Offline Offline
Joined: Apr 19, 2004
Posts: 5683
Location: http://tinyurl.com/5z8dmv
PostPosted: Fri Oct 15, 2004 8:29 pm
Post subject: Re: New function and remote avatar filesize

you could ofcourse load the file fully and do
PHP:
if ($fileinfo = get_fileinfo($url)) {
if (
$fileinfo['type'] == 'image/gif') {
// get whole image using fsockopen() and feof()
if (ereg('NETSCAPE2.0', $file)) cpg_error('Image is animated');
}
}

GOOD LUCK !!!


DJ Maze's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
Fedora 15 / 2.2.22 / 5.5.20 / 5.3.10 / CVS
Back to top
View user's profile Visit poster's website Yahoo Messenger Photo Gallery
MrFatCat
Nice poster
Nice poster

Offline Offline
Joined: Oct 02, 2004
Posts: 51
Location: Chattanooga, TN
PostPosted: Fri Oct 15, 2004 8:34 pm
Post subject: Re: New function and remote avatar filesize

I think maybe the image seperator might be key to determining if the data stream has more than one image present.

Image Separator" wrote:

Identifies the beginning of an Image Descriptor. This field contains the fixed value 0x2C.

_________________
Are we having fun yet?
Home of the FatCat and My 9.0 [CPGNuke] Playground

MrFatCat's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
Linix-Redhat 3.0 Enterprise/Apache 1.3.31/MySql 4.0.20-standard /PHP 4.3.8/CPG 8.2b (& CVS 9.0)
Back to top
View user's profile Visit poster's website ICQ Number MSN Messenger
DJ Maze
Developer
Developer

Offline Offline
Joined: Apr 19, 2004
Posts: 5683
Location: http://tinyurl.com/5z8dmv
PostPosted: Fri Oct 15, 2004 9:25 pm
Post subject: Re: New function and remote avatar filesize

0x2C is character "," and mostly it has 0x00 before it.
There are 9 occurences in above image and that's correct because the gif contains 9 frames

PHP:
preg_match('/\x00\x2C/', $file, $matches)
should do the trick probably


DJ Maze's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
Fedora 15 / 2.2.22 / 5.5.20 / 5.3.10 / CVS
Back to top
View user's profile Visit poster's website Yahoo Messenger Photo Gallery
DJ Maze
Developer
Developer

Offline Offline
Joined: Apr 19, 2004
Posts: 5683
Location: http://tinyurl.com/5z8dmv
PostPosted: Fri Oct 15, 2004 10:29 pm
Post subject: Re: New function and remote avatar filesize

Here's some better detail

_________________
There are two paths, the short one and the long one.
When you choose the short path you will notice it takes longer then the long path.
So READ the FAQ and Wiki first Razz

DJ Maze's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
Fedora 15 / 2.2.22 / 5.5.20 / 5.3.10 / CVS
Back to top
View user's profile Visit poster's website Yahoo Messenger Photo Gallery
PerM
Dragonfly addicted
Dragonfly addicted

Offline Offline
Joined: Aug 07, 2004
Posts: 390
Location: Sweden
PostPosted: Fri Oct 15, 2004 11:37 pm
Post subject: Re: New function and remote avatar filesize

DJMaze wrote:
rolleyes.gif wrote:
removed see image below
All data is LZW compressed so it needs to be uncompressed and check how the image "loops"

The image data is compressed, not the header as I understand it...."NETSCAPE2.0" certainly isn't compressed.


PerM's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
Back to top
View user's profile Visit poster's website ICQ Number
Display posts from previous:   
Post new topic    Revive this topic    Printer Friendly Page    Forum Index ⇒  CVS Info
Page 1 of 4
All times are GMT
Go to page 1, 2, 3, 4  Next

Archive Revive
Username:
This is an archived topic - your reply will not be appended here.
Instead, a new topic will be generated in the active forum.
The new topic will provide a reference link to this archived topic.
 
   Toggle Content User Info

Welcome Anonymous

Nickname
Password
(Register)

   Toggle Content Last CVS commits
· Fixed .ico Expires header.
· Removed domain name from cookies so subdomains wont access them anymore.
· CSS and JS, case insensitives.
· CSS and JS, send correct HTTP 1.1 headers and fixed issues where themes and...
· Further security class improvements.
· 301 redirects on LEO changes
· Option to force 3xx http status codes
· Validate googlebot.com and google.com crawlers.
· CCBot
· Rss with etag and atom.

read more...

   Toggle Content Community

Support for DragonflyCMS in a other languages:

Deutsch
Español

   Toggle Content X-links
UltraEdit Browse Happy logo Firefox MySQL PostgreSQL Valid CSS! Valid XHTML 1.0! Unicode Encoded Badge NukeBiz Resources Raven DragonflyCMS Dedicated Now InsideSupport Lampe Berger

You are seeing squares or questionmarks on this page?

All content of this website is copyrighted by the Creative Commons NC-SA
The logos and trademarks used on this site are the property of their respective owners
We are not responsible for comments posted by our users, as they are the property of the poster.
Our server runs on a P3 1.2GHz with 512MB RAM with no accelerators
Support GoPHP5.org
Interactive software released under GNU GPL, Code Credits, Privacy Policy