Author Topic: [MOD] WAP page to download files.  (Read 78192 times)

0 Members and 1 Guest are viewing this topic.

Offline universal

  • Full Member
  • ***
  • Posts: 213
    • View Profile
    • http://www.funny.lt
[MOD] WAP page to download files.
« on: March 27, 2005, 05:56:59 PM »
Today I have made my first mod for 4images gallery  :wink:
I`m using it for a special category for mobile phones, there are a lot of *.mid files, and users can get it by writing its ID in my WAP page. So... there it goes.

Need to edit one file, and create one.
1. Make a dir something like "wap" at your server.
2. Put file named index.php into dir, with this text (edit settings first  :wink: ):
Code: [Select]
<?
//Some settings
$url = 'http://url.to.your.page'; //where installed 4images, without traling slash
$title = 'wap page'; //title for wap card
$no_id = 'ID not found'; //msg when no id found
$enter_id = 'Enteri ID'; //msg when user comes
$button = 'show'; //text for button
$footer = 'footer'; //footer text
$dbhost = "localhost"; //host of database
$dbuser = "root"; //database user
$dbpass = ""; //database pass
$dbname = ""; //and database ;]

//dont need to change after this
header("Content-type: text/wml");
echo("<?xml version=\"1.0\" encoding=\"windows-1257\"?>\n");
echo("<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.1//EN\""
." \"http://www.wapforum.org/DTD/wml_1.1.xml\">\n");
?>
<wml>
<card title="<? echo $title ?>">
<center>
<form method="post">
<?php 
$id 
$_REQUEST['id'];
if(
$id!=""){
$db mysql_connect("$dbhost""$dbuser""$dbpass") or die ("Error");
@
mysql_select_db("$dbname"$db) or die ("DB not found");
$result mysql_query("SELECT image_id, image_media_file, cat_id, image_name FROM 4images_images where image_id=$id");
$row mysql_fetch_array($result);
$image_id $row["image_id"];
$cat_id $row["cat_id"];
$image_name $row["image_name"];
if (
$image_id!=""){
$image_media_file $row["image_media_file"];
?>

<a href="<? echo $url;?>/data/media/<? echo $cat_id;echo "/";echo $image_media_file; ?>"><? echo $image_name;?></a><br />
<?php }
else { echo 
$no_id; } }
else { echo 
$enter_id; }
?>

<br />
<input name="id" type="text" id="id" size="6" /><br />
<input name="submit" type="submit" value="<? echo $button ?>" />
</form>
<br />
<small>&reg; <? echo $footer ?></small>
</center>
</card>
</wml>

3. Edit details.html and add this where you like:
Code: [Select]
      <tr>
        <td><b>ID for WAP</b></td>
        <td>{image_id}</td>
      </tr>

4. Point your mobile to this page and try it.

By changing this "/data/media/" to "/data/thumbnails/" you can show only small pictures, but i`m using this script for mobile melodies in *.mid format, so it works  :wink:
Sorry for my english.

Good luck ;]
Again this addres?!
http://www.funny.lt

b.o.fan

  • Guest
Re: [MOD] WAP page to download files.
« Reply #1 on: April 06, 2005, 07:46:09 PM »
crazy. but i does´nt go on my system.
http://wap.wartenaufden15.de

why??

my index.php

Code: [Select]
<?
//Some settings
$url = 'http://wartenaufden15.de'; //where installed 4images, without traling slash
$title = 'wap.wartenaufden15.de'; //title for wap card
$no_id = 'ID nicht gefunden'; //msg when no id found
$enter_id = 'Gib die ID ein'; //msg when user comes
$button = 'Anzeigen'; //text for button
$footer = '(c) 2005 by wartenaufden15.de'; //footer text
$dbhost = "localhost"; //host of database
$dbuser = "DBxxxxxx"; //database user
$dbpass = "xxxxxxx"; //database pass
$dbname = "DBxxxxxx"; //and database ;]

//dont need to change after this
header("Content-type: text/vnd.wap.wml");
echo("Content-type: text/vnd.wap.wml\n");
echo("<?xml version=\"1.0\" encoding=\"windows-1257\"\n");
echo("<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.1//EN\""
." \"http://www.wapforum.org/DTD/wml_1.1.xml\">\n");
?>
<wml>
<card title="<? echo $title ?>">
<center>
<form method="post">
<?php
$id 
$_REQUEST['id'];
if(
$id!=""){
$db mysql_connect("$dbhost""$dbuser""$dbpass") or die ("Error");
@
mysql_select_db("$dbname"$db) or die ("DB not found");
$result mysql_query("SELECT image_id, image_media_file, cat_id, image_name FROM 4images_images where image_id=$id");
$row mysql_fetch_array($result);
$image_id $row["image_id"];
$cat_id $row["cat_id"];
$image_name $row["image_name"];
if (
$image_id!=""){
$image_media_file $row["image_media_file"];
?>

<a href="<? echo $url;?>/data/thumbnails/<? echo $cat_id;echo "/";echo $image_media_file; ?>"><? echo $image_name;?></a><br />
<?php }
else { echo 
$no_id; } }
else { echo 
$enter_id; }
?>

