|
1
|
|
|
<?php |
|
2
|
|
|
/****************************************************************************** |
|
3
|
|
|
* Wikipedia Account Creation Assistance tool * |
|
4
|
|
|
* * |
|
5
|
|
|
* All code in this file is released into the public domain by the ACC * |
|
6
|
|
|
* Development Team. Please see team.json for a list of contributors. * |
|
7
|
|
|
******************************************************************************/ |
|
8
|
|
|
|
|
9
|
|
|
namespace Waca\API\Actions; |
|
10
|
|
|
|
|
11
|
|
|
use DOMElement; |
|
12
|
|
|
use Waca\API\IApiAction; |
|
13
|
|
|
use Waca\Tasks\ApiPageBase; |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* API Count action |
|
17
|
|
|
*/ |
|
18
|
|
|
class StatusAction extends ApiPageBase implements IApiAction |
|
19
|
|
|
{ |
|
20
|
|
|
public function executeApiAction(DOMElement $apiDocument) |
|
21
|
|
|
{ |
|
22
|
|
|
$statusElement = $this->document->createElement("status"); |
|
|
|
|
|
|
23
|
|
|
$apiDocument->appendChild($statusElement); |
|
24
|
|
|
|
|
25
|
|
|
$query = $this->getDatabase()->prepare(<<<SQL |
|
26
|
|
|
SELECT /* Api/StatusAction */ COUNT(*) AS count |
|
27
|
|
|
FROM request |
|
28
|
|
|
WHERE |
|
29
|
|
|
status = :pstatus |
|
30
|
|
|
AND emailconfirm = 'Confirmed'; |
|
31
|
|
|
SQL |
|
32
|
|
|
); |
|
33
|
|
|
|
|
34
|
|
|
$availableRequestStates = $this->getSiteConfiguration()->getRequestStates(); |
|
35
|
|
|
|
|
36
|
|
|
foreach ($availableRequestStates as $key => $value) { |
|
37
|
|
|
$query->bindValue(":pstatus", $key); |
|
|
|
|
|
|
38
|
|
|
$query->execute(); |
|
39
|
|
|
$sus = $query->fetchColumn(); |
|
40
|
|
|
$statusElement->setAttribute($value['api'], $sus); |
|
41
|
|
|
$query->closeCursor(); |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
$query = $this->getDatabase()->prepare(<<<SQL |
|
45
|
|
|
SELECT /* Api/StatusAction */ COUNT(*) AS count |
|
46
|
|
|
FROM ban |
|
47
|
|
|
WHERE |
|
48
|
|
|
(duration > UNIX_TIMESTAMP() OR duration = -1) |
|
49
|
|
|
AND active = 1; |
|
50
|
|
|
SQL |
|
51
|
|
|
); |
|
52
|
|
|
|
|
53
|
|
|
$query->execute(); |
|
54
|
|
|
$sus = $query->fetchColumn(); |
|
55
|
|
|
$statusElement->setAttribute("bans", $sus); |
|
|
|
|
|
|
56
|
|
|
$query->closeCursor(); |
|
57
|
|
|
|
|
58
|
|
|
$query = $this->getDatabase()->prepare(<<<SQL |
|
59
|
|
|
SELECT /* Api/StatusAction */ COUNT(*) AS count |
|
60
|
|
|
FROM user WHERE status = :ulevel; |
|
61
|
|
|
SQL |
|
62
|
|
|
); |
|
63
|
|
|
$query->bindValue(":ulevel", "Admin"); |
|
|
|
|
|
|
64
|
|
|
$query->execute(); |
|
65
|
|
|
$sus = $query->fetchColumn(); |
|
66
|
|
|
$statusElement->setAttribute("useradmin", $sus); |
|
|
|
|
|
|
67
|
|
|
$query->closeCursor(); |
|
68
|
|
|
|
|
69
|
|
|
$query->bindValue(":ulevel", "User"); |
|
|
|
|
|
|
70
|
|
|
$query->execute(); |
|
71
|
|
|
$sus = $query->fetchColumn(); |
|
72
|
|
|
$statusElement->setAttribute("user", $sus); |
|
|
|
|
|
|
73
|
|
|
$query->closeCursor(); |
|
74
|
|
|
|
|
75
|
|
|
$query->bindValue(":ulevel", "New"); |
|
|
|
|
|
|
76
|
|
|
$query->execute(); |
|
77
|
|
|
$sus = $query->fetchColumn(); |
|
78
|
|
|
$statusElement->setAttribute("usernew", $sus); |
|
|
|
|
|
|
79
|
|
|
$query->closeCursor(); |
|
80
|
|
|
|
|
81
|
|
|
return $apiDocument; |
|
82
|
|
|
} |
|
|
|
|
|
|
83
|
|
|
} |
|
|
|
|
|
|
84
|
|
|
|
PHP provides two ways to mark string literals. Either with single quotes
'literal'or with double quotes"literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (
\') and the backslash (\\). Every other character is displayed as is.Double quoted string literals may contain other variables or more complex escape sequences.
will print an indented:
Single is ValueIf your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.
For more information on PHP string literals and available escape sequences see the PHP core documentation.