![]() ![]() |
weathermap |
Subversion Repositories: |
Compare with Previous - Blame - Download
<?phpinclude_once('editor-config.php');function js_escape($str){$str = str_replace('\\', '\\\\', $str);$str = str_replace("'", "\\\'", $str);$str = "'".$str."'";return($str);}if(isset($_REQUEST['command']) && $_REQUEST["command"]=='step2'){$dataid = intval($_REQUEST['dataid']);$SQL_graphid = "select graph_templates_item.local_graph_id, title_cache FROM graph_templates_item,graph_templates_graph,data_template_rrd where graph_templates_graph.local_graph_id = graph_templates_item.local_graph_id and task_item_id=data_template_rrd.id and local_data_id=$dataid LIMIT 1;";$link = mysql_connect($database_hostname,$database_username,$database_password)or die('Could not connect: ' . mysql_error());mysql_selectdb($database_default,$link) or die('Could not select database: '.mysql_error());$result = mysql_query($SQL_graphid) or die('Query failed: ' . mysql_error());$line = mysql_fetch_array($result, MYSQL_ASSOC);$graphid = $line['local_graph_id'];?><html><head><script type="text/javascript">function update_source_step2(graphid){var graph_url, hover_url;var base_url = '<?php echo isset($config['base_url'])?$config['base_url']:''; ?>';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';info_url = base_url + 'graph.php?rra_id=all&local_graph_id=' + graphid;opener.document.forms["frmMain"].link_infourl.value = info_url;opener.document.forms["frmMain"].link_hover.value = graph_url;}self.close();}window.onload = update_source_step2(<?php echo $graphid ?>);</script></head><body>This window should disappear in a moment.</body></html><?php}else{?><html><head><script type="text/javascript">function update_source_step1(dataid,datasource){var newlocation;var fullpath;var rra_path = <?php echo js_escape($config['base_path']); ?>;if (typeof window.opener == "object") {fullpath = datasource.replace(/<path_rra>/, rra_path + '/rra');opener.document.forms["frmMain"].link_target.value = fullpath;}if(document.forms['mini'].overlib.checked){newlocation = 'cacti-pick.php?command=step2&dataid=' + dataid;self.location = newlocation;}else{self.close();}}</script><style type="text/css">body { font-family: sans-serif; font-size: 10pt; }ul { list-style: none; margin: 0; padding: 0; }ul { border: 1px solid black; }ul li.row0 { background: #ddd;}ul li.row1 { background: #ccc;}ul li { border-bottom: 1px solid #aaa; border-top: 1px solid #eee; padding: 2px;}ul li a { text-decoration: none; color: black; }</style><title>Pick a data source</title></head><body><?php// print "Cacti is ".$config["cacti_version"] = "0.8.6g";$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;";//$link = mysql_connect($database_hostname,$database_username,$database_password)// or die('Could not connect: ' . 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());?><h3>Pick a data source:</h3><form name="mini"><input name="overlib" type="checkbox" value="yes" checked> Also set OVERLIBGRAPH and INFOURL.</form><ul><?php$queryrows = db_fetch_assoc($SQL_picklist);// print $SQL_picklist;$i=0;if( is_array($queryrows) ){foreach ($queryrows as $line) {//while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {echo "<li class=\"row".($i%2)."\">";$key = $line['local_data_id']."','".$line['data_source_path'];echo "<a href=\"#\" onclick=\"update_source_step1('$key')\">". $line['name_cache'] . "</a>";echo "</li>\n";$i++;}}else{print "No results...";}// Free resultset//mysql_free_result($result);// Closing connection//mysql_close($link);?></ul></body></html><?php} // end of step 1// vim:ts=4:sw=4:?>