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.
";
include_once($config["base_path"]."/include/bottom_footer.php");
break;
// by default, just list the map setup
default:
include_once($config["base_path"]."/include/top_header.php");
maplist();
include_once($config["base_path"]."/include/bottom_footer.php");
break;
}
///////////////////////////////////////////////////////////////////////////
// Repair the sort order column (for when something is deleted or inserted)
function map_resort()
{
$list = db_fetch_assoc("select * from weathermap_maps order by sortorder;");
$i = 1;
foreach ($list as $map)
{
$sql[] = "update weathermap_maps set sortorder = $i where id = ".$map['id'];
$i++;
}
if (!empty($sql)) {
for ($a = 0; $a < count($sql); $a++) {
$result = db_execute($sql[$a]);
}
}
}
function map_move($mapid,$junk,$direction)
{
$source = db_fetch_assoc("select * from weathermap_maps where id=$mapid");
$oldorder = $source[0]['sortorder'];
$neworder = $oldorder + $direction;
$target = db_fetch_assoc("select * from weathermap_maps where sortorder = $neworder");
if(!empty($target[0]['id']))
{
$otherid = $target[0]['id'];
// move $mapid in direction $direction
$sql[] = "update weathermap_maps set sortorder = $neworder where id=$mapid";
// then find the other one with the same sortorder and move that in the opposite direction
$sql[] = "update weathermap_maps set sortorder = $oldorder where id=$otherid";
}
if (!empty($sql)) {
for ($a = 0; $a < count($sql); $a++) {
$result = db_execute($sql[$a]);
}
}
}
function maplist()
{
global $colors;
html_start_box("Weathermaps", "78%", $colors["header"], "3", "center", "weathermap-cacti-plugin-mgmt.php?action=addmap_picker");
html_header(array("Config File", "Title", "Active", "Sort Order", "Accessible By",""));
$query = db_fetch_assoc("select id,username from user_auth");
$users[0] = 'Anyone';
foreach ($query as $user)
{
$users[$user['id']] = $user['username'];
}
$i = 0;
$queryrows = db_fetch_assoc("select * from weathermap_maps order by sortorder");
// or die (mysql_error("Could not connect to database") )
$previous_id = -2;
if( is_array($queryrows) )
{
foreach ($queryrows as $map)
{
form_alternate_row_color($colors["alternate"],$colors["light"],$i);
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 "