require ("../connection.inc");
require ("../sel_codes.inc");
$table_name="users";
if (!$action)
include ("index.php3");
elseif ($action == 'submit' && !$do) {
//Проверка
$chkuser = mysql_query("select nick_name from $table_name where nick_name='".$Tname."'");
$rezz = mysql_fetch_array($chkuser);
$num = mysql_num_rows($chkuser);
if ($num) $error.=" Такое имя уже существует
";
if (!$Tname || !$Tpassword || !$email) $error.=" Не заполнены обязательные поля
";
if (!ereg("^.+@.+\\..+$",$email) && $email<>'') $error.=" Вы ввели неправильный адрес эл. почты
";
if ($Trepass != $Tpassword) $error.=" Несоответствие пароля в полях
";
if (eregi("^[^0-9A-Za-z-]+-[0-9]+$", $Tname)) $error.=" Такое имя уже существует
";
$email = Strip_Tags($email);
$Tname = stripslashes(Strip_Tags(trim($Tname)));
$Tpassword = Strip_Tags($Tpassword);
$Trepass = Strip_Tags($Trepass);
if ($error) {
$do = '';
require ("index.php3");
}
else {
$do = 'continue';
include ("index.php3");
}
}
elseif ($action == 'submit' && $do == 'continue') {
$mydateborn = ("$dateborn3-$dateborn2-$dateborn1");
if ((!$town_id) && ($OtherCity<>'')) $gorod = strip_tags(trim($OtherCity));
else $gorod = '';
$homepage = ereg_replace("http://", "", $homepage);
$gorod = Strip_Tags(trim($gorod));
$Tabout = Strip_Tags(trim($Tabout));
$homepage = Strip_Tags(trim($homepage));
$icq = Strip_Tags(trim($icq));
$user_ip = getenv("HTTP_X_FORWARDED_FOR");
if (!ereg("[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}",$user_ip)) $user_ip = getenv("REMOTE_ADDR");
if ($permission == 'on') $permission = 1;
else $permission = 0;
for ($i=0; $iНачало регистрации";
$yourid = mysql_insert_id();
$do = 'photo';
include ("index.php3");
}
}
elseif ($action == 'submit' && $do == 'photo') {
if ($userfile) {
$max_size = 512000; //Максимально допустимый размер файла в байтах
if (ereg("^/tmp/[[:alnum:]]+$", $userfile)) {
if (ereg(".+\.([a-zA-Z]{3,4})", $userfile_name, $regs))
$ext = strtolower($regs[1]);
// Формирование имени файла
$dir_handle = opendir('../user_images');
while ($file = readdir($dir_handle)) {
//echo "$yourid";
if (preg_match("/^$yourid\_(.+)\./", $file, $end)) {
//echo "----$end[1]-------
";
if (strlen($end[1])==1) $all_ph[] = "0".$end[1];
else $all_ph[] = $end[1];
}
}
closedir($dir_handle);
if (!$all_ph) $num='_';
else {
rsort($all_ph);
if ($all_ph[0] <> '0_') $num = $all_ph[0] + 1;
else $num = $all_ph[1] + 1;
}
$userfile_name = "../user_images/".$yourid."_".$num.".".$ext;
// Конец Формирование имени файла
if (($ext == 'gif') or ($ext == 'jpg') or ($ext == 'jpeg') or ($ext == 'png')) {
if (($userfile_type == "image/gif") or ($userfile_type == "image/jpeg") or ($userfile_type == "image/pjpeg") or ($userfile_type == "image/png") or ($userfile_type == "image/x-png")) {
if ($userfile_size < $max_size) {
if (copy($userfile, $userfile_name)) {
chmod($userfile_name, 0644);
//echo "Все закачано !!!
";
$file = ereg_replace("^../", "", $userfile_name);
if (!$fst_picture) $update = mysql_query("UPDATE users set fst_picture='$file' where id='$yourid'") OR DIE (mysql_error());
else $query = mysql_query("insert into photoalbum (user_id, picture) VALUES ('$yourid','$file')") OR DIE (mysql_error());
}
else
$error .= "Ошибка при закачке файла. Попробуйте еще раз";
}
else
$error .= "Файл превышает максимально допустимый размер (500кБ)";
}
else
$error .= "Можно закачивать только графические файлы форматов jpeg(jpg), gif, png";
}
else
$error .= "Неподходящее расширение у файла";
}
}
$do = 'photo';
include ("index.php3");
}
elseif ($action == 'submit' && $do == 'del') {
if (!$id) { // delete from main table users !!
$query0 = mysql_query("select fst_picture from users where id=$yourid") or die(mysql_error());
$row0 = mysql_fetch_array($query0);
$query = mysql_query("select * from photoalbum where user_id=$yourid order by id limit 0,1") or die(mysql_error());
if (mysql_num_rows($query)) {
$row = mysql_fetch_array($query);
$query2 = mysql_query("update users set fst_picture='$row[picture]', edited='0' where id='$yourid'") OR DIE (mysql_error());
$query3 = mysql_query("delete from photoalbum where id=$row[id]") OR DIE (mysql_error());
}
else {
$query3 = mysql_query("update users set fst_picture='', edited='0' where id='$yourid'") OR DIE (mysql_error());
}
unlink("../$row0[fst_picture]") OR DIE ("Не удалось удалить фотографию с сервера");
}
else { // delete from photoalbum
$query = mysql_query("select * from photoalbum where id='$id'");
$row = mysql_fetch_array($query);
$query2 = mysql_query("delete from photoalbum where id='$id' AND user_id='$yourid'") OR DIE (mysql_error());
unlink("../$row[picture]") OR DIE ("Не удалось удалить фотографию с сервера");
}
$do = 'photo';
include ("index.php3");
}
elseif ($action == 'submit' && $do == 'end') {
include ("end_reg.inc");
}
require ("../disconnect.inc");
?>