Version Description
- Let the user set a custom temporary directory, if the default one is not accessible for some reason.
Download this release
Release Info
Developer | whiteshadow |
Plugin | Broken Link Checker |
Version | 0.5.12 |
Comparing to | |
See all releases |
Code changes from version 0.5.11 to 0.5.12
- broken-link-checker.php +7 -3
- core.php +114 -58
- readme.txt +19 -1
- utility-class.php +2 -2
broken-link-checker.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
Plugin Name: Broken Link Checker
|
5 |
Plugin URI: http://w-shadow.com/blog/2007/08/05/broken-link-checker-for-wordpress/
|
6 |
Description: Checks your posts for broken links and missing images and notifies you on the dashboard if any are found.
|
7 |
-
Version: 0.5.
|
8 |
Author: Janis Elsts
|
9 |
Author URI: http://w-shadow.com/blog/
|
10 |
*/
|
@@ -65,8 +65,12 @@ $blc_config_manager = new blcConfigurationManager(
|
|
65 |
|
66 |
'autoexpand_widget' => true, //Autoexpand the Dashboard widget if broken links are detected
|
67 |
|
68 |
-
|
69 |
-
|
|
|
|
|
|
|
|
|
70 |
)
|
71 |
);
|
72 |
|
4 |
Plugin Name: Broken Link Checker
|
5 |
Plugin URI: http://w-shadow.com/blog/2007/08/05/broken-link-checker-for-wordpress/
|
6 |
Description: Checks your posts for broken links and missing images and notifies you on the dashboard if any are found.
|
7 |
+
Version: 0.5.12
|
8 |
Author: Janis Elsts
|
9 |
Author URI: http://w-shadow.com/blog/
|
10 |
*/
|
65 |
|
66 |
'autoexpand_widget' => true, //Autoexpand the Dashboard widget if broken links are detected
|
67 |
|
68 |
+
'need_resynch' => false, //[Internal flag]
|
69 |
+
'current_db_version' => 0, //The current version of the plugin's tables
|
70 |
+
|
71 |
+
'custom_tmp_dir' => '', //The lockfile will be stored in this directory.
|
72 |
+
//If this option is not set, the plugin's own directory or the
|
73 |
+
//system-wide /tmp directory will be used instead.
|
74 |
)
|
75 |
);
|
76 |
|
core.php
CHANGED
@@ -450,53 +450,56 @@ class wsBrokenLinkChecker {
|
|
450 |
if (isset($_GET['recheck']) && ($_GET['recheck'] == 'true')) {
|
451 |
$this->initiate_recheck();
|
452 |
}
|
453 |
-
if
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
}
|
461 |
-
|
462 |
-
$new_check_threshold=intval($_POST['check_threshold']);
|
463 |
-
if( $new_check_threshold > 0 ){
|
464 |
-
$this->conf->options['check_threshold'] = $new_check_threshold;
|
465 |
-
}
|
466 |
-
|
467 |
-
$this->conf->options['mark_broken_links'] = !empty($_POST['mark_broken_links']);
|
468 |
-
$new_broken_link_css = trim($_POST['broken_link_css']);
|
469 |
-
$this->conf->options['broken_link_css'] = $new_broken_link_css;
|
470 |
-
|
471 |
-
$this->conf->options['exclusion_list']=array_filter( preg_split( '/[\s\r\n]+/',
|
472 |
-
$_POST['exclusion_list'], -1, PREG_SPLIT_NO_EMPTY ) );
|
473 |
-
//TODO: Maybe update affected links when exclusion list changes (expensive).
|
474 |
-
|
475 |
-
|
476 |
-
$new_custom_fields = array_filter( preg_split( '/[\s\r\n]+/',
|
477 |
-
$_POST['blc_custom_fields'], -1, PREG_SPLIT_NO_EMPTY ) );
|
478 |
-
$diff1 = array_diff( $new_custom_fields, $this->conf->options['custom_fields'] );
|
479 |
-
$diff2 = array_diff( $this->conf->options['custom_fields'], $new_custom_fields );
|
480 |
-
$this->conf->options['custom_fields'] = $new_custom_fields;
|
481 |
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
If the list of custom fields was modified then we MUST resynchronize or
|
486 |
-
custom fields linked with existing posts may not be detected. This is somewhat
|
487 |
-
inefficient.
|
488 |
-
*/
|
489 |
-
if ( ( count($diff1) > 0 ) || ( count($diff2) > 0 ) ){
|
490 |
-
$this->resynch();
|
491 |
-
}
|
492 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
493 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
494 |
}
|
495 |
|
496 |
?>
|
497 |
<div class="wrap"><h2>Broken Link Checker Options</h2>
|
498 |
-
|
499 |
-
<form name="link_checker_options" method="post" action="<?php
|
|
|
|
|
500 |
<?php
|
501 |
wp_nonce_field('link-checker-options');
|
502 |
?>
|
@@ -558,9 +561,12 @@ class wsBrokenLinkChecker {
|
|
558 |
<tr valign="top">
|
559 |
<th scope="row">Broken link CSS</th>
|
560 |
<td>
|
561 |
-
|
562 |
-
|
563 |
-
|
|
|
|
|
|
|
564 |
<textarea name="broken_link_css" id="broken_link_css" cols='45' rows='4'/><?php
|
565 |
if( isset($this->conf->options['broken_link_css']) )
|
566 |
echo $this->conf->options['broken_link_css'];
|
@@ -588,6 +594,36 @@ class wsBrokenLinkChecker {
|
|
588 |
echo implode("\n", $this->conf->options['custom_fields']);
|
589 |
?></textarea>
|
590 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
591 |
</td>
|
592 |
</tr>
|
593 |
|
@@ -2050,17 +2086,23 @@ jQuery(function($){
|
|
2050 |
* @return string A filename or FALSE on error
|
2051 |
*/
|
2052 |
function lockfile_name(){
|
2053 |
-
//Try
|
2054 |
-
|
2055 |
-
|
2056 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2057 |
} else {
|
2058 |
-
//Try the
|
2059 |
-
|
2060 |
-
|
2061 |
-
|
2062 |
-
} else if ( is_writable( WP_CONTENT_DIR ) ){
|
2063 |
-
return WP_CONTENT_DIR . '/wp_blc_lock';
|
2064 |
} else {
|
2065 |
//Fail.
|
2066 |
return false;
|
@@ -2111,11 +2153,24 @@ jQuery(function($){
|
|
2111 |
$my_dir = '/plugins/' . basename(dirname(__FILE__)) . '/';
|
2112 |
$settings_page = admin_url( 'options-general.php?page=link-checker-settings#lockfile_directory' );
|
2113 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2114 |
echo sprintf('
|
2115 |
<div id="blc-lockfile-warning" class="error"><p>
|
2116 |
-
<strong>Broken Link Checker can\'t create a lockfile.</strong>
|
2117 |
-
Please make the directory <code>%s</code> writable by plugins.
|
2118 |
-
|
2119 |
<a href="javascript:void(0)" onclick="jQuery(\'#blc-lockfile-details\').toggle()">Details</a>
|
2120 |
</p>
|
2121 |
|
@@ -2124,11 +2179,12 @@ jQuery(function($){
|
|
2124 |
resource-heavy link checking algorithm is running at any given time. Unfortunately,
|
2125 |
BLC can\'t find a writable directory where it could store the lockfile - it failed to
|
2126 |
detect the location of your server\'s temporary directory, and the plugin\'s own directory
|
2127 |
-
isn\'t writable by PHP. To fix this problem, please make the plugin\'s directory writable
|
|
|
2128 |
</p>
|
2129 |
</div>
|
2130 |
</div>',
|
2131 |
-
$
|
2132 |
}
|
2133 |
|
2134 |
}//class ends here
|
450 |
if (isset($_GET['recheck']) && ($_GET['recheck'] == 'true')) {
|
451 |
$this->initiate_recheck();
|
452 |
}
|
453 |
+
if(isset($_POST['submit'])) {
|
454 |
+
check_admin_referer('link-checker-options');
|
455 |
+
|
456 |
+
$new_execution_time = intval($_POST['max_execution_time']);
|
457 |
+
if( $new_execution_time > 0 ){
|
458 |
+
$this->conf->options['max_execution_time'] = $new_execution_time;
|
459 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
460 |
|
461 |
+
$new_check_threshold=intval($_POST['check_threshold']);
|
462 |
+
if( $new_check_threshold > 0 ){
|
463 |
+
$this->conf->options['check_threshold'] = $new_check_threshold;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
464 |
}
|
465 |
+
|
466 |
+
$this->conf->options['mark_broken_links'] = !empty($_POST['mark_broken_links']);
|
467 |
+
$new_broken_link_css = trim($_POST['broken_link_css']);
|
468 |
+
$this->conf->options['broken_link_css'] = $new_broken_link_css;
|
469 |
+
|
470 |
+
$this->conf->options['exclusion_list']=array_filter( preg_split( '/[\s\r\n]+/',
|
471 |
+
$_POST['exclusion_list'], -1, PREG_SPLIT_NO_EMPTY ) );
|
472 |
+
//TODO: Maybe update affected links when exclusion list changes (expensive).
|
473 |
+
|
474 |
+
$new_custom_fields = array_filter( preg_split( '/[\s\r\n]+/',
|
475 |
+
$_POST['blc_custom_fields'], -1, PREG_SPLIT_NO_EMPTY ) );
|
476 |
+
$diff1 = array_diff( $new_custom_fields, $this->conf->options['custom_fields'] );
|
477 |
+
$diff2 = array_diff( $this->conf->options['custom_fields'], $new_custom_fields );
|
478 |
+
$this->conf->options['custom_fields'] = $new_custom_fields;
|
479 |
+
|
480 |
+
$this->conf->options['custom_tmp_dir'] = trim(stripslashes(strval($_POST['custom_tmp_dir'])));
|
481 |
|
482 |
+
$this->conf->save_options();
|
483 |
+
|
484 |
+
/*
|
485 |
+
If the list of custom fields was modified then we MUST resynchronize or
|
486 |
+
custom fields linked with existing posts may not be detected. This is somewhat
|
487 |
+
inefficient.
|
488 |
+
*/
|
489 |
+
if ( ( count($diff1) > 0 ) || ( count($diff2) > 0 ) ){
|
490 |
+
$this->resynch();
|
491 |
+
}
|
492 |
+
|
493 |
+
$base_url = remove_query_arg( array('_wpnonce', 'noheader', 'updated', 'error', 'action', 'message') );
|
494 |
+
wp_redirect( add_query_arg( array( 'updated' => 1), $base_url ) );
|
495 |
}
|
496 |
|
497 |
?>
|
498 |
<div class="wrap"><h2>Broken Link Checker Options</h2>
|
499 |
+
|
500 |
+
<form name="link_checker_options" method="post" action="<?php
|
501 |
+
echo admin_url('options-general.php?page=link-checker-settings&noheader=1');
|
502 |
+
?>">
|
503 |
<?php
|
504 |
wp_nonce_field('link-checker-options');
|
505 |
?>
|
561 |
<tr valign="top">
|
562 |
<th scope="row">Broken link CSS</th>
|
563 |
<td>
|
564 |
+
<label for='mark_broken_links'>
|
565 |
+
<input type="checkbox" name="mark_broken_links" id="mark_broken_links"
|
566 |
+
<?php if ($this->conf->options['mark_broken_links']) echo ' checked="checked"'; ?>/>
|
567 |
+
Apply <em>class="broken_link"</em> to broken links
|
568 |
+
</label>
|
569 |
+
<br/>
|
570 |
<textarea name="broken_link_css" id="broken_link_css" cols='45' rows='4'/><?php
|
571 |
if( isset($this->conf->options['broken_link_css']) )
|
572 |
echo $this->conf->options['broken_link_css'];
|
594 |
echo implode("\n", $this->conf->options['custom_fields']);
|
595 |
?></textarea>
|
596 |
|
597 |
+
</td>
|
598 |
+
</tr>
|
599 |
+
|
600 |
+
<tr valign="top">
|
601 |
+
<th scope="row">
|
602 |
+
<a name='lockfile_directory'></a>Custom temporary directory (advanced)</th>
|
603 |
+
<td>
|
604 |
+
|
605 |
+
<input type="text" name="custom_tmp_dir" id="custom_tmp_dir"
|
606 |
+
value="<?php echo htmlspecialchars( $this->conf->options['custom_tmp_dir'] ); ?>" size='53' maxlength='500'/>
|
607 |
+
<?php
|
608 |
+
if ( !empty( $this->conf->options['custom_tmp_dir'] ) ) {
|
609 |
+
if ( is_dir( $this->conf->options['custom_tmp_dir'] ) ){
|
610 |
+
if ( is_writable( $this->conf->options['custom_tmp_dir'] ) ){
|
611 |
+
echo "<strong>OK</strong>";
|
612 |
+
} else {
|
613 |
+
echo '<span class="error">Error : This directory isn\'t writable by PHP.</span>';
|
614 |
+
}
|
615 |
+
} else {
|
616 |
+
echo '<span class="error">Error : This directory doesn\'t exist.</span>';
|
617 |
+
}
|
618 |
+
}
|
619 |
+
|
620 |
+
?>
|
621 |
+
<br/>
|
622 |
+
<span class="description">
|
623 |
+
Set this field if you want the plugin to use a custom directory for it's lockfiles.
|
624 |
+
Otherwise, leave it blank.
|
625 |
+
</span>
|
626 |
+
|
627 |
</td>
|
628 |
</tr>
|
629 |
|
2086 |
* @return string A filename or FALSE on error
|
2087 |
*/
|
2088 |
function lockfile_name(){
|
2089 |
+
//Try the user-specified temp. directory first, if any
|
2090 |
+
if ( !empty( $this->conf->options['custom_tmp_dir'] ) ) {
|
2091 |
+
if ( is_writable($this->conf->options['custom_tmp_dir']) && is_dir($this->conf->options['custom_tmp_dir']) ) {
|
2092 |
+
return trailingslashit($this->conf->options['custom_tmp_dir']) . 'wp_blc_lock';
|
2093 |
+
} else {
|
2094 |
+
return false;
|
2095 |
+
}
|
2096 |
+
}
|
2097 |
+
|
2098 |
+
//Try the plugin's own directory.
|
2099 |
+
if ( is_writable( dirname(__FILE__) ) ){
|
2100 |
+
return dirname(__FILE__) . '/wp_blc_lock';
|
2101 |
} else {
|
2102 |
+
//Try the system-wide temp directory
|
2103 |
+
$path = sys_get_temp_dir();
|
2104 |
+
if ( $path && is_writable($path)){
|
2105 |
+
return trailingslashit($path) . 'wp_blc_lock';
|
|
|
|
|
2106 |
} else {
|
2107 |
//Fail.
|
2108 |
return false;
|
2153 |
$my_dir = '/plugins/' . basename(dirname(__FILE__)) . '/';
|
2154 |
$settings_page = admin_url( 'options-general.php?page=link-checker-settings#lockfile_directory' );
|
2155 |
|
2156 |
+
//Make the notice customized to the current settings
|
2157 |
+
if ( !empty($this->conf->options['custom_tmp_dir']) ){
|
2158 |
+
$action_notice = sprintf(
|
2159 |
+
'The current temporary directory is not accessible;
|
2160 |
+
please <a href="%s">set a different one</a>.',
|
2161 |
+
$settings_page
|
2162 |
+
);
|
2163 |
+
} else {
|
2164 |
+
$action_notice = sprintf(
|
2165 |
+
'Please make the directory <code>%s</code> writable by plugins or
|
2166 |
+
<a href="%s">set a custom temporary directory</a>.',
|
2167 |
+
$my_dir, $settings_page
|
2168 |
+
);
|
2169 |
+
}
|
2170 |
+
|
2171 |
echo sprintf('
|
2172 |
<div id="blc-lockfile-warning" class="error"><p>
|
2173 |
+
<strong>Broken Link Checker can\'t create a lockfile.</strong> %s
|
|
|
|
|
2174 |
<a href="javascript:void(0)" onclick="jQuery(\'#blc-lockfile-details\').toggle()">Details</a>
|
2175 |
</p>
|
2176 |
|
2179 |
resource-heavy link checking algorithm is running at any given time. Unfortunately,
|
2180 |
BLC can\'t find a writable directory where it could store the lockfile - it failed to
|
2181 |
detect the location of your server\'s temporary directory, and the plugin\'s own directory
|
2182 |
+
isn\'t writable by PHP. To fix this problem, please make the plugin\'s directory writable
|
2183 |
+
or enter a specify a custom temporary directory in the plugin\'s settings.
|
2184 |
</p>
|
2185 |
</div>
|
2186 |
</div>',
|
2187 |
+
$action_notice);
|
2188 |
}
|
2189 |
|
2190 |
}//class ends here
|
readme.txt
CHANGED
@@ -3,7 +3,7 @@ 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.
|
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 |
|
@@ -60,6 +60,24 @@ To upgrade your installation
|
|
60 |
|
61 |
*This is an automatically generated changelog*
|
62 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
= 0.5.9 =
|
64 |
* Added an autogenerated changelog.
|
65 |
* Added a workaround to make this plugin compatible with the SimplePress forum.
|
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.12
|
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 |
|
60 |
|
61 |
*This is an automatically generated changelog*
|
62 |
|
63 |
+
= 0.5.12 =
|
64 |
+
* Let the user set a custom temporary directory, if the default one is not accessible for some reason.
|
65 |
+
|
66 |
+
= 0.5.11 =
|
67 |
+
* Use absolute paths when loading includes. Apparently using the relative path could cause issues in some server configurations.
|
68 |
+
|
69 |
+
= 0.5.10.1 =
|
70 |
+
* Fix a stupid typo
|
71 |
+
|
72 |
+
= 0.5.10 =
|
73 |
+
* Separated the user-side functions from the admin-side code so that the plugin only loads what's required.
|
74 |
+
* Changed some internal flags yet again.
|
75 |
+
* Changed the algorithm for finding the server's temp directory.
|
76 |
+
* Fixed the URL extraction regexp again; turns out backreferences inside character classes don't work.
|
77 |
+
* Process shortcodes in URLs.
|
78 |
+
* If the plugin can't find a usable directory for temporary files, try wp-content.
|
79 |
+
* Don't remove <pre> tags before parsing the post. Turns out they can actually contain valid links (oops).
|
80 |
+
|
81 |
= 0.5.9 =
|
82 |
* Added an autogenerated changelog.
|
83 |
* Added a workaround to make this plugin compatible with the SimplePress forum.
|
utility-class.php
CHANGED
@@ -12,7 +12,7 @@ if ( is_admin() && !function_exists('json_encode') ){
|
|
12 |
require 'JSON.php';
|
13 |
}
|
14 |
|
15 |
-
//Backwards compatible
|
16 |
function json_encode($data) {
|
17 |
$json = new Services_JSON();
|
18 |
return( $json->encode($data) );
|
@@ -24,7 +24,7 @@ if ( !function_exists('sys_get_temp_dir')) {
|
|
24 |
if (!empty($_ENV['TMP'])) { return realpath($_ENV['TMP']); }
|
25 |
if (!empty($_ENV['TMPDIR'])) { return realpath( $_ENV['TMPDIR']); }
|
26 |
if (!empty($_ENV['TEMP'])) { return realpath( $_ENV['TEMP']); }
|
27 |
-
$tempfile=tempnam(uniqid(rand(),TRUE),'');
|
28 |
if (file_exists($tempfile)) {
|
29 |
unlink($tempfile);
|
30 |
return realpath(dirname($tempfile));
|
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) );
|
24 |
if (!empty($_ENV['TMP'])) { return realpath($_ENV['TMP']); }
|
25 |
if (!empty($_ENV['TMPDIR'])) { return realpath( $_ENV['TMPDIR']); }
|
26 |
if (!empty($_ENV['TEMP'])) { return realpath( $_ENV['TEMP']); }
|
27 |
+
$tempfile = tempnam(uniqid(rand(),TRUE),'');
|
28 |
if (file_exists($tempfile)) {
|
29 |
unlink($tempfile);
|
30 |
return realpath(dirname($tempfile));
|