Add scripts to create myops-getqueryview:
[myops.git] / web / view / index.php
1 <html>
2 <title>MyOps-View</title>
3 <head>
4 <!-- Every 5 minutes -->
5 <meta http-equiv="refresh" content="600">
6 </head>
7 <body style="width: 1340px;">
8 <?php
9
10 $f_list = file("urllist.txt");
11
12 $opts = array( 'hideLegend' => 'False', 
13                            'width' => '900', 
14                            'height' => '500' );
15                                 
16 print "Page rendered at <b>" . date("Y-m-d H:i:s e") . "</b>.  Refreshes every 10 minutes.";
17 $url = "http://" . $_SERVER['SERVER_NAME'] . ":5984/myops/_design/myops/index.html";
18 print "<br><a href='$url'>Raw MyOps-Query</a>";
19
20 $tag = NULL;
21 $show_all_default = True;
22 $tagcount = 0;
23 $tag_matches = False;
24 $t = "";
25 if ( isset($_REQUEST['tag']) )
26 {
27     $tag = $_REQUEST['tag'];
28         $show_all_default = False;
29 }
30
31 # there are three cases
32 # show thumbnails of everything
33 # show thumbnails of just one tag
34 # show large version of a thumbnail
35
36 foreach ( $f_list as $url )
37 {
38         $url = trim($url);
39         #print_r($show_all_default); print("sad<br>\n");
40         #print_r($tag); print(": tag<br>\n");
41         #print_r(isset($tag)); print(": tag<br>\n");
42         #print_r($tagcount); print(": tagcount<br>\n");
43         #print_r($tag_matches); print(": tag_matches<br>\n");
44         #print_r(preg_match("/#/", $url) > 0); print(": preg_match(#)<br>\n");
45         #print_r(strcmp(substr($url,1), $tag)); print(": strcmp: " . substr($url, 1) . "--" . $tag . "<BR>\n");
46         if ( $show_all_default || isset($tag) )
47         {
48                 if ( preg_match("/#/", $url) > 0 )
49                 {
50                         if ( strcmp(substr($url,1), $tag) == 0 )
51                         {
52                                 $tag_matches = True;
53                         } else {
54                                 $tag_matches = False;
55                         }
56                         if ( $tag_matches || $show_all_default ) {
57                                 if ( $tagcount >= 4  && $t != "") {
58                                 print "<a href='" . $_SERVER['PHP_SELF'] . "?tag=$t'>" . ($tagcount-4) ." more graphs...</a>\n";
59                                 }
60                                 $t = substr($url, 1);
61                             print "<br><hr><h3><a href='" . $_SERVER['PHP_SELF'] . "?tag=$t'>$t</a></h3>\n";
62                                 $tagcount = 0;
63                         }
64                 } else {
65                         if ( ( ( $tagcount < 4 && $show_all_default ) || $tag_matches )  && preg_match("/http/", $url) > 0 ) {
66                                 print "<a href='$url&" . http_build_query($opts) . "'><img src='$url' /></a>\n";
67                         } 
68                         $tagcount += 1;
69                 }
70         }
71 }
72
73 ?>
74 </body>
75 </html>