/**
 *      [Discuz!] (C)2001-2099 Comsenz Inc.
 *      This is NOT a freeware, use is subject to license terms
 *
 *      $Id: function_portalcp.php 23372 2011-07-12 01:50:34Z zhangguosheng $
 */
function get_uploadcontent($attach, $type = 'portal', $dotype = '')
{
    $return = '';
    $dotype = $dotype ? 'checked' : '';
    if ($attach['isimage']) {
        $pic = pic_get($attach['attachment'], $type, $attach['thumb'], $attach['remote'], 0);
        $small_pic = $attach['thumb'] ? getimgthumbname($pic) : '';
        $check = $attach['pic'] == $type . '/' . $attach['attachment'] ? 'checked' : $dotype;
        $aid = $check ? $attach['aid'] : '';
        $return .= '<table id="attach_list_' . $attach['attachid'] . '" width="100%" class="xi2">';
        $return .= '<td width="50" class="bbs"><a href="' . $pic . '" target="_blank"><img src="' . ($small_pic ? $small_pic : $pic) . '" width="40" height="40"></a></td>';
        $return .= '<td align="right" class="bbs">';
        $return .= '<label for="setconver' . $attach['attachid'] . '"><input type="radio" name="setconver" id="setconver' . $attach['attachid'] . '" class="pr" value="1" onclick=setConver(\'' . addslashes(serialize(array('pic' => $type . '/' . $attach['attachment'], 'thumb' => $attach['thumb'], 'remote' => $attach['remote']))) . '\') ' . $check . '>' . lang('portalcp', 'set_to_conver') . '</label><br>';
        if ($small_pic) {
            $return .= '<a href="javascript:void(0);" onclick="insertImage(\'' . $small_pic . '\', \'' . $pic . '\');return false;">' . lang('portalcp', 'insert_small_image') . '</a><br>';
        }
        $return .= '<a href="javascript:void(0);" onclick="insertImage(\'' . $pic . '\');return false;">' . lang('portalcp', 'insert_large_image') . '</a><br>';
        if ($type == 'portal') {
            $return .= '<a href="javascript:void(0);" onclick="deleteAttach(\'' . $attach['attachid'] . '\', \'portal.php?mod=attachment&id=' . $attach['attachid'] . '&aid=' . $aid . '&op=delete\');return false;">' . lang('portalcp', 'delete') . '</a>';
        }
        $return .= '</td>';
        $return .= '</table>';
    } else {
        $return .= '<table id="attach_list_' . $attach['attachid'] . '" width="100%" class="xi2">';
        $return .= '<td width="50" class="bbs"><a href="portal.php?mod=attachment&id=' . $attach['attachid'] . '" target="_blank">' . $attach['filename'] . '</a></td>';
        $return .= '<td align="right" class="bbs">';
        $return .= '<a href="javascript:void(0);" onclick="insertFile(\'' . $attach['filename'] . '\', \'portal.php?mod=attachment&id=' . $attach['attachid'] . '\');return false;">' . lang('portalcp', 'insert_file') . '</a><br>';
        $return .= '<a href="javascript:void(0);" onclick="deleteAttach(\'' . $attach['attachid'] . '\', \'portal.php?mod=attachment&id=' . $attach['attachid'] . '&op=delete\');return false;">' . lang('portalcp', 'delete') . '</a>';
        $return .= '</td>';
        $return .= '</table>';
    }
    return $return;
}
 public function before_feed()
 {
     if (!empty($_GET['addfeed']) && $this->forum['allowfeed'] && !$this->param['isanonymous']) {
         $this->feed['icon'] = 'goods';
         $this->feed['title_template'] = 'feed_thread_goods_title';
         if ($_GET['item_price'] > 0) {
             if ($this->setting['creditstransextra'][5] != -1 && $_GET['item_credit']) {
                 $this->feed['body_template'] = 'feed_thread_goods_message_1';
             } else {
                 $this->feed['body_template'] = 'feed_thread_goods_message_2';
             }
         } else {
             $this->feed['body_template'] = 'feed_thread_goods_message_3';
         }
         $this->feed['body_data'] = array('itemname' => "<a href=\"forum.php?mod=viewthread&do=tradeinfo&tid=" . $this->tid . "&pid={$pid}\">{$_GET['item_name']}</a>", 'itemprice' => $_GET['item_price'], 'itemcredit' => $_GET['item_credit'], 'creditunit' => $this->setting['extcredits'][$this->setting['creditstransextra'][5]]['unit'] . $this->setting['extcredits'][$this->setting['creditstransextra'][5]]['title']);
         if ($_GET['tradeaid']) {
             $this->feed['images'] = array(getforumimg($_GET['tradeaid']));
             $this->feed['image_links'] = array("forum.php?mod=viewthread&do=tradeinfo&tid=" . $this->tid . "&pid={$pid}");
         }
         if ($_GET['tradeaid']) {
             $attachment = C::t('forum_attachment_n')->fetch('tid:' . $this->tid, $_GET['tradeaid']);
             if (in_array($attachment['filetype'], array('image/gif', 'image/jpeg', 'image/png'))) {
                 $imgurl = $this->setting['attachurl'] . 'forum/' . ($attachment['thumb'] && $attachment['filetype'] != 'image/gif' ? getimgthumbname($attachment['attachment']) : $attachment['attachment']);
                 $this->feed['images'][] = $attachment['attachment'] ? $imgurl : '';
                 $this->feed['image_links'][] = $attachment['attachment'] ? "forum.php?mod=viewthread&tid=" . $this->tid : '';
             }
         }
     }
 }
