desithugg Posted January 25, 2007 Share Posted January 25, 2007 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 More sharing options...
artacus Posted January 25, 2007 Share Posted January 25, 2007 You can't really include a remote file in the way you are wanting to. You can include it, but it will be processed by php on the server its on and all you'll get is whatever you'd see if you typed that address into your browser. Link to comment https://forums.phpfreaks.com/topic/35604-include-remote-files/#findComment-168677 Share on other sites More sharing options...
corbin Posted January 25, 2007 Share Posted January 25, 2007 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 More sharing options...
desithugg Posted January 25, 2007 Author Share Posted January 25, 2007 would it work if I use html frames. Link to comment https://forums.phpfreaks.com/topic/35604-include-remote-files/#findComment-169041 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.