本帖最后由 husan 于 2010-12-13 12:52 编辑
今天给大家介绍一下增加supesite投稿时可以上传附件功能的方法,
建议修改前请先修改《解决supesite审批文章丢失附件的bug》
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">
- <td width="100" align="right" valign="top">内容附件:</td>
- <td>
- <div id="uploadbox">
- <div class="tabs">
- <a id="localuploadtab" href="javascript:;" onclick="hideshowtags('uploadbox', 'localupload');" class="current">本地上传</a>
- <a id="remoteuploadtab" href="javascript:;" onclick="hideshowtags('uploadbox', 'remoteupload');">远程上传</a>
- <a id="batchuploadtab" href="javascript:;" onclick="hideshowtags('uploadbox', '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="2" class="upbtntd"><button onclick="return 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 onclick="return 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="100%">
- <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" onclick="return uploadFile(2)">上传</button>
- </td>
- <tr>
- <td colspan="2">
- <div id="batchpreview"></div>
- </td>
- </tr>
- <tr>
- <td colspan="2">
- <button id="delall" name="delall" onclick="return delpic()" style="background: 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'],
复制代码 修改templates/default/css/common.css文件
在下面添加
- /* 后台附件选项卡 */
- #uploadbox { width: 500px; }
- #uploadbox table { border: 1px solid #CCC; border-top: none; background:#FCFFEF; width: 100%; }
- #uploadbox th { background: transparent; width: 60px; }
- .upbtntd button { padding: 5px 20px 2px 20px; background: #C3D9FF; border-color: #86B9D6; border-style: solid; border-width: 1px 1px 3px; cursor: pointer; color: #6774A8; font-weight: bold; }
- #uploadbox .tabs { height:27px; border-bottom: 1px solid #CCC; padding-left: 5px; }
- #uploadbox .tabs a { float: left; padding: 0 5px; border: 1px solid #CCC; margin-right: 5px; text-decoration: none; height: 26px; line-height: 26px; background: #FFF; }
- #uploadbox .tabs a.current { font-weight: bold; cursor: default; border-bottom: 1px solid #FFF; background: #FCFFEF; }
- #uploadbox .tabs a:hover { color: #333; background: #FCFFEF; }
- #batchpreview { background: #FFF; width: 473px; height: 300px; border: 1px solid #EEE; overflow: auto; }
- .picspace { border-bottom: 1px solid #CCC; margin: 3px; }
- .picspace img { margin: 3px 6px 3px 0; border: 3px solid #EEE; max-width: 60px; max-height: 60px; width: expression(this.width > 60 ? 60: true);; height: expression(this.width > 40 ? 40: true);; }
- #batchupload td { padding:5px; }
复制代码
ok,修改完成,测试一下吧
|