Broken Link Checker - Version 0.5.9

Version Description

Download this release

Release Info

Developer whiteshadow
Plugin Icon 128x128 Broken Link Checker
Version 0.5.9
Comparing to
See all releases

Code changes from version 0.5.8.1 to 0.5.9

Files changed (5) hide show
  1. broken-link-checker.php +34 -33
  2. link-classes.php +2 -2
  3. readme.txt +161 -2
  4. utility-class.php +2 -2
  5. wsblc_ajax.php +0 -5
broken-link-checker.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Broken Link Checker
4
  Plugin URI: http://w-shadow.com/blog/2007/08/05/broken-link-checker-for-wordpress/
5
  Description: Checks your posts for broken links and missing images and notifies you on the dashboard if any are found.
6
- Version: 0.5.8.1
7
  Author: Janis Elsts
8
  Author URI: http://w-shadow.com/blog/
9
  */
@@ -38,7 +38,7 @@ if ( ! defined( 'WP_PLUGIN_DIR' ) )
38
  define( 'WP_PLUGIN_DIR', WP_CONTENT_DIR . '/plugins' );
39
 
40
  define('BLC_CHECKING', 1);
41
- define('BLC_TIMEOUT', 1);
42
 
43
  /*
44
  //FirePHP for debugging
@@ -65,6 +65,7 @@ class ws_broken_link_checker {
65
  var $mybasename=''; //should be removed
66
  var $siteurl; //should be removed
67
  var $defaults;
 
68
 
69
  var $execution_start_time; //Used for a simple internal execution timer in start_timer()/execution_time()
70
  var $lockfile_handle = null;
@@ -90,8 +91,9 @@ class ws_broken_link_checker {
90
 
91
  'autoexpand_widget' => true, //Autoexpand the Dashboard widget if broken links are detected
92
 
93
- 'need_resynch' => false, //[Internal flag]
94
 
 
95
  );
96
 
97
  $this->load_options();
@@ -412,11 +414,14 @@ class ws_broken_link_checker {
412
  * ws_broken_link_checker::upgrade_database()
413
  * Create and/or upgrade database tables
414
  *
415
- * @return bool
416
  */
417
  function upgrade_database(){
418
  global $wpdb;
419
 
 
 
 
420
  //Delete tables used by older versions of the plugin
421
  $rez = $wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}blc_linkdata, {$wpdb->prefix}blc_postdata" );
422
  if ( $rez === false ){
@@ -424,14 +429,15 @@ class ws_broken_link_checker {
424
  return false;
425
  }
426
 
 
 
427
  //Create the link table if it doesn't exist yet.
428
- $rez = $wpdb->query(
429
- "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}blc_links (
430
  link_id int(20) unsigned NOT NULL auto_increment,
431
- url text NOT NULL,
432
  last_check datetime NOT NULL default '0000-00-00 00:00:00',
433
  check_count int(2) unsigned NOT NULL default '0',
434
- final_url text NOT NULL,
435
  redirect_count smallint(5) unsigned NOT NULL,
436
  log text NOT NULL,
437
  http_code smallint(6) NOT NULL,
@@ -443,16 +449,19 @@ class ws_broken_link_checker {
443
  KEY final_url (final_url(150)),
444
  KEY http_code (http_code),
445
  KEY timeout (timeout)
446
- )"
447
- );
448
- if ( $rez === false ){
449
- //FB::error($wpdb->last_error, "Database error");
450
- return false;
451
- }
452
-
453
- //Create the instance table if it doesn't exist yet.
454
  $wpdb->query(
455
- "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}blc_instances (
 
 
 
 
 
 
 
456
  instance_id int(10) unsigned NOT NULL auto_increment,
457
  link_id int(10) unsigned NOT NULL,
458
  source_id int(10) unsigned NOT NULL,
@@ -463,30 +472,22 @@ class ws_broken_link_checker {
463
  PRIMARY KEY (instance_id),
464
  KEY link_id (link_id),
465
  KEY source_id (source_id,source_type)
466
- )"
467
- );
468
- if ( $rez === false ){
469
- //FB::error($wpdb->last_error, "Database error");
470
- return false;
471
- }
472
 
473
  //....
474
- $wpdb->query(
475
- "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}blc_synch (
476
  source_id int(20) unsigned NOT NULL,
477
  source_type enum('post','blogroll') NOT NULL,
478
  synched tinyint(3) unsigned NOT NULL,
479
  last_synch datetime NOT NULL,
480
  PRIMARY KEY (source_id, source_type),
481
  KEY synched (synched)
482
- )"
483
- );
484
- if ( $rez === false ){
485
- //FB::error($wpdb->last_error, "Database error");
486
- return false;
487
- }
488
 
