Rev 1 |
|
Rev 85 |
Line 2... |
|
Line 2... |
|
|
|
$guest_account = true; |
|
$guest_account = true; |
|
|
|
chdir('../../'); |
|
chdir('../../'); |
include_once("./include/auth.php"); |
|
include_once("./include/auth.php"); |
include_once("./include/config.php"); |
|
// include_once("./include/config.php"); |
|
|
|
// include the weathermap class so that we can get the version |
|
// include the weathermap class so that we can get the version |
include_once(dirname(__FILE__)."/Weathermap.class.php"); |
|
include_once(dirname(__FILE__)."/Weathermap.class.php"); |
|
|
|
$action = ""; |
|
$action = ""; |
Line 16... |
|
Line 16... |
$action = $_GET['action']; |
|
$action = $_GET['action']; |
} |
|
} |
|
|
|
switch($action) |
|
switch($action) |
{ |
|
{ |
|
|
case 'viewthumb': // FALL THROUGH |
|
|
case 'viewimage': |
|
|
$id = -1; |
|
|
|
|
|
if( isset($_REQUEST['id']) && (!is_numeric($_REQUEST['id']) || strlen($_REQUEST['id'])==20) ) |
|
|
{ |
|
|
$id = weathermap_translate_id($_REQUEST['id']); |
|
|
} |
|
|
|
|
|
if( isset($_REQUEST['id']) && is_numeric($_REQUEST['id']) ) |
|
|
{ |
|
|
$id = intval($_REQUEST['id']); |
|
|
} |
|
|
|
|
|
if($id >=0) |
|
|
{ |
|
|
$imageformat = strtolower(read_config_option("weathermap_output_format")); |
|
|
|
|
|
$userid = (isset($_SESSION["sess_user_id"]) ? intval($_SESSION["sess_user_id"]) : 1); |
|
|
$map = db_fetch_assoc("select weathermap_maps.* from weathermap_auth,weathermap_maps where weathermap_maps.id=weathermap_auth.mapid and active='on' and (userid=".$userid." or userid=0) and weathermap_maps.id=".$id); |
|
|
|
|
|
if(sizeof($map)) |
|
|
{ |
|
|
$imagefile = dirname(__FILE__).'/output/'.'/'.$map[0]['filehash'].".".$imageformat; |
|
|
if($action == 'viewthumb') $imagefile = dirname(__FILE__).'/output/'.$map[0]['filehash'].".thumb.".$imageformat; |
|
|
|
|
|
$orig_cwd = getcwd(); |
|
|
chdir(dirname(__FILE__)); |
|
|
|
|
|
header('Content-type: image/png'); |
|
|
|
|
|
// readfile_chunked($imagefile); |
|
|
readfile($imagefile); |
|
|
|
|
|
dir($orig_cwd); |
|
|
} |
|
|
else |
|
|
{ |
|
|
// no permission to view this map |
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
break; |
|
|
|
|
|
case 'liveviewimage': |
|
|
$id = -1; |
|
|
|
|
|
if( isset($_REQUEST['id']) && (!is_numeric($_REQUEST['id']) || strlen($_REQUEST['id'])==20) ) |
|
|
{ |
|
|
$id = weathermap_translate_id($_REQUEST['id']); |
|
|
} |
|
|
|
|
|
if( isset($_REQUEST['id']) && is_numeric($_REQUEST['id']) ) |
|
|
{ |
|
|
$id = intval($_REQUEST['id']); |
|
|
} |
|
|
|
|
|
if($id >=0) |
|
|
{ |
|
|
$userid = (isset($_SESSION["sess_user_id"]) ? intval($_SESSION["sess_user_id"]) : 1); |
|
|
$map = db_fetch_assoc("select weathermap_maps.* from weathermap_auth,weathermap_maps where weathermap_maps.id=weathermap_auth.mapid and active='on' and (userid=".$userid." or userid=0) and weathermap_maps.id=".$id); |
|
|
|
|
|
if(sizeof($map)) |
|
|
{ |
|
|
|
|
|
$mapfile = dirname(__FILE__).'/configs/'.'/'.$map[0]['configfile']; |
|
|
$orig_cwd = getcwd(); |
|
|
chdir(dirname(__FILE__)); |
|
|
|
|
|
header('Content-type: image/png'); |
|
|
|
|
|
$map = new WeatherMap; |
|
|
$map->context = ''; |
|
|
// $map->context = "cacti"; |
|
|
$map->rrdtool = read_config_option("path_rrdtool"); |
|
|
$map->ReadConfig($mapfile); |
|
|
$map->ReadData(); |
|
|
$map->DrawMap('','',250,TRUE,FALSE); |
|
|
dir($orig_cwd); |
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
break; |
|
|
case 'liveview': |
|
|
include_once($config["base_path"]."/include/top_graph_header.php"); |
|
|
print "<div id=\"overDiv\" style=\"position:absolute; visibility:hidden; z-index:1000;\"></div>\n"; |
|
|
print "<script type=\"text/javascript\" src=\"overlib.js\"><!-- overLIB (c) Erik Bosrup --></script> \n"; |
|
|
|
|
|
$id = -1; |
|
|
|
|
|
if( isset($_REQUEST['id']) && (!is_numeric($_REQUEST['id']) || strlen($_REQUEST['id'])==20) ) |
|
|
{ |
|
|
$id = weathermap_translate_id($_REQUEST['id']); |
|
|
} |
|
|
|
|
|
if( isset($_REQUEST['id']) && is_numeric($_REQUEST['id']) ) |
|
|
{ |
|
|
$id = intval($_REQUEST['id']); |
|
|
} |
|
|
|
|
|
if($id >=0) |
|
|
{ |
|
|
$userid = (isset($_SESSION["sess_user_id"]) ? intval($_SESSION["sess_user_id"]) : 1); |
|
|
$map = db_fetch_assoc("select weathermap_maps.* from weathermap_auth,weathermap_maps where weathermap_maps.id=weathermap_auth.mapid and active='on' and (userid=".$userid." or userid=0) and weathermap_maps.id=".$id); |
|
|
|
|
|
if(sizeof($map)) |
|
|
{ |
|
|
$maptitle = $map[0]['titlecache']; |
|
|
|
|
|
html_graph_start_box(1,true); |
|
|
?> |
|
|
<tr bgcolor="<?php print $colors["panel"];?>"><td><table width="100%" cellpadding="0" cellspacing="0"><tr><td class="textHeader" nowrap><?php print $maptitle; ?></td></tr></table></td></tr> |
|
|
<?php |
|
|
print "<tr><td>"; |
|
|
|
|
|
# print "Generating map $id here now from ".$map[0]['configfile']; |
|
|
|
|
|
$confdir = dirname(__FILE__).'/configs/'; |
|
|
// everything else in this file is inside this else |
|
|
$mapname = $map[0]['configfile']; |
|
|
$mapfile = $confdir.'/'.$mapname; |
|
|
|
|
|
$orig_cwd = getcwd(); |
|
|
chdir(dirname(__FILE__)); |
|
|
|
|
|
$map = new WeatherMap; |
|
|
// $map->context = "cacti"; |
|
|
$map->rrdtool = read_config_option("path_rrdtool"); |
|
|
print "<pre>"; |
|
|
$map->ReadConfig($mapfile); |
|
|
$map->ReadData(); |
|
|
$map->DrawMap('null'); |
|
|
$map->PreloadMapHTML(); |
|
|
print "</pre>"; |
|
|
print ""; |
|
|
print "<img src='?action=liveviewimage&id=$id' />\n"; |
|
|
print $map->imap->subHTML("LEGEND:"); |
|
|
print $map->imap->subHTML("TIMESTAMP"); |
|
|
print $map->imap->subHTML("NODE:"); |
|
|
print $map->imap->subHTML("LINK:"); |
|
|
chdir($orig_cwd); |
|
|
|
|
|
print "</td></tr>"; |
|
|
html_graph_end_box(); |
|
|
} |
|
|
else |
|
|
{ |
|
|
print "Map unavailable."; |
|
|
} |
|
|
} |
|
|
else |
|
|
{ |
|
|
print "No ID, or unknown map name."; |
|
|
} |
|
|
|
|
|
|
|
|
weathermap_versionbox(); |
|
|
include_once($config["base_path"]."/include/bottom_footer.php"); |
|
|
break; |
|
|
|
|
|
case 'mrss': |
|
|
header('Content-type: application/rss+xml'); |
|
|
print '<?xml version="1.0" encoding="utf-8" standalone="yes"?>'."\n"; |
|
|
print '<rss xmlns:media="http://search.yahoo.com/mrss" version="2.0"><channel><title>My Network Weathermaps</title>'; |
|
|
$userid = (isset($_SESSION["sess_user_id"]) ? intval($_SESSION["sess_user_id"]) : 1); |
|
|
$maplist = db_fetch_assoc( "select distinct weathermap_maps.* from weathermap_auth,weathermap_maps where weathermap_maps.id=weathermap_auth.mapid and active='on' and (userid=".$userid." or userid=0) order by sortorder, id"); |
|
|
foreach ($maplist as $map) { |
|
|
$thumburl = "weathermap-cacti-plugin.php?action=viewthumb&id=".$map['filehash']."&time=".time(); |
|
|
$bigurl = "weathermap-cacti-plugin.php?action=viewimage&id=".$map['filehash']."&time=".time(); |
|
|
$linkurl = 'weathermap-cacti-plugin.php?action=viewmap&id='.$map['filehash']; |
|
|
$maptitle = $map['titlecache']; |
|
|
$guid = $map['filehash']; |
|
|
if($maptitle == '') $maptitle= "Map for config file: ".$map['configfile']; |
|
|
|
|
|
printf('<item><title>%s</title><description>Network Weathermap named "%s"</description><link>%s</link><media:thumbnail url="%s"/><media:content url="%s"/><guid isPermaLink="false">%s%s</guid></item>', |
|
|
$maptitle, $maptitle, $linkurl,$thumburl,$bigurl,$config['url_path'],$guid); |
|
|
print "\n"; |
|
|
} |
|
|
|
|
|
print '</channel></rss>'; |
|
|
break; |
|
|
|
case 'viewmapcycle': |
|
case 'viewmapcycle': |
include_once($config["base_path"]."/include/top_graph_header.php"); |
|
include_once($config["base_path"]."/include/top_graph_header.php"); |
print "<div id=\"overDiv\" style=\"position:absolute; visibility:hidden; z-index:1000;\"></div>\n"; |
|
print "<div id=\"overDiv\" style=\"position:absolute; visibility:hidden; z-index:1000;\"></div>\n"; |
print "<script type=\"text/javascript\" src=\"overlib.js\"><!-- overLIB (c) Erik Bosrup --></script> \n"; |
|
print "<script type=\"text/javascript\" src=\"overlib.js\"><!-- overLIB (c) Erik Bosrup --></script> \n"; |
weathermap_fullview(TRUE); |
|
weathermap_fullview(TRUE); |
Line 30... |
|
Line 214... |
|
|
|
case 'viewmap': |
|
case 'viewmap': |
include_once($config["base_path"]."/include/top_graph_header.php"); |
|
include_once($config["base_path"]."/include/top_graph_header.php"); |
print "<div id=\"overDiv\" style=\"position:absolute; visibility:hidden; z-index:1000;\"></div>\n"; |
|
print "<div id=\"overDiv\" style=\"position:absolute; visibility:hidden; z-index:1000;\"></div>\n"; |
print "<script type=\"text/javascript\" src=\"overlib.js\"><!-- overLIB (c) Erik Bosrup --></script> \n"; |
|
print "<script type=\"text/javascript\" src=\"overlib.js\"><!-- overLIB (c) Erik Bosrup --></script> \n"; |
|
|
|
|
|
$id = -1; |
|
|
|
|
|
if( isset($_REQUEST['id']) && (!is_numeric($_REQUEST['id']) || strlen($_REQUEST['id'])==20) ) |
|
|
{ |
|
|
$id = weathermap_translate_id($_REQUEST['id']); |
|
|
} |
|
|
|
if( isset($_REQUEST['id']) && is_numeric($_REQUEST['id']) ) |
|
if( isset($_REQUEST['id']) && is_numeric($_REQUEST['id']) ) |
{ |
|
{ |
weathermap_singleview($_REQUEST['id']); |
|
$id = intval($_REQUEST['id']); |
} |
|
} |
|
|
|
|
|
if($id>=0) |
|
|
{ |
|
|
weathermap_singleview($id); |
|
|
} |
|
|
|
weathermap_versionbox(); |
|
weathermap_versionbox(); |
|
|
|
include_once($config["base_path"]."/include/bottom_footer.php"); |
|
include_once($config["base_path"]."/include/bottom_footer.php"); |
break; |
|
break; |
default: |
|
default: |
include_once($config["base_path"]."/include/top_graph_header.php"); |
|
include_once($config["base_path"]."/include/top_graph_header.php"); |
print "<div id=\"overDiv\" style=\"position:absolute; visibility:hidden; z-index:1000;\"></div>\n"; |
|
print "<div id=\"overDiv\" style=\"position:absolute; visibility:hidden; z-index:1000;\"></div>\n"; |
print "<script type=\"text/javascript\" src=\"overlib.js\"><!-- overLIB (c) Erik Bosrup --></script> \n"; |
|
print "<script type=\"text/javascript\" src=\"overlib.js\"><!-- overLIB (c) Erik Bosrup --></script> \n"; |
|
|
|
|
|
$group_id = -1; |
|
|
if( isset($_REQUEST['group_id']) && (is_numeric($_REQUEST['group_id']) ) ) |
|
|
{ |
|
|
$group_id = intval($_REQUEST['group_id']); |
|
|
$_SESSION['wm_last_group'] = $group_id; |
|
|
} |
|
|
else |
|
|
{ |
|
|
if(isset($_SESSION['wm_last_group'])) |
|
|
{ |
|
|
$group_id = intval($_SESSION['wm_last_group']); |
|
|
} |
|
|
} |
|
|
|
|
|
$tabs = weathermap_get_valid_tabs(); |
|
|
$tab_ids = array_keys($tabs); |
|
|
if( ($group_id == -1) && (sizeof($tab_ids)>0)) |
|
|
{ |
|
|
$group_id = $tab_ids[0]; |
|
|
} |
|
|
|
if(read_config_option("weathermap_pagestyle") == 0) |
|
if(read_config_option("weathermap_pagestyle") == 0) |
{ |
|
{ |
weathermap_thumbview(); |
|
weathermap_thumbview($group_id); |
} |
|
} |
if(read_config_option("weathermap_pagestyle") == 1) |
|
if(read_config_option("weathermap_pagestyle") == 1) |
{ |
|
{ |
weathermap_fullview(); |
|
weathermap_fullview(FALSE,FALSE,$group_id); |
|
|
} |
|
|
if(read_config_option("weathermap_pagestyle") == 2) |
|
|
{ |
|
|
weathermap_fullview(FALSE, TRUE, $group_id); |
} |
|
} |
|
|
|
weathermap_versionbox(); |
|
weathermap_versionbox(); |
include_once($config["base_path"]."/include/bottom_footer.php"); |
|
include_once($config["base_path"]."/include/bottom_footer.php"); |
break; |
|
break; |
Line 67... |
|
Line 289... |
} |
|
} |
|
|
|
function weathermap_singleview($mapid) |
|
function weathermap_singleview($mapid) |
{ |
|
{ |
global $colors; |
|
global $colors; |
|
|
|
|
|
$is_wm_admin = false; |
|
|
|
$outdir = dirname(__FILE__).'/output/'; |
|
$outdir = dirname(__FILE__).'/output/'; |
$confdir = dirname(__FILE__).'/configs/'; |
|
$confdir = dirname(__FILE__).'/configs/'; |
|
|
|
// $map = db_fetch_assoc("select * from weathermap_maps where id=".$mapid); |
|
$userid = (isset($_SESSION["sess_user_id"]) ? intval($_SESSION["sess_user_id"]) : 1); |
$map = db_fetch_assoc("select weathermap_maps.* from weathermap_auth,weathermap_maps where weathermap_maps.id=weathermap_auth.mapid and active='on' and (userid=".$_SESSION["sess_user_id"]." or userid=0) and weathermap_maps.id=".$mapid); |
|
$map = db_fetch_assoc("select weathermap_maps.* from weathermap_auth,weathermap_maps where weathermap_maps.id=weathermap_auth.mapid and active='on' and (userid=".$userid." or userid=0) and weathermap_maps.id=".$mapid); |
|
|
|
|
|
|
if(sizeof($map)) |
|
if(sizeof($map)) |
{ |
|
{ |
$htmlfile = $outdir."weathermap_".$map[0]['id'].".html"; |
|
# print do_hook_function ('weathermap_page_top', array($map[0]['id'], $map[0]['titlecache']) ); |
|
|
print do_hook_function ('weathermap_page_top', '' ); |
|
|
|
|
|
$htmlfile = $outdir.$map[0]['filehash'].".html"; |
$maptitle = $map[0]['titlecache']; |
|
$maptitle = $map[0]['titlecache']; |
if($maptitle == '') $maptitle= "Map for config file: ".$map[0]['configfile']; |
|
if($maptitle == '') $maptitle= "Map for config file: ".$map[0]['configfile']; |
|
|
|
|
|
weathermap_mapselector($mapid); |
|
|
|
html_graph_start_box(1,true); |
|
html_graph_start_box(1,true); |
?> |
|
?> |
<tr bgcolor="<?php print $colors["panel"];?>"> |
|
<tr bgcolor="<?php print $colors["panel"];?>"><td><table width="100%" cellpadding="0" cellspacing="0"><tr><td class="textHeader" nowrap><?php print $maptitle; |
<td> |
|
|
<table width="100%" cellpadding="0" cellspacing="0"> |
|
if($is_wm_admin) |
<tr> |
|
{ |
<td class="textHeader" nowrap><?php print $maptitle; ?></td> |
|
|
</tr> |
|
print "<span style='font-size: 80%'>"; |
</table> |
|
print "[ <a href='weathermap-cacti-plugin-mgmt.php?action=map_settings&id=".$mapid."'>Map Settings</a> |"; |
</td> |
|
print "<a href='weathermap-cacti-plugin-mgmt.php?action=perms_edit&id=".$mapid."'>Map Permissions</a> |"; |
</tr> |
|
print "<a href=''>Edit Map</a> ]"; |
|
|
print "</span>"; |
|
|
} |
|
|
|
|
|
|
|
|
?></td></tr></table></td></tr> |
<?php |
|
<?php |
// print "<tr><td><h2>".$maptitle."</h2></td></tr>"; |
|
|
print "<tr><td>"; |
|
print "<tr><td>"; |
|
|
|
if(file_exists($htmlfile)) |
|
if(file_exists($htmlfile)) |
{ |
|
{ |
include($htmlfile); |
|
include($htmlfile); |
Line 109... |
|
Line 343... |
$realm_id2 = 0; |
|
$realm_id2 = 0; |
|
|
|
if (isset($user_auth_realm_filenames[basename('weathermap-cacti-plugin.php')])) { |
|
if (isset($user_auth_realm_filenames[basename('weathermap-cacti-plugin.php')])) { |
$realm_id2 = $user_auth_realm_filenames[basename('weathermap-cacti-plugin.php')]; |
|
$realm_id2 = $user_auth_realm_filenames[basename('weathermap-cacti-plugin.php')]; |
} |
|
} |
|
|
|
|
|
$userid = (isset($_SESSION["sess_user_id"]) ? intval($_SESSION["sess_user_id"]) : 1); |
if ((db_fetch_assoc("select user_auth_realm.realm_id from user_auth_realm where user_auth_realm.us |
|
if ((db_fetch_assoc("select user_auth_realm.realm_id from user_auth_realm where user_auth_realm.us |
er_id='" . $_SESSION["sess_user_id"] . "' and user_auth_realm.realm_id='$realm_id2'")) || (empty($realm_id2))) { |
|
er_id='" . $userid . "' and user_auth_realm.realm_id='$realm_id2'")) || (empty($realm_id2))) { |
|
|
|
print " (If this message stays here for more than one poller cycle, then check your cacti.log file for errors!)"; |
|
print " (If this message stays here for more than one poller cycle, then check your cacti.log file for errors!)"; |
|
|
|
} |
|
} |
print "</em></div>"; |
|
print "</em></div>"; |
Line 132... |
|
Line 367... |
$realm_id2 = 0; |
|
$realm_id2 = 0; |
|
|
|
if (isset($user_auth_realm_filenames['weathermap-cacti-plugin-mgmt.php'])) { |
|
if (isset($user_auth_realm_filenames['weathermap-cacti-plugin-mgmt.php'])) { |
$realm_id2 = $user_auth_realm_filenames['weathermap-cacti-plugin-mgmt.php']; |
|
$realm_id2 = $user_auth_realm_filenames['weathermap-cacti-plugin-mgmt.php']; |
} |
|
} |
if ((db_fetch_assoc("select user_auth_realm.realm_id from user_auth_realm where user_auth_realm.user_id='" . $_SESSION["sess_user_id"] . "' and user_auth_realm.realm_id='$realm_id2'")) || (empty($realm_id2))) { |
|
$userid = (isset($_SESSION["sess_user_id"]) ? intval($_SESSION["sess_user_id"]) : 1); |
|
|
if ((db_fetch_assoc("select user_auth_realm.realm_id from user_auth_realm where user_auth_realm.user_id='" . $userid . "' and user_auth_realm.realm_id='$realm_id2'")) || (empty($realm_id2))) { |
|
|
|
print '<a href="' . $config['url_path'] . 'plugins/weathermap/weathermap-cacti-plugin-mgmt.php">Manage Maps</a>'; |
|
print '<a href="' . $config['url_path'] . 'plugins/weathermap/weathermap-cacti-plugin-mgmt.php">Manage Maps</a>'; |
} |
|
} |
} |
|
} |
|
|
|
function weathermap_thumbview() |
|
function weathermap_thumbview($limit_to_group = -1) |
{ |
|
{ |
global $colors; |
|
global $colors; |
|
|
|
$maplist = db_fetch_assoc( "select distinct weathermap_maps.* from weathermap_auth,weathermap_maps where weathermap_maps.id=weathermap_auth.mapid and active='on' and (userid=".$_SESSION["sess_user_id"]." or userid=0) order by sortorder, id"); |
|
$userid = (isset($_SESSION["sess_user_id"]) ? intval($_SESSION["sess_user_id"]) : 1); |
|
|
$maplist_SQL = "select distinct weathermap_maps.* from weathermap_auth,weathermap_maps where weathermap_maps.id=weathermap_auth.mapid and active='on' and "; |
|
|
if($limit_to_group >0) $maplist_SQL .= " weathermap_maps.group_id=".$limit_to_group." and "; |
|
|
$maplist_SQL .= " (userid=".$userid." or userid=0) order by sortorder, id"; |
|
|
|
|
|
$maplist = db_fetch_assoc( $maplist_SQL ); |
|
|
|
|
|
// if there's only one map, ignore the thumbnail setting and show it fullsize |
if(sizeof($maplist) == 1) |
|
if(sizeof($maplist) == 1) |
{ |
|
{ |
$pagetitle = "Network Weathermap"; |
|
$pagetitle = "Network Weathermap"; |
weathermap_fullview(); |
|
weathermap_fullview(FALSE,FALSE, $limit_to_group); |
} |
|
} |
else |
|
else |
{ |
|
{ |
$pagetitle = "Network Weathermaps"; |
|
$pagetitle = "Network Weathermaps"; |
|
|
|
Line 171... |
|
Line 412... |
<tr> |
|
<tr> |
<td><i>Click on thumbnails for a full view (or you can <a href="?action=viewmapcycle">automatically cycle</a> between full-size maps)</i></td> |
|
<td><i>Click on thumbnails for a full view (or you can <a href="?action=viewmapcycle">automatically cycle</a> between full-size maps)</i></td> |
</tr> |
|
</tr> |
<?php |
|
<?php |
html_graph_end_box(); |
|
html_graph_end_box(); |
|
|
$showlivelinks = intval(read_config_option("weathermap_live_view")); |
|
|
|
|
|
weathermap_tabs($limit_to_group); |
$i = 0; |
|
$i = 0; |
if (sizeof($maplist) > 0) |
|
if (sizeof($maplist) > 0) |
{ |
|
{ |
|
|
|
$outdir = dirname(__FILE__).'/output/'; |
|
$outdir = dirname(__FILE__).'/output/'; |
$confdir = dirname(__FILE__).'/configs/'; |
|
$confdir = dirname(__FILE__).'/configs/'; |
|
|
|
$imageformat = strtolower(read_config_option("weathermap_output_format")); |
|
$imageformat = strtolower(read_config_option("weathermap_output_format")); |
|
|
|
html_graph_start_box(1,true); |
|
html_graph_start_box(1,false); |
print "<tr><td>"; |
|
print "<tr><td class='wm_gallery'>"; |
foreach ($maplist as $map) { |
|
foreach ($maplist as $map) { |
$i++; |
|
$i++; |
|
|
|
$thumbfile = $outdir."weathermap_thumb_".$map['id'].".".$imageformat; |
|
$imgsize = ""; |
$thumburl = "output/weathermap_thumb_".$map['id'].".".$imageformat; |
|
# $thumbfile = $outdir."weathermap_thumb_".$map['id'].".".$imageformat; |
|
|
# $thumburl = "output/weathermap_thumb_".$map['id'].".".$imageformat."?time=".time(); |
|
|
$thumbfile = $outdir.$map['filehash'].".thumb.".$imageformat; |
|
|
$thumburl = "?action=viewthumb&id=".$map['filehash']."&time=".time(); |
|
|
if($map['thumb_width'] > 0) { $imgsize = ' WIDTH="'.$map['thumb_width'].'" HEIGHT="'.$map['thumb_height'].'" '; } |
$maptitle = $map['titlecache']; |
|
$maptitle = $map['titlecache']; |
if($maptitle == '') $maptitle= "Map for config file: ".$map['configfile']; |
|
if($maptitle == '') $maptitle= "Map for config file: ".$map['configfile']; |
|
|
|
print '<div class="wm_thumbcontainer" style="margin: 2px; border: 1px solid #bbbbbb; padding: 2px; float:left;">'; |
|
print '<div class="wm_thumbcontainer" style="margin: 2px; border: 1px solid #bbbbbb; padding: 2px; float:left;">'; |
if(file_exists($thumbfile)) |
|
if(file_exists($thumbfile)) |
{ |
|
{ |
print '<div class="wm_thumbtitle" style="font-size: 1.2em; font-weight: bold; text-align: center">'.$maptitle.'</div><a href="weathermap-cacti-plugin.php?action=viewmap&id='.$map['id'].'"><img class="wm_thumb" src="'.$thumburl.'" alt="'.$maptitle.'" border="0" hspace="5" vspace="5" title="'.$maptitle.'"/></a>'; |
|
print '<div class="wm_thumbtitle" style="font-size: 1.2em; font-weight: bold; text-align: center">'.$maptitle.'</div><a href="weathermap-cacti-plugin.php?action=viewmap&id='.$map['filehash'].'"><img class="wm_thumb" '.$imgsize.'src="'.$thumburl.'" alt="'.$maptitle.'" border="0" hspace="5" vspace="5" title="'.$maptitle.'"/></a>'; |
} |
|
} |
else |
|
else |
{ |
|
{ |
print "(thumbnail for map ".$map['id']." not created yet)"; |
|
print "(thumbnail for map not created yet)"; |
|
|
} |
|
|
if($showlivelinks==1) |
|
|
{ |
|
|
print "<a href='?action=liveview&id=".$map['filehash']."'>(live)</a>"; |
} |
|
} |
print '</div> '; |
|
print '</div> '; |
} |
|
} |
print "</td></tr>"; |
|
print "</td></tr>"; |
html_graph_end_box(); |
|
html_graph_end_box(); |
|
|
|
} |
|
} |
else |
|
else |
{ |
|
{ |
print "<div align=\"center\" style=\"padding:20px\"><em>You Have No Maps</em></div>\n"; |
|
print "<div align=\"center\" style=\"padding:20px\"><em>You Have No Maps</em></div>\n"; |
} |
|
} |
} |
|
} |
} |
|
} |
|
|
|
function weathermap_fullview($cycle=FALSE) |
|
function weathermap_fullview($cycle=FALSE, $firstonly=FALSE, $limit_to_group = -1) |
{ |
|
{ |
global $colors; |
|
global $colors; |
|
|
|
$_SESSION['custom']=false; |
|
$_SESSION['custom']=false; |
|
|
|
$maplist = db_fetch_assoc( "select distinct weathermap_maps.* from weathermap_auth,weathermap_maps where weathermap_maps.id=weathermap_auth.mapid and active='on' and (userid=".$_SESSION["sess_user_id"]." or userid=0) order by sortorder, id"); |
|
$userid = (isset($_SESSION["sess_user_id"]) ? intval($_SESSION["sess_user_id"]) : 1); |
|
|
# $query = "select distinct weathermap_maps.* from weathermap_auth,weathermap_maps where weathermap_maps.id=weathermap_auth.mapid and active='on' and (userid=".$userid." or userid=0) order by sortorder, id"; |
|
|
$maplist_SQL = "select distinct weathermap_maps.* from weathermap_auth,weathermap_maps where weathermap_maps.id=weathermap_auth.mapid and active='on' and "; |
|
|
if($limit_to_group >0) $maplist_SQL .= " weathermap_maps.group_id=".$limit_to_group." and "; |
|
|
$maplist_SQL .= " (userid=".$userid." or userid=0) order by sortorder, id"; |
|
|
|
|
|
if($firstonly) { $maplist_SQL .= " LIMIT 1"; } |
|
|
|
|
|
$maplist = db_fetch_assoc( $maplist_SQL ); |
html_graph_start_box(2,true); |
|
html_graph_start_box(2,true); |
|
|
|
if(sizeof($maplist) == 1) |
|
if(sizeof($maplist) == 1) |
{ |
|
{ |
$pagetitle = "Network Weathermap"; |
|
$pagetitle = "Network Weathermap"; |
Line 251... |
|
Line 510... |
</td> |
|
</td> |
</tr> |
|
</tr> |
<?php |
|
<?php |
html_graph_end_box(); |
|
html_graph_end_box(); |
|
|
|
|
|
weathermap_tabs($limit_to_group); |
|
|
|
$i = 0; |
|
$i = 0; |
if (sizeof($maplist) > 0) |
|
if (sizeof($maplist) > 0) |
{ |
|
{ |
|
|
|
$outdir = dirname(__FILE__).'/output/'; |
|
$outdir = dirname(__FILE__).'/output/'; |
$confdir = dirname(__FILE__).'/configs/'; |
|
$confdir = dirname(__FILE__).'/configs/'; |
foreach ($maplist as $map) |
|
foreach ($maplist as $map) |
{ |
|
{ |
$i++; |
|
$i++; |
$htmlfile = $outdir."weathermap_".$map['id'].".html"; |
|
$htmlfile = $outdir.$map['filehash'].".html"; |
$maptitle = $map['titlecache']; |
|
$maptitle = $map['titlecache']; |
if($maptitle == '') $maptitle= "Map for config file: ".$map['configfile']; |
|
if($maptitle == '') $maptitle= "Map for config file: ".$map['configfile']; |
|
|
|
print '<div class="weathermapholder" id="mapholder_'.$map['id'].'">'; |
|
print '<div class="weathermapholder" id="mapholder_'.$map['filehash'].'">'; |
html_graph_start_box(1,true); |
|
html_graph_start_box(1,true); |
|
|
print '<tr bgcolor="#' . $colors["header_panel"] . '">'; |
?> |
|
?> |
<tr bgcolor="#<?php print $colors["header_panel"];?>"> |
|
|
<td colspan="3"> |
|
<td colspan="3"> |
<table width="100%" cellspacing="0" cellpadding="3" border="0"> |
|
<table width="100%" cellspacing="0" cellpadding="3" border="0"> |
<tr> |
|
<tr> |
<td align="left" class="textHeaderDark"><a name="map_<?php echo $map['id']; ?>"></a> |
|
<td align="left" class="textHeaderDark"> |
<?php print htmlspecialchars($maptitle); ?> |
|
<a name="map_<?php echo $map['filehash']; ?>"></a> |
</td> |
|
<?php print htmlspecialchars($maptitle); ?> |
|
|
</td> |
</tr> |
|
</tr> |
</table> |
|
</table> |
</td> |
|
</td> |
</tr> |
|
</tr> |
<tr> |
|
<tr> |
<td> |
|
<td> |
<?php |
|
<?php |
|
|
|
if(file_exists($htmlfile)) |
|
if(file_exists($htmlfile)) |
{ |
|
{ |
include($htmlfile); |
|
include($htmlfile); |
Line 404... |
|
Line 666... |
{ |
|
{ |
print "<div align=\"center\" style=\"padding:20px\"><em>You Have No Maps</em></div>\n"; |
|
print "<div align=\"center\" style=\"padding:20px\"><em>You Have No Maps</em></div>\n"; |
} |
|
} |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
function weathermap_translate_id($idname) |
|
|
{ |
|
|
$SQL = "select id from weathermap_maps where configfile='".mysql_real_escape_string($idname)."' or filehash='".mysql_real_escape_string($idname)."'"; |
|
|
$map = db_fetch_assoc($SQL); |
|
|
|
|
|
return($map[0]['id']); |
} |
|
} |
|
|
|
function weathermap_versionbox() |
|
function weathermap_versionbox() |
{ |
|
{ |
global $WEATHERMAP_VERSION, $colors; |
|
global $WEATHERMAP_VERSION, $colors; |
; |
|
global $config, $user_auth_realms, $user_auth_realm_filenames; |
|
|
|
$pagefoot = "Powered by <a href=\"http://www.network-weathermap.com/?v=$WEATHERMAP_VERSION\">PHP Weathermap version $WEATHERMAP_VERSION</a>"; |
|
$pagefoot = "Powered by <a href=\"http://www.network-weathermap.com/?v=$WEATHERMAP_VERSION\">PHP Weathermap version $WEATHERMAP_VERSION</a>"; |
|
|
|
|
|
$realm_id2 = 0; |
|
|
|
|
|
if (isset($user_auth_realm_filenames['weathermap-cacti-plugin-mgmt.php'])) { |
|
|
$realm_id2 = $user_auth_realm_filenames['weathermap-cacti-plugin-mgmt.php']; |
|
|
} |
|
|
$userid = (isset($_SESSION["sess_user_id"]) ? intval($_SESSION["sess_user_id"]) : 1); |
|
|
if ((db_fetch_assoc("select user_auth_realm.realm_id from user_auth_realm where user_auth_realm.user_id='" . $userid . "' and user_auth_realm.realm_id='$realm_id2'")) || (empty($realm_id2))) |
|
|
{ |
|
|
$pagefoot .= " --- <a href='weathermap-cacti-plugin-mgmt.php' title='Go to the map management page'>Weathermap Management</a>"; |
|
|
$pagefoot .= " | <a target=\"_blank\" href=\"docs/\">Local Documentation</a>"; |
|
|
$pagefoot .= " | <a target=\"_blank\" href=\"editor.php\">Editor</a>"; |
|
|
} |
|
|
|
|
|
|
html_graph_start_box(1,true); |
|
html_graph_start_box(1,true); |
|
|
|
?> |
|
?> |
<tr bgcolor="<?php print $colors["panel"];?>"> |
|
<tr bgcolor="<?php print $colors["panel"];?>"> |
<td> |
|
<td> |
<table width="100%" cellpadding="0" cellspacing="0"> |
|
<table width="100%" cellpadding="0" cellspacing="0"> |
<tr> |
|
<tr> |
<td class="textHeader" nowrap> <?php print $pagefoot; ?> </td> |
|
<td class="textHeader" nowrap> <?php print $pagefoot; ?> </td> |
</tr> |
|
</tr> |
</table> |
|
</table> |
</td> |
|
</td> |
</tr> |
|
</tr> |
<?php |
|
<?php |
html_graph_end_box(); |
|
html_graph_end_box(); |
} |
|
} |
|
|
|
|
|
|
|
|
function readfile_chunked($filename) { |
|
|
$chunksize = 1*(1024*1024); // how many bytes per chunk |
|
|
$buffer = ''; |
|
|
$cnt =0; |
|
|
|
|
|
$handle = fopen($filename, 'rb'); |
|
|
if ($handle === false) return false; |
|
|
|
|
|
while (!feof($handle)) { |
|
|
$buffer = fread($handle, $chunksize); |
|
|
echo $buffer; |
|
|
} |
|
|
$status = fclose($handle); |
|
|
return $status; |
|
|
} |
|
|
|
|
|
function weathermap_footer_links() |
|
|
{ |
|
|
global $colors; |
|
|
global $WEATHERMAP_VERSION; |
|
|
print '<br />'; |
|
|
html_start_box("<center><a target=\"_blank\" class=\"linkOverDark\" href=\"docs/\">Local Documentation</a> -- <a target=\"_blank\" class=\"linkOverDark\" href=\"http://www.network-weathermap.com/\">Weathermap Website</a> -- <a target=\"_target\" class=\"linkOverDark\" href=\"weathermap-cacti-plugin-editor.php?plug=1\">Weathermap Editor</a> -- This is version $WEATHERMAP_VERSION</center>", "78%", $colors["header"], "2", "center", ""); |
|
|
html_end_box(); |
|
|
} |
|
|
|
|
|
function weathermap_mapselector($current_id = 0) |
|
|
{ |
|
|
global $colors; |
|
|
|
|
|
$show_selector = intval(read_config_option("weathermap_map_selector")); |
|
|
|
|
|
if($show_selector == 0) return false; |
|
|
|
|
|
$userid = (isset($_SESSION["sess_user_id"]) ? intval($_SESSION["sess_user_id"]) : 1); |
|
|
$maps = db_fetch_assoc("select distinct weathermap_maps.*,weathermap_groups.name, weathermap_groups.sortorder as gsort from weathermap_groups,weathermap_auth,weathermap_maps where weathermap_maps.group_id=weathermap_groups.id and weathermap_maps.id=weathermap_auth.mapid and active='on' and (userid=".$userid." or userid=0) order by gsort, sortorder"); |
|
|
|
|
|
if(sizeof($maps)>1) |
|
|
{ |
|
|
|
|
|
/* include graph view filter selector */ |
|
|
html_graph_start_box(3, TRUE); |
|
|
?> |
|
|
<tr bgcolor="<?php print $colors["panel"];?>" class="noprint"> |
|
|
<form name="weathermap_select" method="post" action=""> |
|
|
<input name="action" value="viewmap" type="hidden"> |
|
|
<td class="noprint"> |
|
|
<table width="100%" cellpadding="0" cellspacing="0"> |
|
|
<tr class="noprint"> |
|
|
<td nowrap style='white-space: nowrap;' width="40"> |
|
|
<strong>Jump To Map:</strong> |
|
|
</td> |
|
|
<td> |
|
|
<select name="id"> |
|
|
<?php |
|
|
|
|
|
$ngroups = 0; |
|
|
$lastgroup = "------lasdjflkjsdlfkjlksdjflksjdflkjsldjlkjsd"; |
|
|
foreach ($maps as $map) |
|
|
{ |
|
|
if($current_id == $map['id']) $nullhash = $map['filehash']; |
|
|
if($map['name'] != $lastgroup) |
|
|
{ |
|
|
$ngroups++; |
|
|
$lastgroup = $map['name']; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
$lastgroup = "------lasdjflkjsdlfkjlksdjflksjdflkjsldjlkjsd"; |
|
|
foreach ($maps as $map) |
|
|
{ |
|
|
if($ngroups>1 && $map['name'] != $lastgroup) |
|
|
{ |
|
|
print "<option style='font-weight: bold; font-style: italic' value='$nullhash'>".htmlspecialchars($map['name'])."</option>"; |
|
|
$lastgroup = $map['name']; |
|
|
} |
|
|
print '<option '; |
|
|
if($current_id == $map['id']) print " SELECTED "; |
|
|
print 'value="'.$map['filehash'].'">'; |
|
|
// if we're showing group headings, then indent the map names |
|
|
if($ngroups>1) { print " - "; } |
|
|
print htmlspecialchars($map['titlecache']).'</option>'; |
|
|
} |
|
|
?> |
|
|
</select> |
|
|
<input type="image" src="../../images/button_go.gif" alt="Go" border="0" align="absmiddle"> |
|
|
</td> |
|
|
</tr> |
|
|
</table> |
|
|
</td> |
|
|
</form> |
|
|
</tr> |
|
|
<?php |
|
|
|
|
|
html_graph_end_box(FALSE); |
|
|
} |
|
|
} |
|
|
|
|
|
function weathermap_get_valid_tabs() |
|
|
{ |
|
|
$tabs = array(); |
|
|
$userid = (isset($_SESSION["sess_user_id"]) ? intval($_SESSION["sess_user_id"]) : 1); |
|
|
$maps = db_fetch_assoc("select weathermap_maps.*, weathermap_groups.name as group_name from weathermap_auth,weathermap_maps, weathermap_groups where weathermap_groups.id=weathermap_maps.group_id and weathermap_maps.id=weathermap_auth.mapid and active='on' and (userid=".$userid." or userid=0) order by weathermap_groups.sortorder"); |
|
|
|
|
|
|
|
|
foreach ($maps as $map) |
|
|
{ |
|
|
$tabs[$map['group_id']] = $map['group_name']; |
|
|
} |
|
|
|
|
|
return($tabs); |
|
|
} |
|
|
|
|
|
function weathermap_tabs($current_tab) |
|
|
{ |
|
|
global $colors; |
|
|
|
|
|
// $current_tab=2; |
|
|
|
|
|
$tabs = weathermap_get_valid_tabs(); |
|
|
|
|
|
# print "Limiting to $current_tab\n"; |
|
|
|
|
|
if(sizeof($tabs) > 1) |
|
|
{ |
|
|
/* draw the categories tabs on the top of the page */ |
|
|
print "<p></p><table class='tabs' width='100%' cellspacing='0' cellpadding='3' align='center'><tr>\n"; |
|
|
|
|
|
if (sizeof($tabs) > 0) { |
|
|
$show_all = intval(read_config_option("weathermap_all_tab")); |
|
|
if($show_all == 1) |
|
|
{ |
|
|
$tabs['-2'] = "All Maps"; |
|
|
} |
|
|
|
|
|
foreach (array_keys($tabs) as $tab_short_name) { |
|
|
print "<td " . (($tab_short_name == $current_tab) ? "bgcolor='silver'" : "bgcolor='#DFDFDF'") . " nowrap='nowrap' width='" . (strlen($tabs[$tab_short_name]) * 9) . "' align='center' class='tab'> |
|
|
<span class='textHeader'><a href='weathermap-cacti-plugin.php?group_id=$tab_short_name'>$tabs[$tab_short_name]</a></span> |
|
|
</td>\n |
|
|
<td width='1'></td>\n"; |
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
print "<td></td>\n</tr></table>\n"; |
|
|
|
|
|
return(true); |
|
|
} |
|
|
else |
|
|
{ |
|
|
return(false); |
|
|
} |
|
|
|
|
|
} |
|
|
|
// vim:ts=4:sw=4: |
|
// vim:ts=4:sw=4: |
?> |
|
?> |
|
|
|