<?php
function tpl($file)
{
	$file = PHPMPS_ROOT.'m/templates/'.$file.'.htm';
    return $file;
}

function encode_output($str)
{
	global $charset;

    if ($charset != 'utf-8')
    {
        $str = iconvs($charset, 'utf-8', $str);
    }
    return strip_tags($str);
}
function get_zk_array()
{
	global $db, $table;
		$sql = "select * from {$table}com_config where userid='$_userid'";
		$res = $db->query($sql);
		while($row=$db->fetchrow($res)) {
			$zk_array[$row['areaid']] = $row['areaname'];
		}
	return $zk_array;
}

function get_login() {
	global $db, $table, $_userid;
	if(empty($_userid)) {
	  if(is_weixin()===false){
		showwap("请登录后重新扫码!","member.php?act=login");
	  }else{
		showwap("请微信授权登录后重新扫码!","index.php");
	  }
    } else {
	  $member = member_info($_userid);
	if($member['status']!=1) showwap('您尚未通过审核或被锁定！');
    }
}

function is_weixin(){ 
	if ( strpos($_SERVER['HTTP_USER_AGENT'], 'MicroMessenger') !== false ) {
			return true;
	}	
	return false;
}

function get_device_type()
{
 //全部变成小写字母
 $agent = strtolower($_SERVER['HTTP_USER_AGENT']);
 $type = '';
 //分别进行判断
 if(strpos($agent, 'iphone') || strpos($agent, 'ipad'))
{
   $type = 'ios';
 } 
 
 if(strpos($agent, 'android'))
{
   $type = 'android';
 }
 return $type;
}

function showwap($msg,$url='goback')
{
    include tpl('show');
	exit();
}
?>