Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2015-03-15 16:51:42

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,134
GitHub

Textpattern system requirements checker

I made a Textpattern system requirements checker for a weekend project:

https://github.com/petecooper/textpattern-system-requirements

Edit: repo deleted, code inlined here instead.

It’s rudimentary/ugly because I’m just starting to learn, but it seems to work pretty well on Unix-like operating systems.

Last edited by gaekwad (2015-08-06 21:59:40)

Offline

#2 2015-03-15 17:25:22

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,007
Website GitHub Mastodon Twitter

Re: Textpattern system requirements checker

Hi Pete

That is a great idea


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#3 2015-03-15 17:34:00

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,134
GitHub

Re: Textpattern system requirements checker

I picked up on a higher-than-usual frequency of people updating to to 4.5.7 from 4.4.x and not doing any preflight checks, which broke things on their neglected web servers.

It all started with this commit and I used it as the reason to start learning to code.

Last edited by gaekwad (2015-03-15 17:34:29)

Offline

#4 2015-08-06 21:58:27

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,134
GitHub

Re: Textpattern system requirements checker

I’m housekeeping, and deleting the repo mentioned in the OP. Latest code here for reference, if anyone wants to do anything with it:

<?php

/*
 *
 * Textpattern CMS system requirements checker
 * https://github.com/petecooper/textpattern-system-requirements
 *
 * Copyright (C) 2015 Pete Cooper
 *
 * Textpattern CMS system requirements checker is distributed in the hope that
 * it will be useful, but WITHOUT ANY WARRANTY; without even the implied
 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License with
 * Textpattern CMS system requirements checker. If not, see:
 * <http://www.gnu.org/licenses/>.
 *
 */


   $textpattern_version = "4.5.7";
   $php_version_minimum = "5.2.3";
   $php_version_recommended = "5.3.0";
   $mysql_version_minimum = "4.1.0";
   $mysql_version_recommended = "5.0.0";

   function function_mysql_version_installed() {
   $mysql_version_cli_output = shell_exec('mysql -V');
   preg_match('@[0-9]+\.[0-9]+\.[0-9]+@', $mysql_version_cli_output, $mysql_version_installed);
   return $mysql_version_installed[0]; 
   }

   function function_check_php_setting_exists($php_setting) {
   if (ini_get($php_setting) != "") {
      return ini_get($php_setting);
   }
      return false;
   }

   if (in_array('mod_rewrite',apache_get_modules())) {
   $apache_mod_rewrite_status = '<span class="yep">&#10003;</span>';
   }
   else {
   $apache_mod_rewrite_status = '<span class="nope">&#10007;</span>';
   }

?>

