diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..8203a102 --- /dev/null +++ b/.gitignore @@ -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 \ No newline at end of file diff --git a/.htaccess b/.htaccess index 952ded2a..4d53c4aa 100755 --- a/.htaccess +++ b/.htaccess @@ -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] \ No newline at end of file +RewriteRule ^(.*)$ index.php?q=$1 [L,QSA] + +# Disallow directory listing +Options -Indexes \ No newline at end of file diff --git a/README.md b/README.md index b97cef91..b8c7d467 100755 --- a/README.md +++ b/README.md @@ -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 \ No newline at end of file diff --git a/base.php b/base.php new file mode 100755 index 00000000..82727f90 --- /dev/null +++ b/base.php @@ -0,0 +1,9 @@ + - - - - -
-
- - Zöff -
- -
-
-
+ -
- - Settings - Skip -
-
-
-
+// Require the autoloader +require 'base.php'; +require ZOFF_BASE_PATH . '/vendor/autoload.php'; -
-
-
-
-
- +// New instance of smarty +$template = new Smarty(); - - - - - - - - - +// 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 .= '