<?php
// +-------------------------------------------------------------+
// | HiveMail™ version 1.3.1
// +-------------------------------------------------------------+
// | HIVEMAIL™ IS NOT FREE SOFTWARE
// | If you have downloaded this software from a website other
// | than Hivemail or if you have otherwise received
// | this software from someone who is not a representative of
// | this organization you are involved in an illegal activity.
// +-------------------------------------------------------------+
// | $RCSfile: folders.add.php,v $ - $Revision: 1.13 $
// | $Date: 2004/07/21 02:49:32 $ - $Author: tubedogg $
// +-------------------------------------------------------------+

error_reporting(E_ALL & ~E_NOTICE);
$templatesused = 'redirect_foladded';
require_once('./global.php');

// ############################################################################
if (is_array($newfolderlist)) {
	$getorder = $DB_site->query_first("
		SELECT MAX(display) AS max
		FROM hive_folder
		WHERE userid = $hiveuser[userid]
	");
	$thisorder = $getorder['max'] + 1;
	foreach ($newfolderlist as $newfoldername) {
		if (trim($newfoldername) != '') {
			$DB_site->query("
				INSERT INTO hive_folder
				(folderid, userid, title, msgcount, display) VALUES
				(NULL, $hiveuser[userid], '".addslashes($newfoldername)."', 0, $thisorder)
			");
			$thisorder++;
		}
	}

	rebuild_folder_cache();
	eval(makeredirect("redirect_foladded", "folders.list.php"));
} else {
	invalid('folders');
}

?>