function cache_common()
{
global $db;
$data = array();
$result = $db->query("SELECT `module`,`name`,`path`,`url`,`iscore`,`version` FROM `".DB_PRE."module` WHERE `disabled`=0");
//取出模块表中的基本数据,module 为module的英文名,name为中文名,path为它的所在目录,url和path数据一样子,也是表示目录,iscore判断是否为内置核心模块,version为版本号
while($r = $db->fetch_array($result))
{
if(!$r['path']) $r['path'] = $r['module'] == 'phpcms' ? '' : $r['module'].'/'; //设置模块当没有指定路径时,指向phpcms
if(!$r['url']) $r['url'] = $r['module'] == 'phpcms' ? '' : $r['module'].'/'; // //设置模块当没有指定路径时,指向url
$data[$r['module']] = $r;//value=array $r
}
$db->free_result($result);
$CACHE['MODULE'] = $data; //给值给cahe的module变量,值包含path,url此外应该为 所有模块 path/url
$data = array();
$result = $db->query("SELECT * FROM `".DB_PRE."model` WHERE `disabled`=0"); //加载内容模版`disabled`=0", 意思为没有设置关闭的 model表如下
//No. 字段 类型 Null Key 默认值|说明
//1 modelid tinyint(3) unsigned NO PRI | 模型ID auto_increment
//2 name varchar(30) NO | 模型名称
//3 description varchar(255) NO | 描述
//4 tablename varchar(20) NO | 保存表名
//5 itemname varchar(10) NO | 项目名称
//6 itemunit varchar(10) NO | 项目单位
//7 workflowid tinyint(3) unsigned NO 0 | 工作流方案
//8 template_category varchar(30) NO | 栏目首页模板
//9 template_list varchar(30) NO | 栏目列表页模板
//10 template_show varchar(30) NO | 内容页模板
//11 template_print varchar(30) NO | 打印页模板
//12 ishtml tinyint(1) unsigned NO 0 | 是否生成html
//13 category_urlruleid tinyint(1) unsigned NO 0 | 栏目URL规则
//14 show_urlruleid tinyint(1) unsigned NO 0 | 内容页URL规则
//15 enablesearch tinyint(1) unsigned NO 1 |
//16 ischeck tinyint(1) unsigned NO 1 |
//17 isrelated tinyint(1) unsigned NO 1 |
//18 disabled tinyint(1) unsigned NO 0 | 禁用
//19 modeltype tinyint(1) unsigned NO 0 | 类型
while($r = $db->fetch_array($result))
{
$data[$r['modelid']] = $r; //取所有的model_Id
}
$db->free_result($result);
$CACHE['MODEL'] = $data; //给cache变量
$data = array();
$result = $db->query("SELECT `catid`,`module`,`type`,`modelid`,`catname`,`style`,`image`,`catdir`,`url`,`parentid`,`arrparentid`,`parentdir`,`child`,`arrchildid`,`items`,`ismenu` FROM `".DB_PRE."category` WHERE 1 ORDER BY `listorder`,`catid`");
//自己可以在机器上,跑一下如上sql语句,结果是
//cartoary 表结构 字段 类型 Null Key 默认值|说明
//1 catid smallint(5) unsigned NO PRI | 栏目ID auto_increment
//2 module varchar(15) NO MUL | 模块
//3 type tinyint(1) unsigned NO 0 | 栏目类型
//4 modelid tinyint(3) unsigned NO 0 | 模型ID
//5 parentid smallint(5) unsigned NO 0 | 上级栏目ID
//6 arrparentid varchar(255) NO | 所有上级栏目ID
//7 child tinyint(1) unsigned NO 0 | 是否有子栏目
//8 arrchildid mediumtext NO | 所有子栏目ID
//9 catname varchar(30) NO | 栏目名称
//10 style varchar(5) NO | 样式
//11 image varchar(100) NO | 栏目图片
//12 description mediumtext NO | 描述
//13 parentdir varchar(100) NO | 父目录
//14 catdir varchar(30) NO | 栏目目录
//15 url varchar(100) NO | 链接
//16 content mediumtext NO | 单网页内容
//17 items mediumint(8) unsigned NO 0 | 信息数
//18 hits int(10) unsigned NO 0 | 点击数
//19 setting mediumtext NO | 设置
//20 listorder smallint(5) unsigned NO 0 | 排序
//21 ismenu tinyint(1) unsigned NO 1 | 在导航显示
//也就是生成了目录树
while($r = $db->fetch_array($result))
{
$r['url'] = url($r['url']); // url varchar(100) NO | 链接 如生成后,显示为 /module_目录/index.html
$data[$r['catid']] = $r; //目录id,这些在形成首页head里的那个导行非常有用,我测试了下就是从这里调用的数据,如果导航数据有错,可以调整这里
}
$db->free_result($result);
$CACHE['CATEGORY'] = $data; //给cache变量,方便以后调用
$data = array();
$result = $db->query("SELECT `typeid`,`module`,`name`,`style`,`typedir`,`url` FROM `".DB_PRE."type` WHERE 1 ORDER BY `listorder`,`typeid`");
// 1 link 默认分类
// 2 error_report 错字
// 3 error_report 无效URL
// 0 好像为内部栏目类别
while($r = $db->fetch_array($result))
{
$data[$r['typeid']] = $r;
}
$db->free_result($result);
$CACHE['TYPE'] = $data;
$data = array();
$result = $db->query("SELECT `areaid`,`name`,`style`,`parentid`,`arrparentid`,`child`,`arrchildid` FROM `".DB_PRE."area` WHERE 1 ORDER BY `listorder`,`areaid`");
//生成位置数组
while($r = $db->fetch_array($result))
{
$data[$r['areaid']] = $r;
}
$db->free_result($result);
$CACHE['AREA'] = $data;
$data = array();
$result = $db->query("SELECT `urlruleid`,`urlrule` FROM `".DB_PRE."urlrule` WHERE 1 ORDER BY `urlruleid`");
while($r = $db->fetch_array($result))
{
$data[$r['urlruleid']] = $r['urlrule'];
}
$db->free_result($result);
$CACHE['URLRULE'] = $data; //module的url规则 2008默认为it/product/2006/1010/1_2.html格式
$data = array();
$r = $db->get_one("SELECT `setting` FROM `".DB_PRE."module` WHERE `module`='phpcms'");
//SQL查出来,如下数据,这是网站配置的基本信息,在后台可以设置,写到这个表里
// array (
'phpcmsusername' => 'merlang',
'phpcmspassword' => '850110',
'sitename' => 'Phpcms',
'siteurl' => 'http://127.0.0.1/phpcms/',
'ishtml' => '1',
'fileext' => 'html',
'enable_urlencode' => '0',
'meta_title' => '中国领先的网站内容管理系统',
'meta_keywords' => 'Phpcms 网站内容管理系统',
'meta_description' => 'Phpcms 网站内容管理系统',
'copyright' => '
CopyRight 2006---2008 酷6网(北京)信息技术有限公司版权所有',
'icpno' => '京ICP证060955号',
'pageshtml' => '总数:{$total}
首页上一页下一页尾页
页次:{$page}/{$pages}
',
'segmentclass' => 'segment',
'enablegetkeywords' => '1',
'areaid' => '1',
'editor_max_data_hour' => '4',
'editor_interval_data' => '30',
'category_count' => '1',
'show_hits' => '1',
'maxpage' => '100',
'pagesize' => '20',
'autoupdatelist' => '5',
'search_time' => '10',
'search_maxresults' => '500',
'search_pagesize' => '10',
'adminaccessip' => '',
'maxloginfailedtimes' => '5',
'maxiplockedtime' => '1',
'enable_ipbanned' => '0',
'minrefreshtime' => '0',
'filter_word' => '',
'thumb_enable' => '1',
'thumb_width' => '600',
'thumb_height' => '600',
'watermark_enable' => '1',
'watermark_minwidth' => '300',
'watermark_minheight' => '300',
'watermark_img' => 'images/watermark.gif',
'watermark_pct' => '100',
'watermark_quality' => '80',
'watermark_pos' => '9',
'mail_type' => '1',
'mail_server' => 'smtp.163.com',
'mail_port' => '25',
'mail_user' => 'phpcms@163.com',
'mail_password' => '',
'mail_sign' => '
',
'enablepassport' => '0',
'passport_file' => 'discuz',
'passport_charset' => 'gbk',
'passport_url' => 'http://www.***.com/bbs/api/passport.php',
'passport_key' => '',
'enableserverpassport' => '0',
'passport_serverurl' => 'http://www.***.com/bbs/',
'passport_registerurl' => 'register.php',
'passport_loginurl' => 'login.php',
'passport_logouturl' => 'login.php?action=quit',
'passport_getpasswordurl' => 'sendpwd.php',
'passport_serverkey' => '',
'passport_expire' => '',
'uc' => '0',
'uc_api' => 'http://uc.phpcms.cn/uc',
'uc_ip' => '',
'uc_dbhost' => 'localhost',
'uc_dbuser' => 'dbuser',
'uc_dbpwd' => 'dbpw',
'uc_dbname' => 'dbname',
'uc_dbpre' => 'uc_',
'uc_charset' => 'gbk',
'uc_appid' => '3',
'uc_key' => '',
'enabletm' => '0',
'qq' => '',
'msn' => '',
'skype' => '',
'taobao' => '',
'alibaba' => '',
'version' => '2008',
)
//----------------------------------------------------
$setting = $r['setting'];
eval("\$PHPCMS = $setting;");
if($PHPCMS['siteurl'] =='') $PHPCMS['siteurl'] = SITE_URL; // 'siteurl' => 'http://127.0.0.1/phpcms/',
$CACHE['PHPCMS'] = $PHPCMS;
cache_write('common.php', $CACHE); //将上面生成的 $CACHE变量,写到common.php中,也就是形成了data/cache/common.php
return $CACHE;
}
0
顶一下0
踩一下