Show
Ignore:
Timestamp:
12/05/08 10:18:51 (16 years ago)
Author:
ixs
Message:

Additional changes, nslookup support, added time selection to the chart itself...

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/flowmon-web/index.php

    r1 r4  
    1818# along with this program; if not, write to the Free Software 
    1919# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 
    20 # Copyright 2004, 2005 Red Hat, Inc. 
    21 # 
    22 # AUTHOR: Andreas Thienemann <athienem@redhat.com> 
    2320# 
    2421 
     
    7067                print('<option value="'.$probe.'">'.$hostname.' ('.$probe.')</option>'); 
    7168        } 
    72         print('</select><input type="hidden" name="action" value="probe_select"><input type="submit" value="Graph!"></form>'); 
     69        print('</select><input type="hidden" name="action" value="chart"><input type="hidden" name="nslookup" value="on"><input type="hidden" name="rolling" value="on"><input type="submit" value="Graph!"></form>'); 
    7370        print('</div>'); 
    7471        print(html_footer()); 
     
    7774// We have selected a probe, present with detailes form to get the chart parameters 
    7875} else if (array_key_exists('action', $_REQUEST) && $_REQUEST['action'] == 'probe_select') { 
     76 
    7977        print(html_header($title = 'FlowMon '.$prog_vers.' - running on '.$_SERVER['HTTP_HOST'], $calendar = True)); 
    8078        print(page_header($title = 'FlowMon Chart Parameters')); 
     
    112110        print(html_header($title = 'FlowMon '.$prog_vers.' - running on '.$_SERVER['HTTP_HOST'], $calendar = True)); 
    113111        print(page_header($title = 'FlowMon Traffic Chart')); 
     112 
     113        // Initialize defaults which might not exist 
     114        if (!@array_key_exists('style', $_REQUEST)) { 
     115                $_REQUEST['style'] = 'Top Sources'; 
     116        } 
     117        if (!@array_key_exists('timeframe', $_REQUEST)) { 
     118                $_REQUEST['timeframe'] = '3600'; 
     119        } 
     120        if (@$_REQUEST['rolling'] == 'on') { 
     121                $_REQUEST['startdate'] = strftime('%Y-%m-%d', (time() - $_REQUEST['timeframe'])); 
     122                $_REQUEST['starttime'] = strftime('%H:%M', (time() - $_REQUEST['timeframe'])); 
     123                $_REQUEST['enddate'] = strftime('%Y-%m-%d'); 
     124                $_REQUEST['endtime'] = strftime('%H:%M'); 
     125 
     126                $starttime = strtotime($_REQUEST['startdate'].' '.$_REQUEST['starttime']); 
     127                $endtime = strtotime($_REQUEST['enddate'].' '.$_REQUEST['endtime']); 
     128        } else { 
     129                // Sanitize user input 
     130                $starttime = strtotime($_REQUEST['startdate'].' '.$_REQUEST['starttime']); 
     131                $endtime = strtotime($_REQUEST['enddate'].' '.$_REQUEST['endtime']); 
     132        } 
     133        print(chartstyle_header($_REQUEST['startdate'], $_REQUEST['starttime'], $_REQUEST['enddate'], $_REQUEST['endtime'])); 
    114134        print('<div style="margin: 30px auto 30px auto; width: 850px; text-align: left;"> 
    115135                <h1> Statistics</h1>'); 
     
    120140        } 
    121141 
    122         // Sanitize user input 
    123         $starttime = strtotime($_REQUEST['startdate'].' '.$_REQUEST['starttime']); 
    124         $endtime = strtotime($_REQUEST['enddate'].' '.$_REQUEST['endtime']); 
    125142        if (!isvalid_probe($_REQUEST['probe'])) { 
    126143                die("Invalid Probe"); 
    127144        } 
    128145 
    129         $file = chart_prepare($_REQUEST['probe'], $starttime, $endtime); 
     146        // Do we want namelookups? 
     147        if (@$_REQUEST['nslookup'] == 'on') { 
     148                $nslookup = True; 
     149        } else { 
     150                $nslookup = False; 
     151        } 
     152 
     153        $file = chart_prepare($_REQUEST['probe'], $starttime, $endtime, $nslookup=$nslookup); 
    130154 
    131155        print('<img src="'.$file.'" />'); 
     
    135159        print(html_footer()); 
    136160 
    137 // Rolling chart requested 
    138 } else if (array_key_exists('action', $_REQUEST) && $_REQUEST['action'] == 'rollingchart') { 
    139         print(html_header($title = 'FlowMon '.$prog_vers.' - running on '.$_SERVER['HTTP_HOST'], $calendar = False, $refresh = 300)); 
    140         print(page_header($title = 'FlowMon Rolling Traffic Chart')); 
    141         print('<div style="margin: 30px auto 30px auto; width: 850px; text-align: left;"> 
    142                 <h1>Rolling Statistics (updated every 5min)</h1>'); 
    143  
    144         // Import the Chart-Plugin 
    145         if (array_key_exists($_REQUEST['style'], $chart_styles)) { 
    146                 require_once('charts/'.$chart_styles[$_REQUEST['style']]); 
    147         } 
    148  
    149         // Sanitize user input 
    150         if (!isvalid_probe($_REQUEST['probe'])) { 
    151                 die("Invalid Probe"); 
    152         } 
    153  
    154         $file = chart_prepare($_REQUEST['probe'], False, False, $_REQUEST['timeframe']); 
    155  
    156         print('<img src="'.$file.'" />'); 
    157  
    158         print(' </div>'); 
    159  
    160         print(html_footer()); 
    161  
    162  
    163161}