gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r14594 - in gauger: . css


From: gnunet
Subject: [GNUnet-SVN] r14594 - in gauger: . css
Date: Fri, 4 Mar 2011 15:50:01 +0100

Author: bartpolot
Date: 2011-03-04 15:50:01 +0100 (Fri, 04 Mar 2011)
New Revision: 14594

Modified:
   gauger/ajax.php
   gauger/css/style.css
   gauger/explore.php
   gauger/index.php
   gauger/params.php
   gauger/plot.php
   gauger/template_host.php
Log:
Added search in host view, refactored io and session handling


Modified: gauger/ajax.php
===================================================================
--- gauger/ajax.php     2011-03-04 12:46:38 UTC (rev 14593)
+++ gauger/ajax.php     2011-03-04 14:50:01 UTC (rev 14594)
@@ -20,6 +20,8 @@
 */
 include "explore.php";
 include "params.php";
+init_params();
+explore();
 
 process_range();
 

Modified: gauger/css/style.css
===================================================================
--- gauger/css/style.css        2011-03-04 12:46:38 UTC (rev 14593)
+++ gauger/css/style.css        2011-03-04 14:50:01 UTC (rev 14594)
@@ -149,12 +149,14 @@
     margin-bottom:      5px;
 }
 
-#instant_search_main {
+#search_host {
     float:              right;
-    position:           relative;
-    margin-top:         -31px;
 }
 
+.hidden_input {
+    display:            none;
+}
+
 .search_item {
     display:            none;
 }

Modified: gauger/explore.php
===================================================================
--- gauger/explore.php  2011-03-04 12:46:38 UTC (rev 14593)
+++ gauger/explore.php  2011-03-04 14:50:01 UTC (rev 14594)
@@ -22,6 +22,9 @@
 $DATADIR = array_key_exists('data', $CONF) && $CONF["data"] ? $CONF['data'] : 
'data/';
 $PAGELENGTH = array_key_exists('page_length', $CONF) && $CONF['page_lenght'] ? 
$CONF['page_lenght'] : 5;
 if ($DATADIR[strlen($DATADIR)-1] != '/') $DATADIR .= '/';
+$hosts = array();
+$metrics = array();
+$metrics_c = array();
 
 function get_counter_name($s) {
     $s = str_replace('-SLASH-', '/', $s);
@@ -89,36 +92,39 @@
     return $lm ? $lm : 1;
 }
 
