Просмотр файла src/displaymodule.php

Размер файла: 7.63Kb
<?php	
/*
* Harris WapChat
*
* http://www.successkid.com
*
* Harris WapChat is a wap chat application for personal and corporate used.
* Visit {@link http://www.successkid.com} for more info.
* Copyright (C) 2005 Harris Yusuf Arifin
* 
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
* 
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
* 
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*
* @author		Harris Yusuf Arifin <[email protected]>
* @copyright	Copyright 2005, Harris Yusuf Arifin
*
* Please support this software by send DONATION to E-GOLD account :
* E-gold Number : 827550
* E-gold Name 	 : earthweb egold
*/


	include("constant.php");
	define("UA_OTHERS",				"0");	// Undefine
	define("UA_UP_BROWSER",			"1");	// UP Browsers
	define("UA_NOKIA_7110",			"2");	// Nokia 7110
	define("UA_ERICSSON_R320",		"3");	// Ericsson R320
	define("UA_ERICSSON_R380",		"4");	// Ericsson R380
	define("UA_ERICSSON_R520",		"5");	// Ericsson R580
	define("UA_CCWAP",				"6");	// ccWAP Online Browser
	define("UA_UP_BROWSER5",		"7");	// UP Browsers
	define("UA_UP_BROWSER6",		"8");	// UP Browsers
	define("UA_OPERA",				"9");	// Opera Browsers
	define("UA_WEB",				"10");	// web Browsers
	define("UA_XHTML",				"11");	// xhtml Browser support
	
	/*
	* Echo anchor or softkey opening tag
	*
	*/
	function navigateopen($disptext,$label,$key,$useragent) {
		if (($useragent==UA_UP_BROWSER)||($useragent==UA_ERICSSON_R380)||($useragent==UA_CCWAP) || ($useragent==UA_UP_BROWSER5)){
			echo "<do type=\"$key\" label=\"$label\">\n";
		} else {
			echo "<anchor title=\"$label\">$disptext";
		}
	}
	
	/*
	* Echo anchor or softkey closing tag
	*
	*/
	function navigateclose($useragent){
		if (($useragent==UA_UP_BROWSER)||($useragent==UA_ERICSSON_R380)||($useragent==UA_CCWAP) || ($useragent==UA_UP_BROWSER5)){
			echo "</do>\n";
		} else {
			echo "</anchor><br/>\n";
		}
	}
	
	
	function navigate($disptext,$label,$key,$go,$useragent) {
		if (($key != "prev")||($useragent!=UA_UP_BROWSER)) {
			if (($useragent==UA_UP_BROWSER)||($useragent==UA_ERICSSON_R380)||($useragent==UA_CCWAP) || ($useragent==UA_UP_BROWSER5)){
				echo "<do type=\"$key\" label=\"$label\">\n";
			} else {
				echo "<anchor title=\"$label\">$disptext";
			}
			echo $go;
			if (($useragent==UA_UP_BROWSER)||($useragent==UA_ERICSSON_R380)||($useragent==UA_CCWAP) || ($useragent==UA_UP_BROWSER5)){
				echo "</do>\n";
			} else {
				echo "</anchor><br/>\n";
			}
		} else {
			//phone.com should use 2 softkey for back action
			echo "<do name=\"back\" type=\"accept\" label=\"$label\">\n";
			echo $go;
			echo "</do>\n";
			
			echo "<do type=\"prev\" label=\"$label\">\n";
			echo $go;
			echo "</do>\n";
		}	
	}
	
	/*
	* Echo conditional title
	*
	*/
	function echotitle($title,$align,$useragent){
		if (($useragent==UA_UP_BROWSER) || ($useragent==UA_UP_BROWSER5)){
			echo "<p align=\"$align\">\n";
			echo "<b>$title</b>\n";
			echo "</p>\n";
		}
	}
	
	/*
	* Echo input tag
	*
	*/
	function echoinput($title,$varinput,$type,$emptyok,$maxlength,$useragent){
		//$title=$title.":";
		if (($useragent==UA_ERICSSON_R320)||($useragent==UA_ERICSSON_R520)){
			$prompt="";
			$titleparam="title=\"$title".":\"";
		} else {
			$prompt=$title.":";
			$titleparam="title=\"$title\"";
		}
		if ($type=="") {
			$type="text";
		}
		if ($emptyok=="") {
			$emptyokparam="";
		} else {
			$emptyokparam="emptyok=\"$emptyok\"";
		}
		if ($maxlength=="") {
			$maxlengthparam="";
		} else {
			$maxlengthparam="maxlength=\"$maxlength\"";
		}
		echo "$prompt<input name=\"$varinput\" $titleparam type=\"$type\" $emptyokparam $maxlengthparam/><br/>\n";
	}
	
		
	//disable automatic Ok binding to prev function in UP Browser
	function disableok($useragent) {
		if (($useragent==UA_UP_BROWSER)||($useragent==UA_UP_BROWSER5)){
			echo "<do type=\"accept\" label=\" \">\n";
			echo "	<noop/>\n";
			echo "</do>\n";
		}
	}
	
	function disableprev($useragent) {
		if ($useragent==UA_UP_BROWSER){
			echo "<do type=\"prev\" label=\" \">\n";
			echo "	<noop/>\n";
			echo "</do>\n";
		}
	}
	
	
	//Last but not least .... User Agent detection
	if (strpos($HTTP_USER_AGENT, "/5") !== false) {
		$sesUserAgent = UA_UP_BROWSER5;
	} 
	elseif (strpos($HTTP_USER_AGENT, "/6") !== false) {
		$sesUserAgent = UA_UP_BROWSER6;
	}
	elseif (strpos($HTTP_USER_AGENT, "UP") !== false) {
		$sesUserAgent = UA_UP_BROWSER;
	} elseif (strpos($HTTP_USER_AGENT, "VoxGateway") !== false) {
		$sesUserAgent = UA_UP_BROWSER;
	} elseif (strpos($HTTP_USER_AGENT, "Nokia") !== false) {
		$sesUserAgent = UA_NOKIA_7110;
	} elseif (strpos($HTTP_USER_AGENT, "R320") !== false) {
		$sesUserAgent = UA_ERICSSON_R320;
	} elseif ($HTTP_USER_AGENT == "R380 2.0 WAP1.1") {
		$sesUserAgent = UA_ERICSSON_R380;	
	} elseif (strpos($HTTP_USER_AGENT, "R520") !== false) {
		$sesUserAgent = UA_ERICSSON_R520;
	} elseif (strpos($HTTP_USER_AGENT, "R20") !== false) {
		$sesUserAgent = UA_ERICSSON_R520;	
	} elseif ($HTTP_USER_AGENT=="ccWAP-Browser") {
		$sesUserAgent = UA_CCWAP;
	}  elseif (strpos($HTTP_USER_AGENT,"Opera") !== false) {
		$sesUserAgent = UA_OPERA;
	}  elseif (strpos($HTTP_USER_AGENT,"Mozilla") !== false) {
		$sesUserAgent = UA_WEB;
	}  elseif (strpos($HTTP_USER_AGENT,"xhtml") !== false) {
		$sesUserAgent = UA_XHTML;
	} else {
		$sesUserAgent = "0";
	}
	
	switch($sesUserAgent){
		case UA_UP_BROWSER:
			$sesPhoneLineCharDisplayed		= 20;
			$sesPhoneLineCharAnchorDisplayed	= 38;
			$sesPhoneMsgDisplayed 			= 8;
			$sesPhoneChrDisplayed 			= 600;
			$sesPhoneGrpDisplayed 			= 4;
			$sesPhoneCtkDisplayed 			= 6;
			break;
		case UA_UP_BROWSER5:
			$sesPhoneLineCharDisplayed		= 20;
			$sesPhoneLineCharAnchorDisplayed	= 38;
			$sesPhoneMsgDisplayed 			= 8;
			$sesPhoneChrDisplayed 			= 600;
			$sesPhoneGrpDisplayed 			= 4;
			$sesPhoneCtkDisplayed 			= 6;
			break;
		case UA_NOKIA_7110:
			$sesPhoneLineCharDisplayed		= 20;
			$sesPhoneLineCharAnchorDisplayed	= 38;
			$sesPhoneMsgDisplayed 			= 8;
			$sesPhoneChrDisplayed 			= 500;
			$sesPhoneGrpDisplayed 			= 4;
			$sesPhoneCtkDisplayed 			= 6;
			break;
		case UA_ERICSSON_R320:
			$sesPhoneLineCharDisplayed		= 20;
			$sesPhoneLineCharAnchorDisplayed	= 37;
			$sesPhoneMsgDisplayed 			= 10;
			$sesPhoneChrDisplayed 			= 1900;
			$sesPhoneGrpDisplayed 			= 4;
			$sesPhoneCtkDisplayed 			= 5;
			break;
		case UA_ERICSSON_R380:
			$sesPhoneLineCharDisplayed		= 20;
			$sesPhoneLineCharAnchorDisplayed	= 48;
			$sesPhoneMsgDisplayed 			= 10;
			$sesPhoneChrDisplayed 			= 2400;
			$sesPhoneGrpDisplayed 			= 4;
			$sesPhoneCtkDisplayed 			= 5;
			break;
		case UA_ERICSSON_R520:
			$sesPhoneLineCharDisplayed		= 20;
			$sesPhoneLineCharAnchorDisplayed	= 37;
			$sesPhoneMsgDisplayed 			= 10;
			$sesPhoneChrDisplayed 			= 500;
			$sesPhoneGrpDisplayed 			= 4;
			$sesPhoneCtkDisplayed 			= 5;
			break;
		case UA_CCWAP:
			$sesPhoneLineCharDisplayed		= 20;
			$sesPhoneLineCharAnchorDisplayed	= 37;
			$sesPhoneMsgDisplayed 			= 10;
			$sesPhoneChrDisplayed 			= 2400;
			$sesPhoneGrpDisplayed 			= 4;
			$sesPhoneCtkDisplayed 			= 5;
			break;
		default:
			$sesPhoneLineCharDisplayed		= 16;
			$sesPhoneLineCharAnchorDisplayed	= 30;
			$sesPhoneMsgDisplayed 			= 8;
			$sesPhoneChrDisplayed 			= 500;
			$sesPhoneGrpDisplayed 			= 4;
			$sesPhoneCtkDisplayed 			= 5;
			break;
	}
?>