NOTE: 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.";
print "
It is recommended that you don't use this feature, unless you understand and accept the problems it may cause.
";
include_once($config["base_path"]."/include/bottom_footer.php");
break;
case 'rebuildnow2':
include_once(dirname(__FILE__).DIRECTORY_SEPARATOR."Weathermap.class.php");
include_once(dirname(__FILE__).DIRECTORY_SEPARATOR."lib".DIRECTORY_SEPARATOR."poller-common.php");
include_once($config["base_path"]."/include/top_header.php");
print "
Rebuilding all maps
NOTE: 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();
weathermap_footer_links();
include_once($config["base_path"]."/include/bottom_footer.php");
break;
}
///////////////////////////////////////////////////////////////////////////
function weathermap_footer_links()
{
global $colors;
global $WEATHERMAP_VERSION;
print ' ';
html_start_box("
", "78%", $colors["header"], "2", "center", "");
html_end_box();
}
// 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", "Settings", "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;
$had_warnings = 0;
if( is_array($queryrows) )
{
form_alternate_row_color($colors["alternate"],$colors["light"],$i);
print "
'.$had_warnings.' of your maps had warnings last time '.($had_warnings>1?"they":"it").' ran. You can try to find these in your Cacti log file or by clicking on the warning sign next to that map (you might need to increase the log line count).
($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();
if($skipped>0)
{
print "
Some files are not shown because they have already been added. You can show these files too, if you need to.
";
}
if($show_all)
{
print "
Some files are shown even though they have already been added. You can hide those files too, if you need to.
";
}
}
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 "
";
print "";
}
html_end_box();
}
function weathermap_map_settings($id)
{
global $colors, $config;
if($id==0)
{
$title = "Additional settings for ALL maps";
$nonemsg = "There are no settings for all maps yet. You can add some by clicking Add up in the top-right, or choose a single map from the management screen to add settings for that map.";
}
else
{
// print "Per-map settings for map $id";
$title = db_fetch_cell("select titlecache from weathermap_maps where id=".intval($id));
$title = "Edit per-map settings for Weathermap $id: " . $title;
$nonemsg = "There are no per-map settings for this map yet. You can add some by clicking Add up in the top-right.";
}
html_start_box("$title", "70%", $colors["header"], "2", "center", "weathermap-cacti-plugin-mgmt.php?action=map_settings_form&mapid=".intval($id));
html_header(array("","Name", "Value",""));
$n=0;
$settingrows = db_fetch_assoc("select * from weathermap_settings where mapid=".intval($id));
if( is_array($settingrows) )
{
if(sizeof($settingrows)>0)
{
foreach( $settingrows as $setting)
{
form_alternate_row_color($colors["alternate"],$colors["light"],$n);
print '