Kod
<?php
/*****************************************************/
/* jPORTAL - internetowy system portalowy */
/*****************************************************/
/* autor: Pawel 'jaco' Jaczewski */
/* email: info@websys.pl */
/*****************************************************/
function count_poll($id, $val)
{
global $poll_a_tbl, $poll_b_tbl, $poll_err;
if($_COOKIE['poll_cookie_'.$id]<>10)
{
setcookie('poll_cookie_'.$id, 10, time()+3600*12);
if($val<>'')
{
mysql_query("UPDATE $poll_a_tbl SET votes=votes+1 WHERE id='$id'");
mysql_query("UPDATE $poll_b_tbl SET count=count+1 WHERE vid='$id' AND value='$val'");
$poll_err = ' - <b>Dzięki za oddanie głosu!</b>';
}
else
{
$poll_err = ' - <b>Zaznacz jakąś odpowiedź!</b>';
}
}
else
{
$poll_err = ' - <b>Nie możesz głosować 2 razy!</b>';
}
}
function poll_result($id='no')
{
global $poll_a_tbl, $poll_b_tbl, $theme;
if($id<>'no')
{
$query = "SELECT * FROM $poll_a_tbl WHERE id='$id'";
}
else
{
$query = "SELECT * FROM $poll_a_tbl ORDER BY id DESC LIMIT 1";
}
//
$res = mysql_query($query);
$r = mysql_fetch_assoc($res);
$votes = $r['votes'];
echo '<table width="99%" border="0" align="center">
<tr>
<td class="uni_01" colspan="2"><center><b>'.$r['title'].'</b>
</td>
</tr>';
$res = mysql_query("SELECT * FROM $poll_b_tbl WHERE vid='{$r['id']}' ORDER BY value");
$img[0] = file_exists('theme/'.$theme.'/gfx/poll_l.gif') ? '<img src="theme/'.$theme.'/gfx/poll_l.gif">' : '';
$img[3] = file_exists('theme/'.$theme.'/gfx/poll_r.gif') ? '<img src="theme/'.$theme.'/gfx/poll_r.gif">' : '';
while($r = mysql_fetch_assoc($res))
{
if($r['title']<>'')
{
if($votes<>0)
{
$a = $r['count'] / $votes;
$a = $a * 100;
$a = round($a);
$b = $a * 2;
$c = 200 - $b;
}
else
{
$a = 0;
$b = 0;
$c = 0;
}
$img[1] = $b==0 ? '' : '<img src="theme/'.$theme.'/gfx/poll.gif" height="12" width="'.$b.'">';
$img[2] = $c==0 ? '' : '<img src="theme/'.$theme.'/gfx/poll2.gif" height="12" width="'.$c.'">';
ksort($img);
echo '<tr>
<td class="uni_01" width="30%">- '.$r['title'].'</td>
<td class="uni_01">'.join('', $img).' '.$a.'% ('.$r['count'].')</td>
</tr>';
}
}
echo '
<table width="90%" border="0" align="center">
<tr>
<td class="uni_01" colspan="2">
<center>łącznie głosów: <b>'.$votes.'</b></td>
</tr>
</table>';
}
function old_poll()
{
global $poll_a_tbl, $poll_b_tbl, $theme;
$res = mysql_query("SELECT * FROM $poll_a_tbl ORDER BY id DESC");
if(mysql_num_rows($res)>1)
{
echo '<hr size="1" noshade><center><b>Stare sondy</b></center><hr size="1" noshade>
';
while($r = mysql_fetch_assoc($res))
{
if(!isset($s))
{
poll_result($r['id']);
echo '<hr size="1" noshade>
';
}
$s++;
}
}
}
?>
/*****************************************************/
/* jPORTAL - internetowy system portalowy */
/*****************************************************/
/* autor: Pawel 'jaco' Jaczewski */
/* email: info@websys.pl */
/*****************************************************/
function count_poll($id, $val)
{
global $poll_a_tbl, $poll_b_tbl, $poll_err;
if($_COOKIE['poll_cookie_'.$id]<>10)
{
setcookie('poll_cookie_'.$id, 10, time()+3600*12);
if($val<>'')
{
mysql_query("UPDATE $poll_a_tbl SET votes=votes+1 WHERE id='$id'");
mysql_query("UPDATE $poll_b_tbl SET count=count+1 WHERE vid='$id' AND value='$val'");
$poll_err = ' - <b>Dzięki za oddanie głosu!</b>';
}
else
{
$poll_err = ' - <b>Zaznacz jakąś odpowiedź!</b>';
}
}
else
{
$poll_err = ' - <b>Nie możesz głosować 2 razy!</b>';
}
}
function poll_result($id='no')
{
global $poll_a_tbl, $poll_b_tbl, $theme;
if($id<>'no')
{
$query = "SELECT * FROM $poll_a_tbl WHERE id='$id'";
}
else
{
$query = "SELECT * FROM $poll_a_tbl ORDER BY id DESC LIMIT 1";
}
//
$res = mysql_query($query);
$r = mysql_fetch_assoc($res);
$votes = $r['votes'];
echo '<table width="99%" border="0" align="center">
<tr>
<td class="uni_01" colspan="2"><center><b>'.$r['title'].'</b>
</td>
</tr>';
$res = mysql_query("SELECT * FROM $poll_b_tbl WHERE vid='{$r['id']}' ORDER BY value");
$img[0] = file_exists('theme/'.$theme.'/gfx/poll_l.gif') ? '<img src="theme/'.$theme.'/gfx/poll_l.gif">' : '';
$img[3] = file_exists('theme/'.$theme.'/gfx/poll_r.gif') ? '<img src="theme/'.$theme.'/gfx/poll_r.gif">' : '';
while($r = mysql_fetch_assoc($res))
{
if($r['title']<>'')
{
if($votes<>0)
{
$a = $r['count'] / $votes;
$a = $a * 100;
$a = round($a);
$b = $a * 2;
$c = 200 - $b;
}
else
{
$a = 0;
$b = 0;
$c = 0;
}
$img[1] = $b==0 ? '' : '<img src="theme/'.$theme.'/gfx/poll.gif" height="12" width="'.$b.'">';
$img[2] = $c==0 ? '' : '<img src="theme/'.$theme.'/gfx/poll2.gif" height="12" width="'.$c.'">';
ksort($img);
echo '<tr>
<td class="uni_01" width="30%">- '.$r['title'].'</td>
<td class="uni_01">'.join('', $img).' '.$a.'% ('.$r['count'].')</td>
</tr>';
}
}
echo '
<table width="90%" border="0" align="center">
<tr>
<td class="uni_01" colspan="2">
<center>łącznie głosów: <b>'.$votes.'</b></td>
</tr>
</table>';
}
function old_poll()
{
global $poll_a_tbl, $poll_b_tbl, $theme;
$res = mysql_query("SELECT * FROM $poll_a_tbl ORDER BY id DESC");
if(mysql_num_rows($res)>1)
{
echo '<hr size="1" noshade><center><b>Stare sondy</b></center><hr size="1" noshade>
';
while($r = mysql_fetch_assoc($res))
{
if(!isset($s))
{
poll_result($r['id']);
echo '<hr size="1" noshade>
';
}
$s++;
}
}
}
?>