Hi everyone,
I am attempting to grab the source of a website so that I can strip out information that I don't want and only display a subset to the user.
The problem I am having is with actually getting the contents of the file. I am used to using methods like file('filename') or fopen('filename') and whatnot (which works in normal cases).
I think the issue is that the page I want to open is at:
https://"some host address here"/cgi-bin/status.cgi?hostgroup=all&style=summary
I guess that the https protocal and the cgi source is causing the problem.
Any pointers on how to access this source so that I can manipulate the way it appears on screen? Code examples would be very helpful. Ideally, I would like an array of the source file like file('filename') would give me, but beggers can't be choosers.
Thanks.
Opening website source over https
Moderator: General Moderators
There really isn't much to post since I am not contining unless I can get the source for the page I am trying to access.
Here is the code I was using to see if I could access it.
Thanks for any help.
Here is the code I was using to see if I could access it.
Code: Select all
<?
//open the file
$f = fopen("https://dev.cygnalcare.ca:20020/nagios/cgi-bin/status.cgi?hostgroup=all&style=summary", 'r');
//put the lines into an array
$fcontents = file($f);
//try printing
echo $fcontents[1];
//try printing
echo $fcontents[0];
//close the file
fclose($f);
?>- shiznatix
- DevNet Master
- Posts: 2745
- Joined: Tue Dec 28, 2004 5:57 pm
- Location: Tallinn, Estonia
- Contact:
well 1st off you dont need to open the file to use file on it. why dont u try doing
but your probebly want to use htmlentities so you can view the source of the page.
Code: Select all
$arr = file ("https://dev.cygnalcare.ca:20020/nagios/cgi-bin/status.cgi?hostgroup=all&style=summary");
foreach ($arr as $key => $value)
{
echo 'Line '.$key.' containes '.$value.'<br>';
}- shiznatix
- DevNet Master
- Posts: 2745
- Joined: Tue Dec 28, 2004 5:57 pm
- Location: Tallinn, Estonia
- Contact:
try it on a local .html file and see the results. im really not sure how any of this functions as i have never done it before but this has been discussed many many times on these forums, use the search feature and im sure you can come up with somthing.
after just trying to view the site it seams that it needs security certificutes to view it? that is probely why u can only get those 4 lines because your severs php dosnt have the permissions to view that website
after just trying to view the site it seams that it needs security certificutes to view it? that is probely why u can only get those 4 lines because your severs php dosnt have the permissions to view that website
Everything works on local files or even regular webpages. I am able to use these functions in other projects I am doing no problem. These projects involve flat data file (txt) or simple webpages that can be accessed through http. The system I am testing this code on has the certificate for the site installed (even the passwords are saved, lol).
The root of this thread is how to handle connecting through https, or maybe it the cgi that is confusing the code...
Thanks for all the suggestions so far.
The root of this thread is how to handle connecting through https, or maybe it the cgi that is confusing the code...
Thanks for all the suggestions so far.
- shiznatix
- DevNet Master
- Posts: 2745
- Joined: Tue Dec 28, 2004 5:57 pm
- Location: Tallinn, Estonia
- Contact:
the system might have the certificts but your PHP does not. i dont know of any ways to make php able to do that because of obvious security issues
i.e. if you pay for some sort of website you could just make your own website based off the content of the other website becasue you have the cirtificutes. that wouldnt make any sence, so i really do think that its possible just because its a security issue
i.e. if you pay for some sort of website you could just make your own website based off the content of the other website becasue you have the cirtificutes. that wouldnt make any sence, so i really do think that its possible just because its a security issue