Просмотр файла includes/rate.php

Размер файла: 1.16Kb
<?php

switch ($type) {
	case 'blogs': $go =  '?act=view&id='.$id; break;
	case 'loads': $go =  '?act=view&id='.$id; break;
	case 'photos': $go =  '?act=view&id='.$id; break;
	case 'profile': $go =  '?id='.$id; break;
}

if ($u['id']) {
	if ($id != $u['id']) {
		$vote_r = mysql_query("SELECT `id` FROM `voting` WHERE `type` = '$type' and `id_data` = '$id' and `id_user` = '$u[id]'");
		if (!mysql_num_rows($vote_r)) {
			mysql_query("INSERT INTO `voting` SET `type` = '$type', `id_data` = '$id', `id_user` = '$u[id]'");
			if ($ok) {
				// users' rating "karma"
				if ($type == 'profile') {
					mysql_query("UPDATE `users` SET `karma` = (`karma`+1) WHERE `id` = '$id'");
				} else { // other stuff's rating like blogs (=notes)
					mysql_query("UPDATE `$type` SET `rating` = (`rating`+1) WHERE `id` = '$id'");
				}
			} else {
				// users' rating "karma"
				if ($type == 'profile') {
					mysql_query("UPDATE `users` SET `karma` = (`karma`-1) WHERE `id` = '$id'");
				} else { // other stuff's rating like blogs (=notes)
					mysql_query("UPDATE `$type` SET `rating` = (`rating`-1) WHERE `id` = '$id'");
				}
			}
		}
	}
}
redirect($go);
	
?>