Location: PHPKode > scripts > sLog > sLog-0.8/include/form.php
<?php
/** sLog v0.8
 *  copyright (c) 2008 Kjell-Inge Gustafsson kigkonsult
 *  www.kigkonsult.se/slog/index.php
 *  hide@address.com
 *
 *  Description:
 *  This file contains PHP sLog common client functions
 *
 *  This program is free software; you can redistribute it and/or modify it 
 *  under the terms of the GNU General Public License as published by the  Free
 *  Software Foundation; either version 2 of the License, or (at your option)
 *  any later version.
 *
 *  This program 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 General Public License for
 *  more details.
 *
 *  You should have received a copy of the GNU General Public License along with
 *  this program; if not, write to the Free Software Foundation, Inc., 59 Temple
 *  Place, Suite 330, Boston, MA  02111-1307  USA
 */
function getmicrotime(){ 
  list($usec, $sec) = explode(" ",microtime()); 
  return ((float)$usec + (float)$sec); 
}
function fixInput( & $_REQUEST, $wsdl=null ) {
  if( isset( $wsdl )) {
    if( !isset( $_REQUEST['WSurl'] ) || ( '' == $_REQUEST['WSurl'] ))
      $_REQUEST['WSurl'] = 'http://'.$_SERVER['SERVER_NAME'].dirname( $_SERVER['PHP_SELF'] ).DIRECTORY_SEPARATOR.$wsdl;
  }
  else
    unset( $_REQUEST['WSurl'] );
  if( !isset( $_REQUEST['count'] )         || ( 0 == $_REQUEST['count'] ))
    $_REQUEST['count'] = 1000;
  if( !isset( $_REQUEST['organisations'] ) || ( 0 == $_REQUEST['organisations'] ))
    $_REQUEST['organisations'] = 5;
  if( !isset( $_REQUEST['users'] )         || ( 0 == $_REQUEST['users'] ))
    $_REQUEST['users'] = 25;
  if( !isset( $_REQUEST['clients'] )       || ( 0 == $_REQUEST['clients'] ))
    $_REQUEST['clients'] = 5;
  if( !isset( $_REQUEST['applications'] )  || ( 0 == $_REQUEST['applications'] ))
    $_REQUEST['applications'] = 10;
  if( !isset( $_REQUEST['objnos'] )        || ( 0 == $_REQUEST['objnos'] ))
    $_REQUEST['objnos'] = 5;
}
function fixLogparams( $cnt, $_REQUEST ) {
  $cnt++;
  $dt         = date( 'Y-m-d H:i:s', mktime( mt_rand(6,19), mt_rand(0,59), mt_rand(0,59), date('m')-1, mt_rand(10,20), date('Y')));
  $date       = substr( $dt, 0, 10 );
  $time       = substr( $dt, 11, 8 );
  $org        = mt_rand( 1, $_REQUEST['organisations'] );
  $rnd        = mt_rand( 1, 3 );
  $orgSpec    = ( 3 == $rnd ) ? '' : 'orgUnit_'.$org.$rnd;
  $client     = mt_rand( 1, $_REQUEST['clients'] );
  $rnd        = mt_rand( 1, 5 );
  $clientSpec = $client;
  $rnd        = mt_rand( 1, $_REQUEST['users'] );
  list($usec, $sec) = explode(" ",microtime());
  $params     = array( 'date'         => $date
                     , 'time'         => $time
                     , 'organisation' => 'organisation_' . $org
                     , 'organisation_spec' => $orgSpec
                     , 'user1'        => 'user1_'        . $org.$rnd
                     , 'user2'        => 'user2_'        . $org.$rnd
                     , 'client'       => 'client_'       . $client
                     , 'client_spec'  => 'client_'       . $client
                     , 'application'  => 'application_'  . mt_rand( 1, $_REQUEST['applications'] )
                     , 'service'      => 'service_'      . mt_rand( 1, 4 )
                     , 'operation'    => 'oper_'         . mt_rand( 1, 4 )
                     , 'objno'        => mt_rand( 1, $_REQUEST['objnos'] )
                     , 'subject'      => "$cnt subject"
                     , 'body'         => date( 'Y-m-d H:i:s', $sec ).':'.substr($usec, 2, 4));
  return $params;
}
function form( $_REQUEST, $formParams ) {
  $k=1;
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
<!--
sLog v0.8
copyright (c) 2008 Kjell-Inge Gustafsson kigkonsult
www.kigkonsult.se/slog/index.php
hide@address.com

Description:
This file is a PHP HTTP sLog test interface

This program is free software; you can redistribute it and/or modify it 
under the terms of the GNU General Public License as published by the  Free
Software Foundation; either version 2 of the License, or (at your option)
any later version.

This program 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 General Public License for
more details.

You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place, Suite 330, Boston, MA  02111-1307  USA
-->
<html>
<head>
<title><?php echo $formParams['title']; ?></title>
<meta name="author"      content="Kjell-Inge Gustafsson - kigkonsult" />
<meta name="copyright"   content="2008 Kjell-Inge Gustafsson - kigkonsult" />
<meta name="keywords"    content="log, event, statistics, security, tracking, database, mysql" />
<meta name="description" content="sLog" />
<style type="text/css">
body {
  background-color: #ffffff;
}
#page {
  font-family:      Arial, sans-serif;
  width:            600px;
}
h2 {
  font-size:        120%;
  color:            #4d5762;
}
fieldset {
  padding-bottom:   5px;
}
legend {
  font-family:      Verdana, Arial, sans-serif;
  font-size:        80%;
  font-weight:      bold;
  color:            #006080;
  margin:           0;
  padding:          5px 0 5px;
}
.fs0 {
  background-color: #ffffff;
}
.fs1 {
  background-color: #f0f0f0;
}
.right {
  float:            right;
}
.label {
  font-family:      monospace;
  font-size:        70%;
  font-weight:      bold;
  color:            #4d5762;
  margin:           0;
  padding:          0px 5px 0px 0px;
  width:            100px;
  float:            left;
  text-align:       right;
}
input.textfield {
  font-family:      Arial, Verdana, sans-serif;	
  background:       #f9f9f9;
  width:            420px;
  border:           2px solid #ddd;
}
input.textfield:focus {
  color:            #333;
  border:           2px solid #E03800;
}
input.button {
  padding:          3px;
  font-size:        150%;
}
.info {
  font-family:      Arial, Verdana, sans-serif;
  font-size:        120%;
  color:            #E03800;
  margin-left:      10px;
}
</style>
</head>
<body>
<div id="page">
<h2><?php echo $formParams['header']; ?></h2>
<?php echo $formParams['text']; ?>
<div id="content">
<form id="slogtest" action="<?php echo $formParams['action']; ?>" method="post">
<?php if( isset( $_REQUEST['WSurl'] )) { ?>

<fieldset id="fsWSurl" class="fs<?php $k = 1 - $k;echo $k; ?>">
<legend id="WSurlLegend"><?php echo $formParams['URLlegend']; ?></legend>
<div class="label"><label for "WSurl"><?php echo $formParams['URLlabel']; ?></label></div>
<input type="text" name="WSurl" id="WSurl" class="textfield" value="<?php echo $_REQUEST['WSurl']; ?>"/>
</fieldset>
<?php } ?>

