gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r15052 - gauger/web


From: gnunet
Subject: [GNUnet-SVN] r15052 - gauger/web
Date: Wed, 20 Apr 2011 16:23:28 +0200

Author: bartpolot
Date: 2011-04-20 16:23:27 +0200 (Wed, 20 Apr 2011)
New Revision: 15052

Added:
   gauger/web/graphs
   gauger/web/helper.php
   gauger/web/hosts
Modified:
   gauger/web/.htaccess
   gauger/web/index.php
   gauger/web/template.php
   gauger/web/template_graph.php
   gauger/web/template_host.php
Log:
Changed URLs to RESTful format


Modified: gauger/web/.htaccess
===================================================================
--- gauger/web/.htaccess        2011-04-20 13:03:06 UTC (rev 15051)
+++ gauger/web/.htaccess        2011-04-20 14:23:27 UTC (rev 15052)
@@ -1,4 +1,12 @@
 <Files ~ "^.*\.conf">
 Order deny,allow
 Deny from all
-</Files>
\ No newline at end of file
+</Files>
+
+<FilesMatch "^hosts$"> 
+  ForceType application/x-httpd-php
+</FilesMatch>
+
+<FilesMatch "^graphs$"> 
+  ForceType application/x-httpd-php
+</FilesMatch>

Added: gauger/web/graphs
===================================================================
--- gauger/web/graphs                           (rev 0)
+++ gauger/web/graphs   2011-04-20 14:23:27 UTC (rev 15052)
@@ -0,0 +1,29 @@
+<?php
+
+$es = explode('/',$_SERVER['PATH_INFO']);
+// foreach($es as $i => $e) {
+//     $es[$i] = explode(',',$e);
+// }
+
+$basedir = preg_replace('/(.*)\/.*/','\1',$_SERVER['SCRIPT_NAME']);
+
+switch($_SERVER['REQUEST_METHOD']) {
+    case 'GET':
+        $_GET['graph'] = $es[1];
+        $_REQUEST['graph'] = $es[1];
+        include "helper.php";   // Auxiliary functions
+        include "params.php";   // Manage all parameters given by the user
+        include "explore.php";  // Gather all existing hosts and counters
+        init_params();
+        explore();
+// echo "<pre>";
+// print_r($_GET);
+// die();
+        include "template.php"; // Display info
+        break;
+    case 'POST':
+        echo "method is post";
+        break;
+    default:
+        echo "method is.. not allowed";
+}
\ No newline at end of file

Added: gauger/web/helper.php
===================================================================
--- gauger/web/helper.php                               (rev 0)
+++ gauger/web/helper.php       2011-04-20 14:23:27 UTC (rev 15052)
@@ -0,0 +1,24 @@
+<?php
+/** helper.php
+
+    This file is part of gauger.
+    Copyright 2011 Bartlomiej Polot
+
+    gauger is free software: you can redistribute it and/or modify
+    it under the terms of the GNU Affero General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    gauger is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU Affero General Public License for more details.
+
+    You should have received a copy of the GNU Affero General Public License
+    along with gauger.  If not, see <http://www.gnu.org/licenses/>.
+
+*/
+function url($r = '') {
+    global $basedir;
+    return $basedir.'/'.$r;
+}
\ No newline at end of file

Added: gauger/web/hosts
===================================================================
--- gauger/web/hosts                            (rev 0)
+++ gauger/web/hosts    2011-04-20 14:23:27 UTC (rev 15052)
@@ -0,0 +1,29 @@
+<?php
+
+$es = explode('/',$_SERVER['PATH_INFO']);
+// foreach($es as $i => $e) {
+//     $es[$i] = explode(',',$e);
+// }
+
+$basedir = preg_replace('/(.*)\/.*/','\1',$_SERVER['SCRIPT_NAME']);
+
+switch($_SERVER['REQUEST_METHOD']) {
+    case 'GET':
+        $_GET['host'] = $es[1];
+        $_REQUEST['host'] = $es[1];
+        include "helper.php";   // Auxiliary functions
+        include "params.php";   // Manage all parameters given by the user
+        include "explore.php";  // Gather all existing hosts and counters
+        init_params();
+        explore();
+// echo "<pre>";
+// print_r($_GET);
+// die();
+        include "template.php"; // Display info
+        break;
+    case 'POST':
+        echo "method is post";
+        break;
+    default:
+        echo "method is.. not allowed";
+}
\ No newline at end of file

