destoon二次开发基础指南
代码首先包含common.inc.php文件
在common.inc.php文件中,首先定义常量。
define('IN_DESTOON', true);
define('IN_ADMIN', defined('DT_ADMIN') ? true : false);
define('DT_ROOT', str_replace("\", '/', dirname(__FILE__)));
if(defined('DT_REWRITE')) include DT_ROOT.'/include/rewrite.inc.php';//是否定义了url伪静态?
$CFG = array();//网站整体配置信息
require DT_ROOT.'/config.inc.php';//-----------------网站配置文件
define('DT_PATH', $CFG['url']);
define('DT_DOMAIN', $CFG['cookie_domain'] ? substr($CFG['cookie_domain'], 1) : '');
define('DT_WIN', strpos(strtoupper(PHP_OS), 'WIN') !== false ? true: false);
define('DT_CHMOD', ($CFG['file_mod'] && !DT_WIN) ? $CFG['file_mod'] : 0);
define('DT_URL', $CFG['url']);//Fox 3.x
define('DT_LANG', $CFG['language']);
define('DT_KEY', $CFG['authkey']);
define('DT_CHARSET', $CFG['charset']);
define('DT_CACHE', $CFG['cache_dir'] ? $CFG['cache_dir'] : DT_ROOT.'/file/cache');
define('DT_SKIN', DT_PATH.'skin/'.$CFG['skin'].'/');
define('SKIN_PATH', DT_PATH.'skin/'.$CFG['skin'].'/');//For 2.x
define('VIP', $CFG['com_vip']);
define('errmsg', 'Invalid Request');
随后加载网站基本功能
$L = array();
include DT_ROOT.'/lang/'.DT_LANG.'/lang.inc.php';//语言信息
require DT_ROOT.'/version.inc.php';
require DT_ROOT.'/include/global.func.php';//--------全局函数
require DT_ROOT.'/include/tag.func.php';//-----------标签函数
require DT_ROOT.'/api/im.func.php';//----------------聊天工具
require DT_ROOT.'/api/extend.func.php';//------------自己写的扩展函数
if(!$MQG && $_POST) $_POST = daddslashes($_POST);
if(!$MQG && $_GET) $_GET = daddslashes($_GET);
if(function_exists('date_default_timezone_set')) date_default_timezone_set($CFG['timezone']);
$DT_PRE = $CFG['tb_pre'];
$DT_QST = $_SERVER['QUERY_STRING'];//----------------querystring
$DT_TIME = time() + $CFG['timediff'];//--------------当前时间
$DT_IP = get_env('ip');
$DT_URL = get_env('url');
$DT_REF = get_env('referer');
$DT_BOT = is_robot();
链接数据库,建立缓存。
header("Content-Type:text/html;charset=".DT_CHARSET);
require DT_ROOT.'/include/db_'.$CFG['database'].'.class.php';//加载数据库类
require DT_ROOT.'/include/cache_'.$CFG['cache'].'.class.php';//加载缓存类
if($_POST) extract($_POST, EXTR_SKIP);//解析post请求的数据
if($_GET) extract($_GET, EXTR_SKIP);//解析get请求的数据
$db_class = 'db_'.$CFG['database'];
$db = new $db_class;
$db->halt = (DT_DEBUG || IN_ADMIN) ? 1 : 0;
$db->pre = $CFG['tb_pre'];
$db->connect($CFG['db_host'], $CFG['db_user'], $CFG['db_pass'], $CFG['db_name'], $CFG['db_expires'], $CFG['db_charset'], $CFG['pconnect']);
$dc = new dcache();
$dc->pre = $CFG['cache_pre'];
加载模块的基本配置
$DT = $MOD = $EXT = $CSS = $DTMP = $CAT = $ARE = $AREA = array();
$CACHE = cache_read('module.php');
if(!$CACHE) {
//没有缓存模块,就读取缓存模块。
require_once DT_ROOT.'/admin/global.func.php';
require_once DT_ROOT.'/include/post.func.php';
require_once DT_ROOT.'/include/cache.func.php';
cache_all();
$CACHE = cache_read('module.php');
}
$DT = $CACHE['dt'];
$MODULE = $CACHE['module'];
$EXT = cache_read('module-3.php');
加载模块,读取模块信息,引入模块文件
if(!isset($moduleid)) {
$moduleid = 1;
$module = 'destoon';
} else if($moduleid == 1) {
$module = 'destoon';
} else {
$moduleid = intval($moduleid);
isset($MODULE[$moduleid]) or dheader(DT_PATH);
$module = $MODULE[$moduleid]['module'];
$MOD = $moduleid == 3 ? $EXT : cache_read('module-'.$moduleid.'.php');
include DT_ROOT.'/lang/'.DT_LANG.'/'.$module.'.inc.php';
}
$forward = isset($forward) ? urldecode($forward) : $DT_REF;//------------来源页面
$action = isset($action) ? trim($action) : '';//-------------动作指令
//判断用户登录
$destoon_auth = get_cookie('auth');
if($destoon_auth) {
$_dauth = explode("t", decrypt($destoon_auth, md5(DT_KEY.$_SERVER['HTTP_USER_AGENT'])));
//print_r($_dauth);SELECT userid,username,groupid,admin FROM destoon_member
$_userid = isset($_dauth[0]) ? intval($_dauth[0]) : 0;
$_username = isset($_dauth[1]) ? trim($_dauth[1]) : '';
$_groupid = isset($_dauth[2]) ? intval($_dauth[2]) : 3;
$_admin = isset($_dauth[4]) ? intval($_dauth[4]) : 0;
if($_userid && !defined('DT_NONUSER')) {
$_password = isset($_dauth[3]) ? trim($_dauth[3]) : '';
$user = $db->get_one("SELECT username,passport,company,truename,password,groupid,email,message,chat,sound,online,sms,credit,money,loginip,admin,aid,edittime,trade FROM {$DT_PRE}member WHERE userid=$_userid");
if($user && $user['password'] == $_password) {
if($user['groupid'] == 2) dalert(lang('message->common_forbidden'));//禁止用户访问的组别
extract($user, EXTR_PREFIX_ALL, '');
if($user['loginip'] != $DT_IP && ($DT['ip_login'] == 2 || ($DT['ip_login'] == 1 && IN_ADMIN))) {
//单点登录,判断ip
$_userid = 0; set_cookie('auth', '');
dalert(lang('message->common_login', array($user['loginip'])), DT_PATH);
}
} else {
//登录失败
$_userid = 0;
if($db->linked && !isset($swfupload) && strpos($_SERVER['HTTP_USER_AGENT'], 'Flash') === false) set_cookie('auth', '');
}
unset($destoon_auth, $user, $_dauth, $_password);
}
}
if($_userid == 0) { $_groupid = 3; $_username = ''; }
if(!IN_ADMIN) {
if($_groupid == 1) include DT_ROOT.'/module/member/admin.inc.php';
if($_userid && !defined('DT_NONUSER')) {
$db->query("REPLACE INTO {$DT_PRE}online (userid,username,ip,moduleid,online,lasttime) VALUES ('$_userid','$_username','$DT_IP','$moduleid','$_online','$DT_TIME')");
}
else {
if(timetodate($DT_TIME, 'i') == 10) {
$lastime = $DT_TIME - $DT['online'];
$db->query("DELETE FROM {$DT_PRE}online WHERE lasttime<$lastime");
}
}
}
$MG = cache_read('group-'.$_groupid.'.php');//读取用户组别配置
$_areaids = '';
$_areaid = array();
if($DT['city']) {
$AREA or $AREA = cache_read('area.php');
if($_aid) {
$_areaids = $AREA[$_aid]['child'] ? $AREA[$_aid]['arrchildid'] : $_aid;
$_areaid = explode(',', $_areaids);
}
} else {
$_aid < 1 or dalert('系统未开启分站功能,您的分站管理帐号暂不可用', $MODULE[2]['linkurl'].'logout.php');
}
$session = new dsession();
require DT_ROOT.'/admin/global.func.php';
require DT_ROOT.'/include/post.func.php';
require_once DT_ROOT.'/include/cache.func.php';
isset($file) or $file = 'index';
$secretkey = 'admin_'.strtolower(substr($CFG['authkey'], -6));
//echo $secretkey;exit;
if($DT['authadmin'] == 'session') {
$_destoon_admin = isset($_SESSION[$secretkey]) ? intval($_SESSION[$secretkey]) : 0;
} else {
$_destoon_admin = get_cookie($secretkey);
$_destoon_admin = $_destoon_admin ? intval($_destoon_admin) : 0;
}
$_founder = $CFG['founderid'] == $_userid ? $_userid : 0;
$_catids = $_childs = '';
$_catid = $_child = array();
if($file != 'login') {
if($_groupid != 1 || $_admin < 1 || !$_destoon_admin) msg('', '?file=login&forward='.urlencode($DT_URL));
//判断用户是否已经登录?如果未登录,直接跳转到登录页面。防止用户构造url。
if(!admin_check()) {
admin_log(1);
$db->query("DELETE FROM {$db->pre}admin WHERE userid=$_userid AND url='?".$DT_QST."'");
msg('警告!您无权进行此操作 Error(00)');
}
}
//是否记录日志
if($DT['admin_log'] && $action != 'import') admin_log();
if($DT['admin_online']) admin_online();
$psize = isset($psize) ? intval($psize) : 0;
if($psize > 0 && $psize != $pagesize) {
$pagesize = $psize;
$offset = ($page-1)*$pagesize;
}
if($module == 'destoon') {
(include DT_ROOT.'/admin/'.$file.'.inc.php') or msg();
} else {
echo $file.'|'.$module;
include DT_ROOT.'/module/'.$module.'/common.inc.php';//加载模块下的common文件
(include MD_ROOT.'/admin/'.$file.'.inc.php') or msg();//加载模块文件
}
destoon二次开发基础指南的更多相关文章
- destoon二次开发基础代码
标签调用规则 http://help.destoon.com/develop/22.html 数据字典 http://help.destoon.com/dict.php destoon各类调用汇总 h ...
- Civil 3D API二次开发学习指南
Civil 3D构建于AutoCAD 和 Map 3D之上,在学习Civil 3D API二次开发之前,您至少需要了解AutoCAD API的二次开发,你可以参考AutoCAD .NET API二次开 ...
- PIESDK二次开发基础视频
第0讲:PIESDKNet二次开发环境配置 第1讲:PIE产品简介及开发介绍 第2讲:PIE架构及常用控件介绍 第3讲:PIESDK常用功能实践 第4讲:XML插件配置及组件式开发界面搭建 第5讲:地 ...
- Autodesk View and Data API二次开发学习指南
什么是View and Data API? 使用View and Data API,你可以轻松的在网页上显示大型三维模型或者二维图纸而不需要安装任何插件.通过View and Data API,你可以 ...
- destoon二次开发 操作数据库可运行示例
<?phpdefine('IN_DESTOON', true);$userid= $_REQUEST["userid"];//$basepath=$_SERVER['PHP_ ...
- destoon二次开发-用户名、邮箱、手机账号中间字符串以*隐藏 扩展
因为dt里面有用户名.邮箱.手机账号等,所以想办法进行隐藏保护用户隐私,所以个人就试着写了这个代码. 在api/extend.func.php文件下增加以下代码: //用户名.邮箱.手机账号中间字符串 ...
- destoon二次开发-签到时间函数扩展
在api/extend.func.php文件下增加以下代码: //签到时间函数 function timetoday($time = 0, $type = 6) { if(!$time) $time ...
- 踏上Revit二次开发之路 1 准备工作
1 准备工作 工欲善其事,必先利其器.在正式开始之前,我觉得有必要先盘点一下需要准备些什么. 1.1 硬件设备 PC机一台(谢绝Apple). 配置不能太低,至少要i3以上的cpu.4g以上的内存和支 ...
- Android VLC播放器二次开发1——程序结构分析
最近因为一个新项目需要一个多媒体播放器,所以需要做个视频.音频.图片方面的播放器.也查阅了不少这方面的资料,如果要从头做一个播放器工作量太大了,而且难度也很大.所以最后选择了VLC作为基础,进行二次开 ...
随机推荐
- HDU 2660 Accepted Necklace【数值型DFS】
Accepted Necklace Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others ...
- Oracle SQL*Loader commit point tips
http://www.dba-oracle.com/t_sql_loader_commit_frequency.htm - Question: Can I control the commit fr ...
- Web应用漏洞评估工具Paros
Web应用漏洞评估工具Paros Paros是Kali Linux集成的一款Web应用漏洞评估工具.该工具提供HTTP会话分析.网络爬虫.漏洞扫描三大功能.首先借助HTTP代理模式,该工具可以实时 ...
- 网页截图工具CutyCapt
网页截图工具CutyCapt CuteCapt是Kali Linux提供的一款网页截图工具.该工具运行在命令行中,可以将WebKit引擎解析的网页保存为图片.它保存的文件支持矢量图和位图两大类型, ...
- HashCode()的作用
在实现Hash算法的集合里面,例如HashSet,该集合不能存放相同的数据,HashSet会根据对象的equals()和hashCode()方法来判断要存放的数据是否已经存在.Hash算法把HashS ...
- 北京DAY1下午
省选模拟题 周子凯 题目概况 中文题目名 简易比特币 计算 路径 英文题目名 bit calculation Path 输入文件名 bit.in calculation.in path.in 输出文件 ...
- 简单抓取安居客房产数据,并保存到Oracle数据库
思路和上一篇差不多,先获取网站html文件,使用BeautifulSoup进行解析,将对应属性取出,逐一处理,最后把整理出的记录保存到oracle中,持久化储存. '''Created on 2017 ...
- [Android Traffic] 看无线电波如何影响网络操作]
转载自: http://blog.csdn.net/kesenhoo/article/details/7391031 Optimizing Downloads for Efficient Networ ...
- python字符串转日期
需要两步 为了从字符串中提取时间,并进行比较,因此有了这个问题,如何将字符串转换成datetime类型 1.字符串与time类型的转换 >>> import time>> ...
- 一起來玩鳥 Starling Framework 簡介
開場 Starling Framework是一套Flash 2D遊戲開發"工具",是使用Flash最新的Stage3D API建構出來的一套Framework.最大優點在於使用GP ...