1) Исправления в связи со сменой API MySQL
[openlib.git] / www / checkconfig.php
diff --git a/www/checkconfig.php b/www/checkconfig.php
new file mode 100644 (file)
index 0000000..bd92258
--- /dev/null
@@ -0,0 +1,103 @@
+<?php
+/**
+ * COPS (Calibre OPDS PHP Server) Configuration check
+ *
+ * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
+ * @author     Sébastien Lucas <sebastien@slucas.fr>
+ *
+ */
+    require_once ("config.php");
+    require_once ("base.php");
+    
+    header ("Content-Type:text/html; charset=UTF-8");
+    
+    $err = getURLParam ("err", -1);
+    $error = NULL;
+    switch ($err) {
+        case 1 :
+            $error = "Database error";
+            break;
+    }
+
+?>
+<!DOCTYPE html>
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+    <title>COPS Configuration Check</title>
+    <link rel="stylesheet" type="text/css" href="<?php echo getUrlWithVersion(getCurrentCss ()) ?>" media="screen" />
+</head>
+<body>
+<div class="container">
+    <header>
+        <div class="headcenter">
+            <h1>COPS Configuration Check</h1>
+        </div>
+    </header>
+    <div id="content" style="display: none;"></div>
+    <section>
+        <?php
+        if (!is_null ($error)) {
+        ?>
+        <article class="frontpage">
+            <h2>You've been redirected because COPS is not configured properly</h2>
+            <h4><?php echo $error ?></h4>
+        </article>
+        <?php
+        }
+        ?>
+        <article class="frontpage">
+            <h2>Check if GD is properly installed and loaded</h2>
+            <h4>
+            <?php 
+            if (extension_loaded('gd') && function_exists('gd_info')) {
+                echo "OK";
+            } else {
+                echo "Please install the php5-gd extension and make sure it's enabled";
+            }
+            ?>
+            </h4>
+        </article>
+        <article class="frontpage">
+            <h2>Check if MySQL is properly installed and loaded</h2>
+            <h4>
+            <?php 
+            if (extension_loaded('pdo_mysql')) {
+                echo "OK";
+            } else {
+                echo "Please install the php5-mysql extension and make sure it's enabled";
+            }
+            ?>
+            </h4>
+        </article>
+        <article class="frontpage">
+            <h2>Check if libxml is properly installed and loaded</h2>
+            <h4>
+            <?php 
+            if (extension_loaded('libxml')) {
+                echo "OK";
+            } else {
+                echo "Please make sure libxml is enabled";
+            }
+            ?>
+            </h4>
+        </article>
+        <article class="frontpage">
+            <h2>Check if database can be opened with PHP</h2>
+            <h4>
+            <?php 
+            try {
+                $db = new PDO('mysql:'. Base::getDbHost (), Base::getDbUser(), Base::getDbPasswd());
+                echo "Database OK";
+            } catch (Exception $e) {
+                echo "If the database is readable, check your php configuration. Exception detail : " . $e;
+            }
+            ?>
+            </h4>
+        </article>
+    </section>
+    <footer></footer>
+</div>
+</body>
+</html>
\ No newline at end of file