php公用函数列表[正则]


Posted in PHP onFebruary 22, 2007
<?php 
/********************************************************************* 
* 公用函数列表 
* ubb,getip,GoIn,goback,IsInt,InString 
* OurHome:http://iwind.org 
* http://10.13.31.90/~coldwind 
*  
* */ 
/////////////////ubb支持代码函数//////////////////////////// 
function ubb($Text) {  
  $Text=trim($Text); 
  $Text=htmlspecialchars($Text);   
  $Text=ereg_replace("\n","<br>",$Text);  
  $Text=preg_replace("/\\t/is","  ",$Text);  
  $Text=preg_replace("/\[h1\](.+?)\[\/h1\]/is","<h1>\\1</h1>",$Text);  
  $Text=preg_replace("/\[h2\](.+?)\[\/h2\]/is","<h2>\\1</h2>",$Text);  
  $Text=preg_replace("/\[h3\](.+?)\[\/h3\]/is","<h3>\\1</h3>",$Text);  
  $Text=preg_replace("/\[h4\](.+?)\[\/h4\]/is","<h4>\\1</h4>",$Text);  
  $Text=preg_replace("/\[h5\](.+?)\[\/h5\]/is","<h5>\\1</h5>",$Text);  
  $Text=preg_replace("/\[h6\](.+?)\[\/h6\]/is","<h6>\\1</h6>",$Text);  
  $Text=preg_replace("/\[center\](.+?)\[\/center\]/is","<center>\\1</center>",$Text);  
  $Text=preg_replace("/\[url\](http:\/\/.+?)\[\/url\]/is","<a href=\\1>\\1</a>",$Text);  
  $Text=preg_replace("/\[url\](.+?)\[\/url\]/is","<a href=\"http://\\1\">http://\\1</a>",$Text);  
  $Text=preg_replace("/\[url=(http:\/\/.+?)\](.*)\[\/url\]/is","<a href=\\1>\\2</a>",$Text);  
  $Text=preg_replace("/\[url=(.+?)\](.*)\[\/url\]/is","<a href=http://\\1>\\2</a>",$Text);  
  $Text=preg_replace("/\[img\](.+?)\[\/img\]/is","<img src=\\1>",$Text);  
  $Text=preg_replace("/\[color=(.+?)\](.+?)\[\/color\]/is","<font color=\\1>\\2</font>",$Text);  
  $Text=preg_replace("/\[size=(.+?)\](.+?)\[\/size\]/is","<font size=\\1>\\2</font>",$Text);  
  $Text=preg_replace("/\[sup\](.+?)\[\/sup\]/is","<sup>\\1</sup>",$Text);  
  $Text=preg_replace("/\[sub\](.+?)\[\/sub\]/is","<sub>\\1</sub>",$Text);  
  $Text=preg_replace("/\[pre\](.+?)\[\/pre\]/is","<pre>\\1</pre>",$Text);  
  $Text=preg_replace("/\[email\](.+?)\[\/email\]/is","<a href=\\1>\\1</a>",$Text);  
  $Text=preg_replace("/\[i\](.+?)\[\/i\]/is","<i>\\1</i>",$Text);  
  $Text=preg_replace("/\[b\](.+?)\[\/b\]/is","<b>\\1</b>",$Text);  
  $Text=preg_replace("/\[quote\](.+?)\[\/quote\]/is","<blockquote><font size='1' face='Courier New'>quote:</font><hr>\\1<hr></blockquote>", $Text);  
  $Text=preg_replace("/\[code\](.+?)\[\/code\]/is","<blockquote><font size='1' face='Times New Roman'>code:</font><hr color='lightblue'><i>\\1</i><hr color='lightblue'></blockquote>", $Text);  
  $Text=preg_replace("/\[sig\](.+?)\[\/sig\]/is","<div style='text-align: left; color: darkgreen; margin-left: 5%'><br><br>--------------------------<br>\\1<br>--------------------------</div>", $Text);  
  return $Text;  
} ////////////////取得浏览者的ip地址///////////////////////////// 
function getip() {  
   $IP=getenv('REMOTE_ADDR');  
   $IP_ = getenv('HTTP_X_FORWARDED_FOR');  
   if (($IP_ != "") && ($IP_ != "unknown")) $IP=$IP_;  
   return $IP;  
}  
function goback($num,$saying){ 
echo"<table align=\"center\"><tr><td><a href=\"javascript:history.go(-1)\">$saying</a>"; 
} 
///////////////////判断字符串中是否含有array中的某一值///////////////// 
function InString($array,$string){ 
  while(list(,$value)=each($array)){ 
   if(eregi($value,$string)){ 
   return true; 
   exit; 
  } 
  } 
} 
////////////////////链接到某一页面/////////////////////////////////////// 
function GoIn($addr,$saying){ 
echo"<table align=\"center\"><tr><td><a href=\"$addr\">$saying</a></td></tr></table>"; 
} 
////////////////////JS返回////////////////////////////////////////////// 
function IsInt($string){ 
  if(ereg("^[0-9]{0,}$",$string)){ 
  return true; 
  } 
   else { 
  return false; 
  } 
} 
?>
PHP 相关文章推荐
Excel数据导入Mysql数据库的实现代码
Jun 05 PHP
php 魔术函数使用说明
Feb 21 PHP
php中url传递中文字符,特殊危险字符的解决方法
Aug 17 PHP
调试PHP程序的多种方法介绍
Nov 06 PHP
php发送邮件的问题详解
Jun 22 PHP
详解PHP中的null合并运算符
Dec 30 PHP
PHP实现登录搜狐广告获取广告联盟数据的方法【附demo源码】
Oct 14 PHP
PHP操作MongoDB实现增删改查功能【附php7操作MongoDB方法】
Apr 24 PHP
PHP实现负载均衡session共享redis缓存操作示例
Aug 22 PHP
PHP INT类型在内存中占字节详解
Jul 20 PHP
Yii框架布局文件的动态切换操作示例
Nov 11 PHP
分享8个Laravel模型时间戳使用技巧小结
Feb 12 PHP
发布一个用PHP fsockopen写的HTTP下载的类
Feb 22 #PHP
隐藏X-Space个人空间下方版权方法隐藏X-Space个人空间标题隐藏X-Space个人空间管理版权方法
Feb 22 #PHP
excellent!――ASCII Art(由目标图象生成ascii)
Feb 20 #PHP
珊瑚虫IP库浅析
Feb 15 #PHP
PHP中HTTP方式下的Gzip压缩传输方法举偶
Feb 15 #PHP
PHP+.htaccess实现全站静态HTML文件GZIP压缩传输(一)
Feb 15 #PHP
php调用mysql存储过程
Feb 14 #PHP
You might like
探讨如何在php168_cms中提取验证码
2013/06/08 PHP
基于PHP实现栈数据结构和括号匹配算法示例
2017/08/10 PHP
bcastr2.0 通用的图片浏览器
2006/11/22 Javascript
Backbone.js的一些使用技巧
2015/07/01 Javascript
JavaScript编写推箱子游戏
2015/07/07 Javascript
jQuery EasyUi实战教程之布局篇
2016/01/26 Javascript
jQuery插件ImageDrawer.js实现动态绘制图片动画(附源码下载)
2016/02/25 Javascript
一波JavaScript日期判断脚本分享
2016/03/06 Javascript
jQuery短信验证倒计时功能实现方法详解
2016/05/25 Javascript
Node.js实现文件上传
2016/07/05 Javascript
JSONP和批量操作功能的实现方法
2016/08/21 Javascript
8 行 Node.js 代码实现代理服务器
2016/12/05 Javascript
微信小程序开发(一) 微信登录流程详解
2017/01/11 Javascript
angular2 ng build部署后base文件路径问题详细解答
2017/07/15 Javascript
jQuery Ajax 实现分页 kkpager插件实例代码
2017/08/10 jQuery
vue-router权限控制(简单方式)
2018/10/29 Javascript
Nodejs监控事件循环异常示例详解
2019/09/22 NodeJs
vue实现pdf文档在线预览功能
2019/11/26 Javascript
vue 对axios get pust put delete封装的实例代码
2020/01/05 Javascript
vue学习笔记之给组件绑定原生事件操作示例
2020/02/27 Javascript
[02:52]DOTA2新手基础教程 米波
2014/01/21 DOTA
[02:15]2014DOTA2国际邀请赛 专访LGD.lin小兔子是大腿
2014/07/14 DOTA
python脚本实现xls(xlsx)转成csv
2016/04/10 Python
使用Python读写及压缩和解压缩文件的示例
2016/07/08 Python
在PyCharm中批量查找及替换的方法
2019/01/20 Python
Python操作Sqlite正确实现方法解析
2020/02/05 Python
Python Json数据文件操作原理解析
2020/05/09 Python
BSTN意大利:德国街头和运动文化高品质商店
2020/12/22 全球购物
项目经理岗位职责
2013/11/11 职场文书
个人生活学习自我评价范文
2013/11/26 职场文书
社区网格化管理实施方案
2014/03/21 职场文书
临床医师个人自我评价
2014/04/06 职场文书
培训讲师岗位职责
2014/04/13 职场文书
工程造价专业求职信
2014/07/17 职场文书
信访工作个人总结
2015/03/03 职场文书
高中议论文(范文2篇)
2019/08/19 职场文书