jablonka.czprosek.czf

weathermap

Subversion Repositories:
[/] [cacti-pick.php] - Blame information for rev 44

 

Line No. Rev Author Line
11simandl<?php
2 
313simandl// ******************************************
4// sensible defaults
5$mapdir='configs';
6$cacti_base = '../../';
7$cacti_url = '/';
8$ignore_cacti=FALSE;
9 
10@include_once('editor-config.php');
11 
12if( is_dir($cacti_base) && file_exists($cacti_base."/include/config.php") )
13{
14 // include the cacti-config, so we know about the database
15 include_once($cacti_base."/include/config.php");
16 
17 // CHANGE: this to be the URL of the base of your Cacti install
18 // it MUST end with a / character!
19 $config['base_url']=$cacti_url;
20 $cacti_found=TRUE;
21}
22else
23{
24 $cacti_found = FALSE;
25}
26 
27// ******************************************
28 
291simandlfunction js_escape($str)
30{
31 $str = str_replace('\\', '\\\\', $str);
32 $str = str_replace("'", "\\\'", $str);
33 
34 $str = "'".$str."'";
35 
36 return($str);
37}
38 
3913simandlif(isset($_REQUEST['command']) && $_REQUEST["command"]=='link_step2')
401simandl{
41 $dataid = intval($_REQUEST['dataid']);
42 
43 $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;";
44 
45 $link = mysql_connect($database_hostname,$database_username,$database_password)
46 or die('Could not connect: ' . mysql_error());
47 mysql_selectdb($database_default,$link) or die('Could not select database: '.mysql_error());
48 
49 $result = mysql_query($SQL_graphid) or die('Query failed: ' . mysql_error());
50 $line = mysql_fetch_array($result, MYSQL_ASSOC);
51 $graphid = $line['local_graph_id'];
52 
53?>
54<html>
55<head>
56 
57 <script type="text/javascript">
58 function update_source_step2(graphid)
59 {
60 var graph_url, hover_url;
61 
62 var base_url = '<?php echo isset($config['base_url'])?$config['base_url']:''; ?>';
63 
64 if (typeof window.opener == "object") {
65 
66 graph_url = base_url + 'graph_image.php?local_graph_id=' + graphid + '&rra_id=0&graph_nolegend=true&graph_height=100&graph_width=300';
67 info_url = base_url + 'graph.php?rra_id=all&local_graph_id=' + graphid;
68 
69 opener.document.forms["frmMain"].link_infourl.value = info_url;
70 opener.document.forms["frmMain"].link_hover.value = graph_url;
71 }
72 self.close();
73 }
74 
75 window.onload = update_source_step2(<?php echo $graphid ?>);
76 
77 </script>
78</head>
79<body>
80This window should disappear in a moment.
81</body>
82</html>
83<?php
8413simandl // end of link step 2
851simandl}
8613simandl 
87if(isset($_REQUEST['command']) && $_REQUEST["command"]=='link_step1')
881simandl{
89?>
90<html>
91<head>
92 <script type="text/javascript">
93 
94 function update_source_step1(dataid,datasource)
95 {
96 var newlocation;
97 var fullpath;
98 
99 var rra_path = <?php echo js_escape($config['base_path']); ?>;
100 
101 if (typeof window.opener == "object") {
102 fullpath = datasource.replace(/<path_rra>/, rra_path + '/rra');
103 
104 opener.document.forms["frmMain"].link_target.value = fullpath;
105 }
106 if(document.forms['mini'].overlib.checked)
107 {
10813simandl newlocation = 'cacti-pick.php?command=link_step2&dataid=' + dataid;
1091simandl self.location = newlocation;
110 }
111 else
112 {
113 self.close();
114 }
115 }
116 </script>
117<style type="text/css">
118body { font-family: sans-serif; font-size: 10pt; }
119ul { list-style: none; margin: 0; padding: 0; }
120ul { border: 1px solid black; }
121ul li.row0 { background: #ddd;}
122ul li.row1 { background: #ccc;}
123ul li { border-bottom: 1px solid #aaa; border-top: 1px solid #eee; padding: 2px;}
124ul li a { text-decoration: none; color: black; }
125</style>
126<title>Pick a data source</title>
127</head>
128<body>
129 
130<?php
131 
132 // print "Cacti is ".$config["cacti_version"] = "0.8.6g";
133 
134 $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;";
135 $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;";
136 //$link = mysql_connect($database_hostname,$database_username,$database_password)
137 // or die('Could not connect: ' . mysql_error());
138 // mysql_selectdb($database_default,$link) or die('Could not select database: '.mysql_error());
139 
140 //$result = mysql_query($SQL_picklist) or die('Query failed: ' . mysql_error());
141?>
142<h3>Pick a data source:</h3>
143 
144<form name="mini">
145<input name="overlib" type="checkbox" value="yes" checked> Also set OVERLIBGRAPH and INFOURL.
146</form>
147<ul>
148<?php
149 $queryrows = db_fetch_assoc($SQL_picklist);
150 
151 // print $SQL_picklist;
152 
153 $i=0;
154 if( is_array($queryrows) )
155 {
156 foreach ($queryrows as $line) {
157 //while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
158 echo "<li class=\"row".($i%2)."\">";
159 $key = $line['local_data_id']."','".$line['data_source_path'];
160 echo "<a href=\"#\" onclick=\"update_source_step1('$key')\">". $line['name_cache'] . "</a>";
161 echo "</li>\n";
162 $i++;
163 }
164 }
165 else
166 {
167 print "No results...";
168 }
169 
170 // Free resultset
171 //mysql_free_result($result);
172 
173 // Closing connection
174 //mysql_close($link);
175 
176?>
177</ul>
178</body>
179</html>
180<?php
18113simandl} // end of link step 1
182 
183if(isset($_REQUEST['command']) && $_REQUEST["command"]=='node_step1')
184{
185?>
186<html>
187<head>
188 <script type="text/javascript">
189 
190 function update_source_step1(graphid)
191 {
192 var graph_url, hover_url;
193 
194 var base_url = '<?php echo isset($config['base_url'])?$config['base_url']:''; ?>';
195 
196 if (typeof window.opener == "object") {
197 
198 graph_url = base_url + 'graph_image.php?local_graph_id=' + graphid + '&rra_id=0&graph_nolegend=true&graph_height=100&graph_width=300';
199 info_url = base_url + 'graph.php?rra_id=all&local_graph_id=' + graphid;
200 
201 opener.document.forms["frmMain"].node_infourl.value = info_url;
202 opener.document.forms["frmMain"].node_hover.value = graph_url;
203 }
204 self.close();
205 }
206 </script>
207<style type="text/css">
208body { font-family: sans-serif; font-size: 10pt; }
209ul { list-style: none; margin: 0; padding: 0; }
210ul { border: 1px solid black; }
211ul li.row0 { background: #ddd;}
212ul li.row1 { background: #ccc;}
213ul li { border-bottom: 1px solid #aaa; border-top: 1px solid #eee; padding: 2px;}
214ul li a { text-decoration: none; color: black; }
215</style>
216<title>Pick a data source</title>
217</head>
218<body>
219 
220<?php
221 
222 # print "Cacti is ".$config["cacti_version"] = "0.8.6g";
223 
224# $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;";
225# $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;";
226 $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";
227 #$link = mysql_connect($database_hostname,$database_username,$database_password)
228 # or die('Could not connect: ' . mysql_error());
229 # mysql_selectdb($database_default,$link) or die('Could not select database: '.mysql_error());
230 
231 #$result = mysql_query($SQL_picklist) or die('Query failed: ' . mysql_error());
232?>
233<h3>Pick a graph:</h3>
234 
235<ul>
236<?php
237 $queryrows = db_fetch_assoc($SQL_picklist);
238 
239 // print $SQL_picklist;
240 
241 $i=0;
242 if( is_array($queryrows) )
243 {
244 foreach ($queryrows as $line) {
245 //while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
246 echo "<li class=\"row".($i%2)."\">";
247 $key = $line['local_graph_id'];
248 echo "<a href=\"#\" onclick=\"update_source_step1('$key')\">". $line['title_cache'] . "</a>";
249 echo "</li>\n";
250 $i++;
251 }
252 }
253 else
254 {
255 print "No results...";
256 }
257 
258 // Free resultset
259 //mysql_free_result($result);
260 
261 // Closing connection
262 //mysql_close($link);
263?>
264</ul>
265</body>
266</html>
267<?php
268} // end of node step 1
269 
2701simandl// vim:ts=4:sw=4:
271?>

Powered by WebSVN 2.2.1