Modified: gauger/web/index.php
===================================================================
--- gauger/web/index.php        2011-04-20 13:03:06 UTC (rev 15051)
+++ gauger/web/index.php        2011-04-20 14:23:27 UTC (rev 15052)
@@ -18,6 +18,8 @@
     along with gauger.  If not, see <http://www.gnu.org/licenses/>.
 
 */
+$basedir = preg_replace('/(.*)\/.*/','\1',$_SERVER['SCRIPT_NAME']);
+include "helper.php";
 include "params.php";   // Manage all parameters given by the user
 include "explore.php";  // Gather all existing hosts and counters
 init_params();

Modified: gauger/web/template.php
===================================================================
--- gauger/web/template.php     2011-04-20 13:03:06 UTC (rev 15051)
+++ gauger/web/template.php     2011-04-20 14:23:27 UTC (rev 15052)
@@ -25,13 +25,13 @@
         <meta http-equiv="content-type" content="text/html; charset=utf-8">
         <title>Gauger [<?php echo isset($current) && $current ? $current : 
get_counter_name($currentg) ?>]</title>
 
-        <link href="css/smoothness/jquery-ui-1.8.9.custom.css" 
rel="stylesheet" type="text/css"/> 
-        <script type="text/javascript" src="js/jquery-1.4.4.min.js"></script>
-        <script type="text/javascript" 
src="js/jquery-ui-1.8.9.custom.min.js"></script>
-        <script type="text/javascript" src="js/jCookie.js"></script>
+        <link href="<?php echo 
url("css/smoothness/jquery-ui-1.8.9.custom.css") ?>" rel="stylesheet" 
type="text/css"/> 
+        <script type="text/javascript" src="<?php echo 
url("js/jquery-1.4.4.min.js") ?>"></script>
+        <script type="text/javascript" src="<?php echo 
url("js/jquery-ui-1.8.9.custom.min.js") ?>"></script>
+        <script type="text/javascript" src="<?php echo url("js/jCookie.js") 
?>"></script>
 
-        <link rel="shortcut icon" href="images/favicon.png" />
-        <link href="css/style.css" type="text/css" rel="stylesheet">
+        <link rel="shortcut icon" href="<?php echo url("images/favicon.png") 
?>" />
+        <link href="<?php echo url("css/style.css") ?>" type="text/css" 
rel="stylesheet">
 
 
         <script type="text/javascript">
