Skip to content

Commit

Permalink
using reliable temp folder writing / checking for access
Browse files Browse the repository at this point in the history
  • Loading branch information
dgershman committed Jan 8, 2019
1 parent 023b3f5 commit d0fd704
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 47 deletions.
97 changes: 52 additions & 45 deletions bmlt-meeting-list.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -131,6 +131,11 @@ function is_root_server_missing() {
$url = admin_url( 'options-general.php?page=bmlt-meeting-list.php' );
echo "<p><a href='$url'>Settings</a></p>";
echo '</div>';
} else if (!get_temp_dir()) {
echo '<div id="message" class="error"><p>' . get_temp_dir() . ' temporary directory is not writable.</p>';
$url = admin_url( 'options-general.php?page=bmlt-meeting-list.php' );
echo "<p><a href='$url'>Settings</a></p>";
echo '</div>';
}
add_action("admin_notices", array(
&$this,
Expand Down Expand Up @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions partials/_meeting_list_setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
<li><b>Protocol:</b> <?php echo $this->protocol; ?></li>
<li><b>PHP Version:</b> <?php echo phpversion(); ?></li>
<li><b>Server Version:</b> <?php echo $_SERVER["SERVER_SOFTWARE"]; ?></li>
<li><b>Temporary Directory:</b> <?php echo get_temp_dir(); ?></li>
</ul>
</div>
</div>
Expand Down
5 changes: 4 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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]
Expand Down

0 comments on commit d0fd704

Please sign in to comment.