if($username == ""){
echo "You must be logged in to use this function
";
} else {
switch($_GET["function"]){
case "comment";
if($_POST["user"] != ""){
if($_POST["user"] == "") {
//do nothing
} else {
update_points(10);
$to = addslashes($_POST["user"]);
$from = addslashes($_SESSION["user"]["name"]);
$message = addslashes($_POST["message"]);
$q = mysql_query("INSERT INTO comments VALUES('$to', '$from', '$message', '$time')");
print "";
}
}
$usern = $_GET["user"];
startpage("Post Comment");
?>
Comment to print $usern ?>
endpage();
break;
case "build_mode";
if($_POST["profile_build"] == "yes"){
if($_FILES["uploadedfile"]["name"] != ""){
set_time_limit(0);
//resize!
$size = "170";
$prefix = "small_";
$target_path = "images/profiles/";
$imgname = base64_encode($_SESSION["user"]["name"]).".jpg";
$imgnamesmall = $target_path.$prefix.base64_encode($_SESSION["user"]["name"]).".jpg";
$target_path = $target_path.basename($imgname);
$uploaded_type = $_FILES["uploadedfile"]["type"];
if($uploaded_type == "image/pjpeg"){
copy($_FILES["uploadedfile"]["tmp_name"], $target_path);
}
$sizes = getimagesize($target_path);
$aspect_ratio = $sizes[1]/$sizes[0];
if ($sizes[1] <= $size) {
$new_width = $sizes[0];
$new_height = $sizes[1];
}else{
$new_height = $size;
$new_width = abs($new_height/$aspect_ratio);
}
$destimg=imagecreatetruecolor($new_width,$new_height) or die("Problem creating image");
$srcimg=imagecreatefromjpeg($target_path) or die("Problem getting old image");
if(function_exists('imagecopyresampled')){
imagecopyresampled($destimg,$srcimg,0,0,0,0,$new_width,$new_height,imagesx($srcimg),imagesy($srcimg)) or die("No image copy");
}else{
imagecopyresized($destimg,$srcimg,0,0,0,0,$new_width,$new_height,imagesx($srcimg),imagesy($srcimg)) or die("Error!");
}
imagejpeg($destimg,$imgnamesmall,90) or die("Cannot remake image");
}
$result = mysql_query("SELECT * from profiles where username='".$username."'");
$num = mysql_num_rows($result);
//being security for scripts and ect
$_POST["firstname"] = addslashes(replace2($_POST["firstname"]));
$_POST["lastname"] = addslashes(replace2($_POST["lastname"]));
$_POST["petsnames"] = addslashes(replace2($_POST["petsnames"]));
$_POST["hobbies"] = addslashes(replace2($_POST["hobbies"]));
$_POST["interests"] = addslashes(replace2($_POST["interests"]));
$_POST["aboutme"] = addslashes(replace2($_POST["aboutme"]));
$_POST["marstatus"] = addslashes(replace2($_POST["marstatus"]));
if($num != 0){
$query = "UPDATE profiles set firstname='".$_POST["firstname"]."', lastname='".$_POST["lastname"]."', pets='".$_POST["petsnames"]."', hobbies='".$_POST["hobbies"]."', interests='".$_POST["interests"]."', about='".$_POST["aboutme"]."', maritalstatus='".$_POST["marstatus"]."', title='".$_POST["title"]."', private='".$_POST["priv"]."' WHERE username='$username'";
mysql_query($query);
update_points(50);
} else {
$queryins = "INSERT INTO profiles VALUES('".$_POST["firstname"]."', '".$_POST["lastname"]."', '".$_POST["petsnames"]."', '".$_POST["hobbies"]."', '".$_POST["interests"]."', '".$_POST["aboutme"]."', '".$_POST["marstatus"]."', '".$username."','".$_POST["title"]."','".$_post["priv"]."')";
mysql_query($queryins);
update_points(50);
}
startpage("Profile");
?>
Profile updated!
">View profile
endpage();
}
$result = mysql_query("SELECT * from profiles where username='$username'");
$num = mysql_num_rows($result);
if($num !=0){
$row = mysql_fetch_array($result);
$efname = $row["firstname"];
$elname = $row["lastname"];
$epets = $row["pets"];
$einterests = $row["interests"];
$ehobbies = $row["hobbies"];
$eabout = $row["about"];
$emstatus = $row["maritalstatus"];
$etitle = $row["title"];
$valpriva = $row["private"];
}
startpage("Profile build");
?>
endpage();
break;
case "friends";
startpage("$username's friends");
?>
Approved friends |
|
Friend Requests |
|
Pending requests | ";
$res = mysql_query("SELECT * from friends where user='$username' AND status='0'");
while($row = mysql_fetch_array($res)){
echo " ".$row["friend"]." ";
}
?>
|
endpage();
break;
default;
startpage("Profile Index");
?>
Welcome to your profile index echo $username ?> |
Click here to edit your profile. |
Or here to view your profile as others see it! |
Click here to view your friends. |
endpage();
break;
}
}
?>