Перейти из форума на сайт.

НовостиФайловые архивы
ПоискАктивные темыТоп лист
ПравилаКто в on-line?
Вход Забыли пароль? Первый раз на этом сайте? Регистрация
Компьютерный форум Ru.Board » IkonBoard и другие форумы » Ikonboard v.2 » Выборочный вывод полей в голосовании (pollhack)

Модерирует : Antuan

 Версия для печати • ПодписатьсяДобавить в закладки

Открыть новую тему     Написать ответ в эту тему

Sebastyan

Junior Member
Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору
По-умолчанию таблица голосования в топике выглядит так:
 
Радиокнопка | Вариант ответа | Голоса | Проценты
 
Причём это видят и проголосовавшие и не проголосовавшие.
Я изменил вид этой таблицы:
 
1. Не проголосовавшие видят её так:
 
Вариант ответа | Радиокнопка
 
Столбцы "Голоса", "Проценты" и строку "Всего голосов:..." не выводятся, т.к. являются ненужной "предвыборной агитацией" со стороны уже проголосовавших
 
2. Проголосовавшие видят:
 
Вариант ответа | Голоса | Проценты
 
Т.е. не выводим радиокнопку за ненадобностью.
 
Для этого (после полной установки хака голосования) заменить блок в topic.cgi:
 

Код:
 
#-------Polls
 
$pollfileexist = "1";
$filetoopen = "$ikondir" . "forum$inforum/$topicid.poll";
open(FILE1,"$filetoopen") or ($pollfileexist = "0");
@pollfile = <FILE1>;
close(FILE1);
 
