Файл: groups/avatars/handler/upload.php
Строк: 49
<?php
if (!empty($_FILES['file']))
{
if (!is_dir(HOME.'/files/groups/groups/avatars/'.$id))
{
mkdir(HOME.'/files/groups/avatars/'.$id,0777);
mkdir(HOME.'/files/groups/avatars/'.$id.'/icons',0777);
mkdir(HOME.'/files/groups/avatars/'.$id.'/mini',0777);
mkdir(HOME.'/files/groups/avatars/'.$id.'/preview',0777);
}
require_once HOME.'/toolkit/AcImage.php';
AcImage::setTransparency(true);
if(AcImage::isFileExists($_FILES['file']['tmp_name'])) {} else {$err = lang('Файл не существует!','Файл не існує!');}
if($err == false && AcImage::isFileImage($_FILES['file']['tmp_name']))
{
$file_name = time().'_'.rand(0000,9999).'.jpg';
AcImage::createImage($_FILES['file']['tmp_name'])->saveAsJPG(HOME.'/files/groups/avatars/'.$id.'/'.$file_name);
AcImage::setQuality(80);
AcImage::createImage($_FILES['file']['tmp_name'])->cropCenter('4pr', '4pr')->resizeByWidth(50)->saveAsJPG(HOME.'/files/groups/avatars/'.$id.'/icons/'.$file_name);
AcImage::createImage($_FILES['file']['tmp_name'])->cropCenter('4pr', '4pr')->resizeByWidth(150)->saveAsJPG(HOME.'/files/groups/avatars/'.$id.'/mini/'.$file_name);
AcImage::createImage($_FILES['file']['tmp_name'])->resizeByWidth(600)->resizeByHeight(600)->saveAsJPG(HOME.'/files/groups/avatars/'.$id.'/preview/'.$file_name);
mysql_query("UPDATE `groups` SET `avatar` = '".$file_name."', count_wall=count_wall+1 WHERE `id` = '".$id."'");
mysql_query("INSERT INTO `groups_avatars` SET `name` = '".$file_name."', `group_id` = '".$id."', `time` = '".time()."'");
mysql_query("INSERT INTO `groups_wall` SET `photos` = '".$file_name."', `from_group` = 1, `user_id` = '".$user_id."', `wall_id` = '".$id."', `type` = 'update_avatar', `time` = '".time()."'");
if ($ajax_query == true) exit;
else go(URL.'/groups/avatars/?id='.$id.'&r='.rand(0000,9999));
}
}
?>
<script type="text/javascript">
$('input:file').remove();
$(document).ready(function() {
new AjaxUpload('upload', {
action: "/groups/avatars/index.php?id=<?echo $id;?>",
name: "file",
data: {ajax: "yes"},
onSubmit: function(file, ext) {
if(! (ext && /^(jpg|gif|png|jpeg)$/.test(ext))) {
return false;
}
Page.Loading('start');
},
onComplete: function(file, res) {
$('#preview_loading').remove();
if(res)
Page.Go("/groups/avatars/index.php?id=<?echo $id;?>");
}
});
});
</script>