Page 1 of 2 12 LastLast
Results 1 to 10 of 19

Thread: Wml + Xhtml In Same Php File ?

  1. #1
    Member
    Join Date
    Mar 2007
    Location
    Hell
    Posts
    53
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Red face

    How to create a wml & xhtml page in the same php script? like index.php?page=xhtml or index.php?page=wml

  2. #2
    Senior Member blackhowk's Avatar
    Join Date
    Jul 2006
    Location
    Bucharest
    Posts
    411
    Thanks
    0
    Thanked 2 Times in 2 Posts
    Rep Power
    0

    Default

    hello,


    try this:



    <?php
    if(!isset($_GET[&#39;case&#39;])) $_GET[&#39;case&#39;] = &#39;&#39;;
    switch($_GET[&#39;case&#39;]) {
    case &#39;&#39;;


    echo "START CASE";


    break;
    case &#39;1&#39;:
    include (&#39;headwml.php&#39;);

    echo "CASE 1 WML";
    include (&#39;footwml.php&#39;);

    break;
    case &#39;2&#39;:
    include (&#39;headxhtml.php&#39;);

    echo "CASE 2 XHTML";

    include (&#39;footxhtml.php&#39;);

    break;
    case &#39;3&#39;:


    echo "CASE 3 WHAT YOU WANT ";




    }
    ?>


    that is case.php;
    first case must be : yourserver.com/case.php - start case
    second case must be : yourserver.com/case.php?case=1 - wml
    third case must be: yourserver.com/case.php?case=2 - xhtml


    you may need to include some headers and footers for wml and xhtml.
    [Only registered and activated users can see links. Click Here To Register...]

  3. #3
    linkrx7
    Guest

    Default

    heres my way
    put this into core
    Code:
    global $HTTP_USER_AGENT,$HTTP_ACCEPT;
    $script="wml";
    $browser=explode("/",$HTTP_USER_AGENT);
    //feel free 2 add more browsers here//
    if(strpos($_SERVER["HTTP_USER_AGENT"],"Firefox")==true){$script="wml";}
    else if($browser[0]=="Mozilla"){$script="html";}
    else if($browser[0]=="Opera"){$script="xhtml";}
    else if(strpos(strtoupper($HTTP_ACCEPT),"XHTML+XML")>0){$script="xhtml";}
    function header_type()
    {
    global $script;
    if($script=="xhtml"){
    header(&#39;Content-type: application/vnd.wap.xhtml+xml&#39;);
    echo "<?xml version=\"1.0\"?>
    <!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\">";
    }
    else if($script=="html"){
    header(&#39;Content-type: text/html&#39;);
    echo "<?xml version=\"1.0\"?>
    <!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">
    <html>";
    }
    else if($script=="wml"){
    header("Content-type: text/vnd.wap.wml");
    echo "<?xml version=\"1.0\"?>
    <!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.1//EN\"". " \"http://www.wapforum.org/DTD/wml_1.1.xml\">
    <wml>";
    }
    }
    function head_tag($title,$theme_opt,$uid)
    {
    global $script;
    if($theme_opt==0){$theme[0]="white_medium.css";}
    if($script=="html"){
    if($theme_opt==1){
    $theme=mysql_fetch_array(mysql_query("SELECT theme FROM profiles WHERE uid=&#39;".getuid_nick($uid)."&#39;"));
    }
    echo "<head>
    <title>$title</title>
    <link rel=\"stylesheet\" type=\"text/css\" href=\"themes/html_$theme[0]\">
    </head>
    <body onLoad=\"show3()\">";
    }
    else if($script=="xhtml"){
    if($theme_opt==1){
    $theme=mysql_fetch_array(mysql_query("SELECT theme FROM profiles WHERE uid=&#39;".getuid_nick($uid)."&#39;"));
    }
    echo "<head>
    <title>$title</title>
    <link rel=\"stylesheet\" type=\"text/css\" href=\"themes/$theme[0]\">
    </head>
    <body>";
    }else if($script=="wml"){
    echo "<card id=\"main\" title=\"$title\">";
    }
    }
    function foot_tag()
    {
    global $script;
    if(($script=="html")||($script=="xhtml")){
    echo "</body>
    </html>";
    }else if($script=="wml"){
    echo "</card>
    </wml>";
    }
    }
    function database_error()
    {
    global $script;
    echo head_tag("Error!!!",0,0);
    if(($script=="xhtml")||($script=="html")){
    echo "
    <center>
    ";
    }
    else if($script=="wml"){
    echo "
    <p align=\"center\">
    ";
    }
    echo "
    <img src=\"images/notok.gif\" alt=\"!\"/>
    
    Error! Cannot Connect To Database...
    
    
    This error happens usually when backing up the database, please be patient...
    ";
    if(($script=="xhtml")||($script=="html")){
    echo "
    </center>
    ";
    }
    else if($script=="wml"){
    echo "
    </p>
    ";
    }
    echo foot_tag();
    exit();
    }
    thern add this in the pages

    [code]
    <?php
    include("blocked.php");
    include("core.php");
    header("Cache-Control: no-cache, must-revalidate");
    header("Pragma: no-cache");
    header_type();
    $action = $_GET["action"];
    $mode = $_GET["mode"];
    $sid = $_GET["sid"];
    $who = $_GET["who"];
    if(!connectdb())
    {
    echo database_error();
    }
    cleardata();
    if(!islogged($sid))
    {
    echo head_tag("Error!!!",0,0);
    echo session_expired();
    echo foot_tag();
    exit();
    }
    /////////////////////////INDEX/////////////////////////

    if(($action=="")&&($mode==""))
    {
    addonline(getuid_sid($sid),"Index","index.php");
    echo head_tag(getnick_sid($sid)."@Index",1,getnick_sid( $sid));
    if(($script=="html")||($script=="xhtml")){echo "<div>Index</div>";}
    else if($script=="wml"){echo "<p align=\"center\">Index</p>";}

    ////script data goes here//////

    echo foot_tag();
    }
    ?>

  4. #4
    Senior Member blackhowk's Avatar
    Join Date
    Jul 2006
    Location
    Bucharest
    Posts
    411
    Thanks
    0
    Thanked 2 Times in 2 Posts
    Rep Power
    0

    Default

    i dont see refference about LAVA script or else in the first post .
    [Only registered and activated users can see links. Click Here To Register...]

  5. #5
    Member
    Join Date
    Mar 2006
    Location
    in your dreams :P
    Posts
    84
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Default

    i know it aint exactly the prettiest script in the world (i coded it all just in the last 5minutes), but hey, its free and ive even been nice enough to add comments that explain what is going on so dont you dare complain .. or else

    and i know this means having twice as many pages, but the nice advantage is that you can edit it so that the filepaths for each filetype are set in config.php for example, and other programming languages can easily be added / removed .. =]

    anyways, enough of me rambling on and take a look at this lol ..

    Code:
    /// get what the link says the page type should be
    $page = $_GET[&#39;page&#39;];
    
    
    /// make sure what has been given is either wml or xhtml .. this is needed to prevent code injections .. just a quick warning that this isnt totally secure so dont take it for granted that it is..
    if($page == "wml"){
    $pagetype = "wml";
    }elseif($page == "xhtml"){
    $pagetype="xhtml";
    else {
    
    //// some script to figure out what the browser accepts .. there are plenty on here or you can google for one ... then set $pagetype accordingly =]
    
    }
    
    
    ////// make sure that the variables below here are ones that youve set and are validated somehow (for example, if functions)
    
    /// check the value of $pagetype is exactly what you wanted 
    if(($pagetype == "wml") || ($pagetype == "xhtml") && ($pagetype !== "")){
    if($pagetype == "wml"){
    include("PATH TO WML FILE\PAGE.WML");
    }elseif($pagetype == "xhtml"){
    include("PATH TO XHTML FILE\PAGE.XHTML");
    }else{
    echo &#39;this shouldnt ever happen, unless the if(($pagetype == "wml") || ($pagetype == "xhtml") && ($pagetype !== "")) function messed up somehow&#39;;
    }
    }
    ?>

  6. #6
    linkrx7
    Guest

    Default

    i put it there only as an example as urs dnt come from what the browser is but is by what its sent as...

  7. #7
    Member
    Join Date
    Mar 2007
    Location
    Hell
    Posts
    53
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Default

    Thnx guys but blackhowk resolved me

  8. #8
    midnex_lt
    Guest

    Default

    style.class.php

    Code:
    <?php
    // wml + xhtml style class By Midnex 2007
    // Visit my site at [Only registered and activated users can see links. Click Here To Register...]
    // Skype: midnex
    // ICQ  : 350-772-392
    // Email: [Only registered and activated users can see links. Click Here To Register...]
    
    class style {
    
        var $style;
        var $body = &#39;&#39;;
        //This is optional if you want to detect browser in other way, you can write line $style->style = &#39;wml&#39;; in your index.php to change style
        function style()
        {
            list($browser) = explode("/", $_SERVER[&#39;HTTP_USER_AGENT&#39;]);
            $browser_array = array(&#39;Mozilla&#39;,&#39;Opera&#39;);
            $style = 0;
            for($i = 0; $i < count($browser_array); $i++)
            {
                if($browser == $browser_array[$i])
                {
                    $style++;
                }
            }
            if($style == 0)
            {
                $this->style = &#39;wml&#39;;
            }
            else
            {
                $this->style = &#39;xhtml&#39;;
            }
        }
    
        function add_img($url,$text,$br)
        {
            if($this->style == &#39;wml&#39;)
            {
                $this->body .= &#39;[img]&#39;.$url.&#39;[/img]&#39;;
                if($br)
                {
                    $this->body .= &#39;
    &#39;;
                }
            }
    
            if($this->style == &#39;xhtml&#39;)
            {
                $this->body .= &#39;[img]&#39;.$url.&#39;[/img]&#39;;
                if($br)
                {
                    $this->body .= &#39;
    &#39;;
                }
            }
            $this->body .= "\n";
        }
        function start_p($align=&#39;left&#39;)
        {
            if($this->style == &#39;wml&#39;)
            {
                $this->body .= &#39;<p align="&#39;.$align.&#39;">&#39;;
            }
            if($this->style == &#39;xhtml&#39;)
            {
                $this->body .= &#39;<p class="&#39;.$align.&#39;">&#39;;
            }
            $this->body .= "\n";
        }
        function end_p()
        {
            $this->body .= &#39;</p>&#39;;
        }
        function start_page($title)
        {
            if($this->style == &#39;wml&#39;)
            {
                $this->body .= &#39;<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.2//EN" "http://www.wapforum.org/DTD/wml12.dtd">&#39;;
                $this->body .= &#39;<wml><card id="index" title="&#39;.$title.&#39;">&#39;;
                $this->body .= "\n";
            }
            if($this->style == &#39;xhtml&#39;)
            {
                $this->body .= &#39;<?xml version="1.0" encoding="ISO-8859-1"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
                <html xmlns="http://www.w3.org/1999/xhtml"><head>
                <title>&#39;.$title.&#39;</title>
                <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
                </head>
                <body>&#39;;
                $this->body .= "\n";
            }
        }
    
        function end_page()
        {
            if($this->style == &#39;wml&#39;)
            {
                $this->body .= &#39;</card></wml>&#39;;
            }
            if($this->style == &#39;xhtml&#39;)
            {
                $this->body .= &#39;</body></html>&#39;;
            }
            $this->body .= "\n";
        }
    
        function headers()
        {
            if($this->style == &#39;wml&#39;)
            {
                header("Content-type: text/vnd.wap.wml;charset=utf-8");
                header("Cache-Control: no-store, no-cache, must-revalidate");
            }
            if($this->style == &#39;xhtml&#39;)
            {
                header("Content-type: text/html");
                header("Cache-Control: no-store, no-cache, must-revalidate");
            }
        }
    
        function add_link($url,$text,$class=&#39;title&#39;,$br=true)
        {
            if($this->style == &#39;wml&#39;)
            {
                $this->body .= &#39;<anchor>&#39;.$text.&#39;<go href="&#39;.$url.&#39;"></go></anchor>&#39;;
            }
            if($this->style == &#39;xhtml&#39;)
            {
                if(!empty($class))
                {
                    $this->body .= &#39;[Only registered and activated users can see links. Click Here To Register...]&#39;;
                }
                else
                {
                    $this->body .= &#39;[Only registered and activated users can see links. Click Here To Register...]&#39;;
                }
            }
            if($br)
            {
                $this->body .= $this->do_br();
            }
            $this->body .= "\n";
        }
        function img_link($url,$img_url,$text,$br)
        {
            if($this->style == &#39;wml&#39;)
            {
                $this->body .= &#39;<anchor>&#39;;
                $this->body .= $this->add_img($img_url,$text,false);
                $this->body .= &#39;<go href="&#39;.$url.&#39;"></go></anchor>&#39;;
                if($br)
                {
                    $this->body .= &#39;
    &#39;;
                }
            }
            if($this->style == &#39;xhtml&#39;)
            {
                $this->body .= &#39;<a href="&#39;.$url.&#39;">&#39;;
                $this->body .= $this->add_img($img_url,$text,false);
                $this->body .= &#39;</a>&#39;;
                if($br)
                {
                    $this->body .= &#39;
    &#39;;
                }
            }
            $this->body .= "\n";
        }
        function do_br($sk=1)
        {
            $this->body .= str_repeat(&#39;
    &#39;,$sk);
        }
        function simple_text($text,$br=false)
        {
            $this->body .= $text;
            if($br)
            {
                $this->body .= $this->do_br();
            }
            $this->body .= "\n";
        }
        function show_body()
        {
            echo $this->body;
        }
    }
    ?>
    index.php

    Code:
    <?php
    // wml + xhtml style class By Midnex 2007
    // Visit my site at [Only registered and activated users can see links. Click Here To Register...]
    // Skype: midnex
    // ICQ  : 350-772-392
    // Email: [Only registered and activated users can see links. Click Here To Register...]
    
    include(&#39;style.class.php&#39;);
    $style = new style;
    
    //Leave commented if you want the class will detect browser automatically.
    //$style->style = $_GET[&#39;style&#39;]; wml/xhtml
    //$style->style = &#39;wml&#39;;
    //$style->style = &#39;xhtml&#39;;
    
    $style->headers();
    $style->start_page(&#39;Wap-Online.Net&#39;);
    $style->start_p(&#39;center&#39;);
    $style->add_img(&#39;[Only registered and activated users can see links. Click Here To Register...]);
    $style->simple_text(&#39;Hello everyone, im glad you visited my site;)&#39;,true);
    $style->add_link(&#39;[Only registered and activated users can see links. Click Here To Register...]);
    $style->end_p();
    $style->end_page();
    $style->show_body();
    
    ?>
    Got questions ? Ask
    Attached Files Attached Files

  9. #9
    Senior Member
    Join Date
    Apr 2006
    Location
    kingston
    Posts
    493
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Default

    every1 has a different way lol. here&#39;s mine
    config.php
    Code:
    <?php
    
    $themedir = "default";
    $pgtitle = "wizardwap.us";
    $prtname = "wizardwap.us";
    $copyright = "© wizardwap.us";
    
    ?>
    core.php
    Code:
    <?php
    
    include("config.php");
    
    connectdb();
    
    define (&#39;WAP&#39;,&#39;text/vnd.wap.wml&#39;);
    define (&#39;WEB&#39;,&#39;application/xhtml+xml&#39;);
    
    $o = $_GET["o"];
    
    if($o=="wml")
    {
    
    $mime = "text/vnd.wap.wml"; 
    
    
    }else if($o=="xml")
    {
    
    $mime = "application/xhtml+xml"; 
    
    }else if($o=="")
    {
    
    ///$getmime = mysql_fetch_array(mysql_query("SELECT site_mime FROM membertable WHERE id=&#39;".$uid."&#39;"));
    ///$v = $getmime[0];
    $v == "";
    
    if($v=="wml") 
    {
    
    $mime = "text/vnd.wap.wml"; 
    
    }else if($v=="xml") 
    {
    
    $mime = "application/xhtml+xml";
    
    }else if($v=="") 
    {
    
    $mtype = "";  
    
    //$mtype = "application/xhtml+xml";// for debugging            
    
    if($mtype=="")
    {
    
    $mime = ((stristr($_SERVER["HTTP_ACCEPT"],"application/xhtml+xml")) ? "application/xhtml+xml" : "text/vnd.wap.wml");
    
    }else{
    
    $mime = $mtype;
    
    }
    }
    }
    
    $charset = "UTF-8";
    header("content-type: $mime; charset=$charset");
    
    function waphead($pgtitle,$uid)
    {
        $rets = "<wml><card id=\"main\" title=\"$pgtitle\">";
        return $rets;
    }
    
    function wapfoot()
    {
        $rets = "</card></wml>";
        return $rets;
    }
    
    function webhead($pgtitle,$uid)
    {
    global $mime, $charset;
    
        $themedir = "default";
    
        $rets = "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" >";
        $rets .= "<head>";
        $rets .= "<title>$pgtitle</title>";
        $rets .= "<meta http-equiv=\"Content-Type\" content=\"".$mime."; charset=".$charset."\" />";
          $rets .= "<meta http-equiv=\"Cache-Control\" content=\"no-cache\" />";
          $rets .= "<meta http-equiv=\"Cache-Control\" content=\"must-revalidate\" />";
        $rets .= "<link rel=\"StyleSheet\" type=\"text/css\" href=\"../themes/".$themedir."/style/style.css\" />";
        $rets .= "</head><body>";
        return $rets;
    }
    
    function webfoot()
    {
        $rets = "</body></html>";
        return $rets;
    }
    ?>
    index.php
    Code:
    <?php
    
    include("core.php");
    
    if($mime== WAP)
    {
        echo "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>";
        echo "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.1//EN\"". " \"http://www.wapforum.org/DTD/wml_1.1.xml\">";
    }else{
        echo "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>";
        echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">";
    }
    
    
        if($mime== WAP)
        {
            echo waphead($pgtitle,$uid);
            
            echo "<p align=\"center\">";
            echo "<img src=\"../themes/".$themedir."/images/logo.png\" alt=\"$pgtitle\"/>";
            echo "</p>";
    
            echo wapfoot();
    
        }else{
            echo webhead($pgtitle,$uid);
            
            echo "<p align=\"center\">";
            echo "<img src=\"../themes/".$themedir."/images/logo.png\" alt=\"$pgtitle\"/>";
            echo "</p>";
            
            echo webfoot();
        }
    
    ?>
    [Only registered and activated users can see links. Click Here To Register...]

  10. #10
    Senior Member blackhowk's Avatar
    Join Date
    Jul 2006
    Location
    Bucharest
    Posts
    411
    Thanks
    0
    Thanked 2 Times in 2 Posts
    Rep Power
    0

    Default

    so.. wich script is much more lite ? easy,etc ..
    [Only registered and activated users can see links. Click Here To Register...]

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [web] 65 Most Needed Php Scripts
    By jayasanka in forum Scripts Forum
    Replies: 19
    Last Post: 09-11-10, 15:30
  2. .htaccess Tutorial
    By GumSlone in forum Tutorials
    Replies: 8
    Last Post: 28-03-10, 00:19
  3. Introduction to PHP
    By AcidBurn in forum Tutorials
    Replies: 7
    Last Post: 26-06-06, 11:08
  4. XHTML Tutorial
    By GumSlone in forum Tutorials
    Replies: 1
    Last Post: 08-12-05, 14:48

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

SEO by vBSEO

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19