php html转换成text文本函数
文章为各位提供一个哦,如果喜欢就行了。
<?php
if(!defined('DEDEINC'))
{
exit("Request Error!");
}
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;
}
?>
dedecms ajax 下载统计代码<?php
require_once (dirname(__FILE__) . "/include/common.inc.php");
require_once(DEDEINC."/channelunit.class.php");
$aid = (isset($aid) && is_numeric($aid)) ? $aid : 0;
$rand =mt_rand(10,80);
$query = "select count(*) as dd from #@__downloads where id='$aid'";
$row = $dsql->GetOne($query);
if($row['dd'] > 0)
{
$query = "update #@__downloads set downloads=downloads+$rand where id='$aid'";
$dsql->ExecNoneQuery($query);
}else {
$query = "insert into #@__downloads(hash,id,downloads) values('null$aid','$aid',1)";
$dsql->ExecNoneQuery($query);
}
下面是实例方法。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<script src="http://pstatic.xunlei.com/js/webThunderDetect.js"></script>
<script src="http://pstatic.xunlei.com/js/base64.js"></script>
<script language="javascript" type="text/javascript">
var xmlHttp = false;
function ajaxcreate(){
try {
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e2) {
xmlHttp = false;
}
}
if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
xmlHttp = new XMLHttpRequest();
}
if(!xmlHttp){alert('Create Xmlhttp Fail ');return false;}
}
function ajax_add(){
ajaxcreate();
var url="/ajax_down.php?aid="+encodeURI(5396)+"&rd="+Math.random();
xmlHttp.open("POST",url,true);
xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
xmlHttp.send(null);
}
</script>
<title>绿色版Apache+Php+Mysql V1.3 自动安装版_下载地址列表_网站源码下载-整站源码下载-站长常用工具下载</title>
<link href="/templets/style/search.css" rel="stylesheet" type="text/css" media="screen" />
</head>
<body>
<div class="header">
<div class="toplogo">
<h1><a href="http://down.111cn.net/">网站源码下载-整站源码下载-站长常用工具下载</a></h1>
</div>
</div>
<div class="msgbar">
<p>
<strong>软件名称:<a href='/down/soft/server/2009/0629/5396.html'>绿色版Apache+Php+Mysql V1.3 自动安装版</a></strong>
</p>
</div>
<div class="advancedsearch">
<table width="100%" border="0" align="center" cellspacing="2">
<tr>
<td height="30" bgcolor="#F2F7E6">下载地址列表:</td>
</tr>
<tr>
<td height="78"><script language="javascript" src="/js/gg_bottom.js"></script>
<a href="#" class="red" thunderHref="thunder://QUFodHRwOi8vemp0ZWxlNC5za3ljbi5jb20vZG93bi9nZ2dBUE1zZXJ2ZXIuemlwWlo=" thunderPid="85957" thunderType="" thunderResTitle="" onClick="ajax_add();return OnDownloadClick_Simple(this,2);" oncontextmenu="ThunderNetwork_SetHref(this)" >[迅雷专用下载]</a>
<script type="text/javascript"><!--
google_ad_client = "pub-6219414158063594";
/* 336x280, 创建于 09-3-29 */
google_ad_slot = "8019903307";
google_ad_width = 336;
google_ad_height = 280;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<script type="text/javascript"><!--
google_ad_client = "pub-6219414158063594";
google_ad_format = "configurable_sdo";
google_link_target = 2;
google_color_bg = "ffffff";
google_color_link = "000000";
google_color_text = "000000";
google_encoding = "GB2312";
google_ad_channel = "5161927073";
google_box_len = 40;
google_logo_pos = "left";
google_rs_pos = "below";
google_ad_height = 65;
google_ad_width = 500;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_sdo.js">
</script>
</td>
</tr>
</table>
</div>
<div class="footer">
<p class="link">
网站版权信息及免责声明
</p>
<p class="powered">
Copyright <a href="http://down.111cn.net" title="" target="_blank"><strong>down.<span>111cn.net</span></strong></a> © 2004-2008 Inc.
<script language="javascript" src="/js/count.js"></script>
</p><!-- /powered -->
</div>
<div id="tt" ></div>
</body>
</html>
本文章免费为各位朋友提供一款哦,如果你喜欢的话不防进来看看这款图片过滤正则表达试
function msubstr($str, $start, $len) {
$tmpstr = "";
$strlen = $start + $len;
for($i = 0; $i < $strlen; $i++) {
if(ord(substr($str, $i, 1)) > 0xa0) {
$tmpstr .= substr($str, $i, 2);
$i++;
} else
$tmpstr .= substr($str, $i, 1);
}
return $tmpstr;
}
//过滤图片
function img_empty($content){
$content=eregi_replace("<IMG ([a-zA-Z0-9~!& ?:"/._#=~&%]+)>","",$content);
return $content;
}
function getvis(&$pagesid,&$retime) {
global $err,$conf,$HTTP_COOKIE_VARS,$_COOKIE;
if(isset($_COOKIE['ant'])) $cot=$_COOKIE['ant'];
elseif(isset($HTTP_COOKIE_VARS['ant'])) $cot=$HTTP_COOKIE_VARS['ant'];
else $cot='';
$cos=preg_split("/x/",$cot);
$max=sizeof($cos);
for($c=0;$c<$max;$c++) {
if(strlen($cos[$c])==10) {
$id=substr($cos[$c],0,2);
eval("$id=0x$id;");
$anct[$id]=$cos[$c];
}
}
if(isset($_COOKIE['anm'])) $com=$_COOKIE['anm'];
elseif(isset($HTTP_COOKIE_VARS['anm'])) $com=$HTTP_COOKIE_VARS['anm'];
else $com='';
$cos=preg_split("/x/",$com);
$max=sizeof($cos);
for($c=0;$c<$max;$c++) {
if(strlen($cos[$c])==10) {
$id=substr($cos[$c],0,2);
eval("$id=0x$id;");
$tim=substr($cos[$c],2,8);
eval("$tim=0x$tim;");
if($tim>=$conf->mtime) $ancm[$id]=$cos[$c];
}
}
if(isset($_COOKIE['anw'])) $cow=$_COOKIE['anw'];
elseif(isset($HTTP_COOKIE_VARS['anw'])) $cow=$HTTP_COOKIE_VARS['anw'];
else $cow='';
$cos=preg_split("/x/",$cow);
$max=sizeof($cos);
for($c=0;$c<$max;$c++) {
if(strlen($cos[$c])==10) {
$id=substr($cos[$c],0,2);
eval("$id=0x$id;");
$tim=substr($cos[$c],2,8);
eval("$tim=0x$tim;");
if($tim>=$conf->wtime) $ancw[$id]=$cos[$c];
}
}
if(isset($_COOKIE['an1'])) $co1=$_COOKIE['an1'];
elseif(isset($HTTP_COOKIE_VARS['an1'])) $co1=$HTTP_COOKIE_VARS['an1'];
else $co1='';
$cos=preg_split("/x/",$co1);
$max=sizeof($cos);
for($c=0;$c<$max;$c++) {
if(strlen($cos[$c])==10) {
$id=substr($cos[$c],0,2);
eval("$id=0x$id;");
$tim=substr($cos[$c],2,8);
eval("$tim=0x$tim;");
if($tim>=$conf->dtime) $anc1[$id]=$cos[$c];
}
}
//current time in HEX
if($conf->ctime>0x7FFFFFFF) {
$t1=$conf->ctime/16;
$t2=$conf->ctime&0xF;
$ctimestr=sprintf("%07X%01X",$t1,$t2);
}
else {
$ctimestr=sprintf("%08X",$conf->ctime);
}
reset($pagesid);
while($e=each($pagesid)) {
$k=$e[0];
if(isset($anct[$k])) {
$pagesid[$k].='|0';
if(strlen($anct[$k])==10) {
$tim=substr($anct[$k],2,8);
eval("$tim=0x$tim;");
$retime[$k]=$tim;
}
}
else {
$pagesid[$k].='|1';
$anct[$k]=sprintf("%02X%s",$k,$ctimestr);
}
if(isset($ancm[$k])) $pagesid[$k].='|0';
else {
$pagesid[$k].='|1';
$ancm[$k]=sprintf("%02X%s",$k,$ctimestr);
}
if(isset($ancw[$k])) $pagesid[$k].='|0';
else {
$pagesid[$k].='|1';
$ancw[$k]=sprintf("%02X%s",$k,$ctimestr);
}
if(isset($anc1[$k])) $pagesid[$k].='|0';
else {
$pagesid[$k].='|1';
$anc1[$k]=sprintf("%02X%s",$k,$ctimestr);
}
}
$cot=join('x',$anct);
$com=join('x',$ancm);
$cow=join('x',$ancw);
$co1=join('x',$anc1);
//get path
$path=$conf->url;
$path=preg_replace("/^(http://)([^/]+)/i",'',$path);
$path.='aa.php';
//set cookie
SetCookie('ant',$cot,time()+($conf->time1*3000),$path);
SetCookie('anm',$com,time()+($conf->time1*31),$path);
SetCookie('anw',$cow,time()+($conf->time1*7),$path);
SetCookie('an1',$co1,time()+$conf->time1,$path);
}
下面这款个一个是判断输入的域名是不是合法的,然后再把http,https,ftp进行处理,分析再发送
function _scan_url()
{
$req = $this->_url;
$pos = strpos($req, '://');
$this->_protocol = strtolower(substr($req, 0, $pos));
$req = substr($req, $pos+3);
$pos = strpos($req, '/');
if($pos === false)
$pos = strlen($req);
$host = substr($req, 0, $pos);
if(strpos($host, ':') !== false)
{
list($this->_host, $this->_port) = explode(':', $host);
}
else
{
$this->_host = $host;
$this->_port = ($this->_protocol == 'https') ? 443 : 80;
}
$this->_uri = substr($req, $pos);
if($this->_uri == '')
$this->_uri = '/';
}
function cleanDomain($q,$w=0){ //整理域名 $w=1过滤www.前缀 $w=0不过滤
$q = htmlspecialchars(strtolower(trim($q)));
if(substr($q,0,7) == "http://" || substr($q,0,8) == "https://" || substr($q,0,6) == "ftp://"){
$q = str_replace("http:/","",$q);
$q = str_replace("https:/","",$q);
$q = str_replace("ftp:/","",$q);
}
if(substr($q,0,4) == "www." && $w==1) {
$q = str_replace("www.","",$q);
}
$q = trim($q,"/");
return $q;
}
相关文章
- eval函数在php中是一个函数并不是系统组件函数,我们在php.ini中的disable_functions是无法禁止它的,因这他不是一个php_function哦。 eval()针对php安全来说具有很...2016-11-25
- 在php中eval是一个函数并且不能直接禁用了,但eval函数又相当的危险了经常会出现一些问题了,今天我们就一起来看看eval函数对数组的操作 例子, <?php $data="array...2016-11-25
使用PHP+JavaScript将HTML页面转换为图片的实例分享
这篇文章主要介绍了使用PHP+JavaScript将HTML元素转换为图片的实例分享,文后结果的截图只能体现出替换的字体,也不能说将静态页面转为图片可以加快加载,只是这种做法比较interesting XD需要的朋友可以参考下...2016-04-19Python astype(np.float)函数使用方法解析
这篇文章主要介绍了Python astype(np.float)函数使用方法解析,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下...2020-06-08- 这篇文章主要介绍了Python中的imread()函数用法说明,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧...2021-03-16
- 本文主要介绍了C# 中取绝对值的函数。具有很好的参考价值。下面跟着小编一起来看下吧...2020-06-25
- 下面小编就为大家带来一篇C#学习笔记- 随机函数Random()的用法详解。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧...2020-06-25
- 在开发过程中,我们经常会将日期时间的毫秒数存放到数据库,但是它对应的时间看起来就十分不方便,我们可以使用一些函数将毫秒转换成date格式。 一、 在MySQL中,有内置的函数from_unixtime()来做相应的转换,使用如下: 复制...2014-05-31
python Matplotlib基础--如何添加文本和标注
这篇文章主要介绍了python Matplotlib基础--如何添加文本和标注,帮助大家更好的利用Matplotlib绘制图表,感兴趣的朋友可以了解下...2021-01-26- 今天小编在这里就来给美图秀秀的这一款软件的使用者们来说下把普通照片快速转换成卡通效果的教程,各位想知道具体制作步骤的使用者们,那么下面就快阿里跟着小编一起看一...2016-09-14
- 这篇文章主要介绍了Javascript类型转换的规则实例解析,涉及到javascript类型转换相关知识,对本文感兴趣的朋友一起学习吧...2016-02-27
- CREATE FUNCTION ChangeBigSmall (@ChangeMoney money) RETURNS VarChar(100) AS BEGIN Declare @String1 char(20) Declare @String2 char...2016-11-25
- 这篇文章主要介绍了C++中Sort函数详细解析,sort函数是algorithm库下的一个函数,sort函数是不稳定的,即大小相同的元素在排序后相对顺序可能发生改变...2022-08-18
Android开发中findViewById()函数用法与简化
findViewById方法在android开发中是获取页面控件的值了,有没有发现我们一个页面控件多了会反复研究写findViewById呢,下面我们一起来看它的简化方法。 Android中Fin...2016-09-20- strstr() 函数搜索一个字符串在另一个字符串中的第一次出现。该函数返回字符串的其余部分(从匹配点)。如果未找到所搜索的字符串,则返回 false。语法:strstr(string,search)参数string,必需。规定被搜索的字符串。 参数sea...2013-10-04
PHP函数分享之curl方式取得数据、模拟登陆、POST数据
废话不多说直接上代码复制代码 代码如下:/********************** curl 系列 ***********************///直接通过curl方式取得数据(包含POST、HEADER等)/* * $url: 如果非数组,则为http;如是数组,则为https * $header:...2014-06-07- Foreach 函数(PHP4/PHP5)foreach 语法结构提供了遍历数组的简单方式。foreach 仅能够应用于数组和对象,如果尝试应用于其他数据类型的变量,或者未初始化的变量将发出错误信息。...2013-09-28
- free函数是释放之前某一次malloc函数申请的空间,而且只是释放空间,并不改变指针的值。下面我们就来详细探讨下...2020-04-25
- PHP 函数 strip_tags 提供了从字符串中去除 HTML 和 PHP 标记的功能,该函数尝试返回给定的字符串 str 去除空字符、HTML 和 PHP 标记后的结果。由于 strip_tags() 无法实际验证 HTML,不完整或者破损标签将导致更多的数...2014-05-31
- 分享一个PHP加密解密的函数,此函数实现了对部分变量值的加密的功能。 加密代码如下: /* *功能:对字符串进行加密处理 *参数一:需要加密的内容 *参数二:密钥 */ function passport_encrypt($str,$key){ //加密函数 srand(...2015-10-30