head	1.1;
access;
symbols;
locks; strict;
comment	@# @;
expand	@b@;


1.1
date	2003.12.18.00.41.00;	author spike;	state Exp;
branches;
next	;


desc
@@


1.1
log
@first commit for KLDP.net
@
text
@<?

include_once "./setting.php";

include_once $global["root"] . "/include/handle.php";
include_once $global["root"] . "/include/print_array.php";
include_once $global["root"] . "/include/print_byte.php";

include_once $global["root"] . "/lib/Site.php";
include_once $global["root"] . "/lib/Extend_Doc.php";
include_once $global["root"] . "/lib/Item.php";

$Site = new Site;
$Site->init();
$Site->set_permission("user");

include_once $global["lang"] . "/" . $_SESSION["config_lang"] . ".php";

$Quota = new Quota;
if (! $Quota->check_quota("save")) {
	$Site->end1();
	goprev();
}

extract($_POST);

// escape error.
if (! is_array($_FILES["userfile"]) or ! $_FILES["userfile"]["tmp_name"]) {
	$_SESSION["tmp"]["msg"]["content"] = $string["error37"];
	$Site->end1();
	goprev();
}

if (trim($title) == "") {
	$_SESSION["tmp"]["msg"]["content"] = $string["error36"];
	$Site->end1();
	goprev();
}

if (trim($directory_num) == "") {
	//$_SESSION["tmp"]["msg"]["content"] = $string["error7"];
	$Site->end1();
	goprev();
}

$Doc = new Extend_Doc;
$Doc->save();
$storedFilename = $Doc->filename_stored;

$Site->DB->transaction_start(true); // transaction start

$SQL_INSERT_DOC =
	"insert into doc_%s
			(realname, storedname, size, mime_type, author, date, comment, title)
		values('%s','%s','%s','%s','%s','%s','%s','%s')";

$Site->DB->query(sprintf($SQL_INSERT_DOC,
		$_SESSION["config_id"], addslashes($_FILES["userfile"]["name"]),
		$storedFilename, $_FILES["userfile"]["size"],
		addslashes($_FILES["userfile"]["type"]), addslashes($author),
		mktime(), addslashes($comment), addslashes($title)));

$Item = new Item;

if ($Site->DB->retval) {
	$Site->DB->retval = $Item->insert($Site->DB->get_last_insert_id(),
		$_SESSION["user_item_type_rv"]["doc"], $directory_num, false);
}

$retval = $Site->DB->retval;
$Site->DB->close();

if ($retval) {
	$url = sprintf("Location: %s/mail.php?mode=doc&no=a", $_SESSION["user_global_url"]);
	$Site->end1();

	Header($url);
	exit;
} else {
	$Site->end1();

	goprev();
}

/*
Description
-----------

	$directory_num
	$title
	$comment

	$_FILES["userfile"]["size"]
	$_FILES["userfile"]["type"]
	$_FILES["userfile"]["tmp_name"]
	$_FILES["userfile"]["error"]
	$_FILES["userfile"]["name"]

Author
------
 Spike^ekipS <spike@@spikeekips.net>

Changelog
---------

Usage
-----

*/

?>
@
