0) { $m=$prm; } else { $m= date("m"); } $d= date("d"); // Finds today's date if(isset($y) and $y > 0) { //get y from query } else { $y= date("Y"); // Finds today's year } $caldescr[]=array(); /////////////////////////////////////////////////////////////// //if ($_SERVER[REMOTE_ADDR]=="10.112.223.247") { $res=Array(); //$handle = @fopen("http://www.google.com/calendar/ical/9499d9k8fjvi8no41f2r5q6fsg%40group.calendar.google.com/public/basic.ics", "r"); $handle = @fopen("https://www.google.com/calendar/ical/9499d9k8fjvi8no41f2r5q6fsg%40group.calendar.google.com/public/basic.ics", "r"); if ($handle) { while (($buffer = @fgets($handle, 4096)) !== false) { $buffer=trim($buffer); //echo $buffer; $buffer=explode(":",$buffer); if ($buffer[0]=="BEGIN") { //printr($res); //printr($buffer); $_name=$res[SUMMARY]; $_yea=substr($res["DTSTART"],0,4); $_mon=substr($res["DTSTART"],4,2); $_dat=substr($res["DTSTART"],6,2); $_dat=floor($_dat); $_yeae=substr($res["DTEND"],0,4); $_mone=substr($res["DTEND"],4,2); $_date=substr($res["DTEND"],6,2); $_date=floor($_date); //echo "$_dat-$_mon-$_yea-$y/$m
"; if (floor($_yea)==$y && floor($_mon)==$m) { for($i=$_mon; $i<=$_mone;$i++) { for($j=$_dat; $j<=$_date;$j++) { $caldescr[$j][text]=$_name; $caldescr[$j][type]="bye"; } } //$caldescr[$_dat][text]=$_name; //$caldescr[$_dat][type]="bye"; } unset($res); } else { $buffertemp=explode(";",$buffer[0]); //printr($buffertemp); $res[$buffertemp[0]]=iconvth($buffer[1]); } } if (!feof($handle)) { echo "Error: unexpected fgets() fail\n"; } fclose($handle); } //} //printr($caldescr); ////////////////////////////////////////////////////////////// //db gather s $weeklyclose=tmq_dump("weeklyclose","dat","dat"); $s=tmq("select * from closeservice where mon=$m and (yea=$y or yea=$y+543 or yea=-1)"); $byedb=array(); while ($r=tmq_fetch_array($s)) { //print_r($r); $caldescr[$r[dat]][text]=getlang($r[descr]); $caldescr[$r[dat]][type]="bye"; } //db gather e $no_of_days = date('t',mktime(0,0,0,$m,1,$y)); // This is to calculate number of days in a month $j= date('w',mktime(0,0,0,$m,1,$y)); // This will calculate the week day of the first day of the month for($k=1; $k<=$j; $k++){ // Adjustment of date starting $adj .=" "; } /// Starting of top line showing name of the days of the week $qm_back=floor($m)-1; $qm_forward=floor($m)+1; $qy_back=$y; $qy_forward=$y; if ($qm_back==0) { $qm_back=12; $qy_back=$qy_back-1; } if ($qm_forward==12) { $qm_forward=1; $qy_forward=$qy_forward+1; } echo ""; echo ""; ////// End of the top line showing name of the days of the week////////// //////// Starting of the days////////// for($i=1;$i<=$no_of_days;$i++){ $today=date("N",mktime(0, 0, 0, $m, $i, $y)); $bgcol="#f7f7f7"; $brdr=""; $bgimg=""; $brdrs="solid"; $brdrw=1; if ($i==$d && $m== date("m") && $y == date("Y")) { $caldescr[$i][text]="วันนี้"; //$bgcol="#33FF00"; $bgimg="blink.gif"; $brdr="#000000"; $brdrw=1; } if ($today==6) { $bgcol="#DEE0E0"; } if ($today==7) { $bgcol="#DEE0E0"; } if ($caldescr[$i][type]=="bye") { $bgcol="#DDE3EC"; $brdr="#FF0000"; $brdrw=0; } if ($weeklyclose[$today]!="" || $weeklyclose[$today-7]!="") { $brdr="#FF0000"; $brdrw="0"; } echo $adj.""; $adj=''; $j ++; if($j==7){echo ""; $j=0;} } echo "
< ".$thaimonstrbrief[floor(date('m',mktime(0,0,0,$m,1,$y)))]." ".($y+543)." >
".$thaidayshortstr[0]."".$thaidayshortstr[1]."".$thaidayshortstr[2]."".$thaidayshortstr[3]."".$thaidayshortstr[4]."".$thaidayshortstr[5]."".$thaidayshortstr[6]."
$i
"; // This will display the date inside the calendar cell echo "
"; if ($m!= date("m") || $y != date("Y")) { echo "
ไปยังเดือนปัจจุบัน
"; } ?>