supesite 7.5 增加投稿时可以上传附件的功能

1,修改根目录/source/cp_news.php文件

查找
$itemarr = array('message' => $_POST['message'],
        'relativetags' => addslashes(serialize($tagnamearr)),            //相关TAG
         'newsfrom' => $_POST['newsfrom'],
         'newsauthor' => $_POST['newsauthor'],
         'newsfromurl' => $_POST['newsfromurl'],
         'postip' => $_SGLOBAL['onlineip'],
         'includetags' => postgetincludetags($_POST['message'], $tagnamearr)
        );


在下面添加
$newsarr['hash'] = trim($_POST['hash']);
//附件
if(!empty($_POST['divupload']) && is_array($_POST['divupload'])) {
    $newsarr['haveattach'] = 1;
} else {
    $newsarr['haveattach'] = 0;
}


查找
//更新用户最新更新时间
if($_SGLOBAL['supe_uid']) {
    updatetable('members', array('updatetime'=>$_SGLOBAL['timestamp'], 'lastposttime'=>$_SGLOBAL['timestamp']), array('uid'=>$_SGLOBAL['supe_uid']));    
}


在下面添加
//附件
if($newsarr['haveattach']) {
    $_SGLOBAL['db']->query('UPDATE '.tname('attachments').' SET isavailable=1, type=\''.$_POST['type'].'\', itemid='.$itemarr['itemid'].', catid=\''.$_POST['catid'].'\' WHERE hash=\''.$_POST['hash'].'\'');
}

查找
} elseif($op == 'edit') {


在上一行添加
$hashstr = smd5($_SGLOBAL['supe_uid'].'/'.$_SGLOBAL['timestamp'].random(6));


查找
$item['subject'] = shtmlspecialchars($item['subject']);
$item['message'] = jsstrip($item['message']);


在下面添加
    if(!empty($item['haveattach'])) {
                $query = $_SGLOBAL['db']->query('SELECT * FROM '.tname('attachments').' WHERE itemid=\''.$itemid.'\' ORDER BY dateline');
                while ($attach = $_SGLOBAL['db']->fetch_array($query)) {
                    $item['uploadarr'][] = $attach;
                }
    }
    $count = count($item['uploadarr']);
    if(empty($item['noinsert'])) {
        $item['noinsert'] = 0;
        $inserthtml = getuploadinserthtml($item['uploadarr']);
    } else {
        $inserthtml = getuploadinserthtml($item['uploadarr'], 1);
    }




2,修改根目录/tempalte/default/cp_news.html.php文件

查找
<table width="100%" class="globalbox_border">
    <tbody>
        <tr>
            <td width="100" align="right">获取远程资讯:</td>



在下面添加
<input name="subjectpic" id="subjectpic" type="hidden" value="" />
<table cellspacing="0" cellpadding="0" width="100%"  class="maintable">
    <tr id="tr_upload">
        <th>内容附件:</p></th>
        <td>
            <div id="uploadbox">
            <div class="tabs">
                <a id="localuploadtab" href="javascript:;" 'localupload');" class="current">本地上传</a>
                <a id="remoteuploadtab" href="javascript:;" 'remoteupload');">远程上传</a>
                <a id="batchuploadtab" href="javascript:;" 'batchupload');">批量上传</a>
            </div>
            <div id="localupload">
                <table cellpadding="0" cellspacing="0">
                    <tr>
                        <th>选择文件:</th>
                        <td><input name="localfile" type="file" id="localfile" size="28" /></td>
                        <td valign="bottom" rowspan="3" class="upbtntd"><button uploadFile(0)">上传</button></td>
                    </tr>
                    <tr>
                        <th>上传说明:</th>
                        <td><input name="uploadsubject0" type="text" size="40" /></td>
                    </tr>
                </table>
            </div>
            <div id="remoteupload" style="display: none;">
                <table cellpadding="0" cellspacing="0">
                    <tr>
                        <th>输入网址:</th>
                        <td><input type="text" size="40" name="remotefile" value="http://" /></td>
                        <td valign="bottom" rowspan="2" class="upbtntd"><button uploadFile(1)" />上传</button></td>
                    </tr>
                    <tr>
                        <th>上传说明:</th>
                        <td><input name="uploadsubject1" type="text" size="40" /></td>
                    </tr>
                </table>
            </div>
            <div id="batchupload" style="display: none;">
                <table summary="" cellpadding="0" cellspacing="6" border="0" width="70%">
                    <tr>
                        <td><span id="batchdisplay"><input size="28" class="fileinput" id="batch_1" name="batchfile[]" onchange="insertimg(this)" type="file" /></span></td>
                        <td class="upbtntd">
                        <button id="doupfile" uploadFile(2)">上传</button>
                        </td>
                    <tr>
                        <td colspan="2">
                        <div id="batchpreview"></div>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2">
                        <button id="delall" name="delall" delpic()" style=" transparent; border: none; cursor: pointer; color: red; " >全部清空</button>
                        </td>
                    </tr>
                </table>
            </div>

            <p class="textmsg" id="divshowuploadmsg" style="display:none"></p>
            <p class="textmsg succ" id="divshowuploadmsgok" style="display:none"></p>
            <input type="hidden" id="uploadallowmax" name="uploadallowmax" value="100">
            <input type="hidden" name="uploadallowtype" value="$thevalue[allowtype]">
            <input type="hidden" name="thumbwidth" value="$_SCONFIG[thumbarray][news][0]">
            <input type="hidden" name="thumbheight" value="$_SCONFIG[thumbarray][news][1]">
            <input type="hidden" name="noinsert" value="$thevalue['noinsert']">
            <input name="hash" type="hidden" value="$hashstr" />
            </div>
            <div id="divshowupload">$inserthtml</div>
        </td>
    </tr>
</table>


3,经网友提示,幻灯图没有显示,蘑菇新增修复方法

修改根目录/source/cp_news.php文件

查找
$_POST['type'] = shtmlspecialchars(trim($_POST['type']));

在下面添加
$_POST['picid'] = empty($_POST['picid'])?0:intval($_POST['picid']);    //图文资讯标志


查找
'type' => $_POST['type'],

在下面添加
'picid' => $_POST['picid'],


ok,修改完成,请各位同学测试一下吧 
 

你可能感兴趣的:(supesite,上传附件)