<?php
function news() {
global  $htmlorphp,$folder,$name_site,$table_news,$num_news,$limitcharshorts,$LANGAUGE,$_GET;

$page = (int) (!isset($_GET["page"]) ? 1 : $_GET["page"]);
$page = ($page == 0 ? 1 : $page);
$perpage = $num_news;
$startpoint = ($page * $perpage) - $perpage;


$sql = @mysql_query("SELECT * FROM news where active='1' order by id desc LIMIT $startpoint,$perpage");
$xx = mysql_num_rows($sql);
if($xx == 0){
$prints = $LANGAUGE[277];
}else{
$prints = "<div id='newsindex'>";
$c = 0;
while ($Row2 = @mysql_fetch_array($sql))
{
++$c;
if($c == $xx){
$smbol = "";
}else{
$smbol = "<br />";
}

if ($htmlorphp=="1"){
$links = "news-$Row2[id].html";
}else{
$links = "news.php?action=view&id=$Row2[id]";
}

$all = "<a href='$links'>".$LANGAUGE[185]."</a>";

$d = date("j/n/Y",$Row2['date']);

$Row2['sub'] = text(3,$Row2['sub']);
$Row2['thumbs'] = text(3,$Row2['thumbs']);
$Row2['image'] = text(3,$Row2['image']);
$Row2['short'] = text(2,$Row2['short']);
$Row2['editor'] = text(3,$Row2['editor']);
$Row2['news'] = strip_tags($Row2['news']);
$news = text(3,$Row2['news']);

if($Row2['short']==""){
$des = cuttext($limitcharshorts, $news, " ... <a href='$links'>".$LANGAUGE[185]."</a>");
}else{
$des = $Row2['short'];
}

if($Row2['editor'] == ""){
$e = "".$LANGAUGE[186]."".$name_site;
}else{
$e = "".$LANGAUGE[186]."".$Row2['editor'];
}

//if (file_exists($Row2['thumbs'])){
if($Row2['thumbs'] == "" AND $Row2['image'] == ""){
$i = "";
}elseif($Row2['thumbs'] == ""){
$i = "<a href='$links'><img src='".$Row2['image']."' alt='".$Row2['sub']."' border='0' /></a>";
}else{
$i = "<a href='$links'><img src='".$Row2['thumbs']."' alt='".$Row2['sub']."' border='0' /></a>";
}
//}else{
//$i = "";
//}


$sqlw = mysql_query("SELECT * FROM news_cat where id='".$Row2['cat']."'");
$Roww = mysql_fetch_array($sqlw);
$cat = "<a href='news_cat-$Roww[id].html'>".text(3,$Roww['name'])."</a>";

$tf = "<div class='infonews'>".$all." - ".$LANGAUGE[188]." ".$cat." - ".$LANGAUGE[187]." $d - ".$LANGAUGE[189]." $Row2[vis]</div>";

$prints .= "<div class='titlenews'><h1><a href='$links'>".$Row2['sub']."</a></h1></div>";
$prints .= "<div class='contentnews'><div class='paddingnews'>".$des."".$tf."</div></div>";
$prints .= $smbol;
}

$pagesnum = @ceil(mysql_num_rows(mysql_query("select `id` from `news` where active='1'")) / $perpage);

if($pagesnum > 1){
$prints .= "<div class='multipage'>";
for ($i=1; $i<=$pagesnum; $i++) {
if ($i != $page) {

if ($htmlorphp=="1"){
$z = "<span><a href='p-$i.html'>$i</a></span>";
}else{
$z = "<span><a href='index.php?page=$i'>$i</a></span>";
}

} else {
$z = "<span class='act'>$i</span>";
}
$prints .= "$z";

}
$prints .= "</div>";
}
$prints .= "</div>";
}

return $prints;
}





function newswithimage() {
global  $htmlorphp,$folder,$name_site,$num_news,$limitcharshorts,$LANGAUGE,$_GET;

$page = (int) (!isset($_GET["page"]) ? 1 : $_GET["page"]);
$page = ($page == 0 ? 1 : $page);
$perpage = $num_news;
$startpoint = ($page * $perpage) - $perpage;


$sql = @mysql_query("SELECT * FROM news where active='1' order by id desc LIMIT $startpoint,$perpage");
$xx = mysql_num_rows($sql);
if($xx == 0){
$prints =  $LANGAUGE[277];
}else{
$prints = "<div id='newsindex'>";
$c = 0;
while ($Row2 = @mysql_fetch_array($sql))
{
++$c;
if($c == $xx){
$smbol = "";
}else{
$smbol = "<br />";
}

if ($htmlorphp=="1"){
$links = "news-$Row2[id].html";
}else{
$links = "news.php?action=view&id=$Row2[id]";
}

$Row2['sub'] = text(3,$Row2['sub']);
$Row2['thumbs'] = text(3,$Row2['thumbs']);
$Row2['image'] = text(3,$Row2['image']);
$Row2['news'] = strip_tags($Row2['news']);
$Row2['short'] = text(2,$Row2['short']);
$Row2['editor'] = text(3,$Row2['editor']);
$news = text(3,$Row2['news']);
$d = date("j/n/Y",$Row2['date']);

if($Row2['short']==""){
$des = cuttext($limitcharshorts, $news, " ... <a href='$links'>".$LANGAUGE[185]."</a>");
}else{
$des = $Row2['short'];
}

$all = "<a href='$links'>".$LANGAUGE[185]."</a>";

//if (file_exists($Row2['thumbs'])){
if($Row2['thumbs'] == "" AND $Row2['image'] == ""){
$i = "";
}elseif($Row2['thumbs'] == ""){
$i = "<a href='$links'><img src='".$Row2['image']."' alt='".$Row2['sub']."' /></a>";
}else{
$i = "<a href='$links'><img src='".$Row2['thumbs']."' alt='".$Row2['sub']."' /></a>";
}
//}else{
//$i = "";
//}

if($Row2['editor'] == ""){
$e = "".$LANGAUGE[186]."".$name_site;
}else{
$e = "".$LANGAUGE[186]."".$Row2['editor'];
}

$sqlw = mysql_query("SELECT * FROM news_cat where id='".$Row2['cat']."'");
$Roww = mysql_fetch_array($sqlw);
$cat = "<a href='news_cat-$Roww[id].html'>".text(3,$Roww['name'])."</a>";

$tf = "<div class='infonews'>".$all." - ".$LANGAUGE[188]." ".$cat." - ".$LANGAUGE[187]." $d - ".$LANGAUGE[189]." $Row2[vis]</div>";

$prints .= "<div class='titlenews'><h1><a href='$links'>".$Row2['sub']."</a></h1></div>";
$prints .= "<div class='contentnews'><div class='paddingnews'>".$i."".$des."".$tf."</div></div>";
$prints .= $smbol;
}

$pagesnum = @ceil(mysql_num_rows(mysql_query("select `id` from `news` where active='1'")) / $perpage);

if($pagesnum > 1){
$prints .= "<div class='multipage'>";
for ($i=1; $i<=$pagesnum; $i++) {
if ($i != $page) {

if ($htmlorphp=="1"){
$z = "<span><a href='p-$i.html'>$i</a></span>";
}else{
$z = "<span><a href='index.php?page=$i'>$i</a></span>";
}

} else {
$z = "<span class='act'>$i</span>";
}
$prints .= "$z";

}
$prints .= "</div>";
}
$prints .= "</div>";
}

return $prints;
}


