Location: PHPKode > projects > Cricetus log file search > cricetus-1.0/regexp.php
<?php
// regula, 2006/05/18, hide@address.com

  require_once('base.php');

  $time_start  = get_microtime();

  require('web_header.php');

  // define desired action for further usage
  $action = '';
  if(isset($_POST['savechanges']))
  {
    $action = 'savechanges';
  }
  else
  {
    if(isset($_GET['action']))
    {
      $action = $_GET['action'];
    }
  }

  if(isset($_POST['savechanges']))
  {
    set_title('system.configure.regexps');
  }
  else
  {
    set_title('system.configure.regexps.' . $action);
  }

  switch(check_options())
  {
    case 0:
      break;

    case 1:
      if(get_admin()!=1)
      {
        display_message(1,'Errors in system options!','The other system options are not set ' .
          'correctly. Please ask the administrator of this system to fix that.','Go back','history.back()');
      }
      else
      {
        display_message(1,'Errors in system options!','The other system options are not set ' .
          'correctly. Please set them correctly before continuing.','Set other system options',
          'load_href(\'options_other.php\')');
      }
      break;

    case 2:
      if(get_admin()!=1)
      {
        display_message(1,'Errors in system options!','The logging system options are not set ' .
          'correctly. Please ask the administrator of this system to fix that.','Go back','history.back()');
      }
      else
      {
        display_message(1,'Errors in system options!','The logging system options are not set ' .
          'correctly. Please set them correctly before continuing.','Set logging system options',
          'load_href(\'options_logging.php\')');
      }
      break;

    default:
      if(get_admin()!=1)
      {
        display_message(1,'Internal error #001','Please ask the administrator of this system ' .
          'to report this error to the developer.','Go back','history.back()');
      }
      else
      {
        display_message(1,'Internal error #001','Please report this error to the developer.',
          'Go back','history.back()');
      }
      break;
  }

  if($action=='savechanges')
  {
    // mandatories
  }
  else
  {
    make_header('Please fill in all required fields.');
  }
?>

<form name="regexp" action="regexp.php" method="POST">
<input type="hidden" name="service" value="savechanges">
<center>
<table class="dotted" cellspacing="10">

