evententry.php 8.32 KB
<?php 
//*****************************************************************************
//* 
//* プログラム名:e-イベント
//* プログラムID:login.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);

if(isset($sousinn)){
	require('function/readcsv.inc' );
	$file_name = "data/usr/username.csv";
	$tbl_cnt = 0;
	$found1 = 0;
	$found2 = 0;
	$usr_tbl = array();
	$usr_tbl = fun_csvread($usr_tbl, $file_name);
	$id = 0;
	switch($found = userchk($usr_tbl, $usr_name, $usr_pword, $tbl_cnt)){
		case "1":
			$dd = 2;
			break;
		case "2":
			$errmsg = "パスワードが違います";
			fun_errprint($errmsg, $hiduke);
			exit;
		case "3":
			$errmsg = "ユーザー名・パスワードはguestで入力してください";
			 fun_errprint($errmsg, $hiduke);
			exit;
		case "4":
			$dd = 1;
			break;
	 }

}
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<META name="GENERATOR" content="IBM WebSphere Homepage Builder V6.0.1 for Windows">
<META http-equiv="Content-Type" content="text/html; charset=shift_jis">
<META http-equiv="Content-Style-Type" content="text/css">

<TITLE>イベント登録</TITLE>

<SCRIPT type="text/javascript" src="function/checkdata.js"></SCRIPT>
<link href="css/style.css" rel="stylesheet" type="text/css">
</HEAD>

<BODY>
<br>
<?php 	fun_maketbl(1, "イベント登録"); ?>
<FORM method="POST" name=event action="evententry.php" onsubmit="return datacheck();">

<?php fun_makeline(1, 0, 0);?>

<FONT size="-1">イベント名称:<FONT color="#ff0000">(必須)</FONT><BR></FONT>
<INPUT size="100" type="text" name="eventname"><BR><BR>
<?php fun_makeline(2, 0, 0);?>

<BR>

<?php fun_makeline(1, 0, 0);?><BR>

<FONT size="-1">
期間:<BR>


<SELECT name="fyear">
<?php 
 //コンボボックスに変更
list($eventy, $eventm, $eventd) = split(",", $hiduke);
//for ($intCnt = $eventy-1 ; $intCnt <= $eventy+1 ; $intCnt++) {
$intCnt = $eventy;
	echo "<option value=".$intCnt;
	if ($fyear == $intCnt){
		echo " selected";
	}
	echo ">".$intCnt."年</option>";
//}
?>
</SELECT>

<SELECT name="fmon">
<?php
for ($intCnt = 1; $intCnt <= 12; $intCnt++) {
	if (strlen($intCnt) == 1){
		echo "<option value=0".$intCnt;
	}else{
		echo "<option value=".$intCnt;
	}

	if ($eventm == $intCnt){
		echo " selected";
	}
	echo ">".$intCnt."月</option>";
}
?>
</SELECT>

<SELECT name="fday">
<?php
for ($intCnt = 1; $intCnt <= 31; $intCnt++) {
	if (strlen($intCnt) == 1){
		echo "<option value=0".$intCnt;
	}else{
		echo "<option value=".$intCnt;
	}

	if ($eventd == $intCnt){
		echo " selected";
	}
	echo ">".$intCnt."日</option>";
}
?>
</SELECT>



<SELECT name="tyear">
<?php 
//コンボボックスに変更
for ($intCnt = $eventy; $intCnt <= $eventy+1; $intCnt++) {
	echo "<option value=".$intCnt;
	if ($eventy == $intCnt){
		echo " selected";
	}
	echo ">".$intCnt."年</option>";
}
?>
</SELECT>

<SELECT name="tmon">
<?php
for ($intCnt = 1; $intCnt <= 12; $intCnt++) {
	if (strlen($intCnt) == 1){
		echo "<option value=0".$intCnt;
	}else{
		echo "<option value=".$intCnt;
	}

	if ($eventm == $intCnt){
		echo " selected";
	}
	echo ">".$intCnt."月</option>";
}
?>
</SELECT>

<SELECT name="tday">
<?php 
for ($intCnt = 1; $intCnt <= 31; $intCnt++) {
	if (strlen($intCnt) == 1){
		echo "<option value=0".$intCnt;
	}else{
		echo "<option value=".$intCnt;
	}

	if ($eventd == $intCnt){
		echo " selected";
	}
	echo ">".$intCnt."日</option>";
}
print("<input type=\"hidden\" name=\"hiduke\" value =$hiduke>");
?>
</SELECT>

<br>
<FONT size="-1">ホームページアドレス:<BR></FONT>
<INPUT size="100" type="text" name="hpadrs"><BR><BR>
<FONT size="-1">吹き出し文言:<FONT color="#ff0000" size="-1"></FONT><BR></FONT>
<TEXTAREA rows="9" cols="71" name="tipword"></TEXTAREA><BR></FONT>

<?php fun_makeline(2, 0, 0);?>
<BR>
	<INPUT type="submit" name="submit" value=" 登録 ">
	<INPUT type="reset" name="cancel" value="キャンセル">
	<INPUT type="hidden" name="dd" <?php print("value = $dd")?>></DIV>
		<A href=<?php print($home); ?>>
			<IMG src="image/return.gif" width="58" height="36" border="0" align="right" alt="イベントカレンダー">
		</A>
	<INPUT type="hidden" name="pageName" value="<?php echo $pageName ?>">
</FORM>

<?php fun_maketbl(2, 0);?>

<?php 
//カレンダー画面から引き継いだ情報を展開する。
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 = "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($fp, 4096)){
			$buf[$count] = $readbuf;
			$buf[$count][0] = $buf[$count][0]; 
			$buf[$count][1] = $buf[$count][1]; 
			$buf[$count][2] = '"'.$buf[$count][2].'"'; 
			$buf[$count][3] = $buf[$count][3]; 
			$buf[$count][4] = $buf[$count][4]; 
			$buf[$count][5] = $buf[$count][5]; 
			$buf[$count][6] = $buf[$count][6]; 
			$buf[$count][7] = $buf[$count][7]; 
			$buf[$count][8] = $buf[$count][8]; 
			$buf[$count][9] = $buf[$count][9]; 
			$buf[$count][10] = '"'.$buf[$count][10].'"'; 
			$buf[$count][11] = '"'.$buf[$count][11].'"'; 
			$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.'"';
		//並べ替え処理
		array_multisort($buf, SORT_ASC);
		// ファイルポインタを先頭に戻す
		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);
	}

	/* ---------------------------------------------------------------------- */
	print("<script>location.replace('main_menu.php');</script></BODY></HTML>");
}
?>

</BODY>
</HTML>