function waterMark($source, $ext, $imgsize = null) { global $db_watermark, $db_waterwidth, $db_waterheight, $db_ifgif, $db_waterimg, $db_waterpos, $db_watertext, $db_waterfont, $db_watercolor, $db_waterpct, $db_jpgquality; empty($imgsize) && ($imgsize = GetImgSize($source, $ext)); if (empty($imgsize)) { return; } if ($db_watermark && $imgsize['type'] < 4 && $imgsize['width'] > $db_waterwidth && $imgsize['height'] > $db_waterheight && function_exists('imagecreatefromgif') && function_exists('imagealphablending') && ($ext != 'gif' || function_exists('imagegif') && ($db_ifgif == 2 || $db_ifgif == 1 && (PHP_VERSION > '4.4.2' && PHP_VERSION < '5' || PHP_VERSION > '5.1.4'))) && ($db_waterimg && function_exists('imagecopymerge') || !$db_waterimg && function_exists('imagettfbbox'))) { ImgWaterMark($source, $db_waterpos, $db_waterimg, $db_watertext, $db_waterfont, $db_watercolor, $db_waterpct, $db_jpgquality); } }
function GetImgInfo($srcFile) { $imgdata = (array) GetImgSize($srcFile); if ($imgdata['type'] == 1) { $imgdata['type'] = 'gif'; } elseif ($imgdata['type'] == 2) { $imgdata['type'] = 'jpeg'; } elseif ($imgdata['type'] == 3) { $imgdata['type'] = 'png'; } elseif ($imgdata['type'] == 6) { $imgdata['type'] = 'bmp'; } else { return false; } if (empty($imgdata) || !function_exists('imagecreatefrom' . $imgdata['type'])) { return false; } $imagecreatefromtype = 'imagecreatefrom' . $imgdata['type']; $imgdata['source'] = $imagecreatefromtype($srcFile); !$imgdata['width'] && ($imgdata['width'] = imagesx($imgdata['source'])); !$imgdata['height'] && ($imgdata['height'] = imagesy($imgdata['source'])); return $imgdata; }
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)); }
Showmsg('头像保存失败,图片大小请不要超过2M!'); }*/ $data = $_SERVER['HTTP_RAW_POST_DATA'] ? $_SERVER['HTTP_RAW_POST_DATA'] : file_get_contents('php://input'); if ($data) { S::gp(array('from')); require_once R_P . 'require/showimg.php'; $filename = "{$winduid}.{$ext}"; //$normalDir = "upload/$udir/"; $middleDir = "upload/middle/{$udir}/"; $smallDir = "upload/small/{$udir}/"; $img_w = $img_h = 0; $middleFile = PwUpload::savePath($db_ifftp, $filename, $middleDir); PwUpload::createFolder(dirname($middleFile)); writeover($middleFile, $data); require_once R_P . 'require/imgfunc.php'; if (!($img_size = GetImgSize($middleFile))) { P_unlink($middleFile); Showmsg('upload_content_error'); } /*$normalFile = PwUpload::savePath($db_ifftp, "{$winduid}.$ext", "$normalDir"); PwUpload::createFolder(dirname($normalFile)); list($w, $h) = explode("\t", $db_fthumbsize); if ($db_iffthumb && MakeThumb($source, $normalFile, $w, $h)) { 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));
$size2 = filesize($dstsrc); $sizerate = round($size2 / $size1, 3) * 100; include PrintEot('setting'); exit; } else { adminmsg('watermark_error'); } } //pathumb $pathumb = GetGP('pathumb'); InitGP(array('athumbsize'), 'G'); if ($pathumb == 1) { require_once R_P . 'require/imgfunc.php'; $source = $imgdir . '/water/watermark.jpg'; $thumburl = D_P . 'data/bbscache/pathumb_preview.jpg'; $source_size = GetImgSize($source); $size1 = filesize($source); if ($thumbsize = MakeThumb($source, $thumburl, $athumbsize['athumbwidth'], $athumbsize['athumbheight'])) { $size2 = filesize($thumburl); $sizerate = round($size2 / $size1, 3) * 100; $imageurl = 'data/bbscache/pathumb_preview.jpg'; } else { $size2 = $size1; $sizerate = 100; $thumbsize[0] = $source_size['width']; $thumbsize[1] = $source_size['height']; $imageurl = $imgpath . '/water/watermark.jpg'; } include PrintEot('setting'); exit; }
function UploadFile($uid, $uptype = 'all', $thumbs = null) { //fix by noizy global $ifupload, $db_attachnum, $db_uploadfiletype, $action, $replacedb, $winddb, $_G, $tdtime, $timestamp, $fid, $db_attachdir, $attachdir, $db_watermark, $db_waterwidth, $db_waterheight, $db_ifgif, $db_waterimg, $db_waterpos, $db_watertext, $db_waterfont, $db_watercolor, $db_waterpct, $db_jpgquality, $db_ifathumb, $db_iffthumb, $db_athumbsize, $db_fthumbsize, $db_ifftp, $atc_attachment_name, $attach_ext, $savedir, $forumset; $uploaddb = array(); foreach ($_FILES as $key => $value) { if (if_uploaded_file($value['tmp_name'])) { list($t, $i) = explode('_', $key); $i = (int) $i; $atc_attachment = $value['tmp_name']; $atc_attachment_name = S::escapeChar($value['name']); $atc_attachment_size = $value['size']; $attach_ext = strtolower(substr(strrchr($atc_attachment_name, '.'), 1)); if (empty($attach_ext) || !isset($db_uploadfiletype[$attach_ext])) { uploadmsg($uptype, 'upload_type_error'); } if ((int) $atc_attachment_size < 1) { uploadmsg($uptype, 'upload_size_0'); } if ($db_uploadfiletype[$attach_ext] && $atc_attachment_size > $db_uploadfiletype[$attach_ext] * 1024) { uploadmsg($uptype, 'upload_size_error'); } if ($uptype == 'face') { $ifreplace = 0; $db_attachdir = 1; $db_ifathumb = $db_iffthumb; $db_athumbsize = $db_fthumbsize; $savedir = $thumbdir = ''; $tmpname = $uptype . "_{$uid}.{$attach_ext}"; $savedir = 'upload/' . str_pad(substr($uid, -2), 2, '0', STR_PAD_LEFT); $fileuplodeurl = $thumbdir = "{$savedir}/{$uid}.{$attach_ext}"; } elseif ($uptype == 'cnlogo') { $ifreplace = $db_ifathumb = 0; $db_attachdir = 1; $savedir = 'cn_img'; $tmpname = $uptype . "_{$uid}.{$attach_ext}"; $fileuplodeurl = "{$savedir}/colony_{$uid}.{$attach_ext}"; $thumbdir = ''; } elseif ($uptype == 'forumlogo') { $ifreplace = 0; $db_attachdir = 1; $db_ifathumb = 0; $tmpname = $uptype . "_{$uid}.{$attach_ext}"; $savedir = 'forumlogo'; $fileuplodeurl = "{$savedir}/{$fid}.{$attach_ext}"; } elseif ($uptype == 'photo') { if ($t == 'replace') { $ifreplace = 1; $fileuplodeurl = $replacedb[$i]; $tmpurl = strrchr($fileuplodeurl, '/'); $fileuplodename = $tmpurl ? substr($tmpurl, 1) : $fileuplodeurl; $tmpname = $uptype . "_{$fileuplodename}"; } else { $ifreplace = 0; $uid .= substr(md5($timestamp . $i . randstr(8)), 10, 15); $tmpname = $uptype . "_{$uid}.{$attach_ext}"; $fileuplodeurl = $fileuplodename = "{$uid}.{$attach_ext}"; $db_ifathumb = 1; if ($db_attachdir) { $savedir = 'photo/'; if ($db_attachdir == 2) { $savedir .= 'Day_' . date('ymd'); } elseif ($db_attachdir == 3) { $savedir .= "Cyid_{$GLOBALS['cyid']}"; } else { $savedir .= 'Mon_' . date('ym'); } $fileuplodeurl = $savedir . '/' . $fileuplodeurl; } } $thumbdir = str_replace($fileuplodename, 's_' . $fileuplodename, $fileuplodeurl); } else { if ($action == 'modify' && $t == 'replace' && isset($replacedb[$i])) { $ifreplace = 1; $fileuplodeurl = $replacedb[$i]['attachurl']; $tmpurl = strrchr($fileuplodeurl, '/'); $tmpname = $uptype . '_' . ($tmpurl ? substr($tmpurl, 1) : $fileuplodeurl); } else { $ifreplace = 0; $attach_ext = preg_replace('/(php|asp|jsp|cgi|fcgi|exe|pl|phtml|dll|asa|com|scr|inf)/i', "scp_\\1", $attach_ext); $winddb['uploadtime'] = $timestamp; $winddb['uploadnum']++; $prename = substr(md5($timestamp . $i . randstr(8)), 10, 15); $tmpname = $uptype . "_{$prename}.{$attach_ext}"; $fileuplodeurl = $fid . "_{$uid}_{$prename}.{$attach_ext}"; if ($db_attachdir) { if ($db_attachdir == 2) { $savedir = "Type_{$attach_ext}"; } elseif ($db_attachdir == 3) { $savedir = 'Mon_' . date('ym'); } elseif ($db_attachdir == 4) { $savedir = 'Day_' . date('ymd'); } else { $savedir = "Fid_{$fid}"; } $fileuplodeurl = $savedir . '/' . $fileuplodeurl; } } $thumbdir = "thumb/{$fileuplodeurl}"; } $havefile = $ifthumb = 0; if ($db_ifftp || file_exists("{$attachdir}/{$fileuplodeurl}")) { $havefile = 1; $source = D_P . "data/tmp/{$tmpname}"; } else { $source = "{$attachdir}/{$fileuplodeurl}"; } if (!postupload($atc_attachment, $source)) { uploadmsg($uptype, 'upload_error'); } if ($uptype == 'face') { $max_source = $attachdir . "/upload/tmp/max_{$tmpname}"; if (!copy($source, $max_source)) { uploadmsg($uptype, 'upload_error'); } /* if (!postupload($atc_attachment,$max_source)) { uploadmsg($uptype,'upload_error'); } */ } $ifupload = 3; $type = 'zip'; $img_size[0] = $img_size[1] = 0; $size = ceil(filesize($source) / 1024); if (in_array($attach_ext, array('gif', 'jpg', 'jpeg', 'png', 'bmp', 'swf'))) { require_once R_P . 'require/imgfunc.php'; if (!($img_size = GetImgSize($source, $attach_ext))) { P_unlink($source); uploadmsg($uptype, 'upload_content_error'); } $ifupload = 1; $img_size[0] = $img_size['width']; $img_size[1] = $img_size['height']; unset($img_size['width'], $img_size['height']); $type = 'img'; if ($attach_ext == 'swf') { $type = 'zip'; } elseif ($db_ifathumb) { $thumburl = $havefile ? D_P . "data/tmp/thumb_{$tmpname}" : "{$attachdir}/{$thumbdir}"; list($db_thumbw, $db_thumbh) = explode("\t", $db_athumbsize); list($cenTer, $sameFile) = explode("\t", $thumbs); createFolder(dirname($thumburl)); if ($thumbsize = MakeThumb($source, $thumburl, $db_thumbw, $db_thumbh, $cenTer, $sameFile)) { $img_size[0] = $thumbsize[0]; $img_size[1] = $thumbsize[1]; $source != $thumburl && ($ifthumb = 1); } } if ($uptype == 'all' && $db_watermark && $forumset['watermark'] && $img_size[2] < '4' && $img_size[0] > $db_waterwidth && $img_size[1] > $db_waterheight && function_exists('imagecreatefromgif') && function_exists('imagealphablending') && ($attach_ext != 'gif' || function_exists('imagegif') && ($db_ifgif == 2 || $db_ifgif == 1 && (PHP_VERSION > '4.4.2' && PHP_VERSION < '5' || PHP_VERSION > '5.1.4'))) && ($db_waterimg && function_exists('imagecopymerge') || !$db_waterimg && function_exists('imagettfbbox'))) { ImgWaterMark($source, $db_waterpos, $db_waterimg, $db_watertext, $db_waterfont, $db_watercolor, $db_waterpct, $db_jpgquality); if ($ifthumb == 1) { ImgWaterMark($thumburl, $db_waterpos, $db_waterimg, $db_watertext, $db_waterfont, $db_watercolor, $db_waterpct, $db_jpgquality); } } } elseif ($attach_ext == 'txt') { if (preg_match('/(onload|submit|post|form)/i', readover($source))) { P_unlink($source); uploadmsg($uptype, 'upload_content_error'); } $ifupload = 2; $type = 'txt'; } require_once R_P . 'require/functions.php'; if (pwFtpNew($GLOBALS['ftp'], $db_ifftp) && $GLOBALS['ftp']->upload($source, $fileuplodeurl)) { P_unlink($source); P_unlink("{$attachdir}/{$fileuplodeurl}"); if ($ifthumb == 1) { $GLOBALS['ftp']->mkdir("thumb/{$savedir}"); $GLOBALS['ftp']->upload($thumburl, $thumbdir) && P_unlink($thumburl); } } elseif ($havefile) { P_unlink("{$attachdir}/{$fileuplodeurl}"); @rename($source, "{$attachdir}/{$fileuplodeurl}"); if ($ifthumb == 1) { P_unlink("{$attachdir}/{$thumbdir}"); @rename($thumburl, "{$attachdir}/{$thumbdir}"); } } $uploaddb[] = array('id' => $i, 'ifreplace' => $ifreplace, 'name' => $atc_attachment_name, 'size' => $size, 'type' => $type, 'attachurl' => $fileuplodeurl, 'ifthumb' => $ifthumb, 'img_w' => $img_size[0], 'img_h' => $img_size[1], 'tmpname' => $tmpname); } } return $uploaddb; }
} elseif ($db_attachdir == 3) { $savedir = 'Mon_' . date('ym'); } elseif ($db_attachdir == 4) { $savedir = 'Day_' . date('ymd'); } else { $savedir = "Fid_{$fid}"; } } $newattname = $fileuplodeurl = preg_replace('/^0_/', "{$fid}_", $rt['attachurl']); $savedir && ($fileuplodeurl = $savedir . '/' . $fileuplodeurl); $dstfile = "{$attachdir}/{$fileuplodeurl}"; $srcfile = "{$attachdir}/mutiupload/{$rt['attachurl']}"; $ifthumb = 0; if (in_array($attach_ext, array('gif', 'jpg', 'jpeg', 'png', 'bmp'))) { require_once R_P . 'require/imgfunc.php'; if (!($img_size = GetImgSize($srcfile, $attach_ext))) { Showmsg('upload_content_error'); } $img_size[0] = $img_size['width']; $img_size[1] = $img_size['height']; unset($img_size['width'], $img_size['height']); if ($db_watermark && $forumset['watermark'] && $img_size[2] < '4' && $img_size[0] > $db_waterwidth && $img_size[1] > $db_waterheight && function_exists('imagecreatefromgif') && function_exists('imagealphablending') && ($attach_ext != 'gif' || function_exists('imagegif') && ($db_ifgif == 2 || $db_ifgif == 1 && (PHP_VERSION > '4.4.2' && PHP_VERSION < '5' || PHP_VERSION > '5.1.4'))) && ($db_waterimg && function_exists('imagecopymerge') || !$db_waterimg && function_exists('imagettfbbox'))) { ImgWaterMark($srcfile, $db_waterpos, $db_waterimg, $db_watertext, $db_waterfont, $db_watercolor, $db_waterpct, $db_jpgquality); } if ($db_ifathumb) { $thumbdir = "thumb/{$fileuplodeurl}"; $thumburl = $db_ifftp ? D_P . "data/tmp/thumb_{$newattname}" : "{$attachdir}/{$thumbdir}"; list($db_thumbw, $db_thumbh) = explode("\t", $db_athumbsize); createFolder(dirname($thumburl)); if ($thumbsize = MakeThumb($srcfile, $thumburl, $db_thumbw, $db_thumbh)) { $img_size[0] = $thumbsize[0];
} $data = file_get_contents($source); if ($data) { InitGP(array('from')); require_once R_P . 'require/showimg.php'; $filename = "{$winduid}.jpg"; //$normalDir = "upload/$udir/"; $middleDir = "upload/middle/{$udir}/"; $smallDir = "upload/small/{$udir}/"; $img_w = $img_h = 0; $middleFile = PwUpload::savePath($db_ifftp, $filename, $middleDir); PwUpload::createFolder(dirname($middleFile)); writeover($middleFile, $data); MakeThumb($middleFile, $middleFile, 128, 128); require_once R_P . 'require/imgfunc.php'; if (!($img_size = GetImgSize($middleFile, 'jpg'))) { P_unlink($middleFile); wap_msg('upload_content_error', $basename); } list($img_w, $img_h) = getimagesize($normalFile); $smallFile = PwUpload::savePath($db_ifftp, $filename, $smallDir); $s_ifthumb = 0; PwUpload::createFolder(dirname($smallFile)); if (MakeThumb($middleFile, $smallFile, 48, 48)) { $s_ifthumb = 1; } if ($db_ifftp) { PwUpload::movetoftp($middleFile, $middleDir . $filename); $s_ifthumb && PwUpload::movetoftp($smallFile, $smallDir . $filename); } pwFtpClose($GLOBALS['ftp']);
function UploadDiary($uid, $uptype = 'all', $thumbs = null) { global $ifupload, $db_attachnum, $o_uploadsize, $a, $did, $replacedb, $winddb, $_G, $tdtime, $timestamp, $o_attachdir, $attachdir, $db_watermark, $db_waterwidth, $db_waterheight, $db_ifgif, $db_waterimg, $db_waterpos, $db_watertext, $db_waterfont, $db_watercolor, $db_waterpct, $db_jpgquality, $db_ifathumb, $db_iffthumb, $db_athumbsize, $db_fthumbsize, $atc_attachment_name, $attach_ext, $savedir; $uploaddb = array(); foreach ($_FILES as $key => $value) { if (if_uploaded_file($value['tmp_name'])) { list($t, $i) = explode('_', $key); $i = (int) $i; $atc_attachment = $value['tmp_name']; $atc_attachment_name = S::escapeChar($value['name']); $atc_attachment_size = $value['size']; $attach_ext = strtolower(substr(strrchr($atc_attachment_name, '.'), 1)); if (empty($attach_ext) || !isset($o_uploadsize[$attach_ext])) { uploadmsg($uptype, 'upload_type_error'); } if ((int) $atc_attachment_size < 1) { uploadmsg($uptype, 'upload_size_0'); } if ($o_uploadsize[$attach_ext] && $atc_attachment_size > $o_uploadsize[$attach_ext] * 1024) { $GLOBALS['oversize'] = $o_uploadsize[$attach_ext]; uploadmsg($uptype, 'upload_size_error'); } if ($a == 'edit' && $t == 'replace' && isset($replacedb[$i])) { $ifreplace = 1; $fileuplodeurl = $replacedb[$i]['attachurl']; $tmpurl = strrchr($fileuplodeurl, '/'); $tmpname = $uptype . '_' . ($tmpurl ? substr($tmpurl, 1) : $fileuplodeurl); } else { $ifreplace = 0; $attach_ext = preg_replace('/(php|asp|jsp|cgi|fcgi|exe|pl|phtml|dll|asa|com|scr|inf)/i', "scp_\\1", $attach_ext); $winddb['uploadtime'] = $timestamp; $winddb['uploadnum']++; $prename = substr(md5($timestamp . $i . randstr(8)), 10, 15); $tmpname = $uptype . "_{$prename}.{$attach_ext}"; $fileuplodeurl = $uid . "_{$did}_{$prename}.{$attach_ext}"; if ($o_attachdir) { if ($o_attachdir == 1) { $savedir = "Type_{$attach_ext}"; } elseif ($o_attachdir == 2) { $savedir = 'Mon_' . date('ym'); } elseif ($o_attachdir == 3) { $savedir = 'Day_' . date('ymd'); } $fileuplodeurl = $savedir . '/' . $fileuplodeurl; } } $thumbdir = "thumb/diary/{$fileuplodeurl}"; $havefile = $ifthumb = 0; $source = "{$attachdir}/diary/{$fileuplodeurl}"; if (!postupload($atc_attachment, $source)) { uploadmsg($uptype, 'upload_error'); } $ifupload = 3; $img_size[0] = $img_size[1] = 0; $size = ceil(filesize($source) / 1024); if (in_array($attach_ext, array('gif', 'jpg', 'jpeg', 'png', 'bmp'))) { require_once R_P . 'require/imgfunc.php'; if (!($img_size = GetImgSize($source, $attach_ext))) { P_unlink($source); uploadmsg($uptype, 'upload_content_error'); } $ifupload = 1; $img_size[0] = $img_size['width']; $img_size[1] = $img_size['height']; unset($img_size['width'], $img_size['height']); $type = 'img'; if ($db_ifathumb) { $thumburl = $havefile ? D_P . "data/tmp/thumb_{$tmpname}" : "{$attachdir}/{$thumbdir}"; list($db_thumbw, $db_thumbh) = explode("\t", $db_athumbsize); list($cenTer, $sameFile) = explode("\t", $thumbs); createFolder(dirname($thumburl)); if ($thumbsize = MakeThumb($source, $thumburl, $db_thumbw, $db_thumbh, $cenTer, $sameFile)) { $img_size[0] = $thumbsize[0]; $img_size[1] = $thumbsize[1]; $source != $thumburl && ($ifthumb = 1); } } if ($uptype == 'all' && $db_watermark && $img_size[2] < '4' && $img_size[0] > $db_waterwidth && $img_size[1] > $db_waterheight && function_exists('imagecreatefromgif') && function_exists('imagealphablending') && ($attach_ext != 'gif' || function_exists('imagegif') && ($db_ifgif == 2 || $db_ifgif == 1 && (PHP_VERSION > '4.4.2' && PHP_VERSION < '5' || PHP_VERSION > '5.1.4'))) && ($db_waterimg && function_exists('imagecopymerge') || !$db_waterimg && function_exists('imagettfbbox'))) { ImgWaterMark($source, $db_waterpos, $db_waterimg, $db_watertext, $db_waterfont, $db_watercolor, $db_waterpct, $db_jpgquality); if ($ifthumb == 1) { ImgWaterMark($thumburl, $db_waterpos, $db_waterimg, $db_watertext, $db_waterfont, $db_watercolor, $db_waterpct, $db_jpgquality); } } } if ($havefile) { P_unlink("{$attachdir}/diary/{$fileuplodeurl}"); @rename($source, "{$attachdir}/diary/{$fileuplodeurl}"); if ($ifthumb == 1) { P_unlink("{$attachdir}/{$thumbdir}"); @rename($thumburl, "{$attachdir}/{$thumbdir}"); } if ($m_ifthumb == 1) { //TODO $m_ifthumb? P_unlink("{$attachdir}/{$m_thumbdir}/diary"); //TODO $m_thumbdir? @rename($m_thumburl, "{$attachdir}/{$m_thumbdir}/diary"); //TODO $m_thumburl? } if ($s_ifthumb == 1) { //TODO $m_ifthumb? P_unlink("{$attachdir}/{$s_thumbdir}/diary"); //TODO $s_thumbdir? @rename($s_thumburl, "{$attachdir}/{$s_thumbdir}/diary"); //TODO $s_thumburl? } } $uploaddb[] = array('id' => $i, 'ifreplace' => $ifreplace, 'name' => $atc_attachment_name, 'size' => $size, 'type' => $type, 'attachurl' => $fileuplodeurl, 'ifthumb' => $ifthumb, 'img_w' => $img_size[0], 'img_h' => $img_size[1]); } } return $uploaddb; }
function transfer() { global $attachdir, $db_enhideset, $db_sellset, $db_ifpwcache; if (!$this->flashatt) { return false; } $flattids = array_keys($this->flashatt); $attach = $this->pw_attachs->gets(array('tid' => 0, 'pid' => 0, 'uid' => $this->post->uid, 'aid' => $flattids)); foreach ($attach as $rt) { $value = $this->flashatt[$rt['aid']]; $rt['ifthumb'] = 0; $rt['descrip'] = $value['desc']; $rt['special'] = intval($value['special']); $rt['needrvrc'] = intval($value['needrvrc']); $rt['ctype'] = $value['ctype']; $rt['ext'] = strtolower(substr(strrchr($rt['name'], '.'), 1)); $srcfile = "{$attachdir}/mutiupload/{$rt['attachurl']}"; $rt['fileuploadurl'] = $filename = $thumbname = preg_replace('/^0_/', "{$this->forum->fid}_", $rt['attachurl']); $thumbdir = 'thumb/'; if ($savedir = $this->getSaveDir($rt['ext'])) { $rt['fileuploadurl'] = $savedir . $filename; $thumbdir .= $savedir; } $source = PwUpload::savePath(0, $filename, $savedir); $thumburl = PwUpload::savePath($this->ifftp, $thumbname, $thumbdir, 'thumb_'); if (in_array($rt['ext'], array('gif', 'jpg', 'jpeg', 'png', 'bmp'))) { require_once R_P . 'require/imgfunc.php'; if (!($img_size = GetImgSize($srcfile, $rt['ext']))) { Showmsg('upload_content_error'); } if ($this->allowThumb()) { $thumbsize = PwUpload::makeThumb($srcfile, $thumburl, $this->getThumbSize(), $rt['ifthumb']); } if ($this->allowWaterMark()) { PwUpload::waterMark($srcfile, $rt['ext'], $img_size); $rt['ifthumb'] && PwUpload::waterMark($thumburl, $rt['ext']); } } if ($this->ifftp) { if (!PwUpload::movetoftp($srcfile, $rt['fileuploadurl'])) { continue; } $rt['ifthumb'] && PwUpload::movetoftp($thumburl, "thumb/{$rt['fileuploadurl']}"); } else { if (!PwUpload::movefile($srcfile, $source)) { continue; } } $this->attachs[$rt['aid']] = array('aid' => $rt['aid'], 'name' => $rt['name'], 'type' => $rt['type'], 'attachurl' => $rt['fileuploadurl'], 'needrvrc' => 0, 'special' => 0, 'ctype' => '', 'size' => $rt['size'], 'hits' => $rt['hits'], 'desc' => str_replace('\\', '', $rt['descrip']), 'ifthumb' => $rt['ifthumb']); $pwSQL = array('fid' => $this->forum->fid, 'attachurl' => $rt['fileuploadurl'], 'descrip' => $rt['descrip'], 'ifthumb' => $rt['ifthumb']); if ($rt['needrvrc'] > 0 && ($rt['special'] == 1 && $this->post->allowencode && in_array($rt['ctype'], $db_enhideset['type']) || $rt['special'] == 2 && $this->post->allowsell && in_array($rt['ctype'], $db_sellset['type']))) { $this->attachs[$rt['aid']]['needrvrc'] = $pwSQL['needrvrc'] = $rt['needrvrc']; $this->attachs[$rt['aid']]['special'] = $pwSQL['special'] = $rt['special']; $this->attachs[$rt['aid']]['ctype'] = $pwSQL['ctype'] = $rt['ctype']; } $this->post->user['uploadnum']++; $this->post->user['uploadtime'] = $timestamp; $this->pw_attachs->updateById($rt['aid'], $pwSQL); $this->ifupload = $rt['type'] == 'img' ? 1 : ($rt['type'] == 'txt' ? 2 : 3); if ($db_ifpwcache & 512 && !$rt['needrvrc'] && $rt['type'] == 'img' && !$this->elementpic) { $this->elementpic = array('aid' => $rt['aid'], 'attachurl' => $rt['fileuploadurl'], 'ifthumb' => $rt['ifthumb']); } } }