Solved

Get html source of the referring url

Posted on 2007-03-28
9
1,285 Views
Last Modified: 2013-12-13
I have a php script that websites on the internet will use. I would like it so that every time a user loads a page with my php script, it sends me the html of the website, such as:

//the code goes here (get source code of the current website)
mail($my_email, " some subject", $SOURCE-OF-THIS-CURRENT-WEBSITE, "From: xxx");

I need this without using CURL! :)

Thank you.
0
Comment
Question by:sangeetha
9 Comments
 
LVL 29

Expert Comment

by:rdivilbiss
ID: 18808540
$html = fopen($_SERVER['PHP_SELF']);

just a thought, not tested.
0
 
LVL 2

Author Comment

by:sangeetha
ID: 18808637
but upto my knowledge, $_SERVER variable takes the server information of where the file is located.

For example, if "http://www.test.com/parse.php" is the script which I need and if "http://www.example.com/file1.php" is the file that accesses the parse.php file, I need to know the source code of the "http://www.example.com/file1.php".
0
 
LVL 29

Accepted Solution

by:
rdivilbiss earned 38 total points
ID: 18809368
That's what the fopen() is for.
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 29

Assisted Solution

by:TeRReF
TeRReF earned 37 total points
ID: 18810003
$html = file_get_contents($_SERVER['HTTP_REFERER']);
0
 
LVL 29

Expert Comment

by:rdivilbiss
ID: 18810642
file_get_contents(), a better choice.
0
 
LVL 11

Expert Comment

by:JamesCssl
ID: 18813383
<?php
$handle = fopen($_SERVER['HTTP_REFERER'], "r");
$contents = '';
while (!feof($handle)) {
  $contents .= fread($handle, 8192);
}
fclose($handle);
?>

$contents contains the source of the referring site
0
 
LVL 29

Expert Comment

by:rdivilbiss
ID: 18813511
I suggested fopen() also, but really file_get_contents() is a better option for this particular question.
0
 
LVL 1

Expert Comment

by:Computer101
ID: 21291955
Forced accept.

Computer101
EE Admin
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question