К модулю музыки нужно приделать рейтинг
pavel31 03.11.2012 стол заказов Стол заказов 2214 1 комментарий
Всем привет, мне нужно добавить рейтинг к модулю Музыка, сколько это будет стоить и реально ли это вообще сделать??
вот код php файла вывода треков (с навигацией):
вот код php файла вывода треков (с навигацией):
<?php
if (!defined('DATALIFEENGINE')) {die("Hacking attempt!");}
include ENGINE_DIR . '/data/config.php';
$perpage = (!10 ? $perpage = "10" : intval(10));
$url_page = $config['http_home_url'] . "music";
$user_query = "do=music";
if ($cstart) {
$cstart = $cstart - 1;
$cstart = $cstart * $perpage;
}
$i = $cstart;
$query = $db->query("SELECT * FROM " . PREFIX . "_music ORDER BY date DESC LIMIT " . $cstart . "," . $perpage);
$count_all = $db->super_query ("SELECT COUNT(*) as count FROM " . PREFIX . "_music");
$count_all = $count_all['count'];
while ($row = $db->get_row($query)){
$i++;
if (date(Ymd, $row['date']) == date(Ymd, $_TIME)) {
$tpl->set('{date}', $lang['time_heute'] . langdate(", H:i", $row['date']));
}
elseif (date(Ymd, $row['date']) == date(Ymd, ($_TIME - 86400))) {
$tpl->set('{date}', $lang['time_gestern'] . langdate(", H:i", $row['date']));
}
else {
$tpl->set('{date}', langdate($config['timestamp_comment'], $row['date']));
}
if ($config['allow_alt_url'] == "yes") {
$go_page = $config['http_home_url'] . "user/" . urlencode($row['author']) . "/";
}
else {
$go_page = "$PHP_SELF?subaction=userinfo&user=" . urlencode($row['author']);
}
$username = stripslashes($row['author']);
$Category = $row['category'];
$Category = $db->super_query("SELECT * FROM " . PREFIX . "_music_category WHERE id=$Category");
$tpl->load_template('music/music.tpl');
$tpl->set('{title}', stripslashes($row['name']));
$tpl->set('{description}', stripslashes($row['onserver']));
$tpl->set('{username}', "<a onclick=\"showUserHint('" . urlencode($username) . "', this); return false;\" href=\"" . $go_page . "\">" . $username . "</a>");
$tpl->set('{id}', $row['id']);
$tpl->set('{category}', $Category['name']);
$tpl->set('{catid}', $Category['id']);
$tpl->set('{download}', $row['onserver']);
$tpl->compile('music');
$tpl->clear();
}
$db->free();
$tpl->load_template('music/gmusic.tpl');
$tpl->set('{category}', $Category['name']);
$tpl->set('{content}', $tpl->result['music']);
$tpl->compile('content');
$tpl->clear();
// навигация
if( $count_all ) {
$tpl->load_template( 'navigation.tpl' );
$no_prev = false;
$no_next = false;
// назад
if( isset( $cstart ) and $cstart != "" and $cstart > 0 ) {
$prev = $cstart / $perpage;
if( $config['allow_alt_url'] == "yes" ) {
if ($prev == 1)
$prev_page = $url_page . "/";
else
$prev_page = $url_page . "/page/" . $prev . "/";
$tpl->set_block( "'\[prev-link\](.*?)\[/prev-link\]'si", "<a href=\"" . $prev_page . "\">\\1</a>" );
}
else {
if ($prev == 1)
$prev_page = $PHP_SELF . "?" . $user_query;
else
$prev_page = $PHP_SELF . "?cstart=" . $prev . "&" . $user_query;
$tpl->set_block( "'\[prev-link\](.*?)\[/prev-link\]'si", "<a href=\"" . $prev_page . "\">\\1</a>" );
}
}
else {
$tpl->set_block( "'\[prev-link\](.*?)\[/prev-link\]'si", "<span>\\1</span>" );
$no_prev = TRUE;
}
// страницы навигации
if( $perpage ) {
$pages = "";
if( $count_all > $perpage ) {
$enpages_count = @ceil( $count_all / $perpage );
$cstart = ($cstart / $perpage) + 1;
if( $enpages_count <= 10 ) {
for($j = 1; $j <= $enpages_count; $j ++) {
if( $j != $cstart ) {
if( $config['allow_alt_url'] == "yes" ) {
if ($j == 1)
$pages .= "<a href=\"" . $url_page . "/\">$j</a> ";
else
$pages .= "<a href=\"" . $url_page . "/page/" . $j . "/\">$j</a> ";
}
else {
if ($j == 1)
$pages .= "<a href=\"$PHP_SELF?{$user_query}\">$j</a> ";
else
$pages .= "<a href=\"$PHP_SELF?cstart=$j&$user_query\">$j</a> ";
}
}
else
$pages .= "<span>$j</span> ";
}
}
else {
$start = 1;
$end = 10;
$nav_prefix = "<span class=\"nav_ext\">{$lang['nav_trennen']}</span> ";
if( $cstart > 0 ) {
if( $cstart > 6 ) {
$start = $cstart - 4;
$end = $start + 8;
if( $end >= $enpages_count ) {
$start = $enpages_count - 9;
$end = $enpages_count - 1;
$nav_prefix = "";
}
else
$nav_prefix = "<span class=\"nav_ext\">{$lang['nav_trennen']}</span> ";
}
}
if( $start >= 2 ) {
if( $config['allow_alt_url'] == "yes" ) $pages .= "<a href=\"" . $url_page . "/\">1</a> <span class=\"nav_ext\">{$lang['nav_trennen']}</span> ";
else $pages .= "<a href=\"$PHP_SELF?{$user_query}\">1</a> <span class=\"nav_ext\">{$lang['nav_trennen']}</span> ";
}
for($j = $start; $j <= $end; $j ++) {
if( $j != $cstart ) {
if( $config['allow_alt_url'] == "yes" ) {
if ($j == 1)
$pages .= "<a href=\"" . $url_page . "/\">$j</a> ";
else
$pages .= "<a href=\"" . $url_page . "/page/" . $j . "/\">$j</a> ";
}
else {
if ($j == 1)
$pages .= "<a href=\"$PHP_SELF?{$user_query}\">$j</a> ";
else
$pages .= "<a href=\"$PHP_SELF?cstart=$j&$user_query\">$j</a> ";
}
}
else $pages .= "<span>$j</span> ";
}
if( $cstart != $enpages_count ) {
if( $config['allow_alt_url'] == "yes" ) $pages .= $nav_prefix . "<a href=\"" . $url_page . "/page/{$enpages_count}/\">{$enpages_count}</a>";
else $pages .= $nav_prefix . "<a href=\"$PHP_SELF?cstart={$enpages_count}&$user_query\">{$enpages_count}</a>";
}
else $pages .= "<span>{$enpages_count}</span> ";
}
}
$tpl->set( '{pages}', $pages );
}
// вперёд
if( $perpage and $perpage < $count_all and $i < $count_all ) {
$next_page = $i / $perpage + 1;
if( $config['allow_alt_url'] == "yes" ) {
$next = $url_page . '/page/' . $next_page . '/';
$tpl->set_block( "'\[next-link\](.*?)\[/next-link\]'si", "<a href=\"" . $next . "\">\\1</a>" );
}
else {
$next = $PHP_SELF . "?cstart=" . $next_page . "&" . $user_query;
$tpl->set_block( "'\[next-link\](.*?)\[/next-link\]'si", "<a href=\"" . $next . "\">\\1</a>" );
};
}
else {
$tpl->set_block( "'\[next-link\](.*?)\[/next-link\]'si", "<span>\\1</span>" );
$no_next = TRUE;
}
if( ! $no_prev or ! $no_next ) {
$tpl->compile( 'navi' );
switch ( $config['news_navigation'] ) {
case "2" :
$tpl->result['content'] = $tpl->result['navi'].$tpl->result['content'];
break;
case "3" :
$tpl->result['content'] = $tpl->result['navi'].$tpl->result['content'].$tpl->result['navi'];
break;
default :
$tpl->result['content'] .= $tpl->result['navi'];
break;
}
}
$tpl->clear();
}
?>