GetOne("SELECT goodpost,badpost,scores FROM `$maintable` WHERE id='$id' ");
if($cfg_digg_update == 0)
{
if($action == 'good')
{
$row['goodpost'] = $row['goodpost'] + 1;
$dsql->ExecuteNoneQuery("UPDATE `$maintable` SET scores = scores + {$cfg_caicai_add},goodpost=goodpost+1,lastpost=".time()." WHERE id='$id'");
}
else if($action=='bad')
{
$row['badpost'] = $row['badpost'] + 1;
$dsql->ExecuteNoneQuery("UPDATE `$maintable` SET scores = scores - {$cfg_caicai_sub},badpost=badpost+1,lastpost=".time()." WHERE id='$id'");
}
DelCache($prefix, $key);
}
SetCache($prefix, $key, $row, 0);
} else {
if($action == 'good')
{
$row['goodpost'] = $row['goodpost'] + 1;
$row['scores'] = $row['scores'] + $cfg_caicai_sub;
if($row['goodpost'] % $cfg_digg_update == 0)
{
$add_caicai_sub = $cfg_digg_update * $cfg_caicai_sub;
$dsql->ExecuteNoneQuery("UPDATE `$maintable` SET scores = scores + {$add_caicai_sub},goodpost=goodpost+{$cfg_digg_update} WHERE id='$id'");
DelCache($prefix, $key);
}
} else if($action == 'bad')
{
$row['badpost'] = $row['badpost'] + 1;
$row['scores'] = $row['scores'] - $cfg_caicai_sub;
if($row['badpost'] % $cfg_digg_update == 0)
{
$add_caicai_sub = $cfg_digg_update * $cfg_caicai_sub;
$dsql->ExecuteNoneQuery("UPDATE `$maintable` SET scores = scores - {$add_caicai_sub},badpost=badpost+{$cfg_digg_update} WHERE id='$id'");
DelCache($prefix, $key);
}
}
SetCache($prefix, $key, $row, 0);
}
$digg = '';
if(!is_array($row)) exit();
if($row['goodpost'] + $row['badpost'] == 0)
{
$row['goodper'] = $row['badper'] = 0;
}
else
{
$row['goodper'] = number_format($row['goodpost'] / ($row['goodpost'] + $row['badpost']), 3) * 100;
$row['badper'] = 100 - $row['goodper'];
}
if(empty($formurl)) $formurl = '';
if($formurl=='caicai')
{
if($action == 'good') $digg = $row['goodpost'];
if($action == 'bad') $digg = $row['badpost'];
}
else
{
$row['goodper'] = trim(sprintf("%4.2f", $row['goodper']));
$row['badper'] = trim(sprintf("%4.2f", $row['badper']));
$digg = '
';
}
AjaxHead();
echo $digg;
exit();