ecshop 代码问题,高手请进 100
if((DEBUG_MODE&2)!=2){$smarty->caching=true;}$ua=strtolower($_SERVER['HTTP_USER_AGENT...
if ((DEBUG_MODE & 2) != 2)
{
$smarty->caching = true;
}
$ua = strtolower($_SERVER['HTTP_USER_AGENT']);
$uachar = "/(nokia|sony|ericsson|mot|samsung|sgh|lg|philips|panasonic|alcatel|lenovo|cldc|midp|mobile)/i";
if(($ua == '' || preg_match($uachar, $ua))&& !strpos(strtolower($_SERVER['REQUEST_URI']),'wap'))
{
$Loaction = 'mobile/';
if (!empty($Loaction))
{
ecs_header("Location: $Loaction\n");
exit;
}
}
这是ecshop判断访问终端是不是移动设备的代码,是的话跳转到mobile文件夹
我想在这段代码里面加一个弹出框,让手机用户可以自己选择是否进入手机版,请高手给出详细代码,谢谢!
我的设想是这样的,就是在判断完设备后,执行跳转到mobile文件夹之前加一段弹出层的代码,让用户选择,如果选择是就执行跳转,如果选择否,就不执行下面的跳转代码 了,直接跳出这段if循环。 展开
{
$smarty->caching = true;
}
$ua = strtolower($_SERVER['HTTP_USER_AGENT']);
$uachar = "/(nokia|sony|ericsson|mot|samsung|sgh|lg|philips|panasonic|alcatel|lenovo|cldc|midp|mobile)/i";
if(($ua == '' || preg_match($uachar, $ua))&& !strpos(strtolower($_SERVER['REQUEST_URI']),'wap'))
{
$Loaction = 'mobile/';
if (!empty($Loaction))
{
ecs_header("Location: $Loaction\n");
exit;
}
}
这是ecshop判断访问终端是不是移动设备的代码,是的话跳转到mobile文件夹
我想在这段代码里面加一个弹出框,让手机用户可以自己选择是否进入手机版,请高手给出详细代码,谢谢!
我的设想是这样的,就是在判断完设备后,执行跳转到mobile文件夹之前加一段弹出层的代码,让用户选择,如果选择是就执行跳转,如果选择否,就不执行下面的跳转代码 了,直接跳出这段if循环。 展开
展开全部
//在./mobile文件夹里新建index.html,以下为新建的index.html文件
<!DOCTYPE html>
<meta charset="utf-8">
<body>
<center>
<form action="index1.php" method="get">
<h2>是否进入手机版</h2>
<input type="radio" name="select" value="1"/>是</br>
<input type="radio" name="select" value="0"/>否</br>
<input type="submit" value="提交"/>
</form>
</center>
</body>
</html>
//重命名原来./mobile下的index.php为index1.php以下为新建的index1.php
<?php
if($_GET['select']==1){ //在文件开头加个判断
define('IN_ECS', true);
define('ECS_ADMIN', true);
require(dirname(__FILE__) . '/includes/init.php');
$best_goods = get_recommend_goods('best');
$best_num = count($best_goods);
$smarty->assign('best_num' , $best_num);
if ($best_num > 0)
{
$i = 0;
foreach ($best_goods as $key => $best_data)
{
$best_goods[$key]['shop_price'] = encode_output($best_data['shop_price']);
$best_goods[$key]['name'] = encode_output($best_data['name']);
/*if ($i > 2)
{
break;
}*/
$i++;
}
$smarty->assign('best_goods' , $best_goods);
}
/* 热门商品 */
$hot_goods = get_recommend_goods('hot');
$hot_num = count($hot_goods);
$smarty->assign('hot_num' , $hot_num);
if ($hot_num > 0)
{
$i = 0;
foreach ($hot_goods as $key => $hot_data)
{
$hot_goods[$key]['shop_price'] = encode_output($hot_data['shop_price']);
$hot_goods[$key]['name'] = encode_output($hot_data['name']);
/*if ($i > 2)
{
break;
}*/
$i++;
}
$smarty->assign('hot_goods' , $hot_goods);
}
$promote_goods = get_promote_goods();
$promote_num = count($promote_goods);
$smarty->assign('promote_num' , $promote_num);
if ($promote_num > 0)
{
$i = 0;
foreach ($promote_goods as $key => $promote_data)
{
$promote_goods[$key]['shop_price'] = encode_output($promote_data['shop_price']);
$promote_goods[$key]['name'] = encode_output($promote_data['name']);
/*if ($i > 2)
{
break;
}*/
$i++;
}
$smarty->assign('promote_goods' , $promote_goods);
}
$pcat_array = get_categories_tree();
foreach ($pcat_array as $key => $pcat_data)
{
$pcat_array[$key]['name'] = encode_output($pcat_data['name']);
if ($pcat_data['cat_id'])
{
if (count($pcat_data['cat_id']) > 3)
{
$pcat_array[$key]['cat_id'] = array_slice($pcat_data['cat_id'], 0, 3);
}
foreach ($pcat_array[$key]['cat_id'] as $k => $v)
{
$pcat_array[$key]['cat_id'][$k]['name'] = encode_output($v['name']);
}
}
}
$smarty->assign('pcat_array' , $pcat_array);
$brands_array = get_brands();
if (!empty($brands_array))
{
if (count($brands_array) > 3)
{
$brands_array = array_slice($brands_array, 0, 10);
}
foreach ($brands_array as $key => $brands_data)
{
$brands_array[$key]['brand_name'] = encode_output($brands_data['brand_name']);
}
$smarty->assign('brand_array', $brands_array);
}
$article_array = $db->GetALLCached("SELECT article_id, title FROM " . $ecs->table("article") . " WHERE cat_id != 0 AND is_open = 1 AND open_type = 0 ORDER BY article_id DESC LIMIT 0,4");
if (!empty($article_array))
{
foreach ($article_array as $key => $article_data)
{
$article_array[$key]['title'] = encode_output($article_data['title']);
}
$smarty->assign('article_array', $article_array);
}
if ($_SESSION['user_id'] > 0)
{
$smarty->assign('user_name', $_SESSION['user_name']);
}
if (!empty($GLOBALS['_CFG']['search_keywords']))
{
$searchkeywords = explode(',', trim($GLOBALS['_CFG']['search_keywords']));
}
else
{
$searchkeywords = array();
}
$smarty->assign('searchkeywords', $searchkeywords);
$smarty->assign('wap_logo', $_CFG['wap_logo']);
$smarty->assign('footer', get_footer());
$smarty->display("index.html");
}
?>
//望采纳
<!DOCTYPE html>
<meta charset="utf-8">
<body>
<center>
<form action="index1.php" method="get">
<h2>是否进入手机版</h2>
<input type="radio" name="select" value="1"/>是</br>
<input type="radio" name="select" value="0"/>否</br>
<input type="submit" value="提交"/>
</form>
</center>
</body>
</html>
//重命名原来./mobile下的index.php为index1.php以下为新建的index1.php
<?php
if($_GET['select']==1){ //在文件开头加个判断
define('IN_ECS', true);
define('ECS_ADMIN', true);
require(dirname(__FILE__) . '/includes/init.php');
$best_goods = get_recommend_goods('best');
$best_num = count($best_goods);
$smarty->assign('best_num' , $best_num);
if ($best_num > 0)
{
$i = 0;
foreach ($best_goods as $key => $best_data)
{
$best_goods[$key]['shop_price'] = encode_output($best_data['shop_price']);
$best_goods[$key]['name'] = encode_output($best_data['name']);
/*if ($i > 2)
{
break;
}*/
$i++;
}
$smarty->assign('best_goods' , $best_goods);
}
/* 热门商品 */
$hot_goods = get_recommend_goods('hot');
$hot_num = count($hot_goods);
$smarty->assign('hot_num' , $hot_num);
if ($hot_num > 0)
{
$i = 0;
foreach ($hot_goods as $key => $hot_data)
{
$hot_goods[$key]['shop_price'] = encode_output($hot_data['shop_price']);
$hot_goods[$key]['name'] = encode_output($hot_data['name']);
/*if ($i > 2)
{
break;
}*/
$i++;
}
$smarty->assign('hot_goods' , $hot_goods);
}
$promote_goods = get_promote_goods();
$promote_num = count($promote_goods);
$smarty->assign('promote_num' , $promote_num);
if ($promote_num > 0)
{
$i = 0;
foreach ($promote_goods as $key => $promote_data)
{
$promote_goods[$key]['shop_price'] = encode_output($promote_data['shop_price']);
$promote_goods[$key]['name'] = encode_output($promote_data['name']);
/*if ($i > 2)
{
break;
}*/
$i++;
}
$smarty->assign('promote_goods' , $promote_goods);
}
$pcat_array = get_categories_tree();
foreach ($pcat_array as $key => $pcat_data)
{
$pcat_array[$key]['name'] = encode_output($pcat_data['name']);
if ($pcat_data['cat_id'])
{
if (count($pcat_data['cat_id']) > 3)
{
$pcat_array[$key]['cat_id'] = array_slice($pcat_data['cat_id'], 0, 3);
}
foreach ($pcat_array[$key]['cat_id'] as $k => $v)
{
$pcat_array[$key]['cat_id'][$k]['name'] = encode_output($v['name']);
}
}
}
$smarty->assign('pcat_array' , $pcat_array);
$brands_array = get_brands();
if (!empty($brands_array))
{
if (count($brands_array) > 3)
{
$brands_array = array_slice($brands_array, 0, 10);
}
foreach ($brands_array as $key => $brands_data)
{
$brands_array[$key]['brand_name'] = encode_output($brands_data['brand_name']);
}
$smarty->assign('brand_array', $brands_array);
}
$article_array = $db->GetALLCached("SELECT article_id, title FROM " . $ecs->table("article") . " WHERE cat_id != 0 AND is_open = 1 AND open_type = 0 ORDER BY article_id DESC LIMIT 0,4");
if (!empty($article_array))
{
foreach ($article_array as $key => $article_data)
{
$article_array[$key]['title'] = encode_output($article_data['title']);
}
$smarty->assign('article_array', $article_array);
}
if ($_SESSION['user_id'] > 0)
{
$smarty->assign('user_name', $_SESSION['user_name']);
}
if (!empty($GLOBALS['_CFG']['search_keywords']))
{
$searchkeywords = explode(',', trim($GLOBALS['_CFG']['search_keywords']));
}
else
{
$searchkeywords = array();
}
$smarty->assign('searchkeywords', $searchkeywords);
$smarty->assign('wap_logo', $_CFG['wap_logo']);
$smarty->assign('footer', get_footer());
$smarty->display("index.html");
}
?>
//望采纳
追问
感谢你的热心帮助,不过这样好像不行
说说我需要的功能吧,我之前提问的那段代码是站点首页index.php里面的一段代码,就是判断访问终端是不是移动设备,是的话就直接跳转到mobile文件夹,问题是,用手机访问的时候如果我要主动的访问电脑版,比如点击访问电脑版的链接,还是会跳转到站定首页的index.php文件,那么就会再次判断设备,然后又自动进入手机版了。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询