Вход Регистрация
Файл: vxas.ru/loginAPI.php
Строк: 157
<?
include_once 'sys/inc/start.php';
include_once 
'sys/inc/compress.php';
include_once 
'sys/inc/sess.php';
include_once 
'sys/inc/home.php';
include_once 
'sys/inc/settings.php';
include_once 
'sys/inc/db_connect.php';
include_once 
'sys/inc/ipua.php';
include_once 
'sys/inc/fnc.php';
include_once 
'sys/inc/user.php';
include_once 
'sys/inc/shif.php';

if (isset(
$_POST['token'])) {    $s = file_get_contents('http://ulogin.ru/token.php?token='.htmlspecialchars($_POST['token']).'&host=' . $_SERVER['HTTP_HOST']);    $_POST['loginAPI'] = true; }

if (isset(
$_POST['token']))$users = json_decode($s, true);


if (isset(
$_POST['token']) && !isset($user) && $users['network'] && $users['identity'] && $_POST['loginAPI'] == true)
{
if (
mysql_result(mysql_query("SELECT COUNT(*) FROM `user` WHERE `type_reg` = '".mysql_real_escape_string($users['network'])."' AND `identity` = '".mysql_real_escape_string($users['identity'])."'"),0) == 0)
{
/*
================================
Имя к id и пол
================================
*/
if ($users['network'] == 'odnoklassniki')
$idi = 'ok';
else
$idi = null;

if (
$users['sex'] == 2) $pol = 1;
else 
$pol = 0;
/*
================================
Создаем ник
================================
*/
$identity = $users['identity'];
$identity = str_replace('http://www.facebook.com', '', $identity);
$identity = str_replace('http://openid.yandex.ru', '', $identity);
$identity = str_replace('http://vk.com', '', $identity);
$identity = str_replace('http://odnoklassniki.ru', '', $identity);
$identity = str_replace('http://my.mail.ru/mail', '', $identity);
$identity = str_replace('/', '', $identity);
$identity = str_replace('.', '', $identity);
$identity = $idi . $identity;


/*
================================
Проверяем наличие ника в базе
если есть то добавляем случайное 
число
================================
*/
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `user` WHERE `nick` = '".mysql_real_escape_string($identity)."'"),0)!=0)
$identity = $identity . '_' . mt_rand(0000, 9999);
/*
================================
Регаем пользователя
================================
*/
$pass = $passgen;

mysql_query("INSERT INTO `user` (`nick`, `pass`, `date_reg`, `date_last`, `pol`,  `ank_name`, `identity`, `type_reg`)
 values('"
.mysql_real_escape_string($identity)."', '" . shif($pass) . "', '".mysql_real_escape_string($time)."', '".mysql_real_escape_string($time)."', '".mysql_real_escape_string($pol)."', '".mysql_real_escape_string($users['first_name'])."', '".mysql_real_escape_string($users['identity'])."', '".mysql_real_escape_string($users['network'])."')",$db);




$user=mysql_fetch_assoc(mysql_query("SELECT * FROM `user` WHERE `nick` = '".mysql_real_escape_string($identity)."' AND `pass` = '". shif($pass) ."' LIMIT 1"));


// отправка сообщения
$msgg = "Уважаем".htmlspecialchars($pol == 1 ? "ый" : "ая")." $users[first_name], поздравляем с успешной регистрацией на сайте!  ".htmlspecialchars($pol == 1 ? ".дружба." : ".ромашки.")." <br> Ваши регистрационные данные: </br> логин: $identity пароль: $pass . <br>Изменить свой ник вы можете [url=/pages/nick.php]ТУТ[/url] </br>И в целях безопасности смените пароль [url=/secure.php]ТУТ[/url]";
mysql_query("INSERT INTO `mail` (`id_user`, `id_kont`, `msg`, `time`) values('0', '".mysql_real_escape_string($user[id])."', '".my_esc($msgg)."', '".mysql_real_escape_string($time)."')");

$_SESSION['id_user']=$user['id'];
setcookie('id_user', $user['id'], time()+60*60*24*365);

/*
================================
Загружаем фото
================================
*/
$photo = $users['photo_big'];

mysql_query("INSERT INTO `gallery` (`id_user`, `name`) values('".mysql_real_escape_string($user[id])."', 'Личные фото')");

$gallery=mysql_fetch_assoc(mysql_query("SELECT * FROM `gallery` WHERE `id_user` = '".mysql_real_escape_string($user[id])."'  LIMIT 1"));

if (
$photo) // Наличие фото
{
if (
$imgc=@imagecreatefromstring(file_get_contents($photo)))
{
$name=$identity; // имя файла без расширения)),1);
$img_x=imagesx($imgc);
$img_y=imagesy($imgc);

if (!isset(
$err)){
mysql_query("INSERT INTO `gallery_foto` (`id_gallery`, `name`, `ras`, `type`) values ('".mysql_real_escape_string($gallery[id])."', '".mysql_real_escape_string($name)."', 'jpg', 'image/jpeg')");

$id_foto=mysql_insert_id();
mysql_query("UPDATE `gallery` SET `time` = '".mysql_real_escape_string($time)."' WHERE `id` = '".mysql_real_escape_string($gallery[id])."' LIMIT 1");

$fot_id=$id_foto;
if (
$img_x==$img_y)
{
$dstW=48; // ширина
$dstH=48; // высота 
}
elseif (
$img_x>$img_y)
{
$prop=$img_x/$img_y;
$dstW=48;
$dstH=ceil($dstW/$prop);
}
else
{
$prop=$img_y/$img_x;
$dstH=48;
$dstW=ceil($dstH/$prop);
}

$screen=imagecreatetruecolor($dstW, $dstH);
imagecopyresampled($screen, $imgc, 0, 0, 0, 0, $dstW, $dstH, $img_x, $img_y);
//imagedestroy($imgc);
imagejpeg($screen,H."sys/gallery/48/$id_foto.jpg",90);
@
chmod(H."sys/gallery/48/$id_foto.jpg",0777);
imagedestroy($screen);

if (
$img_x==$img_y)
{
$dstW=128; // ширина
$dstH=128; // высота 
}
elseif (
$img_x>$img_y)
{
$prop=$img_x/$img_y;
$dstW=128;
$dstH=ceil($dstW/$prop);
}
else
{
$prop=$img_y/$img_x;
$dstH=128;
$dstW=ceil($dstH/$prop);
}

$screen=imagecreatetruecolor($dstW, $dstH);
imagecopyresampled($screen, $imgc, 0, 0, 0, 0, $dstW, $dstH, $img_x, $img_y);
//imagedestroy($imgc);
$screen=img_copyright($screen); // наложение копирайта
imagejpeg($screen,H."sys/gallery/128/$id_foto.jpg",90);
@
chmod(H."sys/gallery/128/$id_foto.jpg",0777);
imagedestroy($screen);

if (
$img_x>640 || $img_y>640){
if (
$img_x==$img_y)
{
$dstW=640; // ширина
$dstH=640; // высота 
}
elseif (
$img_x>$img_y)
{
$prop=$img_x/$img_y;
$dstW=640;
$dstH=ceil($dstW/$prop);
}
else
{
$prop=$img_y/$img_x;
$dstH=640;
$dstW=ceil($dstH/$prop);
}

$screen=imagecreatetruecolor($dstW, $dstH);
imagecopyresampled($screen, $imgc, 0, 0, 0, 0, $dstW, $dstH, $img_x, $img_y);
//imagedestroy($imgc);
$screen=img_copyright($screen); // наложение копирайта
imagejpeg($screen,H."sys/gallery/640/$id_foto.jpg",90);
imagedestroy($screen);
$imgc=img_copyright($imgc); // наложение копирайта
imagejpeg($imgc,H."sys/gallery/foto/$id_foto.jpg",90);
@
chmod(H."sys/gallery/foto/$id_foto.jpg",0777);
}
else
{
$imgc=img_copyright($imgc); // наложение копирайта

imagejpeg($imgc,H."sys/gallery/640/$id_foto.jpg",90);
imagejpeg($imgc,H."sys/gallery/foto/$id_foto.jpg",90);
@
chmod(H."sys/gallery/foto/$id_foto.jpg",0777);
}

@
chmod(H."sys/gallery/640/$id_foto.jpg",0777);

imagedestroy($imgc);
//mysql_query("UPDATE `gallery_foto` SET `avatar` = '1' WHERE `id` = '".mysql_real_escape_string($id_foto)."' LIMIT 1");
}
}
}

$_SESSION['message'] = 'Поздравляем с успешной регистрацией!';
header("Location: /info.php");
exit;

}else{

    
$user=mysql_fetch_assoc(mysql_query("SELECT * FROM `user` WHERE `type_reg` = '".mysql_real_escape_string($users['network'])."' AND `identity` = '".mysql_real_escape_string($users['identity'])."' LIMIT 1"));
    
    
$_SESSION['id_user'] = mysql_real_escape_string($user['id']);

    
setcookie('id_user', $user['id'], time() + 60 * 60 * 24 * 365);
    
    
mysql_query("UPDATE `user` SET `date_aut` = ".mysql_real_escape_string(time())." WHERE `id` = '".mysql_real_escape_string($user[id])."' LIMIT 1");
    
mysql_query("UPDATE `user` SET `date_last` = ".mysql_real_escape_string(time())." WHERE `id` = '".mysql_real_escape_string($user[id])."' LIMIT 1");
    
    
$_SESSION['message'] = 'Вы успешно авторизовались';
    
header("Location: /info.php");
    exit;
    
}
}

?>
Онлайн: 0
Реклама