From 0ff567a08e30cc5c09b6df157133d46bc698c527 Mon Sep 17 00:00:00 2001
From: Jared Hancock <jared@osticket.com>
Date: Thu, 19 Jun 2014 11:14:44 -0500
Subject: [PATCH] Silently disable Phar usage if unsupported

---
 include/class.i18n.php           |  3 ++-
 include/class.plugin.php         |  1 +
 include/staff/system.inc.php     | 15 +++++++++++++++
 setup/inc/install-prereq.inc.php |  1 +
 4 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/include/class.i18n.php b/include/class.i18n.php
index 2c4d658f1..b61be4beb 100644
--- a/include/class.i18n.php
+++ b/include/class.i18n.php
@@ -277,7 +277,8 @@ class DataTemplate {
                 $this->filepath = Misc::realpath("{$this->base}/$l/$path");
                 break;
             }
-            elseif (Phar::isValidPharFilename("{$this->base}/$l.phar")
+            elseif (class_exists('Phar')
+                    && Phar::isValidPharFilename("{$this->base}/$l.phar")
                     && file_exists("phar://{$this->base}/$l.phar/$path")) {
                 $this->lang = $l;
                 $this->filepath = "phar://{$this->base}/$l.phar/$path";
diff --git a/include/class.plugin.php b/include/class.plugin.php
index 6a8ac830b..a86d661e4 100644
--- a/include/class.plugin.php
+++ b/include/class.plugin.php
@@ -180,6 +180,7 @@ class PluginManager {
                 GLOB_NOSORT|GLOB_BRACE) as $p) {
             $is_phar = false;
             if (substr($p, strlen($p) - 5) == '.phar'
+                    && class_exists('Phar')
                     && Phar::isValidPharFilename($p)) {
                 try {
                 // When public key is invalid, openssl throws a
diff --git a/include/staff/system.inc.php b/include/staff/system.inc.php
index 6b59f0a08..4cfb3608c 100644
--- a/include/staff/system.inc.php
+++ b/include/staff/system.inc.php
@@ -48,6 +48,21 @@ if(!defined('OSTADMININC') || !$thisstaff || !$thisstaff->isAdmin()) die('Access
                     echo extension_loaded('mbstring')?'check':'warning-sign'; ?>"></i></td>
                 <td>mbstring</td>
                 <td>Highly recommended for non western european language content</td></tr>
+            <tr><td><i class="icon icon-<?php
+                    echo extension_loaded('phar')?'check':'warning-sign'; ?>"></i></td>
+                <td>phar</td>
+                <td>Highly recommended for plugins and language packs</td></tr>
+        </tbody></table></td></tr>
+    <tr><td>PHP Settings</td>
+        <td><table><tbody>
+        <tr><td><i class="icon icon-<?php
+                echo extension_loaded('mbstring')?'check':'warning-sign'; ?>"></i>
+            </td><td>
+            <code>cgi.fix_pathinfo</code> =
+                <?php echo ini_get('cgi.fix_pathinfo'); ?>
+            </td><td>
+            <span class="faded">"1" is recommended if AJAX is not working</span>
+        </td></tr>
         </tbody></table></td></tr>
 </tbody>
 <thead>
diff --git a/setup/inc/install-prereq.inc.php b/setup/inc/install-prereq.inc.php
index f004ba688..fa86058ba 100644
--- a/setup/inc/install-prereq.inc.php
+++ b/setup/inc/install-prereq.inc.php
@@ -29,6 +29,7 @@ if(!defined('SETUPINC')) die('Kwaheri!');
                 <li class="<?php echo extension_loaded('json')?'yes':'no'; ?>">PHP JSON extension (faster performance)</li>
                 <li class="<?php echo extension_loaded('gettext')?'yes':'no'; ?>">Gettext is used for translations (faster performance)</li>
                 <li class="<?php echo extension_loaded('mbstring')?'yes':'no'; ?>">Mbstring is <b>strongly</b> recommended for all installations</li>
+                <li class="<?php echo extension_loaded('phar')?'yes':'no'; ?>">Phar is <b>strongly</b> recommended for plugins and language packs</li>
             </ul>
             <div id="bar">
                 <form method="post" action="install.php">
-- 
GitLab