Hello,
I am very new to PHP coding. I am trying to achieve a task via PHP, regarding which I have been googling around for a few days and now come up with emtpy hands!
Ok, what I need to write is a "website preview script". That is I need to display a website hosted on serverA and pointing elsewhere, from ServerA ( via curl possibly ).
For example: I have configured techsware.in and google.com on ServerA ( of course google.com pointing to their IP ). I need to display the contents of google.com "on my server" , if I call http://techsware.in/google.php which has some curl coding in it! Note, what I have is the domain name ( google.com ) and the IP on which it is hosted on serverA to achieve this. Any way to achieve this?
PS: web server is apache and php version is 5.2
Any help will be highly appreciated!
Thank you,
Nibin.
Website preview script
Moderator: General Moderators
Re: Website preview script
Hello,
Just another note - I can achieve this if I put <my IP> google.com in /etc/hosts file ( its Linux ). But I need to run this script for normal users as well, which won't have super user privileges and thus unable to edit /etc/hosts file. So I want to specify somewhere in the PHP script that, google.com points to <my IP>.
Hope someone from this forum will come back a solution
Thank you,
Nibin.
Just another note - I can achieve this if I put <my IP> google.com in /etc/hosts file ( its Linux ). But I need to run this script for normal users as well, which won't have super user privileges and thus unable to edit /etc/hosts file. So I want to specify somewhere in the PHP script that, google.com points to <my IP>.
Hope someone from this forum will come back a solution
Thank you,
Nibin.
Re: Website preview script
You can try php stream functions
Here is a code snippet from php.net
Here is a code snippet from php.net
Code: Select all
<?php
$fp = fsockopen("www.example.com", 80, $errno, $errstr, 30);
if (!$fp) {
echo "$errstr ($errno)<br />\n";
} else {
$out = "GET / HTTP/1.1\r\n";
$out .= "Host: www.example.com\r\n";
$out .= "Connection: Close\r\n\r\n";
fwrite($fp, $out);
while (!feof($fp)) {
echo fgets($fp, 128);
}
fclose($fp);
}
?>
Re: Website preview script
Hello Temidayo,
Thanks for your reply!
But I want to load example.com from my own server, where the php script will run ( localhost in fact ); no matter to where example.com is resolving to. For this, I just have the doain name (example.com ) and the IP on which it is hosted on my server.
Hope this makes more sence!
Thank you,
Nibin.
Thanks for your reply!
But I want to load example.com from my own server, where the php script will run ( localhost in fact ); no matter to where example.com is resolving to. For this, I just have the doain name (example.com ) and the IP on which it is hosted on my server.
Hope this makes more sence!
Thank you,
Nibin.
Re: Website preview script
Maybe html frame/iframe is what you need.Nibin wrote:Hello Temidayo,
...But I want to load example.com from my own server, where the php script will run ( localhost in fact ); no matter to where example.com is resolving to. For this, I just have the doain name (example.com ) and the IP on which it is hosted on my server.