<br />
<input name="id" type="text" id="id" size="6" /><br />
<input name="submit" type="submit" value="<? echo $button ?>" />
</form>
<br />
<small>&reg; <? echo $footer ?></small>
</center>
</card>
</wml>

Offline universal

  • Full Member
  • ***
  • Posts: 213
    • View Profile
    • http://www.funny.lt
Re: [MOD] WAP page to download files.
« Reply #2 on: April 07, 2005, 05:07:55 AM »
Because you have editted the code:
Code: [Select]
//dont need to change after this
header("Content-type: text/wml");

this you replaced with this:

Code: [Select]
//dont need to change after this
header("Content-type: text/vnd.wap.wml");
echo("Content-type: text/vnd.wap.wml\n");

So you get parsing error, try to do like in my example ;)
Again this addres?!
http://www.funny.lt

Offline universal

  • Full Member
  • ***
  • Posts: 213
    • View Profile
    • http://www.funny.lt
Re: [MOD] WAP page to download files.
« Reply #3 on: April 07, 2005, 08:39:13 AM »
how it looks, it`s in lithuanian :)
Again this addres?!
http://www.funny.lt

b.o.fan

  • Guest
Re: [MOD] WAP page to download files.
« Reply #4 on: April 07, 2005, 05:06:35 PM »
oki. my index.php.
in my http://www.wartenaufden15.de/wap or the subdomain http://wap.wartenaufden15.de

my index.php
Code: [Select]
<?
//Some settings
$url = 'http://wartenaufden15.de'; //where installed 4images, without traling slash
$title = 'wap.wartenaufden15.de'; //title for wap card
$no_id = 'ID nicht gefunden'; //msg when no id found
$enter_id = 'Gib die ID ein'; //msg when user comes
$button = 'Anzeigen'; //text for button
$footer = '(c) 2005 by wartenaufden15.de'; //footer text
$dbhost = "localhost"; //host of database
$dbuser = "DB16XXXX"; //database user
$dbpass = "XXXXXXXX"; //database pass
$dbname = "DB16XXXX"; //and database ;]

//dont need to change after this
header("Content-type: text/vnd.wap.wml");
echo("Content-type: text/vnd.wap.wml\n");
echo("<?xml version=\"1.0\" encoding=\"windows-1257\"\n");
echo("<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.1//EN\""
." \"http://www.wapforum.org/DTD/wml_1.1.xml\">\n");
?>
<wml>
<card title="<? echo $title ?>">
<center>
<form method="post">
<?php
$id 
$_REQUEST['id'];
if(
$id!=""){
$db mysql_connect("$dbhost""$dbuser""$dbpass") or die ("Error");
@
mysql_select_db("$dbname"$db) or die ("DB not found");
$result mysql_query("SELECT image_id, image_media_file, cat_id, image_name FROM 4images_images where image_id=$id");
$row mysql_fetch_array($result);
$image_id $row["image_id"];
$cat_id $row["cat_id"];
$image_name $row["image_name"];
if (
$image_id!=""){
$image_media_file $row["image_media_file"];
?>

<a href="<?php echo $url;?>/data/thumbnails/<?php echo $cat_id;echo "/";echo $image_media_file?>"><?php echo $image_name;?></a><br />
<?php }
else { echo 
$no_id; } }
else { echo 
$enter_id; }
?>

<br />
<input name="id" type="text" id="id" size="6" /><br />
<input name="submit" type="submit" value="<?php echo $button ?>" />
</form>
<br />
<small>&reg; <? echo $footer ?></small>
</center>
</card>
</wml>

Offline universal

  • Full Member
  • ***
  • Posts: 213
    • View Profile
    • http://www.funny.lt
Re: [MOD] WAP page to download files.
« Reply #5 on: April 07, 2005, 06:04:23 PM »
try this...  :wink:
Code: [Select]
<?
//Some settings
$url = 'http://wartenaufden15.de'; //where installed 4images, without traling slash
$title = 'wap.wartenaufden15.de'; //title for wap card
$no_id = 'ID nicht gefunden'; //msg when no id found
$enter_id = 'Gib die ID ein'; //msg when user comes
$button = 'Anzeigen'; //text for button
$footer = '(c) 2005 by wartenaufden15.de'; //footer text
$dbhost = "localhost"; //host of database
$dbuser = "DB16XXXX"; //database user
$dbpass = "XXXXXXXX"; //database pass
$dbname = "DB16XXXX"; //and database ;]

//dont need to change after this
header("Content-type: text/wml");
echo("<?xml version=\"1.0\" encoding=\"windows-1257\"?>\n");
echo("<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.1//EN\""
." \"http://www.wapforum.org/DTD/wml_1.1.xml\">\n");
?>
<wml>
<card title="<? echo $title ?>">
<center>
<form method="post">
<?php
$id 
$_REQUEST['id'];
if(
$id!=""){
$db mysql_connect("$dbhost""$dbuser""$dbpass") or die ("Error");
@
mysql_select_db("$dbname"$db) or die ("DB not found");
$result mysql_query("SELECT image_id, image_media_file, cat_id, image_name FROM 4images_images where image_id=$id");
$row mysql_fetch_array($result);
$image_id $row["image_id"];
$cat_id $row["cat_id"];
$image_name $row["image_name"];
if (
$image_id!=""){
$image_media_file $row["image_media_file"];
?>

<a href="<?php echo $url;?>/data/thumbnails/<?php echo $cat_id;echo "/";echo $image_media_file?>"><?php echo $image_name;?></a><br />
<?php }
else { echo 
$no_id; } }
else { echo 
$enter_id; }
?>

<br />
<input name="id" type="text" id="id" size="6" /><br />
<input name="submit" type="submit" value="<?php echo $button ?>" />
</form>
<br />
<small>&reg; <? echo $footer ?></small>
</center>
</card>
</wml>
Again this addres?!
http://www.funny.lt

b.o.fan

  • Guest
Re: [MOD] WAP page to download files.
« Reply #6 on: April 07, 2005, 06:15:38 PM »
oki.
than look @ the wap page.

Offline universal

  • Full Member
  • ***
  • Posts: 213
    • View Profile
    • http://www.funny.lt
Re: [MOD] WAP page to download files.
« Reply #7 on: April 07, 2005, 06:21:41 PM »
working  :wink:
Again this addres?!
http://www.funny.lt

Offline ryann

  • Newbie
  • *
  • Posts: 19
    • View Profile
Re: [MOD] WAP page to download files.
« Reply #8 on: April 10, 2005, 11:57:25 AM »
mine says unknown file format when i goto it on my fone. Does anyone else have this error, or can you help me ?

Offline universal

  • Full Member
  • ***
  • Posts: 213
    • View Profile
    • http://www.funny.lt
Re: [MOD] WAP page to download files.
« Reply #9 on: April 10, 2005, 12:04:31 PM »
what phone you browse with?
wml format is supported by many mobile phones.
Again this addres?!
http://www.funny.lt

Offline ryann

  • Newbie
  • *
  • Posts: 19
    • View Profile
Re: [MOD] WAP page to download files.
« Reply #10 on: April 10, 2005, 12:20:25 PM »
so the /wap/index has to be .php ? i cant think of anything other reason why it doesnt work. can you ?

Offline universal

  • Full Member
  • ***
  • Posts: 213
    • View Profile
    • http://www.funny.lt
Re: [MOD] WAP page to download files.
« Reply #11 on: April 10, 2005, 01:54:14 PM »
the file must be index.php
 this:
Code: [Select]
echo("<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.1//EN\""
." \"http://www.wapforum.org/DTD/wml_1.1.xml\">\n");

shows browser what type of document is this, so it must work.
Again this addres?!
http://www.funny.lt

Offline LBL

  • Pre-Newbie
  • Posts: 5
    • View Profile
Re: [MOD] WAP page to download files.
« Reply #12 on: April 10, 2005, 07:59:20 PM »
Today I have made my first mod for 4images gallery  :wink:
I`m using it for a special category for mobile phones, there are a lot of *.mid files, and users can get it by writing its ID in my WAP page. So... there it goes.

