Merge pull request #21 from OptimusCrime/more-structure

More structure
This commit is contained in:
Nicolas
2014-10-17 13:59:07 +02:00
28 changed files with 226 additions and 52 deletions

11
.gitignore vendored Normal file
View File

@@ -0,0 +1,11 @@
# Ignore .htaccess (copy ht.access and create your own)
.htaccess
# Ignoring composer.phar (because we don't want to push it to Github)
composer.phar
# Ignoring composer.lock (just because)
composer.lock
# Ignoring vendor dir (because files are installed using composer)
vendor

View File

@@ -1,12 +1,11 @@
Options +FollowSymLinks
RewriteEngine on
# Mod rewrite
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
RewriteCond %{REQUEST_URI} !(/$|\.)
RewriteRule (.*) %{REQUEST_URI}/ [R=301,L]
# Route all requests to index.php unless real file or folder
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule /(.*)$ /$1 [L]
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
# Disallow directory listing
Options -Indexes

View File

@@ -8,3 +8,28 @@ Zöff is built around the youtube search and video API, and enables the creation
The project is currently under development and runs on http://zoff.no
Install notes
=============
Composer
--------
This projects uses composer. Install composer by typing:
curl -sS https://getcomposer.org/installer | php
After that, fetch project dependencies:
php composer.phar update
.htaccess
---------
We also use .htaccess to prettify the urls. To keep it easy to develop elsewhere, we have a stock ht.access file. Copy this and call it .htaccess. If you develop in a directory that is not the base in your webserver change
RewriteBase /
To
RewriteBase /your-sub-directory

9
base.php Executable file
View File

@@ -0,0 +1,9 @@
<?php
/*
*
* File: base.php
* Description: Keeps track of absolute path to files, to ease development
*
*/
define('ZOFF_BASE_PATH', dirname(__FILE__));

5
composer.json Executable file
View File

@@ -0,0 +1,5 @@
{
"require": {
"smarty/smarty": "3.1.19"
}
}

View File

Before

Width:  |  Height:  |  Size: 34 KiB

After

Width:  |  Height:  |  Size: 34 KiB

11
ht.access Executable file
View File

@@ -0,0 +1,11 @@
# Mod rewrite
RewriteEngine On
RewriteBase /
# Route all requests to index.php unless real file or folder
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
# Disallow directory listing
Options -Indexes

110
index.php
View File

