/ Published in: PHP
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!
Substitute your own preferred method of input filtering.
I am just a PHP amateur so don't hate on my code!
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php require_once("class.inputfilter_clean.php"); function sec2hms ( $sec, $padHours = false ) { $hms = ""; $hms .= ( $padHours ) : $hours. ':'; 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>
URL: http://ross.uber.name/golden.php