This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
0 ignored issues
–
show
|
|||
2 | /** |
||
3 | * Statistics about the localisation. |
||
4 | * |
||
5 | * This program is free software; you can redistribute it and/or modify |
||
6 | * it under the terms of the GNU General Public License as published by |
||
7 | * the Free Software Foundation; either version 2 of the License, or |
||
8 | * (at your option) any later version. |
||
9 | * |
||
10 | * This program is distributed in the hope that it will be useful, |
||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
13 | * GNU General Public License for more details. |
||
14 | * |
||
15 | * You should have received a copy of the GNU General Public License along |
||
16 | * with this program; if not, write to the Free Software Foundation, Inc., |
||
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
||
18 | * http://www.gnu.org/copyleft/gpl.html |
||
19 | * |
||
20 | * @file |
||
21 | * @ingroup MaintenanceLanguage |
||
22 | * |
||
23 | * @author Ævar Arnfjörð Bjarmason <[email protected]> |
||
24 | * @author Antoine Musso <hashar at free dot fr> |
||
25 | * |
||
26 | * Output is posted from time to time on: |
||
27 | * https://www.mediawiki.org/wiki/Localisation_statistics |
||
28 | */ |
||
29 | $optionsWithArgs = [ 'output' ]; |
||
30 | $optionsWithoutArgs = [ 'help' ]; |
||
31 | |||
32 | require_once __DIR__ . '/../commandLine.inc'; |
||
33 | require_once 'languages.inc'; |
||
34 | require_once __DIR__ . '/StatOutputs.php'; |
||
35 | |||
36 | if ( isset( $options['help'] ) ) { |
||
37 | showUsage(); |
||
38 | } |
||
39 | |||
40 | # Default output is WikiText |
||
41 | if ( !isset( $options['output'] ) ) { |
||
42 | $options['output'] = 'wiki'; |
||
43 | } |
||
44 | |||
45 | /** Print a usage message*/ |
||
46 | function showUsage() { |
||
0 ignored issues
–
show
The function
showUsage() has been defined more than once; this definition is ignored, only the first definition in maintenance/importImages.php (L358-404) is considered.
This check looks for functions that have already been defined in other files. Some Codebases, like WordPress, make a practice of defining functions multiple times. This
may lead to problems with the detection of function parameters and types. If you really
need to do this, you can mark the duplicate definition with the /**
* @ignore
*/
function getUser() {
}
function getUser($id, $realm) {
}
See also the PhpDoc documentation for @ignore. ![]() |
|||
47 | print <<<TEXT |
||
48 | Usage: php transstat.php [--help] [--output=csv|text|wiki] |
||
49 | --help : this helpful message |
||
50 | --output : select an output engine one of: |
||
51 | * 'csv' : Comma Separated Values. |
||
52 | * 'wiki' : MediaWiki syntax (default). |
||
53 | * 'text' : Text with tabs. |
||
54 | Example: php maintenance/transstat.php --output=text |
||
55 | |||
56 | TEXT; |
||
57 | exit( 1 ); |
||
0 ignored issues
–
show
The function showUsage() contains an exit expression.
An exit expression should only be used in rare cases. For example, if you write a short command line script. In most cases however, using an ![]() |
|||
58 | } |
||
59 | |||
60 | # Select an output engine |
||
61 | switch ( $options['output'] ) { |
||
62 | case 'wiki': |
||
63 | $output = new WikiStatsOutput(); |
||
64 | break; |
||
65 | case 'text': |
||
66 | $output = new TextStatsOutput(); |
||
67 | break; |
||
68 | case 'csv': |
||
69 | $output = new CsvStatsOutput(); |
||
70 | break; |
||
71 | default: |
||
72 | showUsage(); |
||
73 | } |
||
74 | |||
75 | # Languages |
||
76 | $languages = new Languages(); |
||
77 | |||
78 | # Header |
||
79 | $output->heading(); |
||
80 | $output->blockstart(); |
||
81 | $output->element( 'Language', true ); |
||
82 | $output->element( 'Code', true ); |
||
83 | $output->element( 'Fallback', true ); |
||
84 | $output->element( 'Translated', true ); |
||
85 | $output->element( '%', true ); |
||
86 | $output->element( 'Obsolete', true ); |
||
87 | $output->element( '%', true ); |
||
88 | $output->element( 'Problematic', true ); |
||
89 | $output->element( '%', true ); |
||
90 | $output->blockend(); |
||
91 | |||
92 | $wgGeneralMessages = $languages->getGeneralMessages(); |
||
93 | $wgRequiredMessagesNumber = count( $wgGeneralMessages['required'] ); |
||
94 | |||
95 | foreach ( $languages->getLanguages() as $code ) { |
||
96 | # Don't check English, RTL English or dummy language codes |
||
97 | if ( $code == 'en' || $code == 'enRTL' || ( is_array( $wgDummyLanguageCodes ) && |
||
98 | isset( $wgDummyLanguageCodes[$code] ) ) |
||
99 | ) { |
||
100 | continue; |
||
101 | } |
||
102 | |||
103 | # Calculate the numbers |
||
104 | $language = Language::fetchLanguageName( $code ); |
||
105 | $fallback = $languages->getFallback( $code ); |
||
106 | $messages = $languages->getMessages( $code ); |
||
107 | $messagesNumber = count( $messages['translated'] ); |
||
108 | $requiredMessagesNumber = count( $messages['required'] ); |
||
109 | $requiredMessagesPercent = $output->formatPercent( |
||
110 | $requiredMessagesNumber, |
||
111 | $wgRequiredMessagesNumber |
||
112 | ); |
||
113 | $obsoleteMessagesNumber = count( $messages['obsolete'] ); |
||
114 | $obsoleteMessagesPercent = $output->formatPercent( |
||
115 | $obsoleteMessagesNumber, |
||
116 | $messagesNumber, |
||
117 | true |
||
118 | ); |
||
119 | $messagesWithMismatchVariables = $languages->getMessagesWithMismatchVariables( $code ); |
||
120 | $emptyMessages = $languages->getEmptyMessages( $code ); |
||
121 | $messagesWithWhitespace = $languages->getMessagesWithWhitespace( $code ); |
||
122 | $nonXHTMLMessages = $languages->getNonXHTMLMessages( $code ); |
||
123 | $messagesWithWrongChars = $languages->getMessagesWithWrongChars( $code ); |
||
124 | $problematicMessagesNumber = count( array_unique( array_merge( |
||
125 | $messagesWithMismatchVariables, |
||
126 | $emptyMessages, |
||
127 | $messagesWithWhitespace, |
||
128 | $nonXHTMLMessages, |
||
129 | $messagesWithWrongChars |
||
130 | ) ) ); |
||
131 | $problematicMessagesPercent = $output->formatPercent( |
||
132 | $problematicMessagesNumber, |
||
133 | $messagesNumber, |
||
134 | true |
||
135 | ); |
||
136 | |||
137 | # Output them |
||
138 | $output->blockstart(); |
||
139 | $output->element( "$language" ); |
||
140 | $output->element( "$code" ); |
||
141 | $output->element( "$fallback" ); |
||
142 | $output->element( "$requiredMessagesNumber/$wgRequiredMessagesNumber" ); |
||
143 | $output->element( $requiredMessagesPercent ); |
||
144 | $output->element( "$obsoleteMessagesNumber/$messagesNumber" ); |
||
145 | $output->element( $obsoleteMessagesPercent ); |
||
146 | $output->element( "$problematicMessagesNumber/$messagesNumber" ); |
||
147 | $output->element( $problematicMessagesPercent ); |
||
148 | $output->blockend(); |
||
149 | } |
||
150 | |||
151 | # Footer |
||
152 | $output->footer(); |
||
153 |
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.