Need to edit one file, and create one.
1. Make a dir something like "wap" at your server.
2. Put file named index.php into dir, with this text (edit settings first  :wink: ):
Code: [Select]
<?
//Some settings
$url = 'http://url.to.your.page'; //where installed 4images, without traling slash
$title = 'wap page'; //title for wap card
$no_id = 'ID not found'; //msg when no id found
$enter_id = 'Enteri ID'; //msg when user comes
$button = 'show'; //text for button
$footer = 'footer'; //footer text
$dbhost = "localhost"; //host of database
$dbuser = "root"; //database user
$dbpass = ""; //database pass
$dbname = ""; //and database ;]

//dont need to change after this
header("Content-type: text/wml");
echo("<?xml version=\"1.0\" encoding=\"windows-1257\"?>\n");
echo("<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.1//EN\""
." \"http://www.wapforum.org/DTD/wml_1.1.xml\">\n");
?>
<wml>
<card title="<? echo $title ?>">
<center>
<form method="post">
<?php 
$id 
$_REQUEST['id'];
if(
$id!=""){
$db mysql_connect("$dbhost""$dbuser""$dbpass") or die ("Error");
@
mysql_select_db("$dbname"$db) or die ("DB not found");
$result mysql_query("SELECT image_id, image_media_file, cat_id, image_name FROM 4images_images where image_id=$id");
$row mysql_fetch_array($result);
$image_id $row["image_id"];
$cat_id $row["cat_id"];
$image_name $row["image_name"];
if (
$image_id!=""){
$image_media_file $row["image_media_file"];
?>

<a href="<? echo $url;?>/data/media/<? echo $cat_id;echo "/";echo $image_media_file; ?>"><? echo $image_name;?></a><br />
<?php }
else { echo 
$no_id; } }
else { echo 
$enter_id; }
?>

