This repository has been archived by the owner on Sep 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 21
/
delete.php
85 lines (73 loc) · 2.29 KB
/
delete.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<?php
require_once "includes.php";
include "header.php";
$wiki = $_GET[ 'wiki' ];
$wikiData = get_wiki_data( $wiki );
if ( !can_delete( $wikiData['creator'] ) ) {
die( '<p>You are not allowed to delete this wiki.</p>' );
}
if ( !isset( $_POST['confirm' ] ) ) {
$patches = format_patch_list( $wikiData['patchList'], $wikiData['branch'] );
$linkedTasks = format_linked_tasks( $wikiData['linkedTaskList'] );
$creator = $wikiData[ 'creator' ] ?? '';
echo '<table class="wikis">' .
'<tr class="headerRow">' .
'<th>Wiki</th>' .
'<th>Patches<br /><em>✓=Merged ✗=Abandoned</em></th>' .
'<th>Linked tasks<br /><em>✓=Resolved ✗=Declined/Invalid</em></th>' .
'<th>Time</th>' .
( $useOAuth ? '<th>Creator</th>' : '' ) .
'</tr>' .
'<tr>' .
'<td data-label="Wiki" class="wiki">' . get_wiki_link( $wiki, $wikiData['landingPage'] ) . '</td>' .
'<td data-label="Patches" class="patches">' . $patches . '</td>' .
'<td data-label="Linked tasks" class="linkedTasks">' . $linkedTasks . '</td>' .
'<td data-label="Time" class="date">' . date( 'Y-m-d H:i:s', $wikiData[ 'created' ] ) . '</td>' .
( $useOAuth ? '<td data-label="Creator">' . ( $creator ? user_link( $creator ) : '?' ) . '</td>' : '' ) .
'</tr>' .
'</table><br>';
echo new OOUI\FormLayout( [
'infusable' => true,
'method' => 'POST',
'items' => [
new OOUI\FieldsetLayout( [
'label' => null,
'items' => [
new OOUI\FieldLayout(
new OOUI\ButtonInputWidget( [
'type' => 'submit',
'name' => 'confirm',
'label' => 'Delete',
'flags' => [ 'primary', 'destructive' ]
] ),
[
'label' => 'Are you sure you want to delete this wiki?',
'help' => 'This cannot be undone.',
'helpInline' => true,
'align' => 'left',
]
),
new OOUI\FieldLayout(
new OOUI\HiddenInputWidget( [
'name' => 'csrf_token',
'value' => get_csrf_token(),
] )
),
]
] )
]
] );
die();
}
if ( !isset( $_POST['csrf_token'] ) || !check_csrf_token( $_POST['csrf_token'] ) ) {
die( "Invalid session." );
}
ob_implicit_flush( true );
echo '<div class="consoleLog">';
$error = delete_wiki( $wiki );
echo '</div>';
if ( $error ) {
die( '<p>Error deleting wiki:<br>' . htmlentities( $error ) . '</p>' );
} else {
echo '<p>Wiki deleted.</p>';
}