From 13db77d2d4cd21596f375403f6ea157549668a95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kasper=20Rynning-T=C3=B8nnesen?= Date: Wed, 22 Oct 2014 23:55:02 +0200 Subject: [PATCH 1/3] Added admin settings input --- lists/tritoen.json | 2 +- php/change.php | 65 ++++++++++++++++++++++++++-------------------- php/panel.php | 13 +++++----- static/style.css | 2 +- 4 files changed, 46 insertions(+), 36 deletions(-) diff --git a/lists/tritoen.json b/lists/tritoen.json index 307f557d..a861b0af 100755 --- a/lists/tritoen.json +++ b/lists/tritoen.json @@ -1 +1 @@ -{"nowPlaying":{"ZyhrYis509A":{"id":"ZyhrYis509A","title":"Aqua - Barbie Girl","votes":0,"added":1413805530,"guids":[]}},"songs":{"aZg2pEokcFw":{"id":"aZg2pEokcFw","title":"H\u00f8vlerivisa","votes":0,"added":1413805864,"guids":[]},"afOH2SGDiK0":{"id":"afOH2SGDiK0","title":"dde vi ska f\u00e6st","votes":0,"added":1413806149,"guids":[]},"bLLMPnPK0fU":{"id":"bLLMPnPK0fU","title":"D.D.E. - Bondekn\u00f8l","votes":0,"added":1413806157,"guids":[]},"byp94CCWKSI":{"id":"byp94CCWKSI","title":"Jason Derulo - \\"The Other Side\\" (Official HD Music Video)","votes":0,"added":1413806422,"guids":[]},"cN-ZjkDBaX8":{"id":"cN-ZjkDBaX8","title":"\u00c5ge Aleksandersen - Fire Pils og en Pizza - Rockefeller, 03.2009. HQ.","votes":0,"added":1413806661,"guids":[]},"cNvjKkXFBvU":{"id":"cNvjKkXFBvU","title":"WEKEED - Wild Child","votes":0,"added":1413807028,"guids":[]},"cjEwjDvh_2c":{"id":"cjEwjDvh_2c","title":"Pelle Politibil Intro Sang","votes":0,"added":1413807168,"guids":[]},"fIMz0nTp2sA":{"id":"fIMz0nTp2sA","title":"E-Type ft. Na Na - Life","votes":0,"added":1413807409,"guids":[]},"iMP4BwvJSwo":{"id":"iMP4BwvJSwo","title":"LMFAO - Sexy And I Know It (Mord Fustang Remix)","votes":0,"added":1413807542,"guids":[]},"kHue-HaXXzg":{"id":"kHue-HaXXzg","title":"Demi Lovato - Let It Go (from \\"Frozen\\") [Official]","votes":0,"added":1413807545,"guids":[]},"kTHNpusq654":{"id":"kTHNpusq654","title":"Katy Perry - Hot N Cold","votes":0,"added":1413807549,"guids":[]},"nI_MVldpxDQ":{"id":"nI_MVldpxDQ","title":"Daddy DJ","votes":0,"added":1413807552,"guids":[]},"qQ31INpjXX0":{"id":"qQ31INpjXX0","title":"Albatraoz - Albatraoz","votes":0,"added":1413807556,"guids":[]},"smwj7ISnwXM":{"id":"smwj7ISnwXM","title":"tribalistas ja sei namorar","votes":0,"added":1413807780,"guids":[]},"tenz01ic1D8":{"id":"tenz01ic1D8","title":"Avicii - Levels","votes":0,"added":1413808022,"guids":[]},"w15oWDh02K4":{"id":"w15oWDh02K4","title":"Gigi D\\'Agostino - L\\'Amour Toujours ( Official Video )","votes":0,"added":1413808717,"guids":[]},"-1jPUB7gRyg":{"id":"-1jPUB7gRyg","title":"Aqua - Doctor Jones","votes":0,"added":1413808929,"guids":[]},"llyiQ4I-mcQ":{"id":"llyiQ4I-mcQ","title":"Vengaboys - Boom, Boom, Boom, Boom!!","votes":0,"added":1413809137,"guids":[]},"-N6O0xI3A2o":{"id":"-N6O0xI3A2o","title":"Guy Sebastian - Like a Drum","votes":0,"added":1413809333,"guids":[]},"2CGF_Z3yZAo":{"id":"2CGF_Z3yZAo","title":"Jason Derulo - Don\\'t Wanna Go Home (Official Video)","votes":0,"added":1413809590,"guids":[]},"4fndeDfaWCg":{"id":"4fndeDfaWCg","title":"Backstreet Boys - I Want It That Way","votes":0,"added":1413809813,"guids":[]},"7x3CCKaOlfU":{"id":"7x3CCKaOlfU","title":"Peaches - Rosa Helikopter","votes":0,"added":1413810040,"guids":[]},"87JabMupbB8":{"id":"87JabMupbB8","title":"Bodybangers Inc. - Kompani Linge 2012","votes":0,"added":1413810263,"guids":[]},"CduA0TULnow":{"id":"CduA0TULnow","title":"Britney Spears - Oops!...I Did It Again","votes":0,"added":1413810519,"guids":[]},"Eo-KmOd3i7s":{"id":"Eo-KmOd3i7s","title":"\\'N Sync - Bye Bye Bye","votes":0,"added":1413810765,"guids":[]},"EpbjEttizy8":{"id":"EpbjEttizy8","title":"David Guetta - Lovers On The Sun (Official Audio) ft Sam Martin","votes":0,"added":1413810973,"guids":[]},"GMoud3dub6U":{"id":"GMoud3dub6U","title":"\u00c5ge Aleksandersen - Levva Livet","votes":0,"added":1413811320,"guids":[]},"J_DV9b0x7v4":{"id":"J_DV9b0x7v4","title":"CaramellDansen (Full Version + Lyrics)","votes":0,"added":1413811502,"guids":[]},"LOZuxwVk7TU":{"id":"LOZuxwVk7TU","title":"Britney Spears - Toxic","votes":0,"added":1413811718,"guids":[]},"MXXRHpVed3M":{"id":"MXXRHpVed3M","title":"Vengaboys - We\\'re Going to Ibiza!","votes":0,"added":1413811942,"guids":[]},"O1OTWCd40bc":{"id":"O1OTWCd40bc","title":"The Weeknd - Wicked Games (Explicit)","votes":0,"added":1413893479,"guids":[]},"ZKuOB1HGWMY":{"id":"ZKuOB1HGWMY","title":"Robert er du neger?","votes":0,"added":1413893541,"guids":["MTI3NzY1"]},"Z7YrFLIyYIw":{"id":"Z7YrFLIyYIw","title":"Tuuli - Do It Like A Dru [[WoW Parody]]","votes":0,"added":1413893741,"guids":[]},"bESGLojNYSo":{"id":"bESGLojNYSo","title":"Lady Gaga - Poker Face","votes":0,"added":1413893762,"guids":["MTI3NzY1"]},"_ovdm2yX4MA":{"id":"_ovdm2yX4MA","title":"Avicii - Levels","votes":0,"added":1413893765,"guids":["MTI3NzY1"]}},"conf":{"startTime":1413893741,"views":2,"skips":[]}} \ No newline at end of file +{"nowPlaying":{"D4V8PgTPK1g":{"id":"D4V8PgTPK1g","title":"ENO - \u1796\u17c1\u179b\u1794\u1784\u1792\u17d2\u179c\u17be\u1796\u17d2\u179a\u17b6\u1793\u1791\u17be\u1794\u17a2\u17bc\u1793\u1785\u17c1\u17c7\u179f\u17d2\u1798\u17c4\u17c7 - Pel Bong Tver Prean Terb Oun Jes Smos [MV]","votes":0,"added":1414013585,"guids":["ODYyMDk1"]}},"songs":{"fIMz0nTp2sA":{"id":"fIMz0nTp2sA","title":"E-Type ft. Na Na - Life","votes":0,"added":1413807409,"guids":[]},"iMP4BwvJSwo":{"id":"iMP4BwvJSwo","title":"LMFAO - Sexy And I Know It (Mord Fustang Remix)","votes":0,"added":1413807542,"guids":[]},"kHue-HaXXzg":{"id":"kHue-HaXXzg","title":"Demi Lovato - Let It Go (from \\"Frozen\\") [Official]","votes":0,"added":1413807545,"guids":[]},"kTHNpusq654":{"id":"kTHNpusq654","title":"Katy Perry - Hot N Cold","votes":0,"added":1413807549,"guids":[]},"nI_MVldpxDQ":{"id":"nI_MVldpxDQ","title":"Daddy DJ","votes":0,"added":1413807552,"guids":[]},"qQ31INpjXX0":{"id":"qQ31INpjXX0","title":"Albatraoz - Albatraoz","votes":0,"added":1413807556,"guids":[]},"smwj7ISnwXM":{"id":"smwj7ISnwXM","title":"tribalistas ja sei namorar","votes":0,"added":1413807780,"guids":[]},"tenz01ic1D8":{"id":"tenz01ic1D8","title":"Avicii - Levels","votes":0,"added":1413808022,"guids":[]},"w15oWDh02K4":{"id":"w15oWDh02K4","title":"Gigi D\\'Agostino - L\\'Amour Toujours ( Official Video )","votes":0,"added":1413808717,"guids":[]},"-1jPUB7gRyg":{"id":"-1jPUB7gRyg","title":"Aqua - Doctor Jones","votes":0,"added":1413808929,"guids":[]},"llyiQ4I-mcQ":{"id":"llyiQ4I-mcQ","title":"Vengaboys - Boom, Boom, Boom, Boom!!","votes":0,"added":1413809137,"guids":[]},"-N6O0xI3A2o":{"id":"-N6O0xI3A2o","title":"Guy Sebastian - Like a Drum","votes":0,"added":1413809333,"guids":[]},"2CGF_Z3yZAo":{"id":"2CGF_Z3yZAo","title":"Jason Derulo - Don\\'t Wanna Go Home (Official Video)","votes":0,"added":1413809590,"guids":[]},"4fndeDfaWCg":{"id":"4fndeDfaWCg","title":"Backstreet Boys - I Want It That Way","votes":0,"added":1413809813,"guids":[]},"7x3CCKaOlfU":{"id":"7x3CCKaOlfU","title":"Peaches - Rosa Helikopter","votes":0,"added":1413810040,"guids":[]},"87JabMupbB8":{"id":"87JabMupbB8","title":"Bodybangers Inc. - Kompani Linge 2012","votes":0,"added":1413810263,"guids":[]},"CduA0TULnow":{"id":"CduA0TULnow","title":"Britney Spears - Oops!...I Did It Again","votes":0,"added":1413810519,"guids":[]},"Eo-KmOd3i7s":{"id":"Eo-KmOd3i7s","title":"\\'N Sync - Bye Bye Bye","votes":0,"added":1413810765,"guids":[]},"EpbjEttizy8":{"id":"EpbjEttizy8","title":"David Guetta - Lovers On The Sun (Official Audio) ft Sam Martin","votes":0,"added":1413810973,"guids":[]},"GMoud3dub6U":{"id":"GMoud3dub6U","title":"\u00c5ge Aleksandersen - Levva Livet","votes":0,"added":1413811320,"guids":[]},"J_DV9b0x7v4":{"id":"J_DV9b0x7v4","title":"CaramellDansen (Full Version + Lyrics)","votes":0,"added":1413811502,"guids":[]},"LOZuxwVk7TU":{"id":"LOZuxwVk7TU","title":"Britney Spears - Toxic","votes":0,"added":1413811718,"guids":[]},"MXXRHpVed3M":{"id":"MXXRHpVed3M","title":"Vengaboys - We\\'re Going to Ibiza!","votes":0,"added":1413811942,"guids":[]},"O1OTWCd40bc":{"id":"O1OTWCd40bc","title":"The Weeknd - Wicked Games (Explicit)","votes":0,"added":1413893479,"guids":[]},"ZKuOB1HGWMY":{"id":"ZKuOB1HGWMY","title":"Robert er du neger?","votes":0,"added":1413893541,"guids":["MTI3NzY1"]},"Z7YrFLIyYIw":{"id":"Z7YrFLIyYIw","title":"Tuuli - Do It Like A Dru [[WoW Parody]]","votes":0,"added":1413893741,"guids":[]},"bESGLojNYSo":{"id":"bESGLojNYSo","title":"Lady Gaga - Poker Face","votes":0,"added":1413893762,"guids":["MTI3NzY1"]},"_ovdm2yX4MA":{"id":"_ovdm2yX4MA","title":"Avicii - Levels","votes":0,"added":1413893765,"guids":["MTI3NzY1"]},"ZyhrYis509A":{"id":"ZyhrYis509A","title":"Aqua - Barbie Girl","votes":0,"added":1414012410,"guids":[]},"aZg2pEokcFw":{"id":"aZg2pEokcFw","title":"H\u00f8vlerivisa","votes":0,"added":1414012594,"guids":[]},"afOH2SGDiK0":{"id":"afOH2SGDiK0","title":"dde vi ska f\u00e6st","votes":0,"added":1414012746,"guids":[]},"bLLMPnPK0fU":{"id":"bLLMPnPK0fU","title":"D.D.E. - Bondekn\u00f8l","votes":0,"added":1414012750,"guids":[]},"byp94CCWKSI":{"id":"byp94CCWKSI","title":"Jason Derulo - \\"The Other Side\\" (Official HD Music Video)","votes":0,"added":1414013014,"guids":[]},"cN-ZjkDBaX8":{"id":"cN-ZjkDBaX8","title":"\u00c5ge Aleksandersen - Fire Pils og en Pizza - Rockefeller, 03.2009. HQ.","votes":0,"added":1414013261,"guids":[]},"cNvjKkXFBvU":{"id":"cNvjKkXFBvU","title":"WEKEED - Wild Child","votes":0,"added":1414013540,"guids":[]},"cjEwjDvh_2c":{"id":"cjEwjDvh_2c","title":"Pelle Politibil Intro Sang","votes":0,"added":1414013683,"guids":[]},"7TQZw7NcMJQ":{"id":"7TQZw7NcMJQ","title":"\u9c57(ap fes11)","votes":0,"added":1414014317,"guids":[]}},"conf":{"startTime":1414014317,"views":2,"skips":[],"adminpass":"$6$rounds=9001$tritoenFuck0ffuS$oTH4CCbgC3OKjtyx9eRmx5oh7DzwJDZe0w.nBaxyIC5aU.nutyG6FzybE4qb0uA3RQtub32Vy1rmE\/Q5CgRIl.","vote":"false","addsongs":"false","longsongs":"false","frontpage":"false","onlymusic":"false","removeplay":"false"}} \ No newline at end of file diff --git a/php/change.php b/php/change.php index cd5ba639..b27ae86f 100755 --- a/php/change.php +++ b/php/change.php @@ -39,11 +39,11 @@ if(isset($_REQUEST['thisUrl'])){ if(!is_null($np[0]["id"]) && !is_null($firstToAdd)){ array_shift($data["songs"]); $q = $data["conf"]; - $q = array_key_exists("delsongs", $q); - if(!$data["conf"]["delsongs"] || $q != 1) - { - $data["songs"][$np[0]["id"]] = array("id" => $np[0]["id"], "title" => $np[0]["title"], "votes" => $np[0]["votes"], "added" => time(), "guids" => array()); - } + $q = array_key_exists("delsongs", $q); + if(!$data["conf"]["delsongs"] || $q != 1) + { + $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"]); @@ -80,28 +80,30 @@ if(isset($_REQUEST['thisUrl'])){ echo $newPlaying[0]["id"]; } else if(isset($_GET['v'])){ //add - $video = htmlspecialchars($_GET['v']); - $name = htmlspecialchars($_GET['n']); - if(!in_array($video, $data["songs"])) + if($data["conf"]["addsongs"] == "false") { - if(count($data["nowPlaying"]) > 0) $place = "songs"; - else $place = "nowPlaying"; - $data[$place][$video] = array("id" => $video, "title" => $name, "votes" => 0, "added" => time(), "guids" => array()); - $data[$place][$video]["votes"] = 1; - array_push($data[$place][$video]["guids"], $guid); - $sort = array(); - if($place != "nowPlaying") + $video = htmlspecialchars($_GET['v']); + $name = htmlspecialchars($_GET['n']); + if(!in_array($video, $data["songs"])) { - foreach($data["songs"] as $k=>$v) { - $sort['votes'][$k] = $v['votes']; - $sort['added'][$k] = $v['added']; + if(count($data["nowPlaying"]) > 0) $place = "songs"; + else $place = "nowPlaying"; + $data[$place][$video] = array("id" => $video, "title" => $name, "votes" => 0, "added" => time(), "guids" => array()); + $data[$place][$video]["votes"] = 1; + array_push($data[$place][$video]["guids"], $guid); + $sort = array(); + if($place != "nowPlaying") + { + 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_multisort($sort['votes'], SORT_DESC, $sort['added'], SORT_ASC, $data["songs"]); + file_put_contents($list, json_encode($data)); + print("added"); } - file_put_contents($list, json_encode($data)); - print("added"); } - } else if(isset($_GET['vote'])){ //add vote @@ -179,18 +181,25 @@ else if(isset($_GET['skip'])){ //skip song request }else if(isset($_POST['conf'])) { - $vote = $_POST['vote']; - $addsongs = $_POST['addsongs']; - $longsongs = $_POST['longsongs']; - $frontpage = $_POST['frontpage']; - $onlymusic = $_POST['onlymusic']; - $removeplay = $_POST['removeplay']; + $data["conf"]["vote"] = $_POST['vote']; + $data["conf"]["addsongs"] = $_POST['addsongs']; + $data["conf"]["longsongs"] = $_POST['longsongs']; + $$data["conf"]["frontpage"] = $_POST['frontpage']; + $data["conf"]["onlymusic"] = $_POST['onlymusic']; + $data["conf"]["removeplay"] = $_POST['removeplay']; $pass = $_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 = array_key_exists("adminpass", $q); + + //$data["conf"]["vote"] = $vote; + //$data["conf"]["addsongs"] = $addsongs; + //$data["conf"]["longsongs"] = $longsongs; + //$data["conf"]["frontpage"] = $frontpage; + //$data["conf"]["onlymusic"] = $onlymusic; + //$data["conf"]["removeplay"] = $removeplay; if($data["conf"]["adminpass"] == $pass || $q != 1) { echo "correct"; diff --git a/php/panel.php b/php/panel.php index 7f230d76..1abaea71 100755 --- a/php/panel.php +++ b/php/panel.php @@ -2,12 +2,13 @@
- - - - - - + + + + + + +
diff --git a/static/style.css b/static/style.css index efeb41b9..444aad84 100755 --- a/static/style.css +++ b/static/style.css @@ -68,7 +68,7 @@ body{background:#000; margin:0; } #adminForm{text-align:left;} #adminForm label{display: block; cursor: pointer;} .adminBox{float:right;} -#adminPanel{color:white; height:180px; padding: 10px; overflow:hidden; background-color: rgba(0,0,0,0.2);} +#adminPanel{color:white; height:200px; padding: 10px; overflow:hidden; background-color: rgba(0,0,0,0.2);} .hiddenAdmin{padding:0 !important; margin:0 !important; height: 0 !important;} .button{background-color: rgba(255,255,255,0.2); border-radius: 4px; border: none;color: white;padding: 5px 15px; margin-top: 15px; transition: all 0.1s ease-in-out;} .button:hover{background-color: rgba(255,255,255,0.4); } From 7df4a17891a65faa410c16efb605503d2c99ce83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kasper=20Rynning-T=C3=B8nnesen?= Date: Thu, 23 Oct 2014 00:07:15 +0200 Subject: [PATCH 2/3] Fixed some minor stupid stuff in change.php --- lists/tritoen.json | 2 +- php/change.php | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/lists/tritoen.json b/lists/tritoen.json index a861b0af..5bdbd37d 100755 --- a/lists/tritoen.json +++ b/lists/tritoen.json @@ -1 +1 @@ -{"nowPlaying":{"D4V8PgTPK1g":{"id":"D4V8PgTPK1g","title":"ENO - \u1796\u17c1\u179b\u1794\u1784\u1792\u17d2\u179c\u17be\u1796\u17d2\u179a\u17b6\u1793\u1791\u17be\u1794\u17a2\u17bc\u1793\u1785\u17c1\u17c7\u179f\u17d2\u1798\u17c4\u17c7 - Pel Bong Tver Prean Terb Oun Jes Smos [MV]","votes":0,"added":1414013585,"guids":["ODYyMDk1"]}},"songs":{"fIMz0nTp2sA":{"id":"fIMz0nTp2sA","title":"E-Type ft. Na Na - Life","votes":0,"added":1413807409,"guids":[]},"iMP4BwvJSwo":{"id":"iMP4BwvJSwo","title":"LMFAO - Sexy And I Know It (Mord Fustang Remix)","votes":0,"added":1413807542,"guids":[]},"kHue-HaXXzg":{"id":"kHue-HaXXzg","title":"Demi Lovato - Let It Go (from \\"Frozen\\") [Official]","votes":0,"added":1413807545,"guids":[]},"kTHNpusq654":{"id":"kTHNpusq654","title":"Katy Perry - Hot N Cold","votes":0,"added":1413807549,"guids":[]},"nI_MVldpxDQ":{"id":"nI_MVldpxDQ","title":"Daddy DJ","votes":0,"added":1413807552,"guids":[]},"qQ31INpjXX0":{"id":"qQ31INpjXX0","title":"Albatraoz - Albatraoz","votes":0,"added":1413807556,"guids":[]},"smwj7ISnwXM":{"id":"smwj7ISnwXM","title":"tribalistas ja sei namorar","votes":0,"added":1413807780,"guids":[]},"tenz01ic1D8":{"id":"tenz01ic1D8","title":"Avicii - Levels","votes":0,"added":1413808022,"guids":[]},"w15oWDh02K4":{"id":"w15oWDh02K4","title":"Gigi D\\'Agostino - L\\'Amour Toujours ( Official Video )","votes":0,"added":1413808717,"guids":[]},"-1jPUB7gRyg":{"id":"-1jPUB7gRyg","title":"Aqua - Doctor Jones","votes":0,"added":1413808929,"guids":[]},"llyiQ4I-mcQ":{"id":"llyiQ4I-mcQ","title":"Vengaboys - Boom, Boom, Boom, Boom!!","votes":0,"added":1413809137,"guids":[]},"-N6O0xI3A2o":{"id":"-N6O0xI3A2o","title":"Guy Sebastian - Like a Drum","votes":0,"added":1413809333,"guids":[]},"2CGF_Z3yZAo":{"id":"2CGF_Z3yZAo","title":"Jason Derulo - Don\\'t Wanna Go Home (Official Video)","votes":0,"added":1413809590,"guids":[]},"4fndeDfaWCg":{"id":"4fndeDfaWCg","title":"Backstreet Boys - I Want It That Way","votes":0,"added":1413809813,"guids":[]},"7x3CCKaOlfU":{"id":"7x3CCKaOlfU","title":"Peaches - Rosa Helikopter","votes":0,"added":1413810040,"guids":[]},"87JabMupbB8":{"id":"87JabMupbB8","title":"Bodybangers Inc. - Kompani Linge 2012","votes":0,"added":1413810263,"guids":[]},"CduA0TULnow":{"id":"CduA0TULnow","title":"Britney Spears - Oops!...I Did It Again","votes":0,"added":1413810519,"guids":[]},"Eo-KmOd3i7s":{"id":"Eo-KmOd3i7s","title":"\\'N Sync - Bye Bye Bye","votes":0,"added":1413810765,"guids":[]},"EpbjEttizy8":{"id":"EpbjEttizy8","title":"David Guetta - Lovers On The Sun (Official Audio) ft Sam Martin","votes":0,"added":1413810973,"guids":[]},"GMoud3dub6U":{"id":"GMoud3dub6U","title":"\u00c5ge Aleksandersen - Levva Livet","votes":0,"added":1413811320,"guids":[]},"J_DV9b0x7v4":{"id":"J_DV9b0x7v4","title":"CaramellDansen (Full Version + Lyrics)","votes":0,"added":1413811502,"guids":[]},"LOZuxwVk7TU":{"id":"LOZuxwVk7TU","title":"Britney Spears - Toxic","votes":0,"added":1413811718,"guids":[]},"MXXRHpVed3M":{"id":"MXXRHpVed3M","title":"Vengaboys - We\\'re Going to Ibiza!","votes":0,"added":1413811942,"guids":[]},"O1OTWCd40bc":{"id":"O1OTWCd40bc","title":"The Weeknd - Wicked Games (Explicit)","votes":0,"added":1413893479,"guids":[]},"ZKuOB1HGWMY":{"id":"ZKuOB1HGWMY","title":"Robert er du neger?","votes":0,"added":1413893541,"guids":["MTI3NzY1"]},"Z7YrFLIyYIw":{"id":"Z7YrFLIyYIw","title":"Tuuli - Do It Like A Dru [[WoW Parody]]","votes":0,"added":1413893741,"guids":[]},"bESGLojNYSo":{"id":"bESGLojNYSo","title":"Lady Gaga - Poker Face","votes":0,"added":1413893762,"guids":["MTI3NzY1"]},"_ovdm2yX4MA":{"id":"_ovdm2yX4MA","title":"Avicii - Levels","votes":0,"added":1413893765,"guids":["MTI3NzY1"]},"ZyhrYis509A":{"id":"ZyhrYis509A","title":"Aqua - Barbie Girl","votes":0,"added":1414012410,"guids":[]},"aZg2pEokcFw":{"id":"aZg2pEokcFw","title":"H\u00f8vlerivisa","votes":0,"added":1414012594,"guids":[]},"afOH2SGDiK0":{"id":"afOH2SGDiK0","title":"dde vi ska f\u00e6st","votes":0,"added":1414012746,"guids":[]},"bLLMPnPK0fU":{"id":"bLLMPnPK0fU","title":"D.D.E. - Bondekn\u00f8l","votes":0,"added":1414012750,"guids":[]},"byp94CCWKSI":{"id":"byp94CCWKSI","title":"Jason Derulo - \\"The Other Side\\" (Official HD Music Video)","votes":0,"added":1414013014,"guids":[]},"cN-ZjkDBaX8":{"id":"cN-ZjkDBaX8","title":"\u00c5ge Aleksandersen - Fire Pils og en Pizza - Rockefeller, 03.2009. HQ.","votes":0,"added":1414013261,"guids":[]},"cNvjKkXFBvU":{"id":"cNvjKkXFBvU","title":"WEKEED - Wild Child","votes":0,"added":1414013540,"guids":[]},"cjEwjDvh_2c":{"id":"cjEwjDvh_2c","title":"Pelle Politibil Intro Sang","votes":0,"added":1414013683,"guids":[]},"7TQZw7NcMJQ":{"id":"7TQZw7NcMJQ","title":"\u9c57(ap fes11)","votes":0,"added":1414014317,"guids":[]}},"conf":{"startTime":1414014317,"views":2,"skips":[],"adminpass":"$6$rounds=9001$tritoenFuck0ffuS$oTH4CCbgC3OKjtyx9eRmx5oh7DzwJDZe0w.nBaxyIC5aU.nutyG6FzybE4qb0uA3RQtub32Vy1rmE\/Q5CgRIl.","vote":"false","addsongs":"false","longsongs":"false","frontpage":"false","onlymusic":"false","removeplay":"false"}} \ No newline at end of file +{"nowPlaying":{"5ryIHUSiOQA":{"id":"5ryIHUSiOQA","title":"Truls - The Next (Matoma Remix)","votes":0,"added":1414011510,"guids":[]}},"songs":{"Sb3XfrCtjVU":{"id":"Sb3XfrCtjVU","title":"The Notorious BIG ft. Ja Rule - Old Thing Back (Matoma Remix)","votes":0,"added":1414011510,"guids":[]},"YEx-QeYvE8Q":{"id":"YEx-QeYvE8Q","title":"L\u00f6wenherz & Freed - Tagtraum","votes":0,"added":1414011522,"guids":[]},"HAIDqt2aUek":{"id":"HAIDqt2aUek","title":"Porter Robinson - Sad Machine (Lyric Video)","votes":0,"added":1414011523,"guids":[]},"uhYMVwn3pJw":{"id":"uhYMVwn3pJw","title":"Bob Sinclar - Cinderella (She Said Her Name) - Official Video","votes":0,"added":1414011530,"guids":[]},"rvPGHb14__4":{"id":"rvPGHb14__4","title":"John Mayer - Waiting On The World To Change (Scheinizzl Remix)","votes":0,"added":1414011531,"guids":[]},"xi8_BuYT9UI":{"id":"xi8_BuYT9UI","title":"Mattafix - Big City Life (LEEX Remix)","votes":0,"added":1414011533,"guids":[]},"V40EjCjP3VU":{"id":"V40EjCjP3VU","title":"Philter - The Seven Seas","votes":0,"added":1414011950,"guids":[]},"vMwFFENUOQk":{"id":"vMwFFENUOQk","title":"Mandeh - Sandbank","votes":0,"added":1414012185,"guids":[]},"lCtozJkvyV8":{"id":"lCtozJkvyV8","title":"Sterk\u00f8l ","votes":0,"added":1414012436,"guids":[]},"FQvak0ZpfBA":{"id":"FQvak0ZpfBA","title":"Philter - The Protagonist","votes":0,"added":1414012633,"guids":[]},"nnjxb5NvAIk":{"id":"nnjxb5NvAIk","title":"Philter - Pi","votes":0,"added":1414012827,"guids":[]},"cV9dsOJXt3g":{"id":"cV9dsOJXt3g","title":"Notorious BIG - Juicy (Sh\u00e8mce Remix)","votes":0,"added":1414013114,"guids":[]},"fkLEljSKY30":{"id":"fkLEljSKY30","title":"IZ - Somewhere Over The Rainbow ( Thomas Jack Remix )","votes":0,"added":1414013497,"guids":[]},"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":[]}},"conf":{"startTime":1414015554,"views":2,"skips":[],"delsongs":false}} \ No newline at end of file diff --git a/php/change.php b/php/change.php index b27ae86f..d81a56f6 100755 --- a/php/change.php +++ b/php/change.php @@ -39,8 +39,8 @@ if(isset($_REQUEST['thisUrl'])){ if(!is_null($np[0]["id"]) && !is_null($firstToAdd)){ array_shift($data["songs"]); $q = $data["conf"]; - $q = array_key_exists("delsongs", $q); - if(!$data["conf"]["delsongs"] || $q != 1) + $q = array_key_exists("removeplay", $q); + if(!$data["conf"]["removeplay"] || $q != 1) { $data["songs"][$np[0]["id"]] = array("id" => $np[0]["id"], "title" => $np[0]["title"], "votes" => $np[0]["votes"], "added" => time(), "guids" => array()); } @@ -80,7 +80,9 @@ if(isset($_REQUEST['thisUrl'])){ echo $newPlaying[0]["id"]; } else if(isset($_GET['v'])){ //add - if($data["conf"]["addsongs"] == "false") + $q = $data["conf"]; + $q = array_key_exists("addsongs", $q); + if($q != 1 || $data["conf"]["addsongs"] == "false") { $video = htmlspecialchars($_GET['v']); $name = htmlspecialchars($_GET['n']); @@ -157,9 +159,9 @@ else if(isset($_GET['skip'])){ //skip song request //$data["conf"]["skips"]=$skips; if($skips>=$viewers/2){ array_shift($data["songs"]); - $q = $data["conf"]; - $q = array_key_exists("delsongs", $q); - if(!$data["conf"]["delsongs"] || $q != 1) + $q = $data["conf"]; + $q = array_key_exists("removeplay", $q); + if(!$data["conf"]["removeplay"] || $q != 1) { $data["songs"][$np[0]["id"]] = array("id" => $np[0]["id"], "title" => $np[0]["title"], "votes" => $np[0]["votes"], "added" => time(), "guids" => array()); } From 679b5e64f379e1e1fee3882d3e747c5b7e2e3af8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kasper=20Rynning-T=C3=B8nnesen?= Date: Thu, 23 Oct 2014 00:48:34 +0200 Subject: [PATCH 3/3] Commented change.php --- lists/tritoen.json | 2 +- php/change.php | 158 +++++++++++++++++++++++---------------------- 2 files changed, 82 insertions(+), 78 deletions(-) diff --git a/lists/tritoen.json b/lists/tritoen.json index 5bdbd37d..d7d41ba7 100755 --- a/lists/tritoen.json +++ b/lists/tritoen.json @@ -1 +1 @@ -{"nowPlaying":{"5ryIHUSiOQA":{"id":"5ryIHUSiOQA","title":"Truls - The Next (Matoma Remix)","votes":0,"added":1414011510,"guids":[]}},"songs":{"Sb3XfrCtjVU":{"id":"Sb3XfrCtjVU","title":"The Notorious BIG ft. Ja Rule - Old Thing Back (Matoma Remix)","votes":0,"added":1414011510,"guids":[]},"YEx-QeYvE8Q":{"id":"YEx-QeYvE8Q","title":"L\u00f6wenherz & Freed - Tagtraum","votes":0,"added":1414011522,"guids":[]},"HAIDqt2aUek":{"id":"HAIDqt2aUek","title":"Porter Robinson - Sad Machine (Lyric Video)","votes":0,"added":1414011523,"guids":[]},"uhYMVwn3pJw":{"id":"uhYMVwn3pJw","title":"Bob Sinclar - Cinderella (She Said Her Name) - Official Video","votes":0,"added":1414011530,"guids":[]},"rvPGHb14__4":{"id":"rvPGHb14__4","title":"John Mayer - Waiting On The World To Change (Scheinizzl Remix)","votes":0,"added":1414011531,"guids":[]},"xi8_BuYT9UI":{"id":"xi8_BuYT9UI","title":"Mattafix - Big City Life (LEEX Remix)","votes":0,"added":1414011533,"guids":[]},"V40EjCjP3VU":{"id":"V40EjCjP3VU","title":"Philter - The Seven Seas","votes":0,"added":1414011950,"guids":[]},"vMwFFENUOQk":{"id":"vMwFFENUOQk","title":"Mandeh - Sandbank","votes":0,"added":1414012185,"guids":[]},"lCtozJkvyV8":{"id":"lCtozJkvyV8","title":"Sterk\u00f8l ","votes":0,"added":1414012436,"guids":[]},"FQvak0ZpfBA":{"id":"FQvak0ZpfBA","title":"Philter - The Protagonist","votes":0,"added":1414012633,"guids":[]},"nnjxb5NvAIk":{"id":"nnjxb5NvAIk","title":"Philter - Pi","votes":0,"added":1414012827,"guids":[]},"cV9dsOJXt3g":{"id":"cV9dsOJXt3g","title":"Notorious BIG - Juicy (Sh\u00e8mce Remix)","votes":0,"added":1414013114,"guids":[]},"fkLEljSKY30":{"id":"fkLEljSKY30","title":"IZ - Somewhere Over The Rainbow ( Thomas Jack Remix )","votes":0,"added":1414013497,"guids":[]},"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":[]}},"conf":{"startTime":1414015554,"views":2,"skips":[],"delsongs":false}} \ No newline at end of file +{"nowPlaying":{"lCtozJkvyV8":{"id":"lCtozJkvyV8","title":"Sterk\u00f8l ","votes":0,"added":1414012436,"guids":[]}},"songs":{"FQvak0ZpfBA":{"id":"FQvak0ZpfBA","title":"Philter - The Protagonist","votes":0,"added":1414012633,"guids":[]},"nnjxb5NvAIk":{"id":"nnjxb5NvAIk","title":"Philter - Pi","votes":0,"added":1414012827,"guids":[]},"cV9dsOJXt3g":{"id":"cV9dsOJXt3g","title":"Notorious BIG - Juicy (Sh\u00e8mce Remix)","votes":0,"added":1414013114,"guids":[]},"fkLEljSKY30":{"id":"fkLEljSKY30","title":"IZ - Somewhere Over The Rainbow ( Thomas Jack Remix )","votes":0,"added":1414013497,"guids":[]},"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":[]}},"conf":{"startTime":1414017982,"views":2,"skips":[],"delsongs":false}} \ No newline at end of file diff --git a/php/change.php b/php/change.php index d81a56f6..87145fca 100755 --- a/php/change.php +++ b/php/change.php @@ -1,59 +1,59 @@ array(), "songs" => array(), "conf" => array("startTime" => time(), "views" => 0, "skips" => array())); -$array = json_encode($array); -$f = @fopen($list,"x"); -if($f){ fwrite($f,$array); fclose($f); } -$file = file_get_contents($list); -$data = json_decode($file, TRUE); -$songs = $data["songs"]; +$array = json_encode($array); //encoding the array +$f = @fopen($list,"x"); //opening a file, ignoring warnings +if($f){ fwrite($f,$array); fclose($f); } //if the file doesn't exist, we create a new one, and adds the newly made array there +$file = file_get_contents($list); //gets the content of the file +$data = json_decode($file, TRUE); //decoding the file. The true is there for array comprehension in php or something. Don't remove! +$songs = $data["songs"]; //setting the now playing and the next song in the next couplecouple of lines $np = $data["nowPlaying"]; $np = array_values($np); $firstSong = array_values($songs); -$save = false; - +$save = false; //declares the save variable, see further down for why +//If test for either saving when the song is done, or an error has occured if(isset($_REQUEST['thisUrl'])){ - $string = $_REQUEST['thisUrl']; - $action = isset($_REQUEST['act']); - $firstToAdd = $firstSong[0]["id"]; - if($np[0]["id"] == $string) + $string = $_REQUEST['thisUrl']; //saving string as the id of the song + $action = isset($_REQUEST['act']); //checking the action of the request, either save or del + $firstToAdd = $firstSong[0]["id"]; //getting the id of the first in the queue + if($np[0]["id"] == $string) //if the string we're sending in matches the id of the song playing now, we proceed { - if($action=="save" || $action == "empty"){ //next song - $save = true; + if($action=="save" || $action == "empty"){ //action save or empty, either way goes further + $save = true; //small fix for the editing of viewers. Explain later in file. //array_shift($data["songs"]); //array_shift($data["nowPlaying"]); - if(!is_null($np[0]["id"]) && !is_null($firstToAdd)){ - array_shift($data["songs"]); + if(!is_null($np[0]["id"]) && !is_null($firstToAdd)){ //Checking both the next song and the song playing now is null, if so it just skips the flipping around with songs + 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) - { + $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 + { //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()); } - array_shift($data["nowPlaying"]); + array_shift($data["nowPlaying"]); //shifting the nowPlaying array, and moving the first in line to the nowPlaying array $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) { + $data["conf"]["skips"] = array(); //resets the skip count + $data["conf"]["startTime"] = time(); //resets the starttime of the song so it will be sorted accordingly + $data["conf"]["views"] = 1; //resets the views ??must be fixed.. + foreach($data["songs"] as $k=>$v) { //the next 5 lines of code is just for sorting the array with highest votes at the top, and the lowest time added at the top, so that the voting will be alot more fair $sort['votes'][$k] = $v['votes']; $sort['added'][$k] = $v['added']; } @@ -62,102 +62,99 @@ if(isset($_REQUEST['thisUrl'])){ /* else if($action=="delete"){ array_shift($firstSong[0]); }*/ - file_put_contents($list, json_encode($data)); - }else if(is_null($np[0]["id"])) + file_put_contents($list, json_encode($data)); //sending the encoded json array to the file + }else if(is_null($np[0]["id"])) //if nowPlaying is null, it just moves the first song in the queue up { 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"]); } - if($action == "save" && !$save) //count views + if($action == "save" && !$save) //count views { $data["conf"]["views"] = $data["conf"]["views"] + 1; file_put_contents($list, json_encode($data)); } - $newPlaying = array_values($data["nowPlaying"]); - echo $newPlaying[0]["id"]; + $newPlaying = array_values($data["nowPlaying"]); //returning the new songs id to the javascript so it gets what song to start next + echo $newPlaying[0]["id"]; } -else if(isset($_GET['v'])){ //add +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") + 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 { - $video = htmlspecialchars($_GET['v']); - $name = htmlspecialchars($_GET['n']); - if(!in_array($video, $data["songs"])) + $video = htmlspecialchars($_GET['v']); //id of the video + $name = htmlspecialchars($_GET['n']); //name of the video + if(!in_array($video, $data["songs"])) //checking if the video already is in the array of songs (should check the now playing to) { - if(count($data["nowPlaying"]) > 0) $place = "songs"; - else $place = "nowPlaying"; + if(count($data["nowPlaying"]) > 0) $place = "songs"; //checking if the nowPlaying array is empty, if it is, the "place" to add it is nowPlaying, if not it is songs + else $place = "nowPlaying"; //Adding to the array $data[$place][$video] = array("id" => $video, "title" => $name, "votes" => 0, "added" => time(), "guids" => array()); - $data[$place][$video]["votes"] = 1; - array_push($data[$place][$video]["guids"], $guid); - $sort = array(); + $data[$place][$video]["votes"] = 1; //Upping the votes, so it comes further up than the ones already played + array_push($data[$place][$video]["guids"], $guid); //adding the users GUID to the array so he can't vote infinite times if($place != "nowPlaying") { + $sort = array(); foreach($data["songs"] as $k=>$v) { - $sort['votes'][$k] = $v['votes']; + $sort['votes'][$k] = $v['votes']; //Again sorting, explained further up $sort['added'][$k] = $v['added']; } array_multisort($sort['votes'], SORT_DESC, $sort['added'], SORT_ASC, $data["songs"]); } file_put_contents($list, json_encode($data)); - print("added"); + print("added"); //Just telling the javascript that it has been added for some reason... } } } -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=='del'){ +else if(isset($_GET['vote'])){ //if the getvaluethingy is vote, this starts + $vote=$_GET['vote']; //The javascript either sends in neg or pos, this is where we save the value + $id=$_GET['id']; //id of the video/song the user is voting for + if($vote=='del'){ //This is so we don't have to make a seperate function for the delete $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){ + if($adminpass == $pass){ //checking if the password is correct, then deleting the song (this is not in use yet.) unset($data["songs"][$id]); file_put_contents($list, json_encode($data)); echo "removed song with ID: ".$id." from list: ".$list; } - }else + }else //if we don't get the del, we're voting, WOHO! { - if($vote == 'neg'){$voteAdd = -1;} - else if($vote == 'pos'){$voteAdd = 1;} + 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) + if($data["songs"][$id]["votes"] > -1) //but only if we're still above or equal to 0 { - $data["songs"][$id]["added"] = time(); - array_push($data["songs"][$id]["guids"], $guid); + $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']; + $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"; + echo "Vote registrated. I hope"; } }else { - echo array_key_exists($id, $data["songs"]); + echo array_key_exists($id, $data["songs"]); //not in use..i think.. } } } -else if(isset($_GET['skip'])){ //skip song request +else if(isset($_GET['skip'])){ //skip, really similar to the save function, not going in depth here. $viewers=$data["conf"]["views"]; - $skips=count($data["conf"]["skips"]); - if(!in_array($guid, $data["conf"]["skips"])){ + $skips=count($data["conf"]["skips"]); //Counting how many GUIDS there are under the skip key + if(!in_array($guid, $data["conf"]["skips"])){ //If the users GUID isn't in the array, its added array_push($data["conf"]["skips"], $guid); - $skips+=1; + $skips+=1; //and the number of skips is upped //$data["conf"]["skips"]=$skips; - if($skips>=$viewers/2){ + if($skips>=$viewers/2){ //checking if the skips wanted is larger than the viewers/2, if so its skipping, woohooo! array_shift($data["songs"]); $q = $data["conf"]; $q = array_key_exists("removeplay", $q); @@ -179,11 +176,11 @@ else if(isset($_GET['skip'])){ //skip song request } file_put_contents($list, json_encode($data)); } - echo($skips."/".$viewers); + echo($skips."/".$viewers); //always printing out the skip/viewer ratio -}else if(isset($_POST['conf'])) +}else if(isset($_POST['conf'])) //conf, this is for admin settings/channel settings { - $data["conf"]["vote"] = $_POST['vote']; + $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']; @@ -202,22 +199,29 @@ else if(isset($_GET['skip'])){ //skip song request //$data["conf"]["frontpage"] = $frontpage; //$data["conf"]["onlymusic"] = $onlymusic; //$data["conf"]["removeplay"] = $removeplay; - if($data["conf"]["adminpass"] == $pass || $q != 1) + if($data["conf"]["adminpass"] == $pass || $q != 1) //if the password is the same as the one in the jsonfile, we are updating the settings (not in use yet) { echo "correct"; file_put_contents($list, json_encode($data)); } -}else if(isset($_GET['timedifference'])){ +}else if(isset($_GET['timedifference'])){ //deprecated i think $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($data); +}else{ //printing the whole data array json encoded for youtube.js or list.js to pick up echo json_encode($data); } -function addSong($name, $id, $title) +// +// +//None of these are in use any more/yet +// +// +// + +function addSong($name, $id, $title) { } @@ -227,7 +231,7 @@ function nextSong(){ array_push($data[0], $data[0][0]); array_shift($data[0]); - array_push($data[2], 0); //reset votes + array_push($data[2], 0); array_shift($data[2]); array_push($data[3], $data[3][0]);