/home/banprang/domains/plai.go.th/public_html/coremain/module/calendar/calendar_1.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
<?php
$per 
id_top_permission("2");
if (!isset(
$_SESSION))
  
session_start();
import_request_variables('pG''p_');
if (
$p_Y != "") {
  
$Y trim($p_Y);
}
if (
$p_m != "") {
  
$m trim($p_m);
}

$contact $_GET['contact'];
$now gmmktime();
$lt localtime($now1);
$is_dst $lt["tm_isdst"];
$now_year intval(gmdate("Y"$now));
$now_month intval(gmdate("m"$now));
$now_date intval(gmdate("d"$now));
$now_hour gmdate(gmdate("H"$now));
$now_min gmdate(gmdate("i"$now));
$now_sec gmdate(gmdate("s"$now));
$nowthai_year $now_year 543;


if (!empty(
$_SERVER["PHP_SELF"]))
  
$PHP_SELF $_SERVER["PHP_SELF"];

if (!empty(
$_SERVER["SCRIPT_NAME"]))
  
$SCRIPT_NAME $_SERVER["SCRIPT_NAME"];

if (!empty(
$_SERVER["SERVER_NAME"]))
  
$SERVER_NAME $_SERVER["SERVER_NAME"];

if (!empty(
$_SERVER["REMOTE_ADDR"]))
  
$REMOTE_ADDR $_SERVER["REMOTE_ADDR"];



$_mo="จ";
$_tu="อ";
$_we="พ";
$_th="พฤ";
$_fr="ศ";
$_sa="ส";
$_su="อา";

$_month_name=array();
$_month_name[1]="มกราคม";
$_month_name[2]="กุมภาพันธ์";
$_month_name[3]="มีนาคม";
$_month_name[4]="เมษายน";
$_month_name[5]="พฤษภาคม";
$_month_name[6]="มิถุนายน";
$_month_name[7]="กรกฎาคม";
$_month_name[8]="สิงหาคม";
$_month_name[9]="กันยายน";
$_month_name[10]="ตุลาคม";
$_month_name[11]="พฤศจิกายน";
$_month_name[12]="ธันวาคม";

if (!empty(
$Y))
  
$cal_year $Y;
else
  
$cal_year $now_year;
$thai_year = ($cal_year) + 543;

if (!empty(
$m))
  
$cal_month $m;
else
  
$cal_month $now_month;

if (!empty(
$HTTP_GET_VARS["d"]))
  
$cal_day $HTTP_GET_VARS["d"];
else
  
$cal_day $now_day;

$cal_next_year $cal_year;
if (
$cal_month 12) {
  
$cal_next_month $cal_month 1;
} else {
  
$cal_next_month 1;
  
$cal_next_year $cal_year 1;
}

$cal_prev_year $cal_year;
if (
$cal_month 1) {
  
$cal_prev_month $cal_month 1;
} else {
  
$cal_prev_month 12;
  
$cal_prev_year $cal_year 1;
}

function 
num_days($year$month) {
  
$num 31;
  while (!
checkdate($month$num$year)) {
    
$num--;
  }
  return 
$num;
}

echo <<<CALENDAR_HEAD
<table width=100% border=0 cellspacing=1 cellpadding=0 bgcolor='$_SESSION[tb_head_bgcolor]'>
  <tr>
    <td align=center class=norm width=10%><a href="index.php?Y=
$cal_prev_year&m=$cal_prev_month"><IMG SRC="coremain/images/p.gif"  BORDER=0 ></a></td>
    <td align=center class=norm colspan=5> 
$_month_name[$cal_month] $thai_year </td>
    <td align=center class=norm width=10%><a href="index.php?Y=
$cal_next_year&m=$cal_next_month"><IMG SRC="coremain/images/n.gif"  BORDER=0 ></a></td>
  </tr>
  <tr align=center class=norm>
    <td width=10% bgcolor=
$datatm[color1]><font color=white>$_su</font></td>
    <td width=10% bgcolor=
$datatm[heder_color]>$_mo</td>
    <td width=10% bgcolor=
$datatm[heder_color]>$_tu</td>
    <td width=10% bgcolor=
$datatm[heder_color]>$_we</td>
    <td width=10% bgcolor=
