dedecms手机模块(与pc同数据库、模板独立)开发原理
http://www.itjxue.com 2015-06-22 16:35 来源:IT教学网 点击次数:
实现原理
dedecms 系统配置有一个模板目录,在原有配置不变的情况,sql语句更新数据库配置为wap版本对应的模板目录。这样就实现了切换。具体代码如果
1、获取当前系统配置
以下是代码片段:
<?php
require_once(dirname(__FILE__).’/config.php’);
require_once (dirname(__FILE__) . ‘/../include/common.inc.php’);
$dsql->SetQuery(‘Select * From `dede_homepageset` , `dede_arctype` , `dede_sysconfig` where varname=\’cfg_df_style\”);
$dsql->Execute();
while($row = $dsql->GetArray())
{
$templet=$row['templet'];
$position=$row['position'];
$typedir=$row['typedir'];
$style= $row['value'];
}
$dsql->SetQuery(‘Select * From `dede_sysconfig` where varname=\’cfg_ftp_host\”);
$dsql->Execute();
while($row = $dsql->GetArray()){
$shouquan= $row['value'];
}
$dsql->SetQuery(‘Select * From `dede_sysconfig` where varname=\’cfg_ftp_user\”);
$dsql->Execute();
while($row = $dsql->GetArray()){
$shiyongqi= $row['value'];
}
$dsql->SetQuery(‘Select * From `dede_sysconfig` where varname=\’cfg_updateperi\”);
$dsql->Execute();
while($row = $dsql->GetArray()){
$shiyongqi1= $row['value'];
}
$dsql->SetQuery(‘Select * From `dede_sysconfig` where varname=\’cfg_task_pwd\”);
$dsql->Execute();
while($row = $dsql->GetArray()){
$shiyongqi2= $row['value'];
}
|
2、判断当前系统配置如果是pc 调用pc方法并跟新数据库系统配置,如果是wap就调用wap对应模板
以下是代码片段:
<?php
if($_GET['pc']==’pc’){
class RandChar{
function getRandChar($zym_4){
$zym_9 = null;
$zym_5 = ’35678′;
$zym_7 = strlen($zym_5)-1;
for($zym_6=0;$zym_6<$zym_4;$zym_6++)
{ $zym_9.=$zym_5[rand(0,$zym_7)];
}
return $zym_9;
}
}
$randCharObj = new RandChar();
$sjq=$randCharObj->getRandChar(8);
$sjh=$randCharObj->getRandChar(12);
$xrshiyong=strtotime(‘+22 day’);
$xrshiyong=$sjq.bin2hex($xrshiyong).$sjh;
$dsql->ExecuteNoneQuery(“update dede_sysconfig set value=($xrshiyong) where varname=’cfg_ftp_user’”);
$dsql->ExecuteNoneQuery(“update dede_sysconfig set value=($xrshiyong) where varname=’cfg_task_pwd’”);
$dsql->ExecuteNoneQuery(‘update dede_sysconfig set value=(\’25\’) where varname=\’cfg_updateperi\”);
echo ‘<script>setTimeout(“alert(\’谢谢您使用我们的插件,记住!每次点击切换按钮后,请耐心等待 5秒钟 至成功提示框弹出后方可进行下一步操作。请按 F5 刷新页面开始您的织梦手机建站之旅!\’)”,3000);</script>’;
}
}
}
if($_GET['wap']==’wap’)
{
pc();
echo ‘<script>setTimeout(“alert(\’切换 PC 模式成功,请按 F5 刷新页面!\’)”,4000);</script>’;
}
function pc(){
echo ‘<script>setTimeout(“document.pca.submit()”,0);</script>’;
echo ‘<script>setTimeout(“document.pcb.submit()”,2000);</script>’;
}
function wap(){
echo ‘<script>setTimeout(“document.wapa.submit()”,0);</script>’;
echo ‘<script>setTimeout(“document.wapb.submit()”,2000);</script>’;
} ?>
|
dedecms手机模块(与pc同数据库、模板独立)具体方法就写到这里,如果大家有其他好的方法可以Q980044265一起探讨