0830轻量级Web信息系统开发框架软件源程序代码.docx
- 文档编号:30220938
- 上传时间:2023-08-07
- 格式:DOCX
- 页数:94
- 大小:38.01KB
0830轻量级Web信息系统开发框架软件源程序代码.docx
《0830轻量级Web信息系统开发框架软件源程序代码.docx》由会员分享,可在线阅读,更多相关《0830轻量级Web信息系统开发框架软件源程序代码.docx(94页珍藏版)》请在冰豆网上搜索。
0830轻量级Web信息系统开发框架软件源程序代码
前30页
1.系统入口
1.1.唯一入口index.php
php
$t=microtime(true);
$s=memory_get_usage();
require'./cnf/config.default.php';
requireCA.'bd.class.php';
header('Content-Type:
text/html;charset='.HE);
$bd=newbd;
$html=$bd->parse();
$html->display();
include('autoback/autobackup.php');
if(file_exists(CFD.'config.'.APP.'.php'))requireCFD.'config.'.APP.'.php';
elserequireCFD.'config.index.php';
/**
系统语言文件设置
**/
if(file_exists(TD.'lang/global.php'))includeTD.'lang/global.php';
elseexit('Nogloballanguagefilehere!
');
//include_once(GA.'include/safeControl.php');
include_once(GA.'include/functions.php');//引入系统函数库
?
>
1.2.系统配置文件config.inc.php
php
session_start();
/**
系统设置
**/
ini_set("display_errors","off");
ini_set('date.timezone','Asia/Shanghai');
date_default_timezone_set("Etc/GMT-8");
/**
系统常量设置
APP应用名
APPDIR应用目录
CA控制器主目录
CD缓存目录
CHCOOKIE前缀
CDOCOOKIE路径
CPCIIKIE作用域
CRT静态HTML缓存刷新时间
CS网站隐私数据加密码
EP编辑器目录
GA公共目录
GUP上传文件保存目录
HE网站和数据库编码
MA模块目录
MP公用模块目录
MS系统对象目录
TD模板目录
UPFS文件上传限制大小
VA视图目录
WP网站访问根目录
**/
define('APP',basename($_SERVER['SCRIPT_NAME'],'.php'));
define('APPDIR',APP.'/');
define('CA','controller/');
define('CFD','cnf/');
define('CH','master_');
define('CDO','');
define('CP','/');
define('CRT',180);
define('CS','xn9dylsl012002');
define('GA','global/');
define('GCD',GA.'data/');
define('GUP',GA.'upload/');
define('HE','utf-8');
define('MA','model/');
define('MP',MA.'public/');
define('MS',MA.'system/');
define('PN',20);
define('SK','a12dsg234');
define('TIME',time());
define('VA','view/');
define('TD',VA.'default/');
define('BAKDIR',GA.'backup');
define('BAKDAY',2);//备份间隔时间
define('DELBAKDAY',60);//删除备份的天数
define('LOGDAY',60);//系统日志保留天数
define('UPFS',20480000);
$wp='http:
//'.str_replace('//','/',$_SERVER['SERVER_NAME'].dirname($_SERVER['SCRIPT_NAME'])).'/';
define('WP',str_replace('\\','',$wp));
require_once('systemLoad.php');
?
>
1.3.核心控制器bd.action.php
php
classbd
{
public$obj=array();
publicfunctionmake($obj)
{
$obj='g'.$obj;
if(!
isset($this->obj[$obj]))
{
if(file_exists(MA.APPDIR.$obj.'.class.php'))
{
includeMA.APPDIR.$obj.'.class.php';
}
elseif(file_exists(MP.$obj.'.class.php'))
{
includeMP.$obj.'.class.php';
}
elseif(file_exists(MS.$obj.'.class.php'))
{
includeMS.$obj.'.class.php';
}
else
{
$report=$this->make("report");
$report->showError($obj.ERS1);
}
$this->obj[$obj]=new$obj($this);
}
return$this->obj[$obj];
}
publicfunctionwake($obj,$par=NULL)
{
if(!
isset($this->obj['w_'.$obj]))
{
if(class_exists($obj))
{
if($par)$this->obj['w_'.$obj]=new$obj($par);
else$this->obj['w_'.$obj]=new$obj();
}
elseecho'error';
}
return$this->obj['w_'.$obj];
}
publicfunctionparse()
{
$ev=$this->make('ev');
$html=$ev->url[1];
if(!
$html)$html='index';
if(file_exists(CA.APPDIR.$html.'.action.php'))
{
includeCA.APPDIR.'ginkgo.action.php';
if($html=='ginkgo')$html='index';
includeCA.APPDIR.$html.'.action.php';
returnnew$html($this);
}
else
{
$report=$this->make("report");
$report->showError($html.ERS2);
}
}
}
?
>
2.模型
2.1.CRUD封装gdb.class.php
php
classgdb
{
private$queryid=0;
private$linkid=0;
public$q=1;
public$bd;
function__construct(&$bd)
{
$this->bd=$bd;
}
function__destruct()
{
//echo$this->q;
}
functiongetVersion()
{
returnmysql_get_server_info($this->linkid);
}
functionconnect($host=DH,$dbuser=DU,$password=DP,$dbname=DB,$dbcode=HE)
{
$dbcode=str_replace("-","",$dbcode);
//连接数据库
if(!
$this->linkid)
{
$this->linkid=mysql_connect($host,$dbuser,$password)ordie($this->bd->make('report')->showError(ERS3));
}
//设置编码
$version=$this->getVersion();
if($version>='4.0.1')
{
mysql_query("SETcharacter_set_connection='{$dbcode}',character_set_results='{$dbcode}',character_set_client=binary",$this->linkid);
if($version>='5.0.1')
{
mysql_query("SETsql_mode=''",$this->linkid);
}
}
else$this->bd->make('report')->showError(ERS2);
mysql_select_db($dbname,$this->linkid);
}
functionexec($sql)
{
$this->query($sql);
/**
if(mysql_errno())
{
echo$sql;
echo"
";
echomysql_error();
exit();
}
**/
returnmysql_affected_rows($this->linkid);
}
functionquery($sql)
{
if(!
$this->linkid)$this->connect();
$this->q++;
//if($this->queryid)mysqli_free_result($this->queryid);
$this->queryid=mysql_query($sql);
$this->lastSql=$sql;
if(mysql_errno($this->linkid))returnfalse;
}
functionfetch($type=0,$sql=NULL,$position=0)
{
if($sql)$this->query($sql);
if(!
mysql_num_rows($this->queryid))returnfalse;
if($position)mysql_data_seek($this->queryid,$position);
if($type==1)returnmysql_fetch_assoc($this->queryid);
elseif($type==2)returnmysql_fetch_object($this->queryid);
elsereturnmysql_fetch_array($this->queryid);
}
functionfetchAll($type=0,$sql=NULL)
{
$rs=array();
if($sql)$this->query($sql);
while($tmp=$this->fetch($type))
{
$rs[]=$tmp;
}
return$rs;
}
functionlastInsertId()
{
returnmysql_insert_id($this->linkid);
}
}
?
>
2.2.数据缓存gdbca.class.php
php
//在ca不能执行时,将缓存写入数据库
classgdbca
{
public$bd;
private$cache=array();
publicfunction__construct(&$bd)
{
$this->bd=$bd;
}
publicfunctionreadCache($cache,$dir='ginkgo')
{
$f=md5($dir.'/'.$cache);
if(isset($this->cache[$f]))returnunserialize(base64_decode($this->cache[$f]['cachecontent']));
else
{
$db=&$this->bd->make('db');
$sql="SELECT*FROM`".DTH."cache`WHEREcacheid='{$f}'";
$r=$db->fetch
(1);
$this->cache[$f]=$r;
if(isset($r['cachecontent']))
returnunserialize(base64_decode($r['cachecontent']));
elsereturnfalse;
}
}
publicfunctionwriteCache($cache,$content,$dir='ginkgo')
{
$f=md5($dir.'/'.$cache);
$time=TIME;
$db=&$this->bd->make('db');
$content=base64_encode(serialize($content));
$sql="REPLACEINTO`".DTH."cache`(`cacheid`,`cachecontent`,`cachetime`,`cachetype`)VALUES('{$f}','{$content}','{$time}','{$dir}')";
$db->exec($sql);
return$db->lastInsertId();
}
publicfunctionisTimeOut($cache,$time=300,$dir='ginkgo')
{
$f=md5($dir.'/'.$cache);
if(isset($this->cache[$f])&&is_array($this->cache[$f]))returnfalse;
else
{
$db=&$this->bd->make('db');
$sql="SELECT*FROM`".DTH."cache`WHEREcacheid='{$f}'";
$db->query($sql);
$r=$db->fetch
(1);
if(isset($r['cachetime']))
{
$this->cache[$f]=$r;
if(time()-$r['cachetime']>$time)returntrue;
elsereturnfalse;
}
elsereturntrue;
}
}
publicfunctionremoveCache($cache,$dir='ginkgo')
{
$f=md5($dir.'/'.$cache);
$db=&$this->bd->make('db');
$sql="DELETEFROM`".DTH."cache`WHEREcacheid='{$f}'";
$db->exec($sql);
returntrue;
}
publicfunctionremoveCacheByDir($dir='ginkgo')
{
$db=&$this->bd->make('db');
$sql="DELETEFROM`".DTH."cache`WHEREcachetype='{$dir}'";
$db->exec($sql);
returntrue;
}
}
?
>
2.3.缓存处理gca.class.php
php
//缓存
classgca
{
public$bd;
publicfunction__construct(&$bd)
{
$this->bd=$bd;
}
/**
*读取缓存内容,$cache缓存文件名
*/
publicfunctionreadCache($cache,$dir='system')
{
$fl=&$this->bd->make('fl');
$f=GCD.$dir.'/'.$cache.'.cache';
if(file_exists($f))returnunserialize($fl->readFile($f));
elsereturnfalse;
}
/**
*写入缓存
*/
publicfunctionwriteCache($cache,$content,$dir='system')
{
$fl=&$this->bd->make('fl');
if(is_dir(GCD.$dir))$fl->mdir(GCD.$dir);
$f=GCD.$dir.'/'.$cache.'.cache';
return$fl->writeFile($f,serialize($content));
}
/**
*判断缓存是否过期$time秒
*/
publicfunctionisTimeOut($cache,$time=300,$dir='system')
{
if(!
$time)returntrue;
$f=GCD.$dir.'/'.$cache.'.cache';
if((!
file_exists($f))||(time()-filemtime($f)>$time))returntrue;
elsereturnfalse;
}
/**
*删除指定缓存
*/
publicfunctionremoveCache($cache,$dir='system')
{
$f=GCD.$dir.'/'.$cache.'.cache';
if((file_exists($f)))unlink($f);
}
publicfunctionremoveCacheByDir($dir='system')
{
$this->bd->make('fl')->delDir(GCD.$dir.'/');
returntrue;
}
}
?
>
2.4.输入数据统一处理gev.class.php
php
/**
*@abstract:
处理POST,GET,SESSION,COOKIE信息
*/
classgev
{
public$cookie;
public$post;
public$get;
public$file;
public$url;//url参数数组
public$bd;
private$e;
//解析地址
functionparseUrl()
{
if(isset($_SERVER['PATH_INFO']))returnexplode('/',$_SERVER['PATH_INFO']);
elsereturnfalse;
}
//返回GET数据,参数为数组键值对应$_REQUEST
functionget($par)
{
if(isset($this->get[$par]))return$this->get[$par];
elsereturnfalse;
}
//返回POST数据,参数为数组键值对应$_POST
functionpost($par)
{
//print_r($this->post);
if(isset($this->post[$par]))return$this->post[$par];
elsereturnfalse;
}
//返回URL数据,参数为数组键值注意:
xxx.php后面每个斜线是一个参数$par=0即第一个斜线后的参数
functionurl($par)
{
if(isset($this->url[$par]))return$this->url[$par];
elsereturnfalse;
}
//设置COOKIE值
functionsetCookie($name,$value,$time=3600)
{
if($time)$time=TIME+$time;
else$time=0;
if(CDO)setCookie(CH.$name,$value,$time,CP,CDO);
elsesetCookie(CH.$name,$value,$time,CP);
}
//返回COOKIE值
functiongetCookie($par,$nohead=0)
{
if(isset($this->cookie[CH.$par]))return$this->cookie[CH.$par];
elseif(isset($this->cookie[$par])&&$nohead)return$this->cookie[$par];
elsereturnfalse;
}
//获取POST来的文件信息$par是文件域的名字
functiongetFile($par)
{
if(isset($thi
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 0830 轻量级 Web 信息系统 开发 框架 软件 源程序 代码
![提示](https://static.bdocx.com/images/bang_tan.gif)