Revision: 15310
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at June 30, 2009 11:09 by rossuber
Initial Code
<?php require_once("class.inputfilter_clean.php"); function sec2hms ( $sec, $padHours = false ) { $hms = ""; $hours = intval( intval( $sec ) / 3600 ); $hms .= ( $padHours ) ? str_pad( $hours, 2, "0", STR_PAD_LEFT ). ':' : $hours. ':'; $minutes = intval( ( $sec / 60 ) % 60 ); $hms .= str_pad( $minutes, 2, "0", STR_PAD_LEFT ). ':'; $seconds = intval( $sec % 60 ); $hms .= str_pad( $seconds, 2, "0", STR_PAD_LEFT ); return $hms; } if ( $_POST["minutes"] or $_POST["seconds"] ) { $myFilter = new InputFilter( $tags, $attr, $tag_method, $attr_method, $xss_auto ); $minutes = $myFilter->process( $_POST["minutes"] ); $seconds = $myFilter->process( $_POST["seconds"] ); $goodpoint = 0.6180339887 * ( $seconds + ( $minutes * 60 ) ); $answer = sec2hms( $goodpoint ); } ?> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title> Golden Calculator </title> </head> <body> <form action="golden.php" method="post"> <p> Min: <input type="text" name="minutes" /> Sec: <input type="text" name="seconds" /> <input type="submit" /> </p> </form> <p> Answer: <strong><?php echo $answer; ?></strong> </p> </body> </html>
Initial URL
http://ross.uber.name/golden.php
Initial Description
This little bit of code is a calculator of the "golden mean" of a given length of time. For example: given a length of 1 minute and 0 seconds, the answer given will be 0:00:37. See U2's "With or Without You", the Greek Parthenon, the human body, etc. Substitute your own preferred method of input filtering. I am just a PHP amateur so don't hate on my code!
Initial Title
Golden mean calculator for a given length of time
Initial Tags
php
Initial Language
PHP