$datatm[heder_color]>$_th</td>
    <td width=10% bgcolor=
$datatm[heder_color]>$_fr</td>
    <td width=10% bgcolor=
$datatm[heder_color]>$_sa</td>
  </tr>
CALENDAR_HEAD;

if ((
$cal_year == $now_year) && ($cal_month == $now_month)) {
  
$today_day $now_day;
} else
  
$today_day 0;

$days_last_month num_days($cal_prev_year$cal_prev_month);
$days_this_month num_days($cal_year$cal_month);

$first_day_pos gmdate("w"gmmktime(100$cal_month2$cal_year$is_dst));
if (
$first_day_pos == 0)
  
$first_day_pos 7;
$day_num $days_last_month - ($first_day_pos 2);
$class "norm";

echo 
$now_date;

for (
$y 1$y <= 6$y++) {
  echo
"<tr align=center>\n";
  for (
$x 1$x <= 7$x++) {
    if ((
$y == 1) && ($x == $first_day_pos)) {
      
$day_num 1;
      
$class "";
    }
    if ((
$y 1) && ($day_num == $days_this_month 1)) {
      
$day_num 1;
      
$class "norm";
    }
//echo $day_num."===".($days_this_month+1)." - - class = $class";
    
if ($class != "") {
      
$ap1 "";
      
$ap2 "";
    } else {
      
//echo_r ($_SESSION);
      
$mydate sprintf("%04d-%02d-%02d"$cal_year$cal_month$day_num);
      
$ap0 "coremain/module/calendar/showevent.php";
      
$ap1 "<a href=javascript:open_window('" $ap0 "?per=$per&date=$day_num&month=$cal_month&year=$cal_year&dbname=$_SESSION[web_name]') class=date>";
      
$ap2 '</a>';
      
//    "'.$ap0."?member_c=".$_SESSION["member"].'&date=$day_num&month=$cal_month&year=$cal_year&dbnmae=$_SESSION[webname]"
    
}

//echo $day_num."---".$now_date."class = $class<br/>";
    
if (($class == "") && ($day_num == $now_date)) {
      echo
'<td bgcolor=#ffcc33><b>' $ap1 '' $day_num $ap2 '</b></td>' "\n"// วันที่ปัจจุบัน
    
} else if ($class == "") {
      
$dates substr($mydate82);
      
$ch_date substr($dates01);
      if (
$ch_date == "0")
        
$dates substr($dates11);
      
$months substr($mydate52);
      
$years substr($mydate04);
      
$date_color $dates "-" $months "-" $years;
      
$sql "SELECT date FROM cms_calendar WHERE `date`='$date_color'";
      
$re mysql_query($sql);
      
$data mysql_fetch_array($re);
      if (
$data[0] != "") {// วันที่ที่มีจริงในแต่ละเดือน
        
echo'<td bgcolor=#cccccc>' $ap1 '' $day_num $ap2 '</td>' "\n";
      } else {
        echo
'<td bgcolor=#fdfef1>' $ap1 '' $day_num $ap2 '</td>' "\n";
      }
    } else {
      echo
'<td class=today1  bgcolor=#ffffff><font color="#dbdbdb">' $ap1 $day_num $ap2 '</font></td>' "\n";  // วันที่ที่ไม่มีจริงในแต่ละเดือน
    
}

    
$day_num++;
  }
  echo
"</tr>";
}



echo <<<CALENDAR_TAIL
  <tr>
    <td colspan=7 align=center bgcolor=#ffffff >วันที่ 
$now_date $_month_name[$now_month] $nowthai_year</td>
  </tr>
CALENDAR_TAIL;

echo 
"<tr>";
echo
"<td colspan=7 bgcolor=#ffffff>";
  
$sql "SELECT * FROM cms_calendar WHERE date = '$date-$month-$year' ORDER BY id DESC";
  
$re mysql_query($sql);
  while (
$data mysql_fetch_array($re)) {
    echo 
" &nbsp;<img src='coremain/images/marker.gif' border=0> " $data['event'] . "<br>";
  }
echo
"</td>";
echo
"</tr>";
echo
"</table>";
?>

</center>
<script language="JavaScript">
<!-- 
function open_window(url) {
awindow = window.open(url,"thewindow",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=580,height=300');
}
// -->
</script>