WordPress HTTPS (SSL) - Version 3.0.2

Version Description

  • Added setting to change where HTTPS settings appear in the admin panel.
  • Any element on an HTTP page that is set to HTTPS should be auto-corrected.
  • Bug Fix - Plugin should no longer interefere with editing posts and using images from the Media Library.
  • Bug Fix - Fixed major bug that occurred when site was installed in the base directory.
  • Bug Fix - File uploader should no longer produce an HTTP Error.
  • Bug Fix - Fixed performance issue that caused the login page to load for a long period of time.
  • Bug Fix - Proxy check should no longer interfere with RSS Feeds, HTML Validators, etc.
  • Bug Fix - Force SSL and SSL Front Page should no longer conflict.
  • Bug Fix - If Force SSL Exclusively is enabled and Secure Front Page is not (or the front page is not secured), links to the front page will be set to HTTP.
Download this release

Release Info

Developer Mvied
Plugin Icon wp plugin WordPress HTTPS (SSL)
Version 3.0.2
Comparing to
See all releases

Code changes from version 3.0.1 to 3.0.2

admin/css/settings.css CHANGED
@@ -76,6 +76,10 @@ img#submit-waiting {
76
  line-height: 32px;
77
  padding: 0;
78
  }
 
 
 
 
79
  #wordpress-https_settings #settings-reset {
80
  float: left;
81
  margin-right: 10px;
76
  line-height: 32px;
77
  padding: 0;
78
  }
79
+ #wordpress-https_settings label.label-radio {
80
+ display: block;
81
+ margin-top: 5px;
82
+ }
83
  #wordpress-https_settings #settings-reset {
84
  float: left;
85
  margin-right: 10px;
admin/templates/metabox/settings.php CHANGED
@@ -2,10 +2,12 @@
2
  $count = 1; // Used to restrict str_replace count
3
  $ssl_host = clone $this->getPlugin()->getHttpsUrl();
4
  $ssl_host = $ssl_host->setPort('')->setScheme('')->toString();
5
- $ssl_host = str_replace($this->getPlugin()->getHttpUrl()->getPath(), '', $ssl_host, $count);
 
 
6
  $ssl_host = rtrim($ssl_host, '/');
7
  ?>
8
- <form name="form" id="<?php echo $this->getPlugin()->getSlug(); ?>" method="post">
9
  <?php settings_fields($this->getPlugin()->getSlug()); ?>
10
 
11
  <table class="form-table">
@@ -56,6 +58,18 @@
56
  </fieldset>
57
  </td>
58
  </tr>
 
 
 
 
 
 
 
 
 
 
 
 
59
  <tr valign="top" id="debug_row">
60
  <th scope="row">Debug Mode</th>
61
  <td>
@@ -68,6 +82,17 @@
68
  </fieldset>
69
  </td>
70
  </tr>
 
 
 
 
 
 
 
 
 
 
 
71
  </table>
72
 
73
  <input type="hidden" name="action" value="save" />
2
  $count = 1; // Used to restrict str_replace count
3
  $ssl_host = clone $this->getPlugin()->getHttpsUrl();
4
  $ssl_host = $ssl_host->setPort('')->setScheme('')->toString();
5
+ if ( $this->getPlugin()->getHttpUrl()->getPath() != '/' ) {
6
+ $ssl_host = str_replace($this->getPlugin()->getHttpUrl()->getPath(), '', $ssl_host, $count);
7
+ }
8
  $ssl_host = rtrim($ssl_host, '/');
9
  ?>
10
+ <form name="form" id="<?php echo $this->getPlugin()->getSlug(); ?>" action="<?php echo $_SERVER['REQUEST_URI']; ?>" method="post">
11
  <?php settings_fields($this->getPlugin()->getSlug()); ?>
12
 
13
  <table class="form-table">
58
  </fieldset>
59
  </td>
60
  </tr>
61
+ <tr valign="top" id="ssl_proxy_row">
62
+ <th scope="row">Proxy</th>
63
+ <td>
64
+ <fieldset>
65
+ <label for="ssl_proxy" class="label-radio">
66
+ <input type="radio" name="ssl_proxy" value="0"<?php echo ((! $this->getPlugin()->getSetting('ssl_proxy')) ? ' checked="checked"' : ''); ?>> <span>No</span>
67
+ <input type="radio" name="ssl_proxy" value="auto"<?php echo (($this->getPlugin()->getSetting('ssl_proxy') === 'auto') ? ' checked="checked"' : ''); ?>> <span>Auto</span>
68
+ <input type="radio" name="ssl_proxy" value="1"<?php echo (($this->getPlugin()->getSetting('ssl_proxy') == 1) ? ' checked="checked"' : ''); ?>> <span>Yes</span>
69
+ </label>
70
+ </fieldset>
71
+ </td>
72
+ </tr>
73
  <tr valign="top" id="debug_row">
74
  <th scope="row">Debug Mode</th>
75
  <td>
82
  </fieldset>
83
  </td>
84
  </tr>
85
+ <tr valign="top" id="admin_menu_row">
86
+ <th scope="row">Admin Menu</th>
87
+ <td>
88
+ <fieldset>
89
+ <label for="admin_menu" class="label-radio">
90
+ <input type="radio" name="admin_menu" value="side"<?php echo (($this->getPlugin()->getSetting('admin_menu') === 'side') ? ' checked="checked"' : ''); ?>> <span>Admin Sidebar</span>
91
+ <input type="radio" name="admin_menu" value="settings"<?php echo (($this->getPlugin()->getSetting('admin_menu') === 'settings') ? ' checked="checked"' : ''); ?>> <span>General Settings</span>
92
+ </label>
93
+ </fieldset>
94
+ </td>
95
+ </tr>
96
  </table>
97
 
98
  <input type="hidden" name="action" value="save" />
lib/WordPressHTTPS.php CHANGED
@@ -6,6 +6,7 @@
6
  * @package WordPressHTTPS
7
  *
8
  */
 
