Jump to content

include remote files


desithugg

Recommended Posts

Hey, well I have my own website that i've worked on over a period of 3 months.
Im quite new to PHP started in around mid June of 2006.
Anyways some websites wanted to use some of my content (which is updated quite often [every 2 days or so).
And that file accesses the database to get some information.
But I don't want to give them my mysql information so I looked into remote including.
[code]
<?php
$get_url = $_GET['http://www.blahblahblah.com/whatever.php'];
$file = fopen ("$get_url", "r");
if (!$file) {
  echo "<p>Unable to open remote file.\n";
  exit;
}
fclose($file);
[/code]
Is there any way I can limit which website can connect to the file and if they will be able to see my mysql connect information.
I could add something like an authorization code.
will something like the fallowing work
[code]
<?php
$get_url = $_GET['includeurl'];
$username_ri = "saad";
$password_ri = "adsh89ds98xc";
$file = fopen ("$get_url", "r");
//inside the file I can have something like if($username_ri != "saad" && $password_ri != "adsh89ds98xc") { echo "Error!"; } else { //execute }
if (!$file) {
  echo "<p>Unable to open remote file.\n";
  exit;
}
fclose($file);
[/code]

Link to comment
https://forums.phpfreaks.com/topic/35604-include-remote-files/
Share on other sites

If you could include files like that, so many sites would be messed up by now :p.

Anyways what you could do is... Hmmm tough one...  Maybe use .htaccess to protect the file from all URIs cept your site's, but then someone could get it with altering their hosts file... You could use an IP address, or if you can include files with get variables (include("http://site.com/?var=a");) then you could use that and use an auth code or something...  Not really sure how to best approach that lol...
Link to comment
https://forums.phpfreaks.com/topic/35604-include-remote-files/#findComment-168683
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.