function updateIcon($uid) { global $atc_attachment_name, $db_ifftp; $uid = intval($uid); if ($uid < 1 || !S::isArray($_FILES)) { return $this->buildResponse(USER_INVALID_PARAMS); } ACloud_Sys_Core_Common::setGlobal('customized_current_uid', $uid); $user = $this->getCurrentUser(); if (!$user->isLogin()) { return $this->buildResponse(USER_NOT_LOGIN); } $ext = strtolower(substr(strrchr($_FILES['icon']['name'], '.'), 1)); L::loadClass('faceupload', 'upload', false); $face = new FaceUpload($user->uid); $icondb = PwUpload::upload($face); require_once R_P . 'require/showimg.php'; $udir = str_pad(substr($user->uid, -2), 2, '0', STR_PAD_LEFT); if (!in_array(strtolower($ext), array('gif', 'jpg', 'jpeg', 'png', 'bmp'))) { return $this->buildResponse(USER_UPLOAD_CONTENT_ERROR); } $filename = "{$user->uid}.{$ext}"; $sourceFilename = "{$user->uid}_tmp.{$ext}"; $sourceDir = "upload/{$udir}/"; $middleDir = "upload/middle/{$udir}/"; $smallDir = "upload/small/{$udir}/"; $img_w = $img_h = 0; $sourceFile = PwUpload::savePath($db_ifftp, $sourceFilename, $sourceDir); $middleFile = PwUpload::savePath($db_ifftp, $filename, $middleDir); PwUpload::createFolder(dirname($middleFile)); PwUpload::movefile($sourceFile, $middleFile); require_once R_P . 'require/imgfunc.php'; if (!($img_size = GetImgSize($middleFile))) { P_unlink($middleFile); return $this->buildResponse(USER_UPLOAD_CONTENT_ERROR); } list($img_w, $img_h) = getimagesize($middleFile); $smallFile = PwUpload::savePath($db_ifftp, $filename, $smallDir); $s_ifthumb = 0; PwUpload::createFolder(dirname($smallFile)); if ($ext == 'gif') { L::loadClass('gifdecoder', 'utility', false); L::loadClass('gif', 'utility', false); $gifDecoder = new GIFDecoder($data); $frames = $gifDecoder->GIFGetFrames(); if (!empty($frames)) { foreach ($frames as $key => $value) { $frames[$key] = makeAvatarGifThumb($value, $img_w, $img_h, 48, 48); } $anime = new GIFEncoder($frames, $gifDecoder->GIFGetDelays(), $gifDecoder->GIFGetLoop(), $gifDecoder->GIFGetDisposal(), $gifDecoder->GIFGetTransparentR(), $gifDecoder->GIFGetTransparentG(), $gifDecoder->GIFGetTransparentB(), 'bin'); $newGifData = $anime->getAnimation(); PwUpload::createFolder(dirname($smallFile)); writeover($smallFile, $newGifData); $s_ifthumb = 1; } } elseif (MakeThumb($middleFile, $smallFile, 48, 48)) { $s_ifthumb = 1; } if ($db_ifftp) { PwUpload::movetoftp($middleFile, $middleDir . $filename); $s_ifthumb && PwUpload::movetoftp($smallFile, $smallDir . $filename); } $user_a = explode('|', $user->icon); $user_a[2] = $img_w; $user_a[3] = $img_h; $usericon = setIcon("{$udir}/{$user->uid}.{$ext}", 3, $user_a); $userService = L::loadClass('UserService', 'user'); /* @var $userService PW_UserService */ $userService->update($user->uid, array('icon' => $usericon)); list($iconurl) = showfacedesign($usericon, 1, 's'); return $this->buildResponse(0, array('icon' => $iconurl)); }
P_unlink($source); } elseif (!PwUpload::movefile($source, $normalFile)) { Showmsg('undefined_action'); }*/ list($img_w, $img_h) = getimagesize($middleFile); $smallFile = PwUpload::savePath($db_ifftp, $filename, $smallDir); $s_ifthumb = 0; PwUpload::createFolder(dirname($smallFile)); if ($ext == 'gif') { L::loadClass('gifdecoder', 'utility', false); L::loadClass('gif', 'utility', false); $gifDecoder = new GIFDecoder($data); $frames = $gifDecoder->GIFGetFrames(); if (!empty($frames)) { foreach ($frames as $key => $value) { $frames[$key] = makeAvatarGifThumb($value, $img_w, $img_h, 48, 48); } $anime = new GIFEncoder($frames, $gifDecoder->GIFGetDelays(), $gifDecoder->GIFGetLoop(), $gifDecoder->GIFGetDisposal(), $gifDecoder->GIFGetTransparentR(), $gifDecoder->GIFGetTransparentG(), $gifDecoder->GIFGetTransparentB(), 'bin'); $newGifData = $anime->getAnimation(); PwUpload::createFolder(dirname($smallFile)); pwCache::writeover($smallFile, $newGifData); $s_ifthumb = 1; } } elseif (MakeThumb($middleFile, $smallFile, 48, 48)) { $s_ifthumb = 1; } if ($db_ifftp) { //PwUpload::movetoftp($normalFile, $normalDir . "{$winduid}.$ext"); PwUpload::movetoftp($middleFile, $middleDir . $filename); $s_ifthumb && PwUpload::movetoftp($smallFile, $smallDir . $filename); }