File "index.php"

Full path: /www/share/index.php
File size: 7.41 KiB (7585 bytes)
MIME-type: text/html
Charset: utf-8

Download   Open   Back

<HTML>
<HEAD>
<META Http-Equiv="Content-Type" Content="text/html;charset=UTF-8">
<TITLE>五洋情報共有システム</TITLE>
<!--<LINK REL="stylesheet" HREF="pict.css" TYPE="text/css">-->
</HEAD>
<BODY>

<script type="text/javascript">
//-------------------------------------------------------------------------------------------------
//関数(javascript)
//-------------------------------------------------------------------------------------------------
//■削除アラート
function goDeleteServlet(name,no)
{
	if(window.confirm( name + 'を削除してもよろしいですか?'))
	{
		location.href = "index.php?del=" + no;
	} 
	else
	{
		location.href = "index.php";
	}
}
</script>
<?php
//プルダウンCSV
$list_csv = "./setting/list.csv";

//ファイルNoパス
$file_no_path= "./setting/no.txt";

//CSVデータ出力パス
$csv_data_path = "data.csv";


//●プルダウンリストの読み込み
$fp = fopen($list_csv,"r");
$pull_list = array();
$list = array();

// ファイルを1行ずつ取得する
while ($line = fgets($fp)) {
  $pull_list[] =  "$line";
}

$ct = count($pull_list);

//各リストを,で分割
for($i = 0;$i < $ct;$i++)
{
	$pull_list[$i] = str_replace("\n", '', $pull_list[$i]);
	$list[] = explode(",",$pull_list[$i]);
}


//●ラジオボタン作成
function Radio_create($type_ ,$name_,$value_,$selected)
{
	print "<div>";
	$value_ct = count($value_);

	for($j= 1 ;$j < $value_ct;$j++)
	{
		if($type_ == 0)
		{
			$sel = ($value_[$j] == $selected) ? "checked='checked'" : "";
			print "<input type='radio' name='" .$name_  ."' value='" .$value_[$j]."' " .$sel .">" .$value_[$j] ."&nbsp;";
		}
		else
		{
			$split = explode("_",$value_[$j]);
			$sel = ($split[0] == $selected) ? "checked='checked'" : "";
			print "<input type='radio' name='" .$name_  ."' value='" .$split[0]."' " .$sel ."  ><FONT COLOR='" .$split[0] ."'>" .$split[1] ."</FONT>&nbsp;";
		}
	}
	print "</div>";
}
//print_r($_POST);
//print_r($_GET);

if(!empty($_POST['regist']))
{
	//現在の登録NO
	if($_POST['menu_name'])
	{
		$now_file_no = file_get_contents($file_no_path);
		
		$file_no = $now_file_no + 1;

		//登録ファイルNoの更新
		file_put_contents($file_no_path, $file_no);

		//表示ファイルのデータ生成・出力
		$output = $file_no ."," .$_POST['menu_name'] ."," .$_POST['url'] ."," .$_POST['bg_color'] ."\n";
		$fp_w = fopen($csv_data_path,"a");
		fwrite($fp_w,$output);
		fclose($fp_w);
		//file_put_contents($csv_data_path, $output);
	}
}

if(!empty($_GET['del']))
{
	//●データの読み込み
	$fp_d = fopen($csv_data_path,"r");
	$list = array();
	$new_data = "";

	// ファイルを1行ずつ取得する
	while ($line = fgets($fp_d))
	{
		$list =  explode(",",$line);
		if(($list[0] != $_GET['del']))
	  	{
			$new_data .= $line;
		}
	}
	fclose($fp_d);
	
	$fp_u = fopen($csv_data_path,"w");
	fwrite($fp_u,$new_data);
	fclose($fp_u);
}


//■現在のデータを配列に読み込む
//現在の登録NO
$data_read = file_get_contents($csv_data_path);

$data_ = explode("\n",$data_read );

//データ数(行数)
$data_ct = count($data_) -1;

//データを項目毎に分割(no,項目名,url,背景色)
//for($i = 0;$i < $data_ct;$i++)
//{
//	$item[$i] = explode(",",$data_[$i]);
//}
//print_r($data_);


//アイコン表示用
$data_view = "";

//アイコンの一列表示数
$row_no = 3;

//アイコン表示スペースの横幅
$view_witdh = 900;

//アイコンの横幅
$icon_witdh = $view_witdh / $row_no;

	$selected = ($selected) ? $selected:"navy";




	print "<TABLE>";
	print "<TR>";
	print "<TD ROWSPAN='3' HEIGHT='400'>";
	print "<img src='i-pentacol_py.png'>";
	print "</TD>";
	print "<TD valign='top'>";
