OK, PLEASE BARE WITH ME...
I HAVE A FLASH WEBSITE
IN THE WEBSITE I HAVE ITEMS THAT CAN BE VOTED FOR VIA A "FLASH 5 STAR VOTING SYSTEM"
I HAVE 3 ITEMS THAT CAN BE VOTED FOR AT THE MOMENT AND WILL BE ADDING MORE ITEMS LATER ONCE MY PROBLEM IS SORTED
I HAVE EACH ITEM LINKED UP WITH THERE OWN PHP AND THE VOTING SYSTEM WORKS FINE
AFTER VOTING FOR AN ITEM YOU ARE UNABLE TO VOTE FOR THAT ITEM AGAIN WHICH IS ALSO FINE, HOWEVER...
WHEN YOU GO TO VOTE FOR ANOTHER ITEM WITHIN THE WEBSITE IT WON'T LET YOU (IT SAY'S YOU HAVE ALREADY VOTED AS IF YOU HAVE JUST VOTED FOR THAT ITEM SPECIFICALLY)
EACH PHP HAS THE EXACT SAME CODING (AND THIS IS WHERE I'M SURE MY PROBLEM LIES)
I'M SURE IT IS SOMETHING TO DO WITH THE COOKIES OR SOMETHING WITHIN EACH PHP THAT NEEDS TO BE DIFFERENT FROM THE OTHER, I HAVE EDITED ALL DIFFERENT AREAS OF EACH PHP WITH NO RESULT.
I HAVE VOTED FOR EACH DIFFERENT ITEM VIA DIFFERENT MACHINES SO THE VOTING ITSELF IS WORKING FINE AND ALL ITEMS ARE ACCEPTING VOTES BUT YOU CAN ONLY VOTE FOR 1 ITEM
BELOW IS A COPY OF THE ORIGINAL PHP (UNEDITED BY MYSELF)
"DO YOU KNOW WHAT I NEED TO CHANGE FOR EACH PHP TO MAKE THEM INDIVIDUAL OR EVEN IF THIS IS MY PROBLEM" Huh
PLEASE HELP, CHEERS, BARRY
<?php
$modify_perm=1;
$islinux = (strrpos(file, "/") === false) ? false : true;
if ($islinux){
//Linux uses: /
$dbprefix = substr(substr(file, 0, strlen(file)-4),strrpos(substr(file, 0, strlen(file)-4),"/")+1);
}else{
//Windows uses: \
$dbprefix = substr(substr(file, 0, strlen(file)-4),strrpos(substr(file, 0, strlen(file)-4),"\")+1);
}
$iswindows = (strpos(file, ":\") !== false) ? true : false;
$database = $dbprefix . ".dat";
$usrip = $_SERVER['REMOTE_ADDR'];
function writeFile($content, $filename){
if ($handle = fopen ($filename, "w")){
if (fwrite($handle, $content) === FALSE) {
return false;
}else{
return true;
}
fclose($handle);
}else{
return false;
}
}
if($modify_perm==1){
if (function_exists("chmod")){
// Try to set the permissions which is needed for the creation of the database
// Fixes windows chmod issues < http://us2.php.net/chmod#16395 >
if ($iswindows){
@chmod(dirname(file), 666);
}else{
@chmod(dirname(file), 0777);
}
}
}
if ($GET['command'] == "getvotes"){
if (file_exists($database)){
$databasecontent = file($database);
$votes = array();
$i=0;
$summation = 0;
foreach($databasecontent as $entry){
if (trim($entry)!=""){
$parts = explode("|",$entry);
$votes[$i]['vote'] = $parts[0];
$votes[$i]['ip'] = $parts[1];
$summation += $parts[0];
$i++;
}
}
echo "&rating=" . ((count($votes) != 0) ? round($summation/count($votes)) : 0);
echo "&numofvotes=" . count($votes). "&foo";
}else{
echo "&rating=0&numofvotes=0&foo";
}
}else if($GET['command'] == "postvotes"){
if (!file_exists($database)){
writeFile("",$database);
if($modify_perm==1){
// Try to set the permissions which is needed for the database
// Fixes windows chmod issues < http://us2.php.net/chmod#16395 >
if ($iswindows){
@chmod($database, 666);
}else{
@chmod($database, 0777);
}
}
}
$databaseunparsed = file_get_contents($database);
$databasecontent = file($database);
$ips = array();
foreach($databasecontent as $entry){
if (trim($entry)!=""){
$parts = explode("|",$entry);
$ips[] = trim($parts[1]);
}
}
if (!in_array($usrip,$ips, false) && is_numeric($GET['vote'])){
//Expire in one year
$flood = time()+606024*365;
$others = array();
if (isset($COOKIE['tntvotesys'])){
$others1 = explode("|",$COOKIE['tntvotesys']);
$others = (is_array($others1)) ? $others1 : $others;
}
if (!in_array(md5(file),$others, false)){
$others[] = md5(file);
$newothers = implode("|",$others);
setcookie("tntvotesys",$newothers,$flood,"/");
//Add the vote
if (trim($databaseunparsed) == ""){
$new = $GET['vote'] . "|" . $usrip;
}else{
$new = $databaseunparsed . "\r\n" . $_GET['vote'] . "|" . $usrip;
}
writeFile($new,$database);
//Display Updated Votes
echo "&message=Vote%20added";
$databasecontent = file($database);
$votes = array();
$i=0;
$summation = 0;
foreach($databasecontent as $entry){
if (trim($entry)!=""){
$parts = explode("|",$entry);
$votes[$i]['vote'] = $parts[0];
$votes[$i]['ip'] = $parts[1];
$summation += $parts[0];
$i++;
}
}
echo "&rating=" . ((count($votes) != 0) ? round($summation/count($votes)) : 0);
echo "&numofvotes=" . count($votes) . "&foo";
}else{
echo "&message=You%20already%20voted";
}
}else{
echo "&message=You%20already%20voted";
}
}
?>