Easy SSL Plugin for SAKURA Rental Server - Version 1.1

Version Description

=

Download this release

Release Info

Developer sakurainternet
Plugin Icon 128x128 Easy SSL Plugin for SAKURA Rental Server
Version 1.1
Comparing to
See all releases

Code changes from version 1.0 to 1.1

Files changed (3) hide show
  1. modules/model/force-ssl.php +73 -2
  2. readme.txt +7 -4
  3. sakura-rs-ssl.php +1 -1
modules/model/force-ssl.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * @package Sakura_Ssl
6
  * @author wokamoto <wokamoto@digitalcube.jp>
7
- * hideokamoto <hide.okamoto@digitalcube.jp>
8
  **/
9
 
10
  if ( ! defined( 'ABSPATH' ) ) {
@@ -78,7 +78,7 @@ class Force_ssl_sakura {
78
  return new WP_Error( 'Sakura SSL type Error', "Type:{$ssl_type} is invalid type." );
79
  break;
80
  }
81
- return insert_with_markers( $htaccess_file, self::HTACCESS_MARKER, $htaccess_template );
82
  }
83
 
84
  /**
@@ -262,4 +262,75 @@ class Force_ssl_sakura {
262
  add_filter( $hook, array( $this, 'replace_urls' ) );
263
  }
264
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
265
  }
4
  *
5
  * @package Sakura_Ssl
6
  * @author wokamoto <wokamoto@digitalcube.jp>
7
+ * hideokamoto <hide.okamoto@digitalcube.jp>
8
  **/
9
 
10
  if ( ! defined( 'ABSPATH' ) ) {
78
  return new WP_Error( 'Sakura SSL type Error', "Type:{$ssl_type} is invalid type." );
79
  break;
80
  }
81
+ return $this->_insert_sakura_ssl_with_markers( $htaccess_file, self::HTACCESS_MARKER, $htaccess_template );
82
  }
83
 
84
  /**
262
  add_filter( $hook, array( $this, 'replace_urls' ) );
263
  }
264
  }
265
+
266
+ private function _insert_sakura_ssl_with_markers( $filename, $marker, $insertion ) {
267
+ if ( ! file_exists( $filename ) ) {
268
+ if ( ! is_writable( dirname( $filename ) ) ) {
269
+ return false;
270
+ }
271
+ if ( ! touch( $filename ) ) {
272
+ return false;
273
+ }
274
+ } elseif ( ! is_writeable( $filename ) ) {
275
+ return false;
276
+ }
277
+ if ( ! is_array( $insertion ) ) {
278
+ $insertion = explode( "\n", $insertion );
279
+ }
280
+ $start_marker = "# BEGIN {$marker}";
281
+ $end_marker = "# END {$marker}";
282
+ $fp = fopen( $filename, 'r+' );
283
+ if ( ! $fp ) {
284
+ return false;
285
+ }
286
+ // Attempt to get a lock. If the filesystem supports locking, this will block until the lock is acquired.
287
+ flock( $fp, LOCK_EX );
288
+ $lines = array();
289
+ while ( ! feof( $fp ) ) {
290
+ $lines[] = rtrim( fgets( $fp ), "\r\n" );
291
+ }
292
+ // Split out the existing file into the preceding lines, and those that appear after the marker
293
+ $pre_lines = $post_lines = $existing_lines = array();
294
+ $found_marker = $found_end_marker = false;
295
+ foreach ( $lines as $line ) {
296
+ if ( ! $found_marker && false !== strpos( $line, $start_marker ) ) {
297
+ $found_marker = true;
298
+ continue;
299
+ } elseif ( ! $found_end_marker && false !== strpos( $line, $end_marker ) ) {
300
+ $found_end_marker = true;
301
+ continue;
302
+ }
303
+ if ( ! $found_marker ) {
304
+ $pre_lines[] = $line;
305
+ } elseif ( $found_marker && $found_end_marker ) {
306
+ $post_lines[] = $line;
307
+ } else {
308
+ $existing_lines[] = $line;
309
+ }
310
+ }
311
+ // Check to see if there was a change
312
+ if ( $existing_lines === $insertion ) {
313
+ flock( $fp, LOCK_UN );
314
+ fclose( $fp );
315
+ return true;
316
+ }
317
+ // Generate the new file data
318
+ $new_file_data = implode( "\n", array_merge(
319
+ array( $start_marker ),
320
+ $insertion,
321
+ array( $end_marker ),
322
+ $pre_lines,
323
+ $post_lines
324
+ ) );
325
+ // Write to the start of the file, and truncate it to that length
326
+ fseek( $fp, 0 );
327
+ $bytes = fwrite( $fp, $new_file_data );
328
+ if ( $bytes ) {
329
+ ftruncate( $fp, ftell( $fp ) );
330
+ }
331
+ fflush( $fp );
332
+ flock( $fp, LOCK_UN );
333
+ fclose( $fp );
334
+ return (bool) $bytes;
335
+ }
336
  }
readme.txt CHANGED
@@ -1,9 +1,9 @@
1
- === さくらのレンタルサーバ 簡単SSL化プラグイン ===
2
  Contributors: sakurainternet
3
  Tags: ssl
4
  Requires at least: 4.7.0
5
- Tested up to: 4.7.3
6
- Stable tag: 1.0
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -44,9 +44,12 @@ SSL証明書の購入や設定はお客様で事前に必要となりますの
44
 
45
  = 1.0 =
46
  * リリース
 
 
47
 
48
  == Upgrade Notice ==
49
 
50
-
51
  = 1.0 =
52
  * リリース
 
 
1
+ === Easy SSL Plugin for SAKURA Rental Server ===
2
  Contributors: sakurainternet
3
  Tags: ssl
4
  Requires at least: 4.7.0
5
+ Tested up to: 4.7.5
6
+ Stable tag: 1.1
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
44
 
45
  = 1.0 =
46
  * リリース
47
+ = 1.1 =
48
+ * パーマリンク設定されている場合に投稿ページがリダイレクトされない場合があるバグを修正
49
 
50
  == Upgrade Notice ==
51
 
 
52
  = 1.0 =
53
  * リリース
54
+ = 1.1 =
55
+ * パーマリンク設定されている場合に投稿ページがリダイレクトされない場合があるバグを修正
sakura-rs-ssl.php CHANGED
@@ -7,7 +7,7 @@
7
  * Plugin URI: https://help.sakura.ad.jp/hc/ja/articles/115000047641
8
  * Text Domain: sakura-rs-ssl
9
  * Domain Path: /languages
10
- * Version: 1.0
11
  *
12
  * @package Sakura_Ssl
13
  * License:
7
  * Plugin URI: https://help.sakura.ad.jp/hc/ja/articles/115000047641
8
  * Text Domain: sakura-rs-ssl
9
  * Domain Path: /languages
10
+ * Version: 1.1
11
  *
12
  * @package Sakura_Ssl
13
  * License: