diff --git a/.gitignore b/.gitignore index cb50cd2c..98dcc8d2 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,5 @@ composer composer.lock vendor wikicache.json +redirects.txt node_modules diff --git a/404.php b/404.php index 98ec41fe..7db20630 100644 --- a/404.php +++ b/404.php @@ -2,9 +2,38 @@ header( 'HTTP/1.0 404 Not Found' ); require_once "includes.php"; -echo new \OOUI\MessageWidget( [ - 'type' => 'error', - 'label' => 'Page not found. The wiki you are looking for may have been deleted.' -] ); +// Check for redirect +$redirects = get_if_file_exists( 'redirects.txt' ); +$redirect = false; +if ( $redirects ) { + $uri = $_SERVER['REQUEST_URI']; + $lines = explode( "\n", $redirects ); + foreach ( $lines as $line ) { + if ( !$line ) { + continue; + } + $parts = explode( ' ', $line ); + if ( strpos( $uri, $parts[0] ) !== false ) { + $uri = str_replace( $parts[0], $parts[1], $uri ); + $redirect = true; + } + } +} + +if ( $redirect ) { + echo new \OOUI\MessageWidget( [ + 'type' => 'info', + 'icon' => 'articleRedirect', + 'label' => new \OOUI\HtmlSnippet( + 'This wiki has been deleted. The following wiki was selected as a direct replacement: ' . + '' . $uri . '' + ) + ] ); +} else { + echo new \OOUI\MessageWidget( [ + 'type' => 'error', + 'label' => 'Page not found. The wiki you are looking for may have been deleted.' + ] ); +} include "footer.html"; diff --git a/delete.php b/delete.php index c4f9cc8e..d36cb43b 100644 --- a/delete.php +++ b/delete.php @@ -11,24 +11,88 @@ } if ( !isset( $_POST['confirm' ] ) ) { - echo '
'; - die(); -} -ob_implicit_flush( true ); + $wikilist = [ + [ + 'data' => '', + 'label' => 'None', + ] + ]; + $cache = load_wikicache(); + if ( $cache ) { + $wikis = json_decode( $cache, true ); + foreach ( $wikis as $hash => $data ) { + $wikilist[] = [ + 'data' => $hash, + 'label' => $hash . ' - ' . $data['creator'] . ' (' . date( 'c', $data[ 'mtime' ] ) . ')', + ]; + } + } + echo new OOUI\FormLayout( [ + 'method' => 'POST', + 'items' => [ + new OOUI\FieldsetLayout( [ + 'label' => new OOUI\HtmlSnippet( + 'Are you sure you want to delete this wiki: ' . $wiki . '?