mirror of
https://github.com/KevinMidboe/zoff.git
synced 2025-10-29 18:00:23 +00:00
Fixed arrays and change.php accordingly
This commit is contained in:
128
change.php
Executable file → Normal file
128
change.php
Executable file → Normal file
@@ -16,45 +16,75 @@ $list="lists/".$list.".json";
|
||||
$f = @fopen($list,"x");
|
||||
if($f){ fwrite($f,"[[],[".time()."],[],[],[],[]]"); fclose($f); }
|
||||
$file = file_get_contents($list);
|
||||
$data = json_decode($file);
|
||||
$data = json_decode($file, TRUE);
|
||||
$songs = $data["songs"];
|
||||
$np = $data["nowPlaying"];
|
||||
$np = array_values($np);
|
||||
$firstSong = array_values($songs);
|
||||
$save = false;
|
||||
|
||||
|
||||
if(isset($_REQUEST['thisUrl'])){
|
||||
$string = $_REQUEST['thisUrl'];
|
||||
$action = isset($_REQUEST['act']);
|
||||
|
||||
if($data[0][0] == $string)
|
||||
$firstToAdd = $firstSong[0]["id"];
|
||||
if($np[0]["id"] == $string)
|
||||
{
|
||||
if($action=="save"){ //next song
|
||||
$save = true;
|
||||
nextSong();
|
||||
}
|
||||
else if($action=="delete"){
|
||||
array_shift($data[0]);
|
||||
array_shift($data[3]);
|
||||
array_shift($data[2]);
|
||||
//array_shift($data["songs"]);
|
||||
//array_shift($data["nowPlaying"]);
|
||||
array_shift($data["songs"]);
|
||||
$data["songs"][$np[0]["id"]] = array("id" => $np[0]["id"], "title" => $np[0]["title"], "votes" => $np[0]["votes"], "added" => time(), "guids" => array());
|
||||
array_shift($data["nowPlaying"]);
|
||||
$data["nowPlaying"][$firstSong[0]["id"]] = array("id" => $firstSong[0]["id"], "title" => $firstSong[0]["title"], "votes" => 0, "added" => $firstSong[0]["added"], "guids" => $firstSong[0]["guids"]);
|
||||
//array_push($data["songs"], $add);
|
||||
$data["conf"]["skips"] = array();
|
||||
$data["conf"]["startTime"] = time();
|
||||
$data["conf"]["views"] = 1;
|
||||
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"]);
|
||||
}
|
||||
/* else if($action=="delete"){
|
||||
array_shift($firstSong[0]);
|
||||
}*/
|
||||
file_put_contents($list, json_encode($data));
|
||||
}
|
||||
if($action == "save" && !$save) //count views
|
||||
{
|
||||
$data[4][0] = $data[4][0] + 1;
|
||||
$data["conf"]["views"] = $data["conf"]["views"] + 1;
|
||||
file_put_contents($list, json_encode($data));
|
||||
}
|
||||
echo $data[0][0];
|
||||
$newPlaying = array_values($data["nowPlaying"]);
|
||||
echo $newPlaying[0]["id"];
|
||||
}
|
||||
else if(isset($_GET['v'])){ //add
|
||||
$video = htmlspecialchars($_GET['v']);
|
||||
$name = htmlspecialchars($_GET['n']);
|
||||
if(!in_array($video, $data[0]))
|
||||
if(!in_array($video, $data["songs"]))
|
||||
{
|
||||
//$arrayAdd = array("id" => array("id" => $video, "title" => $name, "votes" => array()));
|
||||
//array_push($data[0], $video);
|
||||
$i = array_search(0, $data[2]);
|
||||
$data["songs"][$video] = array("id" => $video, "title" => $name, "votes" => 0, "added" => time(), "guids" => array());
|
||||
$data["songs"][$video]["votes"] = 1;
|
||||
array_push($data["songs"][$video]["guids"], $guid);
|
||||
$sort = array();
|
||||
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"]);
|
||||
//array_push($data["songs"], $arrayAdd);
|
||||
/*$i = array_search(0, $data[2]);
|
||||
if($i == 0)$i=1;
|
||||
else if($i == false)$i=count($data[2]);
|
||||
array_splice($data[3], $i, 0, array($name));
|
||||
array_splice($data[2], $i, 0, array(1));
|
||||
array_splice($data[0], $i, 0, array($video));
|
||||
file_put_contents($list, json_encode($data));*/
|
||||
file_put_contents($list, json_encode($data));
|
||||
print("added");
|
||||
}
|
||||
@@ -63,46 +93,64 @@ else if(isset($_GET['v'])){ //add
|
||||
else if(isset($_GET['vote'])){ //add vote
|
||||
$vote=$_GET['vote'];
|
||||
$id=$_GET['id'];
|
||||
$i = array_search($id, $data[0]);
|
||||
//$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;}
|
||||
$name = $data[3][$i];
|
||||
$votes = $data[2][$i] + $voteAdd;
|
||||
if($i == true && $votes >= 0){
|
||||
|
||||
//print_r($i);
|
||||
// echo "IIII: ",$i;
|
||||
unset($data[3][$i]);
|
||||
unset($data[0][$i]);
|
||||
unset($data[2][$i]);
|
||||
$underVote = array_search($votes-1, $data[2]); #nenennenenen feiiiiiiiiiiiiiiiiil
|
||||
|
||||
if($underVote == 0)$underVote=1;
|
||||
else if($underVote == false)$underVote=count($data[2]);
|
||||
array_splice($data[3], $underVote, 0, array($name));
|
||||
array_splice($data[2], $underVote, 0, array($votes));
|
||||
array_splice($data[0], $underVote, 0, array($id));
|
||||
file_put_contents($list, json_encode($data));
|
||||
echo "Vote registrated. I hope";
|
||||
//$name = $data[3][$i];
|
||||
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'];
|
||||
}
|
||||
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"]);
|
||||
}
|
||||
}
|
||||
else if(isset($_GET['skip'])){ //skip song request
|
||||
$viewers=$data[4][0];
|
||||
$skips=count($data[5]);
|
||||
if(!in_array($guid, $data[5])){
|
||||
array_push($data[5], $guid);
|
||||
$viewers=$data["conf"]["views"];
|
||||
$skips=count($data["conf"]["skips"]);
|
||||
if(!in_array($guid, $data["conf"]["skips"])){
|
||||
array_push($data["conf"]["skips"], $guid);
|
||||
$skips+=1;
|
||||
$data[5][0]=$skips;
|
||||
//$data["conf"]["skips"]=$skips;
|
||||
if($skips>=$viewers/2){
|
||||
nextSong();
|
||||
echo("skipped!");
|
||||
array_shift($data["songs"]);
|
||||
$data["songs"][$np[0]["id"]] = array("id" => $np[0]["id"], "title" => $np[0]["title"], "votes" => $np[0]["votes"], "added" => time(), "guids" => array());
|
||||
array_shift($data["nowPlaying"]);
|
||||
$data["nowPlaying"][$firstSong[0]["id"]] = array("id" => $firstSong[0]["id"], "title" => $firstSong[0]["title"], "votes" => 0, "added" => $firstSong[0]["added"], "guids" => $firstSong[0]["guids"]);
|
||||
//array_push($data["songs"], $add);
|
||||
$data["conf"]["skips"] = array();
|
||||
$data["conf"]["startTime"] = time();
|
||||
$data["conf"]["views"] = 1;
|
||||
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($skips."/".$viewers);
|
||||
|
||||
}else if(isset($_GET['timedifference'])){
|
||||
|
||||
$diff = (time() - $data["conf"]["startTime"]);
|
||||
$returnArray = array($diff, $firstSong[0]["id"], time(), $data["conf"]["startTime"], $firstSong[0]["title"], $data["conf"]["views"]);
|
||||
$returnArray = json_encode($returnArray);
|
||||
echo($data);
|
||||
}else{
|
||||
echo json_encode($data);
|
||||
}
|
||||
else{ print($file); }
|
||||
|
||||
function nextSong(){
|
||||
global $data;
|
||||
|
||||
12
list.js
Executable file → Normal file
12
list.js
Executable file → Normal file
@@ -14,25 +14,25 @@ function updateList()
|
||||
async: false
|
||||
}).responseText;
|
||||
list = $.parseJSON(list);
|
||||
list[0].shift();
|
||||
/*list[0].shift();
|
||||
list[3].shift();
|
||||
list[2].shift();
|
||||
list[2].shift();*/
|
||||
|
||||
setTimeout(function()
|
||||
{
|
||||
|
||||
$("#wrapper").empty();
|
||||
|
||||
$.each(list[0], function(j, listeID){
|
||||
$.each(list["songs"], function(j, listeID){
|
||||
|
||||
var video_title=list[3][j].replace(/\\\'/, "'");
|
||||
var video_id = list[0][j];
|
||||
var video_title=listeID["title"].replace(/\\\'/, "'");
|
||||
var video_id = listeID["id"];
|
||||
var video_thumb = "http://i.ytimg.com/vi/"+video_id+"/default.jpg";
|
||||
var odd = ""; if(j%2==0)odd=" oddlist";
|
||||
var finalhtml="<div id='result' class='result lresult"+odd+"'>"+
|
||||
"<img src='"+video_thumb+"' class='thumb lthumb'>"+
|
||||
"<div class='ltitle'>"+video_title+"</div>"+
|
||||
"<div class='votes'>"+list[2][j]+"<a onclick=\"vote('"+video_id+"','pos');\" id='plus'>+</a><a onclick=\"vote('"+video_id+"','neg');\" id='minus'>-</a></div>"+
|
||||
"<div class='votes'>"+listeID["votes"]+"<a onclick=\"vote('"+video_id+"','pos');\" id='plus'>+</a><a onclick=\"vote('"+video_id+"','neg');\" id='minus'>-</a></div>"+
|
||||
"</div>";
|
||||
$("#wrapper").append(finalhtml);
|
||||
});
|
||||
|
||||
@@ -1 +1 @@
|
||||
[["-1jPUB7gRyg","llyiQ4I-mcQ","GMoud3dub6U","tenz01ic1D8","byp94CCWKSI","87JabMupbB8","iMP4BwvJSwo","_ovdm2yX4MA","2CGF_Z3yZAo","fIMz0nTp2sA","kHue-HaXXzg","cN-ZjkDBaX8","J_DV9b0x7v4","nI_MVldpxDQ","-N6O0xI3A2o","MXXRHpVed3M","Eo-KmOd3i7s","w15oWDh02K4","aZg2pEokcFw","bLLMPnPK0fU","afOH2SGDiK0","bESGLojNYSo","kTHNpusq654","LOZuxwVk7TU","CduA0TULnow","4fndeDfaWCg","ZyhrYis509A","ZKuOB1HGWMY","O1OTWCd40bc","cNvjKkXFBvU","Z7YrFLIyYIw","smwj7ISnwXM","cjEwjDvh_2c","7x3CCKaOlfU","qQ31INpjXX0","EpbjEttizy8","JjgU4EypX0w","Id7e-9WaxMc","5LILChvqUo4","TssyfiAWOrA","a_426RiwST8","si81bIoZRJQ","yzC4hFK5P3g","QzEwx4BoYI0","jRx5PrAlUdY","N6xoFhkthls","51Bpx63wkbA","rVeMiVU77wo","2A85xBaLYWc","mllXxyHTzfg","aHjpOzsQ9YI","4kjpZ_sPxzc","Qc9c12q3mrc","YlUKcNNmywk","6Cp6mKbRTQY","6_TtYYiKi_0","Pmv8aQKO6k0","ETfiUYij5UE","mpaPBCBjSVc","3O1_3zBUKM8","6l7J1i1OkKs","_t2TzJOyops","S8jhXmfdRFY","ChzbYiYHOUU","NRWUoDpo2fo","41WtJps5XqQ","lrsNeqANI3k","s8Qa2t71aFE","pt3PcA4UvPA","rQu6_Iv_-H0","HVVUXv1WaGE"],[1412882300],[0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],["Aqua - Doctor Jones","Vengaboys - Boom, Boom, Boom, Boom!!","\u00c5ge Aleksandersen - Levva Livet","Avicii - Levels","Jason Derulo - \\"The Other Side\\" (Official HD Music Video)","Bodybangers Inc. - Kompani Linge 2012","LMFAO - Sexy And I Know It (Mord Fustang Remix)","Avicii - Levels","Jason Derulo - Don\\'t Wanna Go Home (Official Video)","E-Type ft. Na Na - Life","Demi Lovato - Let It Go (from \\"Frozen\\") [Official]","\u00c5ge Aleksandersen - Fire Pils og en Pizza - Rockefeller, 03.2009. HQ.","CaramellDansen (Full Version + Lyrics)","Daddy DJ","Guy Sebastian - Like a Drum","Vengaboys - We\\'re Going to Ibiza!","\\'N Sync - Bye Bye Bye","Gigi D\\'Agostino - L\\'Amour Toujours ( Official Video )","H\u00f8vlerivisa","D.D.E. - Bondekn\u00f8l","dde vi ska f\u00e6st","Lady Gaga - Poker Face","Katy Perry - Hot N Cold","Britney Spears - Toxic","Britney Spears - Oops!...I Did It Again","Backstreet Boys - I Want It That Way","Aqua - Barbie Girl","Robert er du neger?","The Weeknd - Wicked Games (Explicit)","WEKEED - Wild Child","Tuuli - Do It Like A Dru [[WoW Parody]]","tribalistas ja sei namorar","Pelle Politibil Intro Sang","Peaches - Rosa Helikopter","Albatraoz - Albatraoz","David Guetta - Lovers On The Sun (Official Audio) ft Sam Martin","Ludacris - Move Bitch [Dirty]","Ellie Goulding - High For This (The Weeknd Cover)","Porter Robinson - Language (Official Video)","Maroon 5 - It Was Always You (Audio) SPEEDED UP VERSION","The Black Keys - Lonely Boy [Official Music Video]","Porter Robinson - Divinity ft. Amy Millan","\u304d\u3083\u308a\u30fc\u3071\u307f\u3085\u3071\u307f\u3085 - PONPONPON , Kyary Pamyu Pamyu - PONPONPON","Kyla La Grange - Cut Your Teeth (Kygo Remix)","O-Zone - Dragostea Din Tei (Ultra Music)","Datarock - Fa Fa Fa [Official Music Video]","R\u00f6yksopp - Happy Up Here [Official Music Video]","alt-J (\u2206) Breezeblocks","The Weeknd - Wicked Games (LYRICS)","The Hobbit: The Desolation of Smaug - Ed Sheeran \\"I See Fire\\" [HD]","Crystallize - Lindsey Stirling (Dubstep Violin Original Song)","Lemaitre - Cut to Black (Official)","Avicii - Addicted To You","Red Hot Chili Peppers - Californication [Official Music Video]","Avicii - Hey Brother","Lemaitre - Fiction (Official Video)","twenty one pilots: Guns For Hands [OFFICIAL VIDEO]","Biggie Smalls feat. Thomas the Tank Engine","The Black Keys - Tighten Up [Official Music Video]","Naughty Boy - La La La ft. Sam Smith","YG - My Nigga (Remix) (Explicit) ft. Lil Wayne, Rich Homie Quan, Meek Mill, Nicki Minaj","Skrillex - Ruffneck - FULL Flex [Music Video]","Otto Knows - Million Voices","Tim Berg - Bromance (Aviciis Arena Mix) (Official Video HD)","alt-J - Left Hand Free (Official Video) 1","Ms Mr - Hurricane (CHVRCHES Remix)","Hermione Mix | Pogo & Jeesh","Zedd - Shave It (Original Mix)","GTA 5 Official Trailer Song\/Music - \\"Sleepwalking\\" by The Chain Gang of 1974 (Full GTA V Song)","Zedd - Dovregubben (Original Mix)","Hedegaard - Happy Home (Matoma Official Remix)"],[3],[]]
|
||||
{"nowPlaying":{"Sb3XfrCtjVU":{"id":"Sb3XfrCtjVU","title":"The Notorious BIG ft. Ja Rule - Old Thing Back (Matoma Remix)","votes":0,"added":1412940931,"guids":[]}},"songs":{"b24ALjuvR3M":{"id":"b24ALjuvR3M","title":"Philter - Revolver (OFFICIAL MUSIC VIDEO)","votes":1,"added":1412941390,"guids":["MTYwMjcx"]},"jEgX64n3T7g":{"id":"jEgX64n3T7g","title":"Massive Attack - Paradise Circus","votes":1,"added":1412942005,"guids":["MTYwMjcx"]},"u7K72X4eo_s":{"id":"u7K72X4eo_s","title":"Massive Attack - Teardrop","votes":1,"added":1412942256,"guids":["MTYwMjcx"]},"V40EjCjP3VU":{"id":"V40EjCjP3VU","title":"Philter - The Seven Seas","votes":0,"added":1412941171,"guids":[]}},"conf":{"startTime":1412942005,"views":1,"skips":[]}}
|
||||
9
timedifference.php
Executable file → Normal file
9
timedifference.php
Executable file → Normal file
@@ -3,10 +3,11 @@
|
||||
if($list[1]==""||!isset($list[1])||count($list)<=1)$list="videos";
|
||||
else $list=$list[1];
|
||||
$list="lists/".$list.".json";
|
||||
$data = json_decode(file_get_contents($list));
|
||||
$diff = (time() - $data[1][0]);
|
||||
|
||||
$returnArray = array($diff, $data[0][0], time(), $data[1][0], $data[3][0], $data[4][0]);
|
||||
$data = json_decode(file_get_contents($list), true);
|
||||
$songs = $data["nowPlaying"];
|
||||
$id = array_values($songs);
|
||||
$diff = (time() - $data["conf"]["startTime"]);
|
||||
$returnArray = array($diff, $id[0]["id"], time(), $data["conf"]["startTime"], $id[0]["title"], $data["conf"]["views"]);
|
||||
$returnArray = json_encode($returnArray);
|
||||
|
||||
echo $returnArray;
|
||||
|
||||
9
youtube.js
Executable file → Normal file
9
youtube.js
Executable file → Normal file
@@ -39,9 +39,10 @@ $(document).ready(function()
|
||||
url: "change.php",
|
||||
async: false
|
||||
}).responseText;
|
||||
|
||||
url = $.parseJSON(response);
|
||||
|
||||
//console.log(response);
|
||||
response = $.parseJSON(response);
|
||||
for(first in response["nowPlaying"]) break;
|
||||
console.log(first);
|
||||
$.ajax({
|
||||
type: 'get',
|
||||
url: 'timedifference.php',
|
||||
@@ -53,7 +54,7 @@ $(document).ready(function()
|
||||
});
|
||||
console.log("timediff:"+timeDifference[0]);
|
||||
|
||||
response = url[0][0];
|
||||
response = first;
|
||||
|
||||
tag = document.createElement('script');
|
||||
tag.src = "https://www.youtube.com/iframe_api";
|
||||
|
||||
Reference in New Issue
Block a user