jablonka.czprosek.czf

weathermap

Subversion Repositories:
[/] [cacti-pick.php] - Diff between revs 13 and 85

Show entire file Ignore whitespace

Rev 13 Rev 85
Line 4... Line 4...
// sensible defaults // sensible defaults
$mapdir='configs'; $mapdir='configs';
$cacti_base = '../../'; $cacti_base = '../../';
$cacti_url = '/'; $cacti_url = '/';
$ignore_cacti=FALSE; $ignore_cacti=FALSE;
   
  $config['base_url'] = $cacti_url;
   
@include_once('editor-config.php'); @include_once('editor-config.php');
   
if( is_dir($cacti_base) && file_exists($cacti_base."/include/config.php") ) // check if the goalposts have moved
  if( is_dir($cacti_base) && file_exists($cacti_base."/include/global.php") )
  {
  // include the cacti-config, so we know about the database
  include_once($cacti_base."/include/global.php");
  // $config['base_url'] = $cacti_url;
  $config['base_url'] = (isset($config['url_path'])? $config['url_path'] : $cacti_url);
  $cacti_found = TRUE;
  // print "global";
  }
  elseif( is_dir($cacti_base) && file_exists($cacti_base."/include/config.php") )
{ {
// include the cacti-config, so we know about the database // include the cacti-config, so we know about the database
include_once($cacti_base."/include/config.php"); include_once($cacti_base."/include/config.php");
   
// CHANGE: this to be the URL of the base of your Cacti install // $config['base_url'] = $cacti_url;
// it MUST end with a / character! $config['base_url'] = (isset($config['url_path'])? $config['url_path'] : $cacti_url);
$config['base_url']=$cacti_url; $cacti_found = TRUE;
$cacti_found=TRUE; // print "config";
} }
else else
{ {
$cacti_found = FALSE; $cacti_found = FALSE;
} }
   
  // print $config['base_url'];
   
// ****************************************** // ******************************************
   
