・ソース koyomiM.php
<?php
date_default_timezone_set('Asia/Tokyo');
$api = 'https://koyomi.zingsystem.com/api/';
$param = array(
'mode' => "m"
,'cnt' => "1"
,'targetyyyy' => date("Y")
,'targetmm' => date("m")
,'targetdd' => date("d")
);
$ch = curl_init($api);
## パラメータを設定
curl_setopt($ch, CURLOPT_URL, $api);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, TRUE);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($param));
## 結果を取得
$result = curl_exec($ch);
## コネクション切断
curl_close($ch);
## 連想配列にデコード
$data = json_decode($result, true);
## 月初日
$starttimestamp_date = date("Y") . "-" . date("m") . "-01";
## 翌月初日
$stoptimestamp_date = date("Y-m-d", strtotime($starttimestamp_date . " 1 month" ));
$w = date( 'w',strtotime( $starttimestamp_date ));
## 月曜はじまりの場合
if( $w === "0"){
$w = 7;
}
## 日曜はじまりの場合
#$w = $w + 1;
$cell = 0;
?>
<table style="border: 1px #666666 solid; border-collapse:collapse; font-color: #111111;"><tbody>
<tr>
<td style="border: 1px solid gray;font-size: 10px;color: #000000;"><?php echo("月") ?></td>
<td style="border: 1px solid gray;font-size: 10px;color: #000000;"><?php echo("火") ?></td>
<td style="border: 1px solid gray;font-size: 10px;color: #000000;"><?php echo("水") ?></td>
<td style="border: 1px solid gray;font-size: 10px;color: #000000;"><?php echo("木") ?></td>
<td style="border: 1px solid gray;font-size: 10px;color: #000000;"><?php echo("金") ?></td>
<td style="border: 1px solid gray;font-size: 10px;color: #0000CC;background-color:#ccffff;"><?php echo("土") ?></td>
<td style="border: 1px solid gray;font-size: 10px;color: #FF0000;background-color:#ffeeff;"><?php echo("日") ?></td>
</tr>
<tr>
<?php
## カレンダー最初の空白部分
for($i =1;$i < $w;$i++){
?>
<td style="border: 1px solid gray;"></td>
<?php } ?>
<?php
## 日付部分
for($i =$starttimestamp_date;$i < $stoptimestamp_date;$i=date("Y-m-d", strtotime($i . " 1 day" ))){
$date = $data['datelist'][$i];
if($date['week'] === "日"){
$color="#FF0000";
}
else if($date['week'] === "土"){
$color="#0000CC";
}
else if($date['holiday'] !== ""){
$color="#FF0000";
}
else{
$color="#000000";
}
?>
<?php
if($cell === 0){
$cell = $w;
}elseif($cell === 1){
?>
<tr>
<?php }?>
<td style="border: 1px solid gray;color: <?php echo($color) ?>;">
<span style="font-size: 20px;"><?php echo(date("d", strtotime($i))) ?></span><br>
<span style="font-size: 8px;"><?php echo("旧" . $date['kyurekim']."月".$date['kyurekid'] . "日") ?></span><br>
<?php echo($date['sekki']) ?><br>
<?php echo($date['rokuyou']) ?><br>
<?php echo($date['zyusi'] . "" . $date['zyunisi']) ?><br>
<?php echo( $date['holiday']) ?>
</td>
<?php
if($cell === 7){
$cell = 1;
?>
</tr>
<?php
}else{
++$cell;
}
?>
<?php } ?>
</tbody></table>
|