473,378 Members | 1,395 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,378 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 2757
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. ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...

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.