Serve JAD files OTA with PHP
November 3, 2008 on 2:14 pm | In J2ME, PHP, Uncategorized | No CommentsSome handy code to dynamtically serve JAD files for OTA installation. The below script sets the appropriate headers types, also tidies up the JAD file removing stray characters which can cause issues and setting the correct file paths internally.
Place the PH script in a root directory as serveJAD.php. Place your JAR and JAD files in a subdirectory /J2ME
Call the script by serveJAD.php?format=J2ME&file={jad minus extension} or you can use the Apache rewrite below and call as /J2ME/file.jad
ie
serveJAD.php?format=J2ME&file=game
or with Apache rewrite
/J2ME/game.jad
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | <? $format = $_GET["format"]; $file = $_GET["file"].".jad"; header("Cache-Control: no-cache, must-revalidate,no-transform" ); header("Pragma: no-cache" ); header("Content-type: text/vnd.sun.j2me.app-descriptor"); header("Content-Disposition: attachment; filename=".$file.";"); $jad = file_get_contents("./".$format."/".$file); $lines = explode("\n",$jad); $final = ""; foreach($lines as $line){ $line = trim($line); if(strlen($line)>0){ $keypair = explode(": ",$line); if($keypair[0]=='MIDlet-Jar-URL' || stristr($keypair[0],"RIM-COD-URL")){ $url = trim($keypair[1]); if(!stristr($url,"http:")){ $keypair[1] = "http://".$_SERVER["HTTP_HOST"]."/$format/".$url; } }else if($keypair[0]=='MIDlet-Jar-Size'){ $keypair[1] = filesize("./".$format."/".$_GET["file"].".jar"); } $line = join(": ",$keypair); $l = trim($line); if(!empty($final))$final.="\n"; $final.=$l; } } print($final); ?> |
RewriteEngine On
RewriteRule /J2ME/(.*)\.jad /serveJAD.php?format=J2ME&file=$1
You can also use this to build automatic index pages, using this as dir.php?format=J2ME
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | <?php $format = $_GET["format"]; $scanthis = "./".$format; $scanlisting = scandir($scanthis); $dirlisting = array(); foreach($scanlisting as $key => $value){ if(stristr($value,"jad")){ $name = explode(".",$value); $dirlisting[$name[0]] = $name[0]; } } ksort($dirlisting); ?> <!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> <link href="apps.css" rel="stylesheet" type="text/css" /> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Application listing</title> </head> <body> <p> <?php foreach($dirlisting as $name){ ?> <a href="/<?php print($format);?>/<?php print($name);?>.jad"><?php print($name);?></a><br /> <?php } ?></p> </body> </html> |
TinyURL alternative
October 10, 2008 on 10:32 pm | In Useful stuff | No Commentshttp://www.time-safe.com provides URL shortening, but also allows you to specify passwords and time ranges for the URL forwarding.
Delete a tag in Javascript
October 9, 2008 on 4:42 pm | In Javascript | No CommentsI use with with AJAX library to completely remove a DIV tag ( or whatever )
function removeTag(tag){
field = document.getElementById(tag);
field.parentNode.removeChild(field);
}
function removeAllChildren(field){
if ( field.hasChildNodes() )
{
while ( field.childNodes.length >= 1 )
{
removeAllChildren(field.firstChild);
field.removeChild(field.firstChild);
}
}
}
Black screen when playing all video in Windows
September 4, 2008 on 4:00 pm | In Windows | No CommentsSo, the other night I decided to clean up my PC and install XP Service pack 3, update my ATI drivers etc etc.
After the reboot, went to play some of my videos, only to find the video display to be black. Audio was fine, everything looked dandy. VLC, Media Player, Nero all refused to show the video.
Doubling checking the codecs, everything looked fine.
The solution - in the back of my head I remembered settings in the Catalyst Control Center. Look under VIDEO and then BASIC color. For some reason, USE APPLICATION SETTINGS was unchecked, and the brightness turned down to zero. I still can’t set it back up higher, but checking the USE APPLICATION SETTING box fixes the issue.
Blocking the searchme.com bot
July 15, 2008 on 4:04 am | In Linux | No CommentsNice idea for a search engine, however, their bot is a disrespectfull bastard, doesn’t obey robots.txt, plus as it’s a visual search engine, processes Javascript tracking which throws your stats off.
Block it using iptables thus
iptables -I INPUT -m iprange --src-range 165.193.254.1-165.193.254.254 -j DROP
iptables -I INPUT -m iprange --src-range 208.111.154.1-208.111.154.254 -j DROP
Powered by WordPress with Pool theme design by Borja Fernandez.
Entries and comments feeds.
Valid XHTML and CSS. ^Top^