Jump to content

Wordpress + Cookies + session ID check??? anyone??


neuromant

Recommended Posts

Hey all,

 

I am currently using the 'I Like' plugin for wordpress..  I am trying to modify the PHP to only allow ONE vote on the whole site per user. So after one single vote, all voting should be disallowed for that IP address.

 

I am all thumbs when it comes to syntax in PHP so any help modifying this script to do what I need it to do would be IMMENSELY appreciated!

 

<?php
require_once '../../../wp-config.php';

global $wpdb;
$post_ID = $_POST['id'];
$ip = $_SERVER['REMOTE_ADDR'];
$like = get_post_meta($post_ID, '_liked', true);

if($post_ID != '') {
$voteStatusByIp = $wpdb->get_var("SELECT COUNT(*) FROM ".$wpdb->prefix."ilikethis_votes WHERE post_id = '$post_ID' AND ip = '$ip'");

    if (!isset($_COOKIE['liked-'.$post_ID]) && $voteStatusByIp == 0) {
	$likeNew = $like + 1; 
	update_post_meta($post_ID, '_liked', $likeNew);

	setcookie('liked-'.$post_ID, time(), time()+3600*24*365, '/');
	$wpdb->query("INSERT INTO ".$wpdb->prefix."ilikethis_votes VALUES ('', NOW(), '$post_ID', '$ip')");

	echo $likeNew;
}
else {
	echo $like;
}
}
?>

 

 

THANK YOU!!!!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.