Wml + Xhtml In Same Php File ?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Wml + Xhtml In Same Php File ?

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

    #2
    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.
    http://ngeo.ro

    Comment


      #3
      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=\"!\"/>
      
      [b][b]Error! Cannot Connect To Database...[/b][/b]
      
      
      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();
      }
      ?>

      Comment


        #4
        i dont see refference about LAVA script or else in the first post .
        http://ngeo.ro

        Comment


          #5
          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;;
          }
          }
          ?>

          Comment


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

            Comment


              #7
              Thnx guys but blackhowk resolved me

              Comment


                #8
                style.class.php

                Code:
                <?php
                // wml + xhtml style class By Midnex 2007
                // Visit my site at [url="http://wap-online.net"]http://wap-online.net[/url]
                // Skype: midnex
                // ICQ  : 350-772-392
                // Email: [email]midnex@gmail.com[/email]
                
                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;[url="&#39;.$url.&#39;"]&#39;.$text.&#39;[/url]&#39;;
                            }
                            else
                            {
                                $this->body .= &#39;[url="&#39;.$url.&#39;"]&#39;.$text.&#39;[/url]&#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 [url="http://wap-online.net"]http://wap-online.net[/url]
                // Skype: midnex
                // ICQ  : 350-772-392
                // Email: [email]midnex@gmail.com[/email]
                
                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;[url]http://wap-online.net/images/logo.gif&#39;,&#39;Logo&#39;,true[/url]);
                $style->simple_text(&#39;Hello everyone, im glad you visited my site;)&#39;,true);
                $style->add_link(&#39;[url]http://wap-online.net&#39;,&#39;Wap-Online.Net&#39;[/url]);
                $style->end_p();
                $style->end_page();
                $style->show_body();
                
                ?>
                Got questions ? Ask
                Attached Files

                Comment


                  #9
                  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();
                      }
                  
                  ?>

                  Comment


                    #10
                    so.. wich script is much more lite ? easy,etc ..
                    http://ngeo.ro

                    Comment


                      #11
                      The very last script is not effective like others. The best way to join few styles in one is by putting everything in class. Then scripts works quite faster and using it is very simple, while the last script need to check every time if it is wml or xhtml. Instead of checking it in index.php, do it once in a class and everything will be simple

                      Comment


                        #12
                        The very last script is not effective like others. The best way to join few styles in one is by putting everything in class. Then scripts works quite faster and using it is very simple, while the last script need to check every time if it is wml or xhtml. Instead of checking it in index.php, do it once in a class and everything will be simple [/b]

                        true but the script is simple and very easy to understand

                        Comment


                          #13
                          true but the script is simple and very easy to understand[/b]

                          i tried it but it shows my index.php blank dont know why heres my index help please
                          Attached Files

                          Comment


                            #14
                            cant download that file....

                            Comment


                              #15
                              hmm it works for me wizard codeing best i had a blank page first ask link7rx to help him couldnt thats why me so happy
                              i did what cant

                              Comment

                              Working...
                              X