From 50d3d706fcce2831e190e7f092da068856a41b9f Mon Sep 17 00:00:00 2001
From: Jared Hancock <jared@osticket.com>
Date: Wed, 11 Dec 2013 11:37:12 -0600
Subject: [PATCH] Remove dependency on mbstring module

---
 bootstrap.php            | 7 +++++++
 include/class.ticket.php | 2 +-
 main.inc.php             | 2 +-
 3 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/bootstrap.php b/bootstrap.php
index 7d7bf3ca8..05d6d2302 100644
--- a/bootstrap.php
+++ b/bootstrap.php
@@ -236,6 +236,13 @@ class Bootstrap {
                     return preg_replace_callback('/\b\p{Ll}/u', 'mb_strtoupper', $str);
                 }
             }
+            function mb_internal_encoding($encoding) { return 'UTF-8'; }
+            function mb_regex_encoding($encoding) { return 'UTF-8'; }
+            function mb_substr_count($haystack, $needle) {
+                $matches = array();
+                return preg_match_all('`'.preg_quote($needle).'`u', $haystack,
+                    $matches);
+            }
         }
         else {
             // Use UTF-8 for all multi-byte string encoding
diff --git a/include/class.ticket.php b/include/class.ticket.php
index 51cbbf990..07e0650e8 100644
--- a/include/class.ticket.php
+++ b/include/class.ticket.php
@@ -23,7 +23,6 @@ include_once(INCLUDE_DIR.'class.topic.php');
 include_once(INCLUDE_DIR.'class.lock.php');
 include_once(INCLUDE_DIR.'class.file.php');
 include_once(INCLUDE_DIR.'class.attachment.php');
-include_once(INCLUDE_DIR.'class.pdf.php');
 include_once(INCLUDE_DIR.'class.banlist.php');
 include_once(INCLUDE_DIR.'class.template.php');
 include_once(INCLUDE_DIR.'class.variable.php');
@@ -1669,6 +1668,7 @@ class Ticket {
 
     //Print ticket... export the ticket thread as PDF.
     function pdfExport($psize='Letter', $notes=false) {
+        require_once(INCLUDE_DIR.'class.pdf.php');
         $pdf = new Ticket2PDF($this, $psize, $notes);
         $name='Ticket-'.$this->getExtId().'.pdf';
         $pdf->Output($name, 'I');
diff --git a/main.inc.php b/main.inc.php
index 924f72888..7feb271e7 100644
--- a/main.inc.php
+++ b/main.inc.php
@@ -23,8 +23,8 @@ if(isset($_SERVER['SCRIPT_NAME'])
 require('bootstrap.php');
 Bootstrap::loadConfig();
 Bootstrap::defineTables(TABLE_PREFIX);
-Bootstrap::loadCode();
 Bootstrap::i18n_prep();
+Bootstrap::loadCode();
 Bootstrap::connect();
 
 if(!($ost=osTicket::start()) || !($cfg = $ost->getConfig()))
-- 
GitLab