Просмотр файла print.php

Размер файла: 4.27Kb
<?php

/* version  0.5
   home     http://wapnuke.org/
   author   Antonio Terreno
   email    [email protected]
*/

######################################################################
# PHP-NUKE: Web Portal System: Wap Add-on 
# ===========================================
#
# This module is to view your last news items via wap enabled devices 
# This program is free software. You can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License.
#
# Copyright (c) 2002 by Antonio Terreno - http://java2me.org
######################################################################

if (!eregi("modules.php", $PHP_SELF)) {
	die ("You can't access this file directly...");
}
require_once("mainfile.php");
$module_name = basename(dirname(__FILE__));
get_lang($module_name);

header("Content-type: text/vnd.wap.wml");
//Puts the header content type to wml

if(!isset($sid)) {
    exit();
}
function PrintPage($sid) {

global $site_logo, $nukeurl, $sitename, $datetime, $prefix, $dbi;

//now wapnuke supports all tags :-D 

$search  = array  ("'(<\/?)(w+)([^>]*>)'e",
                   "'(<\/?)(br|hr)([^>]*)( />)'ie", 
                   "'(<\/?)(br|hr)([^>]*)(/>)'ie",
                   "'(<\/?)(br|hr)([^>]*)(>)'ie",
                   "'(w+=)(w+)'ie",
                   "'(w+=)(.+?)'ie",
                   "'(<\/?)(img|input|table|td|tr|font)([^>]*)( />)'ie",
                   "'(<\/?)(img|input|table|td|tr|font)([^>]*)(/>)'ie",
                   "'(<\/?)(img|input|table|td|tr|font)([^>]*)(>)'ie",
		   "'(<\/?)(p|blockquote|h1|h2|h3|h4|h5|h6|div|code|tt|em|strong|i|cite|b|pre)([^>]*)( />)'ie",
                   "'(<\/?)(p|blockquote|h1|h2|h3|h4|h5|h6|div|code|tt|em|strong|i|cite|b|pre)([^>]*)(/>)'ie",
                   "'(<\/?)(p|blockquote|h1|h2|h3|h4|h5|h6|div|code|tt|em|strong|i|cite|b|pre)([^>]*)(>)'ie",
                   "'(*)(&|<|>|©|®|ґ|«|»|Ў|ї|А|а|Б|б|В|в|Г|г|Д|д|Е|е|Ж|ж|З|з|Р|р|И|и|Й|й|К|к|Л|л|М|м|Н|н|О|о|П|п|С|с|Т|т|У|у|Ф|ф|Х|х|Ц|ц|Ш|ш|Щ|ъ|Ы|ы|Ь|ь|Э|э|я|Ю|ю|Я)(*)'ie");



$replace = array ("'\\1'.strtolower('\\2').'\\3'",
                   "'\\1\\2\\3>'",
                   "'\\1\\2\\3>'",
                   "'\\1\\2\\3 /\\4'",
                   "strtolower('\\1').'\"\\2\"'",
                   "strtolower('\\1').'\\2'",
		   " ",
		   " ",
		   " ",
                   "'\\1'.strtolower('\\2').'\\3'.'\\4'",
		   "'\\1'.strtolower('\\2').'\\3'.'\\4'",
		   "'\\1'.strtolower('\\2').'\\3'.'\\4'",
                   "'(*)(&amp;|&lt;|&gt;|&copy;|&reg;|&acute;|&laquo;|&raquo;|&iexcl;|&iquest;|&Agrave;|&agrave;|&Aacute;|&aacute;|&Acirc;|&acirc;|&Atilde;|&atilde;|&Auml;|&auml;|&Aring;|&aring;|&AElig;|&aelig;|&Ccedil;|&ccedil;|&ETH;|&eth;|&Egrave;|&egrave;|&Eacute;|&eacute;|&Ecirc;|&ecirc;|&Euml;|&euml;|&Igrave;|&igrave;|&Iacute;|&iacute;|&Icirc;|&icirc;|&Iuml;|&iuml;|&Ntilde;|&ntilde;|&Ograve;|&ograve;|&Oacute;|&oacute;|&Ocirc;|&ocirc;|&Otilde;|&otilde;|&Ouml;|&ouml;|&Oslash;|&oslash;|&Ugrave;|&uacute;|&Ucirc;|&ucirc;|&Uuml;|&uuml;|&Yacute;|&yacute;|&yuml;|&THORN;|&thorn;|&szlig;)(*)'ie");
 
$result = sql_query("select title, time, hometext, bodytext, topic, notes from ".$prefix."_stories where sid=$sid", $dbi);
       
    list($title, $time, $hometext, $bodytext, $topic, $notes) = sql_fetch_row($result, $dbi);
    
    $result2 = sql_query("select topictext from ".$prefix."_topics where topicid=$topic", $dbi);

    list($topictext) = sql_fetch_row($result2, $dbi);
    formatTimestamp($time);

$homexhtml = preg_replace($search, $replace, $hometext);	
$bodyxhtml = preg_replace($search, $replace, $bodytext);	

echo "<?xml version=\"1.0\"?>\n"
    ."<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.2//EN\" \"http://www.wapforum.org/DTD/wml12.dtd\">"
    ."<wml>\n\n"
    ."<template>"
    ."<do name=\"back\" type=\"prev\" label=\"Back\">"
    ."<prev/>"
    ."</do>"
    ."</template>"

    ."<card id=\"Card02\" title=\"News\">\n" 
    ."<p>\n"
    ."<b>$title</b>\n"
    ."<b>"._PDATE."</b> $datetime<br/><b>"
    ._PTOPIC." </b> $topictext<br/><br/>"
    ."$homexhtml<br/><br/>"
    ."$bodyxhtml<br/>"
    ."Posted: $time<br/>"    
    ."</p>"
    ."</card>"
    ."</wml>";

}

PrintPage($sid);

?>