session_start();
require_once "functions.inc";
require_once "db.php";
// Connecting, selecting database
$con = connect_db();
$today = date("D F j, Y, g:i a");
$logged_in = false;
if($_SESSION[LoggedIn] == 'Y'){
$logged_in = true;
}
else{
if($_SESSION[LoggedIn] <> 'Y') $logged_in = false;
}
$action = $_REQUEST["action"];
$db_action = $_REQUEST["db_action"];
switch($db_action){
case 'insert':
// insert the text etc...
$sql = "insert into forum_topic (title, content, date, author, last_updated, image_caption) values (";
$sql .= "'".mysqli_real_escape_string($con,$_REQUEST["title"])."',";
$sql .= "'".mysqli_real_escape_string($con,$_REQUEST["content"])."',";
$sql .= "'".$today."',";
$sql .= "'".mysqli_real_escape_string($con,$_SESSION["ScreenName"])."',";
$sql .= "'".$today."',";
$sql .= "'".mysqli_real_escape_string($con,$_REQUEST["image_caption"])."'";
$sql .= ")";
$result = @mysqli_query($con, $sql);
$id = @mysqli_insert_id($con);
// get image data
$maxsize = '300000';
if(is_uploaded_file($_FILES['image']['tmp_name'])){
$UPLOAD = TRUE;
// get extension..
$ext_array = explode(".",$_FILES['image']['name']);
$ext = strtoupper($ext_array[1]);
if($ext == 'JPG' || $ext = 'JPEG'){
$ext = 'JPG';
}
elseif($ext <> 'GIF' || $ext <> 'PNG'){
$UPLOAD = FALSE;
}
if($UPLOAD){
// check the file is less than the maximum file size
if($_FILES['image']['size'] < $maxsize){
// prepare the image for insertion
$imgData =addslashes(file_get_contents($_FILES['image']['tmp_name']));
// get the image info..
$size = getimagesize($_FILES['image']['tmp_name']);
$width = $size[0];
$height = $size[1];
}
else{
$fail_message = "Image exceeded 200k Maximum.";
$action = 'edit';
break;
}
}
// do the image update...
$sql = "UPDATE forum_topic SET ext = '". $ext ."', width = '" . $width ."', height = '" . $height . "', image = '".$imgData ."'"
. " WHERE id = " . $id;
$request = @mysqli_query($con, $sql);
}
if($fail_message == ''){
print "
";
print "";
print "";
exit(0);
}
break;
}
$page_name = 'post_topic';
?>
page_meta($con, $page_name); ?>
require "top_nav.inc"; ?>
require "site_nav.inc"; ?>
require "footer.inc"; ?>