diff --git a/public/.htaccess b/.htaccess similarity index 72% rename from public/.htaccess rename to .htaccess index e459386..a47598b 100644 --- a/public/.htaccess +++ b/.htaccess @@ -5,3 +5,8 @@ RewriteRule ^ index.php [QSA,L] # Disable index view Options -Indexes + + + Order allow,deny + Deny from all + diff --git a/Procfile b/Procfile index 48aab52..5e4d8ce 100644 --- a/Procfile +++ b/Procfile @@ -1 +1 @@ -web: vendor/bin/heroku-php-apache2 public/ +web: vendor/bin/heroku-php-nginx -C ./setup/nginx.conf diff --git a/README.md b/README.md index 05e3690..cd3eed1 100644 --- a/README.md +++ b/README.md @@ -31,16 +31,14 @@ Clone the repository and fetch the requiered external packages with: ```bash composer install ``` +Move the .env.example file to .env and modify it. Then you can run it using for example the PHP Development Server with: ```bash -php -S localhost:8080 -t public +php -S localhost:8080 ``` ## Configuration -### .env -Move the .env.example file to .env and modify it. - ### Cache engines Available cache engines: * redis: Writes response to Redis @@ -50,21 +48,7 @@ Available cache engines: You don't have to do anything more ### Nginx -Add the following to your config (you can modify the proxitok part if you have or not a subdir): -``` -location /proxitok { - return 302 $scheme://$host/proxitok/; -} - -location /proxitok/ { - try_files $uri $uri/ /proxitok/index.php?$query_string; -} - -location /proxitok/.env { - deny all; - return 404; -} -``` +You can get a config example on /setup/nginx.conf ## TODO * Add a NoJS version / Make the whole program without required JS diff --git a/app/Controllers/SettingsController.php b/app/Controllers/SettingsController.php index 6522a11..6710d94 100644 --- a/app/Controllers/SettingsController.php +++ b/app/Controllers/SettingsController.php @@ -11,19 +11,26 @@ class SettingsController { $latte->render(Misc::getView('settings'), new SettingsTemplate); } + static private function redirect() { + $url = Misc::url('/settings'); + header("Location: {$url}"); + } + static public function proxy() { if (in_array(Cookies::PROXY, $_POST)) { foreach (Cookies::PROXY as $proxy_element) { Cookies::set($proxy_element, $_POST[$proxy_element]); } } - $url = Misc::url('/settings'); - header("Location: {$url}"); + self::redirect(); } static public function api() { - $_POST['legacy'] ?? Cookies::set('api-legacy', '1'); - $url = Misc::url('/settings'); - header("Location: {$url}"); + $legacy = 'off'; + if (isset($_POST['api-legacy'])) { + $legacy = 'on'; + } + Cookies::set('api-legacy', $legacy); + self::redirect(); } } diff --git a/app/Helpers/Misc.php b/app/Helpers/Misc.php index dcf9119..d678ca8 100644 --- a/app/Helpers/Misc.php +++ b/app/Helpers/Misc.php @@ -78,8 +78,7 @@ class Misc { } // Legacy mode - $_COOKIE['enable_legacy'] ?? $legacy = true; // User level - $legacy = self::env('FORCE_LEGACY', false); // Instance level (has priority over user) + $legacy = self::env('FORCE_LEGACY', false) || isset($_COOKIE['api-legacy']) && $_COOKIE['api-legacy'] === 'on'; return $legacy === false ? new \TikScraper\Api($options, $cacheEngine) : new \TikScraper\Legacy($options, $cacheEngine); } diff --git a/components/settings/api.latte b/components/settings/api.latte index feeba44..fe9cefa 100644 --- a/components/settings/api.latte +++ b/components/settings/api.latte @@ -1,7 +1,9 @@
diff --git a/public/index.php b/index.php similarity index 72% rename from public/index.php rename to index.php index b29ed8b..d0c8756 100644 --- a/public/index.php +++ b/index.php @@ -1,5 +1,5 @@ safeLoad(); $router = new Bramus\Router\Router(); $router->setNamespace('\App\Controllers'); -require __DIR__ . '/../routes.php'; +require __DIR__ . '/routes.php'; $router->run(); diff --git a/public/scripts/feed.js b/scripts/feed.js similarity index 100% rename from public/scripts/feed.js rename to scripts/feed.js diff --git a/public/scripts/navbar.js b/scripts/navbar.js similarity index 100% rename from public/scripts/navbar.js rename to scripts/navbar.js diff --git a/scss/package.json b/scss/package.json index 1f31105..f15dfa8 100644 --- a/scss/package.json +++ b/scss/package.json @@ -2,8 +2,8 @@ "name": "proxitok-scss", "private": true, "scripts": { - "bulma": "sass --style=compressed bulma.scss ../public/styles/vendor/bulma.min.css", - "fa": "sass --style=compressed fontawesome.scss ../public/styles/vendor/fontawesome.min.css" + "bulma": "sass --style=compressed bulma.scss ./styles/vendor/bulma.min.css", + "fa": "sass --style=compressed fontawesome.scss ./styles/vendor/fontawesome.min.css" }, "dependencies": { "@fortawesome/fontawesome-free": "^6.0.0", diff --git a/setup/nginx.conf b/setup/nginx.conf new file mode 100644 index 0000000..8096791 --- /dev/null +++ b/setup/nginx.conf @@ -0,0 +1,8 @@ +location / { + try_files $uri $uri/ /index.php?$query_string; +} + +location /.env { + deny all; + return 404; +} diff --git a/public/styles/feed.css b/styles/feed.css similarity index 100% rename from public/styles/feed.css rename to styles/feed.css diff --git a/public/styles/vendor/bulma.min.css b/styles/vendor/bulma.min.css similarity index 100% rename from public/styles/vendor/bulma.min.css rename to styles/vendor/bulma.min.css diff --git a/public/styles/vendor/bulma.min.css.map b/styles/vendor/bulma.min.css.map similarity index 100% rename from public/styles/vendor/bulma.min.css.map rename to styles/vendor/bulma.min.css.map diff --git a/views/tag.latte b/views/tag.latte index fc39f04..0ce9ce3 100644 --- a/views/tag.latte +++ b/views/tag.latte @@ -4,7 +4,7 @@

{$feed->info->detail->title}

{$feed->info->detail->desc}

Videos: {number($feed->info->stats->videoCount)} / Views: {number($feed->info->stats->viewCount)}

- RSS + RSS {/block} {block content}