diff --git a/.editorconfig b/.editorconfig index 160da6b..60cddd6 100644 --- a/.editorconfig +++ b/.editorconfig @@ -31,6 +31,10 @@ indent_size = 2 indent_style = space indent_size = 4 +[**.blade.php] +indent_style = tab +indent_size = 2 + [**.html] indent_style = tab indent_size = 2 diff --git a/composer.json b/composer.json index 55fefb4..b334abf 100644 --- a/composer.json +++ b/composer.json @@ -1,10 +1,13 @@ { "name": "pablouser1/tiktok-viewer", + "description": "An alternative frontend for TikTok", + "version": "1.0.0", + "license": "AGPL-3.0-or-later", "require": { - "leafs/leaf": "dev-v3.x-dev", - "leafs/blade": "^1.2", + "php": "^8.0.0", + "ext-curl": "*", "ssovit/tiktok-api": "^2.0", - "vlucas/phpdotenv": "^5.4", - "php": "^8.0.0" + "bramus/router": "^1.6", + "jenssegers/blade": "^1.4" } } diff --git a/composer.lock b/composer.lock index d2d2c87..af3ed93 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,59 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "24a1a42f9512ff089db3e367de67ade4", + "content-hash": "a272158b7b1fb157a2096739db8a1574", "packages": [ + { + "name": "bramus/router", + "version": "1.6.1", + "source": { + "type": "git", + "url": "https://github.com/bramus/router.git", + "reference": "55657b76da8a0a509250fb55b9dd24e1aa237eba" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/bramus/router/zipball/55657b76da8a0a509250fb55b9dd24e1aa237eba", + "reference": "55657b76da8a0a509250fb55b9dd24e1aa237eba", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "~2.14", + "phpunit/php-code-coverage": "~2.0", + "phpunit/phpunit": "~4.8" + }, + "type": "library", + "autoload": { + "psr-0": { + "Bramus": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Bram(us) Van Damme", + "email": "bramus@bram.us", + "homepage": "http://www.bram.us" + } + ], + "description": "A lightweight and simple object oriented PHP Router", + "homepage": "https://github.com/bramus/router", + "keywords": [ + "router", + "routing" + ], + "support": { + "issues": "https://github.com/bramus/router/issues", + "source": "https://github.com/bramus/router/tree/1.6.1" + }, + "time": "2021-11-18T19:24:07+00:00" + }, { "name": "doctrine/inflector", "version": "2.0.4", @@ -97,68 +148,6 @@ ], "time": "2021-10-22T20:16:43+00:00" }, - { - "name": "graham-campbell/result-type", - "version": "v1.0.4", - "source": { - "type": "git", - "url": "https://github.com/GrahamCampbell/Result-Type.git", - "reference": "0690bde05318336c7221785f2a932467f98b64ca" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/GrahamCampbell/Result-Type/zipball/0690bde05318336c7221785f2a932467f98b64ca", - "reference": "0690bde05318336c7221785f2a932467f98b64ca", - "shasum": "" - }, - "require": { - "php": "^7.0 || ^8.0", - "phpoption/phpoption": "^1.8" - }, - "require-dev": { - "phpunit/phpunit": "^6.5.14 || ^7.5.20 || ^8.5.19 || ^9.5.8" - }, - "type": "library", - "autoload": { - "psr-4": { - "GrahamCampbell\\ResultType\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Graham Campbell", - "email": "hello@gjcampbell.co.uk", - "homepage": "https://github.com/GrahamCampbell" - } - ], - "description": "An Implementation Of The Result Type", - "keywords": [ - "Graham Campbell", - "GrahamCampbell", - "Result Type", - "Result-Type", - "result" - ], - "support": { - "issues": "https://github.com/GrahamCampbell/Result-Type/issues", - "source": "https://github.com/GrahamCampbell/Result-Type/tree/v1.0.4" - }, - "funding": [ - { - "url": "https://github.com/GrahamCampbell", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/graham-campbell/result-type", - "type": "tidelift" - } - ], - "time": "2021-11-21T21:41:47+00:00" - }, { "name": "illuminate/bus", "version": "v8.77.1", @@ -699,73 +688,17 @@ "time": "2021-12-16T19:23:48+00:00" }, { - "name": "leafs/anchor", - "version": "v1.1.1", + "name": "jenssegers/blade", + "version": "v1.4.0", "source": { "type": "git", - "url": "https://github.com/leafsphp/anchor.git", - "reference": "30d6a5eec7f36baf1ddd6b15ed08ebbb0505cc65" + "url": "https://github.com/jenssegers/blade.git", + "reference": "22a3700e9fc469c19dd1c5e5bd1b9138195e421f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/leafsphp/anchor/zipball/30d6a5eec7f36baf1ddd6b15ed08ebbb0505cc65", - "reference": "30d6a5eec7f36baf1ddd6b15ed08ebbb0505cc65", - "shasum": "" - }, - "type": "library", - "autoload": { - "psr-4": { - "Leaf\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Michael Darko", - "email": "mickdd22@gmail.com", - "homepage": "https://mychi.netlify.app", - "role": "Developer" - } - ], - "description": "Leaf PHP util module", - "homepage": "https://leafphp.netlify.app/#/", - "keywords": [ - "framework", - "leaf", - "php", - "util" - ], - "support": { - "issues": "https://github.com/leafsphp/anchor/issues", - "source": "https://github.com/leafsphp/anchor/tree/v1.1.1" - }, - "funding": [ - { - "url": "https://github.com/leafsphp", - "type": "github" - }, - { - "url": "https://opencollective.com/leaf", - "type": "open_collective" - } - ], - "time": "2021-12-16T09:05:13+00:00" - }, - { - "name": "leafs/blade", - "version": "v1.2.4", - "source": { - "type": "git", - "url": "https://github.com/leafsphp/blade.git", - "reference": "4daec543d0aae91de03369cb90c742e95cb111ac" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/leafsphp/blade/zipball/4daec543d0aae91de03369cb90c742e95cb111ac", - "reference": "4daec543d0aae91de03369cb90c742e95cb111ac", + "url": "https://api.github.com/repos/jenssegers/blade/zipball/22a3700e9fc469c19dd1c5e5bd1b9138195e421f", + "reference": "22a3700e9fc469c19dd1c5e5bd1b9138195e421f", "shasum": "" }, "require": { @@ -779,7 +712,7 @@ "type": "library", "autoload": { "psr-4": { - "Leaf\\": "src/" + "Jenssegers\\Blade\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", @@ -788,212 +721,33 @@ ], "authors": [ { - "name": "Michael Darko", - "email": "mickdd22@gmail.com", - "homepage": "https://mychi.netlify.com", - "role": "Developer" + "name": "Jens Segers", + "homepage": "https://jenssegers.com" } ], - "description": "Leaf PHP Framework adaptation of jenssegers/blade package", + "description": "The standalone version of Laravel's Blade templating engine for use outside of Laravel.", "keywords": [ "blade", "laravel", - "leaf", - "leafMVC", "render", "template", "view" ], "support": { - "source": "https://github.com/leafsphp/blade/tree/v1.2.4" - }, - "time": "2021-01-20T17:21:52+00:00" - }, - { - "name": "leafs/http", - "version": "v1.1", - "source": { - "type": "git", - "url": "https://github.com/leafsphp/http.git", - "reference": "c2383c897ef46f9eebf5a3e6e9f9fe148222ca01" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/leafsphp/http/zipball/c2383c897ef46f9eebf5a3e6e9f9fe148222ca01", - "reference": "c2383c897ef46f9eebf5a3e6e9f9fe148222ca01", - "shasum": "" - }, - "require": { - "leafs/anchor": "^1.0" - }, - "type": "library", - "autoload": { - "psr-4": { - "Leaf\\Http\\": "src" - }, - "files": [ - "src/functions.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Michael Darko", - "email": "mickdd22@gmail.com", - "homepage": "https://mychi.netlify.app", - "role": "Developer" - } - ], - "description": "Leaf PHP HTTP module.", - "homepage": "https://leafphp.netlify.app/#/", - "keywords": [ - "framework", - "headers", - "http", - "leaf", - "php", - "request", - "response" - ], - "support": { - "issues": "https://github.com/leafsphp/http/issues", - "source": "https://github.com/leafsphp/http/tree/v1.1" + "issues": "https://github.com/jenssegers/blade/issues", + "source": "https://github.com/jenssegers/blade/tree/v1.4.0" }, "funding": [ { - "url": "https://opencollective.com/leaf", - "type": "open_collective" - } - ], - "time": "2021-11-09T08:14:22+00:00" - }, - { - "name": "leafs/leaf", - "version": "dev-v3.x-dev", - "source": { - "type": "git", - "url": "https://github.com/leafsphp/leaf.git", - "reference": "57507c739106deb29c18da7f1e8e874b43dc1c7a" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/leafsphp/leaf/zipball/57507c739106deb29c18da7f1e8e874b43dc1c7a", - "reference": "57507c739106deb29c18da7f1e8e874b43dc1c7a", - "shasum": "" - }, - "require": { - "leafs/anchor": "^1.1", - "leafs/http": "^1.1", - "leafs/router": "^0.1.4" - }, - "require-dev": { - "pestphp/pest": "^1.21" - }, - "type": "library", - "autoload": { - "psr-4": { - "Leaf\\": "src" - }, - "files": [ - "src/functions.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Michael Darko", - "email": "mickdd22@gmail.com", - "homepage": "https://mychi.netlify.app", - "role": "Developer" - } - ], - "description": "Simple, performant and powerful PHP micro-framework for rapid web app & API development", - "homepage": "https://leafphp.dev", - "keywords": [ - "framework", - "leaf", - "microframework", - "php", - "rest", - "router" - ], - "support": { - "issues": "https://github.com/leafsphp/leaf/issues", - "source": "https://github.com/leafsphp/leaf/tree/v3.x-dev" - }, - "funding": [ - { - "url": "https://github.com/leafsphp", + "url": "https://github.com/jenssegers", "type": "github" }, { - "url": "https://opencollective.com/leaf", + "url": "https://opencollective.com/jenssegers-blade", "type": "open_collective" } ], - "time": "2021-12-31T12:54:44+00:00" - }, - { - "name": "leafs/router", - "version": "v0.1.4", - "source": { - "type": "git", - "url": "https://github.com/leafsphp/router.git", - "reference": "a8fcc8bdf5defd00ac73d2f26aa7aa9699af9190" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/leafsphp/router/zipball/a8fcc8bdf5defd00ac73d2f26aa7aa9699af9190", - "reference": "a8fcc8bdf5defd00ac73d2f26aa7aa9699af9190", - "shasum": "" - }, - "require": { - "leafs/http": "^1.0" - }, - "type": "library", - "autoload": { - "psr-4": { - "Leaf\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Michael Darko", - "email": "mickdd22@gmail.com", - "homepage": "https://mychi.netlify.app", - "role": "Developer" - } - ], - "description": "Leaf router module for Leaf PHP.", - "homepage": "https://leafphp.netlify.app/#/modules/router", - "keywords": [ - "framework", - "leaf", - "php", - "rest", - "router" - ], - "support": { - "issues": "https://github.com/leafsphp/router/issues", - "source": "https://github.com/leafsphp/router/tree/v0.1.4" - }, - "funding": [ - { - "url": "https://opencollective.com/leaf", - "type": "open_collective" - } - ], - "time": "2021-11-22T09:27:33+00:00" + "time": "2020-09-17T08:25:26+00:00" }, { "name": "nesbot/carbon", @@ -1091,77 +845,6 @@ ], "time": "2021-12-03T14:59:52+00:00" }, - { - "name": "phpoption/phpoption", - "version": "1.8.1", - "source": { - "type": "git", - "url": "https://github.com/schmittjoh/php-option.git", - "reference": "eab7a0df01fe2344d172bff4cd6dbd3f8b84ad15" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/schmittjoh/php-option/zipball/eab7a0df01fe2344d172bff4cd6dbd3f8b84ad15", - "reference": "eab7a0df01fe2344d172bff4cd6dbd3f8b84ad15", - "shasum": "" - }, - "require": { - "php": "^7.0 || ^8.0" - }, - "require-dev": { - "bamarni/composer-bin-plugin": "^1.4.1", - "phpunit/phpunit": "^6.5.14 || ^7.5.20 || ^8.5.19 || ^9.5.8" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.8-dev" - } - }, - "autoload": { - "psr-4": { - "PhpOption\\": "src/PhpOption/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "Apache-2.0" - ], - "authors": [ - { - "name": "Johannes M. Schmitt", - "email": "schmittjoh@gmail.com", - "homepage": "https://github.com/schmittjoh" - }, - { - "name": "Graham Campbell", - "email": "hello@gjcampbell.co.uk", - "homepage": "https://github.com/GrahamCampbell" - } - ], - "description": "Option Type for PHP", - "keywords": [ - "language", - "option", - "php", - "type" - ], - "support": { - "issues": "https://github.com/schmittjoh/php-option/issues", - "source": "https://github.com/schmittjoh/php-option/tree/1.8.1" - }, - "funding": [ - { - "url": "https://github.com/GrahamCampbell", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/phpoption/phpoption", - "type": "tidelift" - } - ], - "time": "2021-12-04T23:24:31+00:00" - }, { "name": "psr/container", "version": "1.1.2", @@ -1437,85 +1120,6 @@ ], "time": "2021-12-15T11:06:13+00:00" }, - { - "name": "symfony/polyfill-ctype", - "version": "v1.23.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "46cd95797e9df938fdd2b03693b5fca5e64b01ce" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/46cd95797e9df938fdd2b03693b5fca5e64b01ce", - "reference": "46cd95797e9df938fdd2b03693b5fca5e64b01ce", - "shasum": "" - }, - "require": { - "php": ">=7.1" - }, - "suggest": { - "ext-ctype": "For best performance" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "1.23-dev" - }, - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Ctype\\": "" - }, - "files": [ - "bootstrap.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Gert de Pagter", - "email": "BackEndTea@gmail.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill for ctype functions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "ctype", - "polyfill", - "portable" - ], - "support": { - "source": "https://github.com/symfony/polyfill-ctype/tree/v1.23.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2021-02-19T12:13:01+00:00" - }, { "name": "symfony/polyfill-mbstring", "version": "v1.23.1", @@ -1852,86 +1456,6 @@ ], "time": "2021-09-07T12:43:40+00:00" }, - { - "name": "vlucas/phpdotenv", - "version": "v5.4.1", - "source": { - "type": "git", - "url": "https://github.com/vlucas/phpdotenv.git", - "reference": "264dce589e7ce37a7ba99cb901eed8249fbec92f" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/vlucas/phpdotenv/zipball/264dce589e7ce37a7ba99cb901eed8249fbec92f", - "reference": "264dce589e7ce37a7ba99cb901eed8249fbec92f", - "shasum": "" - }, - "require": { - "ext-pcre": "*", - "graham-campbell/result-type": "^1.0.2", - "php": "^7.1.3 || ^8.0", - "phpoption/phpoption": "^1.8", - "symfony/polyfill-ctype": "^1.23", - "symfony/polyfill-mbstring": "^1.23.1", - "symfony/polyfill-php80": "^1.23.1" - }, - "require-dev": { - "bamarni/composer-bin-plugin": "^1.4.1", - "ext-filter": "*", - "phpunit/phpunit": "^7.5.20 || ^8.5.21 || ^9.5.10" - }, - "suggest": { - "ext-filter": "Required to use the boolean validator." - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "5.4-dev" - } - }, - "autoload": { - "psr-4": { - "Dotenv\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Graham Campbell", - "email": "hello@gjcampbell.co.uk", - "homepage": "https://github.com/GrahamCampbell" - }, - { - "name": "Vance Lucas", - "email": "vance@vancelucas.com", - "homepage": "https://github.com/vlucas" - } - ], - "description": "Loads environment variables from `.env` to `getenv()`, `$_ENV` and `$_SERVER` automagically.", - "keywords": [ - "dotenv", - "env", - "environment" - ], - "support": { - "issues": "https://github.com/vlucas/phpdotenv/issues", - "source": "https://github.com/vlucas/phpdotenv/tree/v5.4.1" - }, - "funding": [ - { - "url": "https://github.com/GrahamCampbell", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/vlucas/phpdotenv", - "type": "tidelift" - } - ], - "time": "2021-12-12T23:22:04+00:00" - }, { "name": "voku/portable-ascii", "version": "1.5.6", @@ -2010,13 +1534,12 @@ "packages-dev": [], "aliases": [], "minimum-stability": "stable", - "stability-flags": { - "leafs/leaf": 20 - }, + "stability-flags": [], "prefer-stable": false, "prefer-lowest": false, "platform": { - "php": "^8.0.0" + "php": "^8.0.0", + "ext-curl": "*" }, "platform-dev": [], "plugin-api-version": "2.2.0" diff --git a/helpers/domains.php b/helpers/domains.php new file mode 100644 index 0000000..d543959 --- /dev/null +++ b/helpers/domains.php @@ -0,0 +1,16 @@ + [ + "p16-sign-va.tiktokcdn.com", + "p16-sign-sg.tiktokcdn.com", + "p77-sign-va.tiktokcdn.com", + "p77-sign-sg.tiktokcdn.com", + "p77-sign-sg-lite.tiktokcdn.com" + ], + "video" => [ + "v16-webapp.tiktok.com" + ], + "audio" => [ + "sf16-ies-music-va.tiktokcdn.com" + ], +]; diff --git a/helpers/settings_elements.php b/helpers/settings_elements.php new file mode 100644 index 0000000..37ab4ef --- /dev/null +++ b/helpers/settings_elements.php @@ -0,0 +1,2 @@ +stream($url); +function getApi(array $proxy_elements): \Sovit\TikTok\Api { + $options = []; + if (in_array($proxy_elements, $_COOKIE)) { + foreach ($proxy_elements as $proxy_element) { + $options[$proxy_element] = $_COOKIE[$proxy_element]; + } + } + $api = new \Sovit\TikTok\Api($options); + return $api; } -$app = new Leaf\App; +$router = new \Bramus\Router\Router(); -$app->get('/', function () use ($app) { - $app->response()->page('./views/home.html'); +$router->get('/', function () { + http_response_code(302); + header('Location: ./home'); }); -$app->get('/stream', function () { +$router->get('/home', function () { + $blade = new Blade('./views', './cache/views'); + echo $blade->render('home'); +}); + +$router->get('/images', function () use ($domains) { + if (!isset($_GET['url'])) { + die('You need to send a url!'); + } + $url = $_GET['url']; + $host = parse_url($url, PHP_URL_HOST); + + if (!filter_var($url, FILTER_VALIDATE_URL) || !in_array($host, $domains['image'])) { + die('Not a valid URL'); + } + $img = file_get_contents($url, false, stream_context_create(['http' => ['ignore_errors' => true]])); + if ($img) { + header('Content-Type: image/jpeg'); + echo $img; + } else { + echo 'Error while getting image!'; + } +}); + +$router->get('/audios', function () use ($domains) { + if (!isset($_GET['url'])) { + die('You need to send a url!'); + } + $url = $_GET['url']; + $host = parse_url($url, PHP_URL_HOST); + if (!filter_var($url, FILTER_VALIDATE_URL) || !in_array($host, $domains['audio'])) { + die('Not a valid URL'); + } + $audio = file_get_contents($url, false, stream_context_create(['http' => ['ignore_errors' => true]])); + if ($audio) { + header('Content-Type: audio/mp3'); + echo $audio; + } else { + echo 'Error while getting audio!'; + } +}); + +$router->get('/stream', function () use ($domains) { if (!isset($_GET['url'])) { die('You need to send a url!'); } - startStream($_GET['url']); + + $url = $_GET['url']; + $host = parse_url($url, PHP_URL_HOST); + + if (!filter_var($url, FILTER_VALIDATE_URL) || !in_array($host, $domains['video'])) { + die('Not a valid URL'); + } + + header('Content-Disposition: attachment; filename="tiktok.mp4"'); + + $streamer = new \Sovit\TikTok\Stream(); + $streamer->stream($url); }); -$app->get("/trending", function () { +$router->get("/trending", function () use ($proxy_elements) { $cursor = 0; if (isset($_GET['cursor']) && is_numeric($_GET['cursor'])) { $cursor = (int) $_GET['cursor']; } $blade = new Blade('./views', './cache/views'); - $api = new \Sovit\TikTok\Api(); + $api = getApi($proxy_elements); $feed = $api->getTrendingFeed($cursor); if ($feed) { echo $blade->render('trending', ['feed' => $feed]); @@ -36,35 +98,13 @@ $app->get("/trending", function () { } }); -/* CURRENTLY NOT WORKING -$app->get('/videos', function () { - if (!isset($_GET['id'])) { - die('You need to send an id param!'); - } - $item = $_GET['id']; - $api = new \Sovit\TikTok\Api(); - // Using an url - if (filter_var($item, FILTER_VALIDATE_URL)) { - $feed = $api->getVideoByUrl($item); - } else { - // Assume is an id - $feed = $api->getVideoByID($item); - } - - if ($feed) { - var_dump($feed); - } - -}); -*/ - -$app->get("/@([^/]+)", function (string $username) { +$router->get("/@([^/]+)", function (string $username) use ($proxy_elements) { $cursor = 0; if (isset($_GET['cursor']) && is_numeric($_GET['cursor'])) { $cursor = (int) $_GET['cursor']; } $blade = new Blade('./views', './cache/views'); - $api = new \Sovit\TikTok\Api(); + $api = getApi($proxy_elements); $feed = $api->getUserFeed($username, $cursor); if ($feed) { echo $blade->render('user', ['feed' => $feed]); @@ -73,4 +113,19 @@ $app->get("/@([^/]+)", function (string $username) { } }); -$app->run(); +$router->get("/settings", function () use ($proxy_elements) { + $blade = new Blade('./views', './cache/views'); + echo $blade->render('settings', ["proxy_elements" => $proxy_elements]); +}); + +$router->post("/settings", function () use ($proxy_elements) { + if (in_array($proxy_elements, $_POST)) { + foreach ($proxy_elements as $proxy_element) { + setcookie($proxy_element, $_POST[$proxy_element], time()+60*60*24*30, '/', '', true, true); + } + } + http_response_code(302); + header('Location: ./home'); +}); + +$router->run(); diff --git a/scripts/navbar.js b/scripts/navbar.js new file mode 100644 index 0000000..9158418 --- /dev/null +++ b/scripts/navbar.js @@ -0,0 +1,6 @@ +const navbar_menu = document.getElementById('navbar-menu') +const burger = document.getElementById('navbar-burger') +burger.addEventListener('click', () => { + burger.classList.toggle('is-active') + navbar_menu.classList.toggle('is-active') +}) diff --git a/views/about.blade.php b/views/about.blade.php new file mode 100644 index 0000000..e3351c1 --- /dev/null +++ b/views/about.blade.php @@ -0,0 +1,24 @@ + + +
+ + + +About
+TODO
+