<?php
//数据库连接类
class ConnDB{ var $dbtype;
var $host;
var $user;
var $pwd;
var $dbname; //构造方法
function ConnDB($dbtype,$host,$user,$pwd,$dbname){
$this->dbtype=$dbtype;
$this->host=$host;
$this->user=$user;
$this->pwd=$pwd;
$this->dbname=$dbname;
} //实现数据库的连接并返回连接对象
function GetConnId(){ if($this->dbtype=="mysql" || $this->dbtype=="mssql"){
$dsn="$this->dbtype:host=$this->host;dbname=$this->dbname";
}else{
$dsn="$this->dbtype:dbname=$this->dbname";
}
try {
$conn = new PDO($dsn, $this->user, $this->pwd); //初始化一个PDO对象,就是创建了数据库连接对象$pdo
$conn->query("set names utf8");
return $conn;
} catch (PDOException $e) {
die ("Error!: " . $e->getMessage() . "<br/>");
} }
} //数据库管理类
class AdminDB{ function ExecSQL($sqlstr,$conn){ $sqltype=strtolower(substr(trim($sqlstr),0,6));
$rs=$conn->prepare($sqlstr); //准备查询语句
$rs->execute(); //执行查询语句,并返回结果集
if($sqltype=="select"){
$array=$rs->fetchAll(PDO::FETCH_ASSOC); //获取结果集中的所有数据
if(count($array)==0 || $rs==false)
return false;
else
return $array;
}elseif ($sqltype=="update" || $sqltype=="insert" || $sqltype=="delete"){
if($rs)
return true;
else
return false;
}
}
}
//分页类
class SepPage{
var $rs;
var $pagesize;
var $nowpage;
var $array;
var $conn;
var $sqlstr;
function ShowData($sqlstr,$conn,$pagesize,$nowpage){ //定义方法
if(!isset($nowpage) || $nowpage=="") //判断变量值是否为空
$this->nowpage=1; //定义每页起始页
else
$this->nowpage=$nowpage;
$this->pagesize=$pagesize; //定义每页输出的记录数
$this->conn=$conn; //连接数据库返回的标识
$this->sqlstr=$sqlstr; //执行的查询语句
$offset=($this->nowpage-1)*$this->pagesize;
$sql=$this->sqlstr." limit $offset, $this->pagesize";
$result=$this->conn->prepare($sql); //准备查询语句
$result->execute(); //执行查询语句,并返回结果集
$this->array=$result->fetchAll(PDO::FETCH_ASSOC); //获取结果集中的所有数据
if(count($this->array)==0 || $this->array==false)
return false;
else
return $this->array;
} function ShowPage($contentname,$utits,$anothersearchstr,$anothersearchstrs,$class){
$str="";
$res=$this->conn->prepare($this->sqlstr); //准备查询语句
$res->execute(); //执行查询语句,并返回结果集
$this->array=$res->fetchAll(PDO::FETCH_ASSOC); //获取结果集中的所有数据
$record=count($this->array); //统计记录总数 $pagecount=ceil($record/$this->pagesize); //计算共有几页
$str.=$contentname."&nbsp;".$record."&nbsp;".$utits."&nbsp;每页&nbsp;".$this->pagesize."&nbsp;".$utits."&nbsp;第&nbsp;".$this->nowpage."&nbsp;页/共&nbsp;".$pagecount."&nbsp;页";
$str.="&nbsp;&nbsp;&nbsp;&nbsp;";
if($this->nowpage!=1)
$str.="<a href=".$_SERVER['PHP_SELF']."?page=1&page_type=".$anothersearchstr."&parameter2=".$anothersearchstrs." class=".$class.">首页</a>";
else
$str.="<font color='#555555'>首页</font>";
$str.="&nbsp;";
if($this->nowpage!=1)
$str.="<a href=".$_SERVER['PHP_SELF']."?page=".($this->nowpage-1)."&page_type=".$anothersearchstr."&parameter2=".$anothersearchstrs." class=".$class.">上一页</a>";
else
$str.="<font color='#555555'>上一页</font>";
$str.="&nbsp;";
if($this->nowpage!=$pagecount)
$str.="<a href=".$_SERVER['PHP_SELF']."?page=".($this->nowpage+1)."&page_type=".$anothersearchstr."&parameter2=".$anothersearchstrs." class=".$class.">下一页</a>";
else
$str.="<font color='#555555'>下一页</font>";
$str.="&nbsp;";
if($this->nowpage!=$pagecount)
$str.="<a href=".$_SERVER['PHP_SELF']."?page=".$pagecount."&page_type=".$anothersearchstr."&parameter2=".$anothersearchstrs." class=".$class.">尾页</a>";
else
$str.="<font color='#555555'>尾页</font>";
if(count($this->array)==0 || $this->array==false)
return "无数据!";
else
return $str;
}
}
//系统常用方法
class UseFun{ function UnHtml($text){
$content=(nl2br(htmlspecialchars($text)));
$content=str_replace("[strong]","<strong>",$content);
$content=str_replace("[/strong]","</strong>",$content);
$content=str_replace("[em]","<em>",$content);
$content=str_replace("[/em]","</em>",$content);
$content=str_replace("[u]","<u>",$content);
$content=str_replace("[/u]","</u>",$content); $content=str_replace("[font color=#FF0000]","<font color=#FF0000>",$content);
$content=str_replace("[font color=#00FF00]","<font color=#00FF00>",$content);
$content=str_replace("[font color=#0000FF]","<font color=#0000FF>",$content); $content=str_replace("[font face=楷体_GB2312]","<font face=楷体_GB2312>",$content);
$content=str_replace("[font face=宋体]","<font face=新宋体>",$content);
$content=str_replace("[font face=隶书]","<font face=隶书>",$content);
$content=str_replace("[/font]","</font>",$content);
//$content=str_replace(chr(32)," ",$content);
$content=str_replace("[font size=1]","<font size=1>",$content);
$content=str_replace("[font size=2]","<font size=2>",$content);
$content=str_replace("[font size=3]","<font size=3>",$content);
$content=str_replace("[font size=4]","<font size=4>",$content);
$content=str_replace("[font size=5]","<font size=5>",$content);
$content=str_replace("[font size=6]","<font size=6>",$content); $content=str_replace("[FIELDSET][LEGEND]","<FIELDSET><LEGEND>",$content);
$content=str_replace("[/LEGEND]","</LEGEND>",$content);
$content=str_replace("[/FIELDSET]","</FIELDSET>",$content);
return $content;
} } ?>

