Просмотр файла éÑαß¿∩ 2 »«αΓá½/index.php

Размер файла: 3.53Kb
<?php
	/**
	 *	Wap Portal русская версия
	 *
	 *	Copyright (C) 2002 - 2005 Красников Виктор
	 *
	 *	Wap Portal
	 *	Developer: Красников Виктор - [email protected]
	 *  Homepage: http://tut.spb.su
	 *	Date: 05/05/2005
	 * 	Version #: 1.0
	**/

$wmlsession = 1;
include("regglobals.php");
include("config.php");
include("lang/".$language);

setlocale (LC_TIME, _DATE_CODE);

// Establish connection with database and select database
$link = mysql_connect($db_host, $db_user, $db_password)
    or die("Could not connect");
mysql_select_db($db_name)
    or die("Could not select database");

// Read date format
$query = "SELECT * FROM wps_dateformat WHERE id = 1";
$result = mysql_query($query);
$row = mysql_fetch_object($result);
$dateformatlong = $row->dateformatlong;
$dateformatmiddle = $row->dateformatmiddle;
$dateformatshort = $row->dateformatshort;

// send wml headers
header("Content-type: text/vnd.wap.wml\n");
echo("<?xml version=\"1.0\" encoding=\""._ENCODING_TAG."\"?>\n");
echo("<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.1//EN\" \"http://www.wapforum.org/DTD/wml_1.1.xml\">\n");

echo "<wml>\n";

// Choose page

switch($option) {
	case "section" :
		labels();
		require ("wml/sections.php");
		break;
	case "component" :
		labels();
		$query = "SELECT name FROM wps_components WHERE id = '$id'";
		$result = mysql_query($query);
		$row = mysql_fetch_object ($result);
		require ("wml/$row->name.php");
		break;
	case "item" :
		labels();
		require ("wml/items.php");
		break;
	default:
		require ("wml/home.php");
		break;
}

echo "</wml>";

function labels() {
	echo "<template>
<do type=\"prev\" label=\""._BACK."\">
	<prev/>
</do>
<do type=\"options\" label=\""._HOME."\" name=\""._HOME."\">
	<go href=\"index.php\"/>
</do>
</template>\n";
}

function parseUBB($string) {
	$string = preg_replace("/\[b\](.*?)\[\/b\]/si", "<b>\\1</b>", $string);
	$string = preg_replace("/\[i\](.*?)\[\/i\]/si", "<i>\\1</i>", $string);
	$string = preg_replace("/\[strong\](.*?)\[\/strong\]/si", "<strong>\\1</strong>", $string);
	$string = preg_replace("/\[em\](.*?)\[\/em\]/si", "<em>\\1</em>", $string);
	$string = preg_replace("/\[u\](.*?)\[\/u\]/si", "<u>\\1</u>", $string);
	$string = preg_replace("/\[p\](.*?)\[\/p\]/si", "<p>\\1</p>", $string);
	$string = preg_replace("/\[big\](.*?)\[\/big\]/si", "<big>\\1</big>", $string);
	$string = preg_replace("/\[small\](.*?)\[\/small\]/si", "<small>\\1</small>", $string);
	$string = preg_replace("/(^|\s)(http:\/\/\S+)/si", "\\1<a href=\"\\2\">\\2</a>", $string);
	$string = preg_replace("/(^|\s)(www\.\S+)/si", "\\1<a href=\"http://\\2\">\\2</a>", $string);
	$string = preg_replace("/\[url\](http|https|ftp)(:\/\/\S+?)\[\/url\]/si",
		"<a href=\"\\1\\2\">\\1\\2</a>", $string);
	$string = preg_replace("/\[url\](\S+?)\[\/url\]/si",
		"<a href=\"http://\\1\">\\1</a>", $string);
	$string = preg_replace("/\[url=(http|https|ftp)(:\/\/\S+?)\](.*?)\[\/url\]/si",
		"<a href=\"\\1\\2\">\\3</a>", $string);
	$string = preg_replace("/\[url=(\S+?)\](\S+?)\[\/url\]/si",
		"<a href=\"http://\\1\">\\2</a>", $string);
	//$string = preg_replace("/\[email\](\S+?@\S+?\\.\S+?)\[\/email\]/si",
	//	"<a href=\"mailto:\\1\">\\1</a>", $string);
	$string = preg_replace("/\[img\](\S+?)\[\/img\]/si",
		"<img src=\"\\1\" alt=\"image\" />", $string);
	return $string;
}

function split_in_array($string, $length) {
	$i=0;
	while (strlen($string) > 0) {
		$str_array[$i] .= substr($string, 0, $length);
		$string = substr($string, $length);
		$i++;
	}
	return $str_array;
}