473,666 Members | 2,060 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1771
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/ApacheReversePr oxy>

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($error s)) {
$err = file_get_conten ts($errors) or
trigger_error(" Failed to read file $errors.");
}
$msg .= $err !== false ? ": $err" : '.';
trigger_error($ msg);
}

if (is_file($error s)) {
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.co m/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
1485
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 paging.
5
3247
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 money on 3rd party applications. Can I do this through code or is there some reason why it is not doable? I've hunted through the net but all I've got are references to commercial applications. A pointer to sample code would be much
3
1823
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 that
5
1980
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 information around it. If you know a way, or a third party control, please let me know. tia Martin
1
2612
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. Included in the application program is a data “GRID” which I believe was created using Visual Basic, not standard Access. Its purpose is to display the results of a range of “from-to-dates” of registrations for different clients. The difficulty...
1
2281
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 I.P. addresses all the users can access the ASP pages. Using I.P. addresses, no one can use our .net pages because the header that is passed back from the server has extra security that require the end users to "log-in" to the server. This is...
8
7196
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 one tell me the idea of how to get data from websites?
3
2004
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 context. This is typically caused by the context not yet being set. Description: An unhandled exception occurred during the execution of
3
4107
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 published. "Allow precompiled site to be updateable" is NOT checked. "Enable strong naming on precompiled assemblies" is NOT checked. However, "Use fixed naming and single page assemblies" IS checked. I did with the idea that if I call a single page from...
0
8448
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8871
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8640
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7387
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6198
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5666
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4198
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4369
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2011
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.