<?php
$url1 = explode('?',$_SERVER['REQUEST_URI']);
$url = basename($_SERVER['PHP_SELF']).'?'.@$url1[1];
$url = htmlspecialchars($url);
$mod = intval(@$_GET['mod']);
if(intval(@$_GET['mod']) != '1' and intval(@$_GET['mod']) != '2')
{
$ua = htmlspecialchars(addslashes(trim(getenv('HTTP_USER_AGENT'))));
if (((strpos ($ua,'M3Gate') !== false) || (strpos ($ua,'Opera') !== false) || (strpos ($ua,'emulator') !== false) || (strpos ($ua,'WinWAP') !== false) || (strpos ($ua,'Wapsilon') !== false) || (strpos ($ua,'Mozilla') !== false) || (strpos ($ua,'M3GATE') !== false))) $mod = '2'; else $mod = '1';
}

if(@$mod == '1')
{
header("Content-type: text/vnd.wap.wml; charset=utf-8");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-cache, must-relative");   
if(!@$url1[1])
$url = $url.'mod=2';
else
{
if(!strstr($url, 'mod=1'))
$url = $url.'&amp;mod=2';
else
$url = str_replace('mod=1','mod=2', $url);
}
$header = '<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.3//EN" "http://www.wapforum.org/DTD/wml13.dtd"><wml><head><meta http-equiv="Cache-Control" content="no-cache" forua="true"/></head><card id="index" title="'.$title.'">';
//-----------
$class_d0 = '';
$class_d1 = '';
$class_d2 = '';
$class_d3 = '';
$class_d4 = '';
$class_div = '';
$class_divz = '';
$class_version = 'WML | <a href="'.$url.'">HTML</a><br/>';
$class_endpage = '</small></p></card></wml>';
}
else
{
header("Content-type: text/html; charset=utf-8");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-cache, must-relative");
if(!@$url1[1])
$url = $url.'mod=1';
else
{
if(!strstr($url, 'mod=2'))
$url = $url.'&amp;mod=1';
else
$url = str_replace('mod=2','mod=1', $url);
}
//-----------
$header = '<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>'.$title.'</title><link rel="stylesheet" href="http://'.$_SERVER['HTTP_HOST'].'/css/style.css" type="text/css" /></head><body>';
//-----------
$class_d0 = '<div class="d0">';
$class_d1 = '<div class="d1">';
$class_d2 = '<div class="d2">';
$class_d3 = '<div class="d3">';
$class_d4 = '<div class="d4">';
$class_div = '<div>';
$class_divz = '</div>';
$class_version = 'HTML | <a href="'.$url.'">WML</a><br/>';
$class_endpage = '</div></body></html>';
}
?>