usr_data.inc
4.11 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
<?PHP
//*****************************************************************************
//*
//* プログラム名:e-イベント
//* プログラムID:usr_input.inc
//* 機能 :イベント登録画面
//* 作成者 :
//*
//*****************************************************************************
header("Content-type: text/html; charset=shift-jis");
function fgetcsv_reg (&$handle, $length = null, $d = ',', $e = '"') {
$d = preg_quote($d);
$e = preg_quote($e);
$_line = "";
while ($eof != true) {
$_line .= (empty($length) ? fgets($handle) : fgets($handle, $length));
$itemcnt = preg_match_all('/'.$e.'/', $_line, $dummy);
if ($itemcnt % 2 == 0) $eof = true;
}
$_csv_line = preg_replace('/(?:\\r\\n|[\\r\\n])?$/', $d, trim($_line));
$_csv_pattern = '/('.$e.'[^'.$e.']*(?:'.$e.$e.'[^'.$e.']*)*'.$e.'|[^'.$d.']*)'.$d.'/';
preg_match_all($_csv_pattern, $_csv_line, $_csv_matches);
$_csv_data = $_csv_matches[1];
for($_csv_i=0;$_csv_i<count($_csv_data);$_csv_i++){
$_csv_data[$_csv_i]=preg_replace('/^'.$e.'(.*)'.$e.'$/s','$1',$_csv_data[$_csv_i]);
$_csv_data[$_csv_i]=str_replace($e.$e, $e, $_csv_data[$_csv_i]);
}
return empty($_line) ? false : $_csv_data;
}
require('../../function/sortrog.inc');
require('../../function/operatezero.inc');
require('../../function/tblctl.inc');
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);
// タグ無効化等の処理をする
$Event_Name = convstr($Event_Name);
$Hp_Addr = convstr($Hp_Addr);
$place = "";
$Hp_Message = convstr($Hp_Message);
$eventymd = $from_date;
//変更後の日付を取得
$after_yy = substr($eventymd,0,4);
$after_mm = substr($eventymd,4,2);
$after_dd = substr($eventymd,6,2);
// ログファイル名###
$ddir = "./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));
//変更後の日付を取得
$after_yy2 = substr($str_edit_date,0,4);
$after_mm2 = substr($str_edit_date,4,2);
$after_dd2 = substr($str_edit_date,6,2);
$logfile = "eventmst".$after_mm2.".csv";
$filename = $ddir.$logfile;
// ログファイルを開く
$fp = @fopen("$filename", "r+");
if ($fp == False){
echo $filename = $ddir.$logfile;
print("ファイルを開くのに失敗しました。<BR>\n");
exit;
}
// ファイルをロックする
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]=$Event_Name;
$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]=$Hp_Addr;
$buf[$count][11]=$Hp_Message;
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);
}
header("Location:calendar.php");
?>