You are here: Home » Reply

Reply To: FireStats – Top 40 php script (now with added charts)

#14744

mas
Participant

@sonichouse wrote:

@mas wrote:

2) More seriously, you use a hardcoded exec to /opt/bin/wget. Most php’s run with exec() disabled as it’s a security hazard. Can you maneuver around using an exec call and do it in php itself? One should defenitly not need to use wget in php, as php has plenty of functions to access images on the web and load em.

This is my second or third week with php, I will find an alternative approach. I first had the charts render just using the google url, but I need the image copy to reference in the summary page. Now that the speed is ok, I suppose the summary page could always get fresh data – but I don’t like that.

Yeah I see. NP. I am also no php guru but I can immediately imagine 3 ways to do it inside php.

1) As the code seems to require fopen for URLs enabled anyway we could simply use the copy() call.
That should be as simple as

copy(“URL”,”file”);

in theory. Cant try it out right now as I just run an aptitiude dist-upgrade (takes a while lol).

2) Probably cleaner and not using fopen-wrappers would be to use fsockopen. See examples here

http://nl2.php.net/manual/en/function.fsockopen.php
and
http://nl3.php.net/manual/en/function.stream-get-contents.php

3) Theres a full http-request class which one can likely also abuse. That could get a bit more tricky.