<fieldset id="execSeconds" class="fs<?php $k = 1 - $k;echo $k; ?>">
<legend id="execSecondsLegend">Execution time</legend>
<div class="label">total</div>
<div id="seconds" class="info"><?php if( isset( $formParams['time'] )) echo $formParams['time'].' '.$formParams['avgTime'];?></div>
<?php if( !empty( $formParams['message'] )) { ?>
<div class="label">errors</div>
<div>
<span id="message" class="info"><?php echo $formParams['message']; ?></span>
</div>
<?php } ?>
</fieldset>

<fieldset id="testTotals" class="fs<?php $k = 1 - $k;echo $k; ?>">
<legend id="testTotalsLegend">Total test logged events</legend>
<div class="label"><label for "count">total</label></div>
<input type="text" name="count" id="count" class="textfield" value="<?php echo $_REQUEST['count']; ?>"/>
</fieldset>

<fieldset id="logItems" class="fs<?php $k = 1 - $k;echo $k; ?>">
<legend id="logItemsLegend">Number of organisations, users, clients and applications</legend>
<div>
<div class="label"><label for "organisations">organisations</label></div>
<input type="text" name="organisations" id="organisations" class="textfield" value="<?php echo $_REQUEST['organisations']; ?>"/>
</div>
<div>
<div class="label"><label for "users">users (every organisation)</label></div>
<input type="text" name="users" id="users" class="textfield" value="<?php echo $_REQUEST['users']; ?>"/>
</div>
<div>
<div class="label"><label for "clients">clients</label></div>
<input type="text" name="clients" id="clients" class="textfield" value="<?php echo $_REQUEST['clients']; ?>"/>
</div>
<div>
<div class="label"><label for "applications">applications (four services/operations)</label></div>
<input type="text" name="applications" id="applications" class="textfield" value="<?php echo $_REQUEST['applications']; ?>"/>
</div>
<div>
<div class="label"><label for "objnos">app-system instants</label></div>
<input type="text" name="objnos" id="objnos" class="textfield" value="<?php echo $_REQUEST['objnos']; ?>"/>
</div>
</fieldset>

<fieldset id="controls" class="fs<?php $k = 1 - $k;echo $k; ?>">
<legend id="controlsLegend">Start test</legend>
<input type="submit" name="submit" value="start" id="submit" class="button" />
</fieldset>
</form>
Log items are randomly set as:<br />
<span class="label">Date</span> : year, previous month, day = rand(10-20)<br />
<span class="label">Time</span> : hour = rand(6-19), minute = rand(0-59), second = rand(0-59)<br />
<span class="label">organisation</span> : &quot;organisation_&quot; + rand( 1 - organisations )<br />
<span class="label">organisation_spec</span> : &quot;orgUnit_&quot; + rand( 1-3 ) (but every 3rd is empty)<br />
<span class="label">user</span> : &quot;user1_&quot; + rand( 1 - users )<br />
<span class="label">user_spec</span> : &quot;user2_&quot; + rand( 1 - users )<br />
<span class="label">client</span> : &quot;client_&quot; + rand( 1 - clients )<br />
<span class="label">client_spec</span> : same as client<br />
<span class="label">application</span> : &quot;application_&quot;     + rand( 1 - applications )<br />
<span class="label">service</span> : &quot;service_&quot; + rand( 1, 4 )<br />
<span class="label">operation</span> : &quot;oper_&quot; + rand( 1, 4 )<br />
<span class="label">objno</span> : rand( 1, objno's )<br />
<span class="label">subject</span> : &quot;{orderno} subject&quot; db / http / soap<br />
<span class="label">body</span> : date( &quot;Y-m-d H:i:s&quot; ) + msec (param create timestamp)<br />

</div>
</div>
</body>
</html>
<?php
  }
?>
Return current item: sLog