Skip to content
This repository has been archived by the owner on Jun 25, 2024. It is now read-only.

TileServer-php checker #48

Open
1 of 4 tasks
daliborjanak opened this issue Jan 8, 2015 · 2 comments
Open
1 of 4 tasks

TileServer-php checker #48

daliborjanak opened this issue Jan 8, 2015 · 2 comments

Comments

@daliborjanak
Copy link
Collaborator

Create one single php file which will check if hosting is ready for installing tileserver. This script will do:

  • validate baseurl and display it
  • check mod rewrite
  • check support for sqlite
if (!extension_loaded('pdo_sqlite')) {
    # HTTP Error 500
    echo "PHP: PDO SQLite extension is not installed";
    die;
}
  • check version of php
@daliborjanak
Copy link
Collaborator Author

First draft:

<?php
$msg = array();
//php version
$version = phpversion();
if (strpos($version, '-') != FALSE) {
  $version = substr($version, 0, strpos($version, '-'));
}
$versionParts = explode('.', $version);
if ($versionParts[0] >= 5 && $versionParts[1] >= 2) {
  $msg[] = array('status' => 'success', 'message' => 'Your PHP version ' . $version . ' is supported!');
} else {
  $msg[] = array('status' => 'warning', 'message' => 'Your PHP version ' . $version . ' is NOT supported!');
}
//mod rewrite
$isModRewrite = false;
if (function_exists('apache_get_modules')) {
  $modules = apache_get_modules();
  if (in_array('mod_rewrite', $modules)) {
    $isModRewrite = true;
  }
} else {
  //check with getenv
  if (getenv('HTTP_MOD_REWRITE') == 'On') {
    $isModRewrite = true;
  }
}
//TODO: Htaccess??
if ($isModRewrite) {
  $msg[] = array('status' => 'success', 'message' => 'Mod_rewrite module is enabled!');
} else {
  $msg[] = array('status' => 'warning', 'message' => 'Mod_rewrite module is disabled!');
}
?>
<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <title>TileServer-PHP Checker</title>
    <style>
      ul{list-style-type: none;}
      li.success{color: green;}
      li.warning{color:red}
    </style>
  </head>
  <body>
    <h1>TileServer-PHP Checker</h1>
    <ul>
      <?php
      //print
      foreach ($msg as $message) {
        echo '<li class="' . $message['status'] . '">' . $message['message'] . '<li>';
      }
      ?>
    </ul>
  </body>
</html>

@daliborjanak
Copy link
Collaborator Author

Reported problem with PHP 7 check in #121

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

1 participant