if ($pollfileexist eq "1") {
($poll1,$poll1v,$poll2,$poll2v,$poll3,$poll3v,$poll4,$poll4v,$poll5,$poll5v,$poll6,$poll6v,$poll7,$poll7v,$poll8,$poll8v,$poll9,$poll9v,$poll10,$poll10v) = split(/\|/,$pollfile[0]);
$totalvotes = ($poll1v + $poll2v + $poll3v + $poll4v + $poll5v + $poll6v + $poll7v + $poll8v + $poll9v + $poll10v);
 
$pollvoters = "1";
 
$filetoopen = "$ikondir" . "forum$inforum/$intopic.vote";
$filetoopen = &stripMETA($filetoopen);
open(FILE, "$filetoopen") or ($pollvoters = "0");
@allvoters = <FILE>;
close(FILE);
 
$votesubmitbutton = qq~<input type=Submit value=Vote name=Submit"  onClick="return clckcntr();">~;
 
if ($pollvoters eq "1") {
foreach $voters (@allvoters) {
chomp $voters;
if ($inmembername eq $voters) { $votesubmitbutton = "Вы уже проголосовали."; }
}
}
if ($inmembername eq "Guest") { $votesubmitbutton = "Гости не могут голосовать. Пожалуйста, зарегистрируйтесь."; }
if ($membercode eq "banned") { $votesubmitbutton = "Заблокированные пользователи не могут голосовать."; }
if ($threadstate eq "closed") { $votesubmitbutton = "Вы не можете проголосовать, т.к. тема закрыта."; }
 
if ($poll1 ne "") {  
$polloption = $poll1;
$pollvotes = $poll1v;
if ($pollvotes ne "0") { $pollpercent = int(($pollvotes / $totalvotes) * 100);
$pollwidth = int($pollpercent * 3); }
 
else { $pollpercent = 0; }
if ($pollpercent eq "0") { $pollb = "" }
else {
$pollb = qq~<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0"><TR><TD BGCOLOR="$pollbar"><IMG SRC="$imagesurl/images/spacer.gif" HEIGHT="10" WIDTH="$pollwidth"></TD></TR></TABLE>~;
}
$poll = qq(  
<tr>
<td bgcolor=$pollback align=center><font face="$font" color=$pollfont size=1><b><input name="vote" type="radio" value="1"></b></td>
<td bgcolor=$pollback><font face="$font" color=$pollfont size=1>$polloption</font></td>
<td bgcolor=$pollback nowrap align="center"><font face="$font" color=$pollfont size=1>$pollvotes</font></td>
<td bgcolor=$pollback nowrap><font face="$font" color=$pollfont size=1>$pollb  $pollpercent%</font></td></tr>)
}
if ($poll2 ne "") {  
$polloption = $poll2;
$pollvotes = $poll2v;
if ($pollvotes ne "0") { $pollpercent = int(($pollvotes / $totalvotes) * 100);
$pollwidth = int($pollpercent * 3); }
 
else { $pollpercent = 0; }
if ($pollpercent eq "0") { $pollb = "" }
else {
$pollb = qq~<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0"><TR><TD BGCOLOR="$pollbar"><IMG SRC="$imagesurl/images/spacer.gif" HEIGHT="10" WIDTH="$pollwidth"></TD></TR></TABLE>~;
}
$poll = qq( $poll
<tr>
<td bgcolor=$pollback align=center><font face="$font" color=$pollfont size=1><b><input name="vote" type="radio" value="2"></b></td>
<td bgcolor=$pollback><font face="$font" color=$pollfont size=1>$polloption</font></td>
<td bgcolor=$pollback nowrap align="center"><font face="$font" color=$pollfont size=1>$pollvotes</font></td>
<td bgcolor=$pollback nowrap><font face="$font" color=$pollfont size=1>$pollb  $pollpercent%</font></td></tr>)
}
if ($poll3 ne "") {  
$polloption = $poll3;
$pollvotes = $poll3v;
if ($pollvotes ne "0") { $pollpercent = int(($pollvotes / $totalvotes) * 100);
$pollwidth = int($pollpercent * 3); }
 
else { $pollpercent = 0; }
if ($pollpercent eq "0") { $pollb = "" }
else {
$pollb = qq~<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0"><TR><TD BGCOLOR="$pollbar"><IMG SRC="$imagesurl/images/spacer.gif" HEIGHT="10" WIDTH="$pollwidth"></TD></TR></TABLE>~;
}
$poll = qq( $poll
<tr>
<td bgcolor=$pollback align=center><font face="$font" color=$pollfont size=1><b><input name="vote" type="radio" value="3"></b></td>
<td bgcolor=$pollback><font face="$font" color=$pollfont size=1>$polloption</font></td>
<td bgcolor=$pollback nowrap align="center"><font face="$font" color=$pollfont size=1>$pollvotes</font></td>
<td bgcolor=$pollback nowrap><font face="$font" color=$pollfont size=1>$pollb  $pollpercent%</font></td></tr>)
}
if ($poll4 ne "") {  
$polloption = $poll4;
$pollvotes = $poll4v;
if ($pollvotes ne "0") { $pollpercent = int(($pollvotes / $totalvotes) * 100);
$pollwidth = int($pollpercent * 3); }
 
else { $pollpercent = 0; }
if ($pollpercent eq "0") { $pollb = "" }
else {
$pollb = qq~<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0"><TR><TD BGCOLOR="$pollbar"><IMG SRC="$imagesurl/images/spacer.gif" HEIGHT="10" WIDTH="$pollwidth"></TD></TR></TABLE>~;
}
$poll = qq( $poll
<tr>
<td bgcolor=$pollback align=center><font face="$font" color=$pollfont size=1><b><input name="vote" type="radio" value="4"></b></td>
<td bgcolor=$pollback><font face="$font" color=$pollfont size=1>$polloption</font></td>
<td bgcolor=$pollback nowrap align="center"><font face="$font" color=$pollfont size=1>$pollvotes</font></td>
<td bgcolor=$pollback nowrap><font face="$font" color=$pollfont size=1>$pollb  $pollpercent%</font></td></tr>)
}
if ($poll5 ne "") {  
$polloption = $poll5;
$pollvotes = $poll5v;
if ($pollvotes ne "0") { $pollpercent = int(($pollvotes / $totalvotes) * 100);
$pollwidth = int($pollpercent * 3); }
 
else { $pollpercent = 0; }
if ($pollpercent eq "0") { $pollb = "" }
else {
$pollb = qq~<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0"><TR><TD BGCOLOR="$pollbar"><IMG SRC="$imagesurl/images/spacer.gif" HEIGHT="10" WIDTH="$pollwidth"></TD></TR></TABLE>~;
}
$poll = qq( $poll
<tr>
<td bgcolor=$pollback align=center><font face="$font" color=$pollfont size=1><b><input name="vote" type="radio" value="5"></b></td>
<td bgcolor=$pollback><font face="$font" color=$pollfont size=1>$polloption</font></td>
<td bgcolor=$pollback nowrap align="center"><font face="$font" color=$pollfont size=1>$pollvotes</font></td>
<td bgcolor=$pollback nowrap><font face="$font" color=$pollfont size=1>$pollb  $pollpercent%</font></td></tr>)
}
if ($poll6 ne "") {  
$polloption = $poll6;
$pollvotes = $poll6v;
if ($pollvotes ne "0") { $pollpercent = int(($pollvotes / $totalvotes) * 100);
$pollwidth = int($pollpercent * 3); }
 
else { $pollpercent = 0; }
if ($pollpercent eq "0") { $pollb = "" }
else {
$pollb = qq~<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0"><TR><TD BGCOLOR="$pollbar"><IMG SRC="$imagesurl/images/spacer.gif" HEIGHT="10" WIDTH="$pollwidth"></TD></TR></TABLE>~;
}
$poll = qq( $poll
<tr>
<td bgcolor=$pollback align=center><font face="$font" color=$pollfont size=1><b><input name="vote" type="radio" value="6"></b></td>
<td bgcolor=$pollback><font face="$font" color=$pollfont size=1>$polloption</font></td>
<td bgcolor=$pollback nowrap align="center"><font face="$font" color=$pollfont size=1>$pollvotes</font></td>
<td bgcolor=$pollback nowrap><font face="$font" color=$pollfont size=1>$pollb  $pollpercent%</font></td></tr>)
}
if ($poll7 ne "") {  
$polloption = $poll7;
$pollvotes = $poll7v;
if ($pollvotes ne "0") { $pollpercent = int(($pollvotes / $totalvotes) * 100);
$pollwidth = int($pollpercent * 3); }
 
else { $pollpercent = 0; }
if ($pollpercent eq "0") { $pollb = "" }
else {
$pollb = qq~<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0"><TR><TD BGCOLOR="$pollbar"><IMG SRC="$imagesurl/images/spacer.gif" HEIGHT="10" WIDTH="$pollwidth"></TD></TR></TABLE>~;
}
$poll = qq( $poll
<tr>
<td bgcolor=$pollback align=center><font face="$font" color=$pollfont size=1><b><input name="vote" type="radio" value="7"></b></td>
<td bgcolor=$pollback><font face="$font" color=$pollfont size=1>$polloption</font></td>
<td bgcolor=$pollback nowrap align="center"><font face="$font" color=$pollfont size=1>$pollvotes</font></td>
<td bgcolor=$pollback nowrap><font face="$font" color=$pollfont size=1>$pollb  $pollpercent%</font></td></tr>)
}
if ($poll8 ne "") {  
$polloption = $poll8;
$pollvotes = $poll8v;
if ($pollvotes ne "0") { $pollpercent = int(($pollvotes / $totalvotes) * 100);
$pollwidth = int($pollpercent * 3); }
 
else { $pollpercent = 0; }
if ($pollpercent eq "0") { $pollb = "" }
else {
$pollb = qq~<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0"><TR><TD BGCOLOR="$pollbar"><IMG SRC="$imagesurl/images/spacer.gif" HEIGHT="10" WIDTH="$pollwidth"></TD></TR></TABLE>~;
}
$poll = qq( $poll
<tr>
<td bgcolor=$pollback align=center><font face="$font" color=$pollfont size=1><b><input name="vote" type="radio" value="8"></b></td>
<td bgcolor=$pollback><font face="$font" color=$pollfont size=1>$polloption</font></td>
<td bgcolor=$pollback nowrap align="center"><font face="$font" color=$pollfont size=1>$pollvotes</font></td>
<td bgcolor=$pollback nowrap><font face="$font" color=$pollfont size=1>$pollb  $pollpercent%</font></td></tr>)
}
if ($poll9 ne "") {  
$polloption = $poll9;
$pollvotes = $poll9v;
if ($pollvotes ne "0") { $pollpercent = int(($pollvotes / $totalvotes) * 100);
$pollwidth = int($pollpercent * 3); }
 
else { $pollpercent = 0; }
if ($pollpercent eq "0") { $pollb = "" }
else {
$pollb = qq~<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0"><TR><TD BGCOLOR="$pollbar"><IMG SRC="$imagesurl/images/spacer.gif" HEIGHT="10" WIDTH="$pollwidth"></TD></TR></TABLE>~;
}
$poll = qq( $poll
<tr>
<td bgcolor=$pollback align=center><font face="$font" color=$pollfont size=1><b><input name="vote" type="radio" value="9"></b></td>
<td bgcolor=$pollback><font face="$font" color=$pollfont size=1>$polloption</font></td>
<td bgcolor=$pollback nowrap align="center"><font face="$font" color=$pollfont size=1>$pollvotes</font></td>
<td bgcolor=$pollback nowrap><font face="$font" color=$pollfont size=1>$pollb  $pollpercent%</font></td></tr>)
}
if ($poll10 ne "") {  
$polloption = $poll10;
$pollvotes = $poll10v;
if ($pollvotes ne "0") { $pollpercent = int(($pollvotes / $totalvotes) * 100);
$pollwidth = int($pollpercent * 3); }
 
else { $pollpercent = 0; }
if ($pollpercent eq "0") { $pollb = "" }
else {
$pollb = qq~<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0"><TR><TD BGCOLOR="$pollbar"><IMG SRC="$imagesurl/images/spacer.gif" HEIGHT="10" WIDTH="$pollwidth"></TD></TR></TABLE>~;
}
$poll = qq( $poll
<tr>
<td bgcolor=$pollback align=center><font face="$font" color=$pollfont size=1><b><input name="vote" type="radio" value="10"></b></td>
<td bgcolor=$pollback><font face="$font" color=$pollfont size=1>$polloption</font></td>
<td bgcolor=$pollback nowrap align="center"><font face="$font" color=$pollfont size=1>$pollvotes</font></td>
<td bgcolor=$pollback nowrap><font face="$font" color=$pollfont size=1>$pollb  $pollpercent%</font></td></tr>)
}
 
    $output .= qq~
<tr>
<td bgcolor=$pollback>
<table width=100% border=1 bgcolor=$pollback>
<tr><form action="$postprog" method=post>
<input type=hidden name="action" value="updatepoll">
<input type=hidden name="forum" value="$inforum">
<input type=hidden name="topic" value="$intopic">
<input type=hidden name="topictitle" value="$topictitle">
<input type=hidden name="forumname" value="$forumname">
<td width=5% bgcolor=$pollback align=center><font face="$font" color=$pollfont size=1><b>Vote</b></td>
<td width=70% bgcolor=$pollback align=center><font face="$font" color=$pollfont size=1><b>Option</b></td>
<td width=5% bgcolor=$pollback nowrap align="center"><font face="$font" color=$pollfont size=1><b>Votes</b></td>
<td width=300 bgcolor=$pollback nowrap align="center"><font face="$font" color=$pollfont size=2><b>Percent</b></td>
<font face="$posternamefont" color="$posterfontcolor" size="2">
</tr>
$poll
</table>
<table width=100% border=0 cellspacing=0 bgcolor=$pollback>
<tr>
<td bgcolor=$pollback width=50%><font face="$font" color=$pollfont size=1><b>$votesubmitbutton</b></td>
<td bgcolor=$pollback align=right><font face="$font" color=$pollfont size=1>Всего голосов: <b>$totalvotes</b></td>
</tr>
</table>
</form>
~;
;}    
#-----------End Polls
 

 
(если короче, то между

Код:
#-------Polls

и

Код:
#-----------End Polls

)
 
