Location: PHPKode > scripts > LazyWAP > lazywap/index.php3
<?php
// LazyWAP v.0.5 by Mike Baikov (hide@address.com)
// http://www.tourbase.ru/zink/
// HTML-to-WAP converter
// requirements: PHP 3.0.13 or higher, or PHP4B3 or higher
//
// HOW TO USE:
// place this file (index.php3) in a directory with the files
// to be converted. That's all
//
// DESIGN NOTES
// files to be converted should not contain tables or JavaScript,
// links should be relative (LazyWAP will convert them automatically)
// WAP is pricky about closed tags !
//
// SECURITY NOTES
// For security reasons LazyWAP works only with files in the dierctory
// where it is installed. Also it is strongly recommended not to place
// files with passwords or other sensitive data in this directory.
//
// you should use this format to point to a specific file:
// index.php3?file=filename
//
// if a file is longer than it is allowed then it is split
// BEWARE: splitting may produce errors
//
// DEVELOPER NOTES
//
// Contact the author if you have made changes to LazyWAP
//
// DISCLAIMER
//
// This software is provided AS IS with NO WARRANTY as to everything
// USE IT AT YOUR OWN RISK


// CONFIGURATION
// maximum page length
$cut=4000;
// uncomment this to strip <a></a> tags
//$noa=1;
// name of the default file
$default="start.html";
// Configuration end, don't change anything below this point.

error_reporting(0);
if ($file==$PHP_SELF){
$file=$default;
};
if ((!isset($file)) OR ($file=="")){
$file=$default;
if (!file_exists($file)){
die("Default file not found");
};
};
$file=str_replace("/","",$file);
$file=str_replace("\\","",$file);
if (!file_exists($file)){
$file=$default;
};
$fp=fopen($file,"r");
$string=fread($fp,filesize($file));
if (eregi("<title>((.)+)</title>",$string,$regs)){
$title=strip_tags($regs[1]);
}else{
$title=" ";
};
$string=eregi_replace("<title>((.)+)</title>","",$string);
if (!isset($noa)){
$add="";
$string=strip_tags($string,"<p><br><a><b>");
}else{
$add="&noa=1";
$string=strip_tags($string,"<p><br><b>");
};
$string=eregi_replace("(( )+)"," ",$string);
$string=eregi_replace("<br>","<br/>",$string);
$string=eregi_replace("((\n|\r)+)","\n",$string);
$string=eregi_replace("<a(( |\n|\r){1})href=(\"|')","<a href=\"$PHP_SELF?file=",$string);
// here comes the WAP headers
header("Content-Type: text/vnd.wap.wml;");
print "<?xml version=\"1.0\"?>\n";
?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">
<wml>
<card title="<? print $title ?>">
<?
if (strlen($string)>$cut){
$totest=substr($string,$cut+$offset,1);
while($totest!="\n"){
$totest=substr($string,$cut+$offset,1);
$cut=$cut-1;
};
$cut++;
if (isset($offset)){
if ($offset>=$cut){
$tmp=$offset-$cut;
?>
[<a href="<?print "$PHP_SELF?file=$file&offset=$tmp$add"?>">back</a>]
<?
};
}else{
$offset=0;
};
print substr($string,$offset,$cut);
$offset=$offset+$cut;
if (strlen($string)>$offset){
?>
[<a href="<?print "$PHP_SELF?file=$file&offset=$offset$add"?>">continue</a>]
<?
};
} else {
print $string;
};
?>
</card>
</wml>
Return current item: LazyWAP