mirror of
https://github.com/KevinMidboe/zoff.git
synced 2025-10-29 18:00:23 +00:00
added so you can't vote negative..
This commit is contained in:
@@ -96,30 +96,23 @@ else if(isset($_GET['vote'])){ //add vote
|
||||
$id=$_GET['id'];
|
||||
//$i = array_search($id, $data["songs"]);
|
||||
//$i = array_search($id, array_keys($data["songs"]))
|
||||
if($vote == 'neg'){$voteAdd = -1; $guid = "n".$guid;}
|
||||
else if($vote == 'pos'){$voteAdd = 1; $guid = "p".$guid;}
|
||||
if(in_array("p".$guid, $data["songs"][$id]["guids"]) && $vote == "neg")
|
||||
{
|
||||
unset($data[array_search("p".$guid, $data["songs"][$id]["guids"])]);
|
||||
$data["songs"][$id]["votes"] = $data["songs"][$id]["votes"] + 1;
|
||||
}else if(in_array("n".$guid, $data["songs"][$id]["guids"]) && $vote == "pos")
|
||||
{
|
||||
unset($data[array_search("n".$guid, $data["songs"][$id]["guids"])]);
|
||||
$data["songs"][$id]["votes"] = $data["songs"][$id]["votes"] - 1;
|
||||
}
|
||||
if($vote == 'neg'){$voteAdd = -1;}
|
||||
else if($vote == 'pos'){$voteAdd = 1;}
|
||||
if(array_key_exists($id, $data["songs"]) && !in_array($guid, $data["songs"][$id]["guids"]))
|
||||
{
|
||||
$data["songs"][$id]["votes"] = $data["songs"][$id]["votes"] + $voteAdd;
|
||||
$data["songs"][$id]["added"] = time();
|
||||
array_push($data["songs"][$id]["guids"], $guid);
|
||||
foreach($data["songs"] as $k=>$v) {
|
||||
$sort['votes'][$k] = $v['votes'];
|
||||
$sort['added'][$k] = $v['added'];
|
||||
if($data["songs"][$id]["votes"] > -1)
|
||||
{
|
||||
$data["songs"][$id]["added"] = time();
|
||||
array_push($data["songs"][$id]["guids"], $guid);
|
||||
foreach($data["songs"] as $k=>$v) {
|
||||
$sort['votes'][$k] = $v['votes'];
|
||||
$sort['added'][$k] = $v['added'];
|
||||
}
|
||||
array_multisort($sort['votes'], SORT_DESC, $sort['added'], SORT_ASC, $data["songs"]);
|
||||
file_put_contents($list, json_encode($data));
|
||||
echo "Vote registrated. I hope";
|
||||
}
|
||||
array_multisort($sort['votes'], SORT_DESC, $sort['added'], SORT_ASC, $data["songs"]);
|
||||
print_r($data);
|
||||
file_put_contents($list, json_encode($data));
|
||||
echo "Vote registrated. I hope";
|
||||
}else
|
||||
{
|
||||
echo array_key_exists($id, $data["songs"]);
|
||||
|
||||
Reference in New Issue
Block a user