Login   Register  
PHP Classes
elePHPant
Icontem

File: debug_leaver.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Simon Roberts  >  QCP135  >  debug_leaver.php  >  Download  
File: debug_leaver.php
Role: Example script
Content type: text/plain
Description: Debug Example Leaver
Class: QCP135
Compute checksum of variable data with QCP135
Author: By
Last change:
Date: 2008-08-15 17:18
Size: 4,619 bytes
 

Contents

Class file image Download
<?
// $Id: debug_leaver.php 1.1.0 - QCP135 2008-08-15 9:22:20 wishcraft $
//  ------------------------------------------------------------------------ //
//                    CLORA - Chronolabs Australia                           //
//                         Copyright (c) 2008                                //
//                   <http://www.chronolabs.org.au/>                         //
//  ------------------------------------------------------------------------ //
//  This program is free software; you can redistribute it and/or modify     //
//  it under the terms of the SDPL Source Directive Public Licence           //
//  as published by Chronolabs Australia; either version 2 of the License,   //
//  (at your option) any later version.                                      //
//                                                                           //
//  You may not change or alter any portion of this comment or credits       //
//  of supporting developers from this source code or any supporting         //
//  source code which is considered copyrighted (c) material of the          //
//  original comment or credit authors.                                      //
//                                                                           //
//  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 Chronolab Australia        //
//  Chronolabs International PO BOX 699, DULWICH HILL, NSW, 2203, Australia  //
//  ------------------------------------------------------------------------ //
$mt=time()+microtime();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>QCP135 Leaver Debug</title>
<style type="text/css">
<!--
body,td,th {
    font-family: Verdana, Arial, Helvetica, sans-serif;
    font-size: 14px;
    color: #006699;
}
body {
    background-color: #FFFFCC;
    background-image: url(QCP135-background.png);
    background-repeat: repeat;
    margin-left: 35px;
    margin-top: 45px;
    margin-right: 35px;
    margin-bottom: 80px;
}
-->
</style></head>

<body>
<div style="float:left; "><a style="border:hidden;" href="http://www.chronolabs.org.au/articles/Source-Code/QCP135-Variable-Checksum/"><img src="QCP135-Logo.png" /></a></div>
<? if (!isset($_POST['charstring'])&&!isset($_POST['seed'])&&!isset($_POST['length'])) { ?>
<form id="form1" name="form1" method="post" action="" target="_blank">
  <label>Seed (0-255)
  <input name="seed" type="text" id="seed" value="128" size="5" maxlength="3" />
  </label>
  <label>Length
  <input name="length" type="text" id="length" value="28" size="5" maxlength="3" />
  </label>
  <label>Characters to test
  <input name="charstring" type="text" id="charstring" value="" size="15" maxlength="11" />
  </label>
  <label>
  <input type="submit" name="Submit" id="Submit" value="Submit" />
  </label>
</form>
<? ?>
<div style="clear:both">&nbsp;</div>
<h2>Debug Examples:</h2>
<ol>
  <li>
    Test Base (<a href="debug_base.php">debug_base.php</a>)
  </li>
  <li>
    Test Enumerator (<a href="debug_enumerator.php">debug_enumerator.php</a>)
  </li>
  <li>
    Index (<a href="index.php">index.php</a>)<br />
  </li>
</ol>
<pre>

<? 
    
if (isset($_POST['charstring'])&&isset($_POST['seed'])&&isset($_POST['length']))
    {
        
error_reporting(0);
        class 
qcp135
        
{
        
        }
    
        require (
'class/qcp135.base.php');
        require (
'class/qcp135.enumerator.php');
        require (
'class/qcp135.leaver.php');
        
        
$qcp135_base = new qcp135_base((int)$_POST['seed']);
        
$enumerator = new qcp135_enumerator($qcp135_base);
                
        for (
$i=1$i<strlen($_POST['charstring']); $i++)
        {
            
$enum_calc $enumerator->enum_calc(substr($_POST['charstring'],$i,1),$enum_calc);
        }
        
        
error_reporting(0);
        
        
$crc = new qcp135_leaver($enum_calc$qcp135_base$_POST['length']);
        echo 
"Milliseconds: ".(abs((time()+microtime())-$mt)*1000)."\n";
        
print_r($crc);
    }
?>

</pre>

</body>
</html>