473,230 Members | 1,754 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,230 software developers and data experts.

Retrieve and display 3rd party pages

Hi,

I'm wondering if you can show me an example php page that allows me to
retrieve and display 3rd party pages. I.e.,

when my php script is called as http://site/path/getit.php?file_key
it can retrieve from http://3rd.party/path2/name-with-file_key.htm
and display the result back to the browser.

I don't know php, and start to learning it. So I hope you can give me a full
php page, not a segment. I don't think it'd be too long though. Luckily, I'm
a programmer, so you don't need to comment it much, unless it is too
convoluted.

Further, if you can throw in handling of gzipped files, that'd be super.

If you have Firefox, it can automagically gunzipped gzipped files, like

http://www.gnu.org/software/bash/manual/bashref.html.gz

So I hope the script http://site/path/getit.php?bashref

can display the content of

http://www.gnu.org/software/bash/manual/bashref.html.gz

thanks
--
Tong (remove underscore(s) to reply)
http://xpt.sourceforge.net/
--
Posted via a free Usenet account from http://www.teranews.com

Oct 29 '06 #1
2 1745
Hi,

You could fetch a remote URL using PHP's URL wrappers. For example,
readfile can stream the contents of a remote URL:

readfile('http://site/content/page.html');

You could also do this with mod_proxy:

ProxyPass /my/mirror/ http://site/content/

Requests for /my/mirror/* will be internally sent to the remote site.
If the page contains internal links that use absolute URLs, you may
want to use mod_proxy_html to rewrite those URLs or use an output
buffer handler. More info on using mod_proxy_html:

<http://www.wlug.org.nz/ApacheReverseProxy>

You could also use a proxy application such as PHP Proxy
(www.phpproxy.com).

Since many browsers can automatically decompress gzip-compressed
content, you wouldn't need to worry about decompressing it yourself. If
you still wanted to do this however, you could use a shell command.
Some code to do that:

<?

// Sample usage:
//
// zcatUrl('http://site/file.html.gz')
//
// That will decompress the remote URL and stream content
// to the browser.

function zcatUrl($url)
{
$errors = tempnam('/tmp', 'zcatUrl-');
$cmd = 'wget -O - ' . escapeshellarg($url) .
' 2' . escapeshellarg($errors) . ' | zcat';
passthru($cmd, $exitCode);

if ($exitCode != 0) {
$msg = "Command \"$cmd\" failed with exit code $exitCode";
$err = false;
if (is_file($errors)) {
$err = file_get_contents($errors) or
trigger_error("Failed to read file $errors.");
}
$msg .= $err !== false ? ": $err" : '.';
trigger_error($msg);
}

if (is_file($errors)) {
unlink($errors) or
trigger_error("Failed to delete file $errors");
}
}

?>

* Tong * wrote:
Hi,

I'm wondering if you can show me an example php page that allows me to
retrieve and display 3rd party pages. I.e.,

when my php script is called as http://site/path/getit.php?file_key
it can retrieve from http://3rd.party/path2/name-with-file_key.htm
and display the result back to the browser.

I don't know php, and start to learning it. So I hope you can give me a full
php page, not a segment. I don't think it'd be too long though. Luckily, I'm
a programmer, so you don't need to comment it much, unless it is too
convoluted.

Further, if you can throw in handling of gzipped files, that'd be super.

If you have Firefox, it can automagically gunzipped gzipped files, like

http://www.gnu.org/software/bash/manual/bashref.html.gz

So I hope the script http://site/path/getit.php?bashref

can display the content of

http://www.gnu.org/software/bash/manual/bashref.html.gz

thanks
--
Tong (remove underscore(s) to reply)
http://xpt.sourceforge.net/
--
Posted via a free Usenet account from http://www.teranews.com
Oct 29 '06 #2
On Sat, 28 Oct 2006 22:12:45 -0700, petersprc wrote:
You could fetch a remote URL using PHP's URL wrappers. For example,
readfile can stream the contents of a remote URL:

readfile('http://site/content/page.html');

You could also do this with mod_proxy...

Since many browsers can automatically decompress gzip-compressed
content, you wouldn't need to worry about decompressing it yourself.
First of all, thanks a lot for this comprehensive reply. You've even
covered issues that I hadn't thought about. thanks!

Just for the archive, following your advice, and scripts found in
http://ca.php.net/readfile
I hacked the following php script, which tested ok:

<?php
header("Content-Type: text/html");
header("Content-Encoding: x-gzip");

set_time_limit(0);

ob_start();
readfile('http://rute.2038bug.com/index.html.gz');
// use @ to hide 'nothing to flush' errors
@ob_flush();

$content = ob_get_contents();
ob_end_clean();
?>
--
Tong (remove underscore(s) to reply)
http://xpt.sourceforge.net/
--
Posted via a free Usenet account from http://www.teranews.com

Oct 29 '06 #3

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

Similar topics

0
by: David Potahisnsky | last post by:
I have ASPX page with DataGrid object. To fill this object I use DataTable that contain result of stored procedure. In my case it's about 300 rows. I would like to display this table with...
5
by: Emmett Power | last post by:
Hi, I use Access to send emails through SMTP. I'd like to mirror the process and retrieve emails from my SMTP/Pop3 server without the intermediary of Outlook. I don't want to spend a lot of...
3
by: Richard Thornley | last post by:
Hello, I was just been given a project and I have some questions on how to accomplish the first part of the task. If a user sends an email to a specific email address I need to detect...
5
by: Martin Moser | last post by:
Does somebody knows, if theres a way to display any file (tiff, doc, pdf, .....) "inline" on an asp.net site? What I want to do is, to display a file, which is stored in the DB, and some...
1
by: John Phelan-Cummings | last post by:
When I add the name of a new individual in a, bound form, it will not display that personís name in a label control of a second unbound form. I have a scheduling program that I am working on. ...
1
by: Lyners | last post by:
What I need - To retrieve the server name that the ASP application is running on. Why - Our current intranet is on a network where we have users that are on a domain and some that are not. Using...
8
by: Yoshitha | last post by:
Hi I want to Extracet(retrieve) data from some of websites and the retrieved data has to be saved in excel or.csv files. I need to develop this in ASP.net(using C#.net Vs 2003). Can any...
3
by: ipramod | last post by:
Hi, I have a code snippet C# when executed gives the following exception on IE. ___________________________________________________________________ Unable to retrieve the user sid from...
3
by: John Kotuby | last post by:
Hi all, Within an IFRAME of a standard site constructed of mostly static HTM type pages, I am calling up one page from a large ASP.NET 3.5 site. I have precompiled the ASP.NET site and...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, youíll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...

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.