dede5.7织梦后台广告插件增加图片上传功能

来源:互联网 发布:全球云计算开源峰会 编辑:程序博客网 时间:2024/05/16 09:05

跟大家分享下给dede织梦广告插件增加图片上传功能的方法。


共需要修改四个文件。

一、打开文件/dede/ad_add.php文件,找到代码:

  1. $normbody = "<a href=\"{$link}\"><img src=\"{$normbody['url']}\"$width $height border=\"0\" /></a>";

修改为:

  1. $normbody = "<a href=\"{$link}\" id=\"qyuef\"><img src=\"{$pic}\"$width $height border=\"0\" /></a>";

二、打开文件/dede/ad_edit.php文件,找到代码:

  1. $endtime = GetMkTime($endtime);

在下方加入代码:

  1. if($img=="qyuefimg"){

  2.    $normbody = "<a href=\"{$piclink}\" id=\"qyuef\"><img src=\"{$pic}\"  border=\"0\" /></a>";

  3.    }

三、打开文件/dede/templets/ad_add.htm文件,在头部<head></head>之间增加下方代码:

  1. <script language="javascript" src="../include/js/dedeajax2.js"></script>

  2. <script language='javascript' src="js/main.js"></script>

找到代码:

  1. <input type="text" size="40" name="normbody[url]" value="" class='iptxt'/>

修改为:

  1. <input type="text" size="40" name="pic" id="pic" value="" class='iptxt'/>

  2. <input type="button" name="Submit" value="浏览..." style="width:70px" onClick="SelectImage('form1.pic','');">

四、打开文件/dede/templets/ad_edit.htm文件,在头部<head></head>之间增加下方代码:

  1. <script language="javascript" src="../include/js/dedeajax2.js"></script>

  2. <script language='javascript' src="js/main.js"></script>

找到代码:

  1. <tr>

  2.  <td height="80" align="center">正常显示内容:</td>

  3.  <td width="76%"><textarea name="normbody" rows="10" id="normbody" style="width:80%;height:100"><?php echo htmlspecialchars(stripslashes($row['normbody']))?></textarea></td>

  4.  <td width="9%">&nbsp;</td>

  5. </tr>

修改为:

<tr>
<td height="80" align="center">正常显示内容:</td>
<td width="76%">
<?php   
if(strstr($row['normbody'],'id="qyuef"'))
{
$pat = '/<a[^>]*?\s*href=\"(.*?)\"(.*?)>(.*?)<\/a>/i';
preg_match_all($pat,$row['normbody'], $m);
$piclink=$m[1][0];
$pic=$m[3][0];
$pattern="/<[img|IMG].*?src=[\'|\"](.*?(?:[\.gif|\.jpg]))[\'|\"].*?[\/]?>/"; 
preg_match_all($pattern,$pic,$match); 
$qyuefpic=$match[1][0]
?>
<input type="hidden" size="40" name="img" id="img" value="qyuefimg" class='iptxt'/>
<input type="text" size="40" name="pic" id="pic" value="<?php echo $qyuefpic?>" class='iptxt'/>
<input type="button" name="Submit" value="浏览..." style="width:70px"  onClick="SelectImage('form1.pic','');"></span>
<tr>
<td height="80" align="center">图片链接:</td>
<td><input type="text" size="40" name="piclink" id="piclink" value="<?php echo $piclink?>" class='iptxt'/></td>
<td>&nbsp;</td>
</tr>
<?php
}else{
?>
<textarea name="normbody" rows="10" id="normbody" style="width:80%;height:100"><?php echo $row['normbody']?></textarea>
<?php
}
?>
 

到此,全部修改完毕。


0 0
原创粉丝点击