function news2table() {
global  $htmlorphp,$folder,$table_news,$num_news,$LANGAUGE,$limitcharshorts,$_GET;

$page = (int) (!isset($_GET["page"]) ? 1 : $_GET["page"]);
$page = ($page == 0 ? 1 : $page);
$perpage = $num_news;
$startpoint = ($page * $perpage) - $perpage;


$sql = @mysql_query("SELECT * FROM news where active='1' order by id desc LIMIT $startpoint,$perpage");
$xx = mysql_num_rows($sql);
if($xx == 0){
$prints = $LANGAUGE[277];
}else{

$prints = "<div id='newsindex'>
<table  border='0' width='100%'>";

$tslsls = '0';
while ($Row2 = @mysql_fetch_array($sql))
{
++$tslsls;
if($tslsls=="2"){
$tslslats = "</tr><tr>";
$tslsls="0";
}else{
$tslslats = "";
}

if ($htmlorphp=="1"){
$links = "news-$Row2[id].html";
}else{
$links = "news.php?action=view&id=$Row2[id]";
}

$all = "<a href='$links'>".$LANGAUGE[185]."</a>";

$Row2['sub'] = text(3,$Row2['sub']);
$Row2['thumbs'] = text(3,$Row2['thumbs']);
$Row2['image'] = text(3,$Row2['image']);
$Row2['news'] = strip_tags($Row2['news']);
$Row2['short'] = text(2,$Row2['short']);
$Row2['editor'] = text(3,$Row2['editor']);
$news = text(3,$Row2['news']);
$d = date("j/n/Y",$Row2['date']);

if($Row2['short']==""){
$des = cuttext($limitcharshorts, $news, " ... <a href='$links'>".$LANGAUGE[185]."</a>");
}else{
$des = $Row2['short'];
}

//if (file_exists($Row2['thumbs'])){
if($Row2['thumbs'] == "" AND $Row2['image'] == ""){
$i = "";
}elseif($Row2['thumbs'] == ""){
$i = "<a href='$links'><img src='".$Row2['image']."' alt='".$Row2['sub']."' border='0' /></a>";
}else{
$i = "<a href='$links'><img src='".$Row2['thumbs']."' alt='".$Row2['sub']."' border='0' /></a>";
}
//}else{
//$i = "";
//}

if($Row2['editor'] == ""){
$e = "".$LANGAUGE[186]."".$name_site;
}else{
$e = "".$LANGAUGE[186]."".$Row2['editor'];
}

$sqlw = mysql_query("SELECT * FROM news_cat where id='".$Row2['cat']."'");
$Roww = mysql_fetch_array($sqlw);
$cat = "<a href='news_cat-$Roww[id].html'>".text(3,$Roww['name'])."</a>";

$tf = "<div class='infonews1'>".$all." - ".$LANGAUGE[188]." ".$cat." - ".$LANGAUGE[187]." $d - ".$LANGAUGE[189]." $Row2[vis]</div>";

$prints .= "<td width='50%' valign='top' style='padding:0 2px 10px 2px'>";

$prints .= "<div class='titlenews'><h1><a href='$links'>".$Row2['sub']."</a></h1></div>";
$prints .= "<div class='newsindex2table'><div class='paddingnews'>".$i."".$des."</div></div>";
$prints .= $tf;
$prints .= $smbol;

$prints .= "</td>";
$prints .= "$tslslats";
}
$prints .= "</table>";

$pagesnum = @ceil(mysql_num_rows(mysql_query("select `id` from `news` where active='1'")) / $perpage);

if($pagesnum > 1){
$prints .= "<div class='multipage'>";
for ($i=1; $i<=$pagesnum; $i++) {
if ($i != $page) {

if ($htmlorphp=="1"){
$z = "<span><a href='p-$i.html'>$i</a></span>";
}else{
$z = "<span><a href='index.php?page=$i'>$i</a></span>";
}

} else {
$z = "<span class='act'>$i</span>";
}
$prints .= "$z";

}
$prints .= "</div>";
}
$prints .= "</div>";
}

return $prints;
}
?>