Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

Help about file_get_contents & readfile

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Help about file_get_contents & readfile

Postby sirpasha » Sun Mar 10, 2013 7:36 pm

Hello , I'm new in php and here too. I'm trying to write a code using php and html to load another websites in a frame. I tried using file_get_contents and readfile but it just load the home page of secondary website and after starting to surf its not using get_contents anymore.
for example , i tried to get_contents for the website: cmyip[dot]com.it shows my hosting IP located in germany 5.112.xxx.xxx in frame , then I start to surf in this html frame and get back to cmyip again. then i'll see my local computer IP.
I want to write a code to make all surfing in the html frame using my hosting IP. its just like a proxy for changing IP.
I dont wanna use any written script like glype or PHProxy.
I also tried to use:
function load();
{
$url = file_get_contents($_SERVER['PHP_SELF']);
echo $url;
}

and

{
$url = file_get_contents($_SERVER['HTML_REFERER']);
echo $url;
}
but i dont know how to use this codes.
thanks in advance and sorry for my bad english.
sirpasha
New php-forum User
New php-forum User
 
Posts: 5
Joined: Sun Mar 10, 2013 7:24 pm

Re: Help about file_get_contents & readfile

Postby seandisanti » Mon Mar 11, 2013 7:42 am

can you post your code please, so we don't have to start from scratch with testing solutions
seandisanti
php-forum Fan User
php-forum Fan User
 
Posts: 838
Joined: Mon Oct 01, 2012 12:32 pm

Re: Help about file_get_contents & readfile

Postby sirpasha » Mon Mar 11, 2013 12:00 pm

I Have 2 Files;

first index.php:
Code: Select all
<html>
<head>
<title>test</title>
<style>
body {
width: 1000px;
margin: 0 auto;
text-align: center;
}
#frame {
width: 998px;
margin: 0 auto;
height: 800px;
</style>
</head>
<body>
Sallam
<p>
<iframe src="url.php" id="frame">
</iframe>
</body>
</html>


and Second url.php:
Code: Select all
<a href="http://cmyip.com">cmyip</a>
<?php
$link = $_SERVER['HTTP_REFERRER'];
$url = readfile($link);
echo $url;
?>


I have used the code above without HTTP_REFERRER before and it just shows the home page and any click in the Frame will load by my local IP.
I'm trying to load the whole website in the frame to open by my Hosting IP, just like a proxy !
sirpasha
New php-forum User
New php-forum User
 
Posts: 5
Joined: Sun Mar 10, 2013 7:24 pm

Re: Help about file_get_contents & readfile

Postby seandisanti » Mon Mar 11, 2013 12:03 pm

cool, I'll take a look at this in a little bit; actively working on something right now for work
seandisanti
php-forum Fan User
php-forum Fan User
 
Posts: 838
Joined: Mon Oct 01, 2012 12:32 pm

Re: Help about file_get_contents & readfile

Postby sirpasha » Mon Mar 11, 2013 12:06 pm

seandisanti wrote:cool, I'll take a look at this in a little bit; actively working on something right now for work

Thank You so Much Sean.
If you have any guidance tell me , I dont wanna sit here and do nothing. lol
sirpasha
New php-forum User
New php-forum User
 
Posts: 5
Joined: Sun Mar 10, 2013 7:24 pm

Re: Help about file_get_contents & readfile

Postby sirpasha » Mon Mar 11, 2013 5:14 pm

I have changed my codes to:

1.php:

Code: Select all

<style>
#frame {
width: 1000px;
height: 900px;
margin: 0 auto;
}
</style>
<iframe src="2.php" id="frame">

</iframe>



and 2.php:

Code: Select all

<?php
$url= ('http://www.google.com');
print_r(get_data($url));
 
/* gets the data from a URL */
 
function get_data($url)
{
$ch = curl_init();
$timeout = 5;
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
?>



lets try searching for a blocked site like facebook , after displaying result click on Facebook and I got an error displaying "you dont have access to this website".

So I Have to change
Code: Select all
$url= ('http://www.google.com');
to
Code: Select all
$url= $_SERVER['HTTP_REFERER'];


then I got a Mirror at mirror loop like you said. but no problem , it will load 1.php inside the iframe.

I Put a link like cmyip.com with HREF so after clicking on cmyip link it will not use my function anymore and display my local IP. the HTTP_REFERER is not working here. I Have to use any clicked links as an array and I Can't find any other codes.

just need to know how to get clicked link by user and put it in the curl function right now.

I also tried for input field and use $_GET['link'] but it doesnt work.

Im newbie in PHP, I live in Iran and my english is not well.

We Used PPTP ,L2TP, SSTP, OpenVPN and HTTPS Proxy to access blocked websites.

now I'm trying to use this for my customers. because the government has blocked all ports for VPN and Proxies.

I tried using PHProxy and Glype before but they had many many problems because of Java Script and Glype Opens Facebook Mobile Version for its plugin.

So... the only way right now is using this codes. I need your helps. I have written some codes about login and membership in PHP with reading forums and toturials. but this one is not easy for me. :(

people need to surf youtube, facebook, twitter and many other in this way. but with this codes i can only display the home page of these websites and they can not login to their accounts.

Thanks
sirpasha
New php-forum User
New php-forum User
 
Posts: 5
Joined: Sun Mar 10, 2013 7:24 pm

Re: Help about file_get_contents & readfile

Postby johnj » Tue Mar 12, 2013 8:48 pm

....just need to know how to get clicked link by user and put it in the curl function right now.


You should understand that the click happens on the client side (on the browser) and the curl functions work on the server. One way will be - When ever a link is clicked (use onClick()) you need to submit a form (use POST) which has a hidden parameter as "clicked link". Once the clicked link is got, use that in your curl function.
johnj
php-forum Super User
php-forum Super User
 
Posts: 1805
Joined: Thu Mar 10, 2011 5:07 pm

Re: Help about file_get_contents & readfile

Postby sirpasha » Wed Mar 13, 2013 7:51 am

John I really appreciate for your reply. It solves many of my problems. :D
sirpasha
New php-forum User
New php-forum User
 
Posts: 5
Joined: Sun Mar 10, 2013 7:24 pm


Return to PHP coding => General

Who is online

Users browsing this forum: Google [Bot], Majestic-12 [Bot] and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.