It always bothered me that I couldn't send the view I was looking at to others via internal chat or email. If I wanted to send a link to a set of graphs from a search filter, I couldn't. Linking to multiple graphs via a host or data query view would work, but if I wanted a specific time period to be conveyed, I had to use a single graph view.
These changes will put a link on the time/search bar thingy that contains the time preset and search fields. You can then 'copy link location' or whatever your browser calls it. It doesn't do the exact time periods, you still have to use the graph.php magnifying glass thingy for that, but it will do last 2 hours, last month, etc.
It also adds some code that redirects the recipient back to a clean url after reading these variables into their session equivalents in the recipient browser.
In graph_view.php, at line 40ish, right after the input validation stuff:
Code: Select all
#redirect to a clean url after grabbing timespan and filter
if (isset($_REQUEST["predefined_timespan"])) {
$url = "http" . ((!empty($_SERVER['HTTPS'])) ? "s" : "") . "://". $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
if (isset($_REQUEST["filter"])) {
$_SESSION["sess_graph_view_filter"] = $_REQUEST["filter"];
}
if (preg_match("/predefined/i", "$url")) {
$_SESSION["sess_current_timespan"] = $_REQUEST["predefined_timespan"];
$url_arr = explode("&pre",$url);
$url = $url_arr[0];
header( "Location:$url" );
}
}
Code: Select all
<a href=<?php print "http" . ((!empty($_SERVER['HTTPS'])) ? "s" : "") . "://". $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . "&predefined_timespan=" . $_SESSION["sess_current_timespan"] . "&filter=" . $_SESSION["sess_graph_view_filter"];?>>Link to this view</a>
I've probably done some scary things here. Forgive me. Not really a programmer. Use at your peril.