VOTE HACK
- Выводим результаты опроса по убыванию
- Выделение ответа пользователя
- Если пользователь уже голосовал в опросе то выводятся результат (+1 запрос БД)
УСТАНОВКА:
Открываем файл engine/ajax/vote.php
Ищем (109-строка)
$pn = 0;
После добавляем:
// --------------------------- VOTE HACK by ANDREJkE.ru
$select = $body[$vote_check];
for ($i = 0; $i < sizeof( $body ); $i ++)
for ($j = sizeof( $body ) - 1; $j > $i; $j --)
if ( $answer[$j-1]['count'] < $answer[$j]['count'] ) {
$body_free = $body[$j-1]; $body[$j-1] = $body[$j]; $body[$j] = $body_free;
$answer_free = $answer[$j-1]['count']; $answer[$j-1]['count'] = $answer[$j]['count']; $answer[$j]['count'] = $answer_free;
}
//----------------------------------------------------/
$select = $body[$vote_check];
for ($i = 0; $i < sizeof( $body ); $i ++)
for ($j = sizeof( $body ) - 1; $j > $i; $j --)
if ( $answer[$j-1]['count'] < $answer[$j]['count'] ) {
$body_free = $body[$j-1]; $body[$j-1] = $body[$j]; $body[$j] = $body_free;
$answer_free = $answer[$j-1]['count']; $answer[$j-1]['count'] = $answer[$j]['count']; $answer[$j]['count'] = $answer_free;
}
//----------------------------------------------------/
Ищем:
$entry .= "<div class=\"vote\" align=\"left\">$body[$i] - $num ($proc%)</div>
<div class=\"vote\" align=\"left\">
<img src=\"{$config['http_home_url']}templates/{$vote_skin}/dleimages/poll{$pn}.gif\" height=\"10\" width=\"$proc%\" style=\"border:1px solid black\">
</div>\n";
<div class=\"vote\" align=\"left\">
<img src=\"{$config['http_home_url']}templates/{$vote_skin}/dleimages/poll{$pn}.gif\" height=\"10\" width=\"$proc%\" style=\"border:1px solid black\">
</div>\n";
Заменяем на
if ($body[$i] != $select)
$entry .= "<div class=\"vote\" align=\"left\">$body[$i] - $num ($proc%)</div>
<div class=\"vote\" align=\"left\">
<img src=\"{$config['http_home_url']}templates/{$vote_skin}/dleimages/poll{$pn}.gif\" height=\"10\" width=\"$proc%\" style=\"border:1px solid black\">
</div>\n";
else
$entry .= "<div class=\"vote\" align=\"left\"><b>$body[$i]</b> - $num ($proc%)</div>
<div class=\"vote\" align=\"left\">
<img src=\"{$config['http_home_url']}templates/{$vote_skin}/dleimages/poll{$pn}.gif\" height=\"10\" width=\"$proc%\" style=\"border:1px solid black\">
</div>\n";
Ищем (174-строка)
$pn = 0;
$entry .= "<div class=\"vote\" align=\"left\">$body[$i] - $num ($proc%)</div>
<div class=\"vote\" align=\"left\">
<img src=\"{$config['http_home_url']}templates/{$vote_skin}/dleimages/poll{$pn}.gif\" height=\"10\" width=\"$proc%\" style=\"border:1px solid black\">
</div>\n";
else
$entry .= "<div class=\"vote\" align=\"left\"><b>$body[$i]</b> - $num ($proc%)</div>
<div class=\"vote\" align=\"left\">
<img src=\"{$config['http_home_url']}templates/{$vote_skin}/dleimages/poll{$pn}.gif\" height=\"10\" width=\"$proc%\" style=\"border:1px solid black\">
</div>\n";
Ищем (174-строка)
$pn = 0;
После добавляем:
// --------------------------- VOTE HACK by ANDREJkE.ru
for ($i = 0; $i < sizeof( $body ); $i ++)
for ($j = sizeof( $body ) - 1; $j > $i; $j --)
if ( $answer[$j-1]['count'] < $answer[$j]['count'] ) {
$body_free = $body[$j-1]; $body[$j-1] = $body[$j]; $body[$j] = $body_free;
$answer_free = $answer[$j-1]['count']; $answer[$j-1]['count'] = $answer[$j]['count']; $answer[$j]['count'] = $answer_free;
}
//------------------------------------------------------
for ($i = 0; $i < sizeof( $body ); $i ++)
for ($j = sizeof( $body ) - 1; $j > $i; $j --)
if ( $answer[$j-1]['count'] < $answer[$j]['count'] ) {
$body_free = $body[$j-1]; $body[$j-1] = $body[$j]; $body[$j] = $body_free;
$answer_free = $answer[$j-1]['count']; $answer[$j-1]['count'] = $answer[$j]['count']; $answer[$j]['count'] = $answer_free;
}
//------------------------------------------------------
открываем файл engine/modules/vote.php
Находим
$max = $vote_info[$rid]['vote_num'];
.....
$flag = 1;
Заменяем на
$_IP = $db->safesql( $_SERVER['REMOTE_ADDR'] );
if( isset( $member_id['name'] ) ) $nick = $member_id['name'];
else $nick = '';
if( $is_logged ) $row = $db->super_query( "SELECT count(*) as count FROM " . PREFIX . "_vote_result WHERE vote_id='$rid' AND name='$nick'" );
else $row = $db->super_query( "SELECT count(*) as count FROM " . PREFIX . "_vote_result WHERE vote_id='$rid' AND ip='$_IP'" );
if( $row['count'] == 0 ) $is_voted = false;
else { $is_voted = true; $flag = 1; }
if( $vote_action == "vote" ) {
$flag = 1;
if( isset( $member_id['name'] ) ) $nick = $member_id['name'];
else $nick = '';
if( $is_logged ) $row = $db->super_query( "SELECT count(*) as count FROM " . PREFIX . "_vote_result WHERE vote_id='$rid' AND name='$nick'" );
else $row = $db->super_query( "SELECT count(*) as count FROM " . PREFIX . "_vote_result WHERE vote_id='$rid' AND ip='$_IP'" );
if( $row['count'] == 0 ) $is_voted = false;
else { $is_voted = true; $flag = 1; }
if( $vote_action == "vote" ) {
$flag = 1;
Находим
case 1 :
Вставляем после:
// --------------------------- VOTE HACK by ANDREJkE.ru
for ($i = 0; $i < sizeof( $body ); $i ++)
for ($j = sizeof( $body ) - 1; $j > $i; $j --)
if ( $answer[$j-1]['count'] < $answer[$j]['count'] ) {
$body_free = $body[$j-1]; $body[$j-1] = $body[$j]; $body[$j] = $body_free;
$answer_free = $answer[$j-1]['count']; $answer[$j-1]['count'] = $answer[$j]['count']; $answer[$j]['count'] = $answer_free;
}
//----------------------------------------------------*/
for ($i = 0; $i < sizeof( $body ); $i ++)
for ($j = sizeof( $body ) - 1; $j > $i; $j --)
if ( $answer[$j-1]['count'] < $answer[$j]['count'] ) {
$body_free = $body[$j-1]; $body[$j-1] = $body[$j]; $body[$j] = $body_free;
$answer_free = $answer[$j-1]['count']; $answer[$j-1]['count'] = $answer[$j]['count']; $answer[$j]['count'] = $answer_free;
}
//----------------------------------------------------*/
установка завершена..
инструкция + модифицированные файлы: Вы не можете скачивать файлы с нашего сервера
Автор: ANDREJkE _andrejke.ru