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!!!!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.