URL: https://www.overclockers.at/coding-stuff/countdown_php-script_171532/page_1 - zur Vollversion wechseln!
Hi Leute
folgendes Anliegen.... ich habe hier ein Countdown PHP-Script welches wie folgt aussieht:
Code: PHP<?php // MACROS define('DEBUG',false); define('DEBUG_TIME',mktime(00,15,00,11,11,2006)); define('MESSAGE_TIME_START_WDAY','sunday'); // english weekday define('MESSAGE_TIME_START_HOUR',11); // hour of day define('MESSAGE_TIME_PERIOD',4); // hours define('PAGE_TIMER','timer.html'); define('PAGE_MESSAGE','message.html'); // IMPLEMENTATION // // => Set timezone (PHP4) // ..not implemented yet! // => Set timezone (PHP5) if (function_exists('date_default_timezone_set')) date_default_timezone_set('Europe/Vienna'); // *) Calculate timestamps $nCurTime = DEBUG ? DEBUG_TIME : time(); $aCurTime = getdate($nCurTime); $nStartTime = strtotime('next '.MESSAGE_TIME_START_WDAY) + MESSAGE_TIME_START_HOUR * 3600; $aStartTime = getdate($nStartTime); if ($nStartTime - $nCurTime > 7*24*3600-MESSAGE_TIME_PERIOD*3600) { $nStartTime = mktime(MESSAGE_TIME_START_HOUR,0,0,$aCurTime['mon'],$aCurTime['mday'],$aCurTime['year']); if ($aCurTime['wday'] > $aStartTime['wday']) // => quick fix for overlapping time in period 1 $nStartTime -= 86400; if ($nCurTime > $nStartTime + MESSAGE_TIME_PERIOD * 3600) // => quick fix for overlapping time in period 2 $nStartTime = strtotime('next '.MESSAGE_TIME_START_WDAY) + MESSAGE_TIME_START_HOUR * 3600; } $aStartTime = getdate($nStartTime); // *) Message fork $bShowTimer = $nCurTime < $nStartTime; // *) Show output page $szPage = $bShowTimer ? PAGE_TIMER : PAGE_MESSAGE; $szContent = file_get_contents($szPage); if ($szContent === false) die("Error: Could not load output page [$szPage]"); // -) Set no-cache headers header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // date in the past // -) Replace current timebase if ($bShowTimer) { // -) Find current timebase $nDiffTime = $nStartTime - $nCurTime; $nDays = (int) ($nDiffTime / 86400); $nDiffTime -= $nDays * 86400; $nHours = (int) ($nDiffTime / 3600); $nDiffTime -= $nHours * 3600; $nMins = (int) ($nDiffTime / 60); $nDiffTime -= $nMins * 60; $nSecs = $nDiffTime; $szContent = str_replace(array('[DAYS]','[HOURS]','[MINS]','[SECS]'),array($nDays,$nHours,$nMins,$nSecs),$szContent); } echo $szContent; ?>
hat sich inzwischen erledigt.... thx mat 
overclockers.at v4.thecommunity
© all rights reserved by overclockers.at 2000-2026