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

	$user_id = $_SESSION['login_id'];
	if ($_GET['id'].'' == '' or $_GET['id'] == '0') {
		exit;
	}
	$id = intval($_GET['id']);
	if (($subject = my_GET('subj')) == '') {
		$subject = "(無題)";
	}
	$con = my_mysql_connect(_DB_SCHEMA);
	$sql = "select * from m_svg where id_svg = ".$id;
	$rs = my_mysql_query($sql);
	$rec = mysql_fetch_array($rs);
	$svgdata = $rec['c_svgdata'];
	$now_date = date("Y/m/d H:i:s");

	$sql = "insert into m_svg ";
	$sql .= "(id_account";
	$sql .= ", c_subject";
	$sql .= ", c_svgdata";
	$sql .= ", c_registtime";
	$sql .= ", c_updatetime";
	$sql .= ") values ";
	$sql .= "( '".$user_id."'";
	$sql .= ", '".str_for_mysql($subject)."'";
	$sql .= ", '".str_for_mysql($svgdata)."'";
	$sql .= ", '".$now_date."'";
	$sql .= ", '".$now_date."'";
	$sql .= ")";
	$ret = my_mysql_query($sql, "登録できませんでした。");
	$new_id = mysql_insert_id();	//直近のINSERTクエリによりAUTO_INCREMENTカラム用に生成されたIDを取得
	$con = mysql_close($con);

	redirect("view.php?id=".$new_id."&sort=new&key=__reset__");
?>
