hi this is my first post here, i really hope i can get a little help with this small php code because it is driving me nuts lol ive been looking at it for days and have no idea how to tackle the situation.
I have installed a simple photo contest script to my website and everything works great accept one small annoying bit. firstly the the developer doesnt seem to be around anymore and the licence for the code says it can be freely modified, shared, distributed, trod on or used as a beer mat if so desired so to speak.
the settings have two options…
Only one vote per contest. (not one vote per person, just one single vote so if i vote on one image then nobody else can vote)
Unlimited votes. (anyone can vote on one or more photos as many times as they like)
I was really hoping to change how the first setting works. I want to edit the code so that everyone can get one vote. at the moment if someone votes then nobody else can vote. below is the code i believe which controls all the voting system…
[php]<?php
include(“config.php”);
if(isset($_POST[‘id’]) and !empty($_POST[‘id’])){
$id= intval($_POST[‘id’]);
$contest= htmlspecialchars($_POST[‘contest’]);
$ip = $_POST[‘fingerprint’];
$ret = mysqli_query($bd, “select * from contests where contest = ‘$contest’”);
if ($ret !== null){
$contest_settings = mysqli_fetch_object($ret);
if ($contest_settings->voting_type == “contest”){
$ip_sql=mysqli_query($bd, “select ip_add from image_IP where contest = ‘$contest’”);
}else{
$ip_sql=mysqli_query($bd, “select ip_add from image_IP where img_id_fk=$id and ip_add=’$ip’”);
}
$count=mysqli_num_rows($ip_sql);
//var_dump($id);
if($count==0){
$sql = "UPDATE images
SET love = love +1 WHERE img_id = ".$id;
//var_dump($sql);
mysqli_query($bd, $sql);
$sql_in = “insert into image_IP (ip_add,img_id_fk,contest) values (’$ip’,$id,’$contest’)”;
mysqli_query($bd, $sql_in);
$result=mysqli_query($bd, “select love from images where img_id=$id”);
//var_dump($result);
$row=mysqli_fetch_array($result);
$love=$row[‘love’];
?>
<?php echo $love; ?>
<?php
}else{
echo _(‘You have already voted !’);
}
}
}
if (isset($_POST[‘action’])){
if ($_POST[‘action’] == ‘login’){
$pwd = $POST[‘pwd’];
if ($pwd == PASSWD){
$ok = setcookie(COOKIE_NAME, sha1(PASSWD.HASH), 0, ‘/’, ‘’, FALSE, TRUE);
if (!$ok){
echo ‘
}
}else{
echo ‘
}
}
}
?>[/php]