声明:此文系舞林cuzn(www.wulinlw.org)原创稿件,转载请保留版权
【DEDE】过滤函数
Continue Read../* * $rptype = 0 表示仅替换 html标记 * $rptype = 1 表示替换 html标记同时去除连续空白字符 * $rptype = 2 表示替换 html标记同时去除所有空白字符 * $rptype = -1 表示仅替换 html危险的标记 */ function HtmlReplace($str,$rptype=0){ $str = stripslashes($str); if($rptype==0) { $str = htmlspecialchars($str); } else if($rptype==1) { $str = htmlspecialchars($str); $str = str_replace(" ",' ',$str); $str = ereg_replace("[\r\n\t ]{1,}",' ',$str); } else if($rptype==2) { $str = htmlspecialchars($str); $str = str_replace(" ",'',$str); $str = ereg_replace("[\r\n\t ]",'',$str); } else if($rptype==3){ $str = $this->SpHtml2Text($str); } else { $str = ereg_replace("[\r\n\t ]{1,}",' ',$str); $str = eregi_replace('script','script',$str); $str = eregi_replace("<[/]{0,1}(link|meta|ifr|fra)[^>]*>",'',$str); } return addslashes($str); } function SpHtml2Text($str) { $str = preg_replace("/<sty(.*)\\/style>|<scr(.*)\\/script>|<!--(.*)-->/isU","",$str); $alltext = ""; $start = 1; for($i=0;$i<strlen($str);$i++) { if($start==0 && $str[$i]==">") { $start = 1; } else if($start==1) { if($str[$i]=="<") { $start = 0; $alltext .= " "; } else if(ord($str[$i])>31) { $alltext .= $str[$i]; } } } $alltext = str_replace(" "," ",$alltext); $alltext = preg_replace("/&([^;&]*)(;|&)/","",$alltext); $alltext = preg_replace("/[ ]+/s"," ",$alltext); return $alltext; }
声明:此文系舞林cuzn(www.wulinlw.org)原创稿件,转载请保留版权
【DEDE】dede的弹窗跳转。感觉不错就粘出来了
Continue Read..function ShowMsg($msg,$gourl,$onlymsg=0,$limittime=0)
if($limittime==0) $litime = 5000;
$gourl = "javascript:window.close();";
}
声明:此文系舞林cuzn(www.wulinlw.org)原创稿件,转载请保留版权
【DEDE】加拼音排序
Continue Read..首先数据库里面没有记录当前数据的拼音。。。根据dede自带的函数和自己写的函数来实现效果
<?php function array_sort($arr,$keys,$type='asc'){ $keysvalue = $new_array = array(); foreach ($arr as $k=>$v){ $keysvalue[$k] = $v[$keys]; } if($type == 'asc'){ asort($keysvalue); }else{ arsort($keysvalue); } reset($keysvalue); foreach ($keysvalue as $k=>$v){ $new_array[$k] = $arr[$k]; } return $new_array; } $i = 1 ; foreach($blockValue as $key => $v){ $blockValue[$i]['pinyin'] = ucfirst(substr(GetPinyin($v['BuildName']),0,1)); $blockValue[$i]['N_buildname'] = $blockValue[$i]['pinyin'] . '-' . $v['BuildName']; $i++; } $N_blockValue = array_sort($blockValue,'pinyin'); var_dump($N_blockValue); ?>
内部函数
function GetPinyin($str,$ishead=0,$isclose=1)
{
global $cfg_soft_lang;
if(!function_exists('SpGetPinyin'))
{
require_once(DEDEINC."/inc/inc_fun_funAdmin.php");//下面函数 SpGetPinyin
}
if($cfg_soft_lang=='utf-8')
{
return SpGetPinyin(utf82gb($str),$ishead,$isclose);
}
else
{
return SpGetPinyin($str,$ishead,$isclose);
}
}
function SpGetPinyin($str,$ishead=0,$isclose=1)
{
global $pinyins;
$restr = '';
$str = trim($str);
$slen = strlen($str);
if($slen<2)
{
return $str;
}
if(count($pinyins)==0)
{
$fp = fopen(DEDEINC.'/data/pinyin.dat','r');
while(!feof($fp))
{
$line = trim(fgets($fp));
$pinyins[$line[0].$line[1]] = substr($line,3,strlen($line)-3);
}
fclose($fp);
}
for($i=0;$i<$slen;$i++)
{
if(ord($str[$i])>0x80)
{
$c = $str[$i].$str[$i+1];
$i++;
if(isset($pinyins[$c]))
{
if($ishead==0)
{
$restr .= $pinyins[$c];
}
else
{
$restr .= $pinyins[$c][0];
}
}else
{
$restr .= "_";
}
}else if( eregi("[a-z0-9]",$str[$i]) )
{
$restr .= $str[$i];
}
else
{
$restr .= "_";
}
}
if($isclose==0)
{
unset($pinyins);
}
return $restr;
}
function SpGetPinyin($str,$ishead=0,$isclose=1)
{
global $pinyins;
$restr = '';
$str = trim($str);
$slen = strlen($str);
if($slen<2)
{
return $str;
}
if(count($pinyins)==0)
{
$fp = fopen(DEDEINC.'/data/pinyin.dat','r');//见插件
while(!feof($fp))
{
$line = trim(fgets($fp));
$pinyins[$line[0].$line[1]] = substr($line,3,strlen($line)-3);
}
fclose($fp);
}
for($i=0;$i<$slen;$i++)
{
if(ord($str[$i])>0x80)
{
$c = $str[$i].$str[$i+1];
$i++;
if(isset($pinyins[$c]))
{
if($ishead==0)
{
$restr .= $pinyins[$c];
}
else
{
$restr .= $pinyins[$c][0];
}
}else
{
$restr .= "_";
}
}else if( eregi("[a-z0-9]",$str[$i]) )
{
$restr .= $str[$i];
}
else
{
$restr .= "_";
}
}
if($isclose==0)
{
unset($pinyins);
}
return $restr;
}
声明:此文系舞林cuzn(www.wulinlw.org)原创稿件,转载请保留版权
【DEDE】dede分页css集合
Continue Read..声明:此文系舞林cuzn(www.wulinlw.org)原创稿件,转载请保留版权
【DEDE】生成新闻时.对该新闻进行IP限制
Continue Read..接了个ZF网站,其中有一个功能是需要对新闻进行IP限制的...你们懂的..废话就不说了..直接上代码
首先找到添加和就改新闻的地方加上
在/dede/templets下面
article_add.htm,article_edit.htm二个文件
分别加入
<tr>
<td height="24" colspan="5" class="bline">
<table width="800" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="90"> IP限制:</td>
<td width="449"><textarea name="xzip" rows="5" id="xzip" style="width:80%;height:50px"><?php echo $xzip; ?></textarea></td>
<td width="261"></td>
</tr>
<tr><td width="800" colspan="3" style="color: red">(格式:192.168.1.1-192.168.1.10,202.10.3.214.1-202.10.3.215.230 多个用半角逗号隔开)</td></tr>
</table>
</td>
</tr>
<tr>
<td height="24" colspan="5" class="bline">
<table width="800" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="90"> IP限制:</td>
<td width="449"><textarea name="xzip" rows="5" id="xzip" style="width:80%;height:50px"><?php echo $arcRow["xzip"]; ?></textarea></td>
<td width="261"></td>
</tr>
<tr><td width="800" colspan="3" style="color: red">(格式:192.168.1.1-192.168.1.10,202.10.3.214.1-202.10.3.215.230 多个用半角逗号隔开)</td></tr>
</table>
</td>
</tr>
加的位置你们自己看着办....
然后在dede_archives表添加一个字段xzip text类型
这样就可以开始添加能通过的ip端了
然后在生成模板的地方
这里可以看到文章模板是自己写的
文章生成的规则是php 生成的是php文件
这样生成出来的文件就可以执行php
这里我们来看下文章模板里面怎么写
直接在顶部添加
<?php
require_once '/../../../../../include/common.inc.php';
$ip = $_SERVER["REMOTE_ADDR"];
$geturl=str_replace('.php','',$_SERVER['REQUEST_URI']);
$idArr = explode("/",$geturl);
$id = $idArr[count($idArr)-1];
$row=$dsql->GetOne("SELECT * FROM dede_archives where id = $id ");
$ipArr = explode(",",$row['xzip']);
$num = 0;
foreach($ipArr as $k=>$v){
$ipstr = explode("-",$v);
$qip = explode(".",$ipstr[0]);
$hip = explode(".",$ipstr[1]);
$dip = explode(".",$ip);
if($dip[0] >= $qip[0] && $dip[0] <= $hip[0]){
if($dip[1] >= $qip[1] && $dip[1] <= $hip[1]){
if($dip[2] >= $qip[2] && $dip[2] <= $hip[2]){
if($dip[3] >= $qip[3] && $dip[3] <= $hip[3]){
$num = $num+1;
}
}
}
}
}
if($num == 0 ){
ShowMsg("IP限制,无权访问!","/index.php");
exit();
}
?>
这里要注意...必须写<?php ?> 而不能用dede自带的标签
因为生成之后写的什么就生成什么
比如写{dede:php}{/dede:php} 那么他直接生成这句..不解析的
所以要写<?php ?>
这样..这整个过程就算写好了
本文章原创...转载请注明........http://www.wulinlw.org/?post=193 谢谢
声明:此文系舞林cuzn(www.wulinlw.org)原创稿件,转载请保留版权