예제 #1
0
 function makeThumb($source, $thumburl, $thumbsize, &$ifthumb)
 {
     list($thumbw, $thumbh, $cenTer) = explode("\t", $thumbsize);
     PwUpload::createFolder(dirname($thumburl));
     if ($thumb = MakeThumb($source, $thumburl, $thumbw, $thumbh, $cenTer)) {
         $source != $thumburl && ($ifthumb = 1);
     }
     return $thumb;
 }
예제 #2
0
 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));
 }
예제 #3
0
 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);
 }
 pwFtpClose($GLOBALS['ftp']);
 $user_a = explode('|', $winddb['icon']);
 $user_a[2] = $img_w;
 $user_a[3] = $img_h;
 $usericon = setIcon("{$udir}/{$winduid}.{$ext}", 3, $user_a);
 $userService = L::loadClass('UserService', 'user');
 /* @var $userService PW_UserService */
 $userService->update($winduid, array('icon' => $usericon));
예제 #4
0
         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;
 }
 if (!$settingdb['att']) {
     if ($action) {
 /**
  * @static
  */
 function makeThumb($source, $thumbInfo, $ifftp, &$ifthumb)
 {
     $array = array();
     foreach ($thumbInfo as $key => $value) {
         list($thumbw, $thumbh, $cenTer) = explode("\t", $value[2]);
         $thumburl = PwUpload::savePath($ifftp, $value[0], $value[1]);
         PwUpload::createFolder(dirname($thumburl));
         if (($thumb = MakeThumb($source, $thumburl, $thumbw, $thumbh, $cenTer)) && $source != $thumburl) {
             $ifthumb |= 1 << $key;
             $array[] = array($thumburl, $value[1] . $value[0]);
         }
     }
     return $array;
 }
예제 #6
0
파일: postfunc.php 프로젝트: jechiy/PHPWind
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;
}
예제 #7
0
     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];
             $img_size[1] = $thumbsize[1];
             $ifthumb = 1;
         }
     }
     //Start elementupdate
     if ($db_ifpwcache & 512 && !$value['needrvrc'] && !$elementpic) {
         $elementpic = array('aid' => $rt['aid'], 'attachurl' => $fileuplodeurl, 'ifthumb' => $ifthumb);
     }
     //End elementupdate
 }
 if (pwFtpNew($ftp, $db_ifftp)) {
     if (!$ftp->upload($srcfile, $fileuplodeurl)) {
         continue;
     }
예제 #8
0
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;
}
예제 #9
0
/**
 * 图片缩略
 *
 * @param string $sourceImg 原图地址
 * @param int $width
 * @param int $height
 * @return string
 */
function minImage($sourceImg, $width, $height)
{
    static $mini = 0;
    global $db_bbsurl, $attachdir, $db_attachname, $_mainUrl;
    if (strpos($sourceImg, '://')) {
        return $sourceImg;
    }
    if (substr($sourceImg, strrpos($sourceImg, '.') + 1) == 'gif') {
        return ($_mainUrl ? $_mainUrl : $db_bbsurl) . '/' . $sourceImg;
    }
    if ($mini == 0) {
        if (file_exists($attachdir . "/mini")) {
            $mini = 1;
        } else {
            if (mkdir($attachdir . "/mini")) {
                @chmod($attachdir . "/mini", 0777);
                $mini = 1;
            } else {
                $mini = 2;
            }
        }
    }
    if ($mini == 1) {
        $width = (int) $width;
        $height = (int) $height;
        if (!$width || !$height) {
            Showmsg('minimage_wh_error');
        }
        $file_ext = end(explode('.', $sourceImg));
        $imgname = substr(md5($sourceImg . $width . $height), 10, 10) . '.' . $file_ext;
        $srcfile = (strpos($sourceImg, $db_attachname) === 0 || strpos($sourceImg, 'images') === 0 ? R_P : $attachdir) . $sourceImg;
        $targtImg = $attachdir . "/mini/" . $imgname;
        if (file_exists($targtImg) && filemtime($targtImg) > filemtime($srcfile)) {
            return ($_mainUrl ? $_mainUrl : $db_bbsurl) . '/' . $db_attachname . "/mini/" . $imgname;
        }
        require_once R_P . 'require/imgfunc.php';
        $thumbsize = MakeThumb($srcfile, $targtImg, $width, $height, 1);
        if ($thumbsize) {
            $fileurl = ($_mainUrl ? $_mainUrl : $db_bbsurl) . '/' . $db_attachname . "/mini/" . $imgname;
            return $fileurl;
        } else {
            return $sourceImg;
        }
    } else {
        return $sourceImg;
    }
}
예제 #10
0
 /**
  * 
  * 重新生成历史缩略图
  * @param int $tid 
  * return bool 
  */
 function reBuildAttachs($tid)
 {
     global $attachdir, $db_ifftp, $db_athumbtype;
     if ($db_ifftp) {
         return false;
     }
     require_once R_P . 'require/imgfunc.php';
     $tid = intval($tid);
     if ($tid < 1) {
         return false;
     }
     $attachsDao = $this->getAttachsDao();
     $yuanPics = $attachsDao->getImgsByTid($tid);
     if (!$yuanPics) {
         return false;
     }
     foreach ($yuanPics as $v) {
         $targtImg = $attachdir . "/thumb/mini/" . $v['attachurl'];
         $srcfile = $attachdir . '/' . $v['attachurl'];
         $this->createFolder(dirname($targtImg));
         if (!file_exists($srcfile)) {
             continue;
         }
         MakeThumb($srcfile, $targtImg, 200, 150, $db_athumbtype);
     }
 }