<?php require('template.hack');
/*
rot13.hack---converts text using rot13.
Chris K. Young <cky@pobox.com>, January 2003.
$Id: rot13.hack,v 1.2 2004/03/29 13:27:25 cky Exp $
Copyright (c) 2003, 2004 Chris K. Young. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public Licence as published by
the Free Software Foundation; either version 2 of the Licence, 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 Licence for more details.
You should have received a copy of the GNU General Public Licence
along with this program; if not, write to Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*/
class rot13 {
var $tmpl;
function common_form($text) {
?>
<form action="<?php print($_SERVER['PHP_SELF']); ?>" method="post">
<p><textarea name="text" rows="8" cols="64" accesskey="t"><?php print(htmlspecialchars($text)); ?></textarea></p>
<p><input type="submit" value="Convert now!" accesskey="c" /></p>
</form>
<?php
}
function print_header() {
$this->tmpl = new template('The rot13 gimmick');
$this->tmpl->set_rcsid('$Id: rot13.hack,v 1.2 2004/03/29 13:27:25 cky Exp $');
$this->tmpl->print_header();
}
function validate_input() {
return isset($_POST['text']);
}
function process_input() {
$text = $_POST['text'];
?>
<p>The original text was:</p>
<?php $this->common_form($text); ?>
<hr />
<p>The converted text is:</p>
<pre><?php print(htmlspecialchars(str_rot13($text))); ?></pre>
<?php
}
function print_form() {
?>
<p>The <samp>rot13</samp> gimmick converts the input text using rot13, and displays the result.</p>
<?php
$this->common_form('');
}
function print_footer() {
$this->tmpl->print_footer();
}
}
?>