Solved

Get html source of the referring url

Posted on 2007-03-28
9
1,275 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
Comment Utility
$html = fopen($_SERVER['PHP_SELF']);

just a thought, not tested.
0
 
LVL 2

Author Comment

by:sangeetha
Comment Utility
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
Comment Utility
That's what the fopen() is for.
0
 
LVL 29

Assisted Solution

by:TeRReF
TeRReF earned 37 total points
Comment Utility
$html = file_get_contents($_SERVER['HTTP_REFERER']);
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 29

Expert Comment

by:rdivilbiss
Comment Utility
file_get_contents(), a better choice.
0
 
LVL 11

Expert Comment

by:JamesCssl
Comment Utility
<?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
Comment Utility
I suggested fopen() also, but really file_get_contents() is a better option for this particular question.
0
 
LVL 1

Expert Comment

by:Computer101
Comment Utility
Forced accept.

Computer101
EE Admin
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to count occurrences of each item in an array.
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…

762 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now