示例#3
0
function dunlink($attach) {
	global $_G;
	$filename = $attach['attachment'];
	$havethumb = $attach['thumb'];
	$remote = $attach['remote'];
	if($remote) {
		ftpcmd('delete', 'forum/'.$filename);
		$havethumb && ftpcmd('delete', 'forum/'.getimgthumbname($filename));
	} else {
		@unlink($_G['setting']['attachdir'].'/forum/'.$filename);
		$havethumb && @unlink($_G['setting']['attachdir'].'/forum/'.getimgthumbname($filename));
	}
	if($attach['aid']) {
		@unlink($_G['setting']['attachdir'].'image/'.$attach['aid'].'_100_100.jpg');
	}
}
示例#4
0
function get_upload_content($attachs, $dotype = '')
{
    $html = '';
    $dotype = $dotype ? 'checked' : '';
    $i = 0;
    foreach ($attachs as $key => $attach) {
        $type = $attach['from'] == 'forum' ? 'forum' : 'portal';
        $html .= '<td id="attach_list_' . $attach['attachid'] . '">';
        if ($attach['isimage']) {
            $pic = pic_get($attach['attachment'], $type, $attach['thumb'], $attach['remote'], 0);
            $small_pic = $attach['thumb'] ? getimgthumbname($pic) : '';
            $check = $attach['pic'] == $type . '/' . $attach['attachment'] ? 'checked' : $dotype;
            $aid = $check ? $attach['aid'] : '';
            $html .= '<a href="javascript:;" class="opattach">';
            $html .= '<span class="opattach_ctrl">';
            $html .= '<span onclick="insertImage(\'' . $pic . '\');" class="cur1">' . lang('portalcp', 'insert_large_image') . '</span><span class="pipe">|</span>';
            if ($small_pic) {
                $html .= '<span onclick="insertImage(\'' . $small_pic . '\', \'' . $pic . '\');" class="cur1">' . lang('portalcp', 'small_image') . '</span>';
            }
            $html .= '</span><img src="' . ($small_pic ? $small_pic : $pic) . '" onclick="insertImage(\'' . $pic . '\');" class="cur1" /></a>';
            $html .= '<label for="setconver' . $attach['attachid'] . '" class="cur1 xi2"><input type="radio" name="setconver" id="setconver' . $attach['attachid'] . '" class="pr" value="1" onclick=setConver(\'' . addslashes(serialize(array('pic' => $type . '/' . $attach['attachment'], 'thumb' => $attach['thumb'], 'remote' => $attach['remote']))) . '\') ' . $check . '>' . lang('portalcp', 'set_to_conver') . '</label>';
            if ($type == 'portal') {
                $html .= '<span class="pipe">|</span><span class="cur1 xi2" onclick="deleteAttach(\'' . $attach['attachid'] . '\', \'portal.php?mod=attachment&id=' . $attach['attachid'] . '&aid=' . $aid . '&op=delete\');">' . lang('portalcp', 'delete') . '</span>';
            }
        } else {
            $html .= '<img src="static/image/editor/editor_file_thumb.png" class="cur1" onclick="insertFile(\'' . $attach['filename'] . '\', \'portal.php?mod=attachment&id=' . $attach['attachid'] . '\');" tip="' . $attach['filename'] . '" onmouseover="showTip(this);" /><br/>';
            $html .= '<span onclick="deleteAttach(\'' . $attach['attachid'] . '\', \'portal.php?mod=attachment&id=' . $attach['attachid'] . '&op=delete\');" class="cur1 xi2">' . lang('portalcp', 'delete') . '</span>';
        }
        $html .= '</td>';
        $i++;
        if ($i % 4 == 0 && isset($attachs[$i])) {
            $html .= '</tr><tr>';
        }
    }
    if (!empty($html)) {
        if (($imgpad = $i % 4) > 0) {
            $html .= str_repeat('<td width="25%"></td>', 4 - $imgpad);
        }
        $html = '<table class="imgl"><tr>' . $html . '</tr></table>';
    }
    return $html;
}
示例#5
0
function fparseattach($aid, $length = 0, $extra = '')
{
    global $_G;
    $html = '';
    if (!empty($_G['post_attach']) && !empty($_G['post_attach'][$aid])) {
        $attach = $_G['post_attach'][$aid];
        unset($_G['post_attach'][$attach['aid']]);
        $attach['url'] = ($attach['remote'] ? $_G['setting']['ftp']['attachurl'] : $_G['setting']['attachurl']) . 'forum/';
        $attach['isimage'] = $attach['isimage'] && !$attach['price'] ? $attach['isimage'] : 0;
        $attach['refcheck'] = !$attach['remote'] && $_G['setting']['attachrefcheck'] || $attach['remote'] && ($_G['setting']['ftp']['hideurl'] || $attach['isimage'] && $_G['setting']['attachimgpost'] && strtolower(substr($_G['setting']['ftp']['attachurl'], 0, 3)) == 'ftp');
        $rimg_id = random(5) . $attach['aid'];
        if ($attach['isimage'] && !$attach['price'] && !$attach['readperm']) {
            $nothumb = $length ? 0 : 1;
            $src = $attach['url'] . (!$attach['thumb'] ? $attach['attachment'] : getimgthumbname($attach['attachment']));
            $html = bbcodeurl($src, '<img id="aimg_' . $rimg_id . '" src="' . $src . '" border="0" alt="' . $attach['filename'] . '" ' . $extra . ' style="cursor: pointer;" />');
            return fcodedisp($html, 'image');
        } else {
            if ($attach['price'] || $attach['readperm']) {
                $html = '<a href="forum.php?mod=viewthread&tid=' . $attach['tid'] . '" id="attach_' . $rimg_id . '" target="_blank" class="flw_attach_price"><strong>' . $attach['filename'] . '</strong><span>' . sizecount($attach['filesize']) . '</span></a>';
            } else {
                require_once libfile('function/attachment');
                $aidencode = packaids($attach);
                $attachurl = "forum.php?mod=attachment&aid={$aidencode}";
                $html = '<a href="' . $attachurl . '" id="attach_' . $rimg_id . '"><strong>' . $attach['filename'] . '</strong><span>' . sizecount($attach['filesize']) . '</span></a>';
            }
            return fcodedisp($html, 'attach');
        }
    }
    return '';
}
function getalbumpic($uid, $id)
{
    global $_G;
    $query = DB::query("SELECT filepath, thumb FROM " . DB::table('home_pic') . " WHERE albumid='{$id}' AND uid='{$uid}' ORDER BY thumb DESC, dateline DESC LIMIT 0,1");
    if ($pic = DB::fetch($query)) {
        return $pic['thumb'] ? getimgthumbname($pic['filepath']) : $pic['filepath'];
    } else {
        return '';
    }
}
示例#7
0
function parseforumattach(&$post, $aids)
{
    global $_G;
    if ($aids = array_unique($aids)) {
        require_once libfile('function/attachment');
        $finds = $replaces = array();
        foreach (C::t('forum_attachment_n')->fetch_all_by_id('tid:' . $post['tid'], 'aid', $aids) as $attach) {
            $attach['url'] = ($attach['remote'] ? $_G['setting']['ftp']['attachurl'] : $_G['setting']['attachurl']) . 'forum/';
            $attach['dateline'] = dgmdate($attach['dateline'], 'u');
            $extension = strtolower(fileext($attach['filename']));
            $attach['ext'] = $extension;
            $attach['imgalt'] = $attach['isimage'] ? strip_tags(str_replace('"', '\\"', $attach['description'] ? $attach['description'] : $attach['filename'])) : '';
            $attach['attachicon'] = attachtype($extension . "\t" . $attach['filetype']);
            $attach['attachsize'] = sizecount($attach['filesize']);
            $attach['refcheck'] = !$attach['remote'] && $_G['setting']['attachrefcheck'] || $attach['remote'] && ($_G['setting']['ftp']['hideurl'] || $attach['isimage'] && $_G['setting']['attachimgpost'] && strtolower(substr($_G['setting']['ftp']['attachurl'], 0, 3)) == 'ftp');
            $aidencode = packaids($attach);
            $widthcode = attachwidth($attach['width']);
            $is_archive = $_G['forum_thread']['is_archived'] ? "&fid=" . $_G['fid'] . "&archiveid=" . $_G['forum_thread']['archiveid'] : '';
            if ($attach['isimage']) {
                $attachthumb = getimgthumbname($attach['attachment']);
                if ($_G['setting']['thumbstatus'] && $attach['thumb']) {
                    $replaces[$attach['aid']] = "<a href=\"javascript:;\"><img id=\"_aimg_{$attach['aid']}\" aid=\"{$attach['aid']}\" onclick=\"zoom(this, this.getAttribute('zoomfile'), 0, 0, '{$_G[forum][showexif]}')\"\n\t\t\t\t\t\tzoomfile=\"" . ($attach['refcheck'] ? "forum.php?mod=attachment{$is_archive}&aid={$aidencode}&noupdate=yes&nothumb=yes" : $attach['url'] . $attach['attachment']) . "\"\n\t\t\t\t\t\tsrc=\"" . ($attach['refcheck'] ? "forum.php?mod=attachment{$is_archive}&aid={$aidencode}" : $attach['url'] . $attachthumb) . "\" alt=\"{$attach['imgalt']}\" title=\"{$attach['imgalt']}\" w=\"{$attach['width']}\" /></a>";
                } else {
                    $replaces[$attach['aid']] = "<img id=\"_aimg_{$attach['aid']}\" aid=\"{$attach['aid']}\"\n\t\t\t\t\t\tzoomfile=\"" . ($attach['refcheck'] ? "forum.php?mod=attachment{$is_archive}&aid={$aidencode}&noupdate=yes&nothumb=yes" : $attach['url'] . $attach['attachment']) . "\"\n\t\t\t\t\t\tsrc=\"" . ($attach['refcheck'] ? "forum.php?mod=attachment{$is_archive}&aid={$aidencode}&noupdate=yes " : $attach['url'] . $attach['attachment']) . "\" {$widthcode} alt=\"{$attach['imgalt']}\" title=\"{$attach['imgalt']}\" w=\"{$attach['width']}\" />";
                }
            } else {
                $replaces[$attach['aid']] = "{$attach['attachicon']}<a href=\"forum.php?mod=attachment{$is_archive}&aid={$aidencode}\" onmouseover=\"showMenu({'ctrlid':this.id,'pos':'12'})\" id=\"aid{$attach['aid']}\" target=\"_blank\">{$attach['filename']}</a>";
            }
            $finds[$attach['aid']] = '[attach]' . $attach['aid'] . '[/attach]';
        }
        if ($finds && $replaces) {
            $post['message'] = str_ireplace($finds, $replaces, $post['message']);
        }
    }
}
        $payrequired = $_G['uid'] ? !DB::result_first("SELECT uid FROM " . DB::table('common_credit_log') . " WHERE uid='{$_G['uid']}' AND relatedid='{$attach['aid']}' AND operation='BAC'") : 1;
        $payrequired && showmessage('attachement_payto_attach', 'forum.php?mod=misc&action=attachpay&aid=' . $attach['aid'] . '&tid=' . $attach['tid']);
    }
}
$isimage = $attach['isimage'];
$_G['setting']['ftp']['hideurl'] = $_G['setting']['ftp']['hideurl'] || $isimage && !empty($_G['gp_noupdate']) && $_G['setting']['attachimgpost'] && strtolower(substr($_G['setting']['ftp']['attachurl'], 0, 3)) == 'ftp';
if (empty($_G['gp_nothumb']) && $attach['isimage'] && $attach['thumb']) {
    $db = DB::object();
    $db->close();
    !$_G['config']['output']['gzip'] && ob_end_clean();
    dheader('Content-Disposition: inline; filename=' . getimgthumbname($attach['filename']));
    dheader('Content-Type: image/pjpeg');
    if ($attach['remote']) {
        $_G['setting']['ftp']['hideurl'] ? getremotefile(getimgthumbname($attach['attachment'])) : dheader('location:' . $_G['setting']['ftp']['attachurl'] . 'forum/' . getimgthumbname($attach['attachment']));
    } else {
        getlocalfile($_G['setting']['attachdir'] . '/forum/' . getimgthumbname($attach['attachment']));
    }
    exit;
}
$filename = $_G['setting']['attachdir'] . '/forum/' . $attach['attachment'];
if (!$attach['remote'] && !is_readable($filename)) {
    if (!$requestmode) {
        showmessage('attachment_nonexistence');
    } else {
        exit;
    }
}
if (!$requestmode) {
    if (!$ispaid && !$forum['allowgetattach']) {
        if (!$forum['getattachperm'] && !$allowgetattach) {
            showmessage('getattachperm_none_nopermission', NULL, array(), array('login' => 1));
示例#9
0
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;
            unset($update['aid']);
            if ($attach['isimage'] && $_G['setting']['watermarkstatus'] && empty($_G['forum']['disablewatermark'])) {
                $image->Watermark($_G['setting']['attachdir'] . '/forum/' . $attach['attachment'], '', 'forum');
                $update['filesize'] = $image->imginfo['size'];
            }
            DB::update(getattachtablebytid($tid), $update, "aid='" . $attachupdate[$attach['aid']] . "'");
            ftpupload(array($attachupdate[$attach['aid']]), $uid);
        }
    }
    $attachcount = DB::result_first("SELECT COUNT(*) FROM " . DB::table(getattachtablebytid($tid)) . " WHERE tid='{$tid}'" . ($pid > 0 ? " AND pid='{$pid}'" : ''));
    $attachment = $attachcount ? DB::result_first("SELECT COUNT(*) FROM " . DB::table(getattachtablebytid($tid)) . " WHERE tid='{$tid}'" . ($pid > 0 ? " AND pid='{$pid}'" : '') . " AND isimage != 0") ? 2 : 1 : 0;
    DB::query("UPDATE " . DB::table('forum_thread') . " SET attachment='{$attachment}' WHERE tid='{$tid}'", 'UNBUFFERED');
    if (!$attachment) {
        DB::delete('forum_threadimage', "tid='{$tid}'");
    }
    $posttable = getposttablebytid($tid);
    DB::query("UPDATE " . DB::table($posttable) . " SET attachment='{$attachment}' WHERE pid='{$pid}'", 'UNBUFFERED');
    $_G['forum_attachexist'] = $attachment;
}
示例#10
0
    } else {
        if ($attach['isimage']) {
            require_once libfile('class/image');
            $image = new image();
            $attach['thumb'] = $image->Thumb($attach['target'], '', '80', '50');
        }
        if (getglobal('setting/ftp/on')) {
            if (ftpcmd('upload', 'portal/' . $attach['attachment'])) {
                if ($attach['thumb']) {
                    ftpcmd('upload', 'portal/' . getimgthumbname($attach['attachment']));
                }
                $attach['remote'] = 1;
            } else {
                if (getglobal('setting/ftp/mirror')) {
                    @unlink($attach['target']);
                    @unlink(getimgthumbname($attach['target']));
                    topic_upload_error($attach, 'diy_remote_upload_failed');
                }
            }
        }
        $setarr = array('uid' => $_G['uid'], 'username' => $_G['username'], 'filename' => $attach['name'], 'filepath' => $attach['attachment'], 'size' => $attach['size'], 'thumb' => $attach['thumb'], 'remote' => $attach['remote'], 'dateline' => $_G['timestamp'], 'topicid' => $topicid);
        $setarr['picid'] = C::t('portal_topic_pic')->insert($setarr, true);
        topic_upload_show($topicid);
    }
} elseif (submitcheck('diysubmit')) {
    require_once libfile('function/portalcp');
    $tpldirectory = getstr($_POST['tpldirectory'], 80);
    $template = getstr($_POST['template'], 50);
    if (dsign($tpldirectory . $template) !== $_POST['diysign']) {
        showmessage('diy_sign_invalid');
    }
function attachinpost($attach, $post)
{
    global $_G;
    $firstpost = $post['first'];
    $attach['refcheck'] = !$attach['remote'] && $_G['setting']['attachrefcheck'] || $attach['remote'] && ($_G['setting']['ftp']['hideurl'] || $attach['isimage'] && $_G['setting']['attachimgpost'] && strtolower(substr($_G['setting']['ftp']['attachurl'], 0, 3)) == 'ftp');
    $aidencode = packaids($attach);
    $widthcode = attachwidth($attach['width']);
    $is_archive = $_G['forum_thread']['is_archived'] ? '&fid=' . $_G['fid'] . '&archiveid=' . $_G[forum_thread][archiveid] : '';
    $attachthumb = getimgthumbname($attach['attachment']);
    $musiccode = getstatus($post[status], 7) && fileext($attach['attachment']) == 'mp3' ? browserversion('ie') > 8 || browserversion('safari') ? '<audio controls="controls"><source src="' . $attach['url'] . $attach['attachment'] . '"></audio>' : parseaudio($attach['url'] . $attach['attachment'], 400) : '';
    $__STATICURL = STATICURL;
    $return = <<<EOF

<ignore_js_op>

EOF;
    if ($attach['attachimg'] && $_G['setting']['showimages'] && (!$attach['price'] || $attach['payed']) && ($_G['group']['allowgetimage'] || $_G['uid'] == $attach['uid'])) {
        if (!IS_ROBOT) {
            if ($_G['setting']['thumbstatus'] && $attach['thumb']) {
                $return .= <<<EOF

<img
EOF;
                if ($attach['price'] && $_G['forum_attachmentdown'] && $_G['uid'] != $attach['uid']) {
                    $return .= <<<EOF
 class="attprice"
EOF;
                }
                $return .= <<<EOF
 style="cursor:pointer" id="aimg_{$attach['aid']}" aid="{$attach['aid']}" src="{$__STATICURL}image/common/none.gif" onclick="zoom(this, this.getAttribute('zoomfile'), 0, 0, '{$_G['setting']['showexif']}')" zoomfile="
EOF;
                if ($attach['refcheck']) {
                    $return .= <<<EOF
forum.php?mod=attachment{$is_archive}&aid={$aidencode}&noupdate=yes&nothumb=yes
EOF;
                } else {
                    $return .= <<<EOF
{$attach['url']}{$attach['attachment']}
EOF;
                }
                $return .= <<<EOF
" file="
EOF;
                if ($attach['refcheck']) {
                    $return .= <<<EOF
forum.php?mod=attachment{$is_archive}&aid={$aidencode}
EOF;
                } else {
                    $return .= <<<EOF
{$attach['url']}{$attachthumb}
EOF;
                }
                $return .= <<<EOF
" inpost="1" alt="{$attach['imgalt']}" title="{$attach['imgalt']}" onmouseover="showMenu({'ctrlid':this.id,'pos':'12'})" />

EOF;
            } else {
                $return .= <<<EOF

<img
EOF;
                if ($attach['price'] && $_G['forum_attachmentdown'] && $_G['uid'] != $attach['uid']) {
                    $return .= <<<EOF
 class="attprice"
EOF;
                }
                $return .= <<<EOF
 id="aimg_{$attach['aid']}" aid="{$attach['aid']}" src="{$__STATICURL}image/common/none.gif" zoomfile="
EOF;
                if ($attach['refcheck']) {
                    $return .= <<<EOF
forum.php?mod=attachment{$is_archive}&aid={$aidencode}&noupdate=yes&nothumb=yes
EOF;
                } else {
                    $return .= <<<EOF
{$attach['url']}{$attach['attachment']}
EOF;
                }
                $return .= <<<EOF
" file="
EOF;
                if ($attach['refcheck']) {
                    $return .= <<<EOF
forum.php?mod=attachment{$is_archive}&aid={$aidencode}&noupdate=yes
EOF;
                } else {
                    $return .= <<<EOF
{$attach['url']}{$attach['attachment']}
EOF;
                }
                $return .= <<<EOF
" {$widthcode} id="aimg_{$attach['aid']}" inpost="1" alt="{$attach['imgalt']}" title="{$attach['imgalt']}" onmouseover="showMenu({'ctrlid':this.id,'pos':'12'})" />

EOF;
            }
            $return .= <<<EOF

<div class="tip tip_4 aimg_tip" id="aimg_{$attach['aid']}_menu" style="position: absolute; display: none" disautofocus="true">
<div class="tip_c xs0">
<div class="y">{$attach['dateline']} 上传</div>
<a href="forum.php?mod=attachment{$is_archive}&amp;aid={$aidencode}&amp;nothumb=yes" title="{$attach['filename']} 下载次数:{$attach['downloads']}" target="_blank"><strong>下载附件</strong> <span class="xs0">({$attach['attachsize']})</span></a>

EOF;
            if ($attach['description']) {
                $return .= <<<EOF
<br />{$attach['description']}
EOF;
            }
            if ($firstpost && $_G['fid'] && $_G['forum']['picstyle'] && ($_G['forum']['ismoderator'] || $_G['uid'] == $attach['uid'])) {
                $return .= <<<EOF

<br /><a href="forum.php?mod=ajax&amp;action=setthreadcover&amp;aid={$attach['aid']}&amp;fid={$_G['fid']}" onclick="showWindow('setcover{$attach['aid']}', this.href)">设为封面</a>

EOF;
            }
        } else {
            if ($attach['description']) {
                $return .= <<<EOF
<p>{$attach['description']}</p>
EOF;
            }
            $return .= <<<EOF

<img src="
EOF;
            if ($attach['refcheck']) {
                $return .= <<<EOF
forum.php?mod=attachment{$is_archive}&aid={$aidencode}&noupdate=yes
EOF;
            } else {
                $return .= <<<EOF
{$attach['url']}{$attach['attachment']}
EOF;
            }
            $return .= <<<EOF
" alt="{$attach['imgalt']}" title="{$attach['imgalt']}" />
<div style="display: none">

EOF;
        }
    } else {
        if ($musiccode) {
            $return .= <<<EOF

<div>{$musiccode}</div>

EOF;
        }
        $return .= <<<EOF

{$attach['attachicon']}
<span style="white-space: nowrap" id="attach_{$attach['aid']}" onmouseover="showMenu({'ctrlid':this.id,'pos':'12'})">

EOF;
        if (!$attach['price'] || $attach['payed']) {
            $return .= <<<EOF

<a href="forum.php?mod=attachment{$is_archive}&amp;aid={$aidencode}" target="_blank">{$attach['filename']}</a>

EOF;
        } else {
            $return .= <<<EOF

<a href="forum.php?mod=misc&amp;action=attachpay&amp;aid={$attach['aid']}&amp;tid={$attach['tid']}" onclick="showWindow('attachpay', this.href)">{$attach['filename']}</a>

EOF;
        }
        $return .= <<<EOF

<em class="xg1">({$attach['attachsize']}, 下载次数: {$attach['downloads']}
EOF;
        if ($attach['price']) {
            $return .= <<<EOF
, 售价: {$attach['price']} {$_G['setting']['extcredits'][$_G['setting']['creditstransextra']['1']]['unit']}{$_G['setting']['extcredits'][$_G['setting']['creditstransextra']['1']]['title']}
EOF;
        }
        $return .= <<<EOF
)</em>
</span>
<div class="tip tip_4" id="attach_{$attach['aid']}_menu" style="position: absolute; display: none" disautofocus="true">
<div class="tip_c xs0">
<div class="y">{$attach['dateline']} 上传</div>
点击文件名下载附件

EOF;
        if ($attach['description']) {
            $return .= <<<EOF
<br />{$attach['description']}
EOF;
        }
        if ($attach['readperm']) {
            $return .= <<<EOF
<br />阅读权限: {$attach['readperm']}
EOF;
        }
    }
    if ($attach['price']) {
        $return .= <<<EOF

<br />售价: {$attach['price']} {$_G['setting']['extcredits'][$_G['setting']['creditstransextra']['1']]['unit']}{$_G['setting']['extcredits'][$_G['setting']['creditstransextra']['1']]['title']}\t&nbsp;<a href="forum.php?mod=misc&amp;action=viewattachpayments&amp;aid={$attach['aid']}" onclick="showWindow('attachpay', this.href)" target="_blank">[记录]</a>

EOF;
        if (!$attach['payed']) {
            $return .= <<<EOF

&nbsp;[<a href="forum.php?mod=misc&amp;action=attachpay&amp;aid={$attach['aid']}&amp;tid={$attach['tid']}" onclick="showWindow('attachpay', this.href)" target="_blank">购买</a>]

EOF;
        }
    }
    if (!$attach['attachimg'] && $_G['getattachcredits']) {
        $return .= <<<EOF
<br />下载积分: {$_G['getattachcredits']}
EOF;
    }
    $return .= <<<EOF

</div>
<div class="tip_horn"></div>
</div>

EOF;
    if ($musiccode) {
        $return .= <<<EOF

<br />

EOF;
    }
    $return .= <<<EOF

</ignore_js_op>

EOF;
    return $return;
}
示例#12
0
function blog_post($POST, $olds = array())
{
    global $_G, $space;
    $isself = 1;
    if (!empty($olds['uid']) && $olds['uid'] != $_G['uid']) {
        $isself = 0;
        $__G = $_G;
        $_G['uid'] = $olds['uid'];
        $_G['username'] = addslashes($olds['username']);
    }
    $POST['subject'] = getstr(trim($POST['subject']), 80, 1, 1);
    $POST['subject'] = censor($POST['subject']);
    if (strlen($POST['subject']) < 1) {
        $POST['subject'] = dgmdate($_G['timestamp'], 'Y-m-d');
    }
    $POST['friend'] = intval($POST['friend']);
    $POST['target_ids'] = '';
    if ($POST['friend'] == 2) {
        $uids = array();
        $names = empty($_POST['target_names']) ? array() : explode(',', preg_replace("/(\\s+)/s", ',', $_POST['target_names']));
        if ($names) {
            $query = DB::query("SELECT uid FROM " . DB::table('common_member') . " WHERE username IN (" . dimplode($names) . ")");
            while ($value = DB::fetch($query)) {
                $uids[] = $value['uid'];
            }
        }
        if (empty($uids)) {
            $POST['friend'] = 3;
        } else {
            $POST['target_ids'] = implode(',', $uids);
        }
    } elseif ($POST['friend'] == 4) {
        $POST['password'] = trim($POST['password']);
        if ($POST['password'] == '') {
            $POST['friend'] = 0;
        }
    }
    if ($POST['friend'] !== 2) {
        $POST['target_ids'] = '';
    }
    if ($POST['friend'] !== 4) {
        $POST['password'] == '';
    }
    $POST['tag'] = dhtmlspecialchars(trim($POST['tag']));
    $POST['tag'] = getstr($POST['tag'], 500, 1, 1);
    $POST['tag'] = censor($POST['tag']);
    if ($_G['mobile']) {
        $POST['message'] = getstr($POST['message'], 0, 1, 0, 1);
        $POST['message'] = censor($POST['message']);
    } else {
        $POST['message'] = checkhtml($POST['message']);
        $POST['message'] = getstr($POST['message'], 0, 1, 0, 0, 1);
        $POST['message'] = censor($POST['message']);
        $POST['message'] = preg_replace(array("/\\<div\\>\\<\\/div\\>/i", "/\\<a\\s+href\\=\"([^\\>]+?)\"\\>/i"), array('', '<a href="\\1" target="_blank">'), $POST['message']);
    }
    $message = $POST['message'];
    if (censormod($message) || censormod($POST['subject']) || $_G['group']['allowblogmod']) {
        $blog_status = 1;
    } else {
        $blog_status = 0;
    }
    if (empty($olds['classid']) || $POST['classid'] != $olds['classid']) {
        if (!empty($POST['classid']) && substr($POST['classid'], 0, 4) == 'new:') {
            $classname = dhtmlspecialchars(trim(substr($POST['classid'], 4)));
            $classname = getstr($classname, 0, 1, 1);
            $classname = censor($classname);
            if (empty($classname)) {
                $classid = 0;
            } else {
                $classid = DB::result(DB::query("SELECT classid FROM " . DB::table('home_class') . " WHERE uid='{$_G['uid']}' AND classname='{$classname}'"));
                if (empty($classid)) {
                    $setarr = array('classname' => $classname, 'uid' => $_G['uid'], 'dateline' => $_G['timestamp']);
                    $classid = DB::insert('home_class', $setarr, 1);
                }
            }
        } else {
            $classid = intval($POST['classid']);
        }
    } else {
        $classid = $olds['classid'];
    }
    if ($classid && empty($classname)) {
        $classname = DB::result(DB::query("SELECT classname FROM " . DB::table('home_class') . " WHERE classid='{$classid}' AND uid='{$_G['uid']}'"));
        if (empty($classname)) {
            $classid = 0;
        }
    }
    $blogarr = array('subject' => $POST['subject'], 'classid' => $classid, 'friend' => $POST['friend'], 'password' => $POST['password'], 'noreply' => empty($POST['noreply']) ? 0 : 1, 'catid' => intval($POST['catid']), 'status' => $blog_status);
    $titlepic = '';
    $uploads = array();
    if (!empty($POST['picids'])) {
        $picids = array_keys($POST['picids']);
        $query = DB::query("SELECT * FROM " . DB::table('home_pic') . " WHERE picid IN (" . dimplode($picids) . ") AND uid='{$_G['uid']}'");
        while ($value = DB::fetch($query)) {
            if (empty($titlepic) && $value['thumb']) {
                $titlepic = getimgthumbname($value['filepath']);
                $blogarr['picflag'] = $value['remote'] ? 2 : 1;
            }
            $uploads[$POST['picids'][$value['picid']]] = $value;
        }
        if (empty($titlepic) && $value) {
            $titlepic = $value['filepath'];
            $blogarr['picflag'] = $value['remote'] ? 2 : 1;
        }
    }
    if ($uploads) {
        preg_match_all("/\\[imgid\\=(\\d+)\\]/i", $message, $mathes);
        if (!empty($mathes[1])) {
            $searchs = $replaces = array();
            foreach ($mathes[1] as $key => $value) {
                if (!empty($uploads[$value])) {
                    $picurl = pic_get($uploads[$value]['filepath'], 'album', $uploads[$value]['thumb'], $uploads[$value]['remote'], 0);
                    $searchs[] = "[imgid={$value}]";
                    $replaces[] = "<img src=\"{$picurl}\">";
                    unset($uploads[$value]);
                }
            }
            if ($searchs) {
                $message = str_replace($searchs, $replaces, $message);
            }
        }
        foreach ($uploads as $value) {
            $picurl = pic_get($value['filepath'], 'album', $value['thumb'], $value['remote'], 0);
            $message .= "<div class=\"uchome-message-pic\"><img src=\"{$picurl}\"><p>{$value['title']}</p></div>";
        }
    }
    $ckmessage = preg_replace("/(\\<div\\>|\\<\\/div\\>|\\s|\\&nbsp\\;|\\<br\\>|\\<p\\>|\\<\\/p\\>)+/is", '', $message);
    if (empty($ckmessage)) {
        return false;
    }
    $message = addslashes($message);
    if (checkperm('manageblog')) {
        $blogarr['hot'] = intval($POST['hot']);
    }
    if ($olds['blogid']) {
        if ($blogarr['catid'] != $olds['catid']) {
            if ($olds['catid']) {
                DB::query("UPDATE " . DB::table('home_blog_category') . " SET num=num-1 WHERE catid='{$olds['catid']}' AND num>0");
            }
            if ($blogarr['catid']) {
                DB::query("UPDATE " . DB::table('home_blog_category') . " SET num=num+1 WHERE catid='{$blogarr['catid']}'");
            }
        }
        $blogid = $olds['blogid'];
        DB::update('home_blog', $blogarr, array('blogid' => $blogid));
        $fuids = array();
        $blogarr['uid'] = $olds['uid'];
        $blogarr['username'] = $olds['username'];
    } else {
        if ($blogarr['catid']) {
            DB::query("UPDATE " . DB::table('home_blog_category') . " SET num=num+1 WHERE catid='{$blogarr['catid']}'");
        }
        $blogarr['uid'] = $_G['uid'];
        $blogarr['username'] = $_G['username'];
        $blogarr['dateline'] = empty($POST['dateline']) ? $_G['timestamp'] : $POST['dateline'];
        $blogid = DB::insert('home_blog', $blogarr, 1);
        DB::update('common_member_status', array('lastpost' => $_G['timestamp']), array('uid' => $_G['uid']));
        DB::update('common_member_field_home', array('recentnote' => $POST['subject']), array('uid' => $_G['uid']));
    }
    $blogarr['blogid'] = $blogid;
    $POST['tag'] = $olds ? modblogtag($POST['tag'], $blogid) : addblogtag($POST['tag'], $blogid);
    $fieldarr = array('message' => $message, 'postip' => $_G['clientip'], 'target_ids' => $POST['target_ids'], 'tag' => $POST['tag']);
    if (!empty($titlepic)) {
        $fieldarr['pic'] = $titlepic;
    }
    if ($olds) {
        DB::update('home_blogfield', $fieldarr, array('blogid' => $blogid));
    } else {
        $fieldarr['blogid'] = $blogid;
        $fieldarr['uid'] = $blogarr['uid'];
        DB::insert('home_blogfield', $fieldarr);
    }
    if ($isself && !$olds && $blog_status == 0) {
        updatecreditbyaction('publishblog', 0, array('blogs' => 1));
        include_once libfile('function/stat');
        updatestat('blog');
    }
    if ($POST['makefeed'] && $blog_status == 0) {
        include_once libfile('function/feed');
        feed_publish($blogid, 'blogid', $olds ? 0 : 1);
    }
    if (!empty($__G)) {
        $_G = $__G;
    }
    if ($blog_status == 1) {
        updatemoderate('blogid', $blogid);
        manage_addnotify('verifyblog');
    }
    return $blogarr;
}
/**
 *
 * 在 DISCUZ_ROOT/source/function_spacecp.php 基础上做了改动
 *
 * @author HanPengyu
 * @copyright 2012-2014 Appbyme
 */
function mobcent_pic_save($FILE, $albumid, $title, $iswatermark = true, $catid = 0)
{
    global $_G, $space;
    if ($albumid < 0) {
        $albumid = 0;
    }
    $allowpictype = array('jpg', 'jpeg', 'gif', 'png');
    $upload = new discuz_upload();
    $upload->init($FILE, 'album');
    if ($upload->error()) {
        return lang('spacecp', 'lack_of_access_to_upload_file_size');
    }
    if (!$upload->attach['isimage']) {
        return lang('spacecp', 'only_allows_upload_file_types');
    }
    $oldgid = $_G['groupid'];
    if (empty($space)) {
        $_G['member'] = $space = getuserbyuid($_G['uid']);
        $_G['username'] = $space['username'];
        $_G['groupid'] = $space['groupid'];
    }
    $_G['member'] = $space;
    loadcache('usergroup_' . $space['groupid'], $oldgid != $_G['groupid'] ? true : false);
    $_G['group'] = $_G['cache']['usergroup_' . $space['groupid']];
    if (!checkperm('allowupload')) {
        return lang('spacecp', 'not_allow_upload');
    }
    if (!cknewuser(1)) {
        if ($_G['setting']['newbiespan'] && $_G['timestamp'] - $_G['member']['regdate'] < $_G['setting']['newbiespan'] * 60) {
            return lang('message', 'no_privilege_newbiespan', array('newbiespan' => $_G['setting']['newbiespan']));
        }
        if ($_G['setting']['need_avatar'] && empty($_G['member']['avatarstatus'])) {
            return lang('message', 'no_privilege_avatar');
        }
        if ($_G['setting']['need_email'] && empty($_G['member']['emailstatus'])) {
            return lang('message', 'no_privilege_email');
        }
        if ($_G['setting']['need_friendnum']) {
            space_merge($_G['member'], 'count');
            if ($_G['member']['friends'] < $_G['setting']['need_friendnum']) {
                return lang('message', 'no_privilege_friendnum', array('friendnum' => $_G['setting']['need_friendnum']));
            }
        }
    }
    if ($_G['group']['maximagesize'] && $upload->attach['size'] > $_G['group']['maximagesize']) {
        return lang('spacecp', 'files_can_not_exceed_size', array('extend' => $upload->attach['ext'], 'size' => sizecount($_G['group']['maximagesize'])));
    }
    $maxspacesize = checkperm('maxspacesize');
    if ($maxspacesize) {
        space_merge($space, 'count');
        space_merge($space, 'field_home');
        if ($space['attachsize'] + $upload->attach['size'] > $maxspacesize + $space['addsize'] * 1024 * 1024) {
            return lang('spacecp', 'inadequate_capacity_space');
        }
    }
    $showtip = true;
    $albumfriend = 0;
    if ($albumid) {
        $catid = intval($catid);
        $albumid = album_creat_by_id($albumid, $catid);
    } else {
        $albumid = 0;
        $showtip = false;
    }
    $upload->save();
    if ($upload->error()) {
        return lang('spacecp', 'mobile_picture_temporary_failure');
    }
    if (!$upload->attach['imageinfo'] || !in_array($upload->attach['imageinfo']['2'], array(1, 2, 3, 6))) {
        @unlink($upload->attach['target']);
        return lang('spacecp', 'only_allows_upload_file_types');
    }
    $new_name = $upload->attach['target'];
    require_once libfile('class/image');
    $image = new image();
    $result = $image->Thumb($new_name, '', 140, 140, 1);
    $thumb = empty($result) ? 0 : 1;
    if ($_G['setting']['maxthumbwidth'] && $_G['setting']['maxthumbheight']) {
        if ($_G['setting']['maxthumbwidth'] < 300) {
            $_G['setting']['maxthumbwidth'] = 300;
        }
        if ($_G['setting']['maxthumbheight'] < 300) {
            $_G['setting']['maxthumbheight'] = 300;
        }
        $image->Thumb($new_name, '', $_G['setting']['maxthumbwidth'], $_G['setting']['maxthumbheight'], 1, 1);
    }
    // 支持客户端上传相册水印 Author:HanPengyu Data:2014/12/04
    Yii::import('application.components.discuz.source.class.class_image', true);
    $image = new Mobcent_Image();
    $image->makeWatermark($new_name, '', 'album');
    // if ($iswatermark) {
    //     $image->Watermark($new_name, '', 'album');
    // }
    $pic_remote = 0;
    $album_picflag = 1;
    if (getglobal('setting/ftp/on')) {
        $ftpresult_thumb = 0;
        $ftpresult = ftpcmd('upload', 'album/' . $upload->attach['attachment']);
        if ($ftpresult) {
            @unlink($_G['setting']['attachdir'] . 'album/' . $upload->attach['attachment']);
            if ($thumb) {
                $thumbpath = getimgthumbname($upload->attach['attachment']);
                ftpcmd('upload', 'album/' . $thumbpath);
                @unlink($_G['setting']['attachdir'] . 'album/' . $thumbpath);
            }
            $pic_remote = 1;
            $album_picflag = 2;
        } else {
            if (getglobal('setting/ftp/mirror')) {
                @unlink($upload->attach['target']);
                @unlink(getimgthumbname($upload->attach['target']));
                return lang('spacecp', 'ftp_upload_file_size');
            }
        }
    }
    $title = getstr($title, 200);
    $title = censor($title);
    if (censormod($title) || $_G['group']['allowuploadmod']) {
        $pic_status = 1;
    } else {
        $pic_status = 0;
    }
    $setarr = array('albumid' => $albumid, 'uid' => $_G['uid'], 'username' => $_G['username'], 'dateline' => $_G['timestamp'], 'filename' => addslashes($upload->attach['name']), 'postip' => $_G['clientip'], 'title' => $title, 'type' => addslashes($upload->attach['ext']), 'size' => $upload->attach['size'], 'filepath' => $upload->attach['attachment'], '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' => $upload->attach['size']));
    include_once libfile('function/stat');
    if ($pic_status) {
        updatemoderate('picid', $setarr['picid']);
    }
    updatestat('pic');
    return $setarr;
}
function attachinpost($attach, $firstpost = 0)
{
    global $_G;
    $attach['refcheck'] = !$attach['remote'] && $_G['setting']['attachrefcheck'] || $attach['remote'] && ($_G['setting']['ftp']['hideurl'] || $attach['isimage'] && $_G['setting']['attachimgpost'] && strtolower(substr($_G['setting']['ftp']['attachurl'], 0, 3)) == 'ftp');
    $aidencode = packaids($attach);
    $widthcode = attachwidth($attach['width']);
    $is_archive = $_G['forum_thread']['is_archived'] ? '&fid=' . $_G['fid'] . '&archiveid=' . $_G[forum_thread][archiveid] : '';
    $attachthumb = getimgthumbname($attach['attachment']);
    $replayinfo_g = get_replayinfo($attach['aid']);
    $time_len = get_game_lentime($replayinfo_g['length']);
    $data = get_replayplayerinfo($attach['aid']);
    //echo $attach['aid'];
    //print_r($attach);
    $return = <<<EOF

<ignore_js_op>
<style type="text/css" id="replay_css">
.wa .wa_text {
 font-family: tahoma;
 font-size: 42px;
 font-weight:bold;
 position: absolute;
margin: 60px 0px 0px 50px;
}
.page
{
background: #E5ECF4;
color: #000000;
}
.tborder
{
background: #D1D1E1;
color: #000000;
border: 1px solid #0B198C;
}
.tcat
{
background: #869BBF url(../../images/gradients/gradient_tcat.gif) repeat-x top left;
color: #FFFFFF;
font: bold 10pt verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif;
}
.tcat a:link, .tcat_alink
{
color: #ffffff;
text-decoration: none;
}
.tcat a:visited, .tcat_avisited
{
color: #ffffff;
text-decoration: none;
}
.tcat a:hover, .tcat a:active, .tcat_ahover
{
color: #FFFF66;
text-decoration: underline;
}
.thead
{
background: #5C7099 url(../../images/gradients/gradient_thead.gif) repeat-x top left;
color: #FFFFFF;
font: bold 12px tahoma, verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif;
}
.thead a:link, .thead_alink
{
color: #FFFFFF;
}
.thead a:visited, .thead_avisited
{
color: #FFFFFF;
}
.thead a:hover, .thead a:active, .thead_ahover
{
color: #FFFF00;
}
.tfoot
{
background: #3E5C92;
color: #E0E0F6;
}
.tfoot a:link, .tfoot_alink
{
color: #E0E0F6;
}
.tfoot a:visited, .tfoot_avisited
{
color: #E0E0F6;
}
.tfoot a:hover, .tfoot a:active, .tfoot_ahover
{
color: #FFFF66;
}
.alt1, .alt1Active
{
background: #F5F5FF;
color: #000000;
}
.alt2, .alt2Active
{
background: #E5ECF4;
color: #000000;
}
.inlinemod
{
background: #FFFFCC;
color: #000000;
}
.wysiwyg
{
background: #F5F5FF;
color: #000000;
font: 10pt verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif;
margin: 5px 10px 10px 10px;
padding: 0px;
}
.wysiwyg a:link, .wysiwyg_alink
{
color: #22229C;
}
.wysiwyg a:visited, .wysiwyg_avisited
{
color: #22229C;
}
.wysiwyg a:hover, .wysiwyg a:active, .wysiwyg_ahover
{
color: #FF4400;
}
textarea, .bginput
{
font: 10pt verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif;
}
.bginput option, .bginput optgroup
{
font-size: 10pt;
font-family: verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif;
}
.button
{
font: 12px verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif;
}

option, optgroup
{
font-size: 12px;
font-family: verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif;
}
.smallfont
{
font: 12px verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif;
}
.time
{
color: #666686;
}
.navbar
{
font: 12px verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif;
}
.highlight
{
color: #FF0000;
font-weight: bold;
}
.fjsel
{
background: #3E5C92;
color: #E0E0F6;
}
.fjdpth0
{
background: #F7F7F7;
color: #000000;
}
.panel
{
background: #E4E7F5 url(../../images/gradients/gradient_panel.gif) repeat-x top left;
color: #000000;
padding: 10px;
border: 2px outset;
}
.panelsurround
{
background: #D1D4E0 url(../../images/gradients/gradient_panelsurround.gif) repeat-x top left;
color: #000000;
}
legend
{
color: #22229C;
font: 12px tahoma, verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif;
}
.vbmenu_control
{
background: #738FBF;
color: #FFFFFF;
font: bold 12px tahoma, verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif;
padding: 3px 6px 3px 6px;
white-space: nowrap;
}
.vbmenu_control a:link, .vbmenu_control_alink
{
color: #FFFFFF;
text-decoration: none;
}
.vbmenu_control a:visited, .vbmenu_control_avisited
{
color: #FFFFFF;
text-decoration: none;
}
.vbmenu_control a:hover, .vbmenu_control a:active, .vbmenu_control_ahover
{
color: #FFFFFF;
text-decoration: underline;
}
.vbmenu_popup

{
background: #FFFFFF;
color: #000000;
border: 1px solid #0B198C;
}
.vbmenu_option
{
background: #BBC7CE;
color: #000000;
font: 12px verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif;
white-space: nowrap;
cursor: pointer;
}
.vbmenu_option a:link, .vbmenu_option_alink
{
color: #22229C;
text-decoration: none;
}
.vbmenu_option a:visited, .vbmenu_option_avisited
{
color: #22229C;
text-decoration: none;
}
.vbmenu_option a:hover, .vbmenu_option a:active, .vbmenu_option_ahover
{
color: #FFFFFF;
text-decoration: none;
}
.vbmenu_hilite
{
background: #8A949E;
color: #FFFFFF;
font: 12px verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif;
white-space: nowrap;
cursor: pointer;
}
.vbmenu_hilite a:link, .vbmenu_hilite_alink
{
color: #FFFFFF;
text-decoration: none;
}
.vbmenu_hilite a:visited, .vbmenu_hilite_avisited
{
color: #FFFFFF;
text-decoration: none;
}
.vbmenu_hilite a:hover, .vbmenu_hilite a:active, .vbmenu_hilite_ahover
{
color: #FFFFFF;
text-decoration: none;
}
/* ***** styling for 'big' usernames on postbit etc. ***** */
.bigusername { font-size: 14pt; }

/* ***** small padding on 'thead' elements ***** */
td.thead, th.thead, div.thead { padding: 4px; }

/* ***** basic styles for multi-page nav elements */
.pagenav a { text-decoration: none; }
.pagenav td { padding: 2px 4px 2px 4px; }

/* ***** de-emphasized text */
.shade, a.shade:link, a.shade:visited { color: #777777; text-decoration: none; }
a.shade:active, a.shade:hover { color: #FF4400; text-decoration: underline; }
.tcat .shade, .thead .shade, .tfoot .shade { color: #DDDDDD; }

/* ***** define margin and font-size for elements inside panels ***** */
.fieldset { margin-bottom: 6px; }
.fieldset, .fieldset td, .fieldset p, .fieldset li { font-size: 12px; }

.copyright { 
display: none; 
}
@charset "utf-8";

/* clear around */
.clearer {
clear:both;
}
.header {
margin-left:-10px;
margin-right:-10px;
width:600px;
height:35px;
color:#000033;
/*border-bottom:solid 1px #696256;*/
}
.header .howto_button {
height:25px;
width:25px;
position: absolute;
z-index: 1;
margin: 2px 0px 0px 560px;
}
.header .gameicon {
height:25px;
width:25px;
position: absolute;
z-index: 1;
margin: 5px 0px 0px 12px;
}

.section {
border:1px solid #8d7e64;
/*\tbackground-color: #2f3237;/*#0c1e34;/*#51493c;*/
/*\tcolor:#fff;*/
background-image:url(../../images/replays/replay_details.jpg);
color:#000033;
float:none;
width:764px;
padding:10px;
text-align:left;
position:relative;
}
/* Replay Details */
#replay_details {
padding-top:0px;
padding-bottom:10;
width:580px;
}
#replay_details .column {
float:left;
width:136px;
padding-top:12px;
}
#replay_details .map a {
display:block;
}
#replay_details .map img {
margin-bottom:5px;
width:120px;
height:120px;
}
#replay_details .columnplayer {
float:left;
width:300px;
padding-top:12px;
}
#replay_details .versus {
/*\tbackground-color:#6699FF;/*#091626;*/
color:#FF0000;
text-align:center;
font-size:9pt;
/*\tfont-style:italic;*/
font-weight:bold;
height:16px;
border-bottom:dotted 1px #696256;
padding:2px 0px;
}

