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 @@