<!DOCTYPE html>
<html>
<head>
   <meta charset="UTF-8">
   <title>Textpattern CMS <?php echo $textpattern_version; ?> system requirements check</title>
   <style>td{padding:5px;}td.results{text-align:center;}td.muted{background-color:#ccc;}span.yep{color:#3f3;}span.nope{color:#f33;}</style>
</head>
<body>
<h1>Textpattern CMS system requirements checker</h1>
<strong><p>Checking system settings for compatibility&hellip;</p></strong>

<table border="1">
   <thead>
      <tr>
         <td colspan="2">&nbsp;</td>
         <td><strong>Minimum</strong></td>
         <td><strong>Recommended</strong></td>
      </tr>
   </thead>
   <tr>
      <td rowspan="8">PHP</td>
      <td>Version</td>
      <td class="results"><?php
         if (version_compare(phpversion(), $php_version_minimum, '>')) {
            echo '<span class="yep">&#10003;</span>';
         }
         else {
            echo '<span class="nope">&#10007;</span>';
         }
         ?><br /><small><?php echo $php_version_minimum; ?>+</small></td>
      <td class="results"><?php
         if (version_compare(phpversion(), $php_version_recommended, '>')) {
            echo '<span class="yep">&#10003;</span>';
         }
         else {
            echo '<span class="nope">&#10007;</span>';
         }
         ?><br /><small><?php echo $php_version_recommended; ?>+</small></td>
   </tr>
   <tr>
      <td>Mode</td>
      <td class="muted">&nbsp;</td>
      <td class="results"><?php
         $php_sapi_name_output = php_sapi_name();
         if ($php_sapi_name_output !== 'apache' && $php_sapi_name_output !== 'apache2filter' && $php_sapi_name_output !== 'apache2handler' && $php_sapi_name_output !== 'cgi-fcgi' ) {
            echo '<span class="nope">&#10007;</span>';
         }
         else {
            echo '<span class="yep">&#10003;</span>';
         }
         ?><br /><small>mod_php or fastcgi</small></td>
   </tr>
   <tr>
      <td><a href="http://www.php.net/manual/en/ref.mysql.php" rel="external">mysql</a></td>
      <td class="results"><?php
         if (extension_loaded(mysql)) {
            echo '<span class="yep">&#10003;</span>';
         }
         else {
            echo '<span class="nope">&#10007;</span>';
         }
         ?></td>
      <td class="muted">&nbsp;</td>
   </tr>
   <tr>
      <td><a href="http://www.php.net/manual/en/ref.xml.php" rel="external">XML</a></td>
      <td class="results"><?php
         if (extension_loaded(xml)) {
            echo '<span class="yep">&#10003;</span>';
         }
         else {
            echo '<span class="nope">&#10007;</span>';
         }
         ?></td>
      <td class="muted">&nbsp;</td>
   </tr>
   <tr>
      <td><a href="http://www.php.net/manual/en/ref.json.php" rel="external">JSON</a></td>
      <td class="results"><?php
         if (extension_loaded(json)) {
            echo '<span class="yep">&#10003;</span>';
         }
         else {
            echo '<span class="nope">&#10007;</span>';
         }
         ?></td>
      <td class="muted">&nbsp;</td>
   </tr>
   <tr>
      <td><a href="http://www.php.net/manual/en/ref.mbstring.php" rel="external">mbstring</a></td>
      <td class="muted">&nbsp;</td>
      <td class="results"><?php
         if (extension_loaded(mbstring)) {
            echo '<span class="yep">&#10003;</span>';
         }
         else {
            echo '<span class="nope">&#10007;</span>';
         }
         ?></td>
   </tr>
   <tr>
      <td><a href="http://www.php.net/manual/en/ref.zlib.php" rel="external">zlib</a></a></td>
      <td>&nbsp;</td>
      <td class="results"><?php
         if (extension_loaded(zlib)) {
            echo '<span class="yep">&#10003;</span>';
         }
         else {
            echo '<span class="nope">&#10007;</span>';
         }
         ?></td>
   </tr>
   <tr>
      <td><a href="http://php.net/manual/en/class.datetimezone.php" rel="external"><tt>date.timezone</tt></a></td>
      <td class="results"><?php
         if (ini_set("date.timezone")) {
            echo '<span class="yep">&#10003;</span>';
         }
         else {
            echo '<span class="nope">&#10007;</span>';
         }
         ?></td>
      <td class="muted">&nbsp;</td>
   </tr>
   <tr>
      <td>MySQL</td>
      <td>Version</td>
      <td class="results"><?php
         if (version_compare(function_mysql_version_installed(), $mysql_version_minimum, '>')) {
            echo '<span class="yep">&#10003;</span>';
         }
         else {
            echo '<span class="nope">&#10007;</span>';
         }
         ?><br /><small><?php echo $mysql_version_minimum; ?>+</small></td>
      <td class="results"><?php
         if (version_compare(function_mysql_version_installed(), $mysql_version_recommended, '>')) {
            echo '<span class="yep">&#10003;</span>';
         }
         else {
            echo '<span class="nope">&#10007;</span>';
         }
         ?><br /><small><?php echo $mysql_version_recommended; ?>+</small></td>
   </tr>
   <tr>
      <td rowspan="3">Apache<br />httpd</td>
      <td>Present</td>
      <td class="muted">&nbsp;</td>
      <td class="results"><?php
         $apache_get_version_output = apache_get_version();
         if (empty($apache_get_version_output)){
         echo '<span class="nope">&#10007;</span>';
         }
         else {
         echo '<span class="yep">&#10003;</span>';
         }
         ?></td>
   </tr>
   <tr>
      <td>Version</td>
      <td class="muted">&nbsp;</td>
      <td class="results"><?php
         echo preg_replace("/[^0-9.]/","", $apache_get_version_output);
         ?><br /><small>1.3+ or 2.0+</small></td>
   </tr>
   <tr>
      <td><tt>mod_rewrite</tt></td>
      <td class="muted">&nbsp;</td>
      <td class="results"><?php
         echo $apache_mod_rewrite_status;
         ?></td>
   </tr>
</table>

<strong><p>Additional details</p></strong>
<ul>
   <li>PHP version: <?php echo phpversion() ?></li>
   <li>MySQL version: <?php echo function_mysql_version_installed() ?></li>
   <li>Apache version: <?php echo apache_get_version() ?></li>
</ul>
</body>
</html>

Offline

#5 2015-08-07 13:03:11

Pat64
Plugin Author
From: France
Registered: 2005-12-12
Posts: 1,595
GitHub Twitter

Re: Textpattern system requirements checker

To be added into Textpattern CMS package (as lot of other CMS tools) ;)


Patrick.

Github | CodePen | Codier | Simplr theme | Wait Me: a maintenance theme | [\a mi.ni.ma]: a “Low Tech” simple Blog theme.

Offline

Board footer

Powered by FluxBB