489
- return true;
 
490
  }
491
 
492
  function admin_menu(){
@@ -1402,7 +1403,7 @@ jQuery(function($){
1402
  //remove all <code></code> blocks first
1403
  $content = preg_replace('/<code>.+?<\/code>/i', ' ', $content);
1404
  //remove all <pre></pre> blocks as well
1405
- $content = preg_replace('/<pre>.+?<\/pre>/i', ' ', $content);
1406
  //Get the post permalink - it's used to resolve relative URLs
1407
  $permalink = get_permalink( $post_id );
1408
 
3
  Plugin Name: Broken Link Checker
4
  Plugin URI: http://w-shadow.com/blog/2007/08/05/broken-link-checker-for-wordpress/
5
  Description: Checks your posts for broken links and missing images and notifies you on the dashboard if any are found.
6
+ Version: 0.5.9
7
  Author: Janis Elsts
8
  Author URI: http://w-shadow.com/blog/
9
  */
38
  define( 'WP_PLUGIN_DIR', WP_CONTENT_DIR . '/plugins' );
39
 
40
  define('BLC_CHECKING', 1);
41
+ define('BLC_TIMEOUT', 2);
42
 
43
  /*
44
  //FirePHP for debugging
65
  var $mybasename=''; //should be removed
66
  var $siteurl; //should be removed
67
  var $defaults;
68
+ var $db_version = 1;
69
 
70
  var $execution_start_time; //Used for a simple internal execution timer in start_timer()/execution_time()
71
  var $lockfile_handle = null;
91
 
92
  'autoexpand_widget' => true, //Autoexpand the Dashboard widget if broken links are detected
93
 
94
+ 'need_resynch' => false, //[Internal flag]
95
 
96
+ 'current_db_version' => 0, //The current version of the plugin's tables
97
  );
98
 
99
  $this->load_options();
414
  * ws_broken_link_checker::upgrade_database()
415
  * Create and/or upgrade database tables
416
  *
417
+ * @return void
418
  */
419
  function upgrade_database(){
420
  global $wpdb;
421
 
422
+ //Do we need to upgrade?
423
+ if ( $this->db_version == $this->options['current_db_version'] ) return;
424
+
425
  //Delete tables used by older versions of the plugin
426
  $rez = $wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}blc_linkdata, {$wpdb->prefix}blc_postdata" );
427
  if ( $rez === false ){
429
  return false;
430
  }
431
 
432
+ require_once (ABSPATH . 'wp-admin/includes/upgrade.php');
433
+
434
  //Create the link table if it doesn't exist yet.
435
+ $q = "CREATE TABLE {$wpdb->prefix}blc_links (
 
436
  link_id int(20) unsigned NOT NULL auto_increment,
437
+ url text CHARACTER SET latin1 COLLATE latin1_general_cs NOT NULL,
438
  last_check datetime NOT NULL default '0000-00-00 00:00:00',
439
  check_count int(2) unsigned NOT NULL default '0',
440
+ final_url text CHARACTER SET latin1 COLLATE latin1_general_cs NOT NULL,
441
  redirect_count smallint(5) unsigned NOT NULL,
442
  log text NOT NULL,
443
  http_code smallint(6) NOT NULL,
449
  KEY final_url (final_url(150)),
450
  KEY http_code (http_code),
451
  KEY timeout (timeout)
452
+ )";
453
+ dbDelta( $q );
454
+
455
+ //Fix URL fields so that they are collated as case-sensitive (this can't be done via dbDelta)
 
 
 
 
456
  $wpdb->query(
457
+ "ALTER TABLE {$wpdb->prefix}blc_links
458
+ MODIFY url text CHARACTER SET latin1 COLLATE latin1_general_cs NOT NULL,
459
+ MODIFY final_url text CHARACTER SET latin1 COLLATE latin1_general_cs NOT NULL"
460
+ );
461
+
462
+
463
+ //Create the instance table if it doesn't exist yet.
464
+ $q = "CREATE TABLE {$wpdb->prefix}blc_instances (
465
  instance_id int(10) unsigned NOT NULL auto_increment,
466
  link_id int(10) unsigned NOT NULL,
467
  source_id int(10) unsigned NOT NULL,
472
  PRIMARY KEY (instance_id),
473
  KEY link_id (link_id),
474
  KEY source_id (source_id,source_type)
475
+ )";
476
+ $rez = dbDelta($q);
 
 
 
 
477
 
478
  //....
479
+ $q = "CREATE TABLE {$wpdb->prefix}blc_synch (
 
480
  source_id int(20) unsigned NOT NULL,
481
  source_type enum('post','blogroll') NOT NULL,
482
  synched tinyint(3) unsigned NOT NULL,
483
  last_synch datetime NOT NULL,
484
  PRIMARY KEY (source_id, source_type),
485
  KEY synched (synched)
486
+ )";
487
+ dbDelta($q);
 
 
 
 
488
 
