mirror of
https://github.com/KevinMidboe/zoff.git
synced 2025-10-29 18:00:23 +00:00
Reorganized files and added script to convert old lists
This commit is contained in:
42
php/admin.php
Normal file
42
php/admin.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<html>
|
||||
<head>
|
||||
<?php include("header.php"); ?>
|
||||
</head>
|
||||
<body>
|
||||
<div class="top vcent centered">
|
||||
<div id="change" class="small">
|
||||
|
||||
<div class="main"></div>
|
||||
|
||||
<h1>Admin Settingspanel</h1>
|
||||
|
||||
<form name="ufo" action="" class="daform nomargin" id="base" method="get" onsubmit="null;" >
|
||||
<label>Anyone can vote:
|
||||
<label> <input type="radio" name="vote" value="yes">yes</input></label>
|
||||
<label> <input type="radio" name="vote" value="no">no</input></label>
|
||||
</label><br>
|
||||
<label>Anyone can add songs:
|
||||
<label><input type="radio" name="addSongs" value="yes">yes</input></label>
|
||||
<label><input type="radio" name="addSongs" value="no">no</input></label>
|
||||
</label><br>
|
||||
<label>Allow long songs:
|
||||
<label><input type="radio" name="longSongs" value="yes">yes</input></label>
|
||||
<label><input type="radio" name="longSongs" value="no">no</input></label>
|
||||
</label><br>
|
||||
<label>Allow only music:
|
||||
<label><input type="radio" name="onlyMusic" value="yes">yes</input></label>
|
||||
<label><input type="radio" name="onlyMusic" value="no">no</input></label>
|
||||
</label><br>
|
||||
<label>Paste playlist here: <input type="text" name="playlist"></label><br>
|
||||
<input type="button" value="Save Settings">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div class="footer small centered top anim bottom">© 2014 <a class="anim" href="//nixo.no">Nixo</a> & <a class="anim" href="//kasperrt.no">KasperRT</a> </div>
|
||||
</body>
|
||||
</html>
|
||||
124
php/change.php
Executable file
124
php/change.php
Executable file
@@ -0,0 +1,124 @@
|
||||
<?php
|
||||
|
||||
$guid=substr(base64_encode(crc32($_SERVER['HTTP_USER_AGENT'].$_SERVER['REMOTE_ADDR'].$_SERVER['HTTP_ACCEPT_LANGUAGE'])), 0, 8);
|
||||
|
||||
if(isset($_REQUEST['test'])){
|
||||
echo($guid);
|
||||
exit;
|
||||
}
|
||||
|
||||
//save or del
|
||||
$list = explode("/", htmlspecialchars(strtolower($_SERVER["REQUEST_URI"])));
|
||||
if($list[1]==""||!isset($list[1])||count($list)<=1)$list="videos";
|
||||
else $list=$list[1];
|
||||
$list="../lists/".$list.".json";
|
||||
|
||||
$f = @fopen($list,"x");
|
||||
if($f){ fwrite($f,"[[],[".time()."],[],[],[],[]]"); fclose($f); }
|
||||
$file = file_get_contents($list);
|
||||
$data = json_decode($file);
|
||||
$save = false;
|
||||
|
||||
if(isset($_REQUEST['thisUrl'])){
|
||||
$string = $_REQUEST['thisUrl'];
|
||||
$action = isset($_REQUEST['act']);
|
||||
|
||||
if($data[0][0] == $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]);
|
||||
}
|
||||
file_put_contents($list, json_encode($data));
|
||||
}
|
||||
if($action == "save" && !$save) //count views
|
||||
{
|
||||
$data[4][0] = $data[4][0] + 1;
|
||||
file_put_contents($list, json_encode($data));
|
||||
}
|
||||
echo $data[0][0];
|
||||
}
|
||||
else if(isset($_GET['v'])){ //add
|
||||
$video = htmlspecialchars($_GET['v']);
|
||||
$name = htmlspecialchars($_GET['n']);
|
||||
if(!in_array($video, $data[0]))
|
||||
{
|
||||
//array_push($data[0], $video);
|
||||
$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));
|
||||
print("added");
|
||||
}
|
||||
|
||||
}
|
||||
else if(isset($_GET['vote'])){ //add vote
|
||||
$vote=$_GET['vote'];
|
||||
$id=$_GET['id'];
|
||||
$i = array_search($id, $data[0]);
|
||||
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";
|
||||
}
|
||||
}
|
||||
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);
|
||||
$skips+=1;
|
||||
$data[5][0]=$skips;
|
||||
if($skips>=$viewers/2){
|
||||
nextSong();
|
||||
echo("skipped!");
|
||||
}
|
||||
file_put_contents($list, json_encode($data));
|
||||
}
|
||||
echo($skips."/".$viewers);
|
||||
|
||||
}
|
||||
else{ print($file); }
|
||||
|
||||
function nextSong(){
|
||||
global $data;
|
||||
array_push($data[0], $data[0][0]);
|
||||
array_shift($data[0]);
|
||||
|
||||
array_push($data[2], 0); //reset votes
|
||||
array_shift($data[2]);
|
||||
|
||||
array_push($data[3], $data[3][0]);
|
||||
array_shift($data[3]);
|
||||
|
||||
array_shift($data[4]);
|
||||
array_push($data[4], 1);
|
||||
|
||||
$data[5]=array();
|
||||
$data[1][0] = time();
|
||||
}
|
||||
?>
|
||||
30
php/convert_lists.php
Normal file
30
php/convert_lists.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
if(isset($_GET["pass"]) && $_GET["pass"]=="bæsj"){
|
||||
|
||||
include("change.php");
|
||||
|
||||
$dir = scandir('../lists');
|
||||
$channels = array();
|
||||
foreach($dir as $file){
|
||||
if(strpos($file, '.json') !== FALSE){
|
||||
$name='./lists/'.$file;
|
||||
$data = json_decode(file_get_contents($name));
|
||||
unlink($name);
|
||||
checkFile($name); //should create a new file with correct stuff, in change
|
||||
processList($data);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
echo("kek");
|
||||
}
|
||||
|
||||
function processList($list, $name){
|
||||
foreach($list as $item){
|
||||
//get id and title
|
||||
addSong($name, $id, $title); //in change
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
6
php/header.php
Normal file
6
php/header.php
Normal file
@@ -0,0 +1,6 @@
|
||||
<title>Zöff</title>
|
||||
<meta name="author" content="Nicolas 'Nixo' Almagro Tonne & Kasper 'KasperRT' Rynning-Tønnesen">
|
||||
<link rel="stylesheet" type="text/css" href="/static/style.css" title="Default" />
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<link rel="icon" type="image/png" href="/static/favicon.png"/>
|
||||
<link href='http://fonts.googleapis.com/css?family=Open+Sans:300' rel='stylesheet' type='text/css'>
|
||||
0
php/index.html
Normal file
0
php/index.html
Normal file
38
php/nochan.php
Executable file
38
php/nochan.php
Executable file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
if(isset($_GET['chan'])){
|
||||
header('Location: '.$_GET['chan']);
|
||||
}
|
||||
|
||||
$dir = scandir('./lists');
|
||||
$channels = array();
|
||||
$time = 60*60*24*7*1; //1 uke
|
||||
foreach($dir as $files){
|
||||
if(strpos($files, '.json') !== FALSE){
|
||||
if(time() - filemtime('./lists/'.$files) < $time){
|
||||
array_push($channels, ucfirst(str_replace(".json", "", $files)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<div class="bigchan nomargin">Zöff</div>
|
||||
<form name="ufo" action="" class="daform nomargin" id="base" method="get" onsubmit="null;" >
|
||||
<input list="searches" id="search" name="chan" type="text" class="search_input innbox" spellcheck="false" placeholder="Type Channel Name" autofocus/>
|
||||
<datalist id="searches">
|
||||
<?php foreach($channels as $channel){echo "<option value='".urldecode($channel)."'> ";} ?>
|
||||
</datalist>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
<center>
|
||||
<div class="channels" id="channels">Active Channels<br>
|
||||
<?php foreach($channels as $channel){echo "<a class='channel' href='/".$channel."'>".urldecode($channel)."</a>";} ?>
|
||||
</div>
|
||||
</center>
|
||||
</div>
|
||||
|
||||
<div class="footer small centered top anim bottom">© 2014 <a class="anim" href="//nixo.no">Nixo</a> & <a class="anim" href="//kasperrt.no">KasperRT</a> </div>
|
||||
</body>
|
||||
</html>
|
||||
13
php/timedifference.php
Executable file
13
php/timedifference.php
Executable file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
$list = explode("/", htmlspecialchars(strtolower($_SERVER["REQUEST_URI"])));
|
||||
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]);
|
||||
$returnArray = json_encode($returnArray);
|
||||
|
||||
echo $returnArray;
|
||||
?>
|
||||
8
php/videos.php
Executable file
8
php/videos.php
Executable file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
$list = htmlspecialchars($_REQUEST['list']);
|
||||
if(!isset($_REQUEST['list']))$list="videos";
|
||||
$filename = "../lists/".$list.'.json';
|
||||
if(!file_exists($filename)){ $f=fopen($filename, "a+"); fwrite($f,"[]"); fclose($f);}
|
||||
$file = file_get_contents($filename);
|
||||
print($file);
|
||||
?>
|
||||
Reference in New Issue
Block a user