php模块参考的更多相关文章

  1. Nginx模块参考手册:HTTP核心模块

    FROM: http://blog.chinaunix.net/xmlrpc.php?r=blog/article&uid=17238776&id=2982697 这些模块默认会全部编 ...

  2. 函数的学习3——传递任意数量的实参&将函数存储在模块——参考Python编程从入门到实践

    传递任意数量的实参 形参前加一个 * ,Python会创建一个已形参为名的空元组,将所有收到的值都放到这个元组中: def make_pizza(*toppings): print("\nM ...

  3. [转载]python中的sys模块(二)

    #!/usr/bin/python # Filename: using_sys.py import sys print 'The command line arguments are:' for i ...

  4. NodeJs + mongodb模块demo

    代码比较通俗易懂,但是我还是在这个过程中浪费了不少时间,也算是看到了nodejs中异步的一个小坑.未来的坑还有很多,慢慢找坑填坑吧. 参考资料如下: 1.断言模块 : https://nodejs.o ...

  5. python3+ 模块学习 之 re

    re 模块 参考:Python3 如何优雅地使用正则表达式(详解系列) Python3 正则表达式特殊符号及用法(详细列表)    (出处: 鱼C论坛) 正则表达式 常用元字符:. ^ $ * + ? ...

  6. OFBiz进阶之HelloWorld(一)创建热部署模块

    创建热部署模块 参考文档 https://cwiki.apache.org/confluence/display/OFBIZ/OFBiz+Tutorial+-+A+Beginners+Developm ...

  7. 读Zepto源码之Callbacks模块

    Callbacks 模块并不是必备的模块,其作用是管理回调函数,为 Defferred 模块提供支持,Defferred 模块又为 Ajax 模块的 promise 风格提供支持,接下来很快就会分析到 ...

  8. 读Zepto源码之Deferred模块

    Deferred 模块也不是必备的模块,但是 ajax 模块中,要用到 promise 风格,必需引入 Deferred 模块.Deferred 也用到了上一篇文章<读Zepto源码之Callb ...

  9. 读Zepto源码之Ajax模块

    Ajax 模块也是经常会用到的模块,Ajax 模块中包含了 jsonp 的现实,和 XMLHttpRequest 的封装. 读 Zepto 源码系列文章已经放到了github上,欢迎star: rea ...

随机推荐

  1. Java Development Kit(JDK) 8 新特性(简述)

    一.接口的默认方法 Java 8允许我们给接口添加一个非抽象的方法实现,只需要使用 default关键字即可,这个特征又叫做扩展方法. 示例如下: interface Formula { calcul ...

  2. (int),Convert.ToInt32(),Int32.Parse(),Int32.TryParsed()的用法总结

    1 (int) 强制转型为整型. 当将long,float,double,decimal等类型转换成int类型时可采用这种方式. double dblNum = 20; int intDblNum = ...

  3. JavaScript-每隔5分钟执行一次ajax请求的实现方法

    个页面好像只能有一个 window.onload=function(){},所以要有多个事件,这样写就好了 window.onload=function(){ //假设这里每个五分钟执行一次test函 ...

  4. UDP编程

    一: socket编程中的几种地址 Socket编程会遇到三种地址, 都是定义的结构体(struct): Struct in_addr     {         Unsigned int s_add ...

  5. iOS之ASIHttp简单的网络请求实现

    描述: ASIHttpRequest是应用第三方库的方法,利用代码快,减少代码量,提高效率 准备工作: 一.导入第三方库ASIHttpRequest 二.会报很多的错,原因有两个,一个是要导入Xcod ...

  6. 使用Socket模拟一个简单的Webservice调用

    webservice是对socket的一个封装,让远程调用调用变得更加简单,那么使用socket究竟有多么麻烦呢?来看看. 做一个简单的天气查询: 服务端: public class SocketSe ...

  7. pnd_start_2

    试过才知道一点都不简单,虽然表现出的逻辑是错的,但是至少运行上是正确的.

  8. Abstract Factory 抽象工厂模式

    提供一个创建一些列相关或相互依赖对象的接口,而无需指定它们具体的类. 抽象工厂顾名思义就是对工厂的抽象,它提供了一组创建抽象产品对象的操作接口,我们实际使用的是抽象工厂的派生类,派生类中提供了操作的具 ...

  9. PHP的数据库 之 关闭问题

    首先,PHP由于有垃圾回收机制,所以数据库即使你不手动关闭,也有自动去关闭的机制, 这里就和操作文本流不同,文本流需要手动去关闭,不然会发生内存浪费现象 并且,PHP在同时连接多个DB的时候,连接到一 ...

  10. Css3 兼容新旧浏览器

    想想10年前用 IE6,火狐,遨游,谷歌等浏览器学习css时,那叫一个艰苦,各种hack各种抓耳挠腮,不是margin塌陷就是元素飞了... 当前借着css3这个东风,如果各大浏览器厂商能统一一下,也 ...