Solved

Get html source of the referring url

Posted on 2007-03-28
9
1,282 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
 
LVL 29

Assisted Solution

by:TeRReF
TeRReF earned 37 total points
ID: 18810003
$html = file_get_contents($_SERVER['HTTP_REFERER']);
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

862 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

30 Experts available now in Live!

Get 1:1 Help Now