<?
if( ! defined( 'DATALIFEENGINE' ) ) {
die( "Hacking attempt!" );
}
function get_images($file){
$h1count = preg_match_all('/(<img)\s (src=\"([a-zA-Z0-9\.;:\/\?&=_|\r|\n]{1,})\")/isxmU',$file,$patterns);
$res = array();
array_push($res,$patterns[3]);
array_push($res,count($patterns[3]));
return $res;
}
$tpl->load_template( 'rating.tpl' );
if (!isset ($_POST['view']) and !isset ($_GET['view']))
{
$view = 10;
} else {
if (isset ($_POST['view']))
{
$view = $_POST['view'];
} else {
$view = $_GET['view'];
}
}
if (!isset ($_POST['rating']) and !isset ($_GET['rating']))
{
$rating = 'news_read';
} else {
if (isset ($_POST['rating']))
{
$rating = $_POST['rating'];
} else {
$rating = $_GET['rating'];
}
}
if (!isset ($_GET['page']))
{
$number_page_get = 1;
} else {
$number_page_get = $_GET['page'];
}
$copyright_write = '<br><center><span style="size:6"><a href="http://ivashka.org/index.php?rozdil_id=10&text_id=56" target="_blank">Powered by ivashka</a></span></center>';
if ($number_page_get==1)
{
$copyright = $copyright_write;
}
$md5 = md5 ($copyright_write);
$first_position = (($view*$number_page_get)-$view);
if ($md5 == '2b0d57774004e153bfdb150fd08e1b0b')
{
$sql_result = $db -> query('select * from dle_post order by '.$rating.' DESC LIMIT '.$first_position.','.$view);
$sql_result_count_dle_post = $db -> query('select count(*) as count from dle_post');
$row_count_dle_post = $db->get_row( $sql_result_count_dle_post );
$number_page = ceil ($row_count_dle_post["count"]/$view);
$sql_result_count_dle_users = $db -> query('select count(*) as count from dle_users');
$row_count_dle_users = $db->get_row( $sql_result_count_dle_users );
}
if ($rating=='news_read')
{
$rating_10 = 'selected';
}
if ($rating=='rating')
{
$rating_20 = 'selected';
}
if ($view==10)
{
$view_10 = 'selected';
}
if ($view==20)
{
$view_20 = 'selected';
}
if ($view==30)
{
$view_30 = 'selected';
}
if ($view==50)
{
$view_50 = 'selected';
}
if ($view==100)
{
$view_100 = 'selected';
}
$body = '
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td><b>Количество публикаций: '.$row_count_dle_post["count"].'<br>
Количество пользователей: '.$row_count_dle_users["count"].'</b>
</td>
<td><div align="right"><form action="" method="post" name="form1" class="style1" id="view">
Показывать:
<select name="view" onChange ="document.getElementById(\'view\').submit()">
<option value="10" '.$view_10.'>10</option>
<option value="20" '.$view_20.'>20</option>
<option value="30" '.$view_30.'>30</option>
<option value="50" '.$view_50.'>50</option>
<option value="100" '.$view_100.'>100</option>
</select>
<input type="hidden" name="rating" value="'.$rating.'">
</form>
<form action="" method="post" name="form1" class="style1" id="rating">
Сортировка:
<select name="rating" onChange ="document.getElementById(\'rating\').submit()">
<option value="news_read" '.$rating_10.'>Просмотры</option>
<option value="rating" '.$rating_20.'>Рейтинг</option>
</select>
<input type="hidden" name="view" value="'.$view.'">
</form></div></td>
</tr>
</table>
<table id="table_items" class="tablesorter" border="0" cellpadding="15" cellspacing="1">
<tr>
<td><center>изображение</center></td>
<td><center>автор</center></td>
<td><center>название</center></td>
<td><center>дата</center></td>
<td><center>просмотры</center></td>
<td><center>рейтинг</center></td>
</tr>
';
while ( $row = $db->get_row( $sql_result ) ) {
$id_news = $row['id'];
$img = $db -> query("select * from dle_images where news_id='$id_news'");
$row_img = $db->get_row( $img );
$img = get_images($row["short_story"]);
$image_array = explode ('|||', $row_img["images"]);
$image = '<img src="'.$config["http_home_url"].'uploads/posts/'.$image_array[0].'" width="70">';
$image_2 = $config["http_home_url"].'uploads/posts/'.$image_array[0];
//$image = '<img src="http://www.myfm.org.ua/uploads/posts/'.$img.'" width="150">';
//user_info
$user_name = $row["autor"];
$user = $db -> query("select * from dle_users where name='$user_name'");
$row_user = $db->get_row( $user );
$user_info = '
<table width=300 border=0 cellpadding=0 cellspacing=0>
<tr>
<td><center><img src='.$config["http_home_url"].'uploads/fotos/'.$row_user["foto"].'></center></td>
<td valign=top>Полное имя: '.$row_user["fullname"].'<br>
Публикаций: '.$row_user["news_num"].'<br>
Комментариев: '.$row_user["comm_num"].'</td>
</tr>
</table>
';
//\user_info
if (strlen($row_img["images"])>0)
{
if ($md5 == '2b0d57774004e153bfdb150fd08e1b0b')
{
$url = $config["http_home_url"].$row["id"].'-'.$row["alt_name"].'.html';
$body .= '
<tr>
<td valign="top"><div align="center"><a href="'.$image_2.'" onclick="return hs.expand(this)" >'.$image.'</a></div></td>
<td valign="top"><div align="center"><a href="'.$config["http_home_url"].'user/'.$row["autor"].'/" title="header=['.$user_info.'] body=[ ] fade=[on]" >'.$row["autor"].'</a></div></td>
<td valign="top"><div align="left"><a href="'.$url.'" target="_blank">'.$row["title"].'</a></div></td>
<td valign="top"><div align="center">'.$row["date"].'</div></td>
<td valign="top"><div align="center">'.$row["news_read"].'</div></td>
<td valign="top"><div align="center">'.$row["rating"].'</div></td>
</tr>
';
}
}
}
if ($md5 == '2b0d57774004e153bfdb150fd08e1b0b')
{
for ($ii=1; $ii<=$number_page; $ii++)
{
if ($ii!=$number_page_get)
{
$links .= '
<a href="'.$config["http_home_url"].'index.php?do=rating&page='.$ii.'&rating='.$rating.'&view='.$view.'">['.$ii.']</a>
';
} else {
$links .= '<b>['.$ii.']</b>';
}
}
}
$body .= '
</table><br>
<center>
<style>
.links_rating a{
color: black;
}
.links_rating a:hover{
color: #FFFFFF;
}
</style>
<table width="85%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td>
<center><span class="links_rating">'.$links.'</span></center></td>
</tr>
</table>
'.$copyright.'</center>
';
if ($md5 != '2b0d57774004e153bfdb150fd08e1b0b')
{
print "<center><h1>Верните пожалуйсто копирайт, он только на первой странице рейтинга</h1></center>";
}
$tpl->set( '{top_rating}', $body );
$tpl->compile( 'content' );
$tpl->clear();
?>