<?php
	require("__include-common.php");
	require("../account/__logincheck.php");

	html_header(HTML_TITLE);
	page_header();

	$_SESSION['edit_myprofile_error'] = "";
	$_SESSION['edit_myprofile_handle'] = "";
	$_SESSION['edit_myprofile_email'] = "";
	$_SESSION['edit_mypass_error'] = "";

	main_proc();

	page_footer();
	html_footer();
	exit();

function main_proc() {
	$con = my_mysql_connect(_DB_ACCOUNT_SCHEMA);
	$sql = "SELECT * FROM m_account WHERE id_account = '" . $_SESSION['login_id'] . "'";
	$selectdb = mysql_select_db($db);
	$rs_account = my_mysql_query($sql);
	$row = mysql_num_rows($rs_account);
	if ($row == 0) {
		echo "アカウント情報がみつかりません。";
		exit;
	}
	$rec_account = mysql_fetch_array($rs_account);
?>
<div class="input_form">
<h3>My設定</h3>
	<div class="menu_standard">
	<ul>
		<li><a href="edit-myprofile.php">[アカウント情報修正]</a></li>
		<li><a href="edit-mypass.php">[パスワード修正]</a></li>
		<li><a href="edit-id-mgr-pass.php">[ID管理パスワード修正]</a></li>
	</ul>
	</div>
<div id="myprofile_account">
	<h4>アカウント情報</h4>
<table class="myprofile_info_table">
<tr>
	<td nowrap>アカウント名：</td>
	<td nowrap><?= my_htmlspecialchars($rec_account['c_account']) ?></td>
</tr>
<tr>
	<td nowrap>ハンドル名：</td>
	<td nowrap><?= my_htmlspecialchars($rec_account['c_handle']) ?></td>
</tr>
<tr>
	<td nowrap>電子メールアドレス：<br>(パスワード忘れ用)</td>
	<td nowrap><?= my_htmlspecialchars($rec_account['c_email']) ?></td>
</tr>
<tr>
	<td nowrap>電子メールアドレス：<br>(スケジュール送信先)</td>
	<td nowrap><?= my_htmlspecialchars($rec_account['c_email_calendar']) ?></td>
</tr>
<tr>
	<td nowrap>コメント：</td>
	<td nowrap><?= ins_br(my_htmlspecialchars($rec_account['c_msg'])) ?></td>
</tr>
<tr>
	<td nowrap>アルバムフォルダ：</td>
<?php
	if (defined("photo_LIMITED_IMAGES_FOLDER") and photo_LIMITED_IMAGES_FOLDER <> '') {
		$photo_folder = photo_LIMITED_IMAGES_FOLDER.'/';
	}
?>
	<td nowrap><?= $photo_folder ?><?= my_htmlspecialchars($rec_account['c_album_folder']) ?></td>
</tr>
<tr>
	<td nowrap>ページ背景色：</td>
	<td nowrap><?= my_htmlspecialchars($rec_account['c_body_background_color']) ?></td>
</tr>
<tr>
	<td nowrap>氏名：</td>
	<td nowrap><?= my_htmlspecialchars($rec_account['c_fullname']) ?></td>
</tr>
<tr>
	<td nowrap>〒番号：</td>
	<td nowrap><?= my_htmlspecialchars($rec_account['c_zip1']) ?>-<?= my_htmlspecialchars($rec_account['c_zip2']) ?></td>
</tr>
<tr>
	<td nowrap>住所 (経路起点)：</td>
	<td nowrap><?= my_htmlspecialchars($rec_account['c_home_address']) ?></td>
</tr>
<tr>
	<td nowrap>住所2：</td>
	<td nowrap><?= my_htmlspecialchars($rec_account['c_home_address2']) ?></td>
</tr>
<tr>
	<td nowrap>カレンダー：</td>
	<td nowrap><? if ($rec_account['c_cal_sbj_use']=='NO') echo '件名を使わない（スケジュール本文のみを使う）'; ?></td>
</tr>
</table>
</div>
<div id="myprofile_friends">
<?php
	if (EDIT_FRIENDS_PAGE == "IDINP") {
		$edit_php = "edit-friends-inp.php";
	} else {
		$edit_php = "edit-friends.php";
	}
?>
	<h4>My参照メンバ<a class="a_update_form" href="<?= $edit_php ?>">追加/削除</a></h4>
<?php
	//$sql = "SELECT m_friends.*, m_account.c_handle FROM m_friends";
	//$sql .= " LEFT OUTER JOIN m_account ON m_friends.id_member_id = m_account.id_account";
	//$sql .= " WHERE m_friends.c_delete = 0 and m_friends.id_account = '" . $_SESSION['login_id'] . "'";
	//$sql .= " order by id_member_id";

	$sql = "SELECT * FROM v_friends";
	$sql .= " WHERE c_delete = 0 and id_account = '" . $_SESSION['login_id'] . "'";
	$sql .= " order by c_displayOrder";

	$selectdb = mysql_select_db($db);
	$rs_friends = my_mysql_query($sql);
	$row = mysql_num_rows($rs_friends);
	if ($row > 0) {
?>
	<table class="myprofile_info_table">
		<tr>
		<th>ID</th>
		<th>ハンドル名</th>
		</tr>
<?php
		while ($rec_friends=mysql_fetch_array($rs_friends)) {
?>
		<tr>
		<td><?= my_htmlspecialchars($rec_friends['id_member_id']) ?></td>
		<td><?= my_htmlspecialchars($rec_friends['c_handle']) ?></td>
		<td><?= my_htmlspecialchars($rec_friends['c_permit_type']) ?></td>
		<td style="text-align: right;"><?= my_htmlspecialchars($rec_friends['c_displayOrder']) ?></td>
		</tr>
<?php
		}
?>
	</table>
<?php
	}
?>
</div>
<div id="myprofile_public">
<?php
	if (EDIT_PUBLIC_PAGE == "IDINP") {
		$edit_php = "edit-public-inp.php";
	} else {
		$edit_php = "edit-public.php";
	}
?>
	<h4>公開先メンバ<a class="a_update_form" href="<?= $edit_php ?>">追加/削除</a></h4>
<?php
	$sql = "SELECT * FROM m_public WHERE id_account = '" . $_SESSION['login_id'] . "'";

	$sql = "SELECT m_public.*, m_account.c_handle, r_permit_type.c_permit_type FROM m_public";
	$sql .= " LEFT OUTER JOIN m_account ON m_public.id_permit_id = m_account.id_account";
	$sql .= " LEFT OUTER JOIN r_permit_type ON m_public.id_permit_type = r_permit_type.id_permit_type";
	$sql .= " WHERE m_public.c_delete = 0 and m_public.id_account = '" . $_SESSION['login_id'] . "'";
	$sql .= " order by id_permit_id";

	$selectdb = mysql_select_db($db);
	$rs_public = my_mysql_query($sql);
	$row = mysql_num_rows($rs_public);
	if ($row > 0) {
?>
	<table class="myprofile_info_table">
		<tr>
		<th>ID</th>
		<th>ハンドル名</th>
		</tr>
<?php
		while ($rec_public=mysql_fetch_array($rs_public)) {
?>
		<tr>
		<td><?= my_htmlspecialchars($rec_public['id_permit_id']) ?></td>
		<td><?= my_htmlspecialchars($rec_public['c_handle']) ?></td>
		<td><?= my_htmlspecialchars($rec_public['c_permit_type']) ?></td>

		</tr>
<?php
		}
?>
	</table>
<?php
	}
?>
</div>
</div>
<?php
	$con = mysql_close($con);
}
?>
