Connecting Tech Pros Worldwide Forums | Help | Site Map

xml tp html or php

Newbie
 
Join Date: Jun 2008
Posts: 3
#1: Jun 25 '08
sir the below script is wap script in xml,if possible to converet html or php plz edit and put here sir
[HTML]<? //include the space function found on php.net Include ('data/function_dskspace.php'); //headers header("Content-type: text/vnd.wap.wml"); echo "<?xml version=\"1.0\"?>"; echo "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.1//EN\""." \"http://www.wapforum.org/DTD/wml_1.1.xml\">"; //sadhu's genius one line fix $page = $_GET["page"]; //how many files do you want shown on each page? EDIT $conf["items_per_page"] = 7; //if the page number is not set, set it too.. Zero/home if (!isset($page)) {$page = 0;} //open our directory or give error message if(!($dp = opendir("./"))) die ("Cannot open ./"); //array and read directory $file_array = array(); while ($file = readdir ($dp)) { //don't want to show that index really eh if(substr($file,0,1) != '.' and $file != "index.php") { $file_array[] = $file; } } //count files in dir $file_count = count ($file_array); //sort the file order sort ($file_array); //main page ?> <wml> <card id="card1" title="wappyBUDDY"> <p align ="center" mode="nowrap"> <img src="" alt="frendz"/><br/><br/></p><p align ="left" mode="nowrap"> <? //if is no files give error message if ($file_count=="0"){echo "<small>Sorry there are $file_count files in this folder!</small>";} //if there is some files if ($file_count > 0) { $first_record = $page * $conf["items_per_page"]; $last_record = $first_record + $conf["items_per_page"]; while (list($fileIndexValue, $file_name) = each ($file_array)) { if (($fileIndexValue >= $first_record) AND ($fileIndexValue < $last_record)) { //icon code so we know the extension of files and can assign the correct gif. I did want to use the mimetype function but found it didn't work on all servers sigh.. $icon = "data/unknown.gif"; $rev = strrev ($file_name); $exp = explode (".", $rev); $true = strrev ($exp[0]); $trueext = strtolower ($true); if ($trueext=="zip" OR $trueext=="rar" OR $trueext=="gz"){$icon = "data/zip.gif";} if ($trueext=="amr"){$icon = "data/amr.gif";} if ($trueext=="midi"){$icon = "data/midi.gif";} if ($trueext=="mid"){$icon = "data/mid.gif";} if ($trueext=="gif"){$icon = "data/gif.gif";} if ($trueext=="jpeg"){$icon = "data/jpeg.gif";} if ($trueext=="jpg"){$icon = "data/jpg.gif";} if ($trueext=="jad"){$icon = "data/jad.gif";} if ($trueext=="jar"){$icon = "data/jar.gif";} if ($trueext=="sis"){$icon = "data/sis.gif";} if ($trueext=="bmp"){$icon = "data/bmp.gif";} if ($trueext=="wbmp"){$icon = "data/wbmp.gif";} if ($trueext=="txt"){$icon = "data/txt.gif";} if ($trueext=="avi"){$icon = "data/avi.gif";} if ($trueext=="thm"){$icon = "data/thm.gif";} if ($trueext=="nth"){$icon = "data/nth.gif";} if ($trueext=="png"){$icon = "data/png.gif";} if ($trueext=="mmf"){$icon = "data/mp4.gif";} if ($trueext=="wav"){$icon = "data/wav.gif";} //find true path of this site.. Ah don't ya just love php.net $docname = "" . $_SERVER [ 'SERVER_NAME' ] . $_SERVER [ 'PHP_SELF' ]; $path = dirname($docname); $path = str_replace ("www.", "", $path); //get rid of ext on files $linkname = str_replace (".$trueext", "", $file_name); //blah getting bored now.. Time for a joint.. $kb="kb"; $number=($fileIndexValue+1); //right.. filesize $size = round(filesize($file_name)/1024,1); //set dir and file values $dirlinks = "<small><img src=\"data/dir.gif\" alt=\"$number\"/>$file_name [dir]<br/>$number: </small><input type=\"text\" title=\"Directory:\" value=\"not allowed [directory]\"/><br/><br/>"; $filelinks = "<small><a href=\"$file_name\"><img src=\"$icon\" alt=\"$number\"/>$linkname [$size$kb]</a><br/>$number: </small><input type=\"text\" title=\"File URL:\" value=\"http://$path/$file_name\"/><br/><br/>"; //show/determine file an dir if (is_dir($file_name)){echo $dirlinks;}else{ echo $filelinks;} } } ?> </p><p align ="center" mode="nowrap"> <? //pages set up $mb = "mb"; $pages = (int) ceil($file_count / $conf["items_per_page"]); $pages = ($pages -1); if ($pages>0){if ($page=="0"){echo "<small>Home Page<br/><br/></small>";}else{ echo "<small><br/>Page $page of $pages<br/><br/></small>";}} if (($file_count > 0) AND ($page != 0)) //previous page { $prev_page = $page -1; echo "<small><a href=\"".$_SERVER["PHP_SELF"]."?page=$prev_page\">«Prev</a></small>"; } if (($file_count > 0) AND ($last_record < $file_count)) //next page { $next_page = $page + 1; if ($page=="0"){$break="";}else{$break="|";} echo "$break<small><a href=\"".$_SERVER["PHP_SELF"]."?page=$next_page&amp;sid=$sid\">Next»</a></small>"; } //watch for numptys putting non existant pages in jumpbox if ($page>$pages){echo "<br/><small><br/><br/>This page does not exist!</small>";} //show the jumpbox if($pages>1)echo "<br/><br/><input emptyok=\"true\" name=\"jump\" format=\"*N\" size=\"3\" value=\"\" /><small><br/><a href=\"".$_SERVER["PHP_SELF"]."?page=$(jump)&amp;sid=$sid\">Jump [1-$pages]</a></small>"; if ($page<$pages){echo "<br/><small><a href=\"".$_SERVER["PHP_SELF"]."?page=$pages&amp;sid=$sid\">Last Page</a></small>";} if ($page=="0" AND $file_count>$conf["items_per_page"]){echo "<br/>";} if ($page>0){echo "<br/><small><a href=\"".$_SERVER["PHP_SELF"]."?page=0&amp;sid=$sid\">Home Page</a><br/></small>";} //file count echo "<small><br/>$file_count </small>"; //diskspace $space = dskspace ('./'); $space = round ($space/1024000,1); //show em lol echo "<small>files [$space$mb]</small>"; //show the path so ya site url is at bottom echo "<br/><small>$path</small>"; } //close our directory ah.. closedir($dp); //WE REQUEST THAT YOU DO NOT REMOVE THE COPYRIGHT/LINK BELOW. //GIVE CREDIT WHERE CREDIT IS DUE! echo "<small><br/>All Rights Reserved<br/>©2003, 2006 <a href=\"http://hack.s-60.org\">raghu</a><u>&</u><a href=\"http://jonroig.com\">jon</a></small>"; ?> </p> </card> </wml> [/HTML]

