Файл: photos/handler/update.php
Строк: 25
<?php
if (!empty($_GET['update']) && is_numeric($_GET['update']))
{
$update = abs(intval($_GET['update']));
if (mysql_result(mysql_query("SELECT COUNT(`id`) FROM `photos_file` WHERE `id` = '".$update."' AND `user_id` = '".$user_id."' LIMIT 1"),0) == true)
{
$arr = mysql_fetch_array(mysql_query("SELECT * FROM `photos_file` WHERE `id` = '".$update."' AND `user_id` = '".$user_id."' LIMIT 1"));
$dir = HOME.'/files/avatars/'.$user_id;
if (!is_dir($dir))
{
mkdir(HOME.'/files/avatars/'.$user_id,0777);
mkdir(HOME.'/files/avatars/'.$user_id.'/icons',0777);
mkdir(HOME.'/files/avatars/'.$user_id.'/mini',0777);
mkdir(HOME.'/files/avatars/'.$user_id.'/preview',0777);
}
if (mysql_result(mysql_query("SELECT COUNT(`id`) FROM `avatars` WHERE `name` = '".$arr['name']."' AND `user_id` = '".$user_id."' LIMIT 1"),0) == false)
{
copy(HOME .'/files/photos/'. $user_id.'/'.$arr['name'], HOME .'/files/avatars/'.$user_id.'/'.$arr['name']);
copy(HOME .'/files/photos/'. $user_id.'/preview/'.$arr['name'], HOME .'/files/avatars/'.$user_id.'/preview/'.$arr['name']);
copy(HOME .'/files/photos/'. $user_id.'/mini/'.$arr['name'], HOME .'/files/avatars/'.$user_id.'/mini/'.$arr['name']);
copy(HOME .'/files/photos/'. $user_id.'/icons/'.$arr['name'], HOME .'/files/avatars/'.$user_id.'/icons/'.$arr['name']);
if (mysql_query("INSERT INTO `avatars` SET `name` = '".$arr['name']."', `user_id` = '".$user_id."', `time` = '".time()."'") == true) mysql_query("UPDATE `users` SET `avatar` = '".$arr['name']."', count_avatars=count_avatars+1 WHERE `id` = '".$user_id."'");
}
else
{
mysql_query("UPDATE `users` SET `avatar` = '".$arr['name']."' WHERE `id` = '".$user_id."'");
}
}
}
?>