4images Modifications / Modifikationen > Mods & Plugins (Releases & Support)

[MOD] WAP page to download files.

(1/8) > >>

universal:
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: ---<?
//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>
--- End code ---

3. Edit details.html and add this where you like:

--- Code: ---      <tr>
        <td><b>ID for WAP</b></td>
        <td>{image_id}</td>
      </tr>

--- End code ---

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 ;]

b.o.fan:
crazy. but i does´nt go on my system.
http://wap.wartenaufden15.de

why??

my index.php


--- Code: ---<?
//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>
--- End code ---

universal:
Because you have editted the code:

--- Code: ---//dont need to change after this
header("Content-type: text/wml");
--- End code ---

this you replaced with this:


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

So you get parsing error, try to do like in my example ;)

universal:
how it looks, it`s in lithuanian :)

b.o.fan:
oki. my index.php.
in my http://www.wartenaufden15.de/wap or the subdomain http://wap.wartenaufden15.de

my index.php

--- Code: ---<?
//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>
--- End code ---

Navigation

[0] Message Index

[#] Next page

Go to full version