evententry.php
6.2 KB
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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
<?PHP
header("Content-type: text/html; charset=shift-jis");
include('./include/smarty.conf');
//セッション開始
require_once("./include/session_start.inc");
include("./ini.php");
$o_smarty->assign('_USR_ROOT_URL_', $_USR_ROOT_URL_."/".$_SESSION["PHP_CAL_FOLDER"]."/calendar.php");
ob_start();
$home ="main_menu.php";
require('function/sortrog.inc');
require('function/operatezero.inc');
require('function/tblctl.inc');
require('function/tblmake.inc');
fun_backhome($hiduke);
list($eventy,$eventm,$eventd)=split(",",$hiduke);
$intCnt = $eventy;
$opt1 = "";
$opt1 .= "<option value=".$intCnt;
if ($fyear==$intCnt){
$opt1 .= " selected";
}
$opt1 .= ">".$intCnt."年</option>";
$o_smarty->assign('opt1',$opt1);
$opt2 = "";
for ($intCnt = 1 ; $intCnt <= 12 ; $intCnt++) {
if (strlen($intCnt)==1){
$opt2 .= "<option value=0".$intCnt;
}else{
$opt2 .= "<option value=".$intCnt;
}
if ($eventm == $intCnt){
$opt2 .= " selected";
}
$opt2 .= ">".$intCnt."月</option>";
}
$o_smarty->assign('opt2',$opt2);
$opt3 = "";
for ($intCnt = 1 ; $intCnt <= 31 ; $intCnt++) {
if (strlen($intCnt)==1){
$opt3 .= "<option value=0".$intCnt;
}else{
$opt3 .= "<option value=".$intCnt;
}
if ($eventd == $intCnt){
$opt3 .= " selected";
}
$opt3 .= ">".$intCnt."日</option>";
}
$o_smarty->assign('opt3',$opt3);
$opt4 = "";
for ($intCnt = $eventy ; $intCnt <= $eventy+1 ; $intCnt++) {
$opt4 .= "<option value=".$intCnt;
if ($eventy==$intCnt){
$opt4 .= " selected";
}
$opt4 .= ">".$intCnt."年</option>";
}
$o_smarty->assign('opt4',$opt4);
$opt5 = "";
for ($intCnt = 1 ; $intCnt <= 12 ; $intCnt++) {
if (strlen($intCnt)==1){
$opt5 .= "<option value=0".$intCnt;
}else{
$opt5 .= "<option value=".$intCnt;
}
if ($eventm == $intCnt){
$opt5 .= " selected";
}
$opt5 .= ">".$intCnt."月</option>";
}
$o_smarty->assign('opt5',$opt5);
$opt6 = "";
for ($intCnt = 1 ; $intCnt <= 31 ; $intCnt++) {
if (strlen($intCnt)==1){
$opt6 .= "<option value=0".$intCnt;
}else{
$opt6 .= "<option value=".$intCnt;
}
if ($eventd == $intCnt){
$opt6 .= " selected";
}
$opt6 .= ">".$intCnt."日</option>";
}
$o_smarty->assign('opt6',$opt6);
$o_smarty->assign('hidHiduke',"<input type=\"hidden\" name=\"hiduke\" value =$hiduke>");
$o_smarty->assign('dd', $dd);
$o_smarty->assign('home', $home);
$o_smarty->assign('pageName', $pageName);
// カレンダー画面から引き継いだ情報を展開する。
list($eventy,$eventm,$eventd)=split(",",$hiduke);
// Keyの日付を作成する。
if ($jun != "")
{
$from_date = $jyear.fun_addzero($jmon).$jun;
}
else
{
$from_date = $fyear.fun_addzero($fmon).fun_addzero($fday);
}
$to_date = $tyear.fun_addzero($tmon).fun_addzero($tday);
// 送信ボタンが押されたときは、フォームの内容をファイルに保存する
if ($submit != ""){
// タグ無効化等の処理をする
//$eventname = convstr($eventname);
//$hpadrs = convstr($hpadrs);
//$place = convstr($place);
//$tipword = convstr($tipword);
$eventymd = $from_date;
//変更後の日付を取得
$after_yy = substr($eventymd,0,4);
$after_mm = substr($eventymd,4,2);
$after_dd = substr($eventymd,6,2);
// ログファイル名###
$ddir = "./calendar/".$_SESSION["PHP_CAL_FOLDER"]."/data/event/";
//イベント登録
if (trim($to_date) ==""){
$int_E_date=date("z",mktime(0,0,0,$after_mm,$after_dd,$after_yy));
}else{
$after_to_yy = substr($to_date,0,4);
$after_to_mm = substr($to_date,4,2);
$after_to_dd = substr($to_date,6,2);
$int_E_date=date("z",mktime(0,0,0,$after_to_mm,$after_to_dd,$after_to_yy));
}
$int_S_date=date("z",mktime(0,0,0,$after_mm,$after_dd,$after_yy));
for($intdateCnt = 0; $intdateCnt < ($int_E_date -$int_S_date+1) ; $intdateCnt++){
//期間1、期間2の編集
$str_wk_dd = $after_dd + $intdateCnt;
$str_wk_dd = fun_addzero($str_wk_dd);
$str_edit_date=date("Ymd",mktime(0,0,0,$after_mm,$str_wk_dd,$after_yy));
//echo "日付".$str_edit_date."<BR>";
//変更後の日付を取得
$after_yy2 = substr($str_edit_date,0,4);
$after_mm2 = substr($str_edit_date,4,2);
$after_dd2 = substr($str_edit_date,6,2);
//入力日付が引き継ぎ情報から変更された場合
//if (fun_addzero($eventm) != $after_mm){
// $eventm = $after_mm;
//}
$logfile = "eventmst".$after_mm2.".csv";
//$logfile = "eventmst".fun_addzero($eventm).".csv";
$filename = $ddir.$logfile;
// ログファイルを開く
$fp = @fopen("$filename", "r+");
if ($fp == False)
{
echo $filename = $ddir.$logfile;
print("ファイルを開くのに失敗しました。<BR>\n");
exit;
}
/*
if ($from_date == $to_date){
$tyear = "";
$tmon = "";
$tday = "";
}
*/
// ファイルをロックする
set_file_buffer($fp, 0);
flock($fp, 2);
// ファイルポインタをファイルの先頭に戻す
rewind($fp);
// メッセージの読み込み数を数える変数を初期化する
$count = 0;
// ファイルの最後まで読み込む
while ($readbuf = fgetcsv_reg($fp,4096))
{
$buf[$count] = $readbuf;
$count++;
}
// 配列の最後に、入力されたメッセージを追加する
//echo $str_edit_date."<BR>";
$buf[$count][0]=$str_edit_date;
$buf[$count][1]=fun_eveidx($buf,$count,$str_edit_date);
$buf[$count][2]=$eventname;
$buf[$count][3]=$fyear;
$buf[$count][4]=fun_addzero($after_mm);
$buf[$count][5]=fun_addzero($after_dd);
$buf[$count][6]=$tyear;
$buf[$count][7]=fun_addzero($tmon);
$buf[$count][8]=fun_addzero($tday);
$buf[$count][9]=$place;
$buf[$count][10]=$hpadrs;
$buf[$count][11]=$tipword;
usort($buf,idxsort);
usort($buf,mycmp);
// ファイルポインタを先頭に戻す
rewind($fp);
// メッセージをファイルに書き込む
for ($i = 0; $i <= $count; $i++){
$tbl_save = join(",",$buf[$i]);
//echo join(",",$buf[$i])."<BR>";
fputs($fp, $tbl_save . "\n");
}
unset($buf);
// ファイルのロックを解除して、ファイルを閉じる
flock($fp, 3);
fclose($fp);
}
/* ---------------------------------------------------------------------- */
$mmanu = "<script>location.replace('main_menu.php');</script>";
}
$o_smarty->assign('mmanu', $mmanu);
$o_smarty->assign('PHP_CAL_NAME',$_SESSION["PHP_CAL_NAME"]);
$o_smarty->assign('PHP_manual_NM',"<a href='../e-manual/' target='_blank'>");
$o_smarty->display('evententry_t.tpl');
$o_smarty->display('header.tpl');
$o_smarty->display('evententry_f.tpl');
?>