eventdel.php
2.83 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
<?php
ob_start();
//セッション開始
require_once("./include/session_start.inc");
require('function/operatezero.inc');
require('function/sortrog.inc');
require('function/tblctl.inc');
fun_backhome($file_month);
//受け取った削除情報配列の項目数を数える
$num = count($touroku);
if ($num != 0){
//マスタファイルのオープン
$ddir = "data/event/";
$filename = $ddir."eventmst".fun_addzero($file_month).".csv";
$fp = @fopen("$filename", "r+");
if ($fp == False){
print("Failed to open file.<BR>\n");
exit;
}
//書き込みファイルをロックする
set_file_buffer($fp, 0);
flock($fp, 2);
//ファイルポインタを先頭に戻す
rewind($fp);
//各変数の初期化
$mstcnt = 0;
//マスタファイルを読み込み、レコード件数を数える
while($mst_read = fgetcsv($fp, 4096)){
$mstbuf[$mstcnt] = $mst_read;
//$mstbuf[$mstcnt][0] = '"'.$mstbuf[$mstcnt][0].'"';
//$mstbuf[$mstcnt][1] = '"'.$mstbuf[$mstcnt][1].'"';
$mstbuf[$mstcnt][2] = '"'.$mstbuf[$mstcnt][2].'"';
$mstbuf[$mstcnt][3] = $mstbuf[$mstcnt][3];
$mstbuf[$mstcnt][4] = $mstbuf[$mstcnt][4];
$mstbuf[$mstcnt][5] = $mstbuf[$mstcnt][5];
$mstbuf[$mstcnt][6] = $mstbuf[$mstcnt][6];
$mstbuf[$mstcnt][7] = $mstbuf[$mstcnt][7];
$mstbuf[$mstcnt][8] = $mstbuf[$mstcnt][8];
$mstbuf[$mstcnt][9] = $mstbuf[$mstcnt][9];
$mstbuf[$mstcnt][10] = '"'.$mstbuf[$mstcnt][10].'"';
$mstbuf[$mstcnt][11] = '"'.$mstbuf[$mstcnt][11].'"';
$mstcnt++;
}
//渡されたKEYを元に一時ファイルから書き込むレコードを抽出
for ($i = 0; $i < $num; $i++){
//KEYを項目に展開
$m_idx = 0;
$found = 0;
list($touroku_ymd, $touroku_idx) = split(",", $touroku[$i]);
//KEYと合致する情報または、テーブルの最後まで
while(($m_idx < $mstcnt) && ($found == 0)){
list($key_ymd, $ev_idx, $eventname, $fnen, $fmon, $fday, $tnen, $tmon, $tday, $place, $hpadrs, $mongon) = $mstbuf[$m_idx];
if (($key_ymd == $touroku_ymd) && ($ev_idx == $touroku_idx)){
$found = 1;
}
$m_idx++;
}
//指定されたレコードが見つかった場合全項目クリア
if ($found != 0){
$mstbuf[$m_idx - 1] = "";
}
}
//データのソート
array_multisort($mstbuf, SORT_ASC);
fun_writetbl($mstbuf, $mstcnt, $fp);
// ファイルのロックを解除して、ファイルを閉じる
flock($fp, 3);
fclose($fp);
}
?>
<HTML>
<HEAD>
<META http-equiv="Content-Type" content="text/html; charset=shift_jis">
<META http-equiv="Content-Style-Type" content="text/css">
<TITLE>e_event admin menu</TITLE>
<SCRIPT LANGUAGE="JAVASCRIPT">
<!--
function load_screen(){
document.event_cal.action = "adminimenu.php";
document.event_cal.method = "POST";
document.event_cal.submit();
}
-->
</SCRIPT>
</HEAD>
<BODY onLoad="return load_screen();">
<form name="event_cal">
<INPUT type ="hidden" name="main_year" value ="<?php echo $main_year; ?>">
<INPUT type ="hidden" name="main_mon" value ="<?php echo $main_mon; ?>">
<INPUT type ="hidden" name="syori" value ="<?php echo $syori; ?>">
</form>
</BODY>
</HTML>