Rebuilding all mapsNOTE: Because your Cacti poller process probably doesn't run as the same user as your webserver, it's possible this will fail with file permission problems even though the normal poller process runs fine. In some situations, it MAY have memory_limit problems, if your mod_php/ISAPI module uses a different php.ini to your command-line PHP.
';
}
}
function addmap_picker()
{
global $weathermap_confdir;
global $colors;
$loaded=array();
// find out what maps are already in the database, so we can skip those
$queryrows = db_fetch_assoc("select * from weathermap_maps");
if( is_array($queryrows) )
{
foreach ($queryrows as $map)
{
$loaded[]=$map['configfile'];
}
}
html_start_box("Available Weathermap Configuration Files", "78%", $colors["header"], "2", "center", "");
if( is_dir($weathermap_confdir))
{
$n=0;
$dh = opendir($weathermap_confdir);
if($dh)
{
$i = 0; $skipped = 0;
html_header(array("Config File", "Title",""),2);
while($file = readdir($dh))
{
$realfile = $weathermap_confdir.'/'.$file;
if(is_file($realfile) && ! in_array($file,$loaded) )
{
if(in_array($file,$loaded))
{
$skipped++;
}
else
{
$title = wmap_get_title($realfile);
$titles[$file] = $title;
$i++;
}
}
}
closedir($dh);
if($i>0)
{
ksort($titles);
$i=0;
foreach ($titles as $file=>$title)
{
$title = $titles[$file];
form_alternate_row_color($colors["alternate"],$colors["light"],$i);
print ''.htmlspecialchars($file).'';
print ''.htmlspecialchars($title).'';
print 'View';
print 'Add';
print '';
$i++;
}
}
if( ($i + $skipped) == 0 )
{
print "No files were found in the configs directory.";
}
if( ($i == 0) && $skipped>0)
{
print "($skipped files weren't shown because they are already in the database)";
}
}
else
{
print "Can't open $weathermap_confdir to read - you should set it to be readable by the webserver.";
}
}
else
{
print "There is no directory named $weathermap_confdir - you will need to create it, and set it to be readable by the webserver. If you want to upload configuration files from inside Cacti, then it should be writable by the webserver too.";
}
html_end_box();
}
function preview_config($file)
{
global $weathermap_confdir;
global $colors;
chdir($weathermap_confdir);
$path_parts = pathinfo($file);
$file_dir = realpath($path_parts['dirname']);
if($file_dir != $weathermap_confdir)
{
// someone is trying to read arbitrary files?
// print "$file_dir != $weathermap_confdir";
print "