473,386 Members | 1,610 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

How to tell if Mime type matches contents

Hi Everyone,

Before I write the script myself, I'm looking for PHP code that checks
that a link's content type matches it's contents. I need this for my
"broken link" checker script, which fails to spot the "broken" links
http://www.awin1.com/show.php?mid=10...6515&aid=49007 and
http://www.awin1.com/awclick.php?mid...36515&id=49007. Any
ideas?

BTW, in case the links get fixed before you read the message, the first
link is a GIF MIME that returns

[document.write('<a
href="http://www.affiliatewindow.com/?id=.&banner=no"
target="_blank"><img
src="http://www.awin1.com/show.php?mid=3&gid=14&aid=477&clickref=nobanner"
border="0"></a>')]

which displays as

[The image
"http://www.awin1.com/show.php?mid=1014&linkid=36515&aid=49007"
cannot be displayed, because it contains errors.] .

The second is a text/html that returns

[<br />
<b>Warning</b>: mysql_result(): Unable to jump to row 0 on MySQL
result index 30 in <b>/home/sites/site3/web/awclick.php</b> on line
<b>51</b><br />
<br />
<b>Warning</b>: mysql_fetch_array(): supplied argument is not a valid
MySQL result resource in
<b>/home/sites/site3/web/linkdeliveryfunctions.inc.php</b> on line
<b>178</b><br />
<br />

<b>Warning</b>: mysql_result(): supplied argument is not a valid MySQL
result resource in
<b>/home/sites/site3/web/linkdeliveryfunctions.inc.php</b> on line
<b>478</b><br />
<br />
<b>Warning</b>: Cannot modify header information - headers already
sent by (output started at /home/sites/site3/web/awclick.php:51) in
<b>/home/sites/site3/web/linkdeliveryfunctions.inc.php</b> on line
<b>462</b><br />
<br />
<b>Warning</b>: Cannot modify header information - headers already
sent by (output started at /home/sites/site3/web/awclick.php:51) in
<b>/home/sites/site3/web/awclick.php</b> on line <b>235</b><br />
]

Thanks,
Ed

Dec 27 '05 #1
1 2759
On 27 Dec 2005 07:27:06 -0800, "ed_spain" <ed********@gmail.com> wrote:
Before I write the script myself, I'm looking for PHP code that checks
that a link's content type matches it's contents. I need this for my
"broken link" checker script, which fails to spot the "broken" links
http://www.awin1.com/show.php?mid=10...6515&aid=49007 and
http://www.awin1.com/awclick.php?mid...36515&id=49007. Any
ideas?

BTW, in case the links get fixed before you read the message, the first
link is a GIF MIME that returns

[document.write('<a
href="http://www.affiliatewindow.com/?id=.&banner=no"
target="_blank"><img
src="http://www.awin1.com/show.php?mid=3&gid=14&aid=477&clickref=nobanner"
border="0"></a>')]

which displays as

[The image
"http://www.awin1.com/show.php?mid=1014&linkid=36515&aid=49007"
cannot be displayed, because it contains errors.] .

The second is a text/html that returns

[<br />
<b>Warning</b>: mysql_result(): Unable to jump to row 0 on MySQL
result index 30 in <b>/home/sites/site3/web/awclick.php</b> on line
<b>51</b><br />
<br />


There's MIME-type detection using "magic numbers" available through:
http://uk2.php.net/mime_content_type

This does a quick check against the first few bytes of the file to see if it
matches up with various file formats.

It won't catch the second one, because that's still a valid HTML page - it may
have PHP errors on it, but they're in HTML.

--
Andy Hassall :: an**@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
Dec 30 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Phil Powell | last post by:
How do you detect an image MIME type if you know of the image in a directory? For example, I know of: if (is_file("$myImagePath/$myImageName")) { // FIND MIME TYPE BUT HOW I DUNNO } The...
12
by: lawrence | last post by:
How do I get PHP to tell the server that when I echo text to the screen, I need for the text to be sent as UTF-8? How does Apache know the right encoding when all the text is being generated by...
303
by: mike420 | last post by:
In the context of LATEX, some Pythonista asked what the big successes of Lisp were. I think there were at least three *big* successes. a. orbitz.com web site uses Lisp for algorithms, etc. b....
1
by: John B. Kim | last post by:
I am working on the code below: ****************************************************** use strict; use MIME::Lite; use Net::SMTP; my $from = 'steve@earthlink.net'; my @addweek1 =...
0
by: clevariant | last post by:
Hello, I'm tasked with creating a WSDL file that is compatible with .NET's code gen' tool, wsdl.exe. I'm getting an error in the code output saying "Missing soap:body input binding", which...
1
by: Michael Loughry | last post by:
I'm writing a web application that fetches documents from the server and sends them to the client. I do this using the Response.BinaryWrite method. However, is there any way to detect the MIME...
0
by: Ed Eichman | last post by:
Hi Everyone, Before I write the script myself, I'm looking for PHP code that checks that a link's content type matches it's contents. I need this for my "broken link" checker script, which fails...
0
by: José Joye | last post by:
hello, I have to communicate with a web Service for which I received the WSDL below. When trying to generate the client proxy, it gives me the error (see below). After investigation, I have...
0
by: Pirmin | last post by:
How can I find the matches for bookings that meet the following conditions. A booking always starts with a date. A booking can consist of several lines. Dates can be part of the booking text. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.