Completed
Pull Request — stable (#106)
by Maximilian
04:48 queued 02:20
created

Upgrade to new PHP Analysis Engine

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
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 32 and the first side effect is on line 74.

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.

Loading history...
2
3
/*
4
This file is part of Peachy MediaWiki Bot API
5
6
Peachy is free software: you can redistribute it and/or modify
7
it under the terms of the GNU General Public License as published by
8
the Free Software Foundation, either version 3 of the License, or
9
(at your option) any later version.
10
11
This program is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
GNU General Public License for more details.
15
16
You should have received a copy of the GNU General Public License
17
along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
19
Peachy is not responsible for any damage caused to the system running it.
20
*/
21
22
/**
23
 * @file
24
 * Main Peachy file
25
 * Defines constants, initializes global variables
26
 * Stores Peachy class
27
 */
28
29
/**
30
 * The version that Peachy is running
31
 */
32
define( 'PEACHYVERSION', '2.0 (alpha 8)' );
33
34
/**
35
 * Minimum MediaWiki version that is required for Peachy
36
 */
37
define( 'MINMW', '1.23' );
38
39
/**
40
 * Minimum PHP version that is required for Peachy
41
 */
42
define( 'MINPHP', '5.2.1' );
43
44
/**
45
 * PECHO constants, used for {@link outputText}()
46
 */
47
define( 'PECHO_VERBOSE', -1 );
48
49
/**
50
 * PECHO constants, used for {@link outputText}()
51
 */
52
define( 'PECHO_NORMAL', 0 );
53
54
/**
55
 * PECHO constants, used for {@link outputText}()
56
 */
57
define( 'PECHO_NOTICE', 1 );
58
59
/**
60
 * PECHO constants, used for {@link outputText}()
61
 */
62
define( 'PECHO_WARN', 2 );
63
64
/**
65
 * PECHO constants, used for {@link outputText}()
66
 */
67
define( 'PECHO_ERROR', 3 );
68
69
/**
70
 * PECHO constants, used for {@link outputText}()
71
 */
72
define( 'PECHO_FATAL', 4 );
73
74
$pgIP = dirname( __FILE__ ) . DIRECTORY_SEPARATOR;
75
76
//If out /tmp directory doesnt exist, make it!
77
if( !file_exists( __DIR__ . '/tmp' ) ) {
78
    mkdir(__DIR__ . '/tmp');
79
}
80
81
require_once( $pgIP . 'Includes/Exceptions.php' );
82
require_once( $pgIP . 'Includes/AutoUpdate.php' );
83
84
peachyCheckPHPVersion( MINPHP );
85
86
$pgHooks = array();
87
$pgProxy = array();
88
$pgUA = 'Peachy MediaWiki Bot API Version ' . PEACHYVERSION;
89
90
require_once( $pgIP . 'Includes/Hooks.php' );
91
require_once( $pgIP . 'HTTP.php' );
92
require_once( $pgIP . 'Includes/Autoloader.php' );
93
require_once( $pgIP . 'GenFunctions.php' );
94
require_once( $pgIP . 'config.inc.php' );
95
require_once( $pgIP . 'Includes/SSH.php' );
96
require_once($pgIP . 'Includes/lime.php');
97
98
$pgVerbose = array();
99
if( $pgDisplayPechoVerbose ) $pgVerbose[] = -1;
100
if( $pgDisplayPechoNormal ) $pgVerbose[] = 0;
101
if( $pgDisplayPechoNotice ) $pgVerbose[] = 1;
102
if( $pgDisplayPechoWarn ) $pgVerbose[] = 2;
103
if( $pgDisplayPechoError ) $pgVerbose[] = 3;
104
if( $pgDisplayPechoFatal ) $pgVerbose[] = 4;
105
106
$pgIRCTrigger = array( '!', '.' );
107
108
//Last version check
109
$tmp = null;
110
111
if( function_exists( 'mb_internal_encoding' ) ) {
112
    mb_internal_encoding("UTF-8");
113
}
114
115
// Suppress warnings if timezone not set on server
116
date_default_timezone_set( @date_default_timezone_get() );
117
118
//Check for updates before loading Peachy.
119
if( !$pgDisableUpdates && !defined( 'PEACHY_PHPUNIT_TESTS' ) ) {
120
    //the below MUST have its own Http object or else things will break
121
    $updater = new AutoUpdate(new HTTP());
122
    $Uptodate = $updater->Checkforupdate();
123
    if (!$Uptodate) {
124
        $updater->updatePeachy();
125
    }
126
}
127
128
require_once( $pgIP . 'Includes/Peachy.php' );
129
130
/**
131
 * Simple version_compare() wrapper
132
 * @param string $check_version string
133
 * @throws DependencyError
134
 * @return void
135
 */
136
function peachyCheckPHPVersion( $check_version )
137
{
138
    if (version_compare(PHP_VERSION, $check_version, '<')) {
139
        throw new DependencyError("PHP " . $check_version, "http://php.net/downloads.php");
140
    }
141
}
142