Code cleanup, following and gif support
This commit is contained in:
parent
493f56a052
commit
30954f3d3a
21 changed files with 318 additions and 123 deletions
|
|
@ -1,18 +1,43 @@
|
|||
<?php
|
||||
require __DIR__ . "/../helpers/settings_elements.php";
|
||||
|
||||
use Helpers\Following;
|
||||
use Helpers\Settings;
|
||||
use Helpers\Misc;
|
||||
use Steampixel\Route;
|
||||
|
||||
Route::add("/settings", function () use ($proxy_elements) {
|
||||
$latte = getLatte();
|
||||
$latte->render(getView('settings'), ["proxy_elements" => $proxy_elements]);
|
||||
Route::add("/settings", function () {
|
||||
$latte = Misc::latte();
|
||||
$latte->render(Misc::getView('settings'), ["proxy_elements" => Settings::$proxy, "following" => Following::get()]);
|
||||
});
|
||||
|
||||
Route::add("/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);
|
||||
Route::add("/settings/proxy", function () {
|
||||
if (in_array(Settings::$proxy, $_POST)) {
|
||||
foreach (Settings::$proxy as $proxy_element) {
|
||||
Settings::set($proxy_element, $_POST[$proxy_element]);
|
||||
}
|
||||
}
|
||||
http_response_code(302);
|
||||
header('Location: ./home');
|
||||
}, 'POST');
|
||||
|
||||
|
||||
Route::add("/settings/following", function () {
|
||||
$following = Following::get();
|
||||
|
||||
if (isset($_POST['add'])) {
|
||||
// Add following
|
||||
array_push($following, $_POST['account']);
|
||||
} elseif (isset($_POST['remove'])) {
|
||||
$index = array_search($_POST['account'], $following);
|
||||
if ($index !== false) {
|
||||
unset($following[$index]);
|
||||
}
|
||||
} else {
|
||||
return 'You need to send a mode!';
|
||||
}
|
||||
|
||||
// Build string
|
||||
$following_string = implode(',', $following);
|
||||
Settings::set('following', $following_string);
|
||||
header('Location: ../settings');
|
||||
}, 'POST');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue