config.php
<?php
$mydbhost = ‘localhost’;//数据库服务器
$mydbuser = ‘root’;//数据库用户名
$mydbpw = ‘admin’;//数据库密码
$mydbname = ‘myclass’;//数据库名
$mydbcharset = ‘gbk’;//数据库编码,不建议修改.
$Admin_Name = ‘admin’;//管理员名称
$Admin_Pwd = ‘21232f297a57a5a743894a0e 4a801fc3′;//管理员密码
$eachpage = 5;//每页显示留言条数
$mydbhost = ‘localhost’;//数据库服务器
$mydbuser = ‘root’;//数据库用户名
$mydbpw = ‘admin’;//数据库密码
$mydbname = ‘myclass’;//数据库名
$mydbcharset = ‘gbk’;//数据库编码,不建议修改.
$Admin_Name = ‘admin’;//管理员名称
$Admin_Pwd = ‘21232f297a57a5a743894a0e
$eachpage = 5;//每页显示留言条数
//分页
$psql = “select count(*) from message”;
$sum = “<b>”;
$stail = “</b> ”;
$link = “<a href=””;
$lmid = “”>”;
$ltail = “</a> ”;
$curpage = “<a href=””;
?>
?>
function.php
<?php
class mysql{
function connect($dbhost, $dbuser, $dbpw, $dbname = ”,$dbcharset=”) {
if(!@mysql_connect($dbhost, $dbuser, $dbpw)) {
$this->show(‘Can not connect to MySQL server’);
}
if($dbname) {
$this->select_db($dbname);
}
if($this->version() > ‘4.1’) {
if($dbcharset) {
$this->query(“SET NAMES ‘”.$dbcharset.”‘”);
}
}
}
class mysql{
//
//
//
//
}
class page extends mysql{
function pagination($sql,$maxnum,$page,$maxpages,$pagepre,$ext=”){
global $sum,$stail,$link,$lmid,$ltail,$curpage;//$ext=’&class=3′
$SELF = $_SERVER[‘PHP_SELF’];
$query = $this->query($sql);
$rows = $this->fetch_array($query,MYSQL_NUM);
$totalrows = $rows[0];
$totalpages = ceil($totalrows/$maxnum);
$startnum = ($page – 1)*$maxnum;
$string = $sum.$totalrows.$stail.$sum.$page.”/”.$totalpages.$stail;
if($page != 1){
$string .= $link.$SELF.”?page=1″.$ext.$lmid.”|‹”.$ltail;
$string .= $link.$SELF.’?page=’.($page – 1).$ext.$lmid.”‹‹”.$ltail;
}
}
function html($str){
$str = get_magic_quotes_gpc()?$str:addslashes($str);
return $str;
}
}
function dehtml($str){
$str = nl2br(stripslashes($str));
return $str;
}
}
function deip($str){
$arr = explode(‘.’,$str);
$str = $arr[0].’.’.$arr[1].’.’.$arr[2].’.*’;
return $str;
}
}
$conn = new mysql();
$conn -> connect($mydbhost, $mydbuser, $mydbpw, $mydbname,$mydbcharset);
?>
$conn -> connect($mydbhost, $mydbuser, $mydbpw, $mydbname,$mydbcharset);
?>