#replay_details .download_button {
height:25px;
width:126px;
margin:8px 0px 0px 3px;
padding:0px;
overflow:hidden;
}

#replay_details .commend_button {
height:65px;
width:98px;
margin:60px 12px 0px;
padding:0px;
overflow:hidden;
position:absolute;
bottom:30px;
right:0px;
}
#replay_details .commend_amount {
/*\tfont-family:Tohoma, Arial, Verdana, Helvetica, sans-serif;*/
font-size:36px;
line-height:10px;
padding: 16px 0px 0px 0px;
}
#replay_details .commend_name {
/*\tfont-family: Tohoma, Arial, Verdana, Helvetica, sans-serif;*/
font-size:14px;
line-height:6px;
padding: 0px 0px 2px 0px;
}
.other_details {
float:left;
list-style-type:none;
font-size:9pt;
/*\tfont-family: Tohoma, Arial, Verdana, Helvetica, sans-serif;*/
color:#8b837a;
margin:5px 0 0 5px;
padding:0;
}
.other_details li {
font-family:Tohoma, Arial, Verdana, Helvetica, sans-serif;
font-size:9pt;
}
.other_details li h5 {
font-size:9pt;
color: #000033;/*#fff;*/
display:inline;
margin-right:3px;
font-weight:bold;
}
#replay_details .footer a:hover {
color: #ff00ff;
}
#replay_details .map {
/*background-color:#282a2e;*//*#091626;*/
/*border:solid 1px #696256;*/
color:#8b837a;
text-align:center;
width:120px;
padding:5px;
}
.teams {
float:left;
width:250px;
margin-left:25px;
         padding-top:15px;
}
.team_players {
list-style-type:none;
vertical-align:middle;
padding:0px;
margin:0px;
}
.team_players li {
font-size:9pt;
border-bottom:dotted 1px #696256;
text-align:left;
padding-left:0px;
height:29px;
margin-top:4px;
         color:#000044
}
.team_players img {
vertical-align:middle;
width:31px;
height:25px;
padding: 1px;
border: #696256 1px solid;
}
.team_players span {
border:solid 0px #666666;
border-left-width:3px;
margin-left:2px;
padding-left: 2px;
}

