ts-website/include/modulecheck.php

118 lines
3.7 KiB
PHP
Raw Normal View History

2016-06-28 22:28:29 +00:00
<?php
if (!defined("PHP_VERSION_ID") || PHP_VERSION_ID < 50500) {
2016-07-25 14:14:04 +00:00
$title = 'Unsupported PHP version';
2016-07-01 20:34:55 +00:00
$text =
'<p>You are using old, unsupported PHP version.</p>' .
'<p>Your PHP version: <b>' . PHP_VERSION . '</b>, required PHP version: <b>5.5.0</b>.</p>' .
'<p>Please update your PHP installation and try again.</p>';
2016-08-29 20:17:53 +00:00
showError($title, $text);
exit;
2016-08-29 20:17:53 +00:00
}
if (!function_exists("utf8_encode")) {
showExtensionMissingError("xml");
exit;
}
2016-08-29 20:17:53 +00:00
if (!extension_loaded("json")) {
showExtensionMissingError("json");
exit;
}
2016-07-01 20:34:55 +00:00
if (!extension_loaded("mbstring")) {
showExtensionMissingError("mbstring");
exit;
2016-07-01 01:03:44 +00:00
}
if((fileperms(__DIR__ . '/../cache') & 0777) !== 0777) {
$title = 'Cache directory is not writable';
$text =
'<p>Please make sure that the <code>cache</code> directory is fully readable, writable and executable.</p>' .
'<p>Running: <code>sudo chmod 777 -R ' . realpath(__DIR__ . '/../cache') . '</code> should fix the problem.</p>';
showError($title, $text);
exit;
2016-09-25 01:50:41 +00:00
}
if (!file_exists(__DIR__ . "/../config/config.php")) {
2016-07-25 14:14:04 +00:00
$title = 'config.php does not exists';
2016-07-01 20:34:55 +00:00
$text =
'<p>Please go into the directory <code>config</code> and rename <code>config.template.php</code> to <code>config.php</code>.</p>' .
'<p>Edit the new file and tweak it to suite your needs.</p>';
2016-07-01 20:34:55 +00:00
showError($title, $text);
exit;
2016-06-28 22:28:29 +00:00
}
2016-06-28 22:28:29 +00:00
// FUNCTION
function showExtensionMissingError($extension_name) {
$title = 'Required extension "' . $extension_name . '" is missing';
2018-03-29 15:16:50 +00:00
$text =
'<p>Required PHP extension <code>' . $extension_name . '</code> is missing or is not loaded.</p>' .
'<p>Install it and restart your server. Usually running <code>sudo apt-get install php-' . $extension_name . '</code> should be enough.</p>' .
'<p>If you still get this error, try restarting your web server and <code>php-fpm</code> service or just reboot your machine</p>' .
'<p>If you are using Web Hosting service, please contact their support for instructions on enabling <code>' . $extension_name . '</code> extension</p>';
showError($title, $text);
}
2016-06-28 22:28:29 +00:00
function showError($title, $text) { ?>
2016-06-28 21:18:59 +00:00
<!DOCTYPE html>
2016-09-25 10:24:29 +00:00
<html lang="en">
2016-06-28 21:18:59 +00:00
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="author" content="Wruczek">
2018-03-29 15:16:50 +00:00
<title><?php echo $title ?></title>
2016-06-28 21:18:59 +00:00
<!-- Icon -->
<link rel="shortcut icon" href="https://assets-cdn.github.com/images/icons/emoji/unicode/26a0.png">
<!-- Twitter Bootstrap -->
2016-08-14 02:31:15 +00:00
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootswatch/3.3.7/superhero/bootstrap.min.css" rel="stylesheet">
2016-06-28 21:18:59 +00:00
<!--[if IE]>
<script src="https://cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
2016-07-01 20:34:55 +00:00
2016-06-28 21:18:59 +00:00
<style>
body { margin-top: 70px }
</style>
</head>
<body>
<div class="container">
<div class="panel panel-default">
<div class="panel-heading">
2018-03-29 15:16:50 +00:00
<h3 class="panel-title"><img src="https://assets-cdn.github.com/images/icons/emoji/unicode/26a0.png" width="20px" alt="Error"> <?php echo $title ?></h3>
2016-06-28 21:18:59 +00:00
</div>
<div class="panel-body">
2018-03-29 15:16:50 +00:00
<?php echo $text ?>
2016-06-28 21:18:59 +00:00
</div>
2016-06-28 22:41:29 +00:00
<div class="panel-footer">
2018-01-26 02:02:24 +00:00
&copy; <a href="https://wruczek.tech">Wruczek</a> 2016 - 2018 | <a href="https://github.com/Wruczek/ts-website">ts-website</a> v 1.4.5 | MIT License
2016-06-28 22:41:29 +00:00
</div>
2016-06-28 21:18:59 +00:00
</div>
</div>
<!-- /container -->
</body>
</html>
2016-06-28 22:28:29 +00:00
<?php }