<?php
include "common/header.php";
include "common/upload_class.php";
$DB = new DB_API;
$upload = new clsUploadFile;
$upload->UploadPath = $_SERVER["DOCUMENT_ROOT"]."/test_upload/";
$table_name = "test_list";
$times = time();
if($upfile["size"]) {
$temp_name = $upfile["name"];
$exe = substr("$temp_name",-4);
if(substr("$exe",0,-3)==".")
{
$exe = $exe;
}
else
{
$exe = substr("$temp_name",-5);
}
$upfile["name"] = $times."_1_".$exe;
$upload->UploadFile($upfile);
$attach_files = $upload->SaveFileName;
$input["upfile"] = $attach_files;
$input["upfile_realname"] = $temp_name;
}
if($upfile2["size"]) {
$temp_name = $upfile2["name"];
$exe = substr("$temp_name",-4);
if(substr("$exe",0,-3)==".")
{
$exe = $exe;
}
else
{
$exe = substr("$temp_name",-5);
}
$upfile2["name"] = $times."_2_".$exe;
$upload->UploadFile($upfile2);
$attach_files = $upload->SaveFileName;
$input["upfile2"] = $attach_files;
$input["upfile2_realname"] = $temp_name;
}
if ($_POST["act_flag"] == "insert")
{
$input["title"] = $_POST["title"];
$input["shop_url"] = $_POST["shop_url"];
$input["writer"] = $_POST["name"];
$input["email"] = $_POST["email"];
$input["phone"] = $_POST["phone"];
$input["content"] = $_POST["content"];
$input["passwd"] = $_POST["pwd"];
$input["writeday"] = date("Y.m.d");
$DB->setInsert($table_name, $input);
$DB->DBClose();
alert_js("alert_move", "등록 되었습니다", "test.php#page_scroll");
exit;
}
else if ($_POST["act_flag"] == "update")
{
$input["title"] = $_POST["title"];
$input["shop_url"] = $_POST["shop_url"];
$input["writer"] = $_POST["name"];
$input["email"] = $_POST["email"];
$input["phone"] = $_POST["phone"];
$input["content"] = $_POST["content"];
$DB->setUpdate($table_name, $input, "idx = ".$idx);
$DB->DBClose();
alert_js("alert_move", "수정 되었습니다", "test.php#page_scroll");
exit;
}
else if ($_GET["act_flag"] == "delete")
{
$DB->setDelete($table_name, "idx = ".$idx);
$DB->DBClose();
alert_js("alert_move", "삭제되었습니다", "test.php");
exit;
}
else if ($_POST["act_flag"] == "file_delete")
{
$file_name = $DB->OneResult($table_name, $fieldname, "idx = ".$idx);
@unlink($upload->UploadPath.$file_name);
$update["upfile"] = "";
$update["upfile_realname"] = "";
$DB->setUpdate($table_name, $update, "idx = ".$idx);
$DB->DBClose();
echo "success";
exit;
}
else if ($_POST["act_flag"] == "file_delete2")
{
$file_name = $DB->OneResult($table_name, $fieldname, "idx = ".$idx);
@unlink($upload->UploadPath.$file_name);
$update["upfile2"] = "";
$update["upfile2_realname"] = "";
$DB->setUpdate($table_name, $update, "idx = ".$idx);
$DB->DBClose();
echo "success";
exit;
}
?>