notclive Posted June 7, 2006 Share Posted June 7, 2006 I want to read the source of a php on a different server, and have it as a string.fopen wont seem to open a url Link to comment Share on other sites More sharing options...
aspnetguy Posted June 7, 2006 Share Posted June 7, 2006 I don't think you can open the contents of a php file from another server. If you could then you could just steal other people's source code. Link to comment Share on other sites More sharing options...
justsomeguy Posted June 7, 2006 Share Posted June 7, 2006 The only thing you can save is the HTML output produced by PHP, unless you have direct access to the server (FTP, SSH, telnet etc) you can't get to the PHP source. If you do have FTP access, you can use PHP to login through FTP and get the source that way. Link to comment Share on other sites More sharing options...
notclive Posted June 7, 2006 Author Share Posted June 7, 2006 The only thing you can save is the HTML outputthats what i want Link to comment Share on other sites More sharing options...
asylum Posted June 7, 2006 Share Posted June 7, 2006 Including will do that though you can't store the output in a variable.EDIT: I take that back, look at this example: $string = get_include_contents('somefile.php');function get_include_contents($filename) { if (is_file($filename)) { ob_start(); include $filename; $contents = ob_get_contents(); ob_end_clean(); return $contents; } return false;} Link to comment Share on other sites More sharing options...
justsomeguy Posted June 7, 2006 Share Posted June 7, 2006 OK, if you just want to read it into a string, use this function:http://www.php.net/manual/en/function.file-get-contents.phpEverything you need to now about it is either on the page or linked from the page. Link to comment Share on other sites More sharing options...
reportingsjr Posted June 8, 2006 Share Posted June 8, 2006 highlight_file()?I beleive there was another topic on this.. anyways just do this: highlight_file('url_here'); and it will automatically "echo" the source code out. Link to comment Share on other sites More sharing options...
notclive Posted June 8, 2006 Author Share Posted June 8, 2006 Ive tried lots of methods and keep getting a similar error message heres my current php file <?phphighlight_file('http://www.aokforums.com/notclive/index.php');?> and heres the error message Warning: highlight_file(): php_network_getaddresses: getaddrinfo failed: No address associated with hostname in /home/www/forum.notclive.co.uk/bar.php on line 2Warning: highlight_file(http://www.aokforums.com/notclive/index.php): failed to open stream: Address family not supported by protocol in /home/www/forum.notclive.co.uk/bar.php on line 2Warning: highlight_file(): Failed opening 'http://www.aokforums.com/notclive/index.php' for highlighting in /home/www/forum.notclive.co.uk/bar.php on line 2 Link to comment Share on other sites More sharing options...
Little Goat Posted June 8, 2006 Share Posted June 8, 2006 I think that has something to do with url_fopen in the php configuration file. some hosts have it turned off. Link to comment Share on other sites More sharing options...
notclive Posted June 8, 2006 Author Share Posted June 8, 2006 this <?phpini_set('allow_url_fopen',true);highlight_file('http://www.aokforums.com/notclive/index.php');?> wont work either Link to comment Share on other sites More sharing options...
asylum Posted June 8, 2006 Share Posted June 8, 2006 I think he means in aokforums.com's configuration which you can't change from your script. Link to comment Share on other sites More sharing options...
notclive Posted June 8, 2006 Author Share Posted June 8, 2006 ahhh crap any other way? using javascript or something else? Link to comment Share on other sites More sharing options...
reportingsjr Posted June 8, 2006 Share Posted June 8, 2006 Asylum is right, but if that happens you can still do it for pages on the same server, so in your case any page on the server with you can be acessed, but not on outside servers. Link to comment Share on other sites More sharing options...
justsomeguy Posted June 8, 2006 Share Posted June 8, 2006 I don't think one host can disable outside PHP from accessing files by a request. A request is a request, no matter where it comes from.You don't want to use highlight_file though, that is only for local PHP scripts. It highlights the PHP source, which you can't get over HTTP. Use the function I pointed you to if you want to get the HTML output in a string through HTTP. Link to comment Share on other sites More sharing options...
notclive Posted June 8, 2006 Author Share Posted June 8, 2006 still nothing <?phpini_set('allow_url_fopen',true);$page=file_get_contents("http://www.aokforums.com/notclive/index.php");echo $page;?> anybody understand what this error message means Warning: file_get_contents(): php_network_getaddresses: getaddrinfo failed: No address associated with hostname in /home/www/forum.notclive.co.uk/bar.php on line 3Warning: file_get_contents(http://www.aokforums.com/notclive/index.php): failed to open stream: Address family not supported by protocol in /home/www/forum.notclive.co.uk/bar.php on line 3 Link to comment Share on other sites More sharing options...
notclive Posted June 8, 2006 Author Share Posted June 8, 2006 still nothing <?phpini_set('allow_url_fopen',true);$page=file_get_contents("http://www.aokforums.com/notclive/index.php");echo $page;?> anybody understand what this error message means Warning: file_get_contents(): php_network_getaddresses: getaddrinfo failed: No address associated with hostname in /home/www/forum.notclive.co.uk/bar.php on line 3Warning: file_get_contents(http://www.aokforums.com/notclive/index.php): failed to open stream: Address family not supported by protocol in /home/www/forum.notclive.co.uk/bar.php on line 3 Link to comment Share on other sites More sharing options...
justsomeguy Posted June 8, 2006 Share Posted June 8, 2006 You seem to have run into a PHP bug. Some people report that restarting various services on the webserver fixes this, some people seem to think it's a DNS issue. I'm still searching. Link to comment Share on other sites More sharing options...
justsomeguy Posted June 8, 2006 Share Posted June 8, 2006 No address associated with hostnameIt does seem like a DNS issue. If possible, try restarting the bind service on the server (or ask an admin to do it). Also, give the error message to an admin, he might know what to do.You can also try accessing via IP instead of hostname. The IP address of aokforums.com is 72.36.168.178, you can try accessing that instead, but I'm getting a 404 for this:http://72.36.168.178/notclive/index.phpEven though the hostname works. They might be redirecting your site to another IP, or they might be disallowing access by IP.I just had a thought. Something about the no address associated with hostname error plus unable to access via IP - there might be some restriction on the other server that is stopping you from being able to do this. Try to open http://www.google.com from the same location and see if that works. Link to comment Share on other sites More sharing options...
Little Goat Posted June 9, 2006 Share Posted June 9, 2006 how did you find out the IP? Link to comment Share on other sites More sharing options...
justsomeguy Posted June 9, 2006 Share Posted June 9, 2006 Some people are surprised at how easy it is to find a lot of information out that they thought was private. So I'll introduce you to this site:http://www.dnsstuff.com/Play with that page for a while, give it a look. If you want to find out IP, you can either use DNS lookup (top right box), type in the domain name, and select ANY (ALL) for the record type. That will give you the names of mail servers, DNS servers, any subdomains defined in DNS for that hostname. You can also type the hostname into Ping or Traceroute and get the IP. Also, check out the City from IP box. Find out where those bastards hitting your server live.. Apparently the aokforums.com server is located in Dallas, Texas. Link to comment Share on other sites More sharing options...
notclive Posted June 9, 2006 Author Share Posted June 9, 2006 google works what does that mean?and the aokforums ip doesntalso this website seems to be able to do it http://web-sniffer.net/?url=http%3A%2F%2Fw...niffer%2F1.0.24 Link to comment Share on other sites More sharing options...
justsomeguy Posted June 9, 2006 Share Posted June 9, 2006 Try using the CURL functions instead:http://www.php.net/curl <?php// create a new curl resource$ch = curl_init();// set URL and other appropriate optionscurl_setopt($ch, CURLOPT_URL, "http://www.example.com/");curl_setopt($ch, CURLOPT_HEADER, 0);curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);// grab URL and store it in a string$page_text = curl_exec($ch);// close curl resource, and free up system resourcescurl_close($ch);?> Link to comment Share on other sites More sharing options...
notclive Posted June 9, 2006 Author Share Posted June 9, 2006 google seems to work but aokforums doesnt theres no error message its just blank Link to comment Share on other sites More sharing options...
justsomeguy Posted June 9, 2006 Share Posted June 9, 2006 It works for me:http://manchine.net/w3/curl.php <?php// create a new curl resource$ch = curl_init();// set URL and other appropriate optionscurl_setopt($ch, CURLOPT_URL, "http://www.aokforums.com/notclive/index.php");curl_setopt($ch, CURLOPT_HEADER, 0);curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);// grab URL and store it in a string$page_text = curl_exec($ch);// close curl resource, and free up system resourcescurl_close($ch);?><html> <head> <title>CURL</title> </head> <body> <textarea rows="20" cols="80"><?php echo $page_text; ?></textarea> </body></html> Link to comment Share on other sites More sharing options...
notclive Posted June 9, 2006 Author Share Posted June 9, 2006 and it wont work for me, so its my server Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now