@@ -76,7 +76,7 @@
                                 if(this.id == "default_range_slider") {
                                     min = 
$(this).parents(".slider_control").find(".auto_min").attr('checked') ? "auto" : 
$(this).slider('values', 0);
                                     max = 
$(this).parents(".slider_control").find(".auto_max").attr('checked') ? "auto" : 
$(this).slider('values', 1);
-                                    $.get("ajax.php", {
+                                    $.get("<?php echo url("ajax.php") ?>", {
                                         x_min: min,
                                         x_max: max,
                                         persist: "true"
@@ -106,7 +106,7 @@
                         max = 
$(this).parents(".slider_control").find(".auto_max").attr('checked') ?
                                 "auto" :
                                 
$(this).parents(".slider_control").find(".slider-range").slider('values', 1);
-                        $.get("ajax.php", {
+                        $.get("<?php echo url("ajax.php") ?>", {
                             x_min: newmin,
                             x_max: max,
                             persist: "true"
@@ -138,7 +138,7 @@
                         min = 
$(this).parents(".slider_control").find(".auto_min").attr('checked') ?
                             "auto" :
                             
$(this).parents(".slider_control").find(".slider-range").slider('values', 0);
-                        $.get("ajax.php", {
+                        $.get("<?php echo url("ajax.php") ?>", {
                             x_min: min,
                             x_max: newmax,
                             persist: "true"
@@ -167,7 +167,7 @@
                         $( ".plot" ).each(function() {
                             this.src = this.src.replace(/&x_min=[^&]+/g, 
'')+"&x_min="+min;
                         });
-                        $.get("ajax.php", {
+                        $.get("<?php echo url("ajax.php") ?>", {
                             x_min: min,
                             persist: "true"
                         });
@@ -192,7 +192,7 @@
                         $( ".plot" ).each(function() {
                             this.src = this.src.replace(/&x_max=[^&]+/g, 
'')+"&x_max="+max;
                         });
-                        $.get("ajax.php", {
+                        $.get("<?php echo url("ajax.php") ?>", {
                             x_max: max,
                             persist: "true"
                         });
@@ -212,7 +212,7 @@
                 $( ".auto_y" ).click(function(){
                     var chk = this.checked;
                     min = chk ? "auto" : 
$("#change_origin_slider").slider('value');
-                    $.get("ajax.php", {
+                    $.get("<?php echo url("ajax.php") ?>", {
                         y_min: min,
                         persist: "true"
                     }, function(data) {
@@ -231,7 +231,7 @@
                         },
                         change: function( event, ui ) {
                                 
$(this).parents(".slider_control").find(".input_max").val(ui.value);
-                                $.get("ajax.php", {
+                                $.get("<?php echo url("ajax.php") ?>", {
                                     y_min: ui.value,
                                     persist: "true"
                                 }, function(data) {
@@ -254,7 +254,7 @@
                                 $("#left-range-x-input").val(ui.value);
                         },
                         change: function( event, ui ) {
-                                $.get("ajax.php", {
+                                $.get("<?php echo url("ajax.php") ?>", {
                                     png_x_size: ui.value,
                                     persist: "true"
                                 }, function(data) {
@@ -277,7 +277,7 @@
                                 $("#right-range-y-input").val(ui.value);
                         },
                         change: function( event, ui ) {
-                                $.get("ajax.php", {
+                                $.get("<?php echo url("ajax.php") ?>", {
                                     png_y_size: ui.value,
                                     persist: "true"
                                 }, function(data) {
@@ -321,10 +321,10 @@
                     ul = $(this).parents(".metric").find("ul");
                     ul.toggle();
                     if(ul.is(':visible')) {
-                        $(this).find("img").attr("src", "images/contract.png");
+                        $(this).find("img").attr("src", "<?php echo 
url("images/contract.png") ?>");
                         $.cookie(":::"+ul.attr("id"), "visible");
                     } else {
-                        $(this).find("img").attr("src", "images/expand.png");
+                        $(this).find("img").attr("src", "<?php echo 
url("images/expand.png") ?>");
                         $.cookie(":::"+ul.attr("id"), "hidden");
                     }
                 });
@@ -377,7 +377,7 @@
                     var links = 
$(".plot-host:checked").parents("li").find("a").get().reverse();
                     for(i in links) {
                         host = "" + links[i];
-                        hosts += sep + host.replace(/.*host=([^&]+).*/g, "$1");
+                        hosts += sep + host.replace(/.*hosts\/([^&]+).*/g, 
"$1");
                         sep = ",";
                     }
                     $(this).parents("tr").find(".plot").each(function() {
@@ -389,7 +389,7 @@
                     added = 
$(this).parents(".control-column").find(".added-metric").parents("li").find("a").get();
                     for(i in added) {
                         a = "" + added[i];
-                        a = a.replace(/.*graph=([^&]+).*/g, "$1");
+                        a = a.replace(/.*graphs\/([^&]+).*/g, "$1");
                         a = a.replace(/%20/g, " ");
                         if (x == a) {
                             return;
@@ -398,7 +398,7 @@
                     
$(this).parents(".control-column").find(".added-metrics").append(
                         '<li>\
                             <input type="checkbox" checked="checked" 
class="added-metric" onclick="rescan_added_hosts(this)">\
-                            <a href="index.php?graph=' + x + '" title="[' + 
get_category(x) + '] ' + get_name(x) + '">' + get_name(x) + '</a>\
+                            <a href="<?php echo url("graphs/") ?>' + x + '" 
title="[' + get_category(x) + '] ' + get_name(x) + '">' + get_name(x) + '</a>\
                         </li>'
                     );
                     u0 = 
get_unit($(this).parents("tr").find("option.same-unit-metric").val());
@@ -426,7 +426,7 @@
             var links = 
$(that).parents("ul").find(".added-metric:checked").parents("li").find("a").get().reverse();
             for(i in links) {
                 graph = "" + links[i];
-                graph = graph.replace(/.*graph=([^&]+).*/g, "$1");
+                graph = graph.replace(/.*graphs\/([^&]+).*/g, "$1");
                 graphs += sep + graph;
                 if(x == null) {
                     if(i == 0) {
@@ -518,8 +518,8 @@
         <div Id="debug"></div>
         <div class="header">
             <?php include "template_menu.php" ?>
-            <a href="index.php" class="name"><img src="images/l.png" /></a>
-            <p><a href="index.php" class="name">Gauger, performance recording 
tool</a></p>
+            <a href="<?php echo url() ?>" class="name"><img src="<?php echo 
url("images/l.png") ?>" /></a>
+            <p><a href="<?php echo url() ?>" class="name">Gauger, performance 
recording tool</a></p>
         </div>
         <div class="header-shadow"></div>
         <div class="container">
@@ -530,7 +530,7 @@
             <ul>
             <?php foreach ($hosts as $host => $counters): ?>
                     <li id="<?php echo $host ?>" class="search_item">
-                        <a href="?host=<?php echo $host ?>">
+                        <a href="<?php echo url("hosts/$host") ?>">
                             <?php echo $host ?>
                         </a>
                     </li>
@@ -544,11 +544,11 @@
                 <div class="metric">
                 <div class="metric_category_header">
                     <?php echo $category ? $category : 'Others' ?>
-                    <img class="expand_arrow" src="images/contract.png"></img>
+                    <img class="expand_arrow" src="<?php echo 
url("images/contract.png") ?>"></img>
                 </div>
                 <ul id="<?php echo $category ? $category : 'Others' ?>">
                 <?php foreach ($counters as $link => $name): ?>
-                    <li id="<?php echo $name ?>" class="search_item"><a 
href="?graph=<?php echo $link ?>">
+                    <li id="<?php echo $name ?>" class="search_item"><a 
href="<?php echo url("graphs/$link") ?>">
                         <?php echo $name . (get_counter_unit($link) ? ' (' . 
get_counter_unit($link) . ')' : '') ?>
                     </a></li>
                 <?php endforeach; ?>

Modified: gauger/web/template_graph.php
===================================================================
--- gauger/web/template_graph.php       2011-04-20 13:03:06 UTC (rev 15051)
+++ gauger/web/template_graph.php       2011-04-20 14:23:27 UTC (rev 15052)
@@ -53,7 +53,7 @@
                 <?php if(array_search($currentg, $counters) !== FALSE): ?>
                     <li>
                     <input type="checkbox" class="plot-host" checked="true"/>
-                    <a href="?host=<?php echo $host ?>" title="<?php echo 
$host ?>">
+                    <a href="<?php echo url("hosts/$host") ?>" title="<?php 
echo $host ?>">
                         <?php echo (strlen($host) > 10) ? 
substr($host,0,8).'...' : $host ?>
                     </a>
                     <br />
@@ -67,7 +67,7 @@
             </ul>
         </th>
         <td height="<?php echo get_session('png_y_size')+2 ?>" width="<?php 
echo get_session('png_x_size')+2 ?>">
-            <img class="plot" src="plot.php?g=<?php echo $currentg ?>" 
alt="loading..."/>
+            <img class="plot" src="<?php echo url("plot.php?g=$currentg") ?>" 
alt="loading..."/>
         </td>
     </tr>
 </table>

Modified: gauger/web/template_host.php
===================================================================
--- gauger/web/template_host.php        2011-04-20 13:03:06 UTC (rev 15051)
+++ gauger/web/template_host.php        2011-04-20 14:23:27 UTC (rev 15052)
@@ -31,17 +31,17 @@
     <?php $p = get_param('page', 1); $maxp = 
ceil(count($hosts[$current])/$PAGELENGTH) ?>
     <p class="pager">
         <?php if ($p >= 4): ?>
-        <a href="index.php?host=<?php echo $current ?>&amp;q=<?php echo $q 
?>&amp;page=1">1</a><?php if ($p > 4) echo " .. " ?>
+        <a href="<?php echo url("hosts/$current") ?>?q=<?php echo $q 
?>&amp;page=1">1</a><?php if ($p > 4) echo " .. " ?>
         <?php endif; ?>
         <?php for ($l = $p - 2; $l <= $p+2; $l++): ?>
             <?php if($l >= 1 && $l <= $maxp): ?>
             <?php if($l == $p) echo "[" ?>
-            <a href="index.php?host=<?php echo $current ?>&amp;q=<?php echo $q 
?>&amp;page=<?php echo $l ?>"><?php echo $l ?></a>
+            <a href="<?php echo url("hosts/$current") ?>?q=<?php echo $q 
?>&amp;page=<?php echo $l ?>"><?php echo $l ?></a>
             <?php if($l == $p) echo "]" ?>
             <?php endif; ?>
         <?php endfor; ?>
         <?php if ($p <= $maxp - 3): ?>
-        <?php if ($p < $maxp - 3) echo " .. " ?><a href="index.php?host=<?php 
echo $current ?>&amp;q=<?php echo $q ?>&amp;page=<?php echo $maxp ?>"><?php 
echo $maxp ?></a>
+        <?php if ($p < $maxp - 3) echo " .. " ?><a href="<?php echo 
url("hosts/$current") ?>?q=<?php echo $q ?>&amp;page=<?php echo $maxp ?>"><?php 
echo $maxp ?></a>
         <?php endif; ?>
     </p>
     <table>
@@ -75,7 +75,7 @@
                 <ul class="added-metrics">
                     <li>
                         <input type="checkbox" checked="checked" 
class="added-metric" disabled>
-                        <a href="?graph=<?php echo $counter ?>" title="<?php 
echo '['.get_counter_category($counter).'] '. get_counter_name($counter)?>">
+                        <a href="<?php echo url("graphs/$counter") ?>" 
title="<?php echo '['.get_counter_category($counter).'] '. 
get_counter_name($counter)?>">
                             <?php echo get_counter_name($counter) ?>
                         </a>
                     </li>
@@ -102,23 +102,23 @@
                 <p class="second-unit-metric">Secondary unit</p>
                 <p class="incompatible-unit-metric">Incompatible</p>
             </th>
-            <td height="<?php echo get_session('png_y_size')+2 ?>" 
width="<?php echo get_session('png_x_size')+2 ?>"><img class="plot" 
src="plot.php?h=<?php echo "$current&g=$counter" ?>" alt="loading..."/></td>
+            <td height="<?php echo get_session('png_y_size')+2 ?>" 
width="<?php echo get_session('png_x_size')+2 ?>"><img class="plot" src="<?php 
echo url("plot.php?h=$current&g=$counter") ?>" alt="loading..."/></td>
         </tr>
         <?php endfor; ?>
     </table>
     <p class="pager">
         <?php if ($p >= 4): ?>
-        <a href="index.php?host=<?php echo $current ?>&amp;q=<?php echo $q 
?>&amp;page=1">1</a><?php if ($p > 4) echo ".." ?>
+        <a href="<?php echo url("hosts/$current") ?>?q=<?php echo $q 
?>&amp;page=1">1</a><?php if ($p > 4) echo ".." ?>
         <?php endif; ?>
         <?php for ($l = $p - 2; $l <= $p+2; $l++): ?>
             <?php if($l >= 1 && $l <= $maxp): ?>
             <?php if($l == $p) echo "[" ?>
-            <a href="index.php?host=<?php echo $current ?>&amp;q=<?php echo $q 
?>&amp;page=<?php echo $l ?>"><?php echo $l ?></a>
+            <a href="<?php echo url("hosts/$current") ?>?q=<?php echo $q 
?>&amp;page=<?php echo $l ?>"><?php echo $l ?></a>
             <?php if($l == $p) echo "]" ?>
             <?php endif; ?>
         <?php endfor; ?>
         <?php if ($p <= $maxp - 3): ?>
-        <?php if ($p < $maxp - 3) echo ".." ?><a href="index.php?host=<?php 
echo $current ?>&amp;q=<?php echo $q ?>&amp;page=<?php echo $maxp ?>"><?php 
echo $maxp ?></a>
+        <?php if ($p < $maxp - 3) echo ".." ?><a href="<?php echo 
url("hosts/$current") ?>?q=<?php echo $q ?>&amp;page=<?php echo $maxp ?>"><?php 
echo $maxp ?></a>
         <?php endif; ?>
     </p>
     <?php else: ?>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]