本文整理汇总了PHP中image::Watermark方法的典型用法代码示例。如果您正苦于以下问题:PHP image::Watermark方法的具体用法?PHP image::Watermark怎么用?PHP image::Watermark使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类image
的用法示例。
在下文中一共展示了image::Watermark方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: stream_save
function stream_save($strdata, $albumid = 0, $fileext = 'jpg', $name = '', $title = '', $delsize = 0, $from = false)
{
global $_G, $space;
if ($albumid < 0) {
$albumid = 0;
}
$setarr = array();
require_once libfile('class/upload');
$upload = new discuz_upload();
$filepath = $upload->get_target_dir('album') . $upload->get_target_filename('album') . '.' . $fileext;
$newfilename = $_G['setting']['attachdir'] . './album/' . $filepath;
if ($handle = fopen($newfilename, 'wb')) {
if (fwrite($handle, $strdata) !== FALSE) {
fclose($handle);
$size = filesize($newfilename);
if (empty($space)) {
$_G['member'] = $space = getspace($_G['uid']);
$_G['username'] = addslashes($space['username']);
}
$_G['member'] = $space;
$maxspacesize = checkperm('maxspacesize');
$maxspacesize = $maxspacesize * 1024 * 1024;
if ($maxspacesize) {
space_merge($space, 'common_member_count');
space_merge($space, 'common_member_field_home');
if ($space['attachsize'] + $size - $delsize > $maxspacesize + $space['addsize']) {
@unlink($newfilename);
return -1;
}
}
if (!$upload->get_image_info($newfilename)) {
@unlink($newfilename);
return -2;
}
require_once libfile('class/image');
$image = new image();
$result = $image->Thumb($newfilename, NULL, 140, 140, 1);
$thumb = empty($result) ? 0 : 1;
$image->Watermark($newfilename);
$pic_remote = 0;
$album_picflag = 1;
if (getglobal('setting/ftp/on')) {
$ftpresult_thumb = 0;
$ftpresult = ftpupload('album/' . $filepath);
if ($ftpresult) {
if ($thumb) {
ftpupload('album/' . $filepath . '.thumb.jpg');
}
$pic_remote = 1;
$album_picflag = 2;
} else {
if (getglobal('setting/ftp/mirror')) {
@unlink($newfilename);
@unlink($newfilename . '.thumb.jpg');
return -3;
}
}
}
$filename = addslashes($name ? $name : substr(strrchr($filepath, '/'), 1));
$title = getstr($title, 200, 1, 1, 1);
if ($albumid) {
$albumid = album_creat_by_id($albumid);
} else {
$albumid = 0;
}
$setarr = array('albumid' => $albumid, 'uid' => $_G['uid'], 'username' => $_G['username'], 'dateline' => $_G['timestamp'], 'filename' => $filename, 'postip' => $_G['clientip'], 'title' => $title, 'type' => $fileext, 'size' => $size, 'filepath' => $filepath, 'thumb' => $thumb, 'remote' => $pic_remote);
$setarr['picid'] = DB::insert('home_pic', $setarr, 1);
DB::query("UPDATE " . DB::table('common_member_count') . " SET attachsize=attachsize+{$size} WHERE uid='{$_G['uid']}'");
include_once libfile('function/stat');
updatestat('pic');
return $setarr;
} else {
fclose($handle);
}
}
return -3;
}
示例2: image
$image = new image();
$thumb = $image->Thumb($upload->attach['target'], '', $_G['setting']['sourcewidth'], $_G['setting']['sourceheight'], 1, 1) ? 1 : 0;
$width = $image->imginfo['width'];
$upload->attach['size'] = $image->imginfo['size'];
}
if ($_G['setting']['thumbstatus']) {
$image = new image();
$thumb = $image->Thumb($upload->attach['target'], '', $_G['setting']['thumbwidth'], $_G['setting']['thumbheight'], $_G['setting']['thumbstatus'], 0) ? 1 : 0;
$width = $image->imginfo['width'];
}
if ($_G['setting']['thumbsource'] || !$_G['setting']['thumbstatus']) {
list($width) = @getimagesize($upload->attach['target']);
}
if ($_G['setting']['watermarkstatus'] && empty($_G['forum']['disablewatermark'])) {
$image = new image();
$image->Watermark($attach['target'], '', 'forum');
$upload->attach['size'] = $image->imginfo['size'];
}
}
$aids[] = $aid = getattachnewaid();
$setarr = array('aid' => $aid, 'dateline' => $_G['timestamp'], 'filename' => $upload->attach['name'], 'filesize' => $upload->attach['size'], 'attachment' => $upload->attach['attachment'], 'isimage' => $upload->attach['isimage'], 'uid' => $_G['uid'], 'thumb' => $thumb, 'remote' => '0', 'width' => $width);
C::t("forum_attachment_unused")->insert($setarr);
$attachaids[$hash] = $imagereplace['newimageurl'][] = '[attachimg]' . $aid . '[/attachimg]';
} else {
$imagereplace['newimageurl'][] = $attachaids[$hash];
}
}
}
if (!empty($aids)) {
require_once libfile('function/post');
}
示例3: updateattach
function updateattach($modnewthreads, $tid, $pid, $attachnew, $attachupdate = array(), $uid = 0)
{
global $_G;
$uid = $uid ? $uid : $_G['uid'];
$uidadd = $_G['forum']['ismoderator'] ? '' : " AND uid='{$uid}'";
if ($attachnew) {
$newaids = array_keys($attachnew);
$newattach = $newattachfile = $albumattach = array();
$query = DB::query("SELECT * FROM " . DB::table('forum_attachment_unused') . " WHERE aid IN (" . dimplode($newaids) . "){$uidadd}");
while ($attach = DB::fetch($query)) {
$newattach[$attach['aid']] = daddslashes($attach);
if ($attach['isimage']) {
$newattachfile[$attach['aid']] = $attach['attachment'];
}
}
if ($_G['setting']['watermarkstatus'] && empty($_G['forum']['disablewatermark'])) {
require_once libfile('class/image');
$image = new image();
}
if (!empty($_G['gp_albumaid'])) {
array_unshift($_G['gp_albumaid'], '');
$_G['gp_albumaid'] = array_unique($_G['gp_albumaid']);
unset($_G['gp_albumaid'][0]);
foreach ($_G['gp_albumaid'] as $aid) {
if (isset($newattach[$aid])) {
$albumattach[$aid] = $newattach[$aid];
}
}
}
foreach ($attachnew as $aid => $attach) {
$update = array();
$update['readperm'] = $_G['group']['allowsetattachperm'] ? $attach['readperm'] : 0;
$update['price'] = $_G['group']['maxprice'] ? intval($attach['price']) <= $_G['group']['maxprice'] ? intval($attach['price']) : $_G['group']['maxprice'] : 0;
$update['tid'] = $tid;
$update['pid'] = $pid;
$update['uid'] = $uid;
$update['description'] = cutstr(dhtmlspecialchars($attach['description']), 100);
DB::update(getattachtablebytid($tid), $update, "aid='{$aid}'");
if (!$newattach[$aid]) {
continue;
}
$update = array_merge($update, $newattach[$aid]);
if (!empty($newattachfile[$aid])) {
if ($_G['setting']['thumbstatus'] && $_G['forum']['disablethumb']) {
$update['thumb'] = 0;
@unlink($_G['setting']['attachdir'] . '/forum/' . getimgthumbname($newattachfile[$aid]));
if (!empty($albumattach[$aid])) {
$albumattach[$aid]['thumb'] = 0;
}
}
if ($_G['setting']['watermarkstatus'] && empty($_G['forum']['disablewatermark'])) {
$image->Watermark($_G['setting']['attachdir'] . '/forum/' . $newattachfile[$aid], '', 'forum');
$update['filesize'] = $image->imginfo['size'];
}
}
if (!empty($_G['gp_albumaid']) && isset($albumattach[$aid])) {
$newalbum = 0;
if (!$_G['gp_uploadalbum']) {
require_once libfile('function/spacecp');
$_G['gp_uploadalbum'] = album_creat(array('albumname' => $_G['gp_newalbum']));
$newalbum = 1;
}
$picdata = array('albumid' => $_G['gp_uploadalbum'], 'uid' => $_G['uid'], 'username' => $_G['username'], 'dateline' => $albumattach[$aid]['dateline'], 'postip' => $_G['clientip'], 'filename' => $albumattach[$aid]['filename'], 'title' => cutstr(dhtmlspecialchars($attach['description']), 100), 'type' => fileext($albumattach[$aid]['attachment']), 'size' => $albumattach[$aid]['filesize'], 'filepath' => $albumattach[$aid]['attachment'], 'thumb' => $albumattach[$aid]['thumb'], 'remote' => $albumattach[$aid]['remote'] + 2);
$update['picid'] = DB::insert('home_pic', $picdata, 1);
if ($newalbum) {
require_once libfile('function/home');
require_once libfile('function/spacecp');
album_update_pic($_G['gp_uploadalbum']);
}
}
DB::insert(getattachtablebytid($tid), $update, false, true);
DB::update('forum_attachment', array('tid' => $tid, 'pid' => $pid, 'tableid' => getattachtableid($tid)), "aid='{$aid}'");
DB::delete('forum_attachment_unused', "aid='{$aid}'");
}
if (!empty($_G['gp_albumaid'])) {
$albumdata = array('picnum' => DB::result_first("SELECT count(*) FROM " . DB::table('home_pic') . " WHERE albumid='{$_G['gp_uploadalbum']}'"), 'updatetime' => $_G['timestamp']);
DB::update('home_album', $albumdata, "albumid='{$_G['gp_uploadalbum']}'");
}
if ($newattach) {
ftpupload($newaids, $uid);
}
}
if (!$modnewthreads && $newattach && $uid == $_G['uid']) {
updatecreditbyaction('postattach', $uid, array(), '', count($newattach), 1, $_G['fid']);
}
if ($attachupdate) {
$query = DB::query("SELECT pid, aid, attachment, thumb, remote FROM " . DB::table(getattachtablebytid($tid)) . " WHERE aid IN (" . dimplode(array_keys($attachupdate)) . ")");
while ($attach = DB::fetch($query)) {
if (array_key_exists($attach['aid'], $attachupdate) && $attachupdate[$attach['aid']]) {
dunlink($attach);
}
}
$uaids = dimplode($attachupdate);
$query = DB::query("SELECT aid, width, filename, filesize, attachment, isimage, thumb, remote FROM " . DB::table('forum_attachment_unused') . " WHERE aid IN ({$uaids}){$uidadd}");
DB::query("DELETE FROM " . DB::table('forum_attachment_unused') . " WHERE aid IN ({$uaids}){$uidadd}");
$attachupdate = array_flip($attachupdate);
while ($attach = DB::fetch($query)) {
$update = $attach;
$update['dateline'] = TIMESTAMP;
$update['remote'] = 0;
//.........这里部分代码省略.........
示例4: libfile
$upload->init($_FILES['Filedata'], 'portal');
$attach = $upload->attach;
if (!$upload->error()) {
$upload->save();
}
if ($upload->error()) {
$errorcode = 4;
}
if (!$errorcode) {
if ($attach['isimage'] && empty($_G['setting']['portalarticleimgthumbclosed'])) {
require_once libfile('class/image');
$image = new image();
$thumbimgwidth = $_G['setting']['portalarticleimgthumbwidth'] ? $_G['setting']['portalarticleimgthumbwidth'] : 300;
$thumbimgheight = $_G['setting']['portalarticleimgthumbheight'] ? $_G['setting']['portalarticleimgthumbheight'] : 300;
$attach['thumb'] = $image->Thumb($attach['target'], '', $thumbimgwidth, $thumbimgheight, 2);
$image->Watermark($attach['target'], '', 'portal');
}
if (getglobal('setting/ftp/on') && (!$_G['setting']['ftp']['allowedexts'] && !$_G['setting']['ftp']['disallowedexts'] || $_G['setting']['ftp']['allowedexts'] && in_array($attach['ext'], $_G['setting']['ftp']['allowedexts']) || $_G['setting']['ftp']['disallowedexts'] && !in_array($attach['ext'], $_G['setting']['ftp']['disallowedexts'])) && (!$_G['setting']['ftp']['minsize'] || $attach['size'] >= $_G['setting']['ftp']['minsize'] * 1024)) {
if (ftpcmd('upload', 'portal/' . $attach['attachment']) && (!$attach['thumb'] || ftpcmd('upload', 'portal/' . getimgthumbname($attach['attachment'])))) {
@unlink($_G['setting']['attachdir'] . '/portal/' . $attach['attachment']);
@unlink($_G['setting']['attachdir'] . '/portal/' . getimgthumbname($attach['attachment']));
$attach['remote'] = 1;
} else {
if (getglobal('setting/ftp/mirror')) {
@unlink($attach['target']);
@unlink(getimgthumbname($attach['target']));
$errorcode = 5;
}
}
}
$setarr = array('uid' => $_G['uid'], 'filename' => $attach['name'], 'attachment' => $attach['attachment'], 'filesize' => $attach['size'], 'isimage' => $attach['isimage'], 'thumb' => $attach['thumb'], 'remote' => $attach['remote'], 'filetype' => $attach['extension'], 'dateline' => $_G['timestamp'], 'aid' => $aid);
示例5: updateattach
function updateattach($modnewthreads, $tid, $pid, $attachnew, $attachupdate = array(), $uid = 0)
{
global $_G;
$thread = C::t('forum_thread')->fetch($tid);
$uid = $uid ? $uid : $_G['uid'];
if ($attachnew) {
$newaids = array_keys($attachnew);
$newattach = $newattachfile = $albumattach = array();
foreach (C::t('forum_attachment_unused')->fetch_all($newaids) as $attach) {
if ($attach['uid'] != $uid && !$_G['forum']['ismoderator']) {
continue;
}
$attach['uid'] = $uid;
$newattach[$attach['aid']] = daddslashes($attach);
if ($attach['isimage']) {
$newattachfile[$attach['aid']] = $attach['attachment'];
}
}
if ($_G['setting']['watermarkstatus'] && empty($_G['forum']['disablewatermark']) || !$_G['setting']['thumbdisabledmobile']) {
require_once libfile('class/image');
$image = new image();
}
if (!empty($_GET['albumaid'])) {
array_unshift($_GET['albumaid'], '');
$_GET['albumaid'] = array_unique($_GET['albumaid']);
unset($_GET['albumaid'][0]);
foreach ($_GET['albumaid'] as $aid) {
if (isset($newattach[$aid])) {
$albumattach[$aid] = $newattach[$aid];
}
}
}
foreach ($attachnew as $aid => $attach) {
$update = array();
$update['readperm'] = $_G['group']['allowsetattachperm'] ? $attach['readperm'] : 0;
$update['price'] = $_G['group']['maxprice'] ? intval($attach['price']) <= $_G['group']['maxprice'] ? intval($attach['price']) : $_G['group']['maxprice'] : 0;
$update['tid'] = $tid;
$update['pid'] = $pid;
$update['uid'] = $uid;
$update['description'] = censor(cutstr(dhtmlspecialchars($attach['description']), 100));
C::t('forum_attachment_n')->update('tid:' . $tid, $aid, $update);
if (!$newattach[$aid]) {
continue;
}
$update = array_merge($update, $newattach[$aid]);
if (!empty($newattachfile[$aid])) {
if ($_G['setting']['thumbstatus'] && $_G['forum']['disablethumb']) {
$update['thumb'] = 0;
@unlink($_G['setting']['attachdir'] . '/forum/' . getimgthumbname($newattachfile[$aid]));
if (!empty($albumattach[$aid])) {
$albumattach[$aid]['thumb'] = 0;
}
} elseif (!$_G['setting']['thumbdisabledmobile']) {
$_daid = sprintf("%09d", $aid);
$dir1 = substr($_daid, 0, 3);
$dir2 = substr($_daid, 3, 2);
$dir3 = substr($_daid, 5, 2);
$dw = 320;
$dh = 320;
$thumbfile = 'image/' . $dir1 . '/' . $dir2 . '/' . $dir3 . '/' . substr($_daid, -2) . '_' . $dw . '_' . $dh . '.jpg';
$image->Thumb($_G['setting']['attachdir'] . '/forum/' . $newattachfile[$aid], $thumbfile, $dw, $dh, 'fixwr');
$dw = 720;
$dh = 720;
$thumbfile = 'image/' . $dir1 . '/' . $dir2 . '/' . $dir3 . '/' . substr($_daid, -2) . '_' . $dw . '_' . $dh . '.jpg';
$image->Thumb($_G['setting']['attachdir'] . '/forum/' . $newattachfile[$aid], $thumbfile, $dw, $dh, 'fixwr');
}
if ($_G['setting']['watermarkstatus'] && empty($_G['forum']['disablewatermark'])) {
$image->Watermark($_G['setting']['attachdir'] . '/forum/' . $newattachfile[$aid], '', 'forum');
$update['filesize'] = $image->imginfo['size'];
}
}
if (!empty($_GET['albumaid']) && isset($albumattach[$aid])) {
$newalbum = 0;
if (!$_GET['uploadalbum']) {
require_once libfile('function/spacecp');
$_GET['uploadalbum'] = album_creat(array('albumname' => $_GET['newalbum']));
$newalbum = 1;
}
$picdata = array('albumid' => $_GET['uploadalbum'], 'uid' => $uid, 'username' => $_G['username'], 'dateline' => $albumattach[$aid]['dateline'], 'postip' => $_G['clientip'], 'filename' => censor($albumattach[$aid]['filename']), 'title' => censor(cutstr(dhtmlspecialchars($attach['description']), 100)), 'type' => fileext($albumattach[$aid]['attachment']), 'size' => $albumattach[$aid]['filesize'], 'filepath' => $albumattach[$aid]['attachment'], 'thumb' => $albumattach[$aid]['thumb'], 'remote' => $albumattach[$aid]['remote'] + 2);
$update['picid'] = C::t('home_pic')->insert($picdata, 1);
if ($newalbum) {
require_once libfile('function/home');
require_once libfile('function/spacecp');
album_update_pic($_GET['uploadalbum']);
}
}
C::t('forum_attachment_n')->insert('tid:' . $tid, $update, false, true);
C::t('forum_attachment')->update($aid, array('tid' => $tid, 'pid' => $pid, 'tableid' => getattachtableid($tid)));
C::t('forum_attachment_unused')->delete($aid);
}
if (!empty($_GET['albumaid'])) {
$albumdata = array('picnum' => C::t('home_pic')->check_albumpic($_GET['uploadalbum']), 'updatetime' => $_G['timestamp']);
C::t('home_album')->update($_GET['uploadalbum'], $albumdata);
require_once libfile('function/home');
require_once libfile('function/spacecp');
album_update_pic($_GET['uploadalbum']);
}
if ($newattach) {
ftpupload($newaids, $uid);
}
//.........这里部分代码省略.........
示例6: stream_save
function stream_save($strdata, $albumid = 0, $fileext = 'jpg', $name = '', $title = '', $delsize = 0, $from = false)
{
global $_G, $space;
if ($albumid < 0) {
$albumid = 0;
}
$allowPicType = array('jpg', 'jpeg', 'gif', 'png');
if (!in_array($fileext, $allowPicType)) {
return -3;
}
$setarr = array();
$upload = new discuz_upload();
$filepath = $upload->get_target_dir('album') . $upload->get_target_filename('album') . '.' . $fileext;
$newfilename = $_G['setting']['attachdir'] . './album/' . $filepath;
if ($handle = fopen($newfilename, 'wb')) {
if (fwrite($handle, $strdata) !== FALSE) {
fclose($handle);
$size = filesize($newfilename);
if (empty($space)) {
$_G['member'] = $space = getuserbyuid($_G['uid']);
$_G['username'] = $space['username'];
}
$_G['member'] = $space;
loadcache('usergroup_' . $space['groupid']);
$_G['group'] = $_G['cache']['usergroup_' . $space['groupid']];
$maxspacesize = checkperm('maxspacesize');
if ($maxspacesize) {
space_merge($space, 'count');
space_merge($space, 'field_home');
if ($space['attachsize'] + $size - $delsize > $maxspacesize + $space['addsize'] * 1024 * 1024) {
@unlink($newfilename);
return -1;
}
}
if (!$upload->get_image_info($newfilename)) {
@unlink($newfilename);
return -2;
}
require_once libfile('class/image');
$image = new image();
$result = $image->Thumb($newfilename, NULL, 140, 140, 1);
$thumb = empty($result) ? 0 : 1;
$image->Watermark($newfilename);
$pic_remote = 0;
$album_picflag = 1;
if (getglobal('setting/ftp/on')) {
$ftpresult_thumb = 0;
$ftpresult = ftpcmd('upload', 'album/' . $filepath);
if ($ftpresult) {
@unlink($_G['setting']['attachdir'] . 'album/' . $filepath);
if ($thumb) {
$thumbpath = getimgthumbname($filepath);
ftpcmd('upload', 'album/' . $thumbpath);
@unlink($_G['setting']['attachdir'] . 'album/' . $thumbpath);
}
$pic_remote = 1;
$album_picflag = 2;
} else {
if (getglobal('setting/ftp/mirror')) {
@unlink($newfilename);
@unlink(getimgthumbname($newfilename));
return -3;
}
}
}
$filename = $name ? $name : substr(strrchr($filepath, '/'), 1);
$title = getstr($title, 200);
$title = censor($title);
if (censormod($title) || $_G['group']['allowuploadmod']) {
$pic_status = 1;
} else {
$pic_status = 0;
}
if ($albumid) {
$albumid = album_creat_by_id($albumid);
} else {
$albumid = 0;
}
$setarr = array('albumid' => $albumid, 'uid' => $_G['uid'], 'username' => $_G['username'], 'dateline' => $_G['timestamp'], 'filename' => $filename, 'postip' => $_G['clientip'], 'title' => $title, 'type' => $fileext, 'size' => $size, 'filepath' => $filepath, 'thumb' => $thumb, 'remote' => $pic_remote, 'status' => $pic_status);
$setarr['picid'] = C::t('home_pic')->insert($setarr, 1);
C::t('common_member_count')->increase($_G['uid'], array('attachsize' => $size));
include_once libfile('function/stat');
updatestat('pic');
return $setarr;
} else {
fclose($handle);
}
}
return -3;
}
示例7: showsubmenu
showsubmenu('imagepreview_thumb');
$sizesource = filesize(DISCUZ_ROOT . './static/image/admincp/watermarkpreview.jpg');
echo '<img src="data/attachment/temp/watermark_temp1.jpg?' . random(5) . '"><br /><br />' . $lang['imagepreview_imagesize_source'] . ' ' . number_format($sizesource) . ' Bytes ' . $lang['imagepreview_imagesize_target'] . ' ' . number_format($sizetarget1) . ' Bytes (' . sprintf("%2.1f", $sizetarget1 / $sizesource * 100) . '%)<br /><br />';
echo '<img src="data/attachment/temp/watermark_temp2.jpg?' . random(5) . '"><br /><br />' . $lang['imagepreview_imagesize_source'] . ' ' . number_format($sizesource) . ' Bytes ' . $lang['imagepreview_imagesize_target'] . ' ' . number_format($sizetarget2) . ' Bytes (' . sprintf("%2.1f", $sizetarget2 / $sizesource * 100) . '%)';
} else {
cpmsg('imagepreview_errorcode_' . $r, '', 'error');
}
} else {
$type = $_GET['type'];
if (!$_G['setting']['watermarkstatus'][$type]) {
cpmsg('watermarkpreview_error', '', 'error');
}
require_once libfile('class/image');
@unlink(DISCUZ_ROOT . './data/attachment/temp/watermark_temp3.jpg');
$image = new image();
if (!($r = $image->Watermark(DISCUZ_ROOT . './static/image/admincp/watermarkpreview.jpg', 'temp/watermark_temp3.jpg', $type))) {
$r = $image->error();
}
if ($r > 0) {
showsubmenu('imagepreview_watermark');
$sizesource = filesize('static/image/admincp/watermarkpreview.jpg');
$sizetarget = $image->imginfo['size'];
echo '<img src="data/attachment/temp/watermark_temp3.jpg?' . random(5) . '"><br /><br />' . $lang['imagepreview_imagesize_source'] . ' ' . number_format($sizesource) . ' Bytes ' . $lang['imagepreview_imagesize_target'] . ' ' . number_format($sizetarget) . ' Bytes (' . sprintf("%2.1f", $sizetarget / $sizesource * 100) . '%)';
} else {
cpmsg('imagepreview_errorcode_' . $r, '', 'error');
}
}
} elseif ($operation == 'rewrite') {
$rule = array();
$rewritedata = rewritedata();
$rule['{apache1}'] = $rule['{apache2}'] = $rule['{iis}'] = $rule['{iis7}'] = $rule['{zeus}'] = $rule['{nginx}'] = '';
示例8: threadsort_insertfile
function threadsort_insertfile($tid, &$files, $sortid, $edit = 0, $modidentifier, $channel)
{
global $_G;
$allowtype = 'jpg, jpeg, gif, bmp, png';
$newfiles = $aid = array();
if (empty($tid)) {
return;
}
if ($files['categoryimg']) {
foreach ($files['categoryimg']['name'] as $key => $val) {
$newfiles[$key]['name'] = $val;
$newfiles[$key]['type'] = $files['categoryimg']['type'][$key];
$newfiles[$key]['tmp_name'] = $files['categoryimg']['tmp_name'][$key];
$newfiles[$key]['error'] = $files['categoryimg']['error'][$key];
$newfiles[$key]['size'] = $files['categoryimg']['size'][$key];
}
} else {
return;
}
require_once libfile('class/upload');
$upload = new discuz_upload();
$uploadtype = 'category';
if ($channel['imageinfo']['watermarkstatus']) {
require_once libfile('class/house_image');
$image = new image($channel);
}
foreach ($newfiles as $key => $file) {
if (!$upload->init($file, $uploadtype)) {
continue;
}
if (!$upload->save()) {
if (count($newfiles) == 1) {
showmessage($upload->errormessage());
}
}
$newattach[$key] = $upload->attach['attachment'];
if ($channel['imageinfo']['watermarkstatus']) {
$image->Watermark($upload->attach['target']);
}
DB::query("INSERT INTO " . DB::table('category_' . $modidentifier . '_pic') . " (tid, url, dateline) VALUES ('{$tid}', '" . $upload->attach['attachment'] . "', '" . TIMESTAMP . "')");
$aid[$key] = DB::insert_id();
}
$attachnum = $edit ? intval(DB::result_first("SELECT COUNT(*) FROM " . DB::table('category_' . $modidentifier . '_pic') . " WHERE tid='{$tid}'")) : intval(count($aid));
if (substr($_G['gp_coverpic'], 0, 4) == 'old_') {
$newaid = substr($_G['gp_coverpic'], 4);
} else {
$_G['gp_coverpic'] = intval($_G['gp_coverpic']);
if ($aid[$_G['gp_coverpic']]) {
$newaid = $aid[$_G['gp_coverpic']];
} else {
$aid = array_slice($aid, 0, 1);
$newaid = $aid[0];
}
}
if (!empty($newaid)) {
DB::query("UPDATE " . DB::table('category_sortvalue') . "{$sortid} SET attachid='{$newaid}', attachnum='{$attachnum}' WHERE tid='{$tid}'");
}
}
示例9: intval
function forum_upload()
{
global $_G;
$this->uid = intval($_G['gp_uid']);
$swfhash = md5(substr(md5($_G['config']['security']['authkey']), 8) . $this->uid);
if (!$_FILES['Filedata']['error'] && $_G['gp_hash'] == $swfhash) {
$this->aid = 0;
$this->simple = !empty($_G['gp_simple']) ? $_G['gp_simple'] : 0;
$_G['groupid'] = intval(DB::result_first("SELECT groupid FROM " . DB::table('common_member') . " WHERE uid='" . $this->uid . "'"));
loadcache('usergroup_' . $_G['groupid']);
$_G['group'] = $_G['cache']['usergroup_' . $_G['groupid']];
require_once libfile('class/upload');
$upload = new discuz_upload();
$upload->init($_FILES['Filedata'], 'forum');
$this->attach =& $upload->attach;
if ($upload->error()) {
$this->uploadmsg(2);
}
$allowupload = !$_G['group']['maxattachnum'] || $_G['group']['maxattachnum'] && $_G['group']['maxattachnum'] > DB::result_first("SELECT count(*) FROM " . DB::table('forum_attachment') . " WHERE uid='{$_G['uid']}' AND dateline>'{$_G['timestamp']}'-86400");
if (!$allowupload) {
$this->uploadmsg(9);
}
if ($_G['group']['attachextensions'] && (!preg_match("/(^|\\s|,)" . preg_quote($upload->attach['ext'], '/') . "(\$|\\s|,)/i", $_G['group']['attachextensions']) || !$upload->attach['ext'])) {
$this->uploadmsg(1);
}
if (empty($upload->attach['size'])) {
$this->uploadmsg(2);
}
if ($_G['group']['maxattachsize'] && $upload->attach['size'] > $_G['group']['maxattachsize']) {
$this->uploadmsg(3);
}
if ($type = DB::fetch_first("SELECT maxsize FROM " . DB::table('forum_attachtype') . " WHERE extension='" . addslashes($upload->attach['ext']) . "'")) {
if ($type['maxsize'] == 0) {
$this->uploadmsg(4);
} elseif ($upload->attach['size'] > $type['maxsize']) {
$this->uploadmsg(5);
}
}
if ($upload->attach['size'] && $_G['group']['maxsizeperday']) {
$todaysize = intval(DB::result_first("SELECT SUM(filesize) FROM " . DB::table('forum_attachment') . " WHERE uid='{$_G['uid']}' AND dateline>'{$_G['timestamp']}'-86400"));
$todaysize += $upload->attach['size'];
if ($todaysize >= $_G['group']['maxsizeperday']) {
$this->uploadmsg(6);
}
}
$upload->save();
if ($upload->error() == -103) {
$this->uploadmsg(8);
} elseif ($upload->error()) {
$this->uploadmsg(9);
}
$thumb = $remote = $width = 0;
if ($upload->attach['isimage']) {
require_once libfile('class/image');
$image = new image();
$thumb = $image->Thumb($upload->attach['target'], '', $_G['setting']['thumbwidth'], $_G['setting']['thumbheight'], $_G['setting']['thumbstatus'], $_G['setting']['thumbsource']) ? 1 : 0;
$image->Watermark($upload->attach['target']);
$width = $image->imginfo['width'];
}
if (!$this->simple) {
$upload->attach['name'] = diconv($upload->attach['name'], 'utf-8');
}
if ($_G['gp_type'] != 'image' && $upload->attach['isimage']) {
$upload->attach['isimage'] = -1;
}
DB::query("INSERT INTO " . DB::table('forum_attachment') . " (tid, pid, dateline, readperm, price, filename, filetype, filesize, attachment, downloads, isimage, uid, thumb, remote, width)\n\t\t\t\tVALUES ('0', '0', '{$_G['timestamp']}', '0', '0', '" . $upload->attach['name'] . "', '" . $upload->attach['type'] . "', '" . $upload->attach['size'] . "', '" . $upload->attach['attachment'] . "', '0', '" . $upload->attach['isimage'] . "', '" . $this->uid . "', '{$thumb}', '{$remote}', '{$width}')");
$this->aid = DB::insert_id();
$this->uploadmsg(0);
}
}
示例10: updateattach
function updateattach($postattachcredits, $tid, $pid, $attachnew, $attachdel, $attachupdate = array(), $uid = 0)
{
global $_G;
$uid = $uid ? $uid : $_G['uid'];
$uidadd = $_G['forum']['ismoderator'] ? '' : " AND uid='{$uid}'";
$attachnum = $_G['group']['allowpostattach'];
if ($attachnew) {
$newaids = array_keys($attachnew);
$newattach = $newattachfile = $albumattach = array();
$query = DB::query("SELECT aid, tid, attachment FROM " . DB::table('forum_attachment') . " WHERE aid IN (" . dimplode($newaids) . "){$uidadd}");
while ($attach = DB::fetch($query)) {
if ($_G['group']['maxattachnum']) {
if ($attachnum <= 0) {
unset($attachnew[$attach['aid']]);
continue;
} else {
$attachnum--;
}
}
if (!$attach['tid']) {
$newattach[$attach['aid']] = $attach['aid'];
$newattachfile[$attach['aid']] = $attach['attachment'];
}
}
if ($_G['setting']['watermarkstatus'] && empty($_G['forum']['disablewatermark'])) {
require_once libfile('class/image');
$image = new image();
}
if (!empty($_G['gp_albumaid'])) {
array_unshift($_G['gp_albumaid'], '');
$_G['gp_albumaid'] = array_unique($_G['gp_albumaid']);
unset($_G['gp_albumaid'][0]);
$query = DB::query("SELECT * FROM " . DB::table('forum_attachment') . " WHERE aid IN (" . dimplode($_G['gp_albumaid']) . ")");
while ($attach = DB::fetch($query)) {
$albumattach[$attach['aid']] = $attach;
}
}
foreach ($attachnew as $aid => $attach) {
$update = array('readperm' => $_G['group']['allowsetattachperm'] ? $attach['readperm'] : 0, 'price' => $_G['group']['maxprice'] ? intval($attach['price']) <= $_G['group']['maxprice'] ? intval($attach['price']) : $_G['group']['maxprice'] : 0, 'tid' => $tid, 'pid' => $pid, 'uid' => $uid);
if ($_G['setting']['watermarkstatus'] && empty($_G['forum']['disablewatermark']) && !empty($newattachfile[$aid])) {
$image->Watermark($_G['setting']['attachdir'] . '/forum/' . $newattachfile[$aid], '', 'forum');
}
if (!empty($_G['gp_albumaid']) && isset($albumattach[$aid])) {
$newalbum = 0;
if (!$_G['gp_uploadalbum']) {
require_once libfile('function/spacecp');
$_G['gp_uploadalbum'] = album_creat(array('albumname' => $_G['gp_newalbum']));
$newalbum = 1;
}
$picdata = array('albumid' => $_G['gp_uploadalbum'], 'uid' => $_G['uid'], 'username' => $_G['username'], 'dateline' => $albumattach[$aid]['dateline'], 'postip' => $_G['clientip'], 'filename' => $albumattach[$aid]['filename'], 'title' => $albumattach[$aid]['description'], 'type' => fileext($albumattach[$aid]['attachment']), 'size' => $albumattach[$aid]['filesize'], 'filepath' => $albumattach[$aid]['attachment'], 'thumb' => $albumattach[$aid]['thumb'], 'remote' => $albumattach[$aid]['remote'] + 2);
$update['picid'] = DB::insert('home_pic', $picdata, 1);
if ($newalbum) {
require_once libfile('function/home');
require_once libfile('function/spacecp');
album_update_pic($_G['gp_uploadalbum']);
}
}
DB::query("REPLACE INTO " . DB::table('forum_attachmentfield') . " (aid, tid, pid, uid, description) VALUES ('{$aid}', '{$tid}', '{$pid}', '{$uid}', '" . cutstr(dhtmlspecialchars($attach['description']), 100) . "')");
DB::update('forum_attachment', $update, "aid='{$aid}'{$uidadd}");
}
if (!empty($_G['gp_albumaid'])) {
$albumdata = array('picnum' => DB::result_first("SELECT count(*) FROM " . DB::table('home_pic') . " WHERE albumid='{$_G['gp_uploadalbum']}'"), 'updatetime' => $_G['timestamp']);
DB::update('home_album', $albumdata, "albumid='{$_G['gp_uploadalbum']}'");
}
if ($newattach) {
ftpupload($newaids, $uid);
}
}
$query = DB::query("SELECT aid, attachment, thumb, remote FROM " . DB::table('forum_attachment') . " WHERE uid='{$uid}'");
$delaids = array();
while ($attach = DB::fetch($query)) {
$aids[] = $attach['aid'];
if ($attachdel && in_array($attach['aid'], $attachdel)) {
$delaids[] = $attach['aid'];
unset($newattach[$attach['aid']]);
dunlink($attach);
}
if ($attachupdate && array_key_exists($attach['aid'], $attachupdate) && $attachupdate[$attach['aid']]) {
dunlink($attach);
}
}
if ($newattach && $uid == $_G['uid']) {
updatecreditbyaction('postattach', $uid, array(), '', count($newattach));
}
if ($attachupdate) {
$uaids = dimplode($attachupdate);
$query = DB::query("SELECT aid, width, filename, filetype, filesize, attachment, isimage, thumb, remote FROM " . DB::table('forum_attachment') . " WHERE aid IN ({$uaids}){$uidadd}");
DB::query("DELETE FROM " . DB::table('forum_attachment') . " WHERE aid IN ({$uaids}){$uidadd}");
$attachupdate = array_flip($attachupdate);
while ($attach = DB::fetch($query)) {
$update = $attach;
$update['dateline'] = TIMESTAMP;
$update['remote'] = 0;
unset($update['aid']);
DB::update('forum_attachment', $update, "aid='" . $attachupdate[$attach['aid']] . "'{$uidadd}");
if ($_G['setting']['watermarkstatus'] && empty($_G['forum']['disablewatermark'])) {
$image->Watermark($_G['setting']['attachdir'] . '/forum/' . $attach['attachment'], '', 'forum');
}
ftpupload(array($attachupdate[$attach['aid']]), $uid);
}
//.........这里部分代码省略.........
示例11: foreach
$attach = $upload->attach;
if (!$upload->error()) {
$upload->save();
}
if ($upload->error()) {
portal_upload_error($upload->error());
}
$attachs[] = $attach;
}
if ($attachs) {
foreach ($attachs as $attach) {
if ($attach['isimage']) {
require_once libfile('class/image');
$image = new image();
$attach['thumb'] = $image->Thumb($attach['target'], '', '300', '300', 2);
$image->Watermark($attach['target']);
}
if (getglobal('setting/ftp/on')) {
if (ftpcmd('upload', 'portal/' . $attach['attachment'])) {
if ($attach['thumb']) {
ftpcmd('upload', 'portal/' . $attach['attachment'] . '.thumb.jpg');
}
$attach['remote'] = 1;
} else {
if (getglobal('setting/ftp/mirror')) {
@unlink($attach['target']);
@unlink($attach['target'] . '.thumb.jpg');
portal_upload_error(lang('portalcp', 'upload_remote_failed'));
}
}
}
示例12: forum_downremotefile
//.........这里部分代码省略.........
} else {
$imagereplace['newimageurl'][] = '';
}
continue;
}
if (!$attach['name']) {
$patharr = explode('/', $imageurl);
$attach['name'] = trim($patharr[count($patharr) - 1]);
}
$patharr = explode('/', $imageurl);
if (!$attach['name']) {
$attach['name'] = trim($patharr[count($patharr) - 1]);
}
$attach['thumb'] = '';
$attach['ext'] = trim($attach['ext']);
//不加这个有些还真不行
$attach['isimage'] = $upload->is_image_ext($attach['ext']);
if ($attach['isimage'] == 1 && $arr['is_download_img'] != 1) {
$imagereplace['newimageurl'][] = $value[0];
continue;
}
$attach['extension'] = $upload->get_target_extension($attach['ext']);
$attach['attachdir'] = $upload->get_target_dir('forum');
$attach['attachment'] = $attach['attachdir'] . $upload->get_target_filename('forum') . '.' . $attach['extension'];
$attach['target'] = getglobal('setting/attachdir') . './forum/' . $attach['attachment'];
if (!in_array($attach['ext'], $get_file_ext_arr) && $get_file_ext_arr && $attach['isimage'] == 0) {
if ($value[4] == 1) {
if ($del_a == 1) {
$imagereplace['newimageurl'][] = $value[2];
} else {
unset($imagereplace['oldimageurl'][$key]);
}
} else {
$imagereplace['newimageurl'][] = '';
}
continue;
}
if (!@($fp = fopen($attach['target'], 'wb'))) {
continue;
} else {
flock($fp, 2);
fwrite($fp, $content);
fclose($fp);
}
if (!$upload->get_image_info($attach['target']) && $attach['isimage'] == 1) {
@unlink($attach['target']);
continue;
}
$attach['size'] = filesize($attach['target']);
$upload->attach = $attach;
$thumb = $width = 0;
if ($upload->attach['isimage']) {
if ($_G['setting']['thumbstatus']) {
$image = new image();
$thumb = $image->Thumb($upload->attach['target'], '', $_G['setting']['thumbwidth'], $_G['setting']['thumbheight'], $_G['setting']['thumbstatus'], $_G['setting']['thumbsource']) ? 1 : 0;
$width = $image->imginfo['width'];
}
if ($_G['setting']['thumbsource'] || !$_G['setting']['thumbstatus']) {
list($width) = @getimagesize($upload->attach['target']);
}
if ($_G['setting']['watermarkstatus'] && empty($_G['forum']['disablewatermark']) && $arr['is_water_img'] == 1) {
$image = new image();
$image->Watermark($attach['target'], '', 'forum');
}
}
$desc = $value[3];
$arr['public_time'] = $arr['public_time'] ? $arr['public_time'] : $arr['dateline'];
$arr['public_time'] = $arr['public_time'] ? $arr['public_time'] : $_G['timestamp'];
$remote = 0;
$setarr = array('uid' => $arr['uid'], 'tid' => $arr['tid'], 'pid' => $arr['pid'], 'filename' => daddslashes($upload->attach['name']), 'attachment' => $upload->attach['attachment'], 'filesize' => $upload->attach['size'], 'thumb' => $thumb, 'remote' => $remote, 'picid' => $picid, 'isimage' => $attach['isimage'], 'description' => $desc, 'readperm' => 0, 'price' => 0, 'width' => $width, 'dateline' => $arr['public_time']);
$setimg_arr = array('tid' => $arr['tid'], 'attachment' => $upload->attach['attachment'], 'remote' => $remote);
$set_att = array('downloads' => rand(1, 15), 'tableid' => getattachtableid($arr['tid']), 'uid' => $arr['uid'], 'pid' => $arr['pid'], 'tid' => $arr['tid']);
if ($threadimage_flag == 0 && !$arr['is_post'] && $attach['isimage'] == 1) {
DB::insert('forum_threadimage', $setimg_arr, true);
$threadimage_flag = 1;
}
$setarr['aid'] = $newaids[] = DB::insert('forum_attachment', $set_att, true);
$at[] = $setarr['aid'];
$attachnew_arr[$setarr['aid']] = array('description' => $setarr['description']);
DB::insert(getattachtablebytid($arr['tid']), $setarr, true);
$attachaids[$hash] = $imagereplace['newimageurl'][] = '[attach]' . $setarr['aid'] . '[/attach]';
} else {
$imagereplace['newimageurl'][] = $attachaids[$hash];
}
}
}
if ($_G['setting']['ftp']['on'] == 1) {
require_once libfile('function/post');
ftpupload($newaids, $arr['uid']);
}
if (count($at) > 0) {
$arr['attachment'] = 2;
}
$arr['message'] = str_replace($imagereplace['oldimageurl'], $imagereplace['newimageurl'], $arr['message']);
if ($del_a == 1) {
$arr['message'] = clear_html_script($arr['message'], array(0));
}
forum_article_content($arr);
}
}