@@ -1,46 +1,70 @@
<html>
<head>
<?php include("php/header.php"); ?>
</head>
<body>
<div class="top vcent centered">
<div id="change" class="small">
<?php
if(isset($_GET['chan'])) header('Location: '.$_GET['chan']);
$list = explode("/", htmlspecialchars(strtolower($_SERVER["REQUEST_URI"])));
if($list[1]==""||!isset($list[1])||count($list)<=1){$list="";include('php/nochan.php');die();}
else $list=$list[1];
?>
<a id="toptitle" href="/">Zöff</a>
<div id="chan" class="chan" title="Show big URL" onclick="show()"><?php echo(ucfirst($list));?></div>
<input id="search" name="v" type="text" class="search_input innbox" spellcheck="false" placeholder="Search" onsubmit="null;" autocomplete="off"/>
<div id="results"></div>
<div class="main">
<div id="player" class="ytplayer"></div>
<?php
/*
*
* File: index.php
* Description: Main controller
*
*/
<div class="playlist" >
<div id="buttons" class="result">
<!--<a href="/php/admin.php?list=<?php echo $list; ?>" title="Channel settings" ><img src="/static/settings2.png" class="skip middle" alt="Settings"/></a>-->
<img src="/static/settings2.png" class="skip middle" alt="Settings" title="Settings" onclick="admin();"/>
<img src="/static/skip.png" class="skip" alt="Skip" title="Skip" onclick="skip();">
</div>
<div id="adminPanel"></div>
<div id="playlist">
<div id="wrapper">
// Require the autoloader
require 'base.php';
require ZOFF_BASE_PATH . '/vendor/autoload.php';
</div>
</div>
</div>
</div>
</div>
<div class="footer small centered top anim">&copy; 2014 <a class="anim" href="//nixo.no">Nixo</a> &amp; <a class="anim" href="//kasperrt.no">KasperRT </a>&amp; David </div>
// New instance of smarty
$template = new Smarty();
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript" src="/js/iscroll.js"></script>
<script type="text/javascript" src="/js/list.js"></script>
<script type="text/javascript" src="/js/youtube.js"></script>
<script type="text/javascript" src="/js/search.js"></script>
<script type="text/javascript" src="/js/admin.js"></script>
<script type="text/javascript" src="/js/visualize.js"></script>
</body>
</html>
// Set smarty options
$template->left_delimiter = '[[+';
$template->right_delimiter = ']]';
// Check if we are in a room or not
if (!isset($_GET['q'])) {
// Not in a room, fetch active rooms
$dir = scandir(ZOFF_BASE_PATH . '/lists');
$channels = [];
$time = 60 * 60 * 24 * 3;
foreach ($dir as $files) {
if (strpos($files, '.json') !== false) {
if (time() - filemtime(ZOFF_BASE_PATH . '/lists/' . $files) < $time) {
$channels[] = ucfirst(str_replace('.json', '', $files));
}
}
}
// Build string for search
$search_string = '';
foreach ($channels as $channel) {
$search_string .= '<option value="' . htmlspecialchars(urldecode($channel)) . '">';
}
// Build string for displaying active rooms
$display_string = '';
foreach ($channels as $channel) {
$display_string .= '<a class="channel" href="' . htmlspecialchars($channel) . '">' .
htmlspecialchars(urldecode($channel)) . '</a>';
}
// Assign to Smarty
$template->assign('SEARCH_STRING', $search_string);
$template->assign('DISPLAY_STRING', $display_string);
// Display template
$template->display('index.tpl');
}
else {
// In a room, check if it is a valid room or not
if (file_exists(ZOFF_BASE_PATH . '/lists/' . strtolower($_GET['q']) . '.json')) {
// Assign channel name
$template->assign('CHANNEL_NAME', htmlspecialchars(urldecode($_GET['q'])));
}
else {
// This is not a channel
header("Location: index.php");
exit;
}
// Display the template
$template->display('chan.tpl');
}

5
lists/.gitignore vendored Executable file
View File

@@ -0,0 +1,5 @@
# Ignore all
*
# Not this file
!.gitignore

View File

View File