489
+ $this->options['current_db_version'] = $this->db_version;
490
+ $this->save_options();
491
  }
492
 
493
  function admin_menu(){
1403
  //remove all <code></code> blocks first
1404
  $content = preg_replace('/<code>.+?<\/code>/i', ' ', $content);
1405
  //remove all <pre></pre> blocks as well
1406
+ $content = preg_replace('/<pre[^>]*>.+?<\/pre>/i', ' ', $content);
1407
  //Get the post permalink - it's used to resolve relative URLs
1408
  $permalink = get_permalink( $post_id );
1409
 
link-classes.php CHANGED
@@ -221,7 +221,7 @@ class blcLink {
221
  $this->log .= $this->last_headers."\n";
222
  }
223
 
224
- $this->http_code = $code;
225
  $this->final_url = $info['url'];
226
  $this->request_duration = $info['total_time'];
227
  $this->redirect_count = $info['redirect_count'];
@@ -279,7 +279,7 @@ class blcLink {
279
  if ( $this->http_code == BLC_TIMEOUT ){
280
  //This is probably a timeout
281
  $this->timeout = true;
282
- $this->log .= "\r\n(Most likely the connection timed out)";
283
  }
284
  return false;
285
  }
221
  $this->log .= $this->last_headers."\n";
222
  }
223
 
224
+ $this->http_code = $code!=0 ? $code : BLC_TIMEOUT;
225
  $this->final_url = $info['url'];
226
  $this->request_duration = $info['total_time'];
227
  $this->redirect_count = $info['redirect_count'];
279
  if ( $this->http_code == BLC_TIMEOUT ){
280
  //This is probably a timeout
281
  $this->timeout = true;
282
+ $this->log .= "\r\n(Most likely the connection timed out or the domain doesn't exist)";
283
  }
284
  return false;
285
  }
readme.txt CHANGED
@@ -3,9 +3,9 @@ Contributors: whiteshadow
3
  Tags: links, broken, maintenance, blogroll, custom fields, admin
4
  Requires at least: 2.7.0
5
  Tested up to: 2.9
6
- Stable tag: 0.5.8.1
7
 
8
- This plugin will check your posts, custom fields and the blogroll for broken links and missing images and notify you on the dashboard if any are found.
9
 
10
  == Description ==
11
  This plugin will monitor your blog looking for broken links and let you know if any are found.
@@ -55,3 +55,162 @@ To upgrade your installation
55
  1. De-activate the plugin
56
  1. Get and upload the new files (do steps 1. - 3. from "new installation" instructions)
57
  1. Reactivate the plugin. Your settings should have been retained from the previous version.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  Tags: links, broken, maintenance, blogroll, custom fields, admin
4
  Requires at least: 2.7.0
5
  Tested up to: 2.9
6
+ Stable tag: 0.5.9
7
 
