broken-link-checker
Last commit date
images
17 years ago
languages
16 years ago
JSON.php
17 years ago
broken-link-checker.php
16 years ago
config-manager.php
16 years ago
core.php
16 years ago
highlighter-class.php
16 years ago
instance-classes.php
16 years ago
link-classes.php
16 years ago
readme.txt
16 years ago
uninstall.php
16 years ago
utility-class.php
16 years ago
broken-link-checker.php
100 lines
| 1 | <?php |
| 2 | |
| 3 | /* |
| 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.6.1 |
| 8 | Author: Janis Elsts |
| 9 | Author URI: http://w-shadow.com/blog/ |
| 10 | */ |
| 11 | |
| 12 | /* |
| 13 | Created by Janis Elsts (email : whiteshadow@w-shadow.com) |
| 14 | MySQL 4.0 compatibility by Jeroen (www.yukka.eu) |
| 15 | */ |
| 16 | |
| 17 | define('BLC_DEBUG', false); |
| 18 | |
| 19 | /* |
| 20 | //FirePHP for debugging |
| 21 | if ( !class_exists('FB') ) { |
| 22 | require_once 'FirePHPCore/fb.php4'; |
| 23 | } |
| 24 | //FB::setEnabled(false); |
| 25 | |
| 26 | //to comment out all calls : (^[^\/]*)(FB::) -> $1\/\/$2 |
| 27 | //to uncomment : \/\/(\s*FB::) -> $1 |
| 28 | //*/ |
| 29 | |
| 30 | //Make sure some useful constants are defined |
| 31 | if ( ! defined( 'WP_CONTENT_URL' ) ) |
| 32 | define( 'WP_CONTENT_URL', get_option( 'siteurl' ) . '/wp-content' ); |
| 33 | if ( ! defined( 'WP_CONTENT_DIR' ) ) |
| 34 | define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' ); |
| 35 | if ( ! defined( 'WP_PLUGIN_URL' ) ) |
| 36 | define( 'WP_PLUGIN_URL', WP_CONTENT_URL. '/plugins' ); |
| 37 | if ( ! defined( 'WP_PLUGIN_DIR' ) ) |
| 38 | define( 'WP_PLUGIN_DIR', WP_CONTENT_DIR . '/plugins' ); |
| 39 | |
| 40 | //The HTTP code of a link record can be set to one of these in some special circumstances |
| 41 | if ( ! defined('BLC_CHECKING') ) |
| 42 | define('BLC_CHECKING', 1); //The link is currently being checked. If this state persists, suspect a glitch. |
| 43 | if ( ! defined('BLC_TIMEOUT') ) |
| 44 | define('BLC_TIMEOUT', 0); //The code used for links that timed out and didn't return an actual response. |
| 45 | |
| 46 | //Load and initialize the plugin's configuration |
| 47 | $blc_directory = dirname(__FILE__); |
| 48 | require $blc_directory . '/config-manager.php'; |
| 49 | $blc_config_manager = new blcConfigurationManager( |
| 50 | //Save the plugin's configuration into this DB option |
| 51 | 'wsblc_options', |
| 52 | //Initialize default settings |
| 53 | array( |
| 54 | 'max_execution_time' => 5*60, //How long the worker instance may run, at most. |
| 55 | 'check_threshold' => 72, //Check each link every 72 hours. |
| 56 | 'mark_broken_links' => true, //Whether to add the broken_link class to broken links in posts. |
| 57 | 'broken_link_css' => ".broken_link, a.broken_link {\n\ttext-decoration: line-through;\n}", |
| 58 | 'exclusion_list' => array(), //Links that contain a substring listed in this array won't be checked. |
| 59 | 'recheck_count' => 3, //[Internal] How many times a broken link should be re-checked (slightly buggy) |
| 60 | |
| 61 | //These three are currently ignored. Everything is checked by default. |
| 62 | 'check_posts' => true, |
| 63 | 'check_custom_fields' => true, |
| 64 | 'check_blogroll' => true, |
| 65 | |
| 66 | 'custom_fields' => array(), //List of custom fields that can contain URLs and should be checked. |
| 67 | |
| 68 | 'autoexpand_widget' => true, //Autoexpand the Dashboard widget if broken links are detected |
| 69 | |
| 70 | 'need_resynch' => false, //[Internal flag] |
| 71 | 'current_db_version' => 0, //The current version of the plugin's tables |
| 72 | |
| 73 | 'custom_tmp_dir' => '', //The lockfile will be stored in this directory. |
| 74 | //If this option is not set, the plugin's own directory or the |
| 75 | //system-wide /tmp directory will be used instead. |
| 76 | |
| 77 | 'timeout' => 30, //Links that take longer than this to respond will be treated as broken. |
| 78 | ) |
| 79 | ); |
| 80 | |
| 81 | |
| 82 | if ( !is_admin() ){ |
| 83 | //This is user-side request, so the only thing we may need to do is run the broken link highlighter. |
| 84 | if ( $blc_config_manager->options['mark_broken_links'] ){ |
| 85 | //Load some utilities (used by the higlighter) and the highlighter itself |
| 86 | require $blc_directory . '/utility-class.php'; |
| 87 | require $blc_directory . '/highlighter-class.php'; |
| 88 | $blc_link_highlighter = new blcLinkHighlighter( $blc_config_manager->options['broken_link_css'] ); |
| 89 | } |
| 90 | } else { |
| 91 | //Load everything |
| 92 | require $blc_directory . '/utility-class.php'; |
| 93 | require $blc_directory . '/instance-classes.php'; |
| 94 | require $blc_directory . '/link-classes.php'; |
| 95 | require $blc_directory . '/core.php'; |
| 96 | |
| 97 | $ws_link_checker = new wsBrokenLinkChecker( __FILE__ , $blc_config_manager ); |
| 98 | } |
| 99 | |
| 100 | ?> |