1
/**
* 類名: mobile
* 描述: 手機信息類
* 其他: 偶然 編寫
*/
class mobile
{
/**
* 函數名稱: getPhoneNumber
* 函數功能: 取手機號
* 輸入參數: none
* 函數返回值: 成功返回號碼,失敗返回false
* 其它說明: 說明
*/
function getPhoneNumber()
{
if (isset($_SERVER["HTTP_X_NETWORK_INFO"]))
{
$str1 = $_SERVER["HTTP_X_NETWORK_INFO"];
$getstr1 = preg_replace("/(.*,)(13[d])(,.*)/i","2",$str1);
Return $getstr1;
}
elseif (isset($_SERVER["HTTP_X_UP_CALLING_LINE_ID"]))
{
$getstr2 = $_SERVER["HTTP_X_UP_CALLING_LINE_ID"];
Return $getstr2;
}
elseif (isset($_SERVER["HTTP_X_UP_SUBNO"]))
{
$str3 = $_SERVER["HTTP_X_UP_SUBNO"];
$getstr3 = preg_replace("/(.*)(13[d])(.*)/i","2",$str3);
Return $getstr3;
}
elseif (isset($_SERVER["DEVICEID"]))
{
Return $_SERVER["DEVICEID"];
}
else
{
Return false;
}
}
/**
* 函數名稱: getHttpHeader
* 函數功能: 取頭信息
* 輸入參數: none
* 函數返回值: 成功返回號碼,失敗返回false
* 其它說明: 說明
*/
function getHttpHeader()
{
$str = "";
foreach ($_SERVER as $key=>$val)
{
$gstr = str_replace("&","&",$val);
$str.= "$key -> ".$gstr."
";
}
Return $str;
}
/**
* 函數名稱: getUA
* 函數功能: 取UA
* 輸入參數: none
* 函數返回值: 成功返回號碼,失敗返回false
* 其它說明: 說明
*/
function getUA()
{
if (isset($_SERVER["HTTP_USER_AGENT"]))
{
Return $_SERVER["HTTP_USER_AGENT"];
}
else
{
Return false;
}
}
/**
* 函數名稱: getPhoneType
* 函數功能: 取得手機類型
* 輸入參數: none
* 函數返回值: 成功返回string,失敗返回false
* 其它說明: 說明
*/
function getPhoneType()
{
$ua = $this->getUA();
if($ua!=false)
{
$str = explode(" ",$ua);
Return $str[0];
}
else
{
Return false;
}
}
/**
* 函數名稱: isOpera
* 函數功能: 判斷是否是opera
* 輸入參數: none
* 函數返回值: 成功返回string,失敗返回false
* 其它說明: 說明
*/
function isOpera()
{
$uainfo = $this->getUA();
if (preg_match("/.*Opera.*/i",$uainfo))
{
Return true;
}
else
{
Return false;
}
}
/**
* 函數名稱: isM3gate
* 函數功能: 判斷是否是m3gate
* 輸入參數: none
* 函數返回值: 成功返回string,失敗返回false
* 其它說明: 說明
*/
function isM3gate()
{
$uainfo = $this->getUA();
if (preg_match("/M3Gate/i",$uainfo))
{
Return true;
}
else
{
Return false;
}
}
/**
* 函數名稱: getHttpAccept
* 函數功能: 取得HA
* 輸入參數: none
* 函數返回值: 成功返回string,失敗返回false
* 其它說明: 說明
*/
function getHttpAccept()
{
if (isset($_SERVER["HTTP_ACCEPT"]))
{
Return $_SERVER["HTTP_ACCEPT"];
}
else
{
Return false;
}
}
/**
* 函數名稱: getIP
* 函數功能: 取得手機IP
* 輸入參數: none
* 函數返回值: 成功返回string
* 其它說明: 說明
*/
function getIP()
{
$ip=getenv("REMOTE_ADDR");
$ip_ = getenv("HTTP_X_FORWARDED_FOR");
if (($ip_ != "") && ($ip_ != "unknown"))
{
$ip=$ip_;
}
return $ip;
}
}
2
class wap
{
function head()
{
$head =header("Content-type:text/vnd.wap.wml");
$head.="<?xml version=/"1.0/" encoding=/"utf-8/"?>"; //這裏應該是gb 2312
$head.="/r/n";
$head.="<!DOCTYPE wml PUBLIC /"-//WAPFORUM//DTD WML 1.1//EN/" /"http://www.wapforum.org/DTD/wml_1.1.xml/">";
$head.="/r/n";
$head.="<wml>";
$head.="/r/n";
echo $head;
}
function nocache()
{
$nocache ="/r/n";
$nocache.= "<head><meta http-equiv=/"Cache-Control/" content=/"no-cache/"/></head>";
$nocache.="/r/n";
echo $nocache;
}
function card($id,$title)
{
$card = "<card id=/"$id/" title=/"$title/">";
$card.= "/r/n";
echo $card;
}
function ontime_url($id,$title,$url,$value)
{
$ontime_url = "<card id=/"$id/" title=/"$title/" ontimer=/"$url/">";
$ontime_url.= "/r/n";
$ontime_url.= "<timer value=/"$value/"/>";
$ontime_url.= "/r/n";
echo $ontime_url;
}
function foot()
{
$foot = "/r/n";
$foot.= "</card>";
$foot.= "/r/n";
$foot.= "</wml>";
echo $foot;
}
function p($str,$align="left")
{
$p = "<p align=/"$align/">";
$p.= $str;
$p.= "</p>";
$p.= "/r/n";
echo $p;
}
function prev($str)
{
$prev = "<anchor><prev/>$str</anchor>";
echo $prev;
}
function link($url,$str)
{
$link = "<a href=/"$url/">$str</a>";
echo $link;
}
function img($url,$alt)
{
$img.= "<img src=/"$url/" alt=/"$alt/"/>";
echo $img;
}
function br()
{
echo "<br/>";
}
function input($name,$type="text",$format="specifier",$maxlength="10",$emptyok="false")
{
echo "<input name=/"$name/" type=/"$type/" format=/"$format/" maxlength=/"$maxlength/" emptyok=/"$emptyok/" />";
}
function Wrong($str)
{
$this->card("Wrong","出錯啦");
if ($str=="post") {
$this -> p("請填寫所有的內容!");
}
if ($str=="note") {
$this -> p("不要TK別人的內容哦!");
}
echo "<p>";
$this -> prev("返回");
echo " ";
$this -> link("./","首頁");
echo "</p>";
$this -> foot();
exit;
}
}