Location: PHPKode > projects > Modular Site Manager > htdocs/misc/forums.post.php
<?php
chdir("../");
include "inc/functions.inc.php";
$no = count($_FILES['attachments']['name']);
$atsel = $mysql->select(PRE.'forums_attachments', NULL, 'id', "ASC", '1');
$g = mysql_fetch_assoc($atsel);
for($i = 0; $i < $no; $i++)
{
	if($_FILES['attachments']['tmp_name'][$i] !== '')
	{
		if($i == 0)
		{
			$toadd = 1;
		} else {
			$toadd = 0;
		}
		$time = time();
		move_uploaded_file($_FILES['attachments']['tmp_name'][$i], SITE_PATH."uploads/".$_COOKIE['user'].'-'.$g['id']+$i+$toadd.'-'.$time.'-'.$_FILES['attachments']['name'][$i]);
		$xpl = explode('.', $_FILES['attachments']['name'][$i]);
		$fend = strtolower($xpl[1]);
		if(preg_match("@image/@", $_FILES['attachments']['type'][$i]))
		{
			$type = 'image';
		} else {
			$type = 'download';
		}
		$mysql->insert(PRE.'forums_attachments', array('filename', 'userid', 'type'), array($_COOKIE['user'].'-'.$g['id']+$i+$toadd.'-'.$time.'-'.$_FILES['attachments']['name'][$i], $_COOKIE['mid'], $type));
	}
}
print_r($_FILES['attachments']);
$opts = array($_POST['opt1'], $_POST['opt2'], $_POST['opt3'], $_POST['opt4'], $_POST['opt5'], $_POST['opt6'], $_POST['opt7'], $_POST['opt8'], $_POST['opt9'], $_POST['opt10']);
//print_r($_POST);
//print_r($opts);
//die;
$time = time();
//$mysql = new mysql(DB_MAIN);
if($_POST['type'] == "poll" && empty($_POST['pollq']))
{
	die('Please make sure you include a poll');
}
if(!isset($_POST['status']))
{
	$status = "normal";
} else {
	$status = $_POST['status'];
}
$mysql->insert(PRE."forums_threads", array('subject', 'date', 'forumid', 'type', 'status', 'pollq', 'userid', 'lastupdate'), array(strip_tags($_POST['subject']), $time, $_POST['forumid'], $_POST['type'], $status, $_POST['pollq'], $_COOKIE['mid'], $time));
$sel = $mysql->select(PRE."forums_threads", "date='".$time."'", "id");
$a = mysql_fetch_assoc($sel);
$threadid = $a['id'];
if($_POST['type'] == "poll")
{
	foreach($opts as $opt)
	{
		if(!empty($opt))
		{
			$mysql->insert(PRE."forums_polls_options", array('threadid', 'option'), array(strip_tags($threadid), $opt));
		}
	}
}
$mysql->insert(PRE."forums_posts", array('userid', 'postid', 'message', 'date', 'threadid'), array($_COOKIE['mid'], '1', strip_tags($_POST['post']), $time, $a['id']));
$mysql->close();
header("Location: ".SITE_URL.'Forums/Thread/'.$threadid);
?>
Return current item: Modular Site Manager