BossBey File Manager
PHP:
7.3.31-1~deb10u1
OS:
Linux
User:
www-data
Root
/
home
/
www
/
sem
/
ajaxcalender
📤 Upload
📝 New File
📁 New Folder
Close
Editing: calender.php
<?php // PHP Calendar Class Version 1.0 (26 Apr 2009) // // Copyright Raja MM 2009 - 2010. All Rights reserved. // // This software may be used, modified and distributed freely // providing this copyright notice remains intact at the head // of the file. // // This software is freeware. The author accepts no liability for // any loss or damages whatsoever incurred directly or indirectly // from the use of this script. The author of this software makes // no claims as to its fitness for any purpose whatsoever. If you // wish to use this software you should first satisfy yourself that // it meets your requirements. // // URL: http://www.PACECODE.com/blog/ // Email: pacecodes@gmail.com //This gets today's date $date =time () ; //This puts the day, month, and year in seperate variables $day = date('d', $date) ; if($_REQUEST['mon'] != "") { $month = $_REQUEST['mon']; } else { $month = date('m', $date) ; } //$year = date('Y', $date) ; $yearCal = date("n/j/Y", mktime(0, 0, 0, $month+1 , date("d")-date("d")+1, date("Y"))); $string = strtotime($yearCal); $year = date('Y',$string); /*$next_month = date("m", mktime(0, 0, 0, $month+1, 1, $year)); $prev_month = date("m", mktime(0, 0, 0, $month-1, 1, $year)); */ $next_month = $month + 1; $prev_month = $month - 1; //Here we generate the first day of the month $first_day = mktime(0,0,0,$month, 1, $year) ; //This gets us the month name $title = date('F', $first_day) ; //Here we find out what day of the week the first day of the month falls on $day_of_week = date('D', $first_day) ; //Here we find out what day of the week the first day of the month falls on $dtFirstDay = date("n/j/y", mktime(0, 0, 0, $month , date("d")-date("d")+1, date("Y"))); $dtLastDay = date("n/j/y", mktime(0, 0, 0, $month+1 , date("d")-date("d"), date("Y"))); //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 = 0; break; case "Mon": $blank = 1; break; case "Tue": $blank = 2; break; case "Wed": $blank = 3; break; case "Thu": $blank = 4; break; case "Fri": $blank = 5; break; case "Sat": $blank = 6; break; } // making timestamp for month foreg: if month value is 13 then it will be 01 $monthStamp = date("m", 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, $monthStamp, $year) ; // Navigation for the monthly calender view $Prenavigation = "<a href=\"javascript:monthViewCalNavigation('".$prev_month."');\"> <img src=\"images/lft-arrow1.gif\" alt=\"\" width=\"8\" height=\"5\" border=\"0\" /></a>"; $Nextnavigation = "<a href=\"javascript:monthViewCalNavigation('".$next_month."');\"> <img src=\"images/rght-arrow.gif\" width=\"8\" height=\"5\" border=\"0\" /></a>"; //Here we start building the table heads echo "<table border=1 width = 714 style='border-collapse:collapse;'>"; echo "<tr><th colspan=7> "; echo "<div class=\"my-calander-top\"><div class=\"clear\"></div><br /> <table width=\"714\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" class=\"pd-top\"> <tr> <td width=\"20\"> </td> <td width=\"200\" align=\"left\" valign=\"middle\"><table width=\"130\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"> <tr> <td width=\"8\" height=\"5\" align=\"center\" valign=\"middle\">".$Prenavigation."</td> <td height='8' width=\"114\" align=\"center\" valign=\"middle\" style=\"padding:0px 0px 0px 0px;\">".$dtFirstDay ." - ".$dtLastDay."</td> <td width=\"8\" height=\"5\" align=\"center\" valign=\"middle\">".$Nextnavigation."</td> </tr> </table> </td> <td width=\"434\" align=\"right\" valign=\"middle\">".$title." ".$year ."</td> <td width=\"60\"> </td> </tr> </table> </div>"; echo "</th></tr>"; echo "<tr><td width=42>Sunday</td><td width=42>Monday</td><td width=42>Tuesday</td><td width=42>Wed</td><td width=42>Thurday</td><td width=42>Friday</td><td width=42>Saturday</td></tr>"; //This counts the days in the week, up to 7 $day_count = 1; echo "<tr height='50'>"; //first we take care of those blank days while ( $blank > 0 ) { echo "<td></td>"; $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 ) { echo "<td> $day_num </td>"; $day_num++; $day_count++; //Make sure we start a new row every week if ($day_count > 7) { echo "</tr><tr height='50'>"; $day_count = 1; } } //Finaly we finish out the table with some blank details if needed while ( $day_count >1 && $day_count <=7 ) { echo "<td> </td>"; $day_count++; } echo "</tr></table>"; ?>
Save
Cancel