This commit is contained in:
danpros 2024-11-18 15:35:29 +07:00
commit 1471fe7ccc
3 changed files with 13 additions and 82 deletions

View file

@ -22,11 +22,6 @@ if (isset($author[0])) {
} else { } else {
$author = default_profile($user); $author = default_profile($user);
} }
if (isset($_GET['search'])) {
$search = _h($_GET['search']);
$url = site_url() . 'search/' . remove_accent($search);
header("Location: $url");
}
?> ?>
<body class="hold-transition sidebar-mini <?php echo ((config('admin.theme') === 'light' || is_null(config('admin.theme'))) ? "light-mode" : "dark-mode"); ?>"> <body class="hold-transition sidebar-mini <?php echo ((config('admin.theme') === 'light' || is_null(config('admin.theme'))) ? "light-mode" : "dark-mode"); ?>">
<div id="top"></div> <div id="top"></div>

View file

@ -19,16 +19,12 @@ if (config('timezone')) {
// Publish scheduled post // Publish scheduled post
publish_scheduled(); publish_scheduled();
// Get search query. Redir to /search/
get_search_query();
// The front page of the blog // The front page of the blog
get('/index', function () { get('/index', function () {
if (isset($_GET['search'])) {
$search = _h($_GET['search']);
$url = site_url() . 'search/' . remove_accent($search);
header("Location: $url");
die;
}
if (!login()) { if (!login()) {
file_cache($_SERVER['REQUEST_URI']); file_cache($_SERVER['REQUEST_URI']);
} }
@ -240,13 +236,6 @@ post('/login', function () {
// Show the author page // Show the author page
get('/author/:name', function ($name) { get('/author/:name', function ($name) {
if (isset($_GET['search'])) {
$search = _h($_GET['search']);
$url = site_url() . 'search/' . remove_accent($search);
header("Location: $url");
die;
}
if (!login()) { if (!login()) {
file_cache($_SERVER['REQUEST_URI']); file_cache($_SERVER['REQUEST_URI']);
} }
@ -2805,13 +2794,6 @@ get('/admin/categories/:category', function ($category) {
// Show the category page // Show the category page
get('/category/:category', function ($category) { get('/category/:category', function ($category) {
if (isset($_GET['search'])) {
$search = _h($_GET['search']);
$url = site_url() . 'search/' . remove_accent($search);
header("Location: $url");
die;
}
if (!login()) { if (!login()) {
file_cache($_SERVER['REQUEST_URI']); file_cache($_SERVER['REQUEST_URI']);
} }
@ -3070,13 +3052,6 @@ post('/category/:category/delete', function () {
// Show the type page // Show the type page
get('/type/:type', function ($type) { get('/type/:type', function ($type) {
if (isset($_GET['search'])) {
$search = _h($_GET['search']);
$url = site_url() . 'search/' . remove_accent($search);
header("Location: $url");
die;
}
if (!login()) { if (!login()) {
file_cache($_SERVER['REQUEST_URI']); file_cache($_SERVER['REQUEST_URI']);
} }
@ -3166,13 +3141,6 @@ get('/type/:type/feed', function ($type) {
// Show the tag page // Show the tag page
get('/tag/:tag', function ($tag) { get('/tag/:tag', function ($tag) {
if (isset($_GET['search'])) {
$search = _h($_GET['search']);
$url = site_url() . 'search/' . remove_accent($search);
header("Location: $url");
die;
}
if (!login()) { if (!login()) {
file_cache($_SERVER['REQUEST_URI']); file_cache($_SERVER['REQUEST_URI']);
} }
@ -3258,13 +3226,6 @@ get('/tag/:tag/feed', function ($tag) {
// Show the archive page // Show the archive page
get('/archive/:req', function ($req) { get('/archive/:req', function ($req) {
if (isset($_GET['search'])) {
$search = _h($_GET['search']);
$url = site_url() . 'search/' . remove_accent($search);
header("Location: $url");
die;
}
if (!login()) { if (!login()) {
file_cache($_SERVER['REQUEST_URI']); file_cache($_SERVER['REQUEST_URI']);
} }
@ -3372,13 +3333,6 @@ get('/archive/:req/feed', function ($req) {
// Show the search page // Show the search page
get('/search/:keyword', function ($keyword) { get('/search/:keyword', function ($keyword) {
if (isset($_GET['search'])) {
$search = _h($_GET['search']);
$url = site_url() . 'search/' . remove_accent($search);
header("Location: $url");
die;
}
if (!login()) { if (!login()) {
file_cache($_SERVER['REQUEST_URI']); file_cache($_SERVER['REQUEST_URI']);
} }
@ -3499,13 +3453,6 @@ get('/feed/opml', function () {
// Show blog post without year-month // Show blog post without year-month
get('/'. permalink_type() .'/:name', function ($name) { get('/'. permalink_type() .'/:name', function ($name) {
if (isset($_GET['search'])) {
$search = _h($_GET['search']);
$url = site_url() . 'search/' . remove_accent($search);
header("Location: $url");
die;
}
if (permalink_type() == 'default') { if (permalink_type() == 'default') {
$post = find_post(null, null, $name); $post = find_post(null, null, $name);
if (is_null($post)) { if (is_null($post)) {
@ -3919,13 +3866,6 @@ post('/'. permalink_type() .'/:name/delete', function () {
// Show various page (top-level), admin, login, sitemap, static page. // Show various page (top-level), admin, login, sitemap, static page.
get('/:static', function ($static) { get('/:static', function ($static) {
if (isset($_GET['search'])) {
$search = _h($_GET['search']);
$url = site_url() . 'search/' . remove_accent($search);
header("Location: $url");
die;
}
if (strpos($static, ".xml") !== false) { if (strpos($static, ".xml") !== false) {
if ($static === 'sitemap.xml') { if ($static === 'sitemap.xml') {
$sitemap = 'index.xml'; $sitemap = 'index.xml';
@ -4398,13 +4338,6 @@ post('/:static/delete', function () {
// Show the sb static page // Show the sb static page
get('/:static/:sub', function ($static, $sub) { get('/:static/:sub', function ($static, $sub) {
if (isset($_GET['search'])) {
$search = _h($_GET['search']);
$url = site_url() . 'search/' . remove_accent($search);
header("Location: $url");
die;
}
if ($static === 'front') { if ($static === 'front') {
$redir = site_url(); $redir = site_url();
@ -4689,13 +4622,6 @@ post('/:static/:sub/delete', function () {
// Show blog post with year-month // Show blog post with year-month
get('/:year/:month/:name', function ($year, $month, $name) { get('/:year/:month/:name', function ($year, $month, $name) {
if (isset($_GET['search'])) {
$search = _h($_GET['search']);
$url = site_url() . 'search/' . remove_accent($search);
header("Location: $url");
die;
}
if (permalink_type() !== 'default') { if (permalink_type() !== 'default') {
$redir = site_url() . permalink_type() . '/' . $name; $redir = site_url() . permalink_type() . '/' . $name;

View file

@ -131,6 +131,16 @@ function save_config($data = array(), $new = array())
return file_put_contents($config_file, $string, LOCK_EX); return file_put_contents($config_file, $string, LOCK_EX);
} }
function get_search_query()
{
if (isset($_GET['search'])) {
$search = _h($_GET['search']);
$url = site_url() . 'search/' . remove_accent($search);
header("Location: $url");
die;
}
}
function to_b64($str) function to_b64($str)
{ {
$str = base64_encode($str); $str = base64_encode($str);