eventdel.php 2.92 KB
<?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("ファイルを開くのに失敗しました。<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]="";
				}
		}
	
		//データのソート
		usort($mstbuf,idxsort);
		usort($mstbuf,mycmp);
 
		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_イベント管理者用画面</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>