简体   繁体   中英

PHP, fopen, Browser Compatibility – What can it be

On this page http://www.effectivewebsolutions.biz/video-spokesmodel.html if you put in your URL it opens it through fopen function and puts a video spokes-model on the website for demonstration purposes, here is the script.

<?php
$handle = fopen($_POST["url"], "r");

while($data = fread($handle, 1000000)){
    $contents .= $data;
}

fclose($handle);

echo "<base href=\"{$_POST['url']}\">";
echo "\n\n";
echo "<!-- Begin inserted page -->";
echo "\n";
echo $contents;
echo "\n";
echo "<!-- End inserted page -->";
echo "\n\n";
echo '<script type="text/javascript" src="http://www.internet-spokesmodels.com/scripts/swfobject.js"></script>';
echo '<style type="text/css" media="screen">object { outline:none; } </style>';
echo "\n";
echo '<script type="text/javascript" src="http://www.internet-spokesmodels.com/actors/script/SabrinaEXAMPLESredshirt_350x500.js"></script>';
?> 

However in Safari it only opens text version of the website (no css or images). It doesn't make sense why would browser make a difference in this case.

Any Ideas?

Probably because the page does not render valid HTML. When I tried it with http://www.google.ca , I got:

<base href="http://google.ca">

<!-- Begin inserted page -->
<!doctype html><html><head><meta http-equiv="content-type" ...

The DOCTYPE should be the first thing in the page, followed by a <html> tag with HTML content. The <base> tag should be within the <head> tag.

You can't blame Safari for displaying invalid HTML incorrectly.

The HTML code being returned should be identical across browsers, since browsers have nothing to do with server-side code. Check the validity of HTML. Also, sanitize your input as suggested meagar.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM