|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Deploying Midlets mechanism problem
1 ------ THE LINK -----
My client gets the link (for example): (URL address blocked: See forum rules) 2 ------ THE .HTACCESS FILE and MIME-TYPES ------- I defined needed mime-type on my apache server: application/java-archive jar text/vnd.sun.j2me.app-descriptor jad In the main directory of wap.website.com it is .htaccess file with specified rewrite rule: RewriteEngine on RewriteRule ^x([a-z0-9]+)/([a-z]+)\.jad$ dd.php?c=$1&f=$2 [NC] This rule rewrites this link: (URL address blocked: See forum rules) to this: (URL address blocked: See forum rules)=CODE&file=MidletName 3 ------- THE PHP SCRIPT --------- This is the most important fragments of php script (dd.php), which is responsible for validating code and (if successfull) sending (redirecting to) Midlets to the client wap browser: $download_directory = '(URL address blocked: See forum rules); // Basic redirecting if there is no code or file specified: if(!empty($_GET[c])) {$code = strip_tags($_GET[c]);}else{header('Location: wap.wkomorce.pl');} if(!empty($_GET[f])) {$file = strip_tags($_GET[f]);$file=strtolower($file);}else{header('Location: wap.wkomorce.pl');} /////////////////////////////////////////////// Here is the main body of validating code, connecting to code database, etc.... this works fine. After successfully validating it calls download() function and sets some special ACCESSED flag to deny next using of this link (one try access). download() function is defined below (2 versions tried): ///////////////////////////////////////////// // Version 1: function download() { global $file; global $download_directory; $location = $download_directory.ucfirst($file).'.jad'; header("Location: $location"); //ends the script } // Version 2: function download(){ global $file; global $download_directory; $location = $download_directory.ucfirst($file).'.jad'; header("Content-Type: text/vnd.sun.j2me.app-descriptor"); header("Content-Disposition:inline; filename=".basename($location)); header("Content-length: ".filesize($location)); $sent=readfile($location); fflush(); } 4 ---------- PROBLEMS!!!!!!!!!!!!! PLEASE HELP ----------- * This all mechanism works fine for quite new mobile phones (on theirs wap browser technically) like for instance Nokia 3220 which has Midp 2.0 and almost every newest ones. But I still get claims for clients with older phones (obviously still compatible with Midlets they link for). Examples (just few I remembered): - Nokia 6280 - unknown file format error - SE K750i - non-proper application - Siemens M65 - unknown file format error (or something similar) - Mototola v3i - no file And much more ... but the thing is when I handy prepare emergency link by creating temporary folder temp and put Midlet in it and send link: (URL address blocked: See forum rules)e/temporary_folder/MidletName.jad to clients with mentioned phones - then everything works Ok and problems dissapears. That means there is no problem with Midlet's compatibility but with redirecting mechamism, which doesn't works for some kinds of mobile wap browsers? Anybody can advise me what is going on? I suspect some headers problems but I lost patient to this cos it's imposible for me to try checking it for every model. I'm sure somebody here knows the answer. I'll be very gratefull for help. regards |
|
#2
|
||||
|
||||
|
argh dealing with java games, i hate having to do that. too many makes and models, jads and jars....... it gives me a headache.
you know the only thing i can think of from glancing at the code is most likely going to be something dead trivial like new line characters at the end of the content disposition headers. \n\r\n type stuff. closer inspections sees fflush with two fs, that's going to cause an error you won't see if the headers have been sent and the jar is being deployed. it could be that which is making it screw on old models.
__________________
Andy Moore << oh no it's got a blog..... Word Press WAP Plugin with Ad Mob Advertising revenue PHP developer deploying ringtones, mp3 downloads and realtones I'm a geek who's obsessed with stats and gadgets |
|
#3
|
||||
|
||||
|
just found this post on devshed
aint search a wonderful think lol kinda backs up my thoughts bout \n\n stuff....... |
|
#4
|
|||
|
|||
|
First of all - great thx for answer.
OK - I've change it and cut some download code to be shorter. I found it at some other post where was written that just 2 lines of code is enough. I combined it wiht your advice and know it looks like that: $location = $download_directory.ucfirst($file).'.jad'; header("Content-Type: text/vnd.sun.j2me.app-descriptor\n\n"); header("Content-Disposition: filename=".basename($_REQUEST[$location])); Would this 2 headers be enought? Thanks you for your suggestions. I would never find out it myself. BTW - do not I need this others headers?: header("Content-length: ".filesize($location)); $sent=readfile($location); fflush(); What are they for? I'm asking cos I just know the basics of Php and I found this fragment of code on the net. Thx one more time for answer - it is a first forum somebody had any suggestion for my problem. |
|
#5
|
||||
|
||||
|
Quote:
No, you need more than that, all that would do is set the header with the content type and the header with the content-disposition to force the file to download. It wouldn't do anything else, like send the file which is what it's all about. Quote:
You most certainly need those extra lines, just setting a file type and telling it to download the file isn't enough, those lines get the size of the file so that can be sent as a header, that way the device knows how large the download is and can show a progress bar if the device supports it. The $sent value and readfile are more important than the file size, a download will most likely be okay without a file size header but the readfile is the key to this. Check out www.php.net/readfile for more info on how it does it, also readfile could be replaced with file_get_contents which would do almost the same job. As for the answers, you're welcome. I know what a bitch it can be working with java games, just the number of files and supported devices makes it a headache I'd personally prefer to stay away from. Much respect to those who can make a living deploying midlets. |
|
#6
|
|||
|
|||
|
Hi!
If just anybody still looks here... This solution haven't made the things better! Snippet of code I use now to download is: $location = $download_directory.$file.'.jad'; header("Content-Type: text/vnd.sun.j2me.app-descriptor\n\n"); header("Content-Disposition: filename=".basename($_REQUEST[$location])); header("Content-length: ".filesize($location)); $sent=readfile($location); And this makes the Nokia 6280 (!!!) error unsupported format.... or something similar But this phone is f¤¤ing nice! Please! AM I something misisng here? Cos I m going crazy |
|
#7
|
||||
|
||||
|
i'd bet a beer on it being \n\r\n type stuff at the end of the content disposition header.
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Mobile Programming > Deploying Midlets mechanism problem |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|