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

	html_header(HTML_TITLE);
?>
<script type="text/javascript">
// by BLUEPIXY
function copy(e){
	var text = window.getSelection()+"";
	text=text.replace(/(.+)\s*/,"$1");
	input = document.createElement("input");
	input.hidden = true;
	input.value = text;
	document.body.appendChild(input);
	input.select();
	try {
		success = document.execCommand("copy", false, null);
	} catch (ex) {
		success = false;
	} finally {
		document.body.removeChild(input);
	}
	return false;
};
</script>
<?php

	$con = my_mysql_connect(_DB_SCHEMA);
	$sql = "select * from v_pass where id_pass = '" . $_GET['id'] . "'";
	$sql .= " and id_account = '" . $_SESSION['current_id'] . "'";
	$sql .= " and c_delete = 0 ";
	if ($_SESSION['current_id'] != $_SESSION['login_id']) {
		$sql .= " and c_privacy = 0";
	}
	$rs = my_mysql_query($sql);
	$row = mysql_num_rows($rs);
	if ($row == 0) {
		echo "レコードがみつかりません。";
		exit;
	}
	if ($rec = mysql_fetch_array($rs)) {
		for ($ix = 1; $ix <= 6; $ix++) {
			if ($rec['c_item'.$ix]<>"" or $rec['c_val'.$ix]<>"") {
				$val = ang2str($rec['c_val'.$ix], $rec['c_updatetime']);
?>
		<table class="id_manager_id_box" cellspacing=0 oncopy="copy(event);return false">
		<tr>
		<td class="id_item_name"><?= my_htmlspecialchars($rec['c_item'.$ix]) ?>：</td>
			<td class="id_item_val_data"><?= $val ?></td>
<?php
				if (strpos($val, '-') !== False or strpos($val, ' ') !== False) {
					$sep_ary = preg_split("[\x20|\x2d]", $val);
					$sepchr = ' ';
					foreach ($sep_ary as $sep) {
?>
				<td class="id_item_space"><?= $sepchr ?></td>
				<td class="id_item_val_data_sep"><?= $sep ?></td>
<?php
						$sepchr = '-';
					}
?>
				<td class="id_item_space"></td>
				<td class="id_item_val_data">
<?php
					foreach ($sep_ary as $sep) {
						echo $sep;
					}
?>
				</td>
<?php
				}
?>
		</tr>
		</table>
<?php
			}
		}
	}
	$con = mysql_close($con);
	html_footer();
?>