-$d = dir($DATADIR);
-$hosts = array();
-$metrics = array();
-$metrics_c = array();
-while (false !== ($entry = $d->read())) {
-    if (is_dir($DATADIR.$entry) && !($entry[0] == ".")) {
-        $hosts[$entry] = array();
-        $d2 = dir($DATADIR.$entry);
-        while (false !== ($counter = $d2->read())) {
-            // Do not include files containing dots or tildes or incomplete 
files
-            if (preg_match("/(\.|~)/", $counter) === 0 && 
is_file("$DATADIR$entry/$counter.dat")) {
-                $hosts[$entry][] = $counter;
-                $metrics[$counter] = get_counter_name($counter);
-                $metrics_c[get_counter_category($counter)][$counter] = 
get_counter_name($counter);
+function explore() {
+    global $DATADIR;
+    global $hosts;
+    global $metrics;
+    global $metrics_c;
+    global $q;
+    $d = dir($DATADIR);
+    while (false !== ($entry = $d->read())) {
+        if (is_dir($DATADIR.$entry) && !($entry[0] == ".")) {
+            $hosts[$entry] = array();
+            $d2 = dir($DATADIR.$entry);
+            while (false !== ($counter = $d2->read())) {
+                // Do not include files containing dots or tildes or 
incomplete files
+                if (($q === "" || strpos($counter, $q) !== false) &&
+                        preg_match("/(\.|~)/", $counter) === 0 &&
+                        is_file("$DATADIR$entry/$counter.dat")) {
+                    $hosts[$entry][] = $counter;
+                    $metrics[$counter] = get_counter_name($counter);
+                    $metrics_c[get_counter_category($counter)][$counter] = 
get_counter_name($counter);
+                }
             }
         }
     }
-}
 
-ksort($hosts);
-foreach($hosts as $host => $a) {
-    sort(&$hosts[$host]);
+    ksort($hosts);
+    foreach($hosts as $host => $a) {
+        sort(&$hosts[$host]);
+    }
+    foreach($metrics_c as $id => $a) {
+        ksort(&$metrics_c[$id]);
+    }
+    ksort(&$metrics_c);
+    $others = array_shift($metrics_c);
+    $metrics_c[""] = $others;
+    $d->close();
 }
-foreach($metrics_c as $id => $a) {
-    ksort(&$metrics_c[$id]);
-}
-ksort(&$metrics_c);
-$others = array_shift($metrics_c);
-$metrics_c[""] = $others;
-$d->close();
-// echo '<pre>';
-// print_r($hosts);
-// die();

Modified: gauger/index.php
===================================================================
--- gauger/index.php    2011-03-04 12:46:38 UTC (rev 14593)
+++ gauger/index.php    2011-03-04 14:50:01 UTC (rev 14594)
@@ -18,6 +18,8 @@
     along with gauger.  If not, see <http://www.gnu.org/licenses/>.
 
 */
+include "params.php";   // Manage all parameters given by the user
 include "explore.php";  // Gather all existing hosts and counters
-include "params.php";   // Manage all parameters given by the user
+init_params();
+explore();
 include "template.php"; // Display info
\ No newline at end of file

Modified: gauger/params.php
===================================================================
--- gauger/params.php   2011-03-04 12:46:38 UTC (rev 14593)
+++ gauger/params.php   2011-03-04 14:50:01 UTC (rev 14594)
@@ -22,6 +22,10 @@
 $range_parameters = Array('x_max', 'x_min',
                             'y_max', 'y_min',
                             'png_x_size', 'png_y_size');
+$mode_host = FALSE;
+$mode_graph = FALSE;
+$current = "";
+$currentg = "";
 
 function get_param($name, $default = '', $persist = FALSE) {
     if (array_key_exists($name, $_REQUEST)) {
@@ -69,35 +73,41 @@
     }
 }
 
-session_start();
+function init_params() {
+    global $mode_host;
+    global $mode_graph;
+    global $current;
+    global $currentg;
+    global $q;
+    global $range_parameters;
 
-if (get_param('logout')) {
-    session_unset();
-    header("Location: " . preg_replace("/\?.*/", "", $_SERVER["REQUEST_URI"]));
-    die();
-}
+    session_start();
 
-$mode_host = FALSE;
-$mode_graph = FALSE;
+    if (get_param('logout')) {
+        session_unset();
+        header("Location: " . preg_replace("/\?.*/", "", 
$_SERVER["REQUEST_URI"]));
+        die();
+    }
 
-if ($current = get_param('host')) {
-    $mode_host = TRUE;
-}
+    if ($current = get_param('host')) {
+        $mode_host = TRUE;
+    }
 
-if ($currentg = get_param('graph')) {
-    $mode_graph = TRUE;
-}
+    if ($currentg = get_param('graph')) {
+        $mode_graph = TRUE;
+    }
 
-if (get_session('xrange_min') === '') {
-    $r = get_range('','');
-    $_SESSION['xrange_min'] = $r[0];
-    $_SESSION['xrange_max'] = $r[1];
-    $_SESSION['y_min'] = 0;
-    foreach ($range_parameters as $param_name) {
-        $_SESSION[$param_name.'_a'] = 1;
+    if (get_session('xrange_min') === '') {
+        $r = get_range('','');
+        $_SESSION['xrange_min'] = $r[0];
+        $_SESSION['xrange_max'] = $r[1];
+        $_SESSION['y_min'] = 0;
+        foreach ($range_parameters as $param_name) {
+            $_SESSION[$param_name.'_a'] = 1;
+        }
+        $_SESSION['png_x_size'] = 640;
+        $_SESSION['png_y_size'] = 480;
     }
-    $_SESSION['png_x_size'] = 640;
-    $_SESSION['png_y_size'] = 480;
-}
 
-// die("#".get_session("xrange_min", "default") ."#");
+    $q = get_param('q', '');
+}
\ No newline at end of file

Modified: gauger/plot.php
===================================================================
--- gauger/plot.php     2011-03-04 12:46:38 UTC (rev 14593)
+++ gauger/plot.php     2011-03-04 14:50:01 UTC (rev 14594)
@@ -179,8 +179,10 @@
     return $out;
 }
 
+include "params.php";
 include "explore.php";
-include "params.php";
+init_params();
+explore();
 
 if ($h = get_param('h')) {
     $h = explode(',', $h);

Modified: gauger/template_host.php
===================================================================
--- gauger/template_host.php    2011-03-04 12:46:38 UTC (rev 14593)
+++ gauger/template_host.php    2011-03-04 14:50:01 UTC (rev 14594)
@@ -19,23 +19,29 @@
 
 */?>
 <?php if (isset($hosts[$current])): ?>
-    <div class="search_realm">
-    <div class="title"><h1>SHOWING HOST: <?php echo $current ?></h1><input 
id="instant_search_main" class="instant_search"/></div>
+    <div class="title">
+        <h1>SHOWING HOST: <?php echo $current ?></h1>
+        <form action="index.php" method="get" id="search_host">
+            <input name="host" value="<?php echo $current ?>" 
class="hidden_input"/>
+            <input name="q" value="<?php echo $q ?>"/>
+            <input type="submit" value="Search">
+        </form>
+    </div>
     <?php if (!empty($hosts[$current])): ?>
     <?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=searchterm&amp;page=1">1</a><?php if ($p > 4) echo ".." ?>
+        <a href="index.php?host=<?php echo $current ?>&amp;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=searchterm&amp;page=<?php echo $l ?>"><?php echo $l ?></a>
+            <a href="index.php?host=<?php echo $current ?>&amp;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=searchterm&amp;page=<?php echo $maxp ?>"><?php echo 
$maxp ?></a>
+        <?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 endif; ?>
     </p>
     <table>
@@ -45,7 +51,7 @@
         </tr>
         <?php for ($i = 0; $i < $PAGELENGTH && ($p-1)*$PAGELENGTH+$i < 
count($hosts[$current]); $i++): ?>
         <?php $counter = $hosts[$current][($p-1)*$PAGELENGTH+$i] ?> 
-        <tr class="search_item" id="<?php echo $counter ?>">
+        <tr>
             <th>
                 Range
                 <br/>
@@ -70,23 +76,22 @@
     </table>
     <p class="pager">
         <?php if ($p >= 4): ?>
-        <a href="index.php?host=<?php echo $current 
?>&amp;q=searchterm&amp;page=1">1</a><?php if ($p > 4) echo ".." ?>
+        <a href="index.php?host=<?php echo $current ?>&amp;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=searchterm&amp;page=<?php echo $l ?>"><?php echo $l ?></a>
+            <a href="index.php?host=<?php echo $current ?>&amp;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=searchterm&amp;page=<?php echo $maxp ?>"><?php echo 
$maxp ?></a>
+        <?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 endif; ?>
     </p>
     <?php else: ?>
     <h1>The host "<?php echo $current ?>" has no counters</h1>
     <?php endif; ?>
-    </div>
 <?php else: ?>
     <h1>Oops!</h1>
     <p>The host you are looking for doesn't seem to exist. Please select a 
host from the menu on the left.</p>




reply via email to

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