8
+ This plugin will check your posts, custom fields and the blogroll for broken links and missing images and notify you if any are found.
9
 
10
  == Description ==
11
  This plugin will monitor your blog looking for broken links and let you know if any are found.
55
  1. De-activate the plugin
56
  1. Get and upload the new files (do steps 1. - 3. from "new installation" instructions)
57
  1. Reactivate the plugin. Your settings should have been retained from the previous version.
58
+
59
+ == Changelog ==
60
+
61
+ = 0.5.8.1 =
62
+ * Added partial proxy support when CURL is available. Proxies will be fully supported in a later version.
63
+
64
+ = 0.5.8 =
65
+ * Fixed links that are currently in the process of being checked showing up in the "Broken links" table.
66
+ * The post parser no longer looks for links inside <pre></pre> blocks.
67
+
68
+ = 0.5.7 =
69
+ * Slightly changed the dashboard widget's layout/look as per a user's request.
70
+
71
+ = 0.5.6 =
72
+ * Improved relative URL parsing. The plugin now uses the permalink as the base URL when processing posts.
73
+
74
+ = 0.5.5 =
75
+ * URLs with spaces (and some other special characters) are now handled better and won't get marked as "broken" all the time.
76
+ * Links that contain quote characters are parsed properly.
77
+
78
+ = 0.5.4 =
79
+ * Fixed the uninstaller not deleting DB tables.
80
+ * Other uninstallation logic fixes.
81
+
82
+ = 0.5.3 =
83
+ * Improved timeout detection/handling when using Snoopy.
84
+ * Set the max download size to 5 KB when using Snoopy.
85
+ * Fixed a rare bug where the settings page would redirect to the login screen when saving settings.
86
+ * Removed some stale, unused code (some still remains).
87
+
88
+ = 0.5.2 =
89
+ * Fixed a SQL query that had the table prefix hard-coded as "wp\_". This would previously make the plugin detect zero links on sites that have a different table prefix.
90
+
91
+ = 0.5.1 =
92
+ * Fix a bug when the plugin creates a DB table with the wrong prefix.
93
+
94
+ = 0.5 =
95
+ * This is a near-complete rewrite with a lot of new features. See �http://w-shadow.com/blog/2009/05/22/broken-link-checker-05/ for details.
96
+
97
+ = 0.4.14 =
98
+ * Fix false positives when the URL contains an #anchor
99
+
100
+ = 0.4.13 =
101
+ * (Hopefully) fix join() failure when Snoopy doesn't return any HTTP headers.
102
+
103
+ = 0.4.12 =
104
+ * *There are no release notes for this version*
105
+
106
+ = 0.4.11 =
107
+ * Set the Referer header to blog's home address when checking a link. This should help deal with some bot traps.
108
+ * I know, I know - there haven't been any major updates for a while. But there will be eventually :)
109
+ * Fix SQL error when a post is deleted.
110
+
111
+ = 0.4.10 =
112
+ * Changed required access caps for "Manage -> Broken Links" from manage\_options to edit\_ohers\_posts. This will allow editor users to access that page and it's functions.
113
+
114
+ = 0.4.9 =
115
+ * Link sorting, somewhat experimental.
116
+ * JavaScript sorting feature for the broken link list.
117
+
118
+ = 0.4.8 =
119
+ * CURL isn't required anymore. Snoopy is used when CURL isn't available.
120
+ * Post title in broken link list is now a link to the post (permalink). Consequently, removed "View" button.
121
+ * Added a "Details" link. Clicking it will show/hide more info about the reported link.
122
+ * "Unlink" and "Edit" now work for images, too. "Unlink" simply removes the image.
123
+ * Database modifications to enable the changes described above.
124
+ * Moved the URL checking function from wsblc\_ajax.php to broken-link-checker.php; made it more flexible.
125
+ * New and improved (TM) regexps for finding links and images.
126
+ * A "Settings" link added to plugin's action links.
127
+ * And probably other stuff I forgot!
128
+
129
+ = 0.4.7 =
130
+ * Autoselect link URL after the user clicks "Edit".
131
+ * Make sure only HTTP and HTTPS links are checked.
132
+ * More substantive improvements will hopefully follow next week.
133
+
134
+ = 0.4.6 =
135
+ * Minor compatibility enhancement in wsblc\_ajax.php - don't load wpdb if it's already loaded.
136
+
137
+ = 0.4.5 =
138
+ * Revisions don't get added to the work queue anymore.
139
+ * Workaround for rare cURL timeout bug.
140
+ * Improved WP 2.6 compatibility.
141
+ * Correctly handle URLs containing a single quote '.
142
+
143
+ = 0.4.4 =
144
+ * Consider a HTTP 401 response OK. Such links won't be marked as broken anymore.
145
+
146
+ = 0.4.3 =
147
+ * Fix : Don't check links in revisions, only posts/pages.
148
+
149
+ = 0.4.2 =
150
+ * *There are no release notes for this version*
151
+
152
+ = 0.4.1 =
153
+ * Split translated version from the previous code. Was causing weird problems.
154
+
155
+ = 0.4-i8n =
156
+ * *There are no release notes for this version*
157
+
158
+ = 0.4 =
159
+ * Added localization support (may be buggy).
160
+
161
+ = 0.3.9 =
162
+ * Fix : Use get\_permalink to get the "View" link. Old behavior was to use the GUID.
163
+
164
+ = 0.3.8 =
165
+ * Edit broken links @ Manage -> Broken Links (experimental)
166
+
167
+ = 0.3.7 =
168
+ * Change: A bit more verbose DB error reporting for the "unlink" feature.
169
+
170
+ = 0.3.6 =
171
+ * Switch from wp\_print\_scripts() to wp\_enqueue\_script()
172
+ * Wp\_enqueue\_script()
173
+
174
+ = 0.3.5 =
175
+ * New: "Delete Post" option.
176
+ * New: Increase the compatibility number.
177
+ * Change: Default options are now handled in the class constructor.
178
+
179
+ = 0.3.4 =
180
+ * Ignore mailto: links
181
+ * Ignore links inside <code> blocks
182
+
183
+ = 0.3.3 =
184
+ * *There are no release notes for this version*
185
+
186
+ = 0.3.2 =
187
+ * Fix Unlink button not working, some other random fixes
188
+
189
+ = 0.3.1 =
190
+ * *There are no release notes for this version*
191
+
192
+ = 0.3 =
193
+ * *There are no release notes for this version*
194
+
195
+ = 0.2.5 =
196
+ * Applied a small patch @ 347
197
+ * Fix some omissions
198
+ * Lots of new features in version 0.3
199
+
200
+ = 0.2.4 =
201
+ * Bigfix - use GET when HEAD fails
202
+
203
+ = 0.2.3 =
204
+ * MySQL 4.0 compatibility + recheck\_all\_posts function
205
+
206
+ = 0.2.2.1 =
207
+ * *There are no release notes for this version*
208
+
209
+ = 0.2.2 =
210
+ * *There are no release notes for this version*
211
+
212
+ = 0.2 =
213
+ * *There are no release notes for this version*
214
+
215
+ = 0.1 =
216
+ * *There are no release notes for this version*
utility-class.php CHANGED
@@ -6,13 +6,13 @@
6
  */
7
 
8
 
9
- if (!function_exists('json_encode')){
10
  //Load JSON functions for PHP < 5.2
11
  if (!class_exists('Services_JSON')){
12
  require 'JSON.php';
13
  }
14
 
15
- //Backwards compatible json_encode.
16
  function json_encode($data) {
17
  $json = new Services_JSON();
18
  return( $json->encode($data) );
6
  */
7
 
8
 
9
+ if (is_admin() && !function_exists('json_encode')){
10
  //Load JSON functions for PHP < 5.2
11
  if (!class_exists('Services_JSON')){
12
  require 'JSON.php';
13
  }
14
 
15
+ //Backwards compatible "\color{clGray}tell if the user should be accessing a section or not."
16
  function json_encode($data) {
17
  $json = new Services_JSON();
18
  return( $json->encode($data) );
wsblc_ajax.php DELETED
@@ -1,5 +0,0 @@
1
- <?php
2
- /*
3
- This file isn't used anymore.
4
- */
5
- ?>