//■■初期画面(画面更新時)
	print "<FORM enctype='multipart/form-data' action='$_SERVER[PHP_SELF]' method='post'>";
	print "<INPUT TYPE='submit'  NAME='reload' VALUE='更新' style='width:100px;'>";
	print "</FORM>";
	print "<div onclick=\"obj=document.getElementById('open').style; obj.display=(obj.display=='none')?'block':'none';\">";
	print "<a style='cursor:pointer;'>▼ 新規登録</a>";
	print "</div>";
	print "<div onclick=\"obj=document.getElementById('open2').style; obj.display=(obj.display=='none')?'block':'none';\">";
	print "<a style='cursor:pointer;'>▼ 編集</a>";
	print "</div>";
	print "</TD>";
	print "</TR>";

	print "<TR>";
	print "<TD>";
	print "<div id='open' style='display:none;clear:both;'>";
	print " <FORM enctype='multipart/form-data' action='$_SERVER[PHP_SELF]' method='post'>";
	print " <TABLE BORDER=\"0\">";
	print " <TR BGCOLOR='blue'>";
	print " <TD WIDTH='70'><FONT SIZE ='2' COLOR='white'>項目名</FONT></TD>";
	print " <TD BGCOLOR='white'><INPUT TYPE='text' size='40' NAME='menu_name' ></TD>";
	print " </TR>";
	print " <TR BGCOLOR='blue'>";
	print " <TD WIDTH='70'><FONT SIZE ='2' COLOR='white'>URL</FONT></TD>";
	print " <TD BGCOLOR='white'><INPUT TYPE='text' size='40' NAME='url'></TD>";
	print " </TR>";
	print " <TR BGCOLOR='blue'>";
	print " <TD WIDTH='70'><FONT SIZE ='2' COLOR='white'>背景色</FONT></TD>";
	print " <TD BGCOLOR='white'>";
	print Radio_create(1 ,'bg_color',$list[0],$selected);
	print " </TD>";
	print " </TR>";
	print " <TR BGCOLOR='white'>";
	print " <TD COLSPAN='2'><INPUT TYPE='submit' NAME='regist' VALUE='登録'>";
	print " </FORM>";
	print " <BR><BR>";
	print " </TD>";
	print " </TR>";
//	print " <TR BGCOLOR='blue'>";
//	print " <TD WIDTH='70'><FONT SIZE ='2' COLOR='white'>登録状況</FONT></TD>";
//	print " </TR>";
	print " </TABLE>";
	print "</div>";
	print "</TD>";
	print "</TR>";

	print "<TR>";
	print "<TD>";
	print "<div id='open2' style='display:none;clear:both;'>";
	if($data_ct != 0)
	{
		print "<div style='height:100px;overflow-y:scroll;'>";
		print " <TABLE BORDER='1'>";
		
		$data_view = "<TABLE>";
		for($i = 0;$i < $data_ct;$i++)
		{

			$item[$i] = explode(",",$data_[$i]);
			print " <TR>";
			print " <TD WIDTH='360'><FONT SIZE ='2'>" .$item[$i][1] ."</FONT></TD>";
			print " <FORM enctype='multipart/form-data' action='edit.php' target='_blank' method='post'>";
			print " <TD><INPUT TYPE='submit' NAME='edit' VALUE='編集'></TD>";
			print " <INPUT TYPE='hidden' NAME='no' VALUE='" .$item[$i][0] ."'>";
			print " <INPUT TYPE='hidden' NAME='menu_name' VALUE='" .$item[$i][1] ."'>";
			print " <INPUT TYPE='hidden' NAME='url' VALUE='" .$item[$i][2] ."'>";
			print " <INPUT TYPE='hidden' NAME='bg_color' VALUE='" .$item[$i][3] ."'>";
			print " </FORM>";
			print " <TD><INPUT TYPE='submit' NAME='delete' VALUE='削除' onclick='goDeleteServlet(\"" .$item[$i][1] ."\"," .$item[$i][0] .")'></TD>";
			print " </TR>";

			if(($i % $row_no) == 0)
			{
				if($i == 0)
				{
					$data_view .= "<TR>";
				}
				else
				{
					$data_view .= "</TR><TR>";
				}
			}

			$data_view .= "<TD ALIGN='center' WIDTH='" .$icon_witdh ."' BGCOLOR='" .$item[$i][3] ."'>";
			$data_view .= "<A HREF='" .$item[$i][2] ."' TARGET='_BLANK'><FONT SIZE ='10' COLOR='white'>" .$item[$i][1] ."</FONT></A>";
			$data_view .= "</TD>";

		}
		print " </TABLE>";
		print "</div>";
		$data_view .= "</TR></TABLE>";
		
	}
	print "</div>";
	print "</TD>";
	print "</TR>";
	print "</TABLE>";


//	print "<TD><INPUT TYPE='checkbox' NAME='check' VALUE='" .$inspection_id ."' ></TD>";
//	print "<FORM enctype='multipart/form-data' action='$_SERVER[PHP_SELF]' method='post'>";
//	print "<TD><INPUT TYPE='submit' NAME='edit[]' VALUE='編集'>";			//●編集ボタン
//	print "<INPUT TYPE='hidden' NAME='edit_id' VALUE='" .$inspection_id ."'>";
//	print "</FORM>";
print $data_view;

?>
</BODY>
</HTML>

PHP File Manager