Source for file GuiSearch.php

Documentation is available at GuiSearch.php

  1. <?php
  2. /**
  3.  *
  4.  *
  5.  * @package     FreeNAC
  6.  * @author      Many: S.Boran, T.Dagonnier, P.Bizeau
  7.  * @copyright   2008 FreeNAC
  8.  * @license     http://www.gnu.org/copyleft/gpl.html   GNU Public License Version 3
  9.  * @version     SVN: $Id$
  10.  * @link        http://freenac.net
  11.  *
  12.  */
  13.  
  14.  
  15. class GuiSearch extends WebCommon
  16. {
  17.   private $id$action;      // See also WebCommon and Common
  18.  
  19.  
  20.   function __construct($action$debug_level=1)
  21.   {
  22.     parent::__construct(false);     // See also WebCommon and Common
  23.     $this->logger->setDebugLevel($debug_level);
  24.     $this->debug("GuiSearch__construct, debug=$debug_level, action=$action"2);
  25.  
  26.     // verify/clean 'action'
  27.     // Now, have we a REQUEST action to carry out?
  28.     if !isset($action) ) {
  29.        throw new InvalidWebInputException("No action ");
  30.     }
  31.     $this->action=validate_webinput($action);
  32.  
  33.   }
  34.  
  35.   public function print_title($title)
  36.   {
  37.     echo $this->print_header();
  38.     echo "<div id='GuiList1Title'>{$title}</div>";
  39.     //$this->debug($_SESSION['login_data'] .":Id=$id:" , 1);
  40.   }
  41.  
  42.   public function handle_request()
  43.   {
  44.     $action=$this->action;
  45.     #global $_SESSION, $_REQUEST;
  46.     #$_REQUEST=array_map('validate_webinput',$_REQUEST);
  47.     $this->debug("handle_request() $action"2);
  48.  
  49.     if (isset($action)) {
  50.       if ($action==='Search'{
  51.         $this->print_title('Search for end devices');
  52.         echo $this->SearchForm();
  53.         #echo $this->query();
  54.         echo $this->print_footer();
  55.  
  56.       else {
  57.         // do nothing, action does not concern us.
  58.       }
  59.     }
  60.   }
  61.  
  62.   public function SearchForm()
  63.   {
  64.     $this->debug("SearchForm()"3);
  65.     #var_dump($_REQUEST);
  66.     if ($_SESSION['nac_rights']<1)
  67.       throw new InsufficientRightsException('SearchForm() ' .$_SESSION['nac_rights']);
  68.     $conn=$this->getConnection();     //  make sure we have a DB connection
  69.  
  70.     // Clean inputs from the web, (security). Use _REQUEST to
  71.     // allow both GET (automation) or POST (interactive GUIs)
  72.     $_REQUEST=array_map('validate_webinput',$_REQUEST);
  73.     if (isset($_REQUEST['searchstring']))
  74.       $cur_mac=$this->htmlescape($_REQUEST['searchstring']);
  75.     $cur_macempty($cur_mac'0006.5bdd.a929' $cur_mac;
  76.  
  77.     $output=<<<TXT
  78. <form action="search.php" method="GET">
  79. <tr>
  80.   <td width="87">MAC Address:</td> 
  81.   <td width="400"> <input name="searchstring" type="text" value="{$cur_mac}"/></td>
  82. </tr>
  83. <tr>
  84.   <td><input type="submit" name="action" class="bluebox" value="Find" 
  85.    title='Find devices with this mac, which can be in 3 formats XXX.XXX.XXX XXXXXXXXXXXX or XX:XX:XX:XX:XX:XX'/> </td>
  86. </tr>
  87. </form>
  88. TXT;
  89.  
  90.  
  91.     return $output;
  92.   }
  93.   
  94.  
  95. // class
  96.  
  97.  
  98.  
  99. /////////// main() should never get here .. ///////////////////////////////////////
  100.  
  101. if (isset($_POST['action']&& $_POST['action']=='Edit'{
  102.   $logger=Logger::getInstance();
  103.   $logger->debug("GuiSearch:action:"$_POST['action']1);
  104. }
  105.  
  106. if isset($_POST['submit']) ) {             // form submit, check fields
  107. ## Initialise (standard header for all modules)
  108.   dir(dirname(__FILE__))set_include_path("./:../");
  109.   require_once('webfuncs.inc');
  110.   $logger=Logger::getInstance();
  111.   $logger->setDebugLevel(1);
  112.   $logger->debug("GuiSearch main -submit");
  113.   #echo handle_submit();
  114.  
  115. else {
  116.   # Do nothing, we've been included.
  117. }
  118.  
  119. ?>

Documentation generated on Mon, 17 Nov 2008 01:10:37 +0100 by phpDocumentor 1.4.0