#features_awards {
float: left;
z-index: 1;
}
.awards, .features {
height: 50px;
width:180px;
margin-left:12px;
margin-right:13px;
padding-left:20px;
}
.awards img, .features img {
padding:1px;
}
/*These footer classes are used when a box needs a footer, eg the replay details box*/
.footer {
/*background-color:#282a2e;*//*#091626;*/
margin-left:-10px;
margin-right:-10px;
margin-top:15px;
padding-top:2px;
width:580px;
height:18px;
color:#000033;
text-align:center;
filter: progid:dximagetransform.microsoft.gradient(gradienttype=1, startcolorstr=#c3daf5, endcolorstr=#ffffff);
}
.footer a, .footer a:active, .footer a:visited, .footer a:hover {
font-family: Tohoma, Arial, Verdana, Helvetica, sans-serif;
font-weight:normal;
font-size:9pt;
margin-right:5px;
margin-left:10px;
color:#000033;
}
.footer .datetime {
float:left;
padding-left:10px;
}
.footer .version {
float:right;
padding-right:10px;
}
.frame {
font-family: Tohoma, Arial, Verdana, Helvetica, sans-serif;
font-size: 9pt;
width:680px;
margin-bottom:10px;
margin-left:3%;
margin-right:3%;
}
.frame .frametop {
background-image:url(../../frame_t.gif);
height:12px;
font-size:0px;
}
.frame .framebody {
padding:0px 10px;
border:solid 1px #DEDFDE;
border-top-width:0px;
border-bottom-width:0px;
}
.frame .framebot {
clear:both;
background-image:url(../../frame_b.gif);
height:12px;
font-size:0px;
}
/* css button */
.commend_button_mouseout, .commend_button_mouseover, .commend_button_mousedown, .commend_button_mouseup, .download_button_mouseout, .download_button_mouseover, .download_button_mousedown, .download_button_mouseup, .howto_button_mouseout, .howto_button_mouseover, .howto_button_mousedown, .howto_button_mouseup, .wa_button_mouseout, .wa_button_mouseover, .wa_button_mousedown, .wa_button_mouseup  {
cursor:pointer;
color: #000033;
font-size: 12px;
padding-top: 0px;
padding-left: 0px;
padding-right: 0px;
height:65px;
width: 98px;
}
.download_button_mouseout, .download_button_mouseover, .download_button_mousedown, .download_button_mouseup {
height:25px;
width:126px;
font-size:14px;
/*\tfont-weight:bold;*/
text-align:center;
padding-top:1px;
}
.howto_button_mouseout, .howto_button_mouseover, .howto_button_mousedown, .howto_button_mouseup {
height:30px;
width:30px;
font-size:22px;
font-weight:bold;
text-align:center;
}

.wa_button_mouseout, .wa_button_mouseover, .wa_button_mousedown, .wa_button_mouseup {
     height:20px;
width: 150px;
font-size:22px;
font-weight:bold;
text-align:center;
}

.commend_button_mouseout, .commend_button_mouseover, .commend_button_mouseup, .download_button_mouseout, .download_button_mouseover, .download_button_mouseup, .howto_button_mouseout, .howto_button_mouseover, .howto_button_mouseup, .wa_button_mouseout, .wa_button_mouseover, .wa_button_mouseup {
border-left: #ffffff 0px solid;
border-right: #ffffff 0px solid;
border-top: #ffffff 0px solid;
border-bottom: #ffffff 0px solid;
}
.commend_button_mouseout, .commend_button_mouseup, .download_button_mouseout, .download_button_mouseup, .howto_button_mouseout, .howto_button_mouseup, .wa_button_mouseout, .wa_button_mouseup  {
filter: progid:dximagetransform.microsoft.gradient(gradienttype=0, startcolorstr=#ffffff, endcolorstr=#c3daf5);
}
.commend_button_mouseup, .download_button_mouseup, .howto_button_mouseup, .wa_button_mouseup {
color: blue;
}
.commend_button_mouseover, .download_button_mouseover, .howto_button_mouseover, .wa_button_mouseover {
color: blue;
filter: progid:dximagetransform.microsoft.gradient(gradienttype=0, startcolorstr=#ffffff, endcolorstr=#d7e7fa);
}
.commend_button_mousedown, .download_button_mousedown, .howto_button_mousedown, .wa_button_mousedown {
/*border-left: #ffe400 1px solid;
border-right: #ffe400 1px solid;
border-top: #ffe400 1px solid;
border-bottom: #ffe400 1px solid;*/
color: red;
filter: progid:dximagetransform.microsoft.gradient(gradienttype=0, startcolorstr=#ffffff, endcolorstr=#c3daf5);
}/* CSS Document */

ul{
list-style:none;
margin: 0px;
}
</style>

EOF;
    if ($attach['attachimg'] && $_G['setting']['showimages'] && (!$attach['price'] || $attach['payed']) && ($_G['group']['allowgetimage'] || $_G['uid'] == $attach['uid'])) {
        if (!IS_ROBOT) {
            $return .= <<<EOF

<img src="
EOF;
            if ($attach['refcheck']) {
                $return .= <<<EOF
forum.php?mod=attachment{$is_archive}&aid={$aidencode}&noupdate=yes
EOF;
            } else {
                $return .= <<<EOF
{$attach['url']}{$attach['attachment']}
EOF;
            }
            $return .= <<<EOF
" alt="{$attach['imgalt']}" title="{$attach['imgalt']}" />\t

EOF;
        } else {
            $return .= <<<EOF

<img src="
EOF;
            if ($attach['refcheck']) {
                $return .= <<<EOF
forum.php?mod=attachment{$is_archive}&aid={$aidencode}&noupdate=yes
EOF;
            } else {
                $return .= <<<EOF
{$attach['url']}{$attach['attachment']}
EOF;
            }
            $return .= <<<EOF
" alt="{$attach['imgalt']}" title="{$attach['imgalt']}" />

EOF;
        }
    } else {
        if (!$attach['price'] || $attach['payed']) {
            $return .= <<<EOF





<div >
<div class="frametop"></div>
<div class="framebody">

<div class="section" id="replay_details">
<div class="header" >
<div class="gameicon" ><img class="thisicon" src="./static/image/replays/{$replayinfo_g['gametype']}.gif" width="25" height="25"/></div>
<div class="howto_button">
<button class="howto_button_mouseout" onmouseover="this.className='howto_button_mouseover'" onmouseout="this.className='howto_button_mouseout'" onmousedown="this.className='howto_button_mousedown'" onmouseup="this.className='howto_button_mouseup'" onclick="javascript:window.open('http://www.gametotal.org/forum/showthread.php?t=21549');" title="怎么观看游戏录像?"><img class="inlineimg" src="./static/image/replays/{$replayinfo_g['gametype']}.gif" alt="ra3replay" title="怎么观看游戏录像?" width="25" height="25" border="0" style="vertical-align:baseline" /></button>\t\t\t\t</div>
</div>
<div class="column">
<div class="map"><img title="{$replayinfo_g['mapname']}" alt="{$replayinfo_g['mapname']}" src="{$data['mapimage']}" /><br />{$replayinfo_g['mapdispname']}</div>
<div class="download_button">
<a href="forum.php?mod=attachment{$is_archive}&amp;aid={$aidencode}" >
<img src="./static/image/replays/download_replay.jpg" border=0>
</a>
</div>
<ul class="other_details">
<li>
下载次数:{$attach['downloads']}
</li>
<li>
录像大小:{$attach['attachsize']}
</li> 
</ul>

</div>
<div class="teams">{$data['player']}</div> \t\t\t
<div class="wa">\t
<div class="wa_text"></div>
</div>\t\t\t
<div id="features_awards"></div>
<div class="clearer"></div>
<div class="footer">
<span class="datetime">录像时间:[<strong>{$replayinfo_g['time']}</strong> <strong>|</strong> <strong>{$time_len}</strong>]</span>
<span class="version">录像版本:[<strong>{$replayinfo_g['version']}</strong>]</span>
</div>
</div>
</div>
<div class="framebot"></div>
</div>


EOF;
        } else {
            $return .= <<<EOF

<!--a href="forum.php?mod=misc&amp;action=attachpay&amp;aid={$attach['aid']}&amp;tid={$attach['tid']}" onclick="showWindow('attachpay', this.href)">{$attach['filename']}</a-->

EOF;
        }
    }
    $return .= <<<EOF


</ignore_js_op>

EOF;
    return $return;
}
示例#15
0
function blog_post($POST, $olds=array()) {
	global $_G, $space;

	$isself = 1;
	if(!empty($olds['uid']) && $olds['uid'] != $_G['uid']) {
		$isself = 0;
		$__G = $_G;
		$_G['uid'] = $olds['uid'];
		$_G['username'] = addslashes($olds['username']);
	}

	$POST['subject'] = getstr(trim($POST['subject']), 80);
	$POST['subject'] = censor($POST['subject']);
	if(strlen($POST['subject'])<1) $POST['subject'] = dgmdate($_G['timestamp'], 'Y-m-d');
	$POST['friend'] = intval($POST['friend']);

	$POST['target_ids'] = '';
	if($POST['friend'] == 2) {
		$uids = array();
		$names = empty($_POST['target_names'])?array():explode(',', preg_replace("/(\s+)/s", ',', $_POST['target_names']));
		if($names) {
			$uids = C::t('common_member')->fetch_all_uid_by_username($names);
		}
		if(empty($uids)) {
			$POST['friend'] = 3;
		} else {
			$POST['target_ids'] = implode(',', $uids);
		}
	} elseif($POST['friend'] == 4) {
		$POST['password'] = trim($POST['password']);
		if($POST['password'] == '') $POST['friend'] = 0;
	}
	if($POST['friend'] !== 2) {
		$POST['target_ids'] = '';
	}
	if($POST['friend'] !== 4) {
		$POST['password'] == '';
	}

	$POST['tag'] = dhtmlspecialchars(trim($POST['tag']));
	$POST['tag'] = getstr($POST['tag'], 500);
	$POST['tag'] = censor($POST['tag']);

	$POST['message'] = checkhtml($POST['message']);
	if($_G['mobile']) {
		$POST['message'] = getstr($POST['message'], 0, 0, 0, 1);
		$POST['message'] = censor($POST['message']);
	} else {
		$POST['message'] = getstr($POST['message'], 0, 0, 0, 0, 1);
		$POST['message'] = censor($POST['message']);
		$POST['message'] = preg_replace(array(
			"/\<div\>\<\/div\>/i",
			"/\<a\s+href\=\"([^\>]+?)\"\>/i"
		), array(
			'',
			'<a href="\\1" target="_blank">'
		), $POST['message']);
	}
	$message = $POST['message'];
	if(censormod($message) || censormod($POST['subject']) || $_G['group']['allowblogmod']) {
		$blog_status = 1;
	} else {
		$blog_status = 0;
	}

	if(empty($olds['classid']) || $POST['classid'] != $olds['classid']) {
		if(!empty($POST['classid']) && substr($POST['classid'], 0, 4) == 'new:') {
			$classname = dhtmlspecialchars(trim(substr($POST['classid'], 4)));
			$classname = getstr($classname);
			$classname = censor($classname);
			if(empty($classname)) {
				$classid = 0;
			} else {
				$classid = C::t('home_class')->fetch_classid_by_uid_classname($_G['uid'], $classname);
				if(empty($classid)) {
					$setarr = array(
						'classname' => $classname,
						'uid' => $_G['uid'],
						'dateline' => $_G['timestamp']
					);
					$classid = C::t('home_class')->insert($setarr, true);
				}
			}
		} else {
			$classid = intval($POST['classid']);

		}
	} else {
		$classid = $olds['classid'];
	}
	if($classid && empty($classname)) {
		$query = C::t('home_class')->fetch($classid);
		$classname = ($query['uid'] == $_G['uid']) ? $query['classname'] : '';
		if(empty($classname)) $classid = 0;
	}

	$blogarr = array(
		'subject' => $POST['subject'],
		'classid' => $classid,
		'friend' => $POST['friend'],
		'password' => $POST['password'],
		'noreply' => empty($POST['noreply'])?0:1,
		'catid' => intval($POST['catid']),
		'status' => $blog_status,
	);

	$titlepic = '';

	$uploads = array();
	if(!empty($POST['picids'])) {
		$picids = array_keys($POST['picids']);
		$query = C::t('home_pic')->fetch_all_by_uid($_G['uid'], 0, 0, $picids);
		foreach($query as $value) {
			if(empty($titlepic) && $value['thumb']) {
				$titlepic = getimgthumbname($value['filepath']);
				$blogarr['picflag'] = $value['remote']?2:1;
			}
			$picurl = pic_get($value['filepath'], 'album', $value['thumb'], $value['remote'], 0);
			$uploads[md5($picurl)] = $value;
		}
		if(empty($titlepic) && $value) {
			$titlepic = $value['filepath'];
			$blogarr['picflag'] = $value['remote']?2:1;
		}
	}

	if($uploads) {
		$albumid = 0;
		if($POST['savealbumid'] < 0 && !empty($POST['newalbum'])) {
			$albumname = addslashes(dhtmlspecialchars(trim($POST['newalbum'])));
			if(empty($albumname)) $albumname = dgmdate($_G['timestamp'],'Ymd');
			$albumarr = array('albumname' => $albumname);
			$albumid = album_creat($albumarr);
		} else {
			$albumid = $POST['savealbumid'] < 0 ? 0 : intval($POST['savealbumid']);
		}
		if($albumid) {
			C::t('home_pic')->update_for_uid($_G['uid'], $picids, array('albumid' => $albumid));
			album_update_pic($albumid);
		}
		preg_match_all("/\s*\<img src=\"(.+?)\".*?\>\s*/is", $message, $mathes);
		if(!empty($mathes[1])) {
			foreach ($mathes[1] as $key => $value) {
				$urlmd5 = md5($value);
				if(!empty($uploads[$urlmd5])) {
					unset($uploads[$urlmd5]);
				}
			}
		}
		foreach ($uploads as $value) {
			$picurl = pic_get($value['filepath'], 'album', $value['thumb'], $value['remote'], 0);
			$message .= "<div class=\"uchome-message-pic\"><img src=\"$picurl\"><p>$value[title]</p></div>";
		}
	}

	$ckmessage = preg_replace("/(\<div\>|\<\/div\>|\s|\&nbsp\;|\<br\>|\<p\>|\<\/p\>)+/is", '', $message);
	if(empty($ckmessage)) {
		return false;
	}


	if(checkperm('manageblog')) {
		$blogarr['hot'] = intval($POST['hot']);
	}

	if($olds['blogid']) {

		if($blogarr['catid'] != $olds['catid']) {
			if($olds['catid']) {
				C::t('home_blog_category')->update_num_by_catid(-1, $olds['catid'], true, true);
			}
			if($blogarr['catid']) {
				C::t('home_blog_category')->update_num_by_catid(1, $blogarr['catid']);
			}
		}

		$blogid = $olds['blogid'];
		C::t('home_blog')->update($blogid, $blogarr);

		$fuids = array();

		$blogarr['uid'] = $olds['uid'];
		$blogarr['username'] = $olds['username'];
	} else {

		if($blogarr['catid']) {
			C::t('home_blog_category')->update_num_by_catid(1, $blogarr['catid']);
		}

		$blogarr['uid'] = $_G['uid'];
		$blogarr['username'] = $_G['username'];
		$blogarr['dateline'] = empty($POST['dateline'])?$_G['timestamp']:$POST['dateline'];
		$blogid = C::t('home_blog')->insert($blogarr, true);

		C::t('common_member_status')->update($_G['uid'], array('lastpost' => $_G['timestamp']));
		C::t('common_member_field_home')->update($_G['uid'], array('recentnote'=>$POST['subject']));
	}

	$blogarr['blogid'] = $blogid;
	$class_tag = new tag();
	$POST['tag'] = $olds ? $class_tag->update_field($POST['tag'], $blogid, 'blogid') : $class_tag->add_tag($POST['tag'], $blogid, 'blogid');
	$fieldarr = array(
		'message' => $message,
		'postip' => $_G['clientip'],
		'target_ids' => $POST['target_ids'],
		'tag' => $POST['tag']
	);

	if(!empty($titlepic)) {
		$fieldarr['pic'] = $titlepic;
	}

	if($olds) {
		C::t('home_blogfield')->update($blogid, $fieldarr);
	} else {
		$fieldarr['blogid'] = $blogid;
		$fieldarr['uid'] = $blogarr['uid'];
		C::t('home_blogfield')->insert($fieldarr);
	}

	if($isself && !$olds && $blog_status == 0) {
		updatecreditbyaction('publishblog', 0, array('blogs' => 1));

		include_once libfile('function/stat');
		updatestat('blog');
	}

	if($olds['blogid'] && $blog_status == 1) {
		updatecreditbyaction('publishblog', 0, array('blogs' => -1), '', -1);
		include_once libfile('function/stat');
		updatestat('blog');
	}

	if($POST['makefeed'] && $blog_status == 0) {
		include_once libfile('function/feed');
		feed_publish($blogid, 'blogid', $olds?0:1);
	}

	if(!empty($__G)) $_G = $__G;
	if($blog_status == 1) {
		updatemoderate('blogid', $blogid);
		manage_addnotify('verifyblog');
	}
	return $blogarr;
}
示例#16
0
function attachinpost($attach, $post) {
global $_G;
$firstpost = $post['first'];
$attach['refcheck'] = (!$attach['remote'] && $_G['setting']['attachrefcheck']) || ($attach['remote'] && ($_G['setting']['ftp']['hideurl'] || ($attach['isimage'] && $_G['setting']['attachimgpost'] && strtolower(substr($_G['setting']['ftp']['attachurl'], 0, 3)) == 'ftp')));
$aidencode = packaids($attach);
$widthcode = attachwidth($attach['width']);
$is_archive = $_G['forum_thread']['is_archived'] ? '&fid='.$_G['fid'].'&archiveid='.$_G[forum_thread][archiveid] : '';
$attachthumb = getimgthumbname($attach['attachment']);
$musiccode = getstatus($post[status], 7) && fileext($attach['attachment']) == 'mp3' ? (browserversion('ie') > 8 || browserversion('safari') ? '<audio controls="controls"><source src="'.$attach['url'].$attach['attachment'].'"></audio>' : parseaudio($attach['url'].$attach['attachment'], 400)) : '';
$guestviewthumb = !empty($_G['setting']['guestviewthumb']['flag']) && !$_G['uid'];
if($guestviewthumb) {
$guestviewthumbcss = guestviewthumbstyle();
}
?><?php
$__STATICURL = STATICURL;$return = <<<EOF

<ignore_js_op>

EOF;
 if($attach['attachimg'] && $_G['setting']['showimages'] && (((!$attach['price'] || $attach['payed']) && ($_G['group']['allowgetimage'] || $_G['uid'] == $attach['uid'])) || (($guestviewthumb)))) { if(!IS_ROBOT) { if($guestviewthumb) { 
$thumbpath = helper_attach::attachpreurl().'image/'.helper_attach::makethumbpath($attach['aid'], $_G['setting']['guestviewthumb']['width'], $_G['setting']['guestviewthumb']['height']);
$makefile = 'forum.php?mod=image&aid='.$attach['aid'].'&size='.$_G['setting']['guestviewthumb']['width'].'x'.$_G['setting']['guestviewthumb']['height'].'&key='.dsign($attach['aid'].'|'.$_G['setting']['guestviewthumb']['width'].'|'.$_G['setting']['guestviewthumb']['height']).'&type=1';

$return .= <<<EOF
{$guestviewthumbcss}
<div class="guestviewthumb">
<div style="margin: 0 auto;">
<img id="aimg_{$attach['aid']}" class="guestviewthumb_cur" aid="{$attach['aid']}" src="{$__STATICURL}image/common/none.gif" onclick="showWindow('login', 'member.php?mod=logging&action=login'+'&referer='+encodeURIComponent(location))" onerror="javascript:if(this.getAttribute('makefile')){this.src=this.getAttribute('makefile'); this.removeAttribute('makefile');}" file="{$thumbpath}" makefile="{$makefile}" inpost="1" alt="{$attach['imgalt']}" title="{$attach['imgalt']}"/>
<br>
<a href="member.php?mod=logging&amp;action=login" onclick="showWindow('login', this.href+'&referer='+encodeURIComponent(location));">登录/注册后可看大图</a>
</div>
</div>

EOF;
 } else { if($_G['setting']['thumbstatus'] && $attach['thumb']) { 
$return .= <<<EOF

<img
EOF;
 if($attach['price'] && $_G['forum_attachmentdown'] && $_G['uid'] != $attach['uid']) { 
$return .= <<<EOF
 class="attprice"
EOF;
 } 
$return .= <<<EOF
 style="cursor:pointer" id="aimg_{$attach['aid']}" aid="{$attach['aid']}" src="{$__STATICURL}image/common/none.gif" onclick="zoom(this, this.getAttribute('zoomfile'), 0, 0, '{$_G['setting']['showexif']}')" zoomfile="
EOF;
 if($attach['refcheck']) { 
$return .= <<<EOF
forum.php?mod=attachment{$is_archive}&aid={$aidencode}&noupdate=yes&nothumb=yes
EOF;
 } else { 
$return .= <<<EOF
{$attach['url']}{$attach['attachment']}
EOF;
 } 
$return .= <<<EOF
" file="
EOF;
 if($attach['refcheck']) { 
$return .= <<<EOF
forum.php?mod=attachment{$is_archive}&aid={$aidencode}
EOF;
 } else { 
$return .= <<<EOF
{$attach['url']}{$attachthumb}
EOF;
 } 
$return .= <<<EOF
" inpost="1"
EOF;
 if($_GET['from'] != 'preview') { 
$return .= <<<EOF
 onmouseover="showMenu({'ctrlid':this.id,'pos':'12'})"
EOF;
 } 
$return .= <<<EOF
 />

EOF;
 } else { 
$return .= <<<EOF

<img
EOF;
 if($attach['price'] && $_G['forum_attachmentdown'] && $_G['uid'] != $attach['uid']) { 
$return .= <<<EOF
 class="attprice"
EOF;
 } 
$return .= <<<EOF
 id="aimg_{$attach['aid']}" aid="{$attach['aid']}" src="{$__STATICURL}image/common/none.gif" zoomfile="
EOF;
 if($attach['refcheck']) { 
$return .= <<<EOF
forum.php?mod=attachment{$is_archive}&aid={$aidencode}&noupdate=yes&nothumb=yes
EOF;
 } else { 
$return .= <<<EOF
{$attach['url']}{$attach['attachment']}
EOF;
 } 
$return .= <<<EOF
" file="
EOF;
 if($attach['refcheck']) { 
$return .= <<<EOF
forum.php?mod=attachment{$is_archive}&aid={$aidencode}&noupdate=yes
EOF;
 } else { 
$return .= <<<EOF
{$attach['url']}{$attach['attachment']}
EOF;
 } 
$return .= <<<EOF
" {$widthcode} id="aimg_{$attach['aid']}" inpost="1"
EOF;
 if($_GET['from'] != 'preview') { 
$return .= <<<EOF
 onmouseover="showMenu({'ctrlid':this.id,'pos':'12'})"
EOF;
 } 
$return .= <<<EOF
 />

EOF;
 } } 
$return .= <<<EOF

<div class="tip tip_4 aimg_tip" id="aimg_{$attach['aid']}_menu" style="position: absolute; display: none" disautofocus="true">
<div class="xs0">
<p><strong>{$attach['filename']}</strong> <em class="xg1">({$attach['attachsize']}, 下载次数: {$attach['downloads']})</em></p>
<p>
<a href="forum.php?mod=attachment{$is_archive}&amp;aid={$aidencode}&amp;nothumb=yes" target="_blank">下载附件</a>

EOF;
 if(helper_access::check_module('album')) { 
$return .= <<<EOF

&nbsp;<a href="javascript:;" onclick="showWindow(this.id, this.getAttribute('url'), 'get', 0);" id="savephoto_{$attach['aid']}" url="home.php?mod=spacecp&amp;ac=album&amp;op=saveforumphoto&amp;aid={$attach['aid']}&amp;handlekey=savephoto_{$attach['aid']}">保存到相册</a>

EOF;
 } if($firstpost && $_G['fid'] && $_G['forum']['picstyle'] && ($_G['forum']['ismoderator'] || $_G['uid'] == $attach['uid'])) { 
$return .= <<<EOF

&nbsp;<a href="forum.php?mod=ajax&amp;action=setthreadcover&amp;aid={$attach['aid']}&amp;fid={$_G['fid']}" onclick="showWindow('setcover{$attach['aid']}', this.href)">设为封面</a>

EOF;
 } 
$return .= <<<EOF

</p>

EOF;
 if($attach['description']) { 
$return .= <<<EOF
<p>{$attach['description']}</p>
EOF;
 } 
$return .= <<<EOF

<p class="xg1 y">{$attach['dateline']} 上传</p>

EOF;
 } else { if($attach['description']) { 
$return .= <<<EOF
<p>{$attach['description']}</p>
EOF;
 } 
$return .= <<<EOF

<img src="
EOF;
 if($attach['refcheck']) { 
$return .= <<<EOF
forum.php?mod=attachment{$is_archive}&aid={$aidencode}&noupdate=yes
EOF;
 } else { 
$return .= <<<EOF
{$attach['url']}{$attach['attachment']}
EOF;
 } 
$return .= <<<EOF
" alt="{$attach['imgalt']}" title="{$attach['imgalt']}" />

EOF;
 } } else { if($musiccode) { 
$return .= <<<EOF

<div>{$musiccode}</div>

EOF;
 } 
$return .= <<<EOF

{$attach['attachicon']}
<span style="white-space: nowrap" id="attach_{$attach['aid']}" 
EOF;
 if($_GET['from'] != 'preview') { 
$return .= <<<EOF
onmouseover="showMenu({'ctrlid':this.id,'pos':'12'})"
EOF;
 } 
$return .= <<<EOF
>

EOF;
 if(!$attach['price'] || $attach['payed']) { 
$return .= <<<EOF

<a href="forum.php?mod=attachment{$is_archive}&amp;aid={$aidencode}" target="_blank">{$attach['filename']}</a>

EOF;
 } else { 
$return .= <<<EOF

<a href="forum.php?mod=misc&amp;action=attachpay&amp;aid={$attach['aid']}&amp;tid={$attach['tid']}" onclick="showWindow('attachpay', this.href)">{$attach['filename']}</a>

EOF;
 } 
$return .= <<<EOF

<em class="xg1">({$attach['attachsize']}, 下载次数: {$attach['downloads']}
EOF;
 if($attach['price']) { 
$return .= <<<EOF
, 售价: {$attach['price']} {$_G['setting']['extcredits'][$_G['setting']['creditstransextra']['1']]['unit']}{$_G['setting']['extcredits'][$_G['setting']['creditstransextra']['1']]['title']}
EOF;
 } 
$return .= <<<EOF
)</em>
</span>
<div class="tip tip_4" id="attach_{$attach['aid']}_menu" style="position: absolute; display: none" disautofocus="true">
<div class="tip_c xs0">
<div class="y">{$attach['dateline']} 上传</div>
点击文件名下载附件

EOF;
 if($attach['description']) { 
$return .= <<<EOF
<br />{$attach['description']}
EOF;
 } if($attach['readperm']) { 
$return .= <<<EOF
<br />阅读权限: {$attach['readperm']}
EOF;
 } } if(!IS_ROBOT && !$guestviewthumb) { if($attach['price']) { 
$return .= <<<EOF

<br />售价: {$attach['price']} {$_G['setting']['extcredits'][$_G['setting']['creditstransextra']['1']]['unit']}{$_G['setting']['extcredits'][$_G['setting']['creditstransextra']['1']]['title']}	&nbsp;<a href="forum.php?mod=misc&amp;action=viewattachpayments&amp;aid={$attach['aid']}" onclick="showWindow('attachpay', this.href)" target="_blank">[记录]</a>

EOF;
 if(!$attach['payed']) { 
$return .= <<<EOF

&nbsp;[<a href="forum.php?mod=misc&amp;action=attachpay&amp;aid={$attach['aid']}&amp;tid={$attach['tid']}" onclick="showWindow('attachpay', this.href)" target="_blank">购买</a>]

EOF;
 } } if(!$attach['attachimg'] && $_G['getattachcredits']) { 
$return .= <<<EOF
<br />下载积分: {$_G['getattachcredits']}
EOF;
 } 
$return .= <<<EOF

</div>
<div class="tip_horn"></div>
</div>

EOF;
 if($musiccode) { 
$return .= <<<EOF

<br />

EOF;
 } } 
$return .= <<<EOF

</ignore_js_op>

EOF;
?><?php 
return $return;
}
示例#17
0
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);
        }
    }
    if (!$modnewthreads && $newattach && $uid == $_G['uid']) {
        updatecreditbyaction('postattach', $uid, array(), '', count($newattach), 1, $_G['fid']);
    }
    if ($attachupdate) {
        $attachs = C::t('forum_attachment_n')->fetch_all_by_id('tid:' . $tid, 'aid', array_keys($attachupdate));
        foreach ($attachs as $attach) {
            if (array_key_exists($attach['aid'], $attachupdate) && $attachupdate[$attach['aid']]) {
                dunlink($attach);
            }
        }
        $unusedattachs = C::t('forum_attachment_unused')->fetch_all($attachupdate);
        $attachupdate = array_flip($attachupdate);
        $unusedaids = array();
        foreach ($unusedattachs as $attach) {
            if ($attach['uid'] != $uid && !$_G['forum']['ismoderator']) {
                continue;
            }
            $unusedaids[] = $attach['aid'];
            $update = $attach;
            $update['dateline'] = TIMESTAMP;
            $update['remote'] = 0;
            unset($update['aid']);
            if ($attach['isimage'] && $_G['setting']['watermarkstatus'] && empty($_G['forum']['disablewatermark'])) {
                $image->Watermark($_G['setting']['attachdir'] . '/forum/' . $attach['attachment'], '', 'forum');
                $update['filesize'] = $image->imginfo['size'];
            }
            C::t('forum_attachment_n')->update('tid:' . $tid, $attachupdate[$attach['aid']], $update);
            @unlink($_G['setting']['attachdir'] . 'image/' . $attach['aid'] . '_100_100.jpg');
            C::t('forum_attachment_exif')->delete($attachupdate[$attach['aid']]);
            C::t('forum_attachment_exif')->update($attach['aid'], array('aid' => $attachupdate[$attach['aid']]));
            ftpupload(array($attachupdate[$attach['aid']]), $uid);
        }
        if ($unusedaids) {
            C::t('forum_attachment_unused')->delete($unusedaids);
        }
    }
    $attachcount = C::t('forum_attachment_n')->count_by_id('tid:' . $tid, $pid ? 'pid' : 'tid', $pid ? $pid : $tid);
    $attachment = 0;
    if ($attachcount) {
        if (C::t('forum_attachment_n')->count_image_by_id('tid:' . $tid, $pid ? 'pid' : 'tid', $pid ? $pid : $tid)) {
            $attachment = 2;
        } else {
            $attachment = 1;
        }
    } else {
        $attachment = 0;
    }
    C::t('forum_thread')->update($tid, array('attachment' => $attachment));
    C::t('forum_post')->update('tid:' . $tid, $pid, array('attachment' => $attachment), true);
    if (!$attachment) {
        C::t('forum_threadimage')->delete_by_tid($tid);
    }
    $_G['forum_attachexist'] = $attachment;
}
示例#18
0
            }
            $html = profile_setting($fieldid, $ufielddata['userfield'], false, true);
            if ($html) {
                $settings[$fieldid] = $_G['cache']['profilesetting'][$fieldid];
                $htmls[$fieldid] = $html;
            }
        }
    }
} else {
    $activity['ufield'] = '';
}
if ($activity['aid']) {
    $attach = C::t('forum_attachment_n')->fetch('tid:' . $_G['tid'], $activity['aid']);
    if ($attach['isimage']) {
        $activity['attachurl'] = ($attach['remote'] ? $_G['setting']['ftp']['attachurl'] : $_G['setting']['attachurl']) . 'forum/' . $attach['attachment'];
        $activity['thumb'] = $attach['thumb'] ? getimgthumbname($activity['attachurl']) : $activity['attachurl'];
        $activity['width'] = $attach['thumb'] && $_G['setting']['thumbwidth'] < $attach['width'] ? $_G['setting']['thumbwidth'] : $attach['width'];
    }
    $skipaids[] = $activity['aid'];
}
$applylistverified = array();
$noverifiednum = 0;
$query = C::t('forum_activityapply')->fetch_all_for_thread($_G['tid'], 0, 0, 0, 1);
foreach ($query as $activityapplies) {
    $activityapplies['dateline'] = dgmdate($activityapplies['dateline'], 'u');
    if ($activityapplies['verified'] == 1) {
        $activityapplies['ufielddata'] = dunserialize($activityapplies['ufielddata']);
        if (count($applylist) < $_G['setting']['activitypp']) {
            $activityapplies['message'] = preg_replace("/(" . lang('forum/misc', 'contact') . ".*)/", '', $activityapplies['message']);
            $applylist[] = $activityapplies;
        }
示例#19
0
 public function parseTradeTopic($_G, $post)
 {
     $rows = C::t('forum_thread')->fetch_all_by_tid($_G['tid']);
     $tpids = array();
     if ($rows[$_G['tid']]['special'] == 2) {
         $query = C::t('forum_trade')->fetch_all_thread_goods($_G['tid']);
         foreach ($query as $trade) {
             $tradesaids[] = $trade['aid'];
             $tradespids[] = $trade['pid'];
         }
         $specialadd2 = 1;
         if ($tradespids) {
             foreach (C::t('forum_attachment_n')->fetch_all_by_id('tid:' . $_G['tid'], 'pid', $tradespids) as $attach) {
                 if ($attach['isimage'] && is_array($tradesaids) && in_array($attach['aid'], $tradesaids)) {
                     $trades[$attach['pid']]['attachurl'] = ($attach['remote'] ? $_G['setting']['ftp']['attachurl'] : $_G['setting']['attachurl']) . 'forum/' . $attach['attachment'];
                     $trades[$attach['pid']]['thumb'] = $attach['thumb'] ? getimgthumbname($trades[$attach['pid']]['attachurl']) : $trades[$attach['pid']]['attachurl'];
                     $trades[$attach['pid']]['width'] = $attach['thumb'] && $_G['setting']['thumbwidth'] < $attach['width'] ? $_G['setting']['thumbwidth'] : $attach['width'];
                     $trades[$attach['pid']]['thumb'] = str_replace('forum/', '', $trades[$attach['pid']]['thumb']);
                     $filename = $this->parseTradeTopicImg($trades[$attach['pid']]);
                     $info[] = array('infor' => $filename, 'type' => 1);
                 }
             }
         }
         $tradepostlist = C::t('forum_post')->fetch_all('tid:' . $_G['tid'], $tradespids);
         foreach ($query as $trade) {
             $quality = $trade['quality'] == 1 ? Common::get_unicode_charset('\\u5168\\u65b0\\u5546\\u54c1') : Common::get_unicode_charset('\\u4e8c\\u624b\\u5546\\u54c1');
             $transport = $trade['transport'];
             switch ($trade['transport']) {
                 case 3:
                     $transport = Common::get_unicode_charset('\\u865a\\u62df\\u5546\\u54c1');
                     break;
                 case 2:
                     $transport = '';
                     break;
                 case 0:
                     $transport = Common::get_unicode_charset('\\u7ebf\\u4e0b\\u4ea4\\u6613');
                     break;
             }
             $time = $trade['expiration'] - time();
             $time = explode('.', $time / 3600 / 24);
             $time = intval($time[0]) . Common::get_unicode_charset('\\u5929') . intval(('0.' . $time[1]) * 24) . Common::get_unicode_charset('\\u5c0f\\u65f6');
             $message[] = array('infor' => Common::get_unicode_charset('\\u5546\\u54c1\\u7c7b\\u578b\\u003a') . $quality, 'type' => 0);
             $message[] = array('infor' => Common::get_unicode_charset('\\u8fd0\\u8d39\\u003a') . $transport, 'type' => 0);
             $message[] = array('infor' => Common::get_unicode_charset('\\u5269\\u4f59\\u65f6\\u95f4\\u003a') . $time, 'type' => 0);
             $message[] = array('infor' => Common::get_unicode_charset('\\u5546\\u54c1\\u6570\\u91cf\\u003a') . $trade['amount'], 'type' => 0);
             $message[] = array('infor' => Common::get_unicode_charset('\\u5730\\u70b9\\u003a') . $trade['locus'], 'type' => 0);
             $message[] = array('infor' => Common::get_unicode_charset('\\u7d2f\\u8ba1\\u552e\\u51fa\\u003a') . $trade['totalitems'], 'type' => 0);
         }
         foreach ($tradepostlist as $val) {
             $topicContent = text_replace($val['message']);
             $topicContent = discuzcode($topicContent, $val['smileyoff'], $val['bbcodeoff']);
             $topicContent = str_replace('<img src="static/', '<img src="/static/', $topicContent);
             $val['message'] = text_replace($topicContent);
             $message1 = doContent($val['message'], $tradesaids);
             $message2 = getContentFont($val['message']);
             foreach ($message1 as $k => $v) {
                 if ($v['type'] == 0) {
                     unset($message1[$k]);
                 } else {
                 }
             }
             $message_array2 = explode('|~|', $message2);
             $message2 = str_replace('[', '1', $message2);
             $message2 = str_replace(']', '1', $message2);
             if (is_array($message_array2) && count($message_array2) > 0) {
                 foreach ($message_array2 as $k => $v) {
                     $message[] = array("infor" => $v, "type" => 0);
                     if ($message1[$k]["infor"] && !empty($message1)) {
                         $message[] = $message1[$k];
                     }
                 }
             } else {
                 $message = getContentFont($val['message']);
             }
         }
     }
     return $message;
 }
示例#20
0
             $feed['body_template'] = 'feed_thread_goods_message_1';
         } else {
             $feed['body_template'] = 'feed_thread_goods_message_2';
         }
     } else {
         $feed['body_template'] = 'feed_thread_goods_message_3';
     }
     $feed['body_data'] = array('itemname' => "<a href=\"forum.php?mod=viewthread&do=tradeinfo&tid={$tid}&pid={$pid}\">{$_GET['item_name']}</a>", 'itemprice' => $_GET['item_price'], 'itemcredit' => $_GET['item_credit'], 'creditunit' => $_G['setting']['extcredits'][$_G['setting']['creditstransextra'][5]]['unit'] . $_G['setting']['extcredits'][$_G['setting']['creditstransextra'][5]]['title']);
     if ($_GET['tradeaid']) {
         $feed['images'] = array(getforumimg($_GET['tradeaid']));
         $feed['image_links'] = array("forum.php?mod=viewthread&do=tradeinfo&tid={$tid}&pid={$pid}");
     }
     if ($_GET['tradeaid']) {
         $attachment = C::t('forum_attachment_n')->fetch('tid:' . $tid, $_GET['tradeaid']);
         if (in_array($attachment['filetype'], array('image/gif', 'image/jpeg', 'image/png'))) {
             $imgurl = $_G['setting']['attachurl'] . 'forum/' . ($attachment['thumb'] && $attachment['filetype'] != 'image/gif' ? getimgthumbname($attachment['attachment']) : $attachment['attachment']);
             $feed['images'][] = $attachment['attachment'] ? $imgurl : '';
             $feed['image_links'][] = $attachment['attachment'] ? "forum.php?mod=viewthread&tid={$tid}" : '';
         }
     }
     $feed['title_data']['hash_data'] = "tid{$tid}";
     $feed['id'] = $tid;
     $feed['idtype'] = 'tid';
     postfeed($feed);
 }
 if ($displayorder != -4) {
     if ($digest) {
         updatepostcredits('+', $_G['uid'], 'digest', $_G['fid']);
     }
     updatepostcredits('+', $_G['uid'], 'post', $_G['fid']);
     if ($isgroup) {
示例#21
0
 function init($method, $source, $target, $nosuffix = 0)
 {
     global $_G;
     $this->errorcode = 0;
     if (empty($source)) {
         return -2;
     }
     $parse = parse_url($source);
     if (isset($parse['host'])) {
         if (empty($target)) {
             return -2;
         }
         $data = dfsockopen($source);
         $this->tmpfile = $source = tempnam($_G['setting']['attachdir'] . './temp/', 'tmpimg_');
         file_put_contents($source, $data);
         if (!$data || $source === FALSE) {
             return -2;
         }
     }
     if ($method == 'thumb') {
         $target = empty($target) ? !$nosuffix ? getimgthumbname($source) : $source : $_G['setting']['attachdir'] . './' . $target;
     } elseif ($method == 'watermask') {
         $target = empty($target) ? $source : $_G['setting']['attachdir'] . './' . $target;
     }
     $targetpath = dirname($target);
     dmkdir($targetpath);
     clearstatcache();
     if (!is_readable($source) || !is_writable($targetpath)) {
         return -2;
     }
     $imginfo = @getimagesize($source);
     if ($imginfo === FALSE) {
         return -1;
     }
     $this->source = $source;
     $this->target = $target;
     $this->imginfo['width'] = $imginfo[0];
     $this->imginfo['height'] = $imginfo[1];
     $this->imginfo['mime'] = $imginfo['mime'];
     $this->imginfo['size'] = @filesize($source);
     $this->libmethod = $this->param['imagelib'] && $this->param['imageimpath'];
     if (!$this->libmethod) {
         switch ($this->imginfo['mime']) {
             case 'image/jpeg':
                 $this->imagecreatefromfunc = function_exists('imagecreatefromjpeg') ? 'imagecreatefromjpeg' : '';
                 $this->imagefunc = function_exists('imagejpeg') ? 'imagejpeg' : '';
                 break;
             case 'image/gif':
                 $this->imagecreatefromfunc = function_exists('imagecreatefromgif') ? 'imagecreatefromgif' : '';
                 $this->imagefunc = function_exists('imagegif') ? 'imagegif' : '';
                 break;
             case 'image/png':
                 $this->imagecreatefromfunc = function_exists('imagecreatefrompng') ? 'imagecreatefrompng' : '';
                 $this->imagefunc = function_exists('imagepng') ? 'imagepng' : '';
                 break;
         }
     } else {
         $this->imagecreatefromfunc = $this->imagefunc = TRUE;
     }
     if (!$this->libmethod && $this->imginfo['mime'] == 'image/gif') {
         if (!$this->imagecreatefromfunc) {
             return -4;
         }
         if (!($fp = @fopen($source, 'rb'))) {
             return -2;
         }
         $content = fread($fp, $this->imginfo['size']);
         fclose($fp);
         $this->imginfo['animated'] = strpos($content, 'NETSCAPE2.0') === FALSE ? 0 : 1;
     }
     return $this->imagecreatefromfunc ? 1 : -4;
 }
示例#22
0
function getalbumpic($uid, $id)
{
    global $_G;
    $pic = C::t('home_pic')->fetch_album_pic($id, $uid);
    if ($pic) {
        return $pic['thumb'] ? getimgthumbname($pic['filepath']) : $pic['filepath'];
    } else {
        return '';
    }
}
示例#23
0
     $tradespids[] = $trade['pid'];
     if ($trade['displayorder'] < 0) {
         $trades[$trade['pid']] = $trade;
     } else {
         $tradesstick[$trade['pid']] = $trade;
     }
 }
 $trades = $tradesstick + $trades;
 $tradespids = dimplode($tradespids);
 unset($trade);
 if ($tradespids) {
     $query = DB::query("SELECT * FROM " . DB::table(getattachtablebytid($_G['tid'])) . " WHERE pid IN ({$tradespids})");
     while ($attach = DB::fetch($query)) {
         if ($attach['isimage'] && is_array($tradesaids) && in_array($attach['aid'], $tradesaids)) {
             $trades[$attach['pid']]['attachurl'] = ($attach['remote'] ? $_G['setting']['ftp']['attachurl'] : $_G['setting']['attachurl']) . 'forum/' . $attach['attachment'];
             $trades[$attach['pid']]['thumb'] = $attach['thumb'] ? getimgthumbname($trades[$attach['pid']]['attachurl']) : $trades[$attach['pid']]['attachurl'];
             $trades[$attach['pid']]['width'] = $attach['thumb'] && $_G['setting']['thumbwidth'] < $attach['width'] ? $_G['setting']['thumbwidth'] : $attach['width'];
         }
     }
 }
 if ($_G['gp_do'] == 'tradeinfo') {
     $verifyadd = '';
     if ($_G['setting']['verify']['enabled']) {
         $verifyadd = "LEFT JOIN " . DB::table('common_member_verify') . " mv USING(uid)";
         $fieldsadd .= ', mv.verify1, mv.verify2, mv.verify3, mv.verify4, mv.verify5';
     }
     $trade = $trades[$_G['gp_pid']];
     unset($trades);
     $posttable = getposttablebytid($_G['tid']);
     $post = DB::fetch_first("SELECT p.*, m.uid, mp.realname, m.username, m.groupid, m.adminid, m.regdate, ms.lastactivity,\r\n\t\t\tm.credits, m.email, mp.gender, mp.site,\tmp.icq, mp.qq, mp.yahoo, mp.msn, mp.taobao, mp.alipay,\r\n\t\t\tms.buyercredit, ms.sellercredit {$fieldsadd}\r\n\t\t\tFROM " . DB::table($posttable) . " p\r\n\t\t\tLEFT JOIN " . DB::table('common_member') . " m ON m.uid=p.authorid\r\n\t\t\tLEFT JOIN " . DB::table('common_member_status') . " ms USING(uid)\r\n\t\t\tLEFT JOIN " . DB::table('common_member_profile') . " mp USING(uid)\r\n\t\t\t{$verifyadd}\r\n\t\t\tWHERE pid='{$_G['gp_pid']}'");
     $postlist[$post['pid']] = viewthread_procpost($post, $lastvisit, $ordertype);
示例#24
0
                }
            }
            if (empty($itemfields['pics'][0])) {
                unset($itemfields['pics'][0]);
            }
        } elseif ($_GET['idtype'] == 'aids') {
            $prefix .= 'portal/';
            foreach (C::t('portal_attachment')->fetch_all_by_aid($_GET['id']) as $pic) {
                if ($first) {
                    $first = false;
                    $itemfields['pics'][0] = '';
                    if (strpos($itemfields['oldpic'], 'nophoto.gif') !== false) {
                        $itemfields['oldpic'] = 'portal/' . $pic['attachment'];
                    }
                }
                $thumb = $prefix . ($pic['thumb'] ? getimgthumbname($pic['attachment']) : $pic['attachment']);
                if ('portal/' . $pic['attachment'] == $itemfields['oldpic']) {
                    $itemfields['pics'][0] = array('big' => $prefix . $pic['attachment'], 'thumb' => $thumb, 'attachment' => 'portal/' . $pic['attachment'], 'first' => 1);
                } else {
                    $itemfields['pics'][] = array('big' => $prefix . $pic['attachment'], 'thumb' => $thumb, 'attachment' => 'portal/' . $pic['attachment'], 'first' => 0);
                }
            }
            if (empty($itemfields['pics'][0])) {
                unset($itemfields['pics'][0]);
            }
        } elseif ($_GET['idtype'] == 'blogids') {
            $itemfields['pics'][] = array('big' => $itemfields['pic'], 'thumb' => 1, 'attachment' => $itemfields['oldpic']);
        }
    }
} elseif ($op == 'getblock') {
    if (!$bid || !$allowmanage && !$allowdata) {
示例#25
0
function pic_upload($FILES, $type = 'album', $thumb_width = 0, $thumb_height = 0, $thumb_type = 2)
{
    $upload = new discuz_upload();
    $result = array('pic' => '', 'thumb' => 0, 'remote' => 0);
    $upload->init($FILES, $type);
    if ($upload->error()) {
        return array();
    }
    $upload->save();
    if ($upload->error()) {
        return array();
    }
    $result['pic'] = $upload->attach['attachment'];
    if ($thumb_width && $thumb_height) {
        require_once libfile('class/image');
        $image = new image();
        if ($image->Thumb($upload->attach['target'], '', $thumb_width, $thumb_height, $thumb_type)) {
            $result['thumb'] = 1;
        }
    }
    if (getglobal('setting/ftp/on')) {
        if (ftpcmd('upload', $type . '/' . $upload->attach['attachment'])) {
            if ($result['thumb']) {
                ftpcmd('upload', $type . '/' . getimgthumbname($upload->attach['attachment']));
            }
            ftpcmd('close');
            $result['remote'] = 1;
        } else {
            if (getglobal('setting/ftp/mirror')) {
                @unlink($upload->attach['target']);
                @unlink(getimgthumbname($upload->attach['target']));
                return array();
            }
        }
    }
    return $result;
}
示例#26
0
function downremotefile($arr, $action, $old_arr = array())
{
    global $_G;
    $evo_img_no = $_G['cache']['evn_milu_pick']['evo_img_no'];
    $config = get_pick_set();
    $get_file_ext_arr = $config['get_file_ext'] ? explode('|', $config['get_file_ext']) : array();
    if ($arr['is_bbs'] != 1) {
        //是论坛回帖就不合并
        if ($action == 'portal') {
            $page_flag = $arr['is_page_public'] == 1 ? '' : '1';
            if ($arr['content_arr']) {
                $arr['content'] = content_merge($arr['content_arr'], $page_flag);
            }
        } else {
            if ($arr['content_arr']) {
                $arr['content'] = content_merge($arr['content_arr']);
            }
        }
    }
    //if(VIP) $arr['content'] = post($arr['content'], array('cookie' => $arr['cookie'], 'page_url' => $arr['page_url'], 'cid' => $arr['cid']));
    $arr['content'] = htmlspecialchars_decode($arr['content'], ENT_QUOTES);
    if ($arr['is_download_img'] == 1 || $arr['is_download_file'] == 1) {
        if (file_exists(libfile('class/upload'))) {
            require_once libfile('class/upload');
        } else {
            require_once libfile('discuz/upload', 'class');
        }
        $upload = new discuz_upload();
        $arrayimageurl = $temp = $imagereplace = $attach_arr = array();
        $string = dstripslashes($arr['content']);
        $downremotefile = true;
        $aid = $arr['aid'];
        preg_match_all("/\\<img.+src=('|\"|)?(.*)(\\1)(.*)?\\>/isU", $string, $temp, PREG_SET_ORDER);
        if ($arr['is_download_file'] == 1) {
            $attach_arr = get_attach_data($arr['page_url'], $string);
        }
        $attach_arr = $attach_arr ? $attach_arr : array();
        $temp = $temp ? $temp : array();
        $temp = array_merge($temp, $attach_arr);
        $del_a = 0;
        if ($arr['content_filter_html'][0] == 0 && $arr['content_filter_html']) {
            $del_a = 1;
        }
        //print_r($arr['content']);
        //print_r($temp);
        if (is_array($temp) && !empty($temp)) {
            foreach ($temp as $tempvalue) {
                $img_url = $tempvalue[2];
                $img_url = str_replace('\\"', '', $img_url);
                $no_remote = 0;
                if (strlen($img_url)) {
                    $img_url = trim(strip_tags($img_url));
                    if (!filter_something($img_url, $evo_img_no)) {
                        //存在
                        $no_remote = 1;
                    }
                    if ($no_remote == 0) {
                        $tempvalue[2] = $img_url;
                        $arrayimageurl[] = $tempvalue;
                    }
                }
            }
            if ($arrayimageurl) {
                $content_md5_arr = array();
                foreach ($arrayimageurl as $key => $tempvalue) {
                    $imageurl = $tempvalue[4] == 1 ? $tempvalue[1] : $tempvalue[2];
                    $attach['ext'] = $upload->fileext($imageurl);
                    if ($upload->is_image_ext($attach['ext']) == 1 && $arr['is_download_img'] != 1) {
                        unset($imagereplace['oldimageurl'][$key]);
                        continue;
                    }
                    $snoopy_args['cookie'] = $arr['cookie'];
                    $snoop_obj = get_snoopy_obj($snoopy_args);
                    $imagereplace['oldimageurl'][$key] = $tempvalue[4] == 1 ? $tempvalue[0] : $tempvalue[2];
                    if (!$upload->is_image_ext($attach['ext'])) {
                        $ext = 'no_get';
                        //continue;
                    }
                    $content = '';
                    if (preg_match('/^(http:\\/\\/|\\.)/i', $imageurl)) {
                        if ($imageurl && snoop_obj) {
                            $content_re = get_img_content($imageurl, $snoop_obj, $ext);
                        }
                        unset($snoop_obj);
                        if (is_array($content_re)) {
                            $content = $content_re['content'];
                            $file_name = $attach['name'] = $content_re['file_name'] ? $content_re['file_name'] : ($value[2] ? _striptext($value[2]) : time() . '.' . $content_re['file_ext']);
                            $attach['ext'] = $content_re['file_ext'] ? $content_re['file_ext'] : trim($upload->fileext($file_name));
                            $file_name = $attach['name'] = $file_name;
                        } else {
                            $content = $content_re;
                        }
                        if (in_array(md5($content), $content_md5_arr)) {
                            unset($imagereplace['oldimageurl'][$key]);
                            continue;
                        }
                        $content_md5_arr[] = md5($content);
                    } elseif (checkperm('allowdownlocalimg')) {
                        if (preg_match('/^data\\/(.*?)\\.thumb\\.jpg$/i', $imageurl)) {
                            $content = file_get_contents(substr($imageurl, 0, strrpos($imageurl, '.') - 6));
                        } elseif (preg_match('/^data\\/(.*?)\\.(jpg|jpeg|gif|png)$/i', $imageurl)) {
                            $content = file_get_contents($imageurl);
                        }
                    }
                    if (empty($content)) {
                        if ($tempvalue[4] == 1) {
                            if ($del_a == 1) {
                                unset($imagereplace['oldimageurl'][$key]);
                                $imagereplace['oldimageurl_a'][$key] = $tempvalue[0];
                                $imagereplace['newimageurl_a'][$key] = $tempvalue[2];
                            } else {
                                unset($imagereplace['oldimageurl'][$key]);
                            }
                        } else {
                            unset($imagereplace['oldimageurl'][$key]);
                        }
                        continue;
                    }
                    if (!$attach['name']) {
                        $temp = explode('/', $imageurl);
                        $attach['name'] = trim($temp[count($temp) - 1]);
                    }
                    $attach['thumb'] = '';
                    $attach['isimage'] = $upload->is_image_ext($attach['ext']);
                    $attach['extension'] = $upload->get_target_extension($attach['ext']);
                    $attach['attachdir'] = $upload->get_target_dir($action);
                    $attach['attachment'] = $attach['attachdir'] . $upload->get_target_filename($action) . '.' . $attach['extension'];
                    $attach['target'] = getglobal('setting/attachdir') . './' . $action . '/' . $attach['attachment'];
                    if ($attach['isimage'] == 1 && $arr['is_download_img'] != 1) {
                        unset($imagereplace['oldimageurl'][$key]);
                        continue;
                    }
                    if (!in_array($attach['ext'], $get_file_ext_arr) && $get_file_ext_arr && $attach['isimage'] == 0) {
                        if ($tempvalue[4] == 1) {
                            if ($del_a == 1) {
                                unset($imagereplace['oldimageurl'][$key]);
                                $imagereplace['oldimageurl_a'][$key] = $tempvalue[0];
                                $imagereplace['newimageurl_a'][$key] = $tempvalue[2];
                            } else {
                                unset($imagereplace['oldimageurl'][$key]);
                            }
                        } else {
                            unset($imagereplace['oldimageurl'][$key]);
                        }
                        continue;
                    }
                    if ($attach['isimage'] == 0) {
                        $imagereplace['oldimageurl'][$key] = $tempvalue[1];
                        if ($action == 'album') {
                            unset($imagereplace['oldimageurl'][$key], $imagereplace['oldimageurl_a'][$key], $imagereplace['newimageurl_a'][$key]);
                        }
                    }
                    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']);
                    $attachs[] = daddslashes($attach);
                }
            }
        }
    }
    //print_r($imagereplace);//exit();
    if ($attachs) {
        foreach ($attachs as $key => $attach) {
            if ($action != 'forum' && $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);
                if ($arr['is_water_img'] == 1) {
                    $image->Watermark($attach['target'], '', $action);
                }
                //打水印
            }
            if ($action == 'portal') {
                //if(!$arr['attachment']) $arr['attachment'] = 'portal/'.$attach['attachment'];
                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']));
                            portal_upload_error(lang('portalcp', 'upload_remote_failed'));
                        }
                    }
                }
                $setarr = array('uid' => $arr['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);
                $setarr['attachid'] = DB::insert("portal_attachment", $setarr, true);
            } else {
                if ($action == 'album') {
                    $arr['pic'] = $attach['attachment'];
                    $new_name = $attach['target'];
                    require_once libfile('class/image');
                    $image = new image();
                    $result = $image->Thumb($new_name, '', 140, 140, 1);
                    $thumb = empty($result) ? 0 : 1;
                    if ($_G['setting']['maxthumbwidth'] && $_G['setting']['maxthumbheight']) {
                        if ($_G['setting']['maxthumbwidth'] < 300) {
                            $_G['setting']['maxthumbwidth'] = 300;
                        }
                        if ($_G['setting']['maxthumbheight'] < 300) {
                            $_G['setting']['maxthumbheight'] = 300;
                        }
                        $image->Thumb($new_name, '', $_G['setting']['maxthumbwidth'], $_G['setting']['maxthumbheight'], 1, 1);
                    }
                    if ($iswatermark) {
                        $image->Watermark($new_name, '', 'album');
                    }
                    $attach['remote'] = 0;
                    $album_picflag = 1;
                    if (getglobal('setting/ftp/on')) {
                        $ftpresult_thumb = 0;
                        $ftpresult = ftpcmd('upload', 'album/' . $attach['attachment']);
                        if ($ftpresult) {
                            @unlink($_G['setting']['attachdir'] . 'album/' . $attach['attachment']);
                            if ($thumb) {
                                $thumbpath = getimgthumbname($attach['attachment']);
                                ftpcmd('upload', 'album/' . $thumbpath);
                                @unlink($_G['setting']['attachdir'] . 'album/' . $thumbpath);
                            }
                            $attach['remote'] = 1;
                            $album_picflag = 2;
                        } else {
                            if (getglobal('setting/ftp/mirror')) {
                                @unlink($upload->attach['target']);
                                @unlink(getimgthumbname($upload->attach['target']));
                                return lang('spacecp', 'ftp_upload_file_size');
                            }
                        }
                    }
                    $setarr = array('uid' => $arr['uid'], 'filename' => $attach['name'], 'filepath' => $attach['attachment'], 'size' => $attach['size'], 'thumb' => $attach['thumb'], 'username' => $arr['username'], 'postip' => $_G['clientip'], 'remote' => $attach['remote'], 'type' => $attach['extension'], 'dateline' => $arr['public_time']);
                    //print_r($setarr);exit();
                    $setarr['attachid'] = DB::insert("home_pic", $setarr, true);
                    if ($attach['thumb'] == 1 && $feed_re != 1) {
                        $feed['image_1'] = 'data/attachment/album/' . $attach['attachment'] . '.thumb.jpg';
                        $feed['image_1_link'] = 'home.php?mod=space&uid=' . $arr['uid'] . '&do=blog&id=' . $arr['aid'];
                        DB::update("home_feed", $feed, array("idtype" => 'blogid', 'id' => $arr['aid']));
                        $feed_re = 1;
                    }
                }
            }
            if ($downremotefile) {
                $attach['url'] = ($attach['remote'] ? $_G['setting']['ftp']['attachurl'] : $_G['setting']['attachurl']) . '' . $action . '/';
                $imagereplace['newimageurl'][] = $attach['url'] . $attach['attachment'];
            }
        }
        if ($downremotefile && $imagereplace || $del_a == 1 && $imagereplace) {
            $string = preg_replace(array("/\\<(script|style|iframe)[^\\>]*?\\>.*?\\<\\/(\\1)\\>/si", "/\\<!*(--|doctype|html|head|meta|link|body)[^\\>]*?\\>/si"), '', $string);
            $string = str_replace($imagereplace['oldimageurl'], $imagereplace['newimageurl'], $string);
            $string = str_replace($imagereplace['oldimageurl_a'], $imagereplace['newimageurl_a'], $string);
            $string = str_replace(array("\r", "\n", "\r\n"), '', addcslashes($string, '/"\\'));
            $arr['content'] = $string;
        }
    }
    if ($del_a == 1) {
        $arr['content'] = clear_html_script($arr['content'], array(0));
    }
    if (DISCUZ_VERSION != 'X2') {
        //2.5版本
        $arr['content'] = dstripslashes($arr['content']);
        //不必转义
    }
    $do = $action . '_article_content';
    if ($action != 'forum') {
        $do($arr, $old_arr);
    }
}