Location: PHPKode > projects > Modular Site Manager > htdocs/misc/forums.reply.php
<?php
chdir("../");
include "inc/functions.inc.php";
$no = count($_FILES['attachments']['name']);
$atsel = $mysql->select(PRE.'forums_attachments', NULL, 'id', "ASC", '1');
chdir(SITE_PATH.'uploads/');
for($i=0;$i<$no;$i++)
{
	$g = mysql_fetch_assoc($atsel);
	if($_FILES['attachments']['name'][$i] !== '')
	{
		if($i == 0)
		{
			$toadd = 1;
		} else {
			$toadd = 0;
		}
		//echo $_COOKIE['user'].'-'.$g['id']+$i+$toadd.'-'.time().'-'.$_FILES['attachments']['name'][$i];
		move_uploaded_file($_FILES['attachments']['tmp_name'][$i], $_COOKIE['user'].'-'.$g['id']+$i+$toadd.'-'.time().'-'.$_FILES['attachments']['name'][$i]) or die('couldn\'t upload your file.');
		$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));
	}
}
//echo $g['id'];
//print_r($_FILES['attachments']);

$time = time();
$mysql = new mysql(DB_MAIN);
$sel = $mysql->select(PRE."forums_threads", "id='".$_POST['threadid']."'", "id");
$a = mysql_fetch_assoc($sel);
$subject = $a['subject'];
// emails the users that have posted
$sel2 = $mysql->select(PRE."forums_posts", "threadid='".$_POST['threadid']."' AND type='user'", "id");
$hasemailed = $_COOKIE['user'].' ';
while($b = mysql_fetch_assoc($sel2))
{
	$username = getuserinfoid('username', $b['userid']);
	$ckreply = getuserinfoid('forumtopicnonotify', $b['userid']);
	$cknotify = explode('~', $ckreply);
	$expl = explode(' ', $hasemailed);
	if(!in_array($username, $expl) && !in_array($_POST['threadid'], $cknotify))
	{
		$hasemailed .= $username.' ';
		$threadlink = $_POST['threadid'];
		mail($username.' <'.getuserinfoid('email', $b['userid']).'>', 'Vouksh.info Forums Topic Reply: '.$a['subject'], $_COOKIE['user']." has replied to a topic you either started, or have replied to. \nThey posted:\n".strip_tags(parse($_POST['post']))."\n".SITE_URL."Forums/Thread/".$threadlink."/#p-".$_POST['postid']."\n\nYou will not be notified of anymore posts until you visit the thread again.", "FROM: Vouksh.info Forums <hide@address.com>");
		$mysql->update(PRE.'members', "forumtopicnonotify='".$ckreply."~".$_POST['threadid']."' ","id='".$b['userid']."'");
	}
}

$mysql->insert(PRE."forums_posts", array('userid', 'postid', 'message', 'date', 'threadid'), array($_COOKIE['mid'], $_POST['postid'], strip_tags($_POST['post']), $time, $_POST['threadid']));
$mysql->update(PRE."forums_threads", "lastupdate='".$time."'", "id='".$_POST['threadid']."'");
header("Location: ".SITE_URL.'Forums/Thread/'.$_POST['threadid'].'/#end');
$mysql->close();
?>
Return current item: Modular Site Manager