<br />
<input name="id" type="text" id="id" size="6" /><br />
<input name="submit" type="submit" value="<? echo $button ?>" />
</form>
<br />
<small>&reg; <? echo $footer ?></small>
</center>
</card>
</wml>

3. Edit details.html and add this where you like:
Code: [Select]
      <tr>
        <td><b>ID for WAP</b></td>
        <td>{image_id}</td>
      </tr>

4. Point your mobile to this page and try it.

By changing this "/data/media/" to "/data/thumbnails/" you can show only small pictures, but i`m using this script for mobile melodies in *.mid format, so it works  :wink:
Sorry for my english.

Good luck ;]

can you show please what is every part? you know, like where the footer text is etc...
thx!

Offline universal

  • Full Member
  • ***
  • Posts: 213
    • View Profile
    • http://www.funny.lt
Re: [MOD] WAP page to download files.
« Reply #13 on: April 10, 2005, 08:14:33 PM »
Everything there is very simple ;]


These is only settings, needed by script later
Quote
<?
//Some settings
$url = 'http://url.to.your.page'; //where installed 4images, without traling slash
$title = 'wap page'; //title for wap card
$no_id = 'ID not found'; //msg when no id found
$enter_id = 'Enteri ID'; //msg when user comes
$button = 'show'; //text for button
$footer = 'footer'; //footer text
$dbhost = "localhost"; //host of database
$dbuser = "root"; //database user
$dbpass = ""; //database pass
$dbname = ""; //and database ;]

Page header:
Quote
//dont need to change after this
header("Content-type: text/wml");
echo("<?xml version=\"1.0\" encoding=\"windows-1257\"?>\n");
echo("<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.1//EN\""
." \"http://www.wapforum.org/DTD/wml_1.1.xml\">\n");
?>

Begining of the page:
Quote
<wml>
<card title="<? echo $title ?>"> <-- echo title name from settings ;]
<center>
<form method="post">
<?php
$id = $_REQUEST['id']; <-- gets user posted values from form
if($id!=""){
$db = mysql_connect("$dbhost", "$dbuser", "$dbpass") or die ("Error"); <-- connects to the database, and gets all information
@mysql_select_db("$dbname", $db) or die ("DB not found");
$result = mysql_query("SELECT image_id, image_media_file, cat_id, image_name FROM 4images_images where image_id=$id");
$row = mysql_fetch_array($result);
$image_id = $row["image_id"];
$cat_id = $row["cat_id"];
$image_name = $row["image_name"];
if ($image_id!=""){
$image_media_file = $row["image_media_file"];
?>

prints a link to media file:
<a href="<? echo $url;?>/data/media/<? echo $cat_id;echo "/";echo $image_media_file; ?>"><? echo $image_name;?></a><br />
<?php }
else { echo $no_id; } } <-- if no id given
else { echo $enter_id; } <-- enter ID
?>
<br />
<input name="id" type="text" id="id" size="6" /><br />
<input name="submit" type="submit" value="<? echo $button ?>" /> <-- button name from settings
</form>
<br />
<small>&reg; <? echo $footer ?></small> <-- footer from settings
</center>
</card>
</wml>
Again this addres?!
http://www.funny.lt

Offline LBL

  • Pre-Newbie
  • Posts: 5
    • View Profile
Re: [MOD] WAP page to download files.
« Reply #14 on: April 10, 2005, 09:59:26 PM »
yeah, it is simple but i don't know what every one of these means....
i mean, if you can show an example of how the page should look like with those settings.

Quote
<?
$title = 'wap page'; //title for wap card
$no_id = 'ID not found'; //msg when no id found
$enter_id = 'Enteri ID'; //msg when user comes
$button = 'show'; //text for button
$footer = 'footer'; //footer text