Jump to content

Require()ing or include()ing files with a query string


opalelement

Recommended Posts

I have a GD script that, if $_GET rebuild == true, it will regenerate the image based on database data. If not, it gets a saved image and displays that.

 

All of that works perfectly. The problem I am having is that I want one script that will run all of my rebuilds at once. However, when require()ing or include()ing the scripts that generate the image, it tells me that it cannot find the file. It can find them when I don't have ?rebuild=true, but then it doesn't update them.

 

The code:

<?php
$maps = array();
if ($handle = opendir('.')) {
    while (false !== ($file = readdir($handle))) {
        if (is_file($file) && !in_array($file, array("error_log", "update.php"))) {
            $maps[] = "$file";
        }
    }
    closedir($handle);
}

for($i = 0; $i < count($maps); $i++)
{
echo "$maps[$i]";
include($maps[$i] . "?rebuild=true");
}
?>

 

Is there any other way to do this? I want it all in one file so I can update all my images with one cron job. This means I can't use <img src="map url"> because the cron job would close it off before the php scripts were done, since the cron-called script is finished.

 

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.