failed');
}
if ($myUser == null) {
die('
');
}
$id = $_POST['id'];
$delta = $_POST['delta'];
$type = $_POST['type'];
switch ($type) {
case 'B':
$table_name = 'blogs';
break;
case 'BC':
$table_name = 'blogs_comments';
break;
case 'P':
$table_name = 'problems';
break;
case 'C':
$table_name = 'contests';
break;
}
$cur = queryZanVal($id, $type, $myUser);
if ($cur != $delta) {
$row = mysql_fetch_array(mysql_query("select zan from $table_name where id = $id"));
if ($row == null) {
die('failed
');
}
$cur += $delta;
if ($cur == 0) {
mysql_query("delete from click_zans where username = '{$myUser['username']}' and type = '$type' and target_id = $id");
} else if ($cur != $delta) {
mysql_query("update click_zans set val = '$cur' where username = '{$myUser['username']}' and type = '$type' and target_id = $id");
} else {
mysql_query("insert into click_zans (username, type, target_id, val) values ('{$myUser['username']}', '$type', $id, $cur)");
}
$cnt = $row['zan'] + $delta;
mysql_query("update $table_name set zan = $cnt where id = $id");
} else {
$row = mysql_fetch_array(mysql_query("select zan from $table_name where id = $id"));
if ($row == null) {
die('failed
');
}
$cnt = $row['zan'];
}
?>
= getClickZanBlock($type, $id, $cnt, $cur) ?>