Atli's Avatar
Moderator
 
Join Date: Nov 2006
Location: Iceland
Posts: 3,757
#2: Jun 25 '08

re: xml tp html or php


Hi.

First of all... that has to be the worst formated piece of code I've ever seen!
What happened to all the new-line chars?

Second. We are not here to create your code for you. Try it yourself and post back if you have any specific problems and we will be happy to do what we can to help you.

If you are just asking for some tips on how to do this, please specify what it is you are attempting to do. I can't really make out what it is you want from the vague statement you made in your post.

Lastly, I would ask that you read through the Posting Guidelines before posting again, specifically the part about How to ask a question.

Thanks.
hsriat's Avatar
Expert
 
Join Date: Jan 2008
Location: Bath, UK
Posts: 1,609
#3: Jun 25 '08

re: xml tp html or php


Quote:

Originally Posted by Atli

First of all... that has to be the worst formated piece of code I've ever seen!

lol!.. I agree

Hey Jackrose,
Its not a regular thing to convert WML to HTML as they have different approach. HTML page is one page, shown at screen at one time. But WML may contain multiple cards (one time screens). So you first need to separate the cards. Then for each card, you would need to convert the markup to HTML.

I would suggest, if this is the only page you need to convert, do it manually. But if the list is long, you should try to make a markup convector using PHP and RegExp.

But I see that there's PHP in the code along with WML, so you need to convert the generated markup and then place it back in the PHP.

Regards
Reply


Similar PHP bytes