View file 4at2/ch/news.php

File size: 3.59Kb
<?
header('Cache-Control: no-store, no-cache, must-revalidate');
header ("Content-type:text/vnd.wap.wml; charset=utf-8");
$ref=rand(10000,1000000);
require("inc.php");

$link = @mysql_pconnect ($MySQL_Hostname, $MySQL_Username, $MySQL_Password)
or die ("<wml><card id=\"error\" title=\"error\">
<do type=\"prev\" label=\"Back\"><prev/></do><p align=\"center\"><small>Can not connect to MySQL</small></p>
</card></wml>");

@mysql_select_db($MySQLDatabasename) or die ("<wml><card id=\"error\" title=\"error\">
<do type=\"prev\" label=\"Back\"><prev/></do><p align=\"center\"><small>error select the database...</small></p>
</card></wml>");

		$result = @mysql_query ("Select pass,user,fsize from users where id='".$id."' LIMIT 1;");

			if (mysql_affected_rows() == 0) {
			echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
echo "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.2//EN\" \"http://www.wapforum.org/DTD/wml12.dtd\">";
echo "<wml>";
echo "<card id=\"error\" title=\"&#x041E;&#x0448;&#x0438;&#x0431;&#x043A;&#x0430;\" ontimer=\"index.php?ref=$ref\"><timer value=\"15\"/>";
echo "<p align=\"center\"><small>";
echo "&#x042E;&#x0437;&#x0435;&#x0440; &#x043D;&#x0435; &#x043D;&#x0430;&#x0439;&#x0434;&#x0435;&#x043D;!";
echo "</small></p></card></wml>";
exit;
}

$row = mysql_fetch_array ($result);
if ($ps !== $row["pass"]){
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
echo "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.2//EN\" \"http://www.wapforum.org/DTD/wml12.dtd\">";
echo "<wml>";
echo "<card id=\"error\" title=\"&#x041E;&#x0448;&#x0438;&#x0431;&#x043A;&#x0430;\" ontimer=\"index.php?ref=$ref\"><timer value=\"15\"/>";
echo "<p align=\"center\"><small>";
echo "&#x041D;&#x0435; &#x0432;&#x0435;&#x0440;&#x043D;&#x043E;&#x0435; &#x0441;&#x043E;&#x0447;&#x0435;&#x0442;&#x0430;&#x043D;&#x0438;&#x0435; &#x043D;&#x0438;&#x043A;&#x0430; &#x0438; &#x043F;&#x0430;&#x0440;&#x043E;&#x043B;&#x044F;!";
echo "</small></p></card></wml>";
exit;
}

$cm = mysql_query ("select count(id) as num from news WHERE 1;");
$cmc = mysql_fetch_array($cm);
$news = $cmc["num"]; 

if($row['fsize'] == "small") { $fsize1 = "<small>"; $fsize2 = "</small>"; }
elseif($row['fsize'] == "big") { $fsize1 = "<big>"; $fsize2 = "</big>"; }
else { $fsize1 = ""; $fsize2 = ""; }


echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
echo "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.2//EN\" \"http://www.wapforum.org/DTD/wml12.dtd\">\n";
echo "<wml>\n";
echo "<card title=\"Новости чата\">\n";
echo "<p align=\"left\">\n";
//echo $fsize1; 
if(empty($page)) $page=0;
$query = @mysql_query("select * from `news`");
$num_of_rows=mysql_num_rows($query);
$total_mat_number=$num_of_rows;
$mat_per_page=5;
$total_pages=ceil($total_mat_number/$mat_per_page);
$print = mysql_query("select * from `news` order by id desc limit ".$page.",".($mat_per_page).";");
if (mysql_affected_rows() == 0) {
echo "Новостей нет(<br/>";
}
while($arr = @mysql_fetch_array($print)) {
        echo "<b>".$arr['date']."</b><br/> ".$arr['content']."<br/>";
		echo "<u>Разместил(а):</u><b> ".$arr['login']."</b><br/>";
        echo "-----<br/>";}   
for ($v=0; $v<$total_pages; $v++){
$page_number=$v*$mat_per_page;
if ($page_number!=$page) {
print "<a href=\"news.php?id=$id&amp;ps=$ps&amp;ref=$ref&amp;page=$page_number\">[&#1089;&#1090;&#1088;.".($v+1)."]</a><br/>";
} else {
print "<b>[&#1089;&#1090;&#1088;.".($v+1)."]</b><br/>"; 
}
}
echo "<a href=\"enter.php?id=$id&amp;ps=$ps&amp;ref=$ref\">Прихожая</a><br/>";
//echo $fsize2; 
?>
</p>
</card>
</wml>
<?
mysql_close($link);
?>