View file wap_snapshot/wap_latest.php

File size: 2.74Kb
<?
header("Content-type:text/vnd.wap.wml");
define('IN_PHPBB', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);


// These are the VARs you may want to change

$num_posts = 5; 	// Number of last posts to display
$HIDE = true; 		//true or false - if true, do not show posts from certain forums - see below
$hide_level = 0;	// display threshold 0=only show posts in forums open for guest reading,1= also registered, 2=also Mods only 3=show ALL posts even those froums for admins only
$TRUNCATE = true; 	// shorten posts messages or not - true or false
$trunc_len = 200;  	//if shortening, to how many chars


//End VARs



$sql="SELECT a1.post_id AS postid, a1.poster_id AS poster, a1.forum_id, a1.topic_id AS topic, a1.post_time AS time, a2.post_subject AS subject, a2.post_text AS text FROM phpbb_posts a1, phpbb_posts_text a2, phpbb_forums a3 WHERE a1.post_id = a2.post_id AND a1.forum_id = a3.forum_id";
  

if($HIDE) $sql .= " AND a3.auth_view <= \"" . $hide_level . "\"";

$sql .= " ORDER BY a1.post_time DESC LIMIT 10";


$result = mysql_query($sql) or die("ERROR Cannot Connect to Database");



print("<?xml version='1.0'?>");
print("<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.1//EN\" \"http://www.wapforum.org/DTD/wml_1.1.xml\">");
print( "<wml>");
print( "<card id=\"main\" title=\"Post Listing\">");
print( "<p><img src=\"phpbb.wbmp\" alt=\"logo_image\" /><br /></p>");



for($i=0;$i<$num_posts;$i++){

	if($post = mysql_fetch_array($result)){
   
  
		if(!$post["subject"]){
			$result2=mysql_query("SELECT topic_title FROM phpbb_topics WHERE topic_id =" . $post["topic"]);
			$replyto = mysql_fetch_array($result2);
			$post["subject"]="RE: " . $replyto["topic_title"];
			mysql_free_result($result2);
		}
		$result3=mysql_query("SELECT username FROM phpbb_users WHERE user_id =" . $post["poster"]);
		$author=mysql_fetch_array($result3);
		print("<p><img src=\"arrow.wbmp\" alt=\"arrow_pic\" /> <b><a href=\"#post" . $i .  "\">" . $post["subject"] . "</a></b><i> on " . date("d-m-y @ H:i:s", $post["time"]) . " By: " . $author["username"] . "</i></p>");
	}
}


print( "</card>");

mysql_freeresult($result);
$result=mysql_query($sql);

for($i=0;$i<$num_posts;$i++){
	if($post = mysql_fetch_array($result)){
		
		
	print( "<card id=\"post" . $i  ."\" title=\"Post Detail\">");
		if($TRUNCATE){$post["text"]= substr($post["text"],0,$trunc_len);}
   		$post["text"] = ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]"," URL Removed ",$post["text"]);
		print( "<p><img src=\"post.wbmp\" alt=\"post_pic\" />" . $post["text"] . "</p>");
		print( "<p><a href=\"#main\">Go Back</a></p>");
		print( "</card>");
		
	}
}
print("</wml>");
?>