На следующий код:
 

Код:
#-------Polls
 
$pollfileexist = "1";
$filetoopen = "$ikondir" . "forum$inforum/$topicid.poll";
open(FILE1,"$filetoopen") or ($pollfileexist = "0");
@pollfile = <FILE1>;
close(FILE1);
 
if ($pollfileexist eq "1") {
($poll1,$poll1v,$poll2,$poll2v,$poll3,$poll3v,$poll4,$poll4v,$poll5,$poll5v,$poll6,$poll6v,$poll7,$poll7v,$poll8,$poll8v,$poll9,$poll9v,$poll10,$poll10v) = split(/\|/,$pollfile[0]);
$totalvotes = ($poll1v + $poll2v + $poll3v + $poll4v + $poll5v + $poll6v + $poll7v + $poll8v + $poll9v + $poll10v);
 
$pollvoters = "1";
 
$filetoopen = "$ikondir" . "forum$inforum/$intopic.vote";
$filetoopen = &stripMETA($filetoopen);
open(FILE, "$filetoopen") or ($pollvoters = "0");
@allvoters = <FILE>;
close(FILE);
 
$votesubmitbutton = qq~<input type=Submit value="Голосовать" name=Submit onClick="return clckcntr();">~;
$alreadyvoit = "n";
if ($pollvoters eq "1") {
foreach $voters (@allvoters) {
chomp $voters;
if ($inmembername eq $voters) { $votesubmitbutton = "Вы уже проголосовали."; $alreadyvoit = "y";}
}
}
if ($inmembername eq "Guest") { $votesubmitbutton = "Гости не могут голосовать. Пожалуйста, зарегистрируйтесь."; }
if ($membercode eq "banned") { $votesubmitbutton = "Заблокированные пользователи не могут голосовать."; }
if ($threadstate eq "closed") { $votesubmitbutton = "Вы не можете проголосовать, т.к. тема закрыта."; }
 
if ($poll1 ne "") {  
$polloption = $poll1;
$pollvotes = $poll1v;
if ($pollvotes ne "0") { $pollpercent = int(($pollvotes / $totalvotes) * 100);
$pollwidth = int($pollpercent * 3); }
 
else { $pollpercent = 0; }
if ($pollpercent eq "0") { $pollb = "" }
else {
$pollb = qq~<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0"><TR><TD BGCOLOR="$pollbar"><IMG SRC="$imagesurl/images/spacer.gif" HEIGHT="10" WIDTH="$pollwidth"></TD></TR></TABLE>~;
}
if ($alreadyvoit eq "y") { $enablevoit="";  
$results=qq~
<td bgcolor=$pollback nowrap align="center"><font face="$font" color=$pollfont size=1>&nbsp;[ $pollvotes ]&nbsp;</font></td>
<td bgcolor=$pollback nowrap><font face="$font" color=$pollfont size=1>$pollb  $pollpercent%</font></td></tr>~;
}
else {$results=""; $enablevoit=qq~<td bgcolor=$pollback align=center><input style={background-color:$pollback;} name="vote" type="radio" value="1"></td>~;}
 
$poll = qq(  
<tr>
<td bgcolor=$pollback align=right><font face="$font" color=$pollfont size=1>$polloption</font></td>
$enablevoit
$results)
}
if ($poll2 ne "") {  
$polloption = $poll2;
$pollvotes = $poll2v;
if ($pollvotes ne "0") { $pollpercent = int(($pollvotes / $totalvotes) * 100);
$pollwidth = int($pollpercent * 3); }
 
else { $pollpercent = 0; }
if ($pollpercent eq "0") { $pollb = "" }
else {
$pollb = qq~<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0"><TR><TD BGCOLOR="$pollbar"><IMG SRC="$imagesurl/images/spacer.gif" HEIGHT="10" WIDTH="$pollwidth"></TD></TR></TABLE>~;
}
if ($alreadyvoit eq "y") { $enablevoit="";  
$results=qq~
<td bgcolor=$pollback nowrap align="center"><font face="$font" color=$pollfont size=1>&nbsp;[ $pollvotes ]&nbsp;</font></td>
<td bgcolor=$pollback nowrap><font face="$font" color=$pollfont size=1>$pollb  $pollpercent%</font></td></tr>~;
}
else {$results=""; $enablevoit=qq~<td bgcolor=$pollback align=center><input style={background-color:$pollback;} name="vote" type="radio" value="2"></td>~;}
 
$poll .= qq(  
<tr>
<td bgcolor=$pollback align=right><font face="$font" color=$pollfont size=1>$polloption</font></td>
$enablevoit
$results)
}
if ($poll3 ne "") {  
$polloption = $poll3;
$pollvotes = $poll3v;
if ($pollvotes ne "0") { $pollpercent = int(($pollvotes / $totalvotes) * 100);
$pollwidth = int($pollpercent * 3); }
 
else { $pollpercent = 0; }
if ($pollpercent eq "0") { $pollb = "" }
else {
$pollb = qq~<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0"><TR><TD BGCOLOR="$pollbar"><IMG SRC="$imagesurl/images/spacer.gif" HEIGHT="10" WIDTH="$pollwidth"></TD></TR></TABLE>~;
}
if ($alreadyvoit eq "y") { $enablevoit="";  
$results=qq~
<td bgcolor=$pollback nowrap align="center"><font face="$font" color=$pollfont size=1>&nbsp;[ $pollvotes ]&nbsp;</font></td>
<td bgcolor=$pollback nowrap><font face="$font" color=$pollfont size=1>$pollb  $pollpercent%</font></td></tr>~;
}
else {$results=""; $enablevoit=qq~<td bgcolor=$pollback align=center><input style={background-color:$pollback;} name="vote" type="radio" value="3"></td>~;}
 
$poll .= qq(  
<tr>
<td bgcolor=$pollback align=right><font face="$font" color=$pollfont size=1>$polloption</font></td>
$enablevoit
$results)
}
if ($poll4 ne "") {  
$polloption = $poll4;
$pollvotes = $poll4v;
if ($pollvotes ne "0") { $pollpercent = int(($pollvotes / $totalvotes) * 100);
$pollwidth = int($pollpercent * 3); }
 
else { $pollpercent = 0; }
if ($pollpercent eq "0") { $pollb = "" }
else {
$pollb = qq~<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0"><TR><TD BGCOLOR="$pollbar"><IMG SRC="$imagesurl/images/spacer.gif" HEIGHT="10" WIDTH="$pollwidth"></TD></TR></TABLE>~;
}
if ($alreadyvoit eq "y") { $enablevoit="";  
$results=qq~
<td bgcolor=$pollback nowrap align="center"><font face="$font" color=$pollfont size=1>&nbsp;[ $pollvotes ]&nbsp;</font></td>
<td bgcolor=$pollback nowrap><font face="$font" color=$pollfont size=1>$pollb  $pollpercent%</font></td></tr>~;
}
else {$results=""; $enablevoit=qq~<td bgcolor=$pollback align=center><input style={background-color:$pollback;} name="vote" type="radio" value="4"></td>~;}
 
$poll .= qq(  
<tr>
<td bgcolor=$pollback align=right><font face="$font" color=$pollfont size=1>$polloption</font></td>
$enablevoit
$results)
}
if ($poll5 ne "") {  
$polloption = $poll5;
$pollvotes = $poll5v;
if ($pollvotes ne "0") { $pollpercent = int(($pollvotes / $totalvotes) * 100);
$pollwidth = int($pollpercent * 3); }
 
else { $pollpercent = 0; }
if ($pollpercent eq "0") { $pollb = "" }
else {
$pollb = qq~<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0"><TR><TD BGCOLOR="$pollbar"><IMG SRC="$imagesurl/images/spacer.gif" HEIGHT="10" WIDTH="$pollwidth"></TD></TR></TABLE>~;
}
if ($alreadyvoit eq "y") { $enablevoit="";  
$results=qq~
<td bgcolor=$pollback nowrap align="center"><font face="$font" color=$pollfont size=1>&nbsp;[ $pollvotes ]&nbsp;</font></td>
<td bgcolor=$pollback nowrap><font face="$font" color=$pollfont size=1>$pollb  $pollpercent%</font></td></tr>~;
}
else {$results=""; $enablevoit=qq~<td bgcolor=$pollback align=center><input style={background-color:$pollback;} name="vote" type="radio" value="5"></td>~;}
 
$poll .= qq(  
<tr>
<td bgcolor=$pollback align=right><font face="$font" color=$pollfont size=1>$polloption</font></td>
$enablevoit
$results)
}
if ($poll6 ne "") {  
$polloption = $poll6;
$pollvotes = $poll6v;
if ($pollvotes ne "0") { $pollpercent = int(($pollvotes / $totalvotes) * 100);
$pollwidth = int($pollpercent * 3); }
 
else { $pollpercent = 0; }
if ($pollpercent eq "0") { $pollb = "" }
else {
$pollb = qq~<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0"><TR><TD BGCOLOR="$pollbar"><IMG SRC="$imagesurl/images/spacer.gif" HEIGHT="10" WIDTH="$pollwidth"></TD></TR></TABLE>~;
}
if ($alreadyvoit eq "y") { $enablevoit="";  
$results=qq~
<td bgcolor=$pollback nowrap align="center"><font face="$font" color=$pollfont size=1>&nbsp;[ $pollvotes ]&nbsp;</font></td>
<td bgcolor=$pollback nowrap><font face="$font" color=$pollfont size=1>$pollb  $pollpercent%</font></td></tr>~;
}
else {$results=""; $enablevoit=qq~<td bgcolor=$pollback align=center><input style={background-color:$pollback;} name="vote" type="radio" value="6"></td>~;}
 
$poll .= qq(  
<tr>
<td bgcolor=$pollback align=right><font face="$font" color=$pollfont size=1>$polloption</font></td>
$enablevoit
$results)
}
if ($poll7 ne "") {  
$polloption = $poll7;
$pollvotes = $poll7v;
if ($pollvotes ne "0") { $pollpercent = int(($pollvotes / $totalvotes) * 100);
$pollwidth = int($pollpercent * 3); }
 
else { $pollpercent = 0; }
if ($pollpercent eq "0") { $pollb = "" }
else {
$pollb = qq~<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0"><TR><TD BGCOLOR="$pollbar"><IMG SRC="$imagesurl/images/spacer.gif" HEIGHT="10" WIDTH="$pollwidth"></TD></TR></TABLE>~;
}
if ($alreadyvoit eq "y") { $enablevoit="";  
$results=qq~
<td bgcolor=$pollback nowrap align="center"><font face="$font" color=$pollfont size=1>&nbsp;[ $pollvotes ]&nbsp;</font></td>
<td bgcolor=$pollback nowrap><font face="$font" color=$pollfont size=1>$pollb  $pollpercent%</font></td></tr>~;
}
else {$results=""; $enablevoit=qq~<td bgcolor=$pollback align=center><input style={background-color:$pollback;} name="vote" type="radio" value="7"></td>~;}
 
$poll .= qq(  
<tr>
<td bgcolor=$pollback align=right><font face="$font" color=$pollfont size=1>$polloption</font></td>
$enablevoit
$results)
}
if ($poll8 ne "") {  
$polloption = $poll8;
$pollvotes = $poll8v;
if ($pollvotes ne "0") { $pollpercent = int(($pollvotes / $totalvotes) * 100);
$pollwidth = int($pollpercent * 3); }
 
else { $pollpercent = 0; }
if ($pollpercent eq "0") { $pollb = "" }
else {
$pollb = qq~<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0"><TR><TD BGCOLOR="$pollbar"><IMG SRC="$imagesurl/images/spacer.gif" HEIGHT="10" WIDTH="$pollwidth"></TD></TR></TABLE>~;
}
if ($alreadyvoit eq "y") { $enablevoit="";  
$results=qq~
<td bgcolor=$pollback nowrap align="center"><font face="$font" color=$pollfont size=1>&nbsp;[ $pollvotes ]&nbsp;</font></td>
<td bgcolor=$pollback nowrap><font face="$font" color=$pollfont size=1>$pollb  $pollpercent%</font></td></tr>~;
}
else {$results=""; $enablevoit=qq~<td bgcolor=$pollback align=center><input style={background-color:$pollback;} name="vote" type="radio" value="8"></td>~;}
 
$poll .= qq(  
<tr>
<td bgcolor=$pollback align=right><font face="$font" color=$pollfont size=1>$polloption</font></td>
$enablevoit
$results)
}
if ($poll9 ne "") {  
$polloption = $poll9;
$pollvotes = $poll9v;
if ($pollvotes ne "0") { $pollpercent = int(($pollvotes / $totalvotes) * 100);
$pollwidth = int($pollpercent * 3); }
 
else { $pollpercent = 0; }
if ($pollpercent eq "0") { $pollb = "" }
else {
$pollb = qq~<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0"><TR><TD BGCOLOR="$pollbar"><IMG SRC="$imagesurl/images/spacer.gif" HEIGHT="10" WIDTH="$pollwidth"></TD></TR></TABLE>~;
}
if ($alreadyvoit eq "y") { $enablevoit="";  
$results=qq~
<td bgcolor=$pollback nowrap align="center"><font face="$font" color=$pollfont size=1>&nbsp;[ $pollvotes ]&nbsp;</font></td>
<td bgcolor=$pollback nowrap><font face="$font" color=$pollfont size=1>$pollb  $pollpercent%</font></td></tr>~;
}
else {$results=""; $enablevoit=qq~<td bgcolor=$pollback align=center><input style={background-color:$pollback;} name="vote" type="radio" value="9"></td>~;}
 
$poll .= qq(  
<tr>
<td bgcolor=$pollback align=right><font face="$font" color=$pollfont size=1>$polloption</font></td>
$enablevoit
$results)
}
if ($poll10 ne "") {  
$polloption = $poll10;
$pollvotes = $poll10v;
if ($pollvotes ne "0") { $pollpercent = int(($pollvotes / $totalvotes) * 100);
$pollwidth = int($pollpercent * 3); }
 
else { $pollpercent = 0; }
if ($pollpercent eq "0") { $pollb = "" }
else {
$pollb = qq~<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0"><TR><TD BGCOLOR="$pollbar"><IMG SRC="$imagesurl/images/spacer.gif" HEIGHT="10" WIDTH="$pollwidth"></TD></TR></TABLE>~;
}
if ($alreadyvoit eq "y") { $enablevoit="";  
$results=qq~
<td bgcolor=$pollback nowrap align="center"><font face="$font" color=$pollfont size=1>&nbsp;[ $pollvotes ]&nbsp;</font></td>
<td bgcolor=$pollback nowrap><font face="$font" color=$pollfont size=1>$pollb  $pollpercent%</font></td></tr>~;
}
else {$results=""; $enablevoit=qq~<td bgcolor=$pollback align=center><input style={background-color:$pollback;} name="vote" type="radio" value="10"></td>~;}
 
$poll .= qq(  
<tr>
<td bgcolor=$pollback align=right><font face="$font" color=$pollfont size=1>$polloption</font></td>
$enablevoit
$results)
}
 
if ($alreadyvoit eq "y") {
$enablevoit=qq~<td width=50% bgcolor=$pollback align=right><font face="$font" color=$pollfont size=1>Всего голосов: <b>$totalvotes</b></font></td>~;
$results=qq~<td width=5% bgcolor=$pollback nowrap align="center"><font face="$font" color=$pollfont size=1><b>Голоса</b></td>
<td width=300 bgcolor=$pollback nowrap align="center"><font face="$font" color=$pollfont size=1><b>%</b></td>~;
}
else
{
$enablevoit="";
$results=qq~<td width=30% bgcolor=$pollback align=center><font face="$font" color=$pollfont size=1><b>&nbsp;</b></td>~;
}
 
    $output .= qq~
<tr>
<td bgcolor=$pollback>
<table width=100% border=1 bgcolor=$pollback>
<tr>
<form action="$postprog" method=post>
<input type=hidden name="action" value="updatepoll">
<input type=hidden name="forum" value="$inforum">
<input type=hidden name="topic" value="$intopic">
<input type=hidden name="topictitle" value="$topictitle">
<input type=hidden name="forumname" value="$forumname">
<td width=70% bgcolor=$pollback align=center><font face="$font" color=$pollfont size=1><b>Вариант</b></td>
$results
</tr>
$poll
</table>
 
<table border=1 align=center cellspacing=0 cellpadding=10 bgcolor=$pollback>
<tr><td bgcolor=$pollback><font face="$font" color=$pollfont size=1><b>$votesubmitbutton</b></td>
$enablevoit
</form></tr>
</table>
~;
;}
undef $results;
undef $enablevoit;
#-----------End Polls
 

 
P.S. Текст в таблице переведён на русский.
Надеюсь ширину столбцов каждый сможет заточить под себя.
 
