ecshop没有上传其它附件的功能.比如rar,doc文档等.可以通过万能的广告来实现,只有增加功能. 暂时没有编辑功能
一,修改admin\templates\ads_info.htm,18行上增加一句
<span style="font-family: monospace; white-space: pre; background-color: rgb(240, 240, 240);"> {if $action eq "add"} <tr> <td class="label">{$lang.media_type}</td> <td> <select name="media_type" onchange="showMedia(this.value)"> <option value='0'>{$lang.ad_img}</option> <option value='1'>{$lang.ad_flash}</option> <option value='2'>{$lang.ad_html}</option> <option value='3'>{$lang.ad_text}</option> <option value='4'>其它后缀的文件</option> </select> </td></span>
然后, 在120行左右增加这一句
{if $ads.media_type eq 4 OR $action eq "add"}
<tbody id="4" style="{if $ads.media_type neq 4 OR $action eq 'add'}display:none{/if}">
<tr>
<td class="label">
其它类型文件</td>
<td>
<input type='file' name='upfile_other' size='35' />
<br /><span class="notice-span" style="display:block;color:red" >注意,这里可以上传任何后缀的文件,比如rar,doc文档,docx,ppt等,<br/>但文件名称中只能使用用英文字母及下划线,比如word_2015_help.doc这种形式<br/>如果上传文件与原上传的文件重名,原文件将会被替换.</span>
</td>
</tr>
</tbody>
{/if}
最下面的js增加一个数组成员
var MediaList = new Array('0', '1', '2', '3','4');
二,修改admin/ads.php
在238行左右增加这一段
/* 新增,如果添加的广告是其它后缀文件 */
elseif ($_POST['media_type'] == '4')
{
if ((isset($_FILES['upfile_other']['error']) && $_FILES['upfile_other']['error'] == 0) || (!isset($_FILES['upfile_other']['error']) && isset($_FILES['upfile_other']['tmp_name']) && $_FILES['upfile_other']['tmp_name'] != 'none'))
{
/* 生成文件名 */
// $urlstr = date('Ymd');
// for ($i = 0; $i < 6; $i++)
// {
// $urlstr .= chr(mt_rand(97, 122));
// }
$source_file = $_FILES['upfile_other']['tmp_name'];
$target = ROOT_PATH . DATA_DIR . '/afficheimg/';
$file_name = $_FILES['upfile_other']['name'];
if (!move_upload_file($source_file, $target.$file_name))
{
$link[] = array('text' => $_LANG['go_back'], 'href' => 'javascript:history.back(-1)');
sys_msg($_LANG['upfile_error'], 0, $link);
}
else
{
$ad_code = $file_name;
}
}
if (((isset($_FILES['upfile_other']['error']) && $_FILES['upfile_other']['error'] > 0) || (!isset($_FILES['upfile_other']['error']) && isset($_FILES['upfile_other']['tmp_name']) && $_FILES['upfile_other']['tmp_name'] == 'none')) && empty($_POST['other_url']))
{
$link[] = array('text' => $_LANG['go_back'], 'href' => 'javascript:history.back(-1)');
sys_msg('文件不能为空', 0, $link);
}
}
最下面的函数function get_adslist()修改下
.$rows['type'] .= ($rows['media_type'] == 3) ? $GLOBALS['_LANG']['ad_text'] : '';
$rows['type'] .= ($rows['media_type'] == 4) ? '其它后缀文件' : '';