proxitok/app/Controllers/RedirectController.php

43 lines
1.3 KiB
PHP
Raw Normal View History

2022-02-05 23:58:30 +00:00
<?php
namespace App\Controllers;
use App\Helpers\Misc;
/**
* Used to be compatible with HTML forms
*/
class RedirectController {
static public function redirect() {
$endpoint = '/';
if (isset($_GET['type'], $_GET['term'])) {
$term = trim($_GET['term']);
switch ($_GET['type']) {
case 'user':
// Remove @ if sent
if ($term[0] === '@') {
$term = substr($term, 1);
}
$endpoint = '/@' . $term;
break;
case 'tag':
// Remove # if sent
if ($term[0] === '#') {
$term = substr($term, 1);
}
$endpoint = '/tag/' . $term;
break;
case 'music':
$endpoint = '/music/' . $term;
break;
case 'video':
// The @username part is not used, but
// it is the schema that TikTok follows
$endpoint = '/@placeholder/video/' . $term;
break;
}
2022-02-05 23:58:30 +00:00
}
$url = Misc::url($endpoint);
header("Location: {$url}");
}
}