public
function
onuploadavatar() {
@header(
"Expires: 0"
);
@header(
"Cache-Control: private, post-check=0, pre-check=0, max-age=0"
, FALSE);
@header(
"Pragma: no-cache"
);
$this
->init_input(
$_GET
[
'agent'
]);
$uid
=
$this
->input[
'uid'
];
if
(
empty
(
$uid
)) {
return
-1;
}
if
(
empty
(
$_FILES
[
'Filedata'
])) {
return
-3;
}
list(
$width
,
$height
,
$type
,
$attr
) =
getimagesize
(
$_FILES
[
'Filedata'
][
'tmp_name'
]);
$imgtype
=
array
(1 =>
'.gif'
, 2 =>
'.jpg'
, 3 =>
'.png'
);
$filetype
=
$imgtype
[
$type
];
$tmpavatar
= MLEINC.
'/tmp/other/member_'
.
$uid
.
$filetype
;
file_exists
(
$tmpavatar
) && @unlink(
$tmpavatar
);
if
(@
copy
(
$_FILES
[
'Filedata'
][
'tmp_name'
],
$tmpavatar
) || @move_uploaded_file(
$_FILES
[
'Filedata'
][
'tmp_name'
],
$tmpavatar
)) {
@unlink(
$_FILES
[
'Filedata'
][
'tmp_name'
]);
list(
$width
,
$height
,
$type
,
$attr
) =
getimagesize
(
$tmpavatar
);
if
(
$width
< 10 ||
$height
< 10 ||
$type
== 4) {
@unlink(
$tmpavatar
);
return
-2;
}
}
else
{
@unlink(
$_FILES
[
'Filedata'
][
'tmp_name'
]);
return
-4;
}
global
$config
;
$avatarurl
=
$config
[
'url'
].
'inc/tmp/other/member_'
.
$uid
.
$filetype
;
return
$avatarurl
;
}