From d0fd704ff0f970949f98c3a4bd8d9176aba7f315 Mon Sep 17 00:00:00 2001 From: Danny Gershman Date: Tue, 8 Jan 2019 01:15:18 -0500 Subject: [PATCH] using reliable temp folder writing / checking for access --- bmlt-meeting-list.php | 97 +++++++++++++++++--------------- docker-compose.yml | 2 +- partials/_meeting_list_setup.php | 1 + readme.txt | 5 +- 4 files changed, 58 insertions(+), 47 deletions(-) diff --git a/bmlt-meeting-list.php b/bmlt-meeting-list.php index 874dc1d..96301b9 100644 --- a/bmlt-meeting-list.php +++ b/bmlt-meeting-list.php @@ -4,7 +4,7 @@ Plugin URI: http://wordpress.org/extend/plugins/bread/ Description: Maintains and generates a PDF Meeting List from BMLT. Author: odathp, radius314, pjaudiomv, klgrimley -Version: 1.9.0 +Version: 1.9.1 */ /* Disallow direct access to the plugin file */ use Mpdf\Mpdf; @@ -131,6 +131,11 @@ function is_root_server_missing() { $url = admin_url( 'options-general.php?page=bmlt-meeting-list.php' ); echo "

Settings

"; echo ''; + } else if (!get_temp_dir()) { + echo '

' . get_temp_dir() . ' temporary directory is not writable.

'; + $url = admin_url( 'options-general.php?page=bmlt-meeting-list.php' ); + echo "

Settings

"; + echo '
'; } add_action("admin_notices", array( &$this, @@ -600,52 +605,54 @@ function bmlt_meeting_list($atts = null, $content = null) { $default_font = $this->options['base_font']; $mode = 's'; if ($default_font == 'arial' || $default_font == 'times' || $default_font == 'courier') { - $mpdf_init_options = [ - 'fontDir' => array( - __DIR__ . '/mpdf/vendor/mpdf/mpdf/ttfonts', - __DIR__ . '/fonts', - ), - 'mode' => $mode, - 'default_font_size' => 7, - 'fontdata' => [ - "arial" => [ - 'R' => "Arial.ttf", - 'B' => "ArialBold.ttf", - 'I' => "ArialItalic.ttf", - 'BI' => "ArialBoldItalic.ttf", - ], - "times" => [ - 'R' => "Times.ttf", - 'B' => "TimesBold.ttf", - 'I' => "TimesItalic.ttf", - 'BI' => "TimesBoldItalic.ttf", - ], - "courier" => [ - 'R' => "CourierNew.ttf", - 'B' => "CourierNewBold.ttf", - 'I' => "CourierNewItalic.ttf", - 'BI' => "CourierNewBoldItalic.ttf", - ] - ], - 'default_font' => $default_font, - 'margin_left' => $this->options['margin_left'], - 'margin_right' => $this->options['margin_right'], - 'margin_top' => $this->options['margin_top'], - 'margin_bottom' => $this->options['margin_bottom'], - 'orientation' => 'P' - ]; + $mpdf_init_options = [ + 'fontDir' => array( + __DIR__ . '/mpdf/vendor/mpdf/mpdf/ttfonts', + __DIR__ . '/fonts', + ), + 'tempDir' => get_temp_dir(), + 'mode' => $mode, + 'default_font_size' => 7, + 'fontdata' => [ + "arial" => [ + 'R' => "Arial.ttf", + 'B' => "ArialBold.ttf", + 'I' => "ArialItalic.ttf", + 'BI' => "ArialBoldItalic.ttf", + ], + "times" => [ + 'R' => "Times.ttf", + 'B' => "TimesBold.ttf", + 'I' => "TimesItalic.ttf", + 'BI' => "TimesBoldItalic.ttf", + ], + "courier" => [ + 'R' => "CourierNew.ttf", + 'B' => "CourierNewBold.ttf", + 'I' => "CourierNewItalic.ttf", + 'BI' => "CourierNewBoldItalic.ttf", + ] + ], + 'default_font' => $default_font, + 'margin_left' => $this->options['margin_left'], + 'margin_right' => $this->options['margin_right'], + 'margin_top' => $this->options['margin_top'], + 'margin_bottom' => $this->options['margin_bottom'], + 'orientation' => 'P' + ]; } else { - $mpdf_init_options = [ - 'mode' => $mode, - 'default_font_size' => 7, - 'default_font' => $default_font, - 'margin_left' => $this->options['margin_left'], - 'margin_right' => $this->options['margin_right'], - 'margin_top' => $this->options['margin_top'], - 'margin_bottom' => $this->options['margin_bottom'], - 'orientation' => 'P' - ]; + $mpdf_init_options = [ + 'mode' => $mode, + 'tempDir' => get_temp_dir(), + 'default_font_size' => 7, + 'default_font' => $default_font, + 'margin_left' => $this->options['margin_left'], + 'margin_right' => $this->options['margin_right'], + 'margin_top' => $this->options['margin_top'], + 'margin_bottom' => $this->options['margin_bottom'], + 'orientation' => 'P' + ]; } $this->mpdf = new mPDF(array_merge($mpdf_init_options, $page_type_settings)); diff --git a/docker-compose.yml b/docker-compose.yml index a4dffc5..afe416f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -15,7 +15,7 @@ services: - ./logs/:/var/log/apache2 mysql: - image: mysql:5.7 + image: mysql:5.6 restart: always environment: MYSQL_ROOT_PASSWORD: example diff --git a/partials/_meeting_list_setup.php b/partials/_meeting_list_setup.php index 3ed2721..430febe 100644 --- a/partials/_meeting_list_setup.php +++ b/partials/_meeting_list_setup.php @@ -77,6 +77,7 @@
  • Protocol: protocol; ?>
  • PHP Version:
  • Server Version:
  • +
  • Temporary Directory:
  • diff --git a/readme.txt b/readme.txt index 0d1e748..c1c919d 100644 --- a/readme.txt +++ b/readme.txt @@ -5,7 +5,7 @@ Tags: meeting list, bmlt, narcotics anonymous, na Requires at least: 4.0 Requires PHP: 5.6 Tested up to: 5.0.0 -Stable tag: 1.9.0 +Stable tag: 1.9.1 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html A web-based tool that creates, maintains and generates a PDF meeting list from BMLT. @@ -54,6 +54,9 @@ Follow all these steps, keep in mind that once you start using bread, it's not g == Changelog == += 1.9.1 = +* Added a check for checking if temp folder is writable. Using the Wordpress influenced temp folder. + = 1.9.0 = * Added a feature to change the start day of the week [#55] * Support for Swedish, better language support overall [#54]