[insert_php]

ini_set(‚display_errors‘,1);
ini_set(‚display_startup_errors‘,1);
error_reporting(-1);

//This gets requested or today’s date and puts the day, month, and year in seperate variables

$date=$_GET[„date“];

if (!isset($date)) {
$date = time ();
$day = date(‚d‘, $date) ;
$month = date(‚m‘, $date) ;
$year = date(‚Y‘, $date) ;
}
else {
$day = 1 ;
$month = substr($date,-2,2);
$year = substr($date,-6,4) ;
}

//This checks validity of date

if (!checkdate($month,$day,$year)) {
$date = time ();
$day = 1;
$month = 1;
$year = 2009 ;
}

//Here we generate the first day of the month
$first_day = mktime(0,0,0,$month, 1, $year) ;

//We then determine how many days are in the current month
$days_in_month = cal_days_in_month(0, $month, $year) ;

if (month==12) $nextclickdate = mktime(0,0,0, 1, 1, $year+1);
else $nextclickdate = mktime(0,0,0,$month+1, 1, $year);

if (month==1) $prevclickdate = mktime(0,0,0, 12, 1, $year-1);
else $prevclickdate = mktime(0,0,0,$month-1, 1, $year);

//This gets us the month name
$title = date(‚F‘, $first_day);

$prevmonth = date(‚F‘, $prevclickdate);
$nextmonth = date(‚F‘, $nextclickdate);

$prevclickdate = date(‚Ym‘, $prevclickdate);
$nextclickdate = date(‚Ym‘, $nextclickdate);

//Here we find out what day of the week the first day of the month falls on
$day_of_week = date(‚D‘, $first_day) ;

//Once we know what day of the week it falls on, we know how many blank days occure before it. If the first day of the week is a Sunday then it would be zero
switch($day_of_week){
case „Sun“: $blank = 6; break;
case „Mon“: $blank = 0; break;
case „Tue“: $blank = 1; break;
case „Wed“: $blank = 2; break;
case „Thu“: $blank = 3; break;
case „Fri“: $blank = 4; break;
case „Sat“: $blank = 5; break;
}

//Here we start building the table heads
$title = ‚

 
'.$prevmonth.'
  ‚.$title.‘ ‚.$year.‘  
'.$nextmonth.'

‚;

$title = str_replace („ary“,“ár“,$title);
$title = str_replace („March“,“Marec“,$title);
$title = str_replace („April“,“Aprí­l“,$title);
$title = str_replace („May“,“Máj“,$title);
$title = str_replace („June“,“Jún“,$title);
$title = str_replace („July“,“Júl“,$title);
$title = str_replace („October“,“Október“,$title);

echo $title.‘

‚;
echo ‚

‚;

//This counts the days in the week, up to 7
$day_count = 1;

//first we take care of those blank days
while ( $blank > 0 )
{
echo ‚

‚;
$blank = $blank-1;
$day_count++;
}

//sets the first day of the month to 1
$day_num = 1;

//count up the days, untill we’ve done all of them in the month
while ( $day_num <= $days_in_month ) { $pdns = date('D', (mktime(0,0,0,$month, $day_num, $year))); switch($pdns){ case "Sun": $dns = "Ne"; break; case "Mon": $dns = "Po"; break; case "Tue": $dns = "Ut"; break; case "Wed": $dns = "Str"; break; case "Thu": $dns = "Stv"; break; case "Fri": $dns = "Pi"; break; case "Sat": $dns = "So"; break; } if ($day_num < 10) { $day_num = "0".$day_num; } $mp3file = "http://www.mladymisionar.sk/images/stories/mp3/slovo/$year/Slovo-$year-$month-$day_num-$dns.mp3"; $day_num = 0 + $day_num; clearstatcache(); if ($dns=="So" or $dns=="Ne") $classa = "cals"; else $classa = "caln"; //if (file_exists($mp3file)) { echo '

‚;
//}
/*else {
echo ‚

‚;
}*/

$day_num++;
$day_count++;

//Make sure we start a new row every week
if ($day_count > 7)
{

$day_num = $day_num-1;

if ($day_num < 10) { $day_num = "0".$day_num; } $zipfile = "http://www.mladymisionar.sk/images/stories/mp3/slovo/$year/Slovo-$year-$month-$day_num.zip"; $day_num = 1 + $day_num; clearstatcache(); //if (url_exists($zipfile)) { echo '

‚;
//}
/*else {
echo “

„;
}*/

$day_count = 1;
}
}

//Finaly we finish out the table with some blank details if needed

while ( $day_count >1 && $day_count <=7 ) { echo '

‚;
$day_count++;
}

echo „

Po  Ut    St    Št    Pi    So    Ne    
‚.$day_num.‘ ‚.$day_num.‘ zip

„;

[/insert_php]