/
process_page.php
78 lines (67 loc) · 2.06 KB
/
process_page.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
<?php
declare(strict_types=1);
set_time_limit(120);
@session_start(['read_and_close' => true]);
require_once 'html_headers.php';
require_once 'setup.php';
$api = new WikipediaBot();
if (HTML_OUTPUT) {
bot_html_header();
$edit_summary_end = "| Suggested by " . $api->get_the_user() . " ";
} else {
$edit_summary_end = ""; // Command line edits as the person
}
check_blocked();
if (isset($argv[1])) {
$pages = $argv[1];
if (in_array($pages, ['page_list.txt', 'page_list2.txt'])) {
$pages = trim((string) @file_get_contents($pages));
}
} elseif (isset($_GET["page"])) {
$pages = $_GET["page"];
if (!is_string($pages)) {
report_warning('Non-string found in GET for page.');
$pages = '';
}
if (strpos($pages, '|') !== false) {
report_warning('Use the webform for multiple pages.');
$pages = '';
}
} elseif (isset($_POST["page"])) {
$pages = $_POST["page"];
if (!is_string($pages)) {
report_warning('Non-string found in POST for page.');
$pages = '';
}
} else {
report_warning('Nothing requested -- OR -- pages got lost during initial authorization ');
$pages = '';
}
if (isset($_REQUEST["edit"]) && $_REQUEST["edit"]) {
if ($_REQUEST["edit"] === 'automated_tools') {
$edit_summary_end .= "| #UCB_automated_tools ";
} elseif ($_REQUEST["edit"] === 'toolbar') {
$edit_summary_end .= "| #UCB_toolbar ";
} elseif ($_REQUEST["edit"] === 'webform') {
$edit_summary_end .= "| #UCB_webform ";
} elseif ($_REQUEST["edit"] === 'Headbomb') {
$edit_summary_end .= "| #UCB_Headbomb ";
} elseif ($_REQUEST["edit"] === 'Smith609') {
$edit_summary_end .= "| #UCB_Smith609 ";
} elseif ($_REQUEST["edit"] === 'arXiv') {
$edit_summary_end .= "| #UCB_arXiv ";
} else {
$edit_summary_end .= "| #UCB_Other ";
}
} else {
if (HTML_OUTPUT) {
$edit_summary_end .= "| #UCB_webform ";
} else {
$edit_summary_end .= "| #UCB_CommandLine ";
}
}
$pages_to_do = array_unique(explode('|', $pages));
unset($pages);
edit_a_list_of_pages($pages_to_do, $api, $edit_summary_end);
exit("\n");
?>