9
  class WordPressHTTPS extends WordPressHTTPS_Plugin {
10
 
11
  /**
@@ -39,7 +40,9 @@ class WordPressHTTPS extends WordPressHTTPS_Plugin {
39
  'exclusive_https' => 0, // Exclusively force SSL on posts and pages with the `Force SSL` option checked.
40
  'frontpage' => 0, // Force SSL on front page
41
  'ssl_admin' => 0, // Force SSL Over Administration Panel (The same as FORCE_SSL_ADMIN)
 
42
  'debug' => 0, // Debug Mode
 
43
  );
44
 
45
  /**
@@ -118,7 +121,7 @@ class WordPressHTTPS extends WordPressHTTPS_Plugin {
118
  $this->getLogger()->log('SSL: ' . ( $this->isSsl() ? 'Yes' : 'No' ));
119
  $this->getLogger()->log('Diff Host: ' . ( $this->getSetting('ssl_host_diff') ? 'Yes' : 'No' ));
120
  $this->getLogger()->log('Subdomain: ' . ( $this->getSetting('ssl_host_subdomain') ? 'Yes' : 'No' ));
121
- $this->getLogger()->log('Proxy: ' . ( isset($_COOKIE['wp_proxy']) && $_COOKIE['wp_proxy'] == 1 ? 'Yes' : 'No') );
122
  $this->getLogger()->log('Secure External URLs: [ ' . implode(', ', (array)$this->getSetting('secure_external_urls')) . ' ]');
123
  $this->getLogger()->log('Unsecure External URLs: [ ' . implode(', ', (array)$this->getSetting('unsecure_external_urls')) . ' ]');
124
 
@@ -151,8 +154,10 @@ class WordPressHTTPS extends WordPressHTTPS_Plugin {
151
  $http_domain = $this->getHttpUrl()->getBaseHost();
152
  $https_domain = $this->getHttpsUrl()->getBaseHost();
153
 
154
- if ( $this->getHttpsUrl()->setScheme('http') != $this->getHttpUrl() && $http_domain == $https_domain ) {
155
  $this->setSetting('ssl_host_subdomain', 1);
 
 
156
  }
157
  }
158
  /**
@@ -188,9 +193,13 @@ class WordPressHTTPS extends WordPressHTTPS_Plugin {
188
  $url->setPort($this->getHttpsUrl()->getPort());
189
 
190
  if ( $this->getSetting('ssl_host_diff') && strpos($url->getPath(), $this->getHttpsUrl()->getPath()) === false ) {
191
- $url->setPath(str_replace($this->getHttpUrl()->getPath(), $this->getHttpsUrl()->getPath(), $url->getPath()));
 
 
 
 
192
  }
193
- return $url;
194
  } else {
195
  return $string;
196
  }
@@ -209,10 +218,10 @@ class WordPressHTTPS extends WordPressHTTPS_Plugin {
209
  $url->setHost($this->getHttpUrl()->getHost());
210
  $url->setPort($this->getHttpUrl()->getPort());
211
 
212
- if ( $this->getSetting('ssl_host_diff') && strpos($url->getPath(), $this->getHttpUrl()->getPath()) === false ) {
213
  $url->setPath(str_replace($this->getHttpsUrl()->getPath(), $this->getHttpUrl()->getPath(), $url->getPath()));
214
  }
215
- return $url;
216
  } else {
217
  return $string;
218
  }
@@ -225,10 +234,8 @@ class WordPressHTTPS extends WordPressHTTPS_Plugin {
225
  * @return bool
226
  */
227
  public function isSsl() {
228
- // Some extra checks for proxies and Shared SSL
229
- if ( isset($_COOKIE['wp_proxy']) && $_COOKIE['wp_proxy'] == true ) {
230
- return true;
231
- } else if ( is_ssl() && strpos($_SERVER['HTTP_HOST'], $this->getHttpsUrl()->getHost()) === false && $_SERVER['SERVER_ADDR'] != $_SERVER['HTTP_HOST'] ) {
232
  return false;
233
  } else if ( isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && strtolower($_SERVER['HTTP_X_FORWARDED_PROTO']) == 'https' ) {
234
  return true;
@@ -268,35 +275,58 @@ class WordPressHTTPS extends WordPressHTTPS_Plugin {
268
  }
269
 
270
  if ( $url ) {
271
- $url->setPath(rtrim(str_replace($this->getHttpUrl()->getPath(), $this->getHttpsUrl()->getPath(), $_SERVER['REQUEST_URI'])));
 
 
 
 
272
 
273
- // Use a cookie to detect redirect loops
274
- $redirect_count = ( isset($_COOKIE['redirect_count']) && is_numeric($_COOKIE['redirect_count']) ? (int)$_COOKIE['redirect_count']+1 : 1 );
275
- setcookie('redirect_count', $redirect_count, 0, '/', '.' . $url->getBaseHost());
 
 
 
 
 
 
 
 
 
 
276
 
277
- // If redirect count is 3 or higher, prevent redirect and log the redirect loop
278
- if ( $redirect_count >= 3 ) {
279
- setcookie('redirect_count', null, -time(), '/', '.' . $url->getBaseHost());
280
- $this->getLogger()->log('[ERROR] Redirect Loop!');
281
- // If no redirect loop, continue with redirect...
282
  } else {
283
- // Redirect
284
- if ( function_exists('wp_redirect') ) {
285
- wp_redirect($url, 301);
286
- } else {
287
- // End all output buffering and redirect
288
- while(@ob_end_clean());
289
-
290
- // If redirecting to an admin page
291
- if ( strpos($url->getPath(), 'wp-admin') !== false || strpos($url->getPath(), 'wp-login') !== false ) {
292
- $url = WordPressHTTPS_Url::fromString($this->getModule('Hooks')->wp_redirect_admin($url));
293
- }
294
-
295
- header("Location: " . $url);
296
  }
297
- exit();
 
298
  }
 
299
  }
300
  }
301
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
302
  }
6
  * @package WordPressHTTPS
7
  *
8
  */
9
+
10
  class WordPressHTTPS extends WordPressHTTPS_Plugin {
11
 
12
  /**
40
  'exclusive_https' => 0, // Exclusively force SSL on posts and pages with the `Force SSL` option checked.
41
  'frontpage' => 0, // Force SSL on front page
42
  'ssl_admin' => 0, // Force SSL Over Administration Panel (The same as FORCE_SSL_ADMIN)
43
+ 'ssl_proxy' => 0, // Proxy detection
44
  'debug' => 0, // Debug Mode
45
+ 'admin_menu' => 'side', // HTTPS Admin Menu location
46
  );
47
 
48
  /**
121
  $this->getLogger()->log('SSL: ' . ( $this->isSsl() ? 'Yes' : 'No' ));
122
  $this->getLogger()->log('Diff Host: ' . ( $this->getSetting('ssl_host_diff') ? 'Yes' : 'No' ));
123
  $this->getLogger()->log('Subdomain: ' . ( $this->getSetting('ssl_host_subdomain') ? 'Yes' : 'No' ));
124
+ $this->getLogger()->log('Proxy: ' . ( $this->getSetting('ssl_proxy') === 'auto' ? 'Auto' : ( $this->getSetting('ssl_proxy') ? 'Yes' : 'No' ) ));
125
  $this->getLogger()->log('Secure External URLs: [ ' . implode(', ', (array)$this->getSetting('secure_external_urls')) . ' ]');
126
  $this->getLogger()->log('Unsecure External URLs: [ ' . implode(', ', (array)$this->getSetting('unsecure_external_urls')) . ' ]');
127
 
154
  $http_domain = $this->getHttpUrl()->getBaseHost();
155
  $https_domain = $this->getHttpsUrl()->getBaseHost();
156
 
157
+ if ( $this->getHttpsUrl()->setScheme('http')->toString() != $this->getHttpUrl()->toString() && $http_domain == $https_domain ) {
158
  $this->setSetting('ssl_host_subdomain', 1);
159
+ } else {
160
+ $this->setSetting('ssl_host_subdomain', 0);
161
  }
162
  }
163
  /**
193
  $url->setPort($this->getHttpsUrl()->getPort());
194
 
195
  if ( $this->getSetting('ssl_host_diff') && strpos($url->getPath(), $this->getHttpsUrl()->getPath()) === false ) {
196
+ if ( $this->getHttpUrl()->getPath() == '/' ) {
197
+ $url->setPath(rtrim($this->getHttpsUrl()->getPath(), '/') . $url->getPath());
198
+ } else {
199
+ $url->setPath(str_replace($this->getHttpUrl()->getPath(), $this->getHttpsUrl()->getPath(), $url->getPath()));
200
+ }
201
  }
202
+ return $url->toString();
203
  } else {
204
  return $string;
205
  }
218
  $url->setHost($this->getHttpUrl()->getHost());
219
  $url->setPort($this->getHttpUrl()->getPort());
220
 
221
+ if ( $this->getSetting('ssl_host_diff') && strpos($url->getPath(), $this->getHttpsUrl()->getPath()) !== false ) {
222
  $url->setPath(str_replace($this->getHttpsUrl()->getPath(), $this->getHttpUrl()->getPath(), $url->getPath()));
223
  }
224
+ return $url->toString();
225
  } else {
226
  return $string;
227
  }
234
  * @return bool
235
  */
236
  public function isSsl() {
237
+ // Some extra checks for Shared SSL
238
+ if ( is_ssl() && strpos($_SERVER['HTTP_HOST'], $this->getHttpsUrl()->getHost()) === false && $_SERVER['SERVER_ADDR'] != $_SERVER['HTTP_HOST'] ) {
 
 
239
  return false;
240
  } else if ( isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && strtolower($_SERVER['HTTP_X_FORWARDED_PROTO']) == 'https' ) {
241
  return true;
275
  }
276
 
277
  if ( $url ) {
278
+ $path = $_SERVER['REQUEST_URI'];
279
+ if ( $this->getHttpsUrl()->getPath() != '/' ) {
280
+ $path = str_replace($this->getHttpsUrl()->getPath(), '', $path);
281
+ }
282
+ $path = ltrim($path, '/');
283
 
284
+ if ( $scheme == 'https' ) {
285
+ if ( $this->getSetting('ssl_host_diff') && $this->getHttpUrl()->getPath() != '/' ) {
286
+ $url->setPath(str_replace($this->getHttpUrl()->getPath(), $this->getHttpsUrl()->getPath(), $_SERVER['REQUEST_URI']));
287
+ } else {
288
+ $url->setPath(rtrim($this->getHttpsUrl()->getPath(), '/') . '/' . $path);
289
+ }
290
+ } else if ($scheme == 'http' ) {
291
+ if ( $this->getSetting('ssl_host_diff') && $this->getHttpsUrl()->getPath() != '/' ) {
292
+ $url->setPath(str_replace($this->getHttpsUrl()->getPath(), $this->getHttpUrl()->getPath(), $_SERVER['REQUEST_URI']));
293
+ } else {
294
+ $url->setPath(rtrim($this->getHttpUrl()->getPath(), '/') . '/' . $path);
295
+ }
296
+ }
297
 
298
+ // Redirect
299
+ if ( function_exists('wp_redirect') ) {
300
+ wp_redirect($url, 301);
 
 
301
  } else {
302
+ // End all output buffering and redirect
303
+ while(@ob_end_clean());
304
+
305
+ // If redirecting to an admin page
306
+ if ( strpos($url->getPath(), 'wp-admin') !== false || strpos($url->getPath(), 'wp-login') !== false ) {
307
+ $url = WordPressHTTPS_Url::fromString($this->redirectAdmin($url));
 
 
 
 
 
 
 
308
  }
309
+
310
+ header("Location: " . $url);
311
  }
312
+ exit();
313
  }
314
  }
315
 
316
+ /**
317
+ * WP Redirect Admin
318
+ * WordPress Filter - wp_redirect_admin
319
+ *
320
+ * @param string $url
321
+ * @return string $url
322
+ */
323
+ public function redirectAdmin( $url ) {
324
+ $url = $this->makeUrlHttps($url);
325
+
326
+ // Fix redirect_to
327
+ preg_match('/redirect_to=([^&]+)/i', $url, $redirect);
328
+ $redirect_url = @$redirect[1];
329
+ $url = str_replace($redirect_url, urlencode($this->makeUrlHttps(urldecode($redirect_url))), $url);
330
+ return $url;
331
+ }
332
  }
lib/WordPressHTTPS/Logger.php CHANGED
@@ -7,6 +7,8 @@
7
  *
8
  */
9
 
 
 
10
  class WordPressHTTPS_Logger implements WordPressHTTPS_Logger_Interface {
11
 
12
  /**
7
  *
8
  */
9
 
10
+ require_once('Logger/Interface.php');
11
+
12
  class WordPressHTTPS_Logger implements WordPressHTTPS_Logger_Interface {
13
 
14
  /**
lib/WordPressHTTPS/Module/Admin.php CHANGED
@@ -9,6 +9,9 @@
9
  *
10
  */
11
 
 
 
 
12
  class WordPressHTTPS_Module_Admin extends WordPressHTTPS_Module implements WordPressHTTPS_Module_Interface {
13
 
14
  /**
@@ -50,9 +53,11 @@ class WordPressHTTPS_Module_Admin extends WordPressHTTPS_Module implements WordP
50
  * @return void
51
  */
52
  public function menu() {
53
- add_menu_page('HTTPS', 'HTTPS', 'manage_options', $this->getPlugin()->getSlug(), array($this->getPlugin()->getModule('Admin\Settings'), 'dispatch'), '', 88);
54
- //remove_submenu_page( $this->getPlugin()->getSlug(), $this->getPlugin()->getSlug() );
55
- //add_submenu_page($this->getPlugin()->getSlug() . '-menu', 'Updates', 'Updates', 'manage_options', $this->getPlugin()->getSlug() . '-updates', array(&$this, 'dispatch'));
 
 
56
  }
57
 
58
  /**
9
  *
10
  */
11
 
12
+ require_once('WordPressHTTPS/Module.php');
13
+ require_once('WordPressHTTPS/Module/Interface.php');
14
+
15
  class WordPressHTTPS_Module_Admin extends WordPressHTTPS_Module implements WordPressHTTPS_Module_Interface {
16
 
17
  /**
53
  * @return void
54
  */
55
  public function menu() {
56
+ if ( $this->getPlugin()->getSetting('admin_menu') === 'side' ) {
57
+ add_menu_page('HTTPS', 'HTTPS', 'manage_options', $this->getPlugin()->getSlug(), array($this->getPlugin()->getModule('Admin\Settings'), 'dispatch'), '', 88);
58
+ } else {
59
+ add_options_page('HTTPS', 'HTTPS', 'manage_options', $this->getPlugin()->getSlug(), array($this->getPlugin()->getModule('Admin\Settings'), 'dispatch'));
60
+ }
61
  }
62
 
63
  /**
lib/WordPressHTTPS/Module/Admin/Post.php CHANGED
@@ -9,6 +9,9 @@
9
  *
10
  */
11
 
 
 
 
12
  class WordPressHTTPS_Module_Admin_Post extends WordPressHTTPS_Module implements WordPressHTTPS_Module_Interface {
13
 
14
  /**
9
  *
10
  */
11
 
12
+ require_once('WordPressHTTPS/Module.php');
13
+ require_once('WordPressHTTPS/Module/Interface.php');
14
+
15
  class WordPressHTTPS_Module_Admin_Post extends WordPressHTTPS_Module implements WordPressHTTPS_Module_Interface {
16
 
17
  /**
lib/WordPressHTTPS/Module/Admin/Settings.php CHANGED
@@ -9,6 +9,9 @@
9
  *
10
  */
11
 
 
 
 
12
  class WordPressHTTPS_Module_Admin_Settings extends WordPressHTTPS_Module implements WordPressHTTPS_Module_Interface {
13
 
14
  /**
@@ -23,7 +26,7 @@ class WordPressHTTPS_Module_Admin_Settings extends WordPressHTTPS_Module impleme
23
  add_action('plugins_loaded', array(&$this, 'save'), 1);
24
  }
25
 
26
- add_action('toplevel_page_' . $this->getPlugin()->getSlug(), array(&$this, 'add_meta_boxes'));
27
 
28
  // Add scripts
29
  add_action('admin_enqueue_scripts', array(&$this, 'enqueue_scripts'));
@@ -149,6 +152,7 @@ class WordPressHTTPS_Module_Admin_Settings extends WordPressHTTPS_Module impleme
149
  foreach ($this->getPlugin()->getSettings() as $key => $default) {
150
  $this->getPlugin()->setSetting($key, $default);
151
  }
 
152
  $reload = true;
153
  } else {
154
  foreach ($this->getPlugin()->getSettings() as $key => $default) {
@@ -166,7 +170,7 @@ class WordPressHTTPS_Module_Admin_Settings extends WordPressHTTPS_Module impleme
166
  $ssl_host = WordPressHTTPS_Url::fromString($_POST[$key]);
167
 
168
  // Add Port
169
- $port = ((isset($_POST['ssl_port']) && is_int($_POST['ssl_port']) ) ? $_POST['ssl_port'] : $ssl_host->port);
170
  $port = (($port != 80 && $port != 443) ? $port : null);
171
  $ssl_host->setPort($port);
172
 
@@ -194,6 +198,11 @@ class WordPressHTTPS_Module_Admin_Settings extends WordPressHTTPS_Module impleme
194
  } else {
195
  $_POST[$key] = get_option($key);
196
  }
 
 
 
 
 
197
  } else if ( $key == 'ssl_admin' ) {
198
  if ( force_ssl_admin() || force_ssl_login() ) {
199
  $errors[] = '<strong>SSL Admin</strong> - FORCE_SSL_ADMIN and FORCE_SSL_LOGIN can not be set to true in your wp-config.php.';
9
  *
10
  */
11
 
12
+ require_once('WordPressHTTPS/Module.php');
13
+ require_once('WordPressHTTPS/Module/Interface.php');
14
+
15
  class WordPressHTTPS_Module_Admin_Settings extends WordPressHTTPS_Module implements WordPressHTTPS_Module_Interface {
16
 
17
  /**
26
  add_action('plugins_loaded', array(&$this, 'save'), 1);
27
  }
28
 
29
+ add_action('admin_init', array(&$this, 'add_meta_boxes'));
30
 
31
  // Add scripts
32
  add_action('admin_enqueue_scripts', array(&$this, 'enqueue_scripts'));
152
  foreach ($this->getPlugin()->getSettings() as $key => $default) {
153
  $this->getPlugin()->setSetting($key, $default);
154
  }
155
+ $this->getPlugin()->install();
156
  $reload = true;
157
  } else {
158
  foreach ($this->getPlugin()->getSettings() as $key => $default) {
170
  $ssl_host = WordPressHTTPS_Url::fromString($_POST[$key]);
171
 
172
  // Add Port
173
+ $port = ((isset($_POST['ssl_port']) && is_int($_POST['ssl_port']) ) ? $_POST['ssl_port'] : $ssl_host->getPort());
174
  $port = (($port != 80 && $port != 443) ? $port : null);
175
  $ssl_host->setPort($port);
176
 
198
  } else {
199
  $_POST[$key] = get_option($key);
200
  }
201
+ } else if ( $key == 'ssl_proxy' ) {
202
+ // Reload if we're auto detecting the proxy and we're not in SSL
203
+ if ( $_POST[$key] == 'auto' && ! $this->getPlugin()->isSsl() ) {
204
+ $reload = true;
205
+ }
206
  } else if ( $key == 'ssl_admin' ) {
207
  if ( force_ssl_admin() || force_ssl_login() ) {
208
  $errors[] = '<strong>SSL Admin</strong> - FORCE_SSL_ADMIN and FORCE_SSL_LOGIN can not be set to true in your wp-config.php.';
lib/WordPressHTTPS/Module/Filters.php CHANGED
@@ -6,6 +6,10 @@
6
  * @package WordPressHTTPS
7
  *
8
  */
 
 
 
 
9
  class WordPressHTTPS_Module_Filters extends WordPressHTTPS_Module implements WordPressHTTPS_Module_Interface {
10
 
11
  /**
@@ -40,8 +44,8 @@ class WordPressHTTPS_Module_Filters extends WordPressHTTPS_Module implements Wor
40
  add_filter('stylesheet_directory_uri', array($this->getPlugin(), 'makeUrlHttps'), 10);
41
  }
42
 
43
- // Filter HTTPS from links in WP 3.0+
44
- if ( version_compare(get_bloginfo('version'), '3.0', '>') && !is_admin() && $this->getPlugin()->getHttpUrl()->getScheme() != 'https' ) {
45
  $filters = array('page_link', 'post_link', 'category_link', 'archives_link', 'tag_link', 'search_link');
46
  foreach( $filters as $filter ) {
47
  add_filter($filter, array($this->getPlugin(), 'makeUrlHttp'), 10);
@@ -51,7 +55,7 @@ class WordPressHTTPS_Module_Filters extends WordPressHTTPS_Module implements Wor
51
  add_filter('bloginfo_url', array(&$this, 'bloginfo'), 10, 2);
52
 
53
  // If the whole site is not HTTPS, set links to the front-end to HTTP from within the admin panel
54
- } else if ( is_admin() && $this->getPlugin()->isSsl() && $this->getPlugin()->getHttpUrl()->getScheme() != 'https' ) {
55
  $filters = array('page_link', 'post_link', 'category_link', 'get_archives_link', 'tag_link', 'search_link');
56
  foreach( $filters as $filter ) {
57
  add_filter($filter, array($this->getPlugin(), 'makeUrlHttp'), 10);
6
  * @package WordPressHTTPS
7
  *
8
  */
9
+
10
+ require_once('WordPressHTTPS/Module.php');
11
+ require_once('WordPressHTTPS/Module/Interface.php');
12
+
13
  class WordPressHTTPS_Module_Filters extends WordPressHTTPS_Module implements WordPressHTTPS_Module_Interface {
14
 
15
  /**
44
  add_filter('stylesheet_directory_uri', array($this->getPlugin(), 'makeUrlHttps'), 10);
45
  }
46
 
47
+ // Filter HTTPS from links
48
+ if ( ! is_admin() && WordPressHTTPS_Url::fromString( home_url('/') )->getScheme() != 'https' ) {
49
  $filters = array('page_link', 'post_link', 'category_link', 'archives_link', 'tag_link', 'search_link');
50
  foreach( $filters as $filter ) {
51
  add_filter($filter, array($this->getPlugin(), 'makeUrlHttp'), 10);
55
  add_filter('bloginfo_url', array(&$this, 'bloginfo'), 10, 2);
56
 
57
  // If the whole site is not HTTPS, set links to the front-end to HTTP from within the admin panel
58
+ } else if ( is_admin() && $this->getPlugin()->isSsl() && WordPressHTTPS_Url::fromString( home_url('/') )->getScheme() != 'https' ) {
59
  $filters = array('page_link', 'post_link', 'category_link', 'get_archives_link', 'tag_link', 'search_link');
60
  foreach( $filters as $filter ) {
61
  add_filter($filter, array($this->getPlugin(), 'makeUrlHttp'), 10);
lib/WordPressHTTPS/Module/Hooks.php CHANGED
@@ -7,6 +7,9 @@
7
  *
8
  */
9
 
 
 
 
10
  class WordPressHTTPS_Module_Hooks extends WordPressHTTPS_Module implements WordPressHTTPS_Module_Interface {
11
 
12
  /**
@@ -27,18 +30,24 @@ class WordPressHTTPS_Module_Hooks extends WordPressHTTPS_Module implements WordP
27
  }
28
 
29
  // Filter redirects in admin panel
30
- if ( is_admin() && $this->getPlugin()->isSsl() ) {
31
- add_action('wp_redirect', array(&$this, 'wp_redirect_admin'), 10, 1);
32
  }
33
  }
34
 
35
- /*
36
- * Run proxy check
37
- */
38
- if ( ! $this->getPlugin()->isSsl() && ! isset($_COOKIE['wp_proxy']) ) {
39
- add_action('init', array(&$this, 'proxy_check'), 1);
40
- add_action('admin_init', array(&$this, 'proxy_check'), 1);
41
- add_action('login_head', array(&$this, 'proxy_check'), 1);
 
 
 
 
 
 
42
  }
43
 
44
  // Check if the page needs to be redirected
@@ -55,6 +64,9 @@ class WordPressHTTPS_Module_Hooks extends WordPressHTTPS_Module implements WordP
55
  * @return void
56
  */
57
  public function proxy_check() {
 
 
 
58
  $cookie_expiration = gmdate('D, d-M-Y H:i:s T', strtotime('now + 10 years'));
59
  echo '<!-- WordPress HTTPS Proxy Check -->' . "\n";
60
  echo '<script type="text/javascript">function getCookie(a){var b=document.cookie;var c=a+"=";var d=b.indexOf("; "+c);if(d==-1){d=b.indexOf(c);if(d!=0)return null}else{d+=2;var e=document.cookie.indexOf(";",d);if(e==-1){e=b.length}}return unescape(b.substring(d+c.length,e))}if(getCookie("wp_proxy")!=true){if(window.location.protocol=="https:"){document.cookie="wp_proxy=1; path=/; expires=' . $cookie_expiration . '"}else if(getCookie("wp_proxy")==null){document.cookie="wp_proxy=0; path=/; expires=' . $cookie_expiration . '"}if(getCookie("wp_proxy")!=null){window.location.reload()}else{document.write("You must enable cookies.")}}</script>' . "\n";
@@ -78,14 +90,14 @@ class WordPressHTTPS_Module_Hooks extends WordPressHTTPS_Module implements WordP
78
  }
79
 
80
  if ( $post->ID > 0 ) {
81
- $force_ssl = apply_filters('force_ssl', $force_ssl, $post->ID );
82
  }
83
 
84
  // Secure Front Page
85
  if ( is_front_page() ) {
86
- if ( $this->getPlugin()->getSetting('frontpage') && ! $this->getPlugin()->isSsl() ) {
87
  $force_ssl = true;
88
- } else if ( ! $this->getPlugin()->getSetting('frontpage') && $this->getPlugin()->isSsl() && ( ! $this->getPlugin()->getSetting('ssl_host_diff') || ( $this->getPlugin()->getSetting('ssl_host_diff') && $this->getPlugin()->getSetting('ssl_admin') && ! is_user_logged_in() ) ) ) {
89
  $force_ssl = false;
90
  }
91
  }
@@ -111,23 +123,6 @@ class WordPressHTTPS_Module_Hooks extends WordPressHTTPS_Module implements WordP
111
  $this->getPlugin()->redirect($scheme);
112
  }
113
  }
114
-
115
- /**
116
- * WP Redirect Admin
117
- * WordPress Filter - wp_redirect_admin
118
- *
119
- * @param string $url
120
- * @return string $url
121
- */
122
- public function wp_redirect_admin( $url ) {
123
- $url = $this->getPlugin()->makeUrlHttps($url);
124
-
125
- // Fix redirect_to
126
- preg_match('/redirect_to=([^&]+)/i', $url, $redirect);
127
- $redirect_url = @$redirect[1];
128
- $url = str_replace($redirect_url, urlencode($this->getPlugin()->makeUrlHttps(urldecode($redirect_url))), $url);
129
- return $url;
130
- }
131
 
132
  /**
133
  * Set Cookie
@@ -141,9 +136,14 @@ class WordPressHTTPS_Module_Hooks extends WordPressHTTPS_Module implements WordP
141
  * @return void
142
  */
143
  public function set_cookie($cookie, $expire, $expiration, $user_id, $scheme) {
 
 
 
 
 
144
  if( $scheme == 'logged_in' ) {
145
  $cookie_name = LOGGED_IN_COOKIE;
146
- } elseif ( $secure || ( $this->getPlugin()->isSsl() && $this->getPlugin()->getSetting('ssl_host_diff') ) ) {
147
  $cookie_name = SECURE_AUTH_COOKIE;
148
  $scheme = 'secure_auth';
149
  } else {
@@ -157,7 +157,7 @@ class WordPressHTTPS_Module_Hooks extends WordPressHTTPS_Module implements WordP
157
  $cookie_path_plugins = PLUGINS_COOKIE_PATH;
158
  $cookie_path_admin = ADMIN_COOKIE_PATH;
159
 
160
- if ( $this->getPlugin()->getSetting('ssl_host_diff') && $this->getPlugin()->isSsl() ) {
161
  // If SSL Host is a subdomain, make cookie domain a wildcard
162
  if ( $this->getPlugin()->getSetting('ssl_host_subdomain') ) {
163
  $cookie_domain = '.' . $this->getPlugin()->getHttpsUrl()->getBaseHost();
@@ -165,19 +165,22 @@ class WordPressHTTPS_Module_Hooks extends WordPressHTTPS_Module implements WordP
165
  } else {
166
  $cookie_domain = $this->getPlugin()->getHttpsUrl()->getHost();
167
  }
168
-
169
- $cookie_path = str_replace($this->getPlugin()->getHttpsUrl()->getPath(), '', $cookie_path);
170
- $cookie_path = str_replace($this->getPlugin()->getHttpUrl()->getPath(), '', $cookie_path);
171
- $cookie_path = rtrim($this->getPlugin()->getHttpsUrl()->getPath(), '/') . '/' . $cookie_path;
172
-
173
- $cookie_path_site = str_replace($this->getPlugin()->getHttpsUrl()->getPath(), '', $cookie_path_site);
174
- $cookie_path_site = str_replace($this->getPlugin()->getHttpUrl()->getPath(), '', $cookie_path_site);
175
- $cookie_path_site = rtrim($this->getPlugin()->getHttpsUrl()->getPath(), '/') . '/' . $cookie_path_site;
176
 
177
- $cookie_path_plugins = str_replace($this->getPlugin()->getHttpsUrl()->getPath(), '', $cookie_path_plugins);
178
- $cookie_path_plugins = str_replace($this->getPlugin()->getHttpUrl()->getPath(), '', $cookie_path_plugins);
179
- $cookie_path_plugins = rtrim($this->getPlugin()->getHttpsUrl()->getPath(), '/') . '/' . $cookie_path_plugins;
 
 
 
 
 
 
 
 
180
 
 
 
 
181
  $cookie_path_admin = $cookie_path_site . 'wp-admin';
182
  }
183
 
@@ -187,7 +190,7 @@ class WordPressHTTPS_Module_Hooks extends WordPressHTTPS_Module implements WordP
187
  if ( $cookie_path != $cookie_path_site ) {
188
  setcookie($cookie_name, $cookie, $expire, $cookie_path_site, $cookie_domain, $secure, true);
189
  }
190
- } else {
191
  setcookie($cookie_name, $cookie, $expire, $cookie_path_plugins, $cookie_domain, false, true);
192
  setcookie($cookie_name, $cookie, $expire, $cookie_path_admin, $cookie_domain, false, true);
193
  }
@@ -201,17 +204,40 @@ class WordPressHTTPS_Module_Hooks extends WordPressHTTPS_Module implements WordP
201
  * @return void
202
  */
203
  public function clear_cookies() {
204
- $cookie_domain = '.' . $this->getPlugin()->getHttpsUrl()->getBaseHost();
205
- $cookie_path = rtrim(parse_url($this->getPlugin()->getHttpsUrl(), PHP_URL_PATH), '/') . COOKIEPATH;
206
- $cookie_path_site = rtrim(parse_url($this->getPlugin()->getHttpsUrl(), PHP_URL_PATH), '/') . SITECOOKIEPATH;
207
- $cookie_path_plugins = rtrim(parse_url($this->getPlugin()->getHttpsUrl(), PHP_URL_PATH), '/') . PLUGINS_COOKIE_PATH;
208
- $cookie_path_admin = $cookie_path_site . 'wp-admin';
209
-
210
  if ( $this->getPlugin()->getSetting('ssl_host_subdomain') ) {
211
- setcookie(LOGGED_IN_COOKIE, ' ', time() - 31536000, $cookie_path, $cookie_domain);
212
- setcookie(LOGGED_IN_COOKIE, ' ', time() - 31536000, $cookie_path_site, $cookie_domain);
 
213
  }
214
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
215
  setcookie(AUTH_COOKIE, ' ', time() - 31536000, $cookie_path_admin);
216
  setcookie(AUTH_COOKIE, ' ', time() - 31536000, $cookie_path_plugins);
217
  setcookie(SECURE_AUTH_COOKIE, ' ', time() - 31536000, $cookie_path_admin);
7
  *
8
  */
9
 
10
+ require_once('WordPressHTTPS/Module.php');
11
+ require_once('WordPressHTTPS/Module/Interface.php');
12
+
13
  class WordPressHTTPS_Module_Hooks extends WordPressHTTPS_Module implements WordPressHTTPS_Module_Interface {
14
 
15
  /**
30
  }
31
 
32
  // Filter redirects in admin panel
33
+ if ( is_admin() && $this->getPlugin()->getSetting('ssl_admin') ) {
34
+ add_action('wp_redirect', array($this->getPlugin(), 'redirectAdmin'), 10, 1);
35
  }
36
  }
37
 
38
+ // Run proxy check
39
+ if ( $this->getPlugin()->getSetting('ssl_proxy') === 'auto' ) {
40
+ // If page is not SSL and no proxy cookie is detected, run proxy check
41
+ if ( ! $this->getPlugin()->isSsl() && ! isset($_COOKIE['wp_proxy']) ) {
42
+ add_action('init', array(&$this, 'proxy_check'), 1);
43
+ add_action('admin_init', array(&$this, 'proxy_check'), 1);
44
+ // Update ssl_proxy setting if a proxy has been detected
45
+ } else if ( $this->getPlugin()->getSetting('ssl_proxy') !== true && isset($_COOKIE['wp_proxy']) && $_COOKIE['wp_proxy'] == 1 ) {
46
+ $this->getPlugin()->setSetting('ssl_proxy', 1);
47
+ // Update ssl_proxy if proxy is no longer detected
48
+ } else if ( $this->getPlugin()->getSetting('ssl_proxy') !== false && isset($_COOKIE['wp_proxy']) && $_COOKIE['wp_proxy'] != 1 ) {
49
+ $this->getPlugin()->setSetting('ssl_proxy', 0);
50
+ }
51
  }
52
 
53
  // Check if the page needs to be redirected
64
  * @return void
65
  */
66
  public function proxy_check() {
67
+ if ( ! is_user_logged_in() ) {
68
+ return false;
69
+ }
70
  $cookie_expiration = gmdate('D, d-M-Y H:i:s T', strtotime('now + 10 years'));
71
  echo '<!-- WordPress HTTPS Proxy Check -->' . "\n";
72
  echo '<script type="text/javascript">function getCookie(a){var b=document.cookie;var c=a+"=";var d=b.indexOf("; "+c);if(d==-1){d=b.indexOf(c);if(d!=0)return null}else{d+=2;var e=document.cookie.indexOf(";",d);if(e==-1){e=b.length}}return unescape(b.substring(d+c.length,e))}if(getCookie("wp_proxy")!=true){if(window.location.protocol=="https:"){document.cookie="wp_proxy=1; path=/; expires=' . $cookie_expiration . '"}else if(getCookie("wp_proxy")==null){document.cookie="wp_proxy=0; path=/; expires=' . $cookie_expiration . '"}if(getCookie("wp_proxy")!=null){window.location.reload()}else{document.write("You must enable cookies.")}}</script>' . "\n";
90
  }
91
 
92
  if ( $post->ID > 0 ) {
93
+ $force_ssl = apply_filters('force_ssl', null, $post->ID );
94
  }
95
 
96
  // Secure Front Page
97
  if ( is_front_page() ) {
98
+ if ( $this->getPlugin()->getSetting('frontpage') ) {
99
  $force_ssl = true;
100
+ } else if ( ! $this->getPlugin()->getSetting('frontpage') && $this->getPlugin()->getSetting('exclusive_https') && ( ! $this->getPlugin()->getSetting('ssl_host_diff') || ( $this->getPlugin()->getSetting('ssl_host_diff') && $this->getPlugin()->getSetting('ssl_admin') && ! is_user_logged_in() ) ) ) {
101
  $force_ssl = false;
102
  }
103
  }
123
  $this->getPlugin()->redirect($scheme);
124
  }
125
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
126
 
127
  /**
128
  * Set Cookie
136
  * @return void
137
  */
138
  public function set_cookie($cookie, $expire, $expiration, $user_id, $scheme) {
139
+ if ( ( $scheme == 'secure_auth' && $this->getPlugin()->isSsl() ) || ( $this->getPlugin()->getSetting('ssl_admin') && ! $this->getPlugin()->getSetting('ssl_host_subdomain') ) ) {
140
+ $secure = true;
141
+ }
142
+ $secure = apply_filters('secure_auth_cookie', $secure, $user_id);
143
+
144
  if( $scheme == 'logged_in' ) {
145
  $cookie_name = LOGGED_IN_COOKIE;
146
+ } elseif ( $secure ) {
147
  $cookie_name = SECURE_AUTH_COOKIE;
148
  $scheme = 'secure_auth';
149
  } else {
157
  $cookie_path_plugins = PLUGINS_COOKIE_PATH;
158
  $cookie_path_admin = ADMIN_COOKIE_PATH;
159
 
160
+ if ( $this->getPlugin()->isSsl() ) {
161
  // If SSL Host is a subdomain, make cookie domain a wildcard
162
  if ( $this->getPlugin()->getSetting('ssl_host_subdomain') ) {
163
  $cookie_domain = '.' . $this->getPlugin()->getHttpsUrl()->getBaseHost();
165
  } else {
166
  $cookie_domain = $this->getPlugin()->getHttpsUrl()->getHost();
167
  }
 
 
 
 
 
 
 
 
168
 
169
+ if ( $this->getPlugin()->getHttpsUrl()->getPath() != '/' ) {
170
+ $cookie_path = str_replace($this->getPlugin()->getHttpsUrl()->getPath(), '', $cookie_path);
171
+ $cookie_path_site = str_replace($this->getPlugin()->getHttpsUrl()->getPath(), '', $cookie_path_site);
172
+ $cookie_path_plugins = str_replace($this->getPlugin()->getHttpsUrl()->getPath(), '', $cookie_path_plugins);
173
+ }
174
+
175
+ if ( $this->getPlugin()->getHttpUrl()->getPath() != '/' ) {
176
+ $cookie_path = str_replace($this->getPlugin()->getHttpUrl()->getPath(), '', $cookie_path);
177
+ $cookie_path_site = str_replace($this->getPlugin()->getHttpUrl()->getPath(), '', $cookie_path_site);
178
+ $cookie_path_plugins = str_replace($this->getPlugin()->getHttpUrl()->getPath(), '', $cookie_path_plugins);
179
+ }
180
 
181
+ $cookie_path = rtrim($this->getPlugin()->getHttpsUrl()->getPath(), '/') . $cookie_path;
182
+ $cookie_path_site = rtrim($this->getPlugin()->getHttpsUrl()->getPath(), '/') . $cookie_path_site;
183
+ $cookie_path_plugins = rtrim($this->getPlugin()->getHttpsUrl()->getPath(), '/') . $cookie_path_plugins;
184
  $cookie_path_admin = $cookie_path_site . 'wp-admin';
185
  }
186
 
190
  if ( $cookie_path != $cookie_path_site ) {
191
  setcookie($cookie_name, $cookie, $expire, $cookie_path_site, $cookie_domain, $secure, true);
192
  }
193
+ } else {
194
  setcookie($cookie_name, $cookie, $expire, $cookie_path_plugins, $cookie_domain, false, true);
195
  setcookie($cookie_name, $cookie, $expire, $cookie_path_admin, $cookie_domain, false, true);
196
  }
204
  * @return void
205
  */
206
  public function clear_cookies() {
 
 
 
 
 
 
207
  if ( $this->getPlugin()->getSetting('ssl_host_subdomain') ) {
208
+ $cookie_domain = '.' . $this->getPlugin()->getHttpsUrl()->getBaseHost();
209
+ } else {
210
+ $cookie_domain = $this->getPlugin()->getHttpsUrl()->getHost();
211
  }
212
 
213
+ $cookie_path = COOKIEPATH;
214
+ $cookie_path_site = SITECOOKIEPATH;
215
+ $cookie_path_plugins = PLUGINS_COOKIE_PATH;
216
+
217
+ if ( $this->getPlugin()->getHttpsUrl()->getPath() != '/' ) {
218
+ $cookie_path = str_replace($this->getPlugin()->getHttpsUrl()->getPath(), '', $cookie_path);
219
+ $cookie_path_site = str_replace($this->getPlugin()->getHttpsUrl()->getPath(), '', $cookie_path_site);
220
+ $cookie_path_plugins = str_replace($this->getPlugin()->getHttpsUrl()->getPath(), '', $cookie_path_plugins);
221
+ }
222
+
223
+ if ( $this->getPlugin()->getHttpUrl()->getPath() != '/' ) {
224
+ $cookie_path = str_replace($this->getPlugin()->getHttpUrl()->getPath(), '', $cookie_path);
225
+ $cookie_path_site = str_replace($this->getPlugin()->getHttpUrl()->getPath(), '', $cookie_path_site);
226
+ $cookie_path_plugins = str_replace($this->getPlugin()->getHttpUrl()->getPath(), '', $cookie_path_plugins);
227
+ }
228
+
229
+ $cookie_path = rtrim($this->getPlugin()->getHttpsUrl()->getPath(), '/') . $cookie_path;
230
+ $cookie_path_site = rtrim($this->getPlugin()->getHttpsUrl()->getPath(), '/') . $cookie_path_site;
231
+ $cookie_path_plugins = rtrim($this->getPlugin()->getHttpsUrl()->getPath(), '/') . $cookie_path_plugins;
232
+ $cookie_path_admin = $cookie_path_site . 'wp-admin';
233
+
234
+ setcookie(AUTH_COOKIE, ' ', time() - 31536000, $cookie_path_admin, $cookie_domain);
235
+ setcookie(AUTH_COOKIE, ' ', time() - 31536000, $cookie_path_plugins, $cookie_domain);
236
+ setcookie(SECURE_AUTH_COOKIE, ' ', time() - 31536000, $cookie_path_admin, $cookie_domain);
237
+ setcookie(SECURE_AUTH_COOKIE, ' ', time() - 31536000, $cookie_path_plugins, $cookie_domain);
238
+ setcookie(LOGGED_IN_COOKIE, ' ', time() - 31536000, $cookie_path, $cookie_domain);
239
+ setcookie(LOGGED_IN_COOKIE, ' ', time() - 31536000, $cookie_path_site, $cookie_domain);
240
+
241
  setcookie(AUTH_COOKIE, ' ', time() - 31536000, $cookie_path_admin);
242
  setcookie(AUTH_COOKIE, ' ', time() - 31536000, $cookie_path_plugins);
243
  setcookie(SECURE_AUTH_COOKIE, ' ', time() - 31536000, $cookie_path_admin);
lib/WordPressHTTPS/Module/Parser.php CHANGED
@@ -7,6 +7,9 @@
7
  *
8
  */
9
 
 
 
 
10
  class WordPressHTTPS_Module_Parser extends WordPressHTTPS_Module implements WordPressHTTPS_Module_Interface {
11
 
12
  /**
@@ -32,7 +35,7 @@ class WordPressHTTPS_Module_Parser extends WordPressHTTPS_Module implements Word
32
  * @return $this
33
  */
34
  public function addSecureExternalUrl( $value ) {
35
- if ( $value == '' ) {
36
  return $this;
37
  }
38
 
@@ -50,7 +53,7 @@ class WordPressHTTPS_Module_Parser extends WordPressHTTPS_Module implements Word
50
  * @return $this
51
  */
52
  public function addUnsecureExternalUrl( $value ) {
53
- if ( $value == '' ) {
54
  return $this;
55
  }
56
 
@@ -83,6 +86,7 @@ class WordPressHTTPS_Module_Parser extends WordPressHTTPS_Module implements Word
83
  public function parseHtml( $buffer ) {
84
  $this->_html = $buffer;
85
 
 
86
  $this->fixLinksAndForms();
87
  $this->fixExtensions();
88
  $this->fixElements();
@@ -117,21 +121,28 @@ class WordPressHTTPS_Module_Parser extends WordPressHTTPS_Module implements Word
117
  public function secureElement( $url, $type = '' ) {
118
  $updated = false;
119
  $url = WordPressHTTPS_Url::fromString($url);
 
 
 
120
  // If local
121
  if ( $this->getPlugin()->isUrlLocal($url) ) {
122
- $updated = $this->getPlugin()->makeUrlHttps($url);
123
- $this->_html = str_replace($url, $updated, $this->_html);
 
 
124
  // If external and not HTTPS
125
  } else if ( $url->getPath() != 'https' ) {
126
  if ( @in_array($url->toString(), $this->getPlugin()->getSetting('secure_external_urls')) == false && @in_array($url->toString(), $this->getPlugin()->getSetting('unsecure_external_urls')) == false ) {
127
- $test_url = clone $url;
128
- $test_url->setScheme('https');
129
- if ( $test_url->isValid() ) {
130
- // Cache this URL as available over HTTPS for future reference
131
- $this->addSecureExternalUrl($url->toString());
132
- } else {
133
- // If not available over HTTPS, mark as an unsecure external URL
134
- $this->addUnsecureExternalUrl($url->toString());
 
 
135
  }
136
  }
137
 
@@ -153,6 +164,64 @@ class WordPressHTTPS_Module_Parser extends WordPressHTTPS_Module implements Word
153
  }
154
  }
155
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
156
  /**
157
  * Fix Elements
158
  *
@@ -162,46 +231,30 @@ class WordPressHTTPS_Module_Parser extends WordPressHTTPS_Module implements Word
162
  * @return void
163
  */
164
  public function fixElements() {
165
- // Fix any occurrence of the HTTPS version of the regular domain when using different SSL Host
166
- if ( $this->getPlugin()->getSetting('ssl_host_diff') ) {
167
- $url = clone $this->getPlugin()->getHttpUrl();
168
- $url->setScheme('https');
169
-
170
- $count = substr_count($this->_html, $url);
171
- if ( $count > 0 ) {
172
- $this->getPlugin()->getLogger()->log('[FIXED] Updated ' . $count . ' Occurrences of URL: ' . $url . ' => ' . $this->getPlugin()->makeUrlHttp($url));
173
- $this->_html = str_replace($url, $this->getPlugin()->makeUrlHttp($url), $this->_html);
174
- }
175
  }
176
 
177
- if ( $this->getPlugin()->isSsl() ) {
178
- if ( is_admin() ) {
179
- preg_match_all('/\<(script|link|img)[^>]+[\'"]((http):\/\/[^\'"]+)[\'"][^>]*>/im', $this->_html, $matches);
180
- } else {
181
- preg_match_all('/\<(script|link|img|input|embed|param)[^>]+[\'"]((http):\/\/[^\'"]+)[\'"][^>]*>/im', $this->_html, $matches);
182
- }
183
- for ($i = 0; $i < sizeof($matches[0]); $i++) {
184
- $html = $matches[0][$i];
185
- $type = $matches[1][$i];
186
- $url = $matches[2][$i];
187
- $scheme = $matches[3][$i];
188
- $updated = false;
189
-
190
- if ( $type == 'img' || $type == 'script' || $type == 'embed' ||
191
- ( $type == 'link' && ( strpos($html, 'stylesheet') !== false || strpos($html, 'pingback') !== false ) ) ||
192
- ( $type == 'form' && strpos($html, 'wp-pass.php') !== false ) ||
193
- ( $type == 'form' && strpos($html, 'commentform') !== false ) ||
194
- ( $type == 'input' && strpos($html, 'image') !== false ) ||
195
- ( $type == 'param' && strpos($html, 'movie') !== false )
196
- ) {
197
- // In admin panel, only fix image tags
198
- if ( is_admin() ) {
199
- if ( $type == 'img' ) {
200
- $this->secureElement($url, $type);
201
- }
202
- } else {
203
- $this->secureElement($url, $type);
204
- }
205
  }
206
  }
207
  }
@@ -229,7 +282,7 @@ class WordPressHTTPS_Module_Parser extends WordPressHTTPS_Module implements Word
229
  * @return void
230
  */
231
  public function fixRelativeElements() {
232
- if ( $this->getPlugin()->getHttpUrl()->getPath() != $this->getPlugin()->getHttpsUrl()->getPath() ) {
233
  preg_match_all('/\<(script|link|img|input|form|embed|param)[^>]+(src|href|action|data|movie|image|value)=[\'"](\/[^\'"]*)[\'"][^>]*>/im', $this->_html, $matches);
234
 
235
  for ($i = 0; $i < sizeof($matches[0]); $i++) {
@@ -260,25 +313,28 @@ class WordPressHTTPS_Module_Parser extends WordPressHTTPS_Module implements Word
260
  * @return void
261
  */
262
  public function fixExtensions() {
263
- if ( $this->getPlugin()->isSsl() ) {
264
- @preg_match_all('/(http|https):\/\/[^\'"]+[\'"]+/i', $this->_html, $matches);
265
- for ($i = 0; $i < sizeof($matches[0]); $i++) {
266
- $url = rtrim($matches[0][$i], '\'"');
267
- $filename = basename($url);
268
- $scheme = $matches[1][$i];
269
-
270
- foreach( $this->_extensions as $extension ) {
271
- if ( $extension == 'js' ) {
272
- $type = 'script';
273
- } else if ( $extension == 'css' ) {
274
- $type = 'style';
275
- } else if ( in_array($extension, array('jpg', 'jpeg', 'png', 'gif')) ) {
276
- $type = 'img';
277
- } else {
278
- $type = '';
279
- }
280
- if ( strpos($filename, '.' . $extension) !== false ) {
 
281
  $this->secureElement($url, $type);
 
 
282
  }
283
  }
284
  }
@@ -309,7 +365,9 @@ class WordPressHTTPS_Module_Parser extends WordPressHTTPS_Module implements Word
309
  if ( $this->getPlugin()->getSetting('ssl_host_diff') ) {
310
  $url_parts['path'] = str_replace($this->getPlugin()->getHttpsUrl()->getPath(), '', $url_parts['path']);
311
  }
312
- $url_parts['path'] = str_replace($this->getPlugin()->getHttpUrl()->getPath(), '', $url_parts['path']);
 
 
313
  }
314
 
315
  if ( $this->getPlugin()->isUrlLocal($url) && preg_match("/page_id=([\d]+)/", parse_url($url, PHP_URL_QUERY), $postID) ) {
@@ -322,12 +380,14 @@ class WordPressHTTPS_Module_Parser extends WordPressHTTPS_Module implements Word
322
  }
323
  if ( $this->getPlugin()->getSetting('frontpage') ) {
324
  $force_ssl = true;
 
 
325
  }
326
  } else if ( $this->getPlugin()->isUrlLocal($url) && ($post = get_page_by_path($url_parts['path'])) ) {
327
  $post = $post->ID;
328
  //TODO When logged in to HTTP and visiting an HTTPS page, admin links will always be forced to HTTPS, even if the user is not logged in via HTTPS. I need to find a way to detect this.
329
  } else if ( ( strpos($url_parts['path'], 'wp-admin') !== false || strpos($url_parts['path'], 'wp-login') !== false ) && ( $this->getPlugin()->isSsl() || $this->getPlugin()->getSetting('ssl_admin') ) ) {
330
- if ( !is_multisite() || ( is_multisite() && $url_parts['host'] == $this->getPlugin()->getHttpsUrl()->getHost() ) ) {
331
  $post = true;
332
  $force_ssl = true;
333
  } else if ( is_multisite() ) {
7
  *
8
  */
9
 
10
+ require_once('WordPressHTTPS/Module.php');
11
+ require_once('WordPressHTTPS/Module/Interface.php');
12
+
13
  class WordPressHTTPS_Module_Parser extends WordPressHTTPS_Module implements WordPressHTTPS_Module_Interface {
14
 
15
  /**
35
  * @return $this
36
  */
37
  public function addSecureExternalUrl( $value ) {
38
+ if ( trim($value) == '' ) {
39
  return $this;
40
  }
41
 
53
  * @return $this
54
  */
55
  public function addUnsecureExternalUrl( $value ) {
56
+ if ( trim($value) == '' ) {
57
  return $this;
58
  }
59
 
86
  public function parseHtml( $buffer ) {
87
  $this->_html = $buffer;
88
 
89
+ $this->normalizeElements();
90
  $this->fixLinksAndForms();
91
  $this->fixExtensions();
92
  $this->fixElements();
121
  public function secureElement( $url, $type = '' ) {
122
  $updated = false;
123
  $url = WordPressHTTPS_Url::fromString($url);
124
+ $upload_dir = wp_upload_dir();
125
+ $upload_path = str_replace($this->getPlugin()->getHttpsUrl()->getPath(), $this->getPlugin()->getHttpUrl()->getPath(), parse_url($upload_dir['baseurl'], PHP_URL_PATH));
126
+
127
  // If local
128
  if ( $this->getPlugin()->isUrlLocal($url) ) {
129
+ if ( ! is_admin() || ( is_admin() && strpos($url, $upload_path) === false ) ) {
130
+ $updated = $this->getPlugin()->makeUrlHttps($url);
131
+ $this->_html = str_replace($url, $updated, $this->_html);
132
+ }
133
  // If external and not HTTPS
134
  } else if ( $url->getPath() != 'https' ) {
135
  if ( @in_array($url->toString(), $this->getPlugin()->getSetting('secure_external_urls')) == false && @in_array($url->toString(), $this->getPlugin()->getSetting('unsecure_external_urls')) == false ) {
136
+ if ( $url->getScheme() != 'https' ) {
137
+ $test_url = clone $url;
138
+ $test_url->setScheme('https');
139
+ if ( $test_url->isValid() ) {
140
+ // Cache this URL as available over HTTPS for future reference
141
+ $this->addSecureExternalUrl($url->toString());
142
+ } else {
143
+ // If not available over HTTPS, mark as an unsecure external URL
144
+ $this->addUnsecureExternalUrl($url->toString());
145
+ }
146
  }
147
  }
148
 
164
  }
165
  }
166
 
167
+ /**
168
+ * Unsecure element
169
+ *
170
+ * @param string $url
171
+ * @param string $type
172
+ * @return void
173
+ */
174
+ public function unsecureElement( $url, $type = '' ) {
175
+ $updated = false;
176
+ $url = WordPressHTTPS_Url::fromString($url);
177
+
178
+ // If local
179
+ if ( $this->getPlugin()->isUrlLocal($url) ) {
180
+ if ( ! is_admin() || ( is_admin() && strpos($url, $upload_path) === false ) ) {
181
+ $updated = $this->getPlugin()->makeUrlHttp($url);
182
+ $this->_html = str_replace($url, $updated, $this->_html);
183
+ }
184
+ }
185
+
186
+ // Add log entry if this change hasn't been logged
187
+ if ( $updated && $url != $updated ) {
188
+ $log = '[FIXED] Element: ' . ( $type != '' ? '<' . $type . '> ' : '' ) . $url . ' => ' . $updated;
189
+ }
190
+ if ( isset($log) && ! in_array($log, $this->getPlugin()->getLogger()->getLog()) ) {
191
+ $this->getPlugin()->getLogger()->log($log);
192
+ }
193
+ }
194
+
195
+ /**
196
+ * Normalize all local URL's to HTTP
197
+ *
198
+ * @param none
199
+ * @return void
200
+ */
201
+ public function normalizeElements() {
202
+ if ( ! is_admin() && $GLOBALS['pagenow'] != 'wp-login.php' ) {
203
+ if ( $this->getPlugin()->getSetting('ssl_host_diff') ) {
204
+ $url = clone $this->getPlugin()->getHttpsUrl();
205
+ $url->setScheme('http');
206
+ preg_match_all('/(' . str_replace('/', '\/', preg_quote($url->toString())) . '[^\'"]*)[\'"]?/im', $this->_html, $httpsMatches);
207
+ }
208
+
209
+ $url = clone $this->getPlugin()->getHttpUrl();
210
+ $url->setScheme('https');
211
+ preg_match_all('/(' . str_replace('/', '\/', preg_quote($url->toString())) . '[^\'"]*)[\'"]?/im', $this->_html, $httpMatches);
212
+ $matches = array_merge($httpsMatches, $httpsMatches);
213
+ for ($i = 0; $i < sizeof($matches[0]); $i++) {
214
+ if ( isset($matches[1][$i]) ) {
215
+ $url = WordPressHTTPS_Url::fromString($matches[1][$i]);
216
+ if ( $url && strpos($url->getPath(), 'wp-admin') === false && strpos($url->getPath(), 'wp-login') === false ) {
217
+ $url = $url->toString();
218
+ $this->_html = str_replace($url, $this->getPlugin()->makeUrlHttp($url), $this->_html);
219
+ }
220
+ }
221
+ }
222
+ }
223
+ }
224
+
225
  /**
226
  * Fix Elements
227
  *
231
  * @return void
232
  */
233
  public function fixElements() {
234
+ if ( is_admin() ) {
235
+ preg_match_all('/\<(script|link|img)[^>]+[\'"]((http|https):\/\/[^\'"]+)[\'"][^>]*>/im', $this->_html, $matches);
236
+ } else {
237
+ preg_match_all('/\<(script|link|img|input|embed|param)[^>]+[\'"]((http|https):\/\/[^\'"]+)[\'"][^>]*>/im', $this->_html, $matches);
 
 
 
 
 
 
238
  }
239
 
240
+ for ($i = 0; $i < sizeof($matches[0]); $i++) {
241
+ $html = $matches[0][$i];
242
+ $type = $matches[1][$i];
243
+ $url = $matches[2][$i];
244
+ $scheme = $matches[3][$i];
245
+ $updated = false;
246
+
247
+ if ( $type == 'img' || $type == 'script' || $type == 'embed' ||
248
+ ( $type == 'link' && ( strpos($html, 'stylesheet') !== false || strpos($html, 'pingback') !== false ) ) ||
249
+ ( $type == 'form' && strpos($html, 'wp-pass.php') !== false ) ||
250
+ ( $type == 'form' && strpos($html, 'commentform') !== false ) ||
251
+ ( $type == 'input' && strpos($html, 'image') !== false ) ||
252
+ ( $type == 'param' && strpos($html, 'movie') !== false )
253
+ ) {
254
+ if ( $scheme == 'http' && ( $this->getPlugin()->isSsl() ) ) {
255
+ $this->secureElement($url, $type);
256
+ } else if ( $scheme == 'https' && ! $this->getPlugin()->isSsl() && strpos($url, 'wp-admin') === false ) {
257
+ $this->unsecureElement($url, $type);
 
 
 
 
 
 
 
 
 
 
258
  }
259
  }
260
  }
282
  * @return void
283
  */
284
  public function fixRelativeElements() {
285
+ if ( $this->getPlugin()->isSsl() && $this->getPlugin()->getHttpUrl()->getPath() != $this->getPlugin()->getHttpsUrl()->getPath() ) {
286
  preg_match_all('/\<(script|link|img|input|form|embed|param)[^>]+(src|href|action|data|movie|image|value)=[\'"](\/[^\'"]*)[\'"][^>]*>/im', $this->_html, $matches);
287
 
288
  for ($i = 0; $i < sizeof($matches[0]); $i++) {
313
  * @return void
314
  */
315
  public function fixExtensions() {
316
+ @preg_match_all('/(http|https):\/\/[^\'"]+[\'"]+/i', $this->_html, $matches);
317
+ for ($i = 0; $i < sizeof($matches[0]); $i++) {
318
+ $url = rtrim($matches[0][$i], '\'"');
319
+ $filename = basename($url);
320
+ $scheme = $matches[1][$i];
321
+
322
+ foreach( $this->_extensions as $extension ) {
323
+ if ( $extension == 'js' ) {
324
+ $type = 'script';
325
+ } else if ( $extension == 'css' ) {
326
+ $type = 'style';
327
+ } else if ( in_array($extension, array('jpg', 'jpeg', 'png', 'gif')) ) {
328
+ $type = 'img';
329
+ } else {
330
+ $type = '';
331
+ }
332
+
333
+ if ( strpos($filename, '.' . $extension) !== false ) {
334
+ if ( $this->getPlugin()->isSsl() ) {
335
  $this->secureElement($url, $type);
336
+ } else {
337
+ $this->unsecureElement($url, $type);
338
  }
339
  }
340
  }
365
  if ( $this->getPlugin()->getSetting('ssl_host_diff') ) {
366
  $url_parts['path'] = str_replace($this->getPlugin()->getHttpsUrl()->getPath(), '', $url_parts['path']);
367
  }
368
+ if ( $this->getPlugin()->getHttpUrl()->getPath() != '/' ) {
369
+ $url_parts['path'] = str_replace($this->getPlugin()->getHttpUrl()->getPath(), '', $url_parts['path']);
370
+ }
371
  }
372
 
373
  if ( $this->getPlugin()->isUrlLocal($url) && preg_match("/page_id=([\d]+)/", parse_url($url, PHP_URL_QUERY), $postID) ) {
380
  }
381
  if ( $this->getPlugin()->getSetting('frontpage') ) {
382
  $force_ssl = true;
383
+ } else if ( $this->getPlugin()->getSetting('exclusive_https') ) {
384
+ $force_ssl = false;
385
  }
386
  } else if ( $this->getPlugin()->isUrlLocal($url) && ($post = get_page_by_path($url_parts['path'])) ) {
387
  $post = $post->ID;
388
  //TODO When logged in to HTTP and visiting an HTTPS page, admin links will always be forced to HTTPS, even if the user is not logged in via HTTPS. I need to find a way to detect this.
389
  } else if ( ( strpos($url_parts['path'], 'wp-admin') !== false || strpos($url_parts['path'], 'wp-login') !== false ) && ( $this->getPlugin()->isSsl() || $this->getPlugin()->getSetting('ssl_admin') ) ) {
390
+ if ( ! is_multisite() || ( is_multisite() && strpos($url_parts['host'], $this->getPlugin()->getHttpsUrl()->getHost()) !== false ) ) {
391
  $post = true;
392
  $force_ssl = true;
393
  } else if ( is_multisite() ) {
lib/WordPressHTTPS/Plugin.php CHANGED
@@ -237,30 +237,30 @@ class WordPressHTTPS_Plugin {
237
  * @param int $setting_blog_id
238
  * @return mixed
239
  */
240
- public function getSetting( $setting, $setting_blog_id = 0 ) {
241
- global $blog_id;
242
-
243
- if ( $setting_blog_id > 0 ) {
244
- $blog_id = $setting_blog_id;
245
- }
246
-
247
- $setting = $this->getSlug() . '_' . $setting;
248
- if ( function_exists('get_blog_option') ) {
249
- $setting = get_blog_option($blog_id, $setting);
250
  } else {
251
- $setting = get_option($setting);
252
  }
253
- switch( $setting ) {
 
 
 
 
 
 
254
  case "1":
255
- $setting = true;
256
  break;
257
  case "0":
258
- $setting = false;
259
  break;
260
  }
261
- return $setting;
262
  }
263
-
264
  /**
265
  * Get Plugin Settings
266
  *
@@ -369,6 +369,10 @@ class WordPressHTTPS_Plugin {
369
  $base_class = get_class($this);
370
  }
371
  $module_full = 'Module\\' . $module;
 
 
 
 
372
 
373
  $class = $base_class . '_' . str_replace('\\', '_', $module_full);
374
  if ( ! isset($this->_modules[$class]) || ! is_object($this->_modules[$class]) || get_class($this->_modules[$class]) != $class ) {
237
  * @param int $setting_blog_id
238
  * @return mixed
239
  */
240
+ public function getSetting( $setting, $blog_id = 0 ) {
241
+ $setting_full = $this->getSlug() . '_' . $setting;
242
+ if ( $blog_id > 0 ) {
243
+ $value = get_blog_option($blog_id, $setting_full);
 
 
 
 
 
 
244
  } else {
245
+ $value = get_option($setting_full);
246
  }
247
+
248
+ // Load default option
249
+ if ( $value === false ) {
250
+ $value = $this->_settings[$setting];
251
+ }
252
+ // Convert 1's and 0's to boolean
253
+ switch( $value ) {
254
  case "1":
255
+ $value = true;
256
  break;
257
  case "0":
258
+ $value = false;
259
  break;
260
  }
261
+ return $value;
262
  }
263
+
264
  /**
265
  * Get Plugin Settings
266
  *
369
  $base_class = get_class($this);
370
  }
371
  $module_full = 'Module\\' . $module;
372
+ $filename = str_replace('\\', '/', $module_full);
373
+ $filename = $filename . '.php';
374
+
375
+ require_once($filename);
376
 
377
  $class = $base_class . '_' . str_replace('\\', '_', $module_full);
378
  if ( ! isset($this->_modules[$class]) || ! is_object($this->_modules[$class]) || get_class($this->_modules[$class]) != $class ) {
lib/WordPressHTTPS/Url.php CHANGED
@@ -156,9 +156,11 @@ class WordPressHTTPS_Url {
156
  public function getBaseHost() {
157
  $return_url = clone $this;
158
  $test_url = clone $this;
 
159
  $host_parts = explode('.', $test_url->getHost());
160
  for ( $i = 0; $i <= sizeof($host_parts); $i++ ) {
161
- if ( $test_url->setHost( str_replace($host_parts[$i] . '.', '', $test_url->getHost()) )->isValid() ) {
 
162
  $return_url = clone $test_url;
163
  } else {
164
  break;
@@ -377,6 +379,7 @@ class WordPressHTTPS_Url {
377
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, $verify_ssl);
378
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
379
  curl_setopt($ch, CURLOPT_FAILONERROR, true);
 
380
  @curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
381
  curl_setopt($ch, CURLOPT_HEADER, false);
382
  curl_setopt($ch, CURLOPT_ENCODING, 'gzip,deflate');
@@ -413,6 +416,7 @@ class WordPressHTTPS_Url {
413
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, $verify_ssl);
414
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
415
  curl_setopt($ch, CURLOPT_FAILONERROR, true);
 
416
  @curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
417
  curl_setopt($ch, CURLOPT_HEADER, false);
418
  curl_setopt($ch, CURLOPT_ENCODING, 'gzip,deflate');
156
  public function getBaseHost() {
157
  $return_url = clone $this;
158
  $test_url = clone $this;
159
+ $test_url->setPath('');
160
  $host_parts = explode('.', $test_url->getHost());
161
  for ( $i = 0; $i <= sizeof($host_parts); $i++ ) {
162
+ $test_url->setHost( str_replace($host_parts[$i] . '.', '', $test_url->getHost()) );
163
+ if ( $test_url->isValid() ) {
164
  $return_url = clone $test_url;
165
  } else {
166
  break;
379
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, $verify_ssl);
380
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
381
  curl_setopt($ch, CURLOPT_FAILONERROR, true);
382
+ curl_setopt($ch, CURLOPT_TIMEOUT, 5);
383
  @curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
384
  curl_setopt($ch, CURLOPT_HEADER, false);
385
  curl_setopt($ch, CURLOPT_ENCODING, 'gzip,deflate');
416
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, $verify_ssl);
417
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
418
  curl_setopt($ch, CURLOPT_FAILONERROR, true);
419
+ curl_setopt($ch, CURLOPT_TIMEOUT, 5);
420
  @curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
421
  curl_setopt($ch, CURLOPT_HEADER, false);
422
  curl_setopt($ch, CURLOPT_ENCODING, 'gzip,deflate');
lib/Zend/Loader.php DELETED
@@ -1,329 +0,0 @@
1
- <?php
2
- /**
3
- * Zend Framework
4
- *
5
- * LICENSE
6
- *
7
- * This source file is subject to the new BSD license that is bundled
8
- * with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://framework.zend.com/license/new-bsd
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@zend.com so we can send you a copy immediately.
14
- *
15
- * @category Zend
16
- * @package Zend_Loader
17
- * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
18
- * @license http://framework.zend.com/license/new-bsd New BSD License
19
- * @version $Id: Loader.php 23775 2011-03-01 17:25:24Z ralph $
20
- */
21
-
22
- /**
23
- * Static methods for loading classes and files.
24
- *
25
- * @category Zend
26
- * @package Zend_Loader
27
- * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
28
- * @license http://framework.zend.com/license/new-bsd New BSD License
29
- */
30
- class Zend_Loader
31
- {
32
- /**
33
- * Loads a class from a PHP file. The filename must be formatted
34
- * as "$class.php".
35
- *
36
- * If $dirs is a string or an array, it will search the directories
37
- * in the order supplied, and attempt to load the first matching file.
38
- *
39
- * If $dirs is null, it will split the class name at underscores to
40
- * generate a path hierarchy (e.g., "Zend_Example_Class" will map
41
- * to "Zend/Example/Class.php").
42
- *
43
- * If the file was not found in the $dirs, or if no $dirs were specified,
44
- * it will attempt to load it from PHP's include_path.
45
- *
46
- * @param string $class - The full class name of a Zend component.
47
- * @param string|array $dirs - OPTIONAL Either a path or an array of paths
48
- * to search.
49
- * @return void
50
- * @throws Zend_Exception
51
- */
52
- public static function loadClass($class, $dirs = null)
53
- {
54
- if (class_exists($class, false) || interface_exists($class, false)) {
55
- return;
56
- }
57
-
58
- if ((null !== $dirs) && !is_string($dirs) && !is_array($dirs)) {
59
- require_once 'Zend/Exception.php';
60
- throw new Zend_Exception('Directory argument must be a string or an array');
61
- }
62
-
63
- // Autodiscover the path from the class name
64
- // Implementation is PHP namespace-aware, and based on
65
- // Framework Interop Group reference implementation:
66
- // http://groups.google.com/group/php-standards/web/psr-0-final-proposal
67
- $className = ltrim($class, '\\');
68
- $file = '';
69
- $namespace = '';
70
- if ($lastNsPos = strripos($className, '\\')) {
71
- $namespace = substr($className, 0, $lastNsPos);
72
- $className = substr($className, $lastNsPos + 1);
73
- $file = str_replace('\\', DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR;
74
- }
75
- $file .= str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php';
76
-
77
- if (!empty($dirs)) {
78
- // use the autodiscovered path
79
- $dirPath = dirname($file);
80
- if (is_string($dirs)) {
81
- $dirs = explode(PATH_SEPARATOR, $dirs);
82
- }
83
- foreach ($dirs as $key => $dir) {
84
- if ($dir == '.') {
85
- $dirs[$key] = $dirPath;
86
- } else {
87
- $dir = rtrim($dir, '\\/');
88
- $dirs[$key] = $dir . DIRECTORY_SEPARATOR . $dirPath;
89
- }
90
- }
91
- $file = basename($file);
92
- self::loadFile($file, $dirs, true);
93
- } else {
94
- self::loadFile($file, null, true);
95
- }
96
-
97
- if (!class_exists($class, false) && !interface_exists($class, false)) {
98
- require_once 'Zend/Exception.php';
99
- throw new Zend_Exception("File \"$file\" does not exist or class \"$class\" was not found in the file");
100
- }
101
- }
102
-
103
- /**
104
- * Loads a PHP file. This is a wrapper for PHP's include() function.
105
- *
106
- * $filename must be the complete filename, including any
107
- * extension such as ".php". Note that a security check is performed that
108
- * does not permit extended characters in the filename. This method is
109
- * intended for loading Zend Framework files.
110
- *
111
- * If $dirs is a string or an array, it will search the directories
112
- * in the order supplied, and attempt to load the first matching file.
113
- *
114
- * If the file was not found in the $dirs, or if no $dirs were specified,
115
- * it will attempt to load it from PHP's include_path.
116
- *
117
- * If $once is TRUE, it will use include_once() instead of include().
118
- *
119
- * @param string $filename
120
- * @param string|array $dirs - OPTIONAL either a path or array of paths
121
- * to search.
122
- * @param boolean $once
123
- * @return boolean
124
- * @throws Zend_Exception
125
- */
126
- public static function loadFile($filename, $dirs = null, $once = false)
127
- {
128
- self::_securityCheck($filename);
129
-
130
- /**
131
- * Search in provided directories, as well as include_path
132
- */
133
- $incPath = false;
134
- if (!empty($dirs) && (is_array($dirs) || is_string($dirs))) {
135
- if (is_array($dirs)) {
136
- $dirs = implode(PATH_SEPARATOR, $dirs);
137
- }
138
- $incPath = get_include_path();
139
- set_include_path($dirs . PATH_SEPARATOR . $incPath);
140
- }
141
-
142
- /**
143
- * Try finding for the plain filename in the include_path.
144
- */
145
- if ($once) {
146
- include_once $filename;
147
- } else {
148
- include $filename;
149
- }
150
-
151
- /**
152
- * If searching in directories, reset include_path
153
- */
154
- if ($incPath) {
155
- set_include_path($incPath);
156
- }
157
-
158
- return true;
159
- }
160
-
161
- /**
162
- * Returns TRUE if the $filename is readable, or FALSE otherwise.
163
- * This function uses the PHP include_path, where PHP's is_readable()
164
- * does not.
165
- *
166
- * Note from ZF-2900:
167
- * If you use custom error handler, please check whether return value
168
- * from error_reporting() is zero or not.
169
- * At mark of fopen() can not suppress warning if the handler is used.
170
- *
171
- * @param string $filename
172
- * @return boolean
173
- */
174
- public static function isReadable($filename)
175
- {
176
- if (is_readable($filename)) {
177
- // Return early if the filename is readable without needing the
178
- // include_path
179
- return true;
180
- }
181
-
182
- if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN'
183
- && preg_match('/^[a-z]:/i', $filename)
184
- ) {
185
- // If on windows, and path provided is clearly an absolute path,
186
- // return false immediately
187
- return false;
188
- }
189
-
190
- foreach (self::explodeIncludePath() as $path) {
191
- if ($path == '.') {
192
- if (is_readable($filename)) {
193
- return true;
194
- }
195
- continue;
196
- }
197
- $file = $path . '/' . $filename;
198
- if (is_readable($file)) {
199
- return true;
200
- }
201
- }
202
- return false;
203
- }
204
-
205
- /**
206
- * Explode an include path into an array
207
- *
208
- * If no path provided, uses current include_path. Works around issues that
209
- * occur when the path includes stream schemas.
210
- *
211
- * @param string|null $path
212
- * @return array
213
- */
214
- public static function explodeIncludePath($path = null)
215
- {
216
- if (null === $path) {
217
- $path = get_include_path();
218
- }
219
-
220
- if (PATH_SEPARATOR == ':') {
221
- // On *nix systems, include_paths which include paths with a stream
222
- // schema cannot be safely explode'd, so we have to be a bit more
223
- // intelligent in the approach.
224
- $paths = preg_split('#:(?!//)#', $path);
225
- } else {
226
- $paths = explode(PATH_SEPARATOR, $path);
227
- }
228
- return $paths;
229
- }
230
-
231
- /**
232
- * spl_autoload() suitable implementation for supporting class autoloading.
233
- *
234
- * Attach to spl_autoload() using the following:
235
- * <code>
236
- * spl_autoload_register(array('Zend_Loader', 'autoload'));
237
- * </code>
238
- *
239
- * @deprecated Since 1.8.0
240
- * @param string $class
241
- * @return string|false Class name on success; false on failure
242
- */
243
- public static function autoload($class)
244
- {
245
- trigger_error(__CLASS__ . '::' . __METHOD__ . ' is deprecated as of 1.8.0 and will be removed with 2.0.0; use Zend_Loader_Autoloader instead', E_USER_NOTICE);
246
- try {
247
- @self::loadClass($class);
248
- return $class;
249
- } catch (Exception $e) {
250
- return false;
251
- }
252
- }
253
-
254
- /**
255
- * Register {@link autoload()} with spl_autoload()
256
- *
257
- * @deprecated Since 1.8.0
258
- * @param string $class (optional)
259
- * @param boolean $enabled (optional)
260
- * @return void
261
- * @throws Zend_Exception if spl_autoload() is not found
262
- * or if the specified class does not have an autoload() method.
263
- */
264
- public static function registerAutoload($class = 'Zend_Loader', $enabled = true)
265
- {
266
- trigger_error(__CLASS__ . '::' . __METHOD__ . ' is deprecated as of 1.8.0 and will be removed with 2.0.0; use Zend_Loader_Autoloader instead', E_USER_NOTICE);
267
- require_once 'Zend/Loader/Autoloader.php';
268
- $autoloader = Zend_Loader_Autoloader::getInstance();
269
- $autoloader->setFallbackAutoloader(true);
270
-
271
- if ('Zend_Loader' != $class) {
272
- self::loadClass($class);
273
- $methods = get_class_methods($class);
274
- if (!in_array('autoload', (array) $methods)) {
275
- require_once 'Zend/Exception.php';
276
- throw new Zend_Exception("The class \"$class\" does not have an autoload() method");
277
- }
278
-
279
- $callback = array($class, 'autoload');
280
-
281
- if ($enabled) {
282
- $autoloader->pushAutoloader($callback);
283
- } else {
284
- $autoloader->removeAutoloader($callback);
285
- }
286
- }
287
- }
288
-
289
- /**
290
- * Ensure that filename does not contain exploits
291
- *
292
- * @param string $filename
293
- * @return void
294
- * @throws Zend_Exception
295
- */
296
- protected static function _securityCheck($filename)
297
- {
298
- /**
299
- * Security check
300
- */
301
- if (preg_match('/[^a-z0-9\\/\\\\_.:-]/i', $filename)) {
302
- require_once 'Zend/Exception.php';
303
- throw new Zend_Exception('Security check: Illegal character in filename');
304
- }
305
- }
306
-
307
- /**
308
- * Attempt to include() the file.
309
- *
310
- * include() is not prefixed with the @ operator because if
311
- * the file is loaded and contains a parse error, execution
312
- * will halt silently and this is difficult to debug.
313
- *
314
- * Always set display_errors = Off on production servers!
315
- *
316
- * @param string $filespec
317
- * @param boolean $once
318
- * @return boolean
319
- * @deprecated Since 1.5.0; use loadFile() instead
320
- */
321
- protected static function _includeFile($filespec, $once = false)
322
- {
323
- if ($once) {
324
- return include_once $filespec;
325
- } else {
326
- return include $filespec ;
327
- }
328
- }
329
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/Zend/Loader/Autoloader.php DELETED
@@ -1,589 +0,0 @@
1
- <?php
2
- /**
3
- * Zend Framework
4
- *
5
- * LICENSE
6
- *
7
- * This source file is subject to the new BSD license that is bundled
8
- * with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://framework.zend.com/license/new-bsd
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@zend.com so we can send you a copy immediately.
14
- *
15
- * @category Zend
16
- * @package Zend_Loader
17
- * @subpackage Autoloader
18
- * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
19
- * @version $Id: Autoloader.php 23953 2011-05-03 05:47:39Z ralph $
20
- * @license http://framework.zend.com/license/new-bsd New BSD License
21
- */
22
-
23
- /** Zend_Loader */
24
- require_once 'Zend/Loader.php';
25
-
26
- /**
27
- * Autoloader stack and namespace autoloader
28
- *
29
- * @uses Zend_Loader_Autoloader
30
- * @package Zend_Loader
31
- * @subpackage Autoloader
32
- * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
33
- * @license http://framework.zend.com/license/new-bsd New BSD License
34
- */
35
- class Zend_Loader_Autoloader
36
- {
37
- /**
38
- * @var Zend_Loader_Autoloader Singleton instance
39
- */
40
- protected static $_instance;
41
-
42
- /**
43
- * @var array Concrete autoloader callback implementations
44
- */
45
- protected $_autoloaders = array();
46
-
47
- /**
48
- * @var array Default autoloader callback
49
- */
50
- protected $_defaultAutoloader = array('Zend_Loader', 'loadClass');
51
-
52
- /**
53
- * @var bool Whether or not to act as a fallback autoloader
54
- */
55
- protected $_fallbackAutoloader = false;
56
-
57
- /**
58
- * @var array Callback for internal autoloader implementation
59
- */
60
- protected $_internalAutoloader;
61
-
62
- /**
63
- * @var array Supported namespaces 'Zend' and 'ZendX' by default.
64
- */
65
- protected $_namespaces = array(
66
- 'Zend_' => true,
67
- 'ZendX_' => true,
68
- );
69
-
70
- /**
71
- * @var array Namespace-specific autoloaders
72
- */
73
- protected $_namespaceAutoloaders = array();
74
-
75
- /**
76
- * @var bool Whether or not to suppress file not found warnings
77
- */
78
- protected $_suppressNotFoundWarnings = false;
79
-
80
- /**
81
- * @var null|string
82
- */
83
- protected $_zfPath;
84
-
85
- /**
86
- * Retrieve singleton instance
87
- *
88
- * @return Zend_Loader_Autoloader
89
- */
90
- public static function getInstance()
91
- {
92
- if (null === self::$_instance) {
93
- self::$_instance = new self();
94
- }
95
- return self::$_instance;
96
- }
97
-
98
- /**
99
- * Reset the singleton instance
100
- *
101
- * @return void
102
- */
103
- public static function resetInstance()
104
- {
105
- self::$_instance = null;
106
- }
107
-
108
- /**
109
- * Autoload a class
110
- *
111
- * @param string $class
112
- * @return bool
113
- */
114
- public static function autoload($class)
115
- {
116
- $self = self::getInstance();
117
-
118
- foreach ($self->getClassAutoloaders($class) as $autoloader) {
119
- if ($autoloader instanceof Zend_Loader_Autoloader_Interface) {
120
- if ($autoloader->autoload($class)) {
121
- return true;
122
- }
123
- } elseif (is_array($autoloader)) {
124
- if (call_user_func($autoloader, $class)) {
125
- return true;
126
- }
127
- } elseif (is_string($autoloader) || is_callable($autoloader)) {
128
- if ($autoloader($class)) {
129
- return true;
130
- }
131
- }
132
- }
133
-
134
- return false;
135
- }
136
-
137
- /**
138
- * Set the default autoloader implementation
139
- *
140
- * @param string|array $callback PHP callback
141
- * @return void
142
- */
143
- public function setDefaultAutoloader($callback)
144
- {
145
- if (!is_callable($callback)) {
146
- throw new Zend_Loader_Exception('Invalid callback specified for default autoloader');
147
- }
148
-
149
- $this->_defaultAutoloader = $callback;
150
- return $this;
151
- }
152
-
153
- /**
154
- * Retrieve the default autoloader callback
155
- *
156
- * @return string|array PHP Callback
157
- */
158
- public function getDefaultAutoloader()
159
- {
160
- return $this->_defaultAutoloader;
161
- }
162
-
163
- /**
164
- * Set several autoloader callbacks at once
165
- *
166
- * @param array $autoloaders Array of PHP callbacks (or Zend_Loader_Autoloader_Interface implementations) to act as autoloaders
167
- * @return Zend_Loader_Autoloader
168
- */
169
- public function setAutoloaders(array $autoloaders)
170
- {
171
- $this->_autoloaders = $autoloaders;
172
- return $this;
173
- }
174
-
175
- /**
176
- * Get attached autoloader implementations
177
- *
178
- * @return array
179
- */
180
- public function getAutoloaders()
181
- {
182
- return $this->_autoloaders;
183
- }
184
-
185
- /**
186
- * Return all autoloaders for a given namespace
187
- *
188
- * @param string $namespace
189
- * @return array
190
- */
191
- public function getNamespaceAutoloaders($namespace)
192
- {
193
- $namespace = (string) $namespace;
194
- if (!array_key_exists($namespace, $this->_namespaceAutoloaders)) {
195
- return array();
196
- }
197
- return $this->_namespaceAutoloaders[$namespace];
198
- }
199
-
200
- /**
201
- * Register a namespace to autoload
202
- *
203
- * @param string|array $namespace
204
- * @return Zend_Loader_Autoloader
205
- */
206
- public function registerNamespace($namespace)
207
- {
208
- if (is_string($namespace)) {
209
- $namespace = (array) $namespace;
210
- } elseif (!is_array($namespace)) {
211
- throw new Zend_Loader_Exception('Invalid namespace provided');
212
- }
213
-
214
- foreach ($namespace as $ns) {
215
- if (!isset($this->_namespaces[$ns])) {
216
- $this->_namespaces[$ns] = true;
217
- }
218
- }
219
- return $this;
220
- }
221
-
222
- /**
223
- * Unload a registered autoload namespace
224
- *
225
- * @param string|array $namespace
226
- * @return Zend_Loader_Autoloader
227
- */
228
- public function unregisterNamespace($namespace)
229
- {
230
- if (is_string($namespace)) {
231
- $namespace = (array) $namespace;
232
- } elseif (!is_array($namespace)) {
233
- throw new Zend_Loader_Exception('Invalid namespace provided');
234
- }
235
-
236
- foreach ($namespace as $ns) {
237
- if (isset($this->_namespaces[$ns])) {
238
- unset($this->_namespaces[$ns]);
239
- }
240
- }
241
- return $this;
242
- }
243
-
244
- /**
245
- * Get a list of registered autoload namespaces
246
- *
247
- * @return array
248
- */
249
- public function getRegisteredNamespaces()
250
- {
251
- return array_keys($this->_namespaces);
252
- }
253
-
254
- public function setZfPath($spec, $version = 'latest')
255
- {
256
- $path = $spec;
257
- if (is_array($spec)) {
258
- if (!isset($spec['path'])) {
259
- throw new Zend_Loader_Exception('No path specified for ZF');
260
- }
261
- $path = $spec['path'];
262
- if (isset($spec['version'])) {
263
- $version = $spec['version'];
264
- }
265
- }
266
-
267
- $this->_zfPath = $this->_getVersionPath($path, $version);
268
- set_include_path(implode(PATH_SEPARATOR, array(
269
- $this->_zfPath,
270
- get_include_path(),
271
- )));
272
- return $this;
273
- }
274
-
275
- public function getZfPath()
276
- {
277
- return $this->_zfPath;
278
- }
279
-
280
- /**
281
- * Get or set the value of the "suppress not found warnings" flag
282
- *
283
- * @param null|bool $flag
284
- * @return bool|Zend_Loader_Autoloader Returns boolean if no argument is passed, object instance otherwise
285
- */
286
- public function suppressNotFoundWarnings($flag = null)
287
- {
288
- if (null === $flag) {
289
- return $this->_suppressNotFoundWarnings;
290
- }
291
- $this->_suppressNotFoundWarnings = (bool) $flag;
292
- return $this;
293
- }
294
-
295
- /**
296
- * Indicate whether or not this autoloader should be a fallback autoloader
297
- *
298
- * @param bool $flag
299
- * @return Zend_Loader_Autoloader
300
- */
301
- public function setFallbackAutoloader($flag)
302
- {
303
- $this->_fallbackAutoloader = (bool) $flag;
304
- return $this;
305
- }
306
-
307
- /**
308
- * Is this instance acting as a fallback autoloader?
309
- *
310
- * @return bool
311
- */
312
- public function isFallbackAutoloader()
313
- {
314
- return $this->_fallbackAutoloader;
315
- }
316
-
317
- /**
318
- * Get autoloaders to use when matching class
319
- *
320
- * Determines if the class matches a registered namespace, and, if so,
321
- * returns only the autoloaders for that namespace. Otherwise, it returns
322
- * all non-namespaced autoloaders.
323
- *
324
- * @param string $class
325
- * @return array Array of autoloaders to use
326
- */
327
- public function getClassAutoloaders($class)
328
- {
329
- $namespace = false;
330
- $autoloaders = array();
331
-
332
- // Add concrete namespaced autoloaders
333
- foreach (array_keys($this->_namespaceAutoloaders) as $ns) {
334
- if ('' == $ns) {
335
- continue;
336
- }
337
- if (0 === strpos($class, $ns)) {
338
- if ((false === $namespace) || (strlen($ns) > strlen($namespace))) {
339
- $namespace = $ns;
340
- $autoloaders = $this->getNamespaceAutoloaders($ns);
341
- }
342
- }
343
- }
344
-
345
- // Add internal namespaced autoloader
346
- foreach ($this->getRegisteredNamespaces() as $ns) {
347
- if (0 === strpos($class, $ns)) {
348
- $namespace = $ns;
349
- $autoloaders[] = $this->_internalAutoloader;
350
- break;
351
- }
352
- }
353
-
354
- // Add non-namespaced autoloaders
355
- $autoloadersNonNamespace = $this->getNamespaceAutoloaders('');
356
- if (count($autoloadersNonNamespace)) {
357
- foreach ($autoloadersNonNamespace as $ns) {
358
- $autoloaders[] = $ns;
359
- }
360
- unset($autoloadersNonNamespace);
361
- }
362
-
363
- // Add fallback autoloader
364
- if (!$namespace && $this->isFallbackAutoloader()) {
365
- $autoloaders[] = $this->_internalAutoloader;
366
- }
367
-
368
- return $autoloaders;
369
- }
370
-
371
- /**
372
- * Add an autoloader to the beginning of the stack
373
- *
374
- * @param object|array|string $callback PHP callback or Zend_Loader_Autoloader_Interface implementation
375
- * @param string|array $namespace Specific namespace(s) under which to register callback
376
- * @return Zend_Loader_Autoloader
377
- */
378
- public function unshiftAutoloader($callback, $namespace = '')
379
- {
380
- $autoloaders = $this->getAutoloaders();
381
- array_unshift($autoloaders, $callback);
382
- $this->setAutoloaders($autoloaders);
383
-
384
- $namespace = (array) $namespace;
385
- foreach ($namespace as $ns) {
386
- $autoloaders = $this->getNamespaceAutoloaders($ns);
387
- array_unshift($autoloaders, $callback);
388
- $this->_setNamespaceAutoloaders($autoloaders, $ns);
389
- }
390
-
391
- return $this;
392
- }
393
-
394
- /**
395
- * Append an autoloader to the autoloader stack
396
- *
397
- * @param object|array|string $callback PHP callback or Zend_Loader_Autoloader_Interface implementation
398
- * @param string|array $namespace Specific namespace(s) under which to register callback
399
- * @return Zend_Loader_Autoloader
400
- */
401
- public function pushAutoloader($callback, $namespace = '')
402
- {
403
- $autoloaders = $this->getAutoloaders();
404
- array_push($autoloaders, $callback);
405
- $this->setAutoloaders($autoloaders);
406
-
407
- $namespace = (array) $namespace;
408
- foreach ($namespace as $ns) {
409
- $autoloaders = $this->getNamespaceAutoloaders($ns);
410
- array_push($autoloaders, $callback);
411
- $this->_setNamespaceAutoloaders($autoloaders, $ns);
412
- }
413
-
414
- return $this;
415
- }
416
-
417
- /**
418
- * Remove an autoloader from the autoloader stack
419
- *
420
- * @param object|array|string $callback PHP callback or Zend_Loader_Autoloader_Interface implementation
421
- * @param null|string|array $namespace Specific namespace(s) from which to remove autoloader
422
- * @return Zend_Loader_Autoloader
423
- */
424
- public function removeAutoloader($callback, $namespace = null)
425
- {
426
- if (null === $namespace) {
427
- $autoloaders = $this->getAutoloaders();
428
- if (false !== ($index = array_search($callback, $autoloaders, true))) {
429
- unset($autoloaders[$index]);
430
- $this->setAutoloaders($autoloaders);
431
- }
432
-
433
- foreach ($this->_namespaceAutoloaders as $ns => $autoloaders) {
434
- if (false !== ($index = array_search($callback, $autoloaders, true))) {
435
- unset($autoloaders[$index]);
436
- $this->_setNamespaceAutoloaders($autoloaders, $ns);
437
- }
438
- }
439
- } else {
440
- $namespace = (array) $namespace;
441
- foreach ($namespace as $ns) {
442
- $autoloaders = $this->getNamespaceAutoloaders($ns);
443
- if (false !== ($index = array_search($callback, $autoloaders, true))) {
444
- unset($autoloaders[$index]);
445
- $this->_setNamespaceAutoloaders($autoloaders, $ns);
446
- }
447
- }
448
- }
449
-
450
- return $this;
451
- }
452
-
453
- /**
454
- * Constructor
455
- *
456
- * Registers instance with spl_autoload stack
457
- *
458
- * @return void
459
- */
460
- protected function __construct()
461
- {
462
- spl_autoload_register(array(__CLASS__, 'autoload'));
463
- $this->_internalAutoloader = array($this, '_autoload');
464
- }
465
-
466
- /**
467
- * Internal autoloader implementation
468
- *
469
- * @param string $class
470
- * @return bool
471
- */
472
- protected function _autoload($class)
473
- {
474
- $callback = $this->getDefaultAutoloader();
475
- try {
476
- if ($this->suppressNotFoundWarnings()) {
477
- @call_user_func($callback, $class);
478
- } else {
479
- call_user_func($callback, $class);
480
- }
481
- return $class;
482
- } catch (Zend_Exception $e) {
483
- return false;
484
- }
485
- }
486
-
487
- /**
488
- * Set autoloaders for a specific namespace
489
- *
490
- * @param array $autoloaders
491
- * @param string $namespace
492
- * @return Zend_Loader_Autoloader
493
- */
494
- protected function _setNamespaceAutoloaders(array $autoloaders, $namespace = '')
495
- {
496
- $namespace = (string) $namespace;
497
- $this->_namespaceAutoloaders[$namespace] = $autoloaders;
498
- return $this;
499
- }
500
-
501
- /**
502
- * Retrieve the filesystem path for the requested ZF version
503
- *
504
- * @param string $path
505
- * @param string $version
506
- * @return void
507
- */
508
- protected function _getVersionPath($path, $version)
509
- {
510
- $type = $this->_getVersionType($version);
511
-
512
- if ($type == 'latest') {
513
- $version = 'latest';
514
- }
515
-
516
- $availableVersions = $this->_getAvailableVersions($path, $version);
517
- if (empty($availableVersions)) {
518
- throw new Zend_Loader_Exception('No valid ZF installations discovered');
519
- }
520
-
521
- $matchedVersion = array_pop($availableVersions);
522
- return $matchedVersion;
523
- }
524
-
525
- /**
526
- * Retrieve the ZF version type
527
- *
528
- * @param string $version
529
- * @return string "latest", "major", "minor", or "specific"
530
- * @throws Zend_Loader_Exception if version string contains too many dots
531
- */
532
- protected function _getVersionType($version)
533
- {
534
- if (strtolower($version) == 'latest') {
535
- return 'latest';
536
- }
537
-
538
- $parts = explode('.', $version);
539
- $count = count($parts);
540
- if (1 == $count) {
541
- return 'major';
542
- }
543
- if (2 == $count) {
544
- return 'minor';
545
- }
546
- if (3 < $count) {
547
- throw new Zend_Loader_Exception('Invalid version string provided');
548
- }
549
- return 'specific';
550
- }
551
-
552
- /**
553
- * Get available versions for the version type requested
554
- *
555
- * @param string $path
556
- * @param string $version
557
- * @return array
558
- */
559
- protected function _getAvailableVersions($path, $version)
560
- {
561
- if (!is_dir($path)) {
562
- throw new Zend_Loader_Exception('Invalid ZF path provided');
563
- }
564
-
565
- $path = rtrim($path, '/');
566
- $path = rtrim($path, '\\');
567
- $versionLen = strlen($version);
568
- $versions = array();
569
- $dirs = glob("$path/*", GLOB_ONLYDIR);
570
- foreach ((array) $dirs as $dir) {
571
- $dirName = substr($dir, strlen($path) + 1);
572
- if (!preg_match('/^(?:ZendFramework-)?(\d+\.\d+\.\d+((a|b|pl|pr|p|rc)\d+)?)(?:-minimal)?$/i', $dirName, $matches)) {
573
- continue;
574
- }
575
-
576
- $matchedVersion = $matches[1];
577
-
578
- if (('latest' == $version)
579
- || ((strlen($matchedVersion) >= $versionLen)
580
- && (0 === strpos($matchedVersion, $version)))
581
- ) {
582
- $versions[$matchedVersion] = $dir . '/library';
583
- }
584
- }
585
-
586
- uksort($versions, 'version_compare');
587
- return $versions;
588
- }
589
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/Zend/Loader/Autoloader/Interface.php DELETED
@@ -1,43 +0,0 @@
1
- <?php
2
- /**
3
- * Zend Framework
4
- *
5
- * LICENSE
6
- *
7
- * This source file is subject to the new BSD license that is bundled
8
- * with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://framework.zend.com/license/new-bsd
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@zend.com so we can send you a copy immediately.
14
- *
15
- * @category Zend
16
- * @package Zend_Loader
17
- * @subpackage Autoloader
18
- * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
19
- * @version $Id: Interface.php 23775 2011-03-01 17:25:24Z ralph $
20
- * @license http://framework.zend.com/license/new-bsd New BSD License
21
- */
22
-
23
- /**
24
- * Autoloader interface
25
- *
26
- * @package Zend_Loader
27
- * @subpackage Autoloader
28
- * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
29
- * @license http://framework.zend.com/license/new-bsd New BSD License
30
- */
31
- interface Zend_Loader_Autoloader_Interface
32
- {
33
- /**
34
- * Autoload a class
35
- *
36
- * @abstract
37
- * @param string $class
38
- * @return mixed
39
- * False [if unable to load $class]
40
- * get_class($class) [if $class is successfully loaded]
41
- */
42
- public function autoload($class);
43
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/Zend/Loader/Autoloader/Resource.php DELETED
@@ -1,472 +0,0 @@
1
- <?php
2
- /**
3
- * Zend Framework
4
- *
5
- * LICENSE
6
- *
7
- * This source file is subject to the new BSD license that is bundled
8
- * with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://framework.zend.com/license/new-bsd
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@zend.com so we can send you a copy immediately.
14
- *
15
- * @category Zend
16
- * @package Zend_Loader
17
- * @subpackage Autoloader
18
- * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
19
- * @version $Id: Resource.php 23860 2011-04-14 17:03:28Z matthew $
20
- * @license http://framework.zend.com/license/new-bsd New BSD License
21
- */
22
-
23
- /** Zend_Loader_Autoloader_Interface */
24
- require_once 'Zend/Loader/Autoloader/Interface.php';
25
-
26
- /**
27
- * Resource loader
28
- *
29
- * @uses Zend_Loader_Autoloader_Interface
30
- * @package Zend_Loader
31
- * @subpackage Autoloader
32
- * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
33
- * @license http://framework.zend.com/license/new-bsd New BSD License
34
- */
35
- class Zend_Loader_Autoloader_Resource implements Zend_Loader_Autoloader_Interface
36
- {
37
- /**
38
- * @var string Base path to resource classes
39
- */
40
- protected $_basePath;
41
-
42
- /**
43
- * @var array Components handled within this resource
44
- */
45
- protected $_components = array();
46
-
47
- /**
48
- * @var string Default resource/component to use when using object registry
49
- */
50
- protected $_defaultResourceType;
51
-
52
- /**
53
- * @var string Namespace of classes within this resource
54
- */
55
- protected $_namespace;
56
-
57
- /**
58
- * @var array Available resource types handled by this resource autoloader
59
- */
60
- protected $_resourceTypes = array();
61
-
62
- /**
63
- * Constructor
64
- *
65
- * @param array|Zend_Config $options Configuration options for resource autoloader
66
- * @return void
67
- */
68
- public function __construct($options)
69
- {
70
- if ($options instanceof Zend_Config) {
71
- $options = $options->toArray();
72
- }
73
- if (!is_array($options)) {
74
- require_once 'Zend/Loader/Exception.php';
75
- throw new Zend_Loader_Exception('Options must be passed to resource loader constructor');
76
- }
77
-
78
- $this->setOptions($options);
79
-
80
- $namespace = $this->getNamespace();
81
- if ((null === $namespace)
82
- || (null === $this->getBasePath())
83
- ) {
84
- require_once 'Zend/Loader/Exception.php';
85
- throw new Zend_Loader_Exception('Resource loader requires both a namespace and a base path for initialization');
86
- }
87
-
88
- if (!empty($namespace)) {
89
- $namespace .= '_';
90
- }
91
- require_once 'Zend/Loader/Autoloader.php';
92
- Zend_Loader_Autoloader::getInstance()->unshiftAutoloader($this, $namespace);
93
- }
94
-
95
- /**
96
- * Overloading: methods
97
- *
98
- * Allow retrieving concrete resource object instances using 'get<Resourcename>()'
99
- * syntax. Example:
100
- * <code>
101
- * $loader = new Zend_Loader_Autoloader_Resource(array(
102
- * 'namespace' => 'Stuff_',
103
- * 'basePath' => '/path/to/some/stuff',
104
- * ))
105
- * $loader->addResourceType('Model', 'models', 'Model');
106
- *
107
- * $foo = $loader->getModel('Foo'); // get instance of Stuff_Model_Foo class
108
- * </code>
109
- *
110
- * @param string $method
111
- * @param array $args
112
- * @return mixed
113
- * @throws Zend_Loader_Exception if method not beginning with 'get' or not matching a valid resource type is called
114
- */
115
- public function __call($method, $args)
116
- {
117
- if ('get' == substr($method, 0, 3)) {
118
- $type = strtolower(substr($method, 3));
119
- if (!$this->hasResourceType($type)) {
120
- require_once 'Zend/Loader/Exception.php';
121
- throw new Zend_Loader_Exception("Invalid resource type $type; cannot load resource");
122
- }
123
- if (empty($args)) {
124
- require_once 'Zend/Loader/Exception.php';
125
- throw new Zend_Loader_Exception("Cannot load resources; no resource specified");
126
- }
127
- $resource = array_shift($args);
128
- return $this->load($resource, $type);
129
- }
130
-
131
- require_once 'Zend/Loader/Exception.php';
132
- throw new Zend_Loader_Exception("Method '$method' is not supported");
133
- }
134
-
135
- /**
136
- * Helper method to calculate the correct class path
137
- *
138
- * @param string $class
139
- * @return False if not matched other wise the correct path
140
- */
141
- public function getClassPath($class)
142
- {
143
- $segments = explode('_', $class);
144
- $namespaceTopLevel = $this->getNamespace();
145
- $namespace = '';
146
-
147
- if (!empty($namespaceTopLevel)) {
148
- $namespace = array();
149
- $topLevelSegments = count(explode('_', $namespaceTopLevel));
150
- for ($i = 0; $i < $topLevelSegments; $i++) {
151
- $namespace[] = array_shift($segments);
152
- }
153
- $namespace = implode('_', $namespace);
154
- if ($namespace != $namespaceTopLevel) {
155
- // wrong prefix? we're done
156
- return false;
157
- }
158
- }
159
-
160
- if (count($segments) < 2) {
161
- // assumes all resources have a component and class name, minimum
162
- return false;
163
- }
164
-
165
- $final = array_pop($segments);
166
- $component = $namespace;
167
- $lastMatch = false;
168
- do {
169
- $segment = array_shift($segments);
170
- $component .= empty($component) ? $segment : '_' . $segment;
171
- if (isset($this->_components[$component])) {
172
- $lastMatch = $component;
173
- }
174
- } while (count($segments));
175
-
176
- if (!$lastMatch) {
177
- return false;
178
- }
179
-
180
- $final = substr($class, strlen($lastMatch) + 1);
181
- $path = $this->_components[$lastMatch];
182
- $classPath = $path . '/' . str_replace('_', '/', $final) . '.php';
183
-
184
- if (Zend_Loader::isReadable($classPath)) {
185
- return $classPath;
186
- }
187
-
188
- return false;
189
- }
190
-
191
- /**
192
- * Attempt to autoload a class
193
- *
194
- * @param string $class
195
- * @return mixed False if not matched, otherwise result if include operation
196
- */
197
- public function autoload($class)
198
- {
199
- $classPath = $this->getClassPath($class);
200
- if (false !== $classPath) {
201
- return include $classPath;
202
- }
203
- return false;
204
- }
205
-
206
- /**
207
- * Set class state from options
208
- *
209
- * @param array $options
210
- * @return Zend_Loader_Autoloader_Resource
211
- */
212
- public function setOptions(array $options)
213
- {
214
- // Set namespace first, see ZF-10836
215
- if (isset($options['namespace'])) {
216
- $this->setNamespace($options['namespace']);
217
- unset($options['namespace']);
218
- }
219
-
220
- $methods = get_class_methods($this);
221
- foreach ($options as $key => $value) {
222
- $method = 'set' . ucfirst($key);
223
- if (in_array($method, $methods)) {
224
- $this->$method($value);
225
- }
226
- }
227
- return $this;
228
- }
229
-
230
- /**
231
- * Set namespace that this autoloader handles
232
- *
233
- * @param string $namespace
234
- * @return Zend_Loader_Autoloader_Resource
235
- */
236
- public function setNamespace($namespace)
237
- {
238
- $this->_namespace = rtrim((string) $namespace, '_');
239
- return $this;
240
- }
241
-
242
- /**
243
- * Get namespace this autoloader handles
244
- *
245
- * @return string
246
- */
247
- public function getNamespace()
248
- {
249
- return $this->_namespace;
250
- }
251
-
252
- /**
253
- * Set base path for this set of resources
254
- *
255
- * @param string $path
256
- * @return Zend_Loader_Autoloader_Resource
257
- */
258
- public function setBasePath($path)
259
- {
260
- $this->_basePath = (string) $path;
261
- return $this;
262
- }
263
-
264
- /**
265
- * Get base path to this set of resources
266
- *
267
- * @return string
268
- */
269
- public function getBasePath()
270
- {
271
- return $this->_basePath;
272
- }
273
-
274
- /**
275
- * Add resource type
276
- *
277
- * @param string $type identifier for the resource type being loaded
278
- * @param string $path path relative to resource base path containing the resource types
279
- * @param null|string $namespace sub-component namespace to append to base namespace that qualifies this resource type
280
- * @return Zend_Loader_Autoloader_Resource
281
- */
282
- public function addResourceType($type, $path, $namespace = null)
283
- {
284
- $type = strtolower($type);
285
- if (!isset($this->_resourceTypes[$type])) {
286
- if (null === $namespace) {
287
- require_once 'Zend/Loader/Exception.php';
288
- throw new Zend_Loader_Exception('Initial definition of a resource type must include a namespace');
289
- }
290
- $namespaceTopLevel = $this->getNamespace();
291
- $namespace = ucfirst(trim($namespace, '_'));
292
- $this->_resourceTypes[$type] = array(
293
- 'namespace' => empty($namespaceTopLevel) ? $namespace : $namespaceTopLevel . '_' . $namespace,
294
- );
295
- }
296
- if (!is_string($path)) {
297
- require_once 'Zend/Loader/Exception.php';
298
- throw new Zend_Loader_Exception('Invalid path specification provided; must be string');
299
- }
300
- $this->_resourceTypes[$type]['path'] = $this->getBasePath() . '/' . rtrim($path, '\/');
301
-
302
- $component = $this->_resourceTypes[$type]['namespace'];
303
- $this->_components[$component] = $this->_resourceTypes[$type]['path'];
304
- return $this;
305
- }
306
-
307
- /**
308
- * Add multiple resources at once
309
- *
310
- * $types should be an associative array of resource type => specification
311
- * pairs. Each specification should be an associative array containing
312
- * minimally the 'path' key (specifying the path relative to the resource
313
- * base path) and optionally the 'namespace' key (indicating the subcomponent
314
- * namespace to append to the resource namespace).
315
- *
316
- * As an example:
317
- * <code>
318
- * $loader->addResourceTypes(array(
319
- * 'model' => array(
320
- * 'path' => 'models',
321
- * 'namespace' => 'Model',
322
- * ),
323
- * 'form' => array(
324
- * 'path' => 'forms',
325
- * 'namespace' => 'Form',
326
- * ),
327
- * ));
328
- * </code>
329
- *
330
- * @param array $types
331
- * @return Zend_Loader_Autoloader_Resource
332
- */
333
- public function addResourceTypes(array $types)
334
- {
335
- foreach ($types as $type => $spec) {
336
- if (!is_array($spec)) {
337
- require_once 'Zend/Loader/Exception.php';
338
- throw new Zend_Loader_Exception('addResourceTypes() expects an array of arrays');
339
- }
340
- if (!isset($spec['path'])) {
341
- require_once 'Zend/Loader/Exception.php';
342
- throw new Zend_Loader_Exception('addResourceTypes() expects each array to include a paths element');
343
- }
344
- $paths = $spec['path'];
345
- $namespace = null;
346
- if (isset($spec['namespace'])) {
347
- $namespace = $spec['namespace'];
348
- }
349
- $this->addResourceType($type, $paths, $namespace);
350
- }
351
- return $this;
352
- }
353
-
354
- /**
355
- * Overwrite existing and set multiple resource types at once
356
- *
357
- * @see Zend_Loader_Autoloader_Resource::addResourceTypes()
358
- * @param array $types
359
- * @return Zend_Loader_Autoloader_Resource
360
- */
361
- public function setResourceTypes(array $types)
362
- {
363
- $this->clearResourceTypes();
364
- return $this->addResourceTypes($types);
365
- }
366
-
367
- /**
368
- * Retrieve resource type mappings
369
- *
370
- * @return array
371
- */
372
- public function getResourceTypes()
373
- {
374
- return $this->_resourceTypes;
375
- }
376
-
377
- /**
378
- * Is the requested resource type defined?
379
- *
380
- * @param string $type
381
- * @return bool
382
- */
383
- public function hasResourceType($type)
384
- {
385
- return isset($this->_resourceTypes[$type]);
386
- }
387
-
388
- /**
389
- * Remove the requested resource type
390
- *
391
- * @param string $type
392
- * @return Zend_Loader_Autoloader_Resource
393
- */
394
- public function removeResourceType($type)
395
- {
396
- if ($this->hasResourceType($type)) {
397
- $namespace = $this->_resourceTypes[$type]['namespace'];
398
- unset($this->_components[$namespace]);
399
- unset($this->_resourceTypes[$type]);
400
- }
401
- return $this;
402
- }
403
-
404
- /**
405
- * Clear all resource types
406
- *
407
- * @return Zend_Loader_Autoloader_Resource
408
- */
409
- public function clearResourceTypes()
410
- {
411
- $this->_resourceTypes = array();
412
- $this->_components = array();
413
- return $this;
414
- }
415
-
416
- /**
417
- * Set default resource type to use when calling load()
418
- *
419
- * @param string $type
420
- * @return Zend_Loader_Autoloader_Resource
421
- */
422
- public function setDefaultResourceType($type)
423
- {
424
- if ($this->hasResourceType($type)) {
425
- $this->_defaultResourceType = $type;
426
- }
427
- return $this;
428
- }
429
-
430
- /**
431
- * Get default resource type to use when calling load()
432
- *
433
- * @return string|null
434
- */
435
- public function getDefaultResourceType()
436
- {
437
- return $this->_defaultResourceType;
438
- }
439
-
440
- /**
441
- * Object registry and factory
442
- *
443
- * Loads the requested resource of type $type (or uses the default resource
444
- * type if none provided). If the resource has been loaded previously,
445
- * returns the previous instance; otherwise, instantiates it.
446
- *
447
- * @param string $resource
448
- * @param string $type
449
- * @return object
450
- * @throws Zend_Loader_Exception if resource type not specified or invalid
451
- */
452
- public function load($resource, $type = null)
453
- {
454
- if (null === $type) {
455
- $type = $this->getDefaultResourceType();
456
- if (empty($type)) {
457
- require_once 'Zend/Loader/Exception.php';
458
- throw new Zend_Loader_Exception('No resource type specified');
459
- }
460
- }
461
- if (!$this->hasResourceType($type)) {
462
- require_once 'Zend/Loader/Exception.php';
463
- throw new Zend_Loader_Exception('Invalid resource type specified');
464
- }
465
- $namespace = $this->_resourceTypes[$type]['namespace'];
466
- $class = $namespace . '_' . ucfirst($resource);
467
- if (!isset($this->_resources[$class])) {
468
- $this->_resources[$class] = new $class;
469
- }
470
- return $this->_resources[$class];
471
- }
472
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
4
  Tags: security, encryption, ssl, shared ssl, private ssl, public ssl, private ssl, http, https
5
  Requires at least: 3.0
6
  Tested up to: 3.4
7
- Stable tag: 3.0.1
8
 
9
  WordPress HTTPS is intended to be an all-in-one solution to using SSL on WordPress sites.
10
 
@@ -43,7 +43,7 @@ Most insecure content warnings can generally be resolved by changing absolute re
43
  <ul>
44
  <li>Elements loaded via JavaScript that are hard-coded to HTTP. Usually this can be fixed by altering the JavaScript calling these elements.</li>
45
  <li>External elements that can not be delivered over HTTPS. These elements will have to be removed from the page, or hosted locally so that they can be loaded over HTTPS.</li>
46
- <li>YouTube videos - YouTube does not allow videos to be streamed over HTTPS. YouTube videos will have to be removed from secure pages.</li>
47
  <li>Google Maps - Loading Google maps over HTTPS requires a Google Maps API Premiere account. (<a href="http://code.google.com/apis/maps/faq.html#ssl" target="_blank">source</a>)</li>
48
  </ul>
49
 
@@ -59,11 +59,31 @@ Yes! Here is an example of how to use the 'force_ssl' hook to force a page to be
59
 
60
  add_filter('force_ssl' , 'custom_force_ssl', 10, 2);`
61
 
 
 
 
 
 
 
 
 
 
 
62
  == Screenshots ==
63
  1. WordPress HTTPS Settings screen
64
  2. Force SSL checkbox added to add/edit posts screen
65
 
66
  == Changelog ==
 
 
 
 
 
 
 
 
 
 
67
  = 3.0.1 =
68
  * Bug Fix - Fixed major issue when upgrading from previous version of WordPress HTTPS.
69
  * Bug Fix - Added is_ssl method back to main plugin class to avoid errors with Gravity Forms.
4
  Tags: security, encryption, ssl, shared ssl, private ssl, public ssl, private ssl, http, https
5
  Requires at least: 3.0
6
  Tested up to: 3.4
7
+ Stable tag: 3.0.2
8
 
9
  WordPress HTTPS is intended to be an all-in-one solution to using SSL on WordPress sites.
10
 
43
  <ul>
44
  <li>Elements loaded via JavaScript that are hard-coded to HTTP. Usually this can be fixed by altering the JavaScript calling these elements.</li>
45
  <li>External elements that can not be delivered over HTTPS. These elements will have to be removed from the page, or hosted locally so that they can be loaded over HTTPS.</li>
46
+ <li>YouTube videos - YouTube allows videos to use HTTPS. <a href="http://support.google.com/youtube/bin/answer.py?hl=en&answer=171780&expand=UseHTTPS">How to embed a YouTube video</a>.</li>
47
  <li>Google Maps - Loading Google maps over HTTPS requires a Google Maps API Premiere account. (<a href="http://code.google.com/apis/maps/faq.html#ssl" target="_blank">source</a>)</li>
48
  </ul>
49
 
59
 
60
  add_filter('force_ssl' , 'custom_force_ssl', 10, 2);`
61
 
62
+ You can also use this filter to filter pages based on their URL. Let's say you have an E-commerce site and all of your E-commerce URL's contain 'store'.
63
+ `function store_force_ssl( $force_ssl, $post_id ) {
64
+ if ( strpos($_SERVER['REQUEST_URI'], 'store') !== false ) {
65
+ $force_ssl = true;
66
+ }
67
+ return $force_ssl;
68
+ }
69
+
70
+ add_filter('force_ssl', 'store_force_ssl');`
71
+
72
  == Screenshots ==
73
  1. WordPress HTTPS Settings screen
74
  2. Force SSL checkbox added to add/edit posts screen
75
 
76
  == Changelog ==
77
+ = 3.0.2 =
78
+ * Added setting to change where HTTPS settings appear in the admin panel.
79
+ * Any element on an HTTP page that is set to HTTPS should be auto-corrected.
80
+ * Bug Fix - Plugin should no longer interefere with editing posts and using images from the Media Library.
81
+ * Bug Fix - Fixed major bug that occurred when site was installed in the base directory.
82
+ * Bug Fix - File uploader should no longer produce an HTTP Error.
83
+ * Bug Fix - Fixed performance issue that caused the login page to load for a long period of time.
84
+ * Bug Fix - Proxy check should no longer interfere with RSS Feeds, HTML Validators, etc.
85
+ * Bug Fix - Force SSL and SSL Front Page should no longer conflict.
86
+ * Bug Fix - If Force SSL Exclusively is enabled and Secure Front Page is not (or the front page is not secured), links to the front page will be set to HTTP.
87
  = 3.0.1 =
88
  * Bug Fix - Fixed major issue when upgrading from previous version of WordPress HTTPS.
89
  * Bug Fix - Added is_ssl method back to main plugin class to avoid errors with Gravity Forms.
uninstall.php CHANGED
@@ -15,6 +15,7 @@ delete_option('wordpress-https_ssl_port');
15
  delete_option('wordpress-https_exclusive_https');
16
  delete_option('wordpress-https_frontpage');
17
  delete_option('wordpress-https_ssl_admin');
 
18
  delete_option('wordpress-https_ssl_host_subdomain');
19
  delete_option('wordpress-https_version');
20
  delete_option('wordpress-https_debug');
15
  delete_option('wordpress-https_exclusive_https');
16
  delete_option('wordpress-https_frontpage');
17
  delete_option('wordpress-https_ssl_admin');
18
+ delete_option('wordpress-https_ssl_proxy');
19
  delete_option('wordpress-https_ssl_host_subdomain');
20
  delete_option('wordpress-https_version');
21
  delete_option('wordpress-https_debug');
wordpress-https.php CHANGED
@@ -4,7 +4,7 @@
4
  Plugin URI: http://mvied.com/projects/wordpress-https/
5
  Description: WordPress HTTPS is intended to be an all-in-one solution to using SSL on WordPress sites.
6
  Author: Mike Ems
7
- Version: 3.0.1
8
  Author URI: http://mvied.com/
9
  */
10
 
@@ -15,16 +15,23 @@ $include_paths = array(
15
  );
16
  set_include_path(implode(PATH_SEPARATOR, $include_paths));
17
 
18
- require_once('Zend/Loader/Autoloader.php');
19
- $autoloader = Zend_Loader_Autoloader::getInstance();
20
- $autoloader->registerNamespace('WordPressHTTPS_');
 
 
 
21
 
 
 
 
 
22
  require_once('WordPressHTTPS.php');
23
 
24
  if ( function_exists('get_bloginfo') && ! defined('WP_UNINSTALL_PLUGIN') ) {
25
  $wordpress_https = new WordPressHTTPS;
26
  $wordpress_https->setSlug('wordpress-https');
27
- $wordpress_https->setVersion('3.0.1');
28
  $wordpress_https->setLogger(WordPressHTTPS_Logger::getInstance());
29
  $wordpress_https->setPluginUrl(plugins_url('', __FILE__));
30
  $wordpress_https->setDirectory(dirname(__FILE__));
4
  Plugin URI: http://mvied.com/projects/wordpress-https/
5
  Description: WordPress HTTPS is intended to be an all-in-one solution to using SSL on WordPress sites.
6
  Author: Mike Ems
7
+ Version: 3.0.2
8
  Author URI: http://mvied.com/
9
  */
10
 
15
  );
16
  set_include_path(implode(PATH_SEPARATOR, $include_paths));
17
 
18
+ /*
19
+ * WordPress HTTPS Reset
20
+ * Uncomment the line below (remove the two forward slashes) to reset the plugin to its default settings.
21
+ * When the plugin is reset, comment the line out again.
22
+ */
23
+ //define('WPHTTPS_RESET', true);
24
 
25
+ require_once('WordPressHTTPS/Url.php');
26
+ require_once('WordPressHTTPS/Logger.php');
27
+ require_once('WordPressHTTPS/Module.php');
28
+ require_once('WordPressHTTPS/Plugin.php');
29
  require_once('WordPressHTTPS.php');
30
 
31
  if ( function_exists('get_bloginfo') && ! defined('WP_UNINSTALL_PLUGIN') ) {
32
  $wordpress_https = new WordPressHTTPS;
33
  $wordpress_https->setSlug('wordpress-https');
34
+ $wordpress_https->setVersion('3.0.2');
35
  $wordpress_https->setLogger(WordPressHTTPS_Logger::getInstance());
36
  $wordpress_https->setPluginUrl(plugins_url('', __FILE__));
37
  $wordpress_https->setDirectory(dirname(__FILE__));