No karma whores!\n"; exit(); } # number of seconds in one hour $oneday = 60 * 60; #get current timestamp $now = time(); #calculate timestamp of one day ago $delete = $now - $oneday; #delete all entries older than one day $sql = "DELETE FROM blog_karma where timestamp <= $delete"; $res = $db->Execute($sql); #look if already had karma vote for this entry $sql = "SELECT count(*) as count from blog_karma where ip='$REMOTE_ADDR' and bid=$blogid and eid=$eid"; $res = $db->Execute($sql); #if not if($res->fields['count'] == 0) { #grab table name of blog $sql = "SELECT table_name from blog_list where blog_id=$blogid"; $res = $db->Execute($sql); $table = $res->fields['table_name']; #get karma value for entry $sql = "SELECT karma from blog_$table where id=$eid"; $res = $db->Execute($sql); $karma = $res->fields['karma']; #perform op if($op == "add") { $karma = $karma + 1; } elseif($op == "sub") { $karma = $karma - 1; } #update karma for entry $sql = "UPDATE blog_$table set karma=$karma where id=$eid"; $res = $db->Execute($sql); #enter IP into karma table $sql = "INSERT into blog_karma values ('$REMOTE_ADDR',$blogid,$eid,'$now')"; $res = $db->Execute($sql); } else { include("header.php"); ?> Sorry, only one karma vote per IP, per entry, per hour

Go back