Files
legacy_rock/chat/user_info_update.php
2013-08-07 09:12:22 +00:00

174 lines
6.6 KiB
PHP

<?php
require_once("inc_common.php");
include($engine_path."users_get_list.php");
set_variable("surname");
set_variable("firstname");
set_variable("city");
set_variable("comments");
set_variable("email");
set_variable("url");
set_variable("icquin");
set_variable("day");
set_variable("month");
set_variable("year");
set_variable("sex");
set_variable("passwd1");
set_variable("passwd2");
set_variable("showGroup1");
set_variable("showGroup2");
set_variable("sm_del");
set_variable("big_del");
set_variable("enable_web_indicator");
if (isset($_FILES['small_photo']['name'])) $small_photo_name = $_FILES['small_photo']['name'];
else $small_photo_name = "";
if (isset($_FILES['small_photo']['tmp_name'])) $small_photo = $_FILES['small_photo']['tmp_name'];
else $small_photo = "";
if (isset($_FILES['small_photo']['size'])) $small_photo_size = $_FILES['small_photo']['size'];
else $small_photo_size = "";
if (isset($_FILES['big_photo']['name'])) $big_photo_name = $_FILES['big_photo']['name'];
else $big_photo_name = "";
if (isset($_FILES['big_photo']['tmp_name'])) $big_photo = $_FILES['big_photo']['tmp_name'];
else $big_photo = "";
if (isset($_FILES['big_photo']['size'])) $big_photo_size = $_FILES['big_photo']['size'];
else $big_photo_size = "";
$fields_to_update = array();
$new_small_image = "";
if (!$exists) {
$error_text = "$w_no_user";
include($file_path."designes/".$design."/error_page.php");
exit;
}
include("inc_user_class.php");
include($ld_engine_path."users_get_object.php");
$info_message = "";
$passwd1 = str_replace("\t","",$passwd1);
if ( strlen($passwd1)<1 or ($passwd1 != $passwd2) )
$info_message .= "$w_pas_not_changed.<br>\n";
else {
$info_message .= "$w_pas_changed.<br>\n";
$current_user->password = md5($passwd1);
}
if ($showGroup1 == "on") $current_user->show_group_1=1; else $current_user->show_group_1 = 0;
if ($showGroup2 == "on") $current_user->show_group_2=1; else $current_user->show_group_2=0;
$current_user->enable_web_indicator = ($enable_web_indicator == "on") ? 1 : 0;
$photo_base_path = $file_path."photos/".floor($is_regist/2000)."/";
$pic_name = "" . $is_regist . ".big.gif";
if (!file_exists($photo_base_path.$pic_name)) {
$pic_name = "" . $is_regist . ".big.jpg";
if (!file_exists($photo_base_path.$pic_name)) {
$pic_name = "" . $is_regist . ".big.png";
if (!file_exists($photo_base_path.$pic_name)) $pic_name="";
}
}
$big_picture = $pic_name;
$pic_name = "" . $is_regist . ".gif";
if (!file_exists($photo_base_path.$pic_name)) {
$pic_name = "" . $is_regist . ".jpg";
if (!file_exists($photo_base_path.$pic_name)) {
$pic_name = "" . $is_regist . ".png";
if (!file_exists($photo_base_path.$pic_name)) $pic_name="";
}
}
$small_picture = $pic_name;
$new_small_image = ($small_picture == "") ? "":floor($is_regist/2000)."/".$small_picture;
if (($big_photo_name != "" and $big_photo_name != "none") or $big_del == "on")
if ($big_picture != "") unlink($photo_base_path.$big_picture);
if (($small_photo_name != "" and $small_photo_name != "none") or $sm_del == "on")
if ($small_picture != "") {
unlink($photo_base_path.$small_picture);
$new_small_image = "";
}
#saving users photos
#not really good.
#I have also version which uses GD-library
#but it's not clear for me now, should I include it here or not.
#'cause it's not easy to determine which gd-functions are supported by ISP
if ($big_photo_name != "" and $big_photo_name != "none") {
if ($big_photo_size > $max_photo_size && $max_photo_size > 0)
echo str_replace("~", $max_photo_size,
str_replace("*", $big_photo_size,$w_too_big_photo))."<br>\n";
else {
$photo_sizes = getimagesize($big_photo);
if ($photo_sizes[2]<1 || $photo_sizes[2]>3)
echo $w_invalid_image."<br>\n";
else {
$new_file_name = "".$is_regist.".big.".
(($photo_sizes[2] == 1)? "gif":
($photo_sizes[2] == 2) ? "jpg":"png"
);
if ($photo_sizes[0] > $max_photo_width && $max_photo_width > 0)
echo str_replace("~", $max_photo_width,
str_replace("*", $photo_sizes[0],$w_too_big_photo_width))."<br>\n";
else if ($photo_sizes[1] > $max_photo_height && $max_photo_height > 0)
echo str_replace("~", $max_photo_height,
str_replace("*", $photo_sizes[1],$w_too_big_photo_height))."<br>\n";
else {
move_uploaded_file ($big_photo, $photo_base_path.$new_file_name);
@chmod($photo_base_path.$new_file_name, 0644);
}
}//end of 'image is valid'
}//end of 'big_photo_size is ok'
}
if ($small_photo_name != "" and $small_photo_name != "none") {
if ($small_photo_size > $max_avatar_size && $max_avatar_size > 0)
echo str_replace("~", $max_avatar_size,
str_replace("*", $small_photo_size,$w_too_big_avatar))."<br>\n";
else {
$photo_sizes = getimagesize($small_photo);
if ($photo_sizes[2]<1 || $photo_sizes[2]>3)
echo $w_invalid_image."<br>\n";
else {
$new_file_name = "".$is_regist.
(($photo_sizes[2] == 1)? "gif":
($photo_sizes[2] == 2) ? "jpg":"png"
);
if ($photo_sizes[0] > $max_avatar_width && $max_avatar_width > 0)
echo str_replace("~", $max_avatar_width,
str_replace("*", $photo_sizes[0],$w_too_big_photo_width))."<br>\n";
else if ($photo_sizes[1] > $max_avatar_height && $max_avatar_height > 0)
echo str_replace("~", $max_avatar_height,
str_replace("*", $photo_sizes[1],$w_too_big_photo_height))."<br>\n";
else {
move_uploaded_file ($small_photo, $photo_base_path.$new_file_name);
@chmod($photo_base_path.$new_file_name, 0644);
$new_small_image = floor($is_regist/2000)."/".$new_file_name;
}
}//end of 'image is valid'
}//end of 'small_photo_size is ok'
}
$fields_to_update[0][0] = USER_AVATAR;
$fields_to_update[0][1] = $new_small_image;
$fields_to_update[1][0] = USER_GENDER;
$fields_to_update[1][1] = intval($sex);
include($engine_path."user_din_data_update.php");
$current_user->surname = htmlspecialchars($surname);
$current_user->firstname = htmlspecialchars($firstname);
$current_user->city = htmlspecialchars($city);
$current_user->about = htmlspecialchars($comments);
$current_user->about = str_replace("\n","<br>", $current_user->about);
$current_user->email = htmlspecialchars($email);
$current_user->url = htmlspecialchars($url);
$current_user->icquin = htmlspecialchars($icquin);
//0 means no value
$day = intval($day); $current_user->b_day = ($day<0||$day>31) ? 0:$day;
$month = intval($month); $current_user->b_month = ($month<0||$month>12) ? 0:$month;
$year = intval($year); $current_user->b_year = ($year<1900||$year>(date("Y")-3)) ? 0:$year;
$sex = intval($sex); $current_user->sex = ($sex<0||$sex>2) ? 0:$sex;
include($ld_engine_path."user_info_update.php");
include($file_path."designes/".$design."/user_info_update.php");
?>