include_once "includes/dbConnNew.php";
include_once "includes/loggedOnPop.php";
$theDate = date("Y-m-d");
if($_REQUEST['theAction'] == "addIt" && $_REQUEST["The_Text"] > " "){
if( $_FILES['ProfilePicture']['name'] > " "){
//make sure this directory is writable!
$path_thumbs = "userPhotos/";
//the new width of the resized image, in pixels.
$img_thumb_width = 160; //
$extlimit = "yes"; //Limit allowed extensions? (no for all extensions allowed)
//List of allowed extensions if extlimit = yes
$limitedext = array(".gif",".jpg",".png",".jpeg",".JPG");
//the image -> variables
$file_type = $_FILES['ProfilePicture']['type'];
$file_name = $_FILES['ProfilePicture']['name'];
$file_size = $_FILES['ProfilePicture']['size'];
$file_tmp = $_FILES['ProfilePicture']['tmp_name'];
//check the file's extension
$ext = strrchr($file_name,'.');
$ext = strtolower($ext);
//uh-oh! the file extension is not allowed!
if (($extlimit == "yes") && (!in_array($ext,$limitedext))) {
echo "Wrong file extension.
--back";
exit();
}
//so, whats the file's extension?
$getExt = explode ('.', $file_name);
$file_ext = $getExt[count($getExt)-1];
//create a random file name
//$rand_name = md5(time());
///$rand_name = time();
$rand_name = "journal_".$_SESSION["sessionUserID"]."_".time();
//the new width variable
$ThumbWidth = $img_thumb_width;
//keep image type
if($file_size){
if($file_type == "image/pjpeg" || $file_type == "image/jpeg"){
$new_img = imagecreatefromjpeg($file_tmp);
}elseif($file_type == "image/x-png" || $file_type == "image/png"){
$new_img = imagecreatefrompng($file_tmp);
}elseif($file_type == "image/gif"){
$new_img = imagecreatefromgif($file_tmp);
}
//list the width and height and keep the height ratio.
list($width, $height) = getimagesize($file_tmp);
//calculate the image ratio
$imgratio=$width/$height;
if ($imgratio>1){
$newwidth = $ThumbWidth;
$newheight = $ThumbWidth/$imgratio;
}else{
$newheight = $ThumbWidth;
$newwidth = $ThumbWidth*$imgratio;
}
//make sure the image is big enough to resize
if (($newwidth > $width) || ($newheight > $height) ){
$newwidth = $width;
$newheight = $height;
}
//function for resize image.
if (function_exists(imagecreatetruecolor)){
$resized_img = imagecreatetruecolor($newwidth,$newheight);
}else{
die("Error: Please make sure you have GD library ver 2+");
}
//the resizing is going on here!
imagecopyresampled($resized_img, $new_img, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
//finally, save the image
ImageJpeg ($resized_img,"$path_thumbs/$rand_name.$file_ext");
$pictureName= $rand_name.".".$file_ext ;
ImageDestroy ($resized_img);
ImageDestroy ($new_img);
}
}
$The_Text = ereg_replace("'","´",$_REQUEST["The_Text"]);
$Title = ereg_replace("'","´",$_REQUEST["Title"]);
$SQL = "INSERT INTO journal( Photo, User_ID, Title, The_Text, The_Date ) VALUES ( '$pictureName', '" . $_SESSION["sessionUserID"] . "' , '$Title', '$The_Text', '" . $theDate . "' )";
$result = mysql_query($SQL) or die(mysql_error());
$reqID=mysql_insert_id() ;
header("Location: myJournal.php?ID=$reqID ");
exit ;
}
?>
Yada Home | Journal
include 'beforeEndHead.php'; ?>
 |
 |
 |
 |
include "topSignIn.php"; ?> |
 |
include "nav-new.php" ;?>
 |
 |
|
| |
|
| |
 |
| include "bottomLocalSearch.php"; ?> |
|
|
include "googAna.php"; ?>