function js_escape($str) function js_escape($str)
{ {
Line 51... Line 65...
$graphid = $line['local_graph_id']; $graphid = $line['local_graph_id'];
   
?> ?>
<html> <html>
<head> <head>
   
<script type="text/javascript"> <script type="text/javascript">
function update_source_step2(graphid) function update_source_step2(graphid)
{ {
var graph_url, hover_url; var graph_url, hover_url;
   
Line 87... Line 100...
if(isset($_REQUEST['command']) && $_REQUEST["command"]=='link_step1') if(isset($_REQUEST['command']) && $_REQUEST["command"]=='link_step1')
{ {
?> ?>
<html> <html>
<head> <head>
  <script type="text/javascript" src="editor-resources/jquery-latest.min.js"></script>
<script type="text/javascript"> <script type="text/javascript">
   
  function filterlist(previous)
  {
  var filterstring = $('input#filterstring').val();
   
  if(filterstring=='')
  {
  $('ul#dslist > li').show();
  return;
  }
   
  if(filterstring!=previous)
  {
  $('ul#dslist > li').hide();
  $("ul#dslist > li:contains('" + filterstring + "')").show();
  }
  }
   
  $(document).ready( function() {
  $('span.filter').keyup(function() {
  var previous = $('input#filterstring').val();
  setTimeout(function () {filterlist(previous)}, 500);
  }).show();
  });
   
function update_source_step1(dataid,datasource) function update_source_step1(dataid,datasource)
{ {
var newlocation; var newlocation;
var fullpath; var fullpath;
   
var rra_path = <?php echo js_escape($config['base_path']); ?>; var rra_path = <?php echo js_escape($config['rra_path']); ?>;
   
if (typeof window.opener == "object") { if (typeof window.opener == "object") {
fullpath = datasource.replace(/<path_rra>/, rra_path + '/rra'); fullpath = datasource.replace(/<path_rra>/, rra_path);
  if(document.forms['mini'].aggregate.checked)
opener.document.forms["frmMain"].link_target.value = fullpath; {
  opener.document.forms["frmMain"].link_target.value = opener.document.forms["frmMain"].link_target.value + " " + fullpath;
  }
  else
  {
  opener.document.forms["frmMain"].link_target.value = fullpath;
  }
} }
if(document.forms['mini'].overlib.checked) if(document.forms['mini'].overlib.checked)
{ {
newlocation = 'cacti-pick.php?command=link_step2&dataid=' + dataid; newlocation = 'cacti-pick.php?command=link_step2&dataid=' + dataid;
self.location = newlocation; self.location = newlocation;
Line 111... Line 155...
else else
{ {
self.close(); self.close();
} }
} }
   
  function applyDSFilterChange(objForm) {
  strURL = '?host_id=' + objForm.host_id.value;
  strURL = strURL + '&command=link_step1';
  if( objForm.overlib.checked)
  {
  strURL = strURL + "&overlib=1";
  }
  else
  {
  strURL = strURL + "&overlib=0";
  }
  // document.frmMain.link_bandwidth_out_cb.checked
  if( objForm.aggregate.checked)
  {
  strURL = strURL + "&aggregate=1";
  }
  else
  {
  strURL = strURL + "&aggregate=0";
  }
  document.location = strURL;
  }
   
</script> </script>
<style type="text/css"> <style type="text/css">
body { font-family: sans-serif; font-size: 10pt; } body { font-family: sans-serif; font-size: 10pt; }
ul { list-style: none; margin: 0; padding: 0; } ul { list-style: none; margin: 0; padding: 0; }
ul { border: 1px solid black; } ul { border: 1px solid black; }
Line 124... Line 192...
ul li a { text-decoration: none; color: black; } ul li a { text-decoration: none; color: black; }
</style> </style>
<title>Pick a data source</title> <title>Pick a data source</title>
</head> </head>
<body> <body>
   
<?php <?php
   
// print "Cacti is ".$config["cacti_version"] = "0.8.6g"; $SQL_picklist = "select data_local.host_id, data_template_data.local_data_id, data_template_data.name_cache, data_template_data.active, data_template_data.data_source_path from data_local,data_template_data,data_input,data_template where data_local.id=data_template_data.local_data_id and data_input.id=data_template_data.data_input_id and data_local.data_template_id=data_template.id ";
   
$SQL_picklist = "select data_template_data.local_data_id, data_template_data.name_cache, data_template_data.active, data_template_data.data_source_path from data_local,data_template_data,data_input,data_template left join data_input on data_input.id=data_template_data.data_input_id left join data_template on data_local.data_template_id=data_template.id where data_local.id=data_template_data.local_data_id order by name_cache;"; $host_id = -1;
$SQL_picklist = "select data_template_data.local_data_id, data_template_data.name_cache, data_template_data.active, data_template_data.data_source_path from data_local,data_template_data,data_input,data_template where data_local.id=data_template_data.local_data_id and data_input.id=data_template_data.data_input_id and data_local.data_template_id=data_template.id order by name_cache;";  
//$link = mysql_connect($database_hostname,$database_username,$database_password) $overlib = true;
// or die('Could not connect: ' . mysql_error()); $aggregate = false;
// mysql_selectdb($database_default,$link) or die('Could not select database: '.mysql_error());  
  if(isset($_REQUEST['aggregate'])) $aggregate = ( $_REQUEST['aggregate']==0 ? false : true);
//$result = mysql_query($SQL_picklist) or die('Query failed: ' . mysql_error()); if(isset($_REQUEST['overlib'])) $overlib= ( $_REQUEST['overlib']==0 ? false : true);
   
   
  if(isset($_REQUEST['host_id']))
  {
  $host_id = intval($_REQUEST['host_id']);
  if($host_id>=0) $SQL_picklist .= " and data_local.host_id=$host_id ";
  }
   
  $SQL_picklist .= " order by name_cache;";
   
  $hosts = db_fetch_assoc("select id,CONCAT_WS('',description,' (',hostname,')') as name from host order by description,hostname");
?> ?>
   
<h3>Pick a data source:</h3> <h3>Pick a data source:</h3>
   
<form name="mini"> <form name="mini">
<input name="overlib" type="checkbox" value="yes" checked> Also set OVERLIBGRAPH and INFOURL. <?php
</form> if(sizeof($hosts) > 0) {
<ul> print 'Host: <select name="host_id" onChange="applyDSFilterChange(document.mini)">';
<?php  
  print '<option '.($host_id==-1 ? 'SELECTED' : '' ).' value="-1">Any</option>';
  print '<option '.($host_id==0 ? 'SELECTED' : '' ).' value="0">None</option>';
  foreach ($hosts as $host)
  {
  print '<option ';
  if($host_id==$host['id']) print " SELECTED ";
  print 'value="'.$host['id'].'">'.$host['name'].'</option>';
  }
  print '</select><br />';
  }
   
  print '<span class="filter" style="display: none;">Filter: <input id="filterstring" name="filterstring" size="20"> (case-sensitive)<br /></span>';
  print '<input id="overlib" name="overlib" type="checkbox" value="yes" '.($overlib ? 'CHECKED' : '' ).'> <label for="overlib">Also set OVERLIBGRAPH and INFOURL.</label><br />';
  print '<input id="aggregate" name="aggregate" type="checkbox" value="yes" '.($aggregate ? 'CHECKED' : '' ).'> <label for="aggregate">Append TARGET to existing one (Aggregate)</label>';
   
  print '</form><div class="listcontainer"><ul id="dslist">';
   
$queryrows = db_fetch_assoc($SQL_picklist); $queryrows = db_fetch_assoc($SQL_picklist);
   
// print $SQL_picklist; // print $SQL_picklist;
   
$i=0; $i=0;
if( is_array($queryrows) ) if( is_array($queryrows) && sizeof($queryrows) > 0 )
{ {
foreach ($queryrows as $line) { foreach ($queryrows as $line) {
//while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) { //while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
echo "<li class=\"row".($i%2)."\">"; echo "<li class=\"row".($i%2)."\">";
$key = $line['local_data_id']."','".$line['data_source_path']; $key = $line['local_data_id']."','".$line['data_source_path'];
echo "<a href=\"#\" onclick=\"update_source_step1('$key')\">". $line['name_cache'] . "</a>"; echo "<a href=\"#\" onclick=\"update_source_step1('$key')\">". $line['name_cache'] . "</a>";
echo "</li>\n"; echo "</li>\n";
   
$i++; $i++;
} }
} }
else else
{ {
print "No results..."; print "<li>No results...</li>";
} }
   
// Free resultset // Free resultset
//mysql_free_result($result); //mysql_free_result($result);
   
// Closing connection // Closing connection
//mysql_close($link); //mysql_close($link);
   
?> ?>
</ul> </ul>
  </div>
</body> </body>
</html> </html>
<?php <?php
} // end of link step 1 } // end of link step 1
   
if(isset($_REQUEST['command']) && $_REQUEST["command"]=='node_step1') if(isset($_REQUEST['command']) && $_REQUEST["command"]=='node_step1')
{ {
  $host_id = -1;
  $SQL_picklist = "SELECT graph_templates_graph.id, graph_local.host_id, graph_templates_graph.local_graph_id, graph_templates_graph.height, graph_templates_graph.width, graph_templates_graph.title_cache, graph_templates.name, graph_local.host_id FROM (graph_local,graph_templates_graph) LEFT JOIN graph_templates ON (graph_local.graph_template_id=graph_templates.id) WHERE graph_local.id=graph_templates_graph.local_graph_id ";
   
  $overlib = true;
  $aggregate = false;
   
  if(isset($_REQUEST['aggregate'])) $aggregate = ( $_REQUEST['aggregate']==0 ? false : true);
  if(isset($_REQUEST['overlib'])) $overlib= ( $_REQUEST['overlib']==0 ? false : true);
   
   
  if(isset($_REQUEST['host_id']))
  {
  $host_id = intval($_REQUEST['host_id']);
  if($host_id>=0) $SQL_picklist .= " and graph_local.host_id=$host_id ";
  }
  $SQL_picklist .= " order by title_cache";
   
  $hosts = db_fetch_assoc("select id,CONCAT_WS('',description,' (',hostname,')') as name from host order by description,hostname");
   
?> ?>
<html> <html>
<head> <head>
  <script type="text/javascript" src="editor-resources/jquery-latest.min.js"></script>
  <script type="text/javascript">
   
  function filterlist(previous)
  {
  var filterstring = $('input#filterstring').val();
   
  if(filterstring=='')
  {
  $('ul#dslist > li').show();
  return;
  }
   
  if(filterstring!=previous)
  {
  $('ul#dslist > li').hide();
  $('ul#dslist > li').contains(filterstring).show();
  }
  }
   
  $(document).ready( function() {
  $('span.filter').keyup(function() {
  var previous = $('input#filterstring').val();
  setTimeout(function () {filterlist(previous)}, 500);
  }).show();
  });
   
  function applyDSFilterChange(objForm) {
  strURL = '?host_id=' + objForm.host_id.value;
  strURL = strURL + '&command=node_step1';
  if( objForm.overlib.checked)
  {
  strURL = strURL + "&overlib=1";
  }
  else
  {
  strURL = strURL + "&overlib=0";
  }
   
  //if( objForm.aggregate.checked)
  //{
  // strURL = strURL + "&aggregate=1";
  //}
  //else
  //{
  // strURL = strURL + "&aggregate=0";
  //}
  document.location = strURL;
  }
   
  </script>
<script type="text/javascript"> <script type="text/javascript">
   
function update_source_step1(graphid) function update_source_step1(graphid)
{ {
var graph_url, hover_url; var graph_url, hover_url;
   
var base_url = '<?php echo isset($config['base_url'])?$config['base_url']:''; ?>'; var base_url = '<?php echo isset($config['base_url'])?$config['base_url']:''; ?>';
   
if (typeof window.opener == "object") { if (typeof window.opener == "object") {
   
graph_url = base_url + 'graph_image.php?local_graph_id=' + graphid + '&rra_id=0&graph_nolegend=true&graph_height=100&graph_width=300'; graph_url = base_url + 'graph_image.php?rra_id=0&graph_nolegend=true&graph_height=100&graph_width=300&local_graph_id=' + graphid;
info_url = base_url + 'graph.php?rra_id=all&local_graph_id=' + graphid; info_url = base_url + 'graph.php?rra_id=all&local_graph_id=' + graphid;
   
opener.document.forms["frmMain"].node_infourl.value = info_url; // only set the overlib URL unless the box is checked
  if( document.forms['mini'].overlib.checked)
  {
  opener.document.forms["frmMain"].node_infourl.value = info_url;
  }
opener.document.forms["frmMain"].node_hover.value = graph_url; opener.document.forms["frmMain"].node_hover.value = graph_url;
} }
self.close(); self.close();
} }
</script> </script>
Line 211... Line 383...
ul li.row0 { background: #ddd;} ul li.row0 { background: #ddd;}
ul li.row1 { background: #ccc;} ul li.row1 { background: #ccc;}
ul li { border-bottom: 1px solid #aaa; border-top: 1px solid #eee; padding: 2px;} ul li { border-bottom: 1px solid #aaa; border-top: 1px solid #eee; padding: 2px;}
ul li a { text-decoration: none; color: black; } ul li a { text-decoration: none; color: black; }
</style> </style>
<title>Pick a data source</title> <title>Pick a graph</title>
</head> </head>
<body> <body>
   
<?php <?php
   
# print "Cacti is ".$config["cacti_version"] = "0.8.6g"; # print "Cacti is ".$config["cacti_version"];
   
# $SQL_picklist = "select data_template_data.local_data_id, data_template_data.name_cache, data_template_data.active, data_template_data.data_source_path from data_local,data_template_data,data_input,data_template left join data_input on data_input.id=data_template_data.data_input_id left join data_template on data_local.data_template_id=data_template.id where data_local.id=data_template_data.local_data_id order by name_cache;"; # $SQL_picklist = "select data_template_data.local_data_id, data_template_data.name_cache, data_template_data.active, data_template_data.data_source_path from data_local,data_template_data,data_input,data_template left join data_input on data_input.id=data_template_data.data_input_id left join data_template on data_local.data_template_id=data_template.id where data_local.id=data_template_data.local_data_id order by name_cache;";
# $SQL_picklist = "select data_template_data.local_data_id, data_template_data.name_cache, data_template_data.active, data_template_data.data_source_path from data_local,data_template_data,data_input,data_template where data_local.id=data_template_data.local_data_id and data_input.id=data_template_data.data_input_id and data_local.data_template_id=data_template.id order by name_cache;"; # $SQL_picklist = "select data_template_data.local_data_id, data_template_data.name_cache, data_template_data.active, data_template_data.data_source_path from data_local,data_template_data,data_input,data_template where data_local.id=data_template_data.local_data_id and data_input.id=data_template_data.data_input_id and data_local.data_template_id=data_template.id order by name_cache;";
$SQL_picklist = "SELECT graph_templates_graph.id, graph_templates_graph.local_graph_id, graph_templates_graph.height, graph_templates_graph.width, graph_templates_graph.title_cache, graph_templates.name, graph_local.host_id FROM (graph_local,graph_templates_graph) LEFT JOIN graph_templates ON (graph_local.graph_template_id=graph_templates.id) WHERE graph_local.id=graph_templates_graph.local_graph_id order by title_cache";  
   
   
#$link = mysql_connect($database_hostname,$database_username,$database_password) #$link = mysql_connect($database_hostname,$database_username,$database_password)
# or die('Could not connect: ' . mysql_error()); # or die('Could not connect: ' . mysql_error());
# mysql_selectdb($database_default,$link) or die('Could not select database: '.mysql_error()); # mysql_selectdb($database_default,$link) or die('Could not select database: '.mysql_error());
   
#$result = mysql_query($SQL_picklist) or die('Query failed: ' . mysql_error()); #$result = mysql_query($SQL_picklist) or die('Query failed: ' . mysql_error());
?> ?>
   
<h3>Pick a graph:</h3> <h3>Pick a graph:</h3>
   
<ul> <form name="mini">
<?php <?php
  if(sizeof($hosts) > 0) {
  print 'Host: <select name="host_id" onChange="applyDSFilterChange(document.mini)">';
   
  print '<option '.($host_id==-1 ? 'SELECTED' : '' ).' value="-1">Any</option>';
  print '<option '.($host_id==0 ? 'SELECTED' : '' ).' value="0">None</option>';
  foreach ($hosts as $host)
  {
  print '<option ';
  if($host_id==$host['id']) print " SELECTED ";
  print 'value="'.$host['id'].'">'.$host['name'].'</option>';
  }
  print '</select><br />';
  }
   
  print '<span class="filter" style="display: none;">Filter: <input id="filterstring" name="filterstring" size="20"> (case-sensitive)<br /></span>';
  print '<input id="overlib" name="overlib" type="checkbox" value="yes" '.($overlib ? 'CHECKED' : '' ).'> <label for="overlib">Set both OVERLIBGRAPH and INFOURL.</label><br />';
  // print '<input id="aggregate" name="aggregate" type="checkbox" value="yes" '.($aggregate ? 'CHECKED' : '' ).'> <label for="aggregate">Append TARGET to existing one (Aggregate)</label>';
   
  print '</form><div class="listcontainer"><ul id="dslist">';
   
$queryrows = db_fetch_assoc($SQL_picklist); $queryrows = db_fetch_assoc($SQL_picklist);
   
// print $SQL_picklist; // print $SQL_picklist;
   
$i=0; $i=0;
if( is_array($queryrows) ) if( is_array($queryrows) && sizeof($queryrows) > 0)
{ {
foreach ($queryrows as $line) { foreach ($queryrows as $line) {
//while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) { //while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
echo "<li class=\"row".($i%2)."\">"; echo "<li class=\"row".($i%2)."\">";
$key = $line['local_graph_id']; $key = $line['local_graph_id'];

Powered by WebSVN 2.2.1