@@ -1 +0,0 @@
{"nowPlaying":{"87JabMupbB8":{"id":"87JabMupbB8","title":"Bodybangers Inc. - Kompani Linge 2012","votes":0,"added":1412951860,"guids":[]}},"songs":{"CduA0TULnow":{"id":"CduA0TULnow","title":"Britney Spears - Oops!...I Did It Again","votes":0,"added":1412951860,"guids":[]},"Eo-KmOd3i7s":{"id":"Eo-KmOd3i7s","title":"\\'N Sync - Bye Bye Bye","votes":0,"added":1412951860,"guids":[]},"EpbjEttizy8":{"id":"EpbjEttizy8","title":"David Guetta - Lovers On The Sun (Official Audio) ft Sam Martin","votes":0,"added":1412951860,"guids":[]},"GMoud3dub6U":{"id":"GMoud3dub6U","title":"\u00c5ge Aleksandersen - Levva Livet","votes":0,"added":1412951860,"guids":[]},"J_DV9b0x7v4":{"id":"J_DV9b0x7v4","title":"CaramellDansen (Full Version + Lyrics)","votes":0,"added":1412951860,"guids":[]},"LOZuxwVk7TU":{"id":"LOZuxwVk7TU","title":"Britney Spears - Toxic","votes":0,"added":1412951860,"guids":[]},"MXXRHpVed3M":{"id":"MXXRHpVed3M","title":"Vengaboys - We\\'re Going to Ibiza!","votes":0,"added":1412951860,"guids":[]},"O1OTWCd40bc":{"id":"O1OTWCd40bc","title":"The Weeknd - Wicked Games (Explicit)","votes":0,"added":1412951860,"guids":[]},"Z7YrFLIyYIw":{"id":"Z7YrFLIyYIw","title":"Tuuli - Do It Like A Dru [[WoW Parody]]","votes":0,"added":1412951860,"guids":[]},"ZKuOB1HGWMY":{"id":"ZKuOB1HGWMY","title":"Robert er du neger?","votes":0,"added":1412951860,"guids":[]},"ZyhrYis509A":{"id":"ZyhrYis509A","title":"Aqua - Barbie Girl","votes":0,"added":1412951860,"guids":[]},"_ovdm2yX4MA":{"id":"_ovdm2yX4MA","title":"Avicii - Levels","votes":0,"added":1412951860,"guids":[]},"aZg2pEokcFw":{"id":"aZg2pEokcFw","title":"H\u00f8vlerivisa","votes":0,"added":1412951860,"guids":[]},"afOH2SGDiK0":{"id":"afOH2SGDiK0","title":"dde vi ska f\u00e6st","votes":0,"added":1412951860,"guids":[]},"bESGLojNYSo":{"id":"bESGLojNYSo","title":"Lady Gaga - Poker Face","votes":0,"added":1412951860,"guids":[]},"bLLMPnPK0fU":{"id":"bLLMPnPK0fU","title":"D.D.E. - Bondekn\u00f8l","votes":0,"added":1412951860,"guids":[]},"byp94CCWKSI":{"id":"byp94CCWKSI","title":"Jason Derulo - \\&quot;The Other Side\\&quot; (Official HD Music Video)","votes":0,"added":1412951860,"guids":[]},"cN-ZjkDBaX8":{"id":"cN-ZjkDBaX8","title":"\u00c5ge Aleksandersen - Fire Pils og en Pizza - Rockefeller, 03.2009. HQ.","votes":0,"added":1412951860,"guids":[]},"cNvjKkXFBvU":{"id":"cNvjKkXFBvU","title":"WEKEED - Wild Child","votes":0,"added":1412951860,"guids":[]},"cjEwjDvh_2c":{"id":"cjEwjDvh_2c","title":"Pelle Politibil Intro Sang","votes":0,"added":1412951860,"guids":[]},"fIMz0nTp2sA":{"id":"fIMz0nTp2sA","title":"E-Type ft. Na Na - Life","votes":0,"added":1412951860,"guids":[]},"iMP4BwvJSwo":{"id":"iMP4BwvJSwo","title":"LMFAO - Sexy And I Know It (Mord Fustang Remix)","votes":0,"added":1412951860,"guids":[]},"kHue-HaXXzg":{"id":"kHue-HaXXzg","title":"Demi Lovato - Let It Go (from \\&quot;Frozen\\&quot;) [Official]","votes":0,"added":1412951860,"guids":[]},"kTHNpusq654":{"id":"kTHNpusq654","title":"Katy Perry - Hot N Cold","votes":0,"added":1412951860,"guids":[]},"nI_MVldpxDQ":{"id":"nI_MVldpxDQ","title":"Daddy DJ","votes":0,"added":1412951860,"guids":[]},"qQ31INpjXX0":{"id":"qQ31INpjXX0","title":"Albatraoz - Albatraoz","votes":0,"added":1412951860,"guids":[]},"smwj7ISnwXM":{"id":"smwj7ISnwXM","title":"tribalistas ja sei namorar","votes":0,"added":1412951860,"guids":[]},"tenz01ic1D8":{"id":"tenz01ic1D8","title":"Avicii - Levels","votes":0,"added":1412951860,"guids":[]},"w15oWDh02K4":{"id":"w15oWDh02K4","title":"Gigi D\\'Agostino - L\\'Amour Toujours ( Official Video )","votes":0,"added":1412951860,"guids":[]},"-1jPUB7gRyg":{"id":"-1jPUB7gRyg","title":"Aqua - Doctor Jones","votes":0,"added":1412952071,"guids":[]},"llyiQ4I-mcQ":{"id":"llyiQ4I-mcQ","title":"Vengaboys - Boom, Boom, Boom, Boom!!","votes":0,"added":1412952280,"guids":[]},"-N6O0xI3A2o":{"id":"-N6O0xI3A2o","title":"Guy Sebastian - Like a Drum","votes":0,"added":1412952356,"guids":[]},"2CGF_Z3yZAo":{"id":"2CGF_Z3yZAo","title":"Jason Derulo - Don\\'t Wanna Go Home (Official Video)","votes":0,"added":1412955658,"guids":[]},"4fndeDfaWCg":{"id":"4fndeDfaWCg","title":"Backstreet Boys - I Want It That Way","votes":0,"added":1412971020,"guids":[]},"7x3CCKaOlfU":{"id":"7x3CCKaOlfU","title":"Peaches - Rosa Helikopter","votes":0,"added":1412971324,"guids":[]}},"conf":{"startTime":1412971324,"views":1,"skips":[]}}

