note 104746 added to function.file-get-contents
| From: | fibrefox at dynamicfiles dot de | Date: | Tue, 05 Jul 2011 12:45:44 +0000 |
| Subject: | note 104746 added to function.file-get-contents | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-181236@lists.php.net to get a copy of this message | ||
If you want to insert tracking-scripts into your shopping-system, some scripts doesn't support
intelligent detection of HTTPS, so i made a script i put on the server that rewrites
'http' to 'https' in the script, assuming everything has to be UTF-8 encoded (as
a fallback it makes a redirect).
It is important that the HTTPS-source DOES exist!
<?php
function file_get_contents_utf8($fn) {
$opts = array(
'http' => array(
'method'=>"GET",
'header'=>"Content-Type: text/html; charset=utf-8"
)
);
$context = stream_context_create($opts);
$result = @file_get_contents($fn,false,$context);
return $result;
}
header("Content-Type: text/html; charset=utf-8");
$tPath = "URL YOU WANT TO MODIFY";
$result = file_get_contents_utf8("http://".$tPath);
if( $result == false){
header("Location: https://".$tPath); // fallback
exit();
}
else{
echo mb_ereg_replace("http","https",$result);
}
----
Server IP: 69.147.83.197
Probable Submitter: 83.236.210.186
----
Manual Page -- http://www.php.net/manual/en/function.file-get-contents.php
Edit -- https://master.php.net/note/edit/104746
Del: integrated -- https://master.php.net/note/delete/104746/integrated
Del: useless -- https://master.php.net/note/delete/104746/useless
Del: bad code -- https://master.php.net/note/delete/104746/bad+code
Del: spam -- https://master.php.net/note/delete/104746/spam
Del: non-english -- https://master.php.net/note/delete/104746/non-english
Del: in docs -- https://master.php.net/note/delete/104746/in+docs
Del: other reasons-- https://master.php.net/note/delete/104746
Reject -- https://master.php.net/note/reject/104746
Search -- https://master.php.net/manage/user-notes.php