И ещё, по ходу пьесы:
IMHO, странно реализована защита от создания опросов кем-либо кроме админов и модеров
(если включить в Админцентре режим "начинать могут только админы и модеры")
Просто не выводится кнопка "Создать новое голосование"...
А если вбить ссылку ручками, то новый опрос может сделать даже Guest.
 
Как поправить:
в post.cgi найти строку:

Код:
if ($pollstate eq "no") { &error("Posting&Sorry, You can not start a poll in this forum"); }

 
Перед ней добавить:

Код:
if (($startnewpolls eq "no") && ($membercode ne "ad") && ($membercode ne "mo")) { &error("Создание опроса&Только администраторы и модераторы могут создавать опросы");}

 
И ещё, если выбран режим создания опросов по-умолчанию "All registered members", гости опять-же могут начинать опросы.
Я не против, править не стал




Молодец.
Добавлено в карту форума:
Обзор форума IkonBoard V. 2 (карта форума) » Статьи, хаки - вся IkonBoard V. 2 в одной теме

Всего записей: 34 | Зарегистр. 06-11-2003 | Отправлено: 14:27 21-10-2004 | Исправлено: lynx, 18:40 21-10-2004
Sebastyan

Junior Member
Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору
При проверке оказалось, что pollhack не защищён от "шаловливых ручек":
если поля вариантов ответа оставить пустыми или ввести всего один вариант, pollhack не ругается.
 
