mirror of
https://github.com/KevinMidboe/zoff.git
synced 2025-10-29 18:00:23 +00:00
12
js/admin.js
12
js/admin.js
@@ -11,24 +11,26 @@ function admin()
|
||||
|
||||
function submitAdmin(form)
|
||||
{
|
||||
vote = form.vote.checked,
|
||||
voting = form.vote.checked,
|
||||
addSongs = form.addSongs.checked,
|
||||
longSongs = form.longSongs.checked,
|
||||
frontpage = form.frontPage.checked,
|
||||
onlyMusic = form.onlyMusic.checked,
|
||||
removePlay = form.removePlay.checked,
|
||||
pass = form.pass.value;
|
||||
adminpass = form.pass.value;
|
||||
|
||||
conf = $.ajax({
|
||||
confRes = $.ajax({
|
||||
type: "POST",
|
||||
url: "php/change.php",
|
||||
async: false,
|
||||
data: "conf=start&vote="+vote+"&addsongs="+addSongs+"&longsongs="+longSongs+"&frontpage="+frontpage+"&onlymusic="+onlyMusic+"&removeplay="+removePlay+"&pass="+pass,
|
||||
data: "conf=start&vote="+voting+"&addsongs="+addSongs+"&longsongs="+longSongs+"&frontpage="+frontpage+"&onlymusic="+onlyMusic+"&removeplay="+removePlay+"&pass="+adminpass,
|
||||
|
||||
success: function() {
|
||||
console.log("configurations response: "+response);
|
||||
}
|
||||
}).responseText;
|
||||
|
||||
console.log(conf);
|
||||
pass = confRes;
|
||||
console.log(pass);
|
||||
|
||||
}
|
||||
|
||||
18
js/list.js
18
js/list.js
@@ -14,6 +14,15 @@ function updateList()
|
||||
async: false
|
||||
}).responseText;
|
||||
list = $.parseJSON(list);
|
||||
conf = list["conf"];
|
||||
if(conf.hasOwnProperty("addsongs") && conf["addsongs"] == "true") adminadd = 1;
|
||||
else adminadd = 0;
|
||||
if(conf.hasOwnProperty("onlymusic") && conf["onlymusic"] == "true") music = 1;
|
||||
else music = 0;
|
||||
if(conf.hasOwnProperty("longsongs") && conf["longsongs"] == "true") longS = 1;
|
||||
else longS = 0;
|
||||
if(conf.hasOwnProperty("vote") && conf["vote"] == "true") adminvote = 1;
|
||||
else adminvote = 0;
|
||||
/*list[0].shift();
|
||||
list[3].shift();
|
||||
list[2].shift();*/
|
||||
@@ -67,15 +76,22 @@ function updateList()
|
||||
document.getElementById("player").style.display="none";
|
||||
ytplayer.pauseVideo();
|
||||
}
|
||||
document.getElementsByName("vote")[0].checked = (conf["vote"] === "true");
|
||||
document.getElementsByName("addSongs")[0].checked = (conf["addsongs"] === "true");
|
||||
document.getElementsByName("longSongs")[0].checked = (conf["longsongs"] === "true");
|
||||
document.getElementsByName("frontPage")[0].checked = (conf["frontpage"] === "true");
|
||||
document.getElementsByName("onlyMusic")[0].checked = (conf["onlymusic"] === "true");
|
||||
document.getElementsByName("removePlay")[0].checked = (conf["removeplay"] === "true");
|
||||
}, 2500);
|
||||
}
|
||||
|
||||
function vote(id, vote){
|
||||
console.log(adminpass);
|
||||
console.log($.ajax({
|
||||
type: "GET",
|
||||
url: "php/change.php",
|
||||
async: false,
|
||||
data: "vote="+vote+"&id="+id,
|
||||
data: "vote="+vote+"&id="+id+"&pass="+adminpass,
|
||||
success: function() {
|
||||
console.log("voted "+vote+" on "+id);
|
||||
if(vote=="pos"){ $("#playlist").addClass("success");}
|
||||
|
||||
@@ -39,8 +39,8 @@ $(document).ready(function()
|
||||
{
|
||||
$.each(response.data.items, function(i,data)
|
||||
{
|
||||
if(data.duration > 720){return;}
|
||||
if(data["category"] == "Music"){
|
||||
if(data.duration > 720 && longS == 0){return;}
|
||||
if(data["category"] == "Music" || music == 0){
|
||||
var video_title=encodeURIComponent(data.title).replace(/'/g, "\\\'");
|
||||
var views=data.viewCount;
|
||||
var video_thumb = "http://i.ytimg.com/vi/"+data.id+"/default.jpg";
|
||||
@@ -74,7 +74,7 @@ $(document).ready(function()
|
||||
type: "GET",
|
||||
url: "php/change.php",
|
||||
async: false,
|
||||
data: "v="+id+"&n="+title,
|
||||
data: "v="+id+"&n="+title+"&pass="+adminpass,
|
||||
success: function() {
|
||||
console.log("added "+id);
|
||||
document.getElementById("search").value = "";
|
||||
|
||||
@@ -22,6 +22,14 @@ var interval;
|
||||
var viewers;
|
||||
var video_id;
|
||||
var changed = false;
|
||||
var conf = [];
|
||||
var adminvote = 0;
|
||||
var adminadd = 0;
|
||||
var adminskip = 0;
|
||||
var music = 0;
|
||||
var longS = 0;
|
||||
var frontpage = 1;
|
||||
var adminpass = "";
|
||||
|
||||
$(document).ready(function()
|
||||
{
|
||||
@@ -43,6 +51,8 @@ $(document).ready(function()
|
||||
//console.log(response);
|
||||
response = $.parseJSON(response);
|
||||
console.log(response["nowPlaying"].length);
|
||||
conf = response["conf"];
|
||||
console.log(conf);
|
||||
try{
|
||||
for(first in response["nowPlaying"]) break;
|
||||
console.log(first);
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"nowPlaying":{"fkLEljSKY30":{"id":"fkLEljSKY30","title":"IZ - Somewhere Over The Rainbow ( Thomas Jack Remix )","votes":0,"added":1414013497,"guids":[]}},"songs":{"lSooYPG-5Rg":{"id":"lSooYPG-5Rg","title":"Porter Robinson - Sea of Voices (Audio)","votes":0,"added":1414013802,"guids":[]},"si81bIoZRJQ":{"id":"si81bIoZRJQ","title":"Porter Robinson - Divinity ft. Amy Millan","votes":0,"added":1414014174,"guids":[]},"CUJcEYOjXI8":{"id":"CUJcEYOjXI8","title":"Philter - Flutterby","votes":0,"added":1414014353,"guids":[]},"FHCYHldJi_g":{"id":"FHCYHldJi_g","title":"Duke Dumont - I Got U (Official video) ft. Jax Jones","votes":0,"added":1414014596,"guids":[]},"VHoT4N43jK8":{"id":"VHoT4N43jK8","title":"Stromae - Alors On Danse","votes":0,"added":1414014891,"guids":[]},"eg5sRQNEwtg":{"id":"eg5sRQNEwtg","title":"Philter - Love","votes":0,"added":1414015111,"guids":[]},"oiKj0Z_Xnjc":{"id":"oiKj0Z_Xnjc","title":"Stromae - Papaoutai","votes":0,"added":1414015348,"guids":[]},"ublchJYzhao":{"id":"ublchJYzhao","title":"Stromae - ta f\u00eate","votes":0,"added":1414015554,"guids":[]},"5ryIHUSiOQA":{"id":"5ryIHUSiOQA","title":"Truls - The Next (Matoma Remix)","votes":0,"added":1414015747,"guids":[]},"Sb3XfrCtjVU":{"id":"Sb3XfrCtjVU","title":"The Notorious BIG ft. Ja Rule - Old Thing Back (Matoma Remix)","votes":0,"added":1414016072,"guids":[]},"YEx-QeYvE8Q":{"id":"YEx-QeYvE8Q","title":"L\u00f6wenherz & Freed - Tagtraum","votes":0,"added":1414016380,"guids":[]},"HAIDqt2aUek":{"id":"HAIDqt2aUek","title":"Porter Robinson - Sad Machine (Lyric Video)","votes":0,"added":1414016642,"guids":[]},"uhYMVwn3pJw":{"id":"uhYMVwn3pJw","title":"Bob Sinclar - Cinderella (She Said Her Name) - Official Video","votes":0,"added":1414016836,"guids":[]},"rvPGHb14__4":{"id":"rvPGHb14__4","title":"John Mayer - Waiting On The World To Change (Scheinizzl Remix)","votes":0,"added":1414017132,"guids":[]},"xi8_BuYT9UI":{"id":"xi8_BuYT9UI","title":"Mattafix - Big City Life (LEEX Remix)","votes":0,"added":1414017509,"guids":[]},"V40EjCjP3VU":{"id":"V40EjCjP3VU","title":"Philter - The Seven Seas","votes":0,"added":1414017748,"guids":[]},"vMwFFENUOQk":{"id":"vMwFFENUOQk","title":"Mandeh - Sandbank","votes":0,"added":1414017982,"guids":[]},"lCtozJkvyV8":{"id":"lCtozJkvyV8","title":"Sterk\u00f8l ","votes":0,"added":1414018229,"guids":[]},"FQvak0ZpfBA":{"id":"FQvak0ZpfBA","title":"Philter - The Protagonist","votes":0,"added":1414018425,"guids":[]},"nnjxb5NvAIk":{"id":"nnjxb5NvAIk","title":"Philter - Pi","votes":0,"added":1414018616,"guids":[]},"cV9dsOJXt3g":{"id":"cV9dsOJXt3g","title":"Notorious BIG - Juicy (Sh\u00e8mce Remix)","votes":0,"added":1414019099,"guids":[]}},"conf":{"startTime":1414019099,"views":2,"skips":[],"delsongs":false}}
|
||||
{"nowPlaying":{"CUJcEYOjXI8":{"id":"CUJcEYOjXI8","title":"Philter - Flutterby","votes":0,"added":1414085270,"guids":["ODYyMDk1"]}},"songs":{"si81bIoZRJQ":{"id":"si81bIoZRJQ","title":"Porter Robinson - Divinity ft. Amy Millan","votes":1,"added":1414085726,"guids":["ODYyMDk1"]},"S_xH7noaqTA":{"id":"S_xH7noaqTA","title":"Stromae - Formidable (ceci n'est pas une le\u00e7on)","votes":1,"added":1414085750,"guids":["ODYyMDk1"]},"CAMWdvo71ls":{"id":"CAMWdvo71ls","title":"Stromae - Tous Les M\u00eames","votes":1,"added":1414085803,"guids":["ODYyMDk1"]},"FHCYHldJi_g":{"id":"FHCYHldJi_g","title":"Duke Dumont - I Got U (Official video) ft. Jax Jones","votes":0,"added":1414080930,"guids":[]},"VHoT4N43jK8":{"id":"VHoT4N43jK8","title":"Stromae - Alors On Danse","votes":0,"added":1414081170,"guids":[]},"eg5sRQNEwtg":{"id":"eg5sRQNEwtg","title":"Philter - Love","votes":0,"added":1414081389,"guids":[]},"oiKj0Z_Xnjc":{"id":"oiKj0Z_Xnjc","title":"Stromae - Papaoutai","votes":0,"added":1414081626,"guids":[]},"ublchJYzhao":{"id":"ublchJYzhao","title":"Stromae - ta f\u00eate","votes":0,"added":1414081830,"guids":[]},"5ryIHUSiOQA":{"id":"5ryIHUSiOQA","title":"Truls - The Next (Matoma Remix)","votes":0,"added":1414082020,"guids":[]},"Sb3XfrCtjVU":{"id":"Sb3XfrCtjVU","title":"The Notorious BIG ft. Ja Rule - Old Thing Back (Matoma Remix)","votes":0,"added":1414082346,"guids":[]},"YEx-QeYvE8Q":{"id":"YEx-QeYvE8Q","title":"L\u00f6wenherz & Freed - Tagtraum","votes":0,"added":1414082654,"guids":[]},"HAIDqt2aUek":{"id":"HAIDqt2aUek","title":"Porter Robinson - Sad Machine (Lyric Video)","votes":0,"added":1414082916,"guids":[]},"rvPGHb14__4":{"id":"rvPGHb14__4","title":"John Mayer - Waiting On The World To Change (Scheinizzl Remix)","votes":0,"added":1414083212,"guids":[]},"uhYMVwn3pJw":{"id":"uhYMVwn3pJw","title":"Bob Sinclar - Cinderella (She Said Her Name) - Official Video","votes":0,"added":1414083406,"guids":[]},"xi8_BuYT9UI":{"id":"xi8_BuYT9UI","title":"Mattafix - Big City Life (LEEX Remix)","votes":0,"added":1414083784,"guids":[]},"vMwFFENUOQk":{"id":"vMwFFENUOQk","title":"Mandeh - Sandbank","votes":0,"added":1414084019,"guids":[]},"V40EjCjP3VU":{"id":"V40EjCjP3VU","title":"Philter - The Seven Seas","votes":0,"added":1414084258,"guids":[]},"lCtozJkvyV8":{"id":"lCtozJkvyV8","title":"Sterk\u00f8l ","votes":0,"added":1414084517,"guids":[]},"FQvak0ZpfBA":{"id":"FQvak0ZpfBA","title":"Philter - The Protagonist","votes":0,"added":1414084765,"guids":[]},"nnjxb5NvAIk":{"id":"nnjxb5NvAIk","title":"Philter - Pi","votes":0,"added":1414084956,"guids":[]},"cV9dsOJXt3g":{"id":"cV9dsOJXt3g","title":"Notorious BIG - Juicy (Sh\u00e8mce Remix)","votes":0,"added":1414085243,"guids":[]},"fkLEljSKY30":{"id":"fkLEljSKY30","title":"IZ - Somewhere Over The Rainbow ( Thomas Jack Remix )","votes":0,"added":1414085626,"guids":[]},"lSooYPG-5Rg":{"id":"lSooYPG-5Rg","title":"Porter Robinson - Sea of Voices (Audio)","votes":0,"added":1414085929,"guids":[]}},"conf":{"startTime":1414085929,"views":2,"skips":[],"addsongs":"true","longsongs":"false","onlymusic":"true","removeplay":"false","adminpass":"$6$rounds=9001$tritoenFuck0ffuS$oTH4CCbgC3OKjtyx9eRmx5oh7DzwJDZe0w.nBaxyIC5aU.nutyG6FzybE4qb0uA3RQtub32Vy1rmE\/Q5CgRIl.","frontpage":"false","vote":"true"}}
|
||||
@@ -40,7 +40,7 @@ if(isset($_REQUEST['thisUrl'])){
|
||||
array_shift($data["songs"]); //already shifts the array of songs, because we have the first in the queue saved
|
||||
$q = $data["conf"];
|
||||
$q = array_key_exists("removeplay", $q);
|
||||
if(!$data["conf"]["removeplay"] || $q != 1) //checking if removeplay exists or if its false. If its true, the song we just played won't be added to the queue
|
||||
if($data["conf"]["removeplay"] == "false" || $q != 1) //checking if removeplay exists or if its false. If its true, the song we just played won't be added to the queue
|
||||
{ //here we just adds the song that was just played into the queue in the songs array, take note here we set added as the current time it was added. This is because of the multisort further down
|
||||
$data["songs"][$np[0]["id"]] = array("id" => $np[0]["id"], "title" => $np[0]["title"], "votes" => $np[0]["votes"], "added" => time(), "guids" => array());
|
||||
}
|
||||
@@ -81,7 +81,10 @@ if(isset($_REQUEST['thisUrl'])){
|
||||
else if(isset($_GET['v'])){ //if it gets v, we start our add "function"
|
||||
$q = $data["conf"];
|
||||
$q = array_key_exists("addsongs", $q);
|
||||
if($q != 1 || $data["conf"]["addsongs"] == "false") //checking wether it has been set so only admins can add songs. If its false, or the value doesn't exist, we continue
|
||||
$pass = htmlspecialchars($_GET['pass']);
|
||||
$x = explode("/", htmlspecialchars(strtolower($_SERVER["REQUEST_URI"])));
|
||||
$pass=crypt($pass, '$6$rounds=9001$'.$x[1].'Fuck0ffuSn34kyn!ggerzZ$');
|
||||
if($pass == $data['conf']['adminpass'] || $data['conf']['addsongs'] == "false" || $q != 1) //checking wether it has been set so only admins can add songs. If its false, or the value doesn't exist, we continue
|
||||
{
|
||||
$video = htmlspecialchars($_GET['v']); //id of the video
|
||||
$name = htmlspecialchars($_GET['n']); //name of the video
|
||||
@@ -124,27 +127,37 @@ else if(isset($_GET['vote'])){ //if th
|
||||
|
||||
}else //if we don't get the del, we're voting, WOHO!
|
||||
{
|
||||
if($vote == 'neg'){$voteAdd = -1;} //setting the votetoadd to the array depending of what way you swing.
|
||||
else if($vote == 'pos'){$voteAdd = 1;} //checking if the key exists in the array, and if we're already voted
|
||||
if(array_key_exists($id, $data["songs"]) && !in_array($guid, $data["songs"][$id]["guids"]))
|
||||
{ //finally adding the vote to the votings
|
||||
$data["songs"][$id]["votes"] = $data["songs"][$id]["votes"] + $voteAdd;
|
||||
if($data["songs"][$id]["votes"] > -1) //but only if we're still above or equal to 0
|
||||
{
|
||||
$data["songs"][$id]["added"] = time(); //updating the added time, so it comes on the bottom of its own "level" of votes
|
||||
array_push($data["songs"][$id]["guids"], $guid); //pushing the users guid to the array so he/she can't vote again
|
||||
foreach($data["songs"] as $k=>$v) {
|
||||
$sort['votes'][$k] = $v['votes']; //again, sorting
|
||||
$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
|
||||
$q = $data["conf"];
|
||||
$q = array_key_exists("vote", $q);
|
||||
$pass = htmlspecialchars($_GET['pass']);
|
||||
$x = explode("/", htmlspecialchars(strtolower($_SERVER["REQUEST_URI"])));
|
||||
$pass=crypt($pass, '$6$rounds=9001$'.$x[1].'Fuck0ffuSn34kyn!ggerzZ$');
|
||||
if($pass == $data['conf']['adminpass'] || $data['conf']['vote'] == "false" || $q != 1)
|
||||
{
|
||||
echo array_key_exists($id, $data["songs"]); //not in use..i think..
|
||||
if($vote == 'neg'){$voteAdd = -1;} //setting the votetoadd to the array depending of what way you swing.
|
||||
else if($vote == 'pos'){$voteAdd = 1;} //checking if the key exists in the array, and if we're already voted
|
||||
if(array_key_exists($id, $data["songs"]) && !in_array($guid, $data["songs"][$id]["guids"]))
|
||||
{ //finally adding the vote to the votings
|
||||
$data["songs"][$id]["votes"] = $data["songs"][$id]["votes"] + $voteAdd;
|
||||
if($data["songs"][$id]["votes"] > -1) //but only if we're still above or equal to 0
|
||||
{
|
||||
$data["songs"][$id]["added"] = time(); //updating the added time, so it comes on the bottom of its own "level" of votes
|
||||
array_push($data["songs"][$id]["guids"], $guid); //pushing the users guid to the array so he/she can't vote again
|
||||
foreach($data["songs"] as $k=>$v) {
|
||||
$sort['votes'][$k] = $v['votes']; //again, sorting
|
||||
$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"]); //not in use..i think..
|
||||
}
|
||||
}
|
||||
echo $pass."\n".$data['conf']['adminpass'];
|
||||
|
||||
}
|
||||
}
|
||||
else if(isset($_GET['skip'])){ //skip, really similar to the save function, not going in depth here.
|
||||
@@ -158,7 +171,7 @@ else if(isset($_GET['skip'])){ //skip,
|
||||
array_shift($data["songs"]);
|
||||
$q = $data["conf"];
|
||||
$q = array_key_exists("removeplay", $q);
|
||||
if(!$data["conf"]["removeplay"] || $q != 1)
|
||||
if($data["conf"]["removeplay"] == "false" || $q != 1)
|
||||
{
|
||||
$data["songs"][$np[0]["id"]] = array("id" => $np[0]["id"], "title" => $np[0]["title"], "votes" => $np[0]["votes"], "added" => time(), "guids" => array());
|
||||
}
|
||||
@@ -183,14 +196,14 @@ else if(isset($_GET['skip'])){ //skip,
|
||||
$data["conf"]["vote"] = $_POST['vote']; //setting all the settings from the post gotten from admin.js
|
||||
$data["conf"]["addsongs"] = $_POST['addsongs'];
|
||||
$data["conf"]["longsongs"] = $_POST['longsongs'];
|
||||
$$data["conf"]["frontpage"] = $_POST['frontpage'];
|
||||
$data["conf"]["frontpage"] = $_POST['frontpage'];
|
||||
$data["conf"]["onlymusic"] = $_POST['onlymusic'];
|
||||
$data["conf"]["removeplay"] = $_POST['removeplay'];
|
||||
$pass = $_POST['pass'];
|
||||
$pass = htmlspecialchars($_POST['pass']);
|
||||
$x = explode("/", htmlspecialchars(strtolower($_SERVER["REQUEST_URI"])));
|
||||
$pass=crypt($pass, '$6$rounds=9001$'.$x[1].'Fuck0ffuSn34kyn!ggerzZ$');
|
||||
$data['conf']['adminpass'] = $pass;
|
||||
$q = $data["conf"];
|
||||
$q = $data["conf"];
|
||||
$q = array_key_exists("adminpass", $q);
|
||||
|
||||
//$data["conf"]["vote"] = $vote;
|
||||
@@ -203,7 +216,10 @@ else if(isset($_GET['skip'])){ //skip,
|
||||
{
|
||||
echo "correct";
|
||||
file_put_contents($list, json_encode($data));
|
||||
}
|
||||
}else
|
||||
{
|
||||
echo "wrong";
|
||||
}
|
||||
}else if(isset($_GET['timedifference'])){ //deprecated i think
|
||||
|
||||
$diff = (time() - $data["conf"]["startTime"]);
|
||||
|
||||
@@ -10,5 +10,5 @@
|
||||
<label>Remove song after playing <input type="checkbox" name="removePlay" value="1"></label>
|
||||
<label>Admin Password <input type="password" name="pass"></label>
|
||||
|
||||
<input type="button" class="button" value="Save Settings" onclick="submitAdmin(this.form)">
|
||||
<input type="button" class="button" value="Save Settings" onclick="submitAdmin(this.form);">
|
||||
</form>
|
||||
|
||||
Reference in New Issue
Block a user