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:
@@ -1 +1 @@
|
||||
{"nowPlaying":{"b24ALjuvR3M":{"id":"b24ALjuvR3M","title":"Philter - Revolver (OFFICIAL MUSIC VIDEO)","votes":0,"added":1412941390,"guids":["MTYwMjcx"]}},"songs":{"jEgX64n3T7g":{"id":"jEgX64n3T7g","title":"Massive Attack - Paradise Circus","votes":2,"added":1412944217,"guids":["MTYwMjcx","MjQ3Mjk5"]},"u7K72X4eo_s":{"id":"u7K72X4eo_s","title":"Massive Attack - Teardrop","votes":2,"added":1412944232,"guids":["MTYwMjcx","MjQ3Mjk5"]},"Sb3XfrCtjVU":{"id":"Sb3XfrCtjVU","title":"The Notorious BIG ft. Ja Rule - Old Thing Back (Matoma Remix)","votes":1,"added":1412944219,"guids":["MjQ3Mjk5"]},"V40EjCjP3VU":{"id":"V40EjCjP3VU","title":"Philter - The Seven Seas","votes":1,"added":1412944225,"guids":["MjQ3Mjk5"]}},"conf":{"startTime":1412944204,"views":1,"skips":[]}}
|
||||
{"nowPlaying":{"u7K72X4eo_s":{"id":"u7K72X4eo_s","title":"Massive Attack - Teardrop","votes":0,"added":1412944772,"guids":[]}},"songs":{"Sb3XfrCtjVU":{"id":"Sb3XfrCtjVU","title":"The Notorious BIG ft. Ja Rule - Old Thing Back (Matoma Remix)","votes":0,"added":1412945400,"guids":[]},"V40EjCjP3VU":{"id":"V40EjCjP3VU","title":"Philter - The Seven Seas","votes":0,"added":1412945413,"guids":[]},"jEgX64n3T7g":{"id":"jEgX64n3T7g","title":"Massive Attack - Paradise Circus","votes":0,"added":1412945537,"guids":["pMTYwMjcx","nMTYwMjcx"]},"b24ALjuvR3M":{"id":"b24ALjuvR3M","title":"Philter - Revolver (OFFICIAL MUSIC VIDEO)","votes":0,"added":1412945620,"guids":[]}},"conf":{"startTime":1412945620,"views":1,"skips":[]}}
|
||||
@@ -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