Чтобы исправить это:
в post.cgi, в sub addnewpoll, перед строкой:

Код:
### Get a new thread number.

добавить:

Код:
my $isnumenough=0;
if ($poll1 ne "") {$isnumenough++;}
if ($poll2 ne "") {$isnumenough++;}
if ($poll3 ne "") {$isnumenough++;}
if ($poll4 ne "") {$isnumenough++;}
if ($poll5 ne "") {$isnumenough++;}
if ($poll6 ne "") {$isnumenough++;}
if ($poll7 ne "") {$isnumenough++;}
if ($poll8 ne "") {$isnumenough++;}
if ($poll9 ne "") {$isnumenough++;}
if ($poll10 ne "") {$isnumenough++;}
if ($isnumenough < 2) {&error("Новый опрос&Количество вариантов ответа должно быть больше одного."); }
undef $isnumenough;

 
Грубо, но работает.

Всего записей: 34 | Зарегистр. 06-11-2003 | Отправлено: 13:58 22-10-2004 | Исправлено: Sebastyan, 14:01 22-10-2004
Открыть новую тему     Написать ответ в эту тему

Компьютерный форум Ru.Board » IkonBoard и другие форумы » Ikonboard v.2 » Выборочный вывод полей в голосовании (pollhack)


Реклама на форуме Ru.Board.

Powered by Ikonboard "v2.1.7b" © 2000 Ikonboard.com
Modified by Ru.B0ard
© Ru.B0ard 2000-2024

BitCoin: 1NGG1chHtUvrtEqjeerQCKDMUi6S6CG4iC

Рейтинг.ru