PluginProbe ʕ •ᴥ•ʔ
Matomo Analytics – Powerful, Privacy-First Insights for WordPress / 1.3.1
Matomo Analytics – Powerful, Privacy-First Insights for WordPress v1.3.1
5.11.1 5.11.0 5.10.2 5.10.1 trunk 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.1.0 1.1.1 1.1.2 1.1.3 1.2.0 1.3.0 1.3.1 1.3.2 4.0.0 4.0.1 4.0.2 4.0.3 4.0.4 4.1.0 4.1.1 4.1.2 4.1.3 4.10.0 4.11.0 4.12.0 4.13.0 4.13.2 4.13.3 4.13.4 4.13.5 4.14.0 4.14.1 4.14.2 4.15.0 4.15.1 4.15.2 4.15.3 4.2.0 4.3.0 4.3.1 4.4.1 4.4.2 4.5.0 4.6.0 5.0.1 5.0.2 5.0.3 5.0.4 5.0.5 5.0.6 5.0.7 5.0.8 5.1.0 5.1.1 5.1.2 5.1.3 5.1.4 5.1.5 5.1.6 5.1.7 5.10.0 5.2.0 5.2.1 5.2.2 5.3.0 5.3.1 5.3.2 5.3.3 5.6.0 5.6.1 5.7.0 5.7.1 5.8.0 5.8.1 5.8.2
matomo / app / core / testMinimumPhpVersion.php
matomo / app / core Last commit date
API 6 years ago Access 6 years ago Application 6 years ago Archive 6 years ago ArchiveProcessor 6 years ago Archiver 6 years ago AssetManager 6 years ago Auth 6 years ago Category 6 years ago CliMulti 6 years ago Columns 6 years ago Composer 6 years ago Concurrency 6 years ago Config 6 years ago Container 6 years ago CronArchive 6 years ago DataAccess 5 years ago DataFiles 6 years ago DataTable 6 years ago Db 6 years ago DeviceDetector 5 years ago Email 6 years ago Exception 6 years ago Http 6 years ago Intl 6 years ago Mail 6 years ago Measurable 6 years ago Menu 6 years ago Metrics 6 years ago Notification 6 years ago Period 6 years ago Plugin 6 years ago ProfessionalServices 6 years ago Report 6 years ago ReportRenderer 6 years ago Scheduler 6 years ago Segment 6 years ago Session 6 years ago Settings 6 years ago Tracker 5 years ago Translation 6 years ago UpdateCheck 6 years ago Updater 6 years ago Updates 6 years ago Validators 6 years ago View 6 years ago ViewDataTable 6 years ago Visualization 6 years ago Widget 6 years ago .htaccess 6 years ago Access.php 6 years ago Archive.php 6 years ago ArchiveProcessor.php 6 years ago AssetManager.php 6 years ago Auth.php 6 years ago BaseFactory.php 6 years ago Cache.php 6 years ago CacheId.php 6 years ago CliMulti.php 6 years ago Common.php 6 years ago Config.php 6 years ago Console.php 6 years ago Context.php 6 years ago Cookie.php 5 years ago CronArchive.php 5 years ago DataArray.php 6 years ago DataTable.php 6 years ago Date.php 6 years ago Db.php 6 years ago DbHelper.php 6 years ago Development.php 6 years ago DeviceDetectorFactory.php 6 years ago ErrorHandler.php 6 years ago EventDispatcher.php 6 years ago ExceptionHandler.php 6 years ago FileIntegrity.php 6 years ago Filechecks.php 6 years ago Filesystem.php 6 years ago FrontController.php 6 years ago Http.php 6 years ago IP.php 6 years ago Log.php 6 years ago LogDeleter.php 6 years ago Mail.php 6 years ago Metrics.php 6 years ago MetricsFormatter.php 6 years ago Nonce.php 5 years ago Notification.php 6 years ago NumberFormatter.php 6 years ago Option.php 5 years ago Period.php 6 years ago Piwik.php 6 years ago Plugin.php 6 years ago Profiler.php 6 years ago ProxyHeaders.php 6 years ago ProxyHttp.php 6 years ago QuickForm2.php 6 years ago RankingQuery.php 6 years ago Registry.php 6 years ago ReportRenderer.php 6 years ago ScheduledTask.php 6 years ago Segment.php 6 years ago Sequence.php 6 years ago Session.php 6 years ago SettingsPiwik.php 6 years ago SettingsServer.php 6 years ago Singleton.php 6 years ago Site.php 6 years ago TCPDF.php 6 years ago TaskScheduler.php 6 years ago Theme.php 6 years ago Timer.php 6 years ago Tracker.php 6 years ago Translate.php 6 years ago Twig.php 6 years ago Unzip.php 6 years ago UpdateCheck.php 6 years ago Updater.php 6 years ago Updates.php 6 years ago Url.php 6 years ago UrlHelper.php 6 years ago Version.php 5 years ago View.php 6 years ago bootstrap.php 6 years ago dispatch.php 6 years ago testMinimumPhpVersion.php 6 years ago
testMinimumPhpVersion.php
198 lines
1 <?php
2 /**
3 * Piwik - free/libre analytics platform
4 *
5 * @link https://matomo.org
6 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
7 *
8 */
9
10 /**
11 * This file is executed before anything else.
12 * It checks the minimum PHP version required to run Matomo.
13 * This file must be compatible PHP4.
14 */
15
16 $piwik_errorMessage = '';
17
18 // Minimum requirement: stream_resolve_include_path, working json_encode in 5.3.3, namespaces in 5.3
19 // NOTE: when changing this variable, we also need to update
20 // 1) api.matomo.org
21 // 2) tests/travis/generator/Generator.php
22 // 3) composer.json (in two places)
23 // 4) tests/PHPUnit/Integration/ReleaseCheckListTest.php
24 $piwik_minimumPHPVersion = '5.5.9';
25 $piwik_currentPHPVersion = PHP_VERSION;
26 $minimumPhpInvalid = version_compare($piwik_minimumPHPVersion, $piwik_currentPHPVersion) > 0;
27 if ($minimumPhpInvalid) {
28 $piwik_errorMessage .= "<p><strong>To run Matomo you need at least PHP version $piwik_minimumPHPVersion</strong></p>
29 <p>Unfortunately it seems your webserver is using PHP version $piwik_currentPHPVersion. </p>
30 <p>Please try to update your PHP version, Matomo is really worth it! Nowadays most web hosts
31 support PHP $piwik_minimumPHPVersion.</p>
32 <p>Also see the FAQ: <a href='https://matomo.org/faq/how-to-install/#faq_77'>My Web host supports PHP4 by default. How can I enable PHP5?</a></p>";
33 } else {
34 if (!extension_loaded('session')) {
35 $piwik_errorMessage .= "<p><strong>Matomo and Zend_Session require the session extension</strong></p>
36 <p>It appears your PHP was compiled with <pre>--disable-session</pre>.
37 To enjoy Matomo, you need PHP compiled without that configure option.</p>";
38 }
39
40 if (!function_exists('ini_set')) {
41 $piwik_errorMessage .= "<p><strong>Matomo and Zend_Session require the <code>ini_set()</code> function</strong></p>
42 <p>It appears your PHP has disabled this function.
43 To enjoy Matomo, you need remove <pre>ini_set</pre> from your <pre>disable_functions</pre> directive in php.ini, and restart your webserver.</p>";
44 }
45
46 if (ini_get('mbstring.func_overload')) {
47 $piwik_errorMessage .= "<p><strong>Matomo does not work when PHP is configured with <pre>mbstring.func_overload = " . ini_get('mbstring.func_overload') . "</pre></strong></p>
48 <p>It appears your mbstring extension in PHP is configured to override string functions.
49 To enjoy Matomo, you need to modify php.ini <pre>mbstring.func_overload = 0</pre>, and restart your webserver.</p>";
50 }
51
52 if (!function_exists('json_encode')) {
53 $piwik_errorMessage .= "<p><strong>Matomo requires the php5-json extension which provides the functions <code>json_encode()</code> and <code>json_decode()</code></strong></p>
54 <p>It appears your PHP has not yet installed the php5-json extension.
55 To use Matomo, please ask your web host to install php5-json or install it yourself, for example on debian system: <code>sudo apt-get install php5-json</code>. <br/>Then restart your webserver and refresh this page.</p>";
56 }
57
58 if (!file_exists(PIWIK_VENDOR_PATH . '/autoload.php')) {
59 $composerInstall = "In the matomo directory, run in the command line the following (eg. via ssh): \n\n"
60 . "<pre> curl -sS https://getcomposer.org/installer | php \n\n php composer.phar install\n\n</pre> ";
61 if (DIRECTORY_SEPARATOR === '\\' /* ::isWindows() */) {
62 $composerInstall = "Download and run <a href=\"https://getcomposer.org/Composer-Setup.exe\"><b>Composer-Setup.exe</b></a>, it will install the latest Composer version and set up your PATH so that you can just call composer from any directory in your command line. "
63 . " <br>Then run this command in a terminal in the matomo directory: <br> $ php composer.phar install ";
64 }
65 $piwik_errorMessage .= "<p>It appears the <a href='https://getcomposer.org/' rel='noreferrer noopener' target='_blank'>composer</a> tool is not yet installed. You can install Composer in a few easy steps:\n\n".
66 "<br/>" . $composerInstall.
67 " This will initialize composer for Matomo and download libraries we use in vendor/* directory.".
68 "\n\n<br/><br/>Then reload this page to access your analytics reports." .
69 "\n\n<br/><br/>For more information check out this FAQ: <a href='https://matomo.org/faq/how-to-install/faq_18271/' rel='noreferrer noopener' target='_blank'>How do I use Matomo from the Git repository?</a>." .
70 "\n\n<br/><br/>Note: if for some reasons you cannot install composer, instead install the latest Matomo release from ".
71 "<a href='https://builds.matomo.org/piwik.zip' rel='noreferrer noopener'>builds.matomo.org</a>.</p>";
72 }
73 }
74
75 define('PAGE_TITLE_WHEN_ERROR', 'Matomo &rsaquo; Error');
76
77 if (!function_exists('Piwik_GetErrorMessagePage')) {
78 /**
79 * Returns true if Piwik should print the backtrace with error messages.
80 *
81 * To make sure the backtrace is printed, define PIWIK_PRINT_ERROR_BACKTRACE.
82 *
83 * @return bool
84 */
85 function Piwik_ShouldPrintBackTraceWithMessage()
86 {
87 if (\Piwik\SettingsServer::isArchivePhpTriggered()
88 && \Piwik\Common::isPhpCliMode()
89 ) {
90 return true;
91 }
92
93 $bool = (defined('PIWIK_PRINT_ERROR_BACKTRACE') && PIWIK_PRINT_ERROR_BACKTRACE)
94 || !empty($GLOBALS['PIWIK_TRACKER_DEBUG']);
95
96 return $bool;
97 }
98
99 /**
100 * Displays info/warning/error message in a friendly UI and exits.
101 *
102 * Note: this method should not be called by anyone other than FrontController.
103 *
104 * @param string $message Main message, must be html encoded before calling
105 * @param bool|string $optionalTrace Backtrace; will be displayed in lighter color
106 * @param bool $optionalLinks If true, will show links to the Piwik website for help
107 * @param bool $optionalLinkBack If true, displays a link to go back
108 * @param bool|string $logoUrl The URL to the logo to use.
109 * @param bool|string $faviconUrl The URL to the favicon to use.
110 * @return string
111 */
112 function Piwik_GetErrorMessagePage($message, $optionalTrace = false, $optionalLinks = false, $optionalLinkBack = false,
113 $logoUrl = false, $faviconUrl = false, $isCli = null)
114 {
115 error_log(sprintf("Error in Matomo: %s", str_replace("\n", " ", strip_tags($message))));
116
117 if (!headers_sent()) {
118 header('Content-Type: text/html; charset=utf-8');
119 header('Cache-Control: private, no-cache, no-store');
120
121 $isInternalServerError = preg_match('/(sql|database|mysql)/i', $message);
122 if ($isInternalServerError) {
123 header('HTTP/1.1 500 Internal Server Error');
124 }
125 }
126
127 // We return only an HTML fragment for AJAX requests
128 if (isset($_SERVER['HTTP_X_REQUESTED_WITH'])
129 && (strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest')
130 ) {
131 return "<div class='alert alert-danger'><strong>Error:</strong> $message</div>";
132 }
133
134 if (empty($logoUrl)) {
135 $logoUrl = "plugins/Morpheus/images/logo.svg";
136 }
137
138 if (empty($faviconUrl)) {
139 $faviconUrl = "plugins/CoreHome/images/favicon.png";
140 }
141
142 if ($optionalTrace) {
143 $optionalTrace = '<h2>Stack trace</h2><pre>' . htmlentities($optionalTrace, ENT_COMPAT | ENT_HTML401, 'UTF-8') . '</pre>';
144 }
145
146 if ($isCli === null) {
147 $isCli = PHP_SAPI == 'cli';
148 }
149
150 if ($optionalLinks) {
151 $optionalLinks = '<ul>
152 <li><a rel="noreferrer noopener" target="_blank" href="https://matomo.org">Matomo.org homepage</a></li>
153 <li><a rel="noreferrer noopener" target="_blank" href="https://matomo.org/faq/">Frequently Asked Questions</a></li>
154 <li><a rel="noreferrer noopener" target="_blank" href="https://matomo.org/docs/">User Guides</a></li>
155 <li><a rel="noreferrer noopener" target="_blank" href="https://forum.matomo.org/">Matomo Forums</a></li>
156 <li><a rel="noreferrer noopener" target="_blank" href="https://matomo.org/support/?pk_campaign=App_AnErrorOccured&pk_source=Matomo_App&pk_medium=ProfessionalServicesLink">Professional Support for Matomo</a></li>
157 </ul>';
158 }
159 if ($optionalLinkBack) {
160 $optionalLinkBack = '<a href="javascript:window.history.back();">Go Back</a>';
161 }
162
163 $headerPage = file_get_contents(PIWIK_INCLUDE_PATH . '/plugins/Morpheus/templates/simpleLayoutHeader.tpl');
164 $headerPage = str_replace('%logoUrl%', $logoUrl, $headerPage);
165 $headerPage = str_replace('%faviconUrl%', $faviconUrl, $headerPage);
166
167 $footerPage = file_get_contents(PIWIK_INCLUDE_PATH . '/plugins/Morpheus/templates/simpleLayoutFooter.tpl');
168
169 $headerPage = str_replace('{$HTML_TITLE}', PAGE_TITLE_WHEN_ERROR, $headerPage);
170
171 $content = '<h2>' . $message . '</h2>
172 <p>'
173 . $optionalLinkBack
174 . ' | <a href="index.php">Go to Matomo</a>'
175 . '</p>'
176 . ' ' . (Piwik_ShouldPrintBackTraceWithMessage() ? $optionalTrace : '')
177 . ' ' . $optionalLinks;
178
179
180 $message = str_replace(array("<br />", "<br>", "<br/>", "</p>"), "\n", $message);
181 $message = str_replace("\t", "", $message);
182 $message = strip_tags($message);
183
184 if (!$isCli) {
185 $message = $headerPage . $content . $footerPage;
186 }
187
188 $message .= "\n";
189
190 return $message;
191 }
192 }
193
194 if (!empty($piwik_errorMessage)) {
195 echo Piwik_GetErrorMessagePage($piwik_errorMessage, false, true);
196 exit(1);
197 }
198