include('includes/config.php'); include('includes/auth.php'); $page="profileEdit"; include('includes/header.php'); $errors=null; if(isset($_POST['saveProfile']) && $_POST['saveProfile']==1){ //check for required fields if(!isset($_POST['fullname']) || $_POST['fullname']=="") $errors['fullname']="How will we know what to call you?"; if(!isset($_POST['emailaddress']) || $_POST['emailaddress']=="") $errors['emailaddress']="We promise not to spam you."; elseif(checkEmail($_POST['emailaddress'])) $errors['emailaddress']="This doesn't look right, have a check of it."; if(isset($_POST['passwordone']) && strlen($_POST['passwordone'])>0){ if($_POST['passwordone']!=$_POST['passwordtwo']) $errors['passwordone']="The two passwords don't match."; elseif(strlen($_POST['passwordone']) < 4) $errors['passwordone']="You can think of something longer than that I hope."; elseif(strlen($_POST['passwordone']) > 72) $errors['passwordone']="That password's a bit long, try something less that 72 characters."; else{ //hash password $hash = $hasher->HashPassword($_POST['passwordone']); if (strlen($hash) < 20) $errors['general']="There was an error saving your details, try submitting again."; else $user->properties['password']=$hash; } } //upload image $image=""; if(isset($_FILES['profilepic']) && $_FILES['profilepic']['name']!=""){ $uploadsDirectory=$_SERVER['DOCUMENT_ROOT']."/img/profileimages/"; //check it's an image @getimagesize($_FILES['profilepic']['tmp_name']) or $errors['profilepic']="File is not an image."; $now = 0; while(file_exists($uploadFilename = $uploadsDirectory.$now.'-'.$_FILES['profilepic']['name'])) { $now++; } @move_uploaded_file($_FILES['profilepic']['tmp_name'], $uploadFilename) or $errors['profilepic']="There was a problem uploading the file"; if($errors==null) $user->properties['image']=str_replace($uploadsDirectory,"", $uploadFilename); }//end if(isset($_FILES['postimage'])) //set values - ensure posted info shows in form //only saved if there are currently no errors $user->properties['name']=$_POST['fullname']; $user->properties['url']=$_POST['url']; $user->properties['profile']=$_POST['profile']; $user->properties['emailaddress']=$_POST['emailaddress']; //if($_POST['facebookAP']==1 || $_POST['facebookAPquick']==1) $user->properties['fbap']==1; $user->properties['fbap']=$_POST['facebookAP']; //if($_POST['twitterAP']==1 || $_POST['twitterAPquick']==1) $user->properties['twitterap']==1; $user->properties['twitterap']=$_POST['twitterAP']; $user->properties['showtwitter']=$_POST['showTwitter']; $user->properties['mailinglist']=$_POST['mailinglist']; if(isset($_POST['authCode']) && $_POST['authCode']==$user->properties['authenticationCode']) $user->properties['authenticated']=1; if($errors==null){ $user->save(); }//end if errors==null }//end if(isset($_POST['savePost']) && $_POST['savePost']==1){ ?>