include_once "includes/dbConnNew.php";
include_once "includes/loggedOn.php";
import_request_variables("gp", "");
//$_SESSION["sessionUserID"]= 22 ;
if($_REQUEST["theAction"] != "update"){
$SelectStr = "SELECT DATE_FORMAT(Birth_Date, '%m/%d/%Y') as BirthDate,DATE_FORMAT(Anniversary, '%m/%d/%Y') as Anniv, users.* from users where ID='" . $_SESSION["sessionUserID"] . "'";
$result = mysql_query($SelectStr)or die(mysql_error());
if($myrow=MySQL_fetch_array($result)){
if($myrow["Birth_Date"] <> "0000-00-00"){
$Birth_Date = $myrow["BirthDate"] ;
}
$Anniversary = $myrow["Anniv"] ;
}
}
if($_REQUEST["theAction"] == "update"){
$dob = $_REQUEST[Birthdate] ;
list($BirthMonth,$BirthDay,$BirthYear) = explode("/", $dob);
$Birthdate = $BirthYear."-".$BirthMonth."-".$BirthDay ;
$YearDiff = date("Y") - $BirthYear;
$MonthDiff = date("m") - $BirthMonth;
$DayDiff = date("d") - $BirthDay;
if ($MonthDiff < "0"){
$YearDiff --;
} else if ($BirthMonth == date("m") && $DayDiff < "0"){
$YearDiff --;
}
$age = $YearDiff ;
$agelimit=$age;
$ann = explode("/", $Anniversary) ;
$Anniversary =$ann[2]."-".$ann[0]."-".$ann[1] ;
$occupation = ereg_replace("'","´",$occupation);
if(checkdate($BirthMonth,$BirthDay,$BirthYear)){
if($agelimit >= 18 && $agelimit <= 90){
$SQL2 = "UPDATE users SET Birth_Date ='$Birthdate' ,Occupation = '$occupation',Gender ='$gender' ,Marital_Status = '$Marital' ,Anniversary ='$Anniversary' WHERE ID = '" . $_SESSION["sessionUserID"]. "'";
$result1 = mysql_query($SQL2) or die(mysql_error());
$_SESSION["sessionGender"] = $gender;
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 = 500; //
$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 = "profile_".$_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);
}
//now do the thumb
//make sure this directory is writable!
$path_thumbs = "userPhotos/thumbnails/";
//the new width of the resized image, in pixels.
$img_thumb_width = 84; //
$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 = "profile-" . $_SESSION['sessionUserID'] ;
//the new width variable
$ThumbWidth = $img_thumb_width;
/////////////////////////////////
// CREATE THE THUMBNAIL //
////////////////////////////////
//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);
//now do tiny image
//make sure this directory is writable!
$path_thumbs = "userPhotos/tiny/";
//the new width of the resized image, in pixels.
$img_thumb_width = 40; //
$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 = "profile-" . $_SESSION['sessionUserID'] ;
//the new width variable
$ThumbWidth = $img_thumb_width;
/////////////////////////////////
// CREATE THE THUMBNAIL //
////////////////////////////////
//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);
}
//end of tiny image
}
//GET FILE NAME TO DELETE
$sql = "SELECT Photo FROM users WHERE ID = '" . $_SESSION["sessionUserID"]. "'";
$sth = mysql_query($sql) or die(mysql_error());
$myrow=mysql_fetch_array($sth);
if ($myrow["Photo"])
{
unlink("userPhotos/" . $myrow["Photo"]);
unlink("userPhotos/thumbnails/" . $myrow["Photo"]);
unlink("userPhotos/tiny/" . $myrow["Photo"]);
}
$SQL2 = "UPDATE users SET Photo ='$pictureName' WHERE ID = '" . $_SESSION["sessionUserID"]. "'";
$result1 = mysql_query($SQL2) or die(mysql_error());
}
header("Location: myProfile.php");
exit ;
} else {
header("Location: editProfile1.php?error=a");
exit ;
}
} else {
header("Location: editProfile1.php?error=d");
exit ;
}
}
?>
YadaHome | Edit Profile
include 'beforeEndHead.php'; ?>
 |
 |
 |
 |
include "topSignIn.php"; ?> |
 |
include "nav-new.php" ;?>
 |
 |
|
|
|
|
|
include "bottomLocalSearch.php"; ?>
|
 |
|
|
include "googAna.php"; ?>