From d0c5f92ac7a766f9c6c555c16e2f7ed1077e0255 Mon Sep 17 00:00:00 2001 From: "Nicolas A. Tonne" Date: Tue, 21 Oct 2014 14:47:25 +0200 Subject: [PATCH] Added and styled delete button --- php/change.php | 48 ++++++++++++++++++++++++++++++++---------------- static/style.css | 2 +- 2 files changed, 33 insertions(+), 17 deletions(-) diff --git a/php/change.php b/php/change.php index 387c6b7f..574898bd 100755 --- a/php/change.php +++ b/php/change.php @@ -103,31 +103,47 @@ else if(isset($_GET['v'])){ //add } } + else if(isset($_GET['vote'])){ //add vote $vote=$_GET['vote']; $id=$_GET['id']; //$i = array_search($id, $data["songs"]); //$i = array_search($id, array_keys($data["songs"])) - 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; - 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"]); + if($vote=='del'){ + $pass=$_GET['pass']; + $x = explode("/", htmlspecialchars(strtolower($_SERVER["REQUEST_URI"]))); + $pass=crypt($pass, '$6$rounds=9001$'.$x[1].'Fuck0ffuSn34kyn!ggerzZ$'); + $adminpass='$6$rounds=9001$tritoenFuck0ffuS$si2Hi95ghCxSbVAfgeBN0dVzf5DTn1mQoizOuLEzr0N2q6fclGLrapscJQA0PsA2F0TlG5q0YAYrPHy9dZxpj0'; //$data["conf"]["admin"]; + + if($adminpass == $pass){ + unset($data["songs"][$id]); file_put_contents($list, json_encode($data)); - echo "Vote registrated. I hope"; + echo "removed song with ID: ".$id." from list: ".$list; } + }else { - echo array_key_exists($id, $data["songs"]); + 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; + 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"; + } + }else + { + echo array_key_exists($id, $data["songs"]); + } } } else if(isset($_GET['skip'])){ //skip song request diff --git a/static/style.css b/static/style.css index 0f15f981..c6b3159f 100755 --- a/static/style.css +++ b/static/style.css @@ -72,7 +72,7 @@ body{background:#000; margin:0; } .votes{position: relative; margin-top: -0-5em; font-size: 18px; color:#fff;} #plus, #minus {text-decoration: none; color:#eee; margin-left: 2px; padding-left: 3px; padding-right: 3px; } #plus:hover,#minus:hover{color:#000;} -#del{float: right; font-weight: bold; margin-right: 20px; margin-top:0px; border-radius: 2px;} +#del{float: right; font-weight: bold; margin-right: 20px; margin-top:0px; border-radius: 2px; display:none;} #del:hover{color:red;} #player{height: 68%; height: calc(87% - 183px); width: 60%; border-radius: 3px; box-shadow: 0 8px 11px -4px black;}