1
lists/zoff.json Normal file
View File

@@ -0,0 +1 @@
{"nowPlaying":{"":{"id":null,"title":null,"votes":0,"added":null,"guids":null}},"songs":[],"conf":{"startTime":1413481661,"views":1,"skips":[]}}

View File

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

View File

Before

Width:  |  Height:  |  Size: 36 KiB

After

Width:  |  Height:  |  Size: 36 KiB

32
templates/chan.tpl Executable file
View File

@@ -0,0 +1,32 @@
<html>
<head>
[[+include file="header.tpl"]]
</head>
<body>
<div class="top vcent centered">
<div id="change" class="small">
<a id="toptitle" href="../">Zöff</a>
<div id="chan" class="chan" title="Show big URL" onclick="show()">
[[+$CHANNEL_NAME]]
</div>
<input id="search" name="v" type="text" class="search_input innbox" spellcheck="false" placeholder="Search" onsubmit="null;" autocomplete="off" />
<div id="results"></div>
<div class="main">
<div id="player" class="ytplayer"></div>
<div class="playlist" >
<div id="buttons" class="result">
<!--<a href="/php/admin.php?list=<?php echo $list; ?>" title="Channel settings" ><img src="static/settings2.png" class="skip middle" alt="Settings"/></a>-->
<img src="static/css/gfx/settings.png" class="skip middle" alt="Settings" title="Settings" onclick="admin();"/>
<img src="static/css/gfx/skip.png" class="skip" alt="Skip" title="Skip" onclick="skip();">
</div>
<div id="adminPanel"></div>
<div id="playlist">
<div id="wrapper"></div>
</div>
</div>
</div>
</div>
</div>
[[+include file="footer.tpl"]]
</body>
</html>

10
templates/footer.tpl Executable file
View File

@@ -0,0 +1,10 @@
<div class="footer small centered top anim bottom">
&copy; 2014 <a class="anim" href="//nixo.no">Nixo</a> &amp; <a class="anim" href="//kasperrt.no">KasperRT </a>&amp; David
</div>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript" src="static/js/iscroll.js"></script>
<script type="text/javascript" src="static/js/list.js"></script>
<script type="text/javascript" src="static/js/youtube.js"></script>
<script type="text/javascript" src="static/js/search.js"></script>
<script type="text/javascript" src="static/js/admin.js"></script>
<script type="text/javascript" src="static/js/visualize.js"></script>

13
templates/header.tpl Executable file
View File

@@ -0,0 +1,13 @@
<title>Zöff</title>
<<<<<<< HEAD
<meta name="author" content="Nicolas 'Nixo' Almagro Tonne &amp; 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"/>
=======
<meta name="author" content="Nicolas 'Nixo' Almagro Tonne &amp; Kasper 'KasperRT' Rynning-Tønnesen" />
<link rel="stylesheet" type="text/css" href="static/css/style.css" title="Default" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="icon" type="image/png" href="favicon.png"/>
>>>>>>> Moved some files around
<link href='http://fonts.googleapis.com/css?family=Open+Sans:300' rel='stylesheet' type='text/css'>

25
templates/index.tpl Executable file
View File

@@ -0,0 +1,25 @@
<html>
<head>
[[+include file="header.tpl]]
</head>
<body>
<div class="top vcent centered">
<div id="change" class="small">
<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" maxlength="15" placeholder="Type Channel Name" autofocus/>
<datalist id="searches">
[[+$SEARCH_STRING]]
</datalist>
</form>
</div>
<center>
<div class="channels" id="channels">Active Channels<br>
[[+$DISPLAY_STRING]]
</div>
</center>
</div>
[[+include file="footer.tpl"]]
</body>
</html>

5
templates_c/.gitignore vendored Executable file
View File

@@ -0,0 +1,5 @@
# Ignore all
*
# Not gitignore
!.gitignore