<?php
  if($action=='add')
  {
?>
  <tr>
    <td>
      <fieldset>
        <legend><b>Add new regular expressions</b></legend>
        <table class="misc">
          <tr>
            <th width="5%">&nbsp;</th>
            <th width="45%" align="left">Description</th>
            <th width="45%" align="left">Regular Expression</th>
            <th width="5%" align="left">Limit</th>
          </tr>
          <tr>
            <td width="5%">1.</td>
            <td width="45%"><input type="text" name="description1" size="70" maxlength="128" value=""></td>
            <td width="45%"><input type="text" name="expression1" size="70" maxlength="128" value=""></td>
            <td width="5%"><input type="text" name="limit1" size="3" maxlength="3" value=""></td>
          </tr>
          <tr>
            <td width="5%">2.</td>
            <td width="45%"><input type="text" name="description2" size="70" maxlength="128" value=""></td>
            <td width="45%"><input type="text" name="expression2" size="70" maxlength="128" value=""></td>
            <td width="5%"><input type="text" name="limit2" size="3" maxlength="3" value=""></td>
          </tr>
          <tr>
            <td width="5%">3.</td>
            <td width="45%"><input type="text" name="description_3" size="70" maxlength="128" value=""></td>
            <td width="45%"><input type="text" name="expression_3" size="70" maxlength="128" value=""></td>
            <td width="5%"><input type="text" name="limit_3" size="3" maxlength="3" value=""></td>
          </tr>
        </table>
      </fieldset>
    </td>
  </tr>
<?php
  }

  if(($action=='modifyall')||($action=='add'))
  {
    echo '<tr>';
    echo '<td>';
    echo '<fieldset>';
    if($action=='modifyall')
    {
      echo '<legend><b>Modify existing regular expressions</b></legend>';
    }
    else
    {
      echo '<legend><b>Existing regular expressions</b></legend>';
    }
    echo '<table class="misc">';
    echo '<tr>';
    if($action=='modifyall')
    {
      echo '<th width="5%">Delete</th>';
    }
    else
    {
      echo '<th width="5%">Scope</th>';
    }
    echo '<th width="45%" align="left">Description</th>';
    echo '<th width="45%" align="left">Regular Expression</th>';
    echo '<th width="5%" align="left">Limit</th>';
    echo '</tr>';

    if(get_admin()==1)
    {
      $query = 'SELECT * FROM regexps ORDER BY username ASC, description ASC';
    }
    else
    {
      $query = sprintf("SELECT * FROM regexps WHERE (ISNULL(username) OR username='%s') " .
        "ORDER BY username ASC, description ASC",get_username());
    }

    logging('debug','QUERY: ' . $query . '...');

    $result = mysql_query($query);

    if(!$result)
    {
      echo '</table></fieldset></td></tr></table>';

      display_message(1,'Error reading regexps table!','Unable to read the regular expressions from the database. ' .
        'Please consult an administrator of this system.','','');

      exit;
    }

    $counter = 0;

    while($row = mysql_fetch_array($result,MYSQL_NUM))
    {
      if(get_admin()!=1)
      {
        if(($row[1]!=get_username())&&($action=='modifyall'))
        {
          continue;
        }
      }

      if($action=='add')
      {
        $counter++;
        if($counter%2!=0)
        {
          echo '<tr bgcolor="#E0E0E0">';
        }
        else
        {
          echo '<tr bgcolor="#FEFEFE">';
        }
      }
      else
      {
        echo '<tr>';
      }
      echo '<td width="5%" align="center">';
      if($action=='modifyall')
      {
        echo '<input type="checkbox" name="delete_' . $row[0] . '" value="1" onClick="updateModifyAll();">';
      }
      else
      {
        if(empty($row[1]))
        {
          echo '<i>global</i>';
        }
        else
        {
          echo '<i>' . $row[1] . '</i>';
        }
      }
      echo '</td>';
      echo '<td width="45%">';
      if($action=='modifyall')
      {
        echo '<input type="text" name="description_' . $row[0] . '" size="70" maxlength="128" value="' . $row[2] . '">';
      }
      else
      {
        echo $row[2];
      }
      echo '</td>';
      echo '<td width="45%">';
      if($action=='modifyall')
      {
        echo '<input type="text" name="expression_' . $row[0] . '" size="70" maxlength="128" value="' . $row[3] . '">';
      }
      else
      {
        echo $row[3];
      }
      echo '</td>';
      echo '<td width="5%">';
      if($action=='modifyall')
      {
        echo '<input type="text" name="limit_' . $row[0] . '" size="3" maxlength="3" value="' . $row[4] . '">';
      }
      else
      {
        echo $row[4];
      }
      echo '</td>';
      echo '</tr>';
    }

    echo '</table>';
    echo '</fieldset>';
    echo '</td>';
    echo '</tr>';
  }

  if($action=='modify')
  {
    echo '<tr>';
    echo '<td>';
    echo '<fieldset>';
    echo '<legend><b>Modify</b></legend>';
    echo '<table class="misc">';
    echo '<tr>';

    $id = $_GET['id'];
    $query = sprintf("SELECT * FROM regexps WHERE id=%d",$id);

    logging('debug','QUERY: ' . $query . '...');

    $result = mysql_query($query);

    if(!$result)
    {
      echo '</tr></table></fieldset></td></tr></table>';

      display_message(1,'Error reading regexps table!','Unable to read the regular expressions from the database. ' .
        'Please consult an administrator of this system.','','');

      exit;
    }

    $erg = mysql_fetch_row($result);

    if($erg==TRUE)
    {
      logging('debug','Got result...');
    }
    else
    {
      echo '</tr></table></fieldset></td></tr></table>';

      display_message(1,'Error reading regexps table!','Unable to read the regular expressions from the database. ' .
        'Please consult an administrator of this system.','','');

      exit;
    }

    if(get_admin()!=1)
    {
      if($erg[1]!=get_username())
      {
        echo '</tr></table></fieldset></td></tr></table>';

        display_message(1,'No rights!','You have no rights to modify this entry. ' .
          'Please consult an administrator of this system.','','');

        exit;
      }
    }

    echo '<th width="5%">Delete</th>';
    echo '<th width="45%" align="left">Description</th>';
    echo '<th width="45%" align="left">Regular Expression</th>';
    echo '<th width="5%" align="left">Limit</th>';
    echo '</tr>';
    echo '<tr>';
    echo '<td colspan="4">';
    echo '<input type="hidden" name="id" value="' . $id . '">';
    echo '</td>';
    echo '</tr>';

    echo '<td width="5%" align="center">';
    if((get_admin()==1)||($erg[1]==get_username()))
    {
      echo '<input type="checkbox" name="delete" value="1" onClick="updateModifyRegexp();">';
    }
    else
    {
      echo '<i>global</i>';
    }
    echo '</td>';
    echo '<td width="45%">';
    if((get_admin()==1)||($erg[1]==get_username()))
    {
      echo '<input type="text" name="description" size="70" maxlength="128" value="' . $erg[2] . '">';
    }
    else
    {
      echo $erg[2];
    }
    echo '</td>';
    echo '<td width="45%">';
    if((get_admin()==1)||($erg[1]==get_username()))
    {
      echo '<input type="text" name="expression" size="70" maxlength="128" value="' . $erg[3] . '">';
    }
    else
    {
      echo $erg[3];
    }
    echo '</td>';
    echo '<td width="5%">';
    if((get_admin()==1)||($erg[1]==get_username()))
    {
      echo '<input type="text" name="limit" size="3" maxlength="3" value="' . $erg[4] . '">';
    }
    else
    {
      echo $erg[4];
    }
    echo '</td>';
    echo '</tr>';
    echo '</table>';
    echo '</fieldset>';
    echo '</td>';
    echo '</tr>';
  }
?>

  <tr>
    <td align="left">
      <input type="submit" class="buttonmisc" name="savechanges" value="Save changes">
    </td>
  </tr>
</table>
<script type="text/javascript">
  <!--
    updateModifyAll();
    updateModifyRegexp();
  //-->
</script>
</center>
</form>

<?php
  make_footer($time_start);
?>

</body>
</html>
Return current item: Cricetus log file search