".$confirm_headline."\n\n"; // Sets the amount of time that should pass until the counting stops. Is always amount of seconds to countdown from plus 1! $limit = $sec + 1; // Sets font-unit, maximum and minimum font-size. $font_size_unit = 'em'; $font_size_max = 10; $font_size_min = (($font_size_max / $sec) > 1) ? $font_size_max / $sec : 1; // Sets maximum and minimum font-weight. $font_weight_max = 900; $font_weight_min = (($font_weight_max / $sec) > 100) ? $font_weight_max / $sec : 100; // Sets maximum and minimum opacity. Do not set to decimal numbers! $opacity_max = 99; $opacity_min = 20; // Sets maximum and minimum position. Do not move too near towards the outer boundaries, since fonts can become quite large and dissapear from the viewport! $position_max = 70; $position_min = 10; // Sets HTML-patterns with dynamic, inline CSS. Static styling is placed in the documents head or in an external stylesheet. $clock_pat = "
%s
\n"; $countdown_pat = "

%s

\n"; $confirm_pat = "
\n%s
"; // Disables all output buffering and automatically performs flush() after every print or echo. ob_implicit_flush(TRUE); // Counts until limit is reached. for($i = 0; $i < $limit; $i++) { // "Pulsates" until 1 is reached. Then redirects or prints confirmation message. if($i < $sec) { // Sets elapsed time. $elapsed = $sec - $i; // Start randomizing! Make sure stylings actually change by adding some changing value to them. In this case I use "+(1 / ($i + 1) * 10))" - a small dynamic value. srand(microtime()*1000000); // Font $font_size = rand($font_size_min,$font_size_max+(1 / ($i + 1) * 10)).$font_size_unit; $font_weight = rand($font_weight_min,$font_weight_max+(1 / ($i + 1) * 10)); // Position $top = rand($position_min,$position_max+(1 / ($i + 1) * 10)).'%'; $left = rand($position_min,$position_max+(1 / ($i + 1) * 10)).'%'; // Opacity $opacity = rand($opacity_min,$opacity_max+(1 / ($i + 1) * 10)); // Prints randomly styled countdown. printf($countdown_pat,$top,$left,$i,$font_size,$font_weight,$opacity,$opacity,$opacity,$opacity,$opacity,$elapsed); // Prints current date and time. printf($clock_pat,$i,date('r')); // "Pulsates" every 1 seconds. sleep(1); }else{ if($confirm == FALSE) { // Redirects immediately. print "\n"; }else{ // Prints confirmation message, before going to destination URL. printf($confirm_pat,$i,($font_size_max/2).$font_size_unit,$confirm_msg); } } } } ?> Randomly styled PHP Countdown