mirror of
https://gitlab.com/ruany/litebans-php.git
synced 2025-05-23 16:32:45 +00:00
Add detection and error handling for extensions like pdo_mysql
This commit is contained in:
parent
c4afc1399f
commit
120bfd1a07
@ -28,7 +28,7 @@ class Check {
|
|||||||
if (!isset($uuid)) {
|
if (!isset($uuid)) {
|
||||||
if (filter_var($name, FILTER_VALIDATE_FLOAT)) {
|
if (filter_var($name, FILTER_VALIDATE_FLOAT)) {
|
||||||
echo "<br>";
|
echo "<br>";
|
||||||
$page->settings->redirect("info.php?id=$name&type=$type", false);
|
redirect("info.php?id=$name&type=$type", false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$name = htmlspecialchars($name, ENT_QUOTES, 'UTF-8');
|
$name = htmlspecialchars($name, ENT_QUOTES, 'UTF-8');
|
||||||
@ -42,7 +42,7 @@ class Check {
|
|||||||
}
|
}
|
||||||
|
|
||||||
echo "<br>";
|
echo "<br>";
|
||||||
$page->settings->redirect($href, false);
|
redirect($href, false);
|
||||||
/*
|
/*
|
||||||
$table = $page->settings->table['bans'];
|
$table = $page->settings->table['bans'];
|
||||||
|
|
||||||
|
46
error/missing-extensions.php
Normal file
46
error/missing-extensions.php
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<meta name="description" content="">
|
||||||
|
<title>litebans-php - Missing Extensions</title>
|
||||||
|
<link href="../inc/css/bootstrap.min.css" rel="stylesheet">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="container">
|
||||||
|
<div class="jumbotron">
|
||||||
|
<h2>Missing Extensions</h2><br>
|
||||||
|
<div class="text-warning">
|
||||||
|
The following PHP extensions are required by litebans-php but were not found:
|
||||||
|
<br>
|
||||||
|
<?php if (!extension_loaded("pdo_mysql")) {
|
||||||
|
echo "- <a class=\"text-danger\">pdo_mysql</a>";
|
||||||
|
} ?>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<?php
|
||||||
|
|
||||||
|
ob_start();
|
||||||
|
phpinfo();
|
||||||
|
$phpinfo = array('phpinfo' => array());
|
||||||
|
if (preg_match_all('#(?:<h2>(?:<a name=".*?">)?(.*?)(?:</a>)?</h2>)|(?:<tr(?: class=".*?")?><t[hd](?: class=".*?")?>(.*?)\s*</t[hd]>(?:<t[hd](?: class=".*?")?>(.*?)\s*</t[hd]>(?:<t[hd](?: class=".*?")?>(.*?)\s*</t[hd]>)?)?</tr>)#s', ob_get_clean(), $matches, PREG_SET_ORDER))
|
||||||
|
foreach ($matches as $match)
|
||||||
|
if (strlen($match[1]))
|
||||||
|
$phpinfo[$match[1]] = array();
|
||||||
|
elseif (isset($match[3]))
|
||||||
|
$phpinfo[end(array_keys($phpinfo))][$match[2]] = isset($match[4]) ? array($match[3], $match[4]) : $match[3];
|
||||||
|
else
|
||||||
|
$phpinfo[end(array_keys($phpinfo))][] = $match[2];
|
||||||
|
|
||||||
|
echo "These extensions can be enabled in php.ini.<br>";
|
||||||
|
echo "php.ini location: <a class=\"text-info\">" . $phpinfo['phpinfo']["Loaded Configuration File"] . "</a>";
|
||||||
|
?>
|
||||||
|
</div>
|
||||||
|
<br>
|
||||||
|
<a href="../" class="btn btn-default">Try Again</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
12
inc/init.php
Normal file
12
inc/init.php
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
function redirect($url, $showtext = true) {
|
||||||
|
if ($showtext === true) {
|
||||||
|
echo "<a href=\"$url\">Redirecting...</a>";
|
||||||
|
}
|
||||||
|
die("<script data-cfasync=\"false\" type=\"text/javascript\">document.location=\"$url\";</script>");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!extension_loaded("pdo_mysql")) {
|
||||||
|
redirect("error/missing-extensions.php");
|
||||||
|
}
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
require_once './inc/init.php';
|
||||||
|
|
||||||
class Page {
|
class Page {
|
||||||
public function __construct($name, $header = true) {
|
public function __construct($name, $header = true) {
|
||||||
|
@ -165,7 +165,7 @@ final class Settings {
|
|||||||
$this->driver = $driver;
|
$this->driver = $driver;
|
||||||
if ($connect) {
|
if ($connect) {
|
||||||
if ($username === "" && $password === "") {
|
if ($username === "" && $password === "") {
|
||||||
$this->redirect("error/unconfigured.php");
|
redirect("error/unconfigured.php");
|
||||||
}
|
}
|
||||||
$host = $this->host;
|
$host = $this->host;
|
||||||
$port = $this->port;
|
$port = $this->port;
|
||||||
@ -212,9 +212,9 @@ final class Settings {
|
|||||||
if ($settings->error_pages) {
|
if ($settings->error_pages) {
|
||||||
if (strstr($message, "Access denied for user")) {
|
if (strstr($message, "Access denied for user")) {
|
||||||
if ($settings->error_reporting) {
|
if ($settings->error_reporting) {
|
||||||
$settings->redirect("error/access-denied.php?error=" . base64_encode($message));
|
redirect("error/access-denied.php?error=" . base64_encode($message));
|
||||||
} else {
|
} else {
|
||||||
$settings->redirect("error/access-denied.php");
|
redirect("error/access-denied.php");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (strstr($message, "Base table or view not found:")) {
|
if (strstr($message, "Base table or view not found:")) {
|
||||||
@ -223,12 +223,12 @@ final class Settings {
|
|||||||
$st->fetch();
|
$st->fetch();
|
||||||
$st->closeCursor();
|
$st->closeCursor();
|
||||||
} catch (PDOException $e) {
|
} catch (PDOException $e) {
|
||||||
$settings->redirect("error/tables-not-found.php");
|
redirect("error/tables-not-found.php");
|
||||||
}
|
}
|
||||||
$settings->redirect("error/outdated-plugin.php");
|
redirect("error/outdated-plugin.php");
|
||||||
}
|
}
|
||||||
if (strstr($message, "Unknown column")) {
|
if (strstr($message, "Unknown column")) {
|
||||||
$settings->redirect("error/outdated-plugin.php");
|
redirect("error/outdated-plugin.php");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($settings->error_reporting === false) {
|
if ($settings->error_reporting === false) {
|
||||||
@ -238,13 +238,6 @@ final class Settings {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function redirect($url, $showtext = true) {
|
|
||||||
if ($showtext === true) {
|
|
||||||
echo "<a href=\"$url\">Redirecting...</a>";
|
|
||||||
}
|
|
||||||
echo "<script data-cfasync=\"false\" type=\"text/javascript\">document.location=\"$url\";</script>";
|
|
||||||
die;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function test_strftime() {
|
private function test_strftime() {
|
||||||
// If you modify this function, you may get an "Assertion failed" error.
|
// If you modify this function, you may get an "Assertion failed" error.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user