Changeset 3481332
- Timestamp:
- 03/12/2026 04:27:49 PM (2 weeks ago)
- Location:
- broken-link-notifier
- Files:
-
- 56 added
- 4 edited
-
tags/1.3.7.1 (added)
-
tags/1.3.7.1/broken-link-notifier.php (added)
-
tags/1.3.7.1/includes (added)
-
tags/1.3.7.1/includes/cache.php (added)
-
tags/1.3.7.1/includes/css (added)
-
tags/1.3.7.1/includes/css/results-front.css (added)
-
tags/1.3.7.1/includes/css/results-front.min.css (added)
-
tags/1.3.7.1/includes/discord.php (added)
-
tags/1.3.7.1/includes/example-hook.php (added)
-
tags/1.3.7.1/includes/export.php (added)
-
tags/1.3.7.1/includes/helpers.php (added)
-
tags/1.3.7.1/includes/img (added)
-
tags/1.3.7.1/includes/img/admin-help-docs.png (added)
-
tags/1.3.7.1/includes/img/clear-cache-everywhere.png (added)
-
tags/1.3.7.1/includes/img/dev-debug-tools.png (added)
-
tags/1.3.7.1/includes/img/devconsole.gif (added)
-
tags/1.3.7.1/includes/img/discord.png (added)
-
tags/1.3.7.1/includes/img/eri-file-library.png (added)
-
tags/1.3.7.1/includes/img/gf-discord.png (added)
-
tags/1.3.7.1/includes/img/gf-msteams.png (added)
-
tags/1.3.7.1/includes/img/gf-tools.png (added)
-
tags/1.3.7.1/includes/img/gravity-zwr.png (added)
-
tags/1.3.7.1/includes/img/logo-teal.png (added)
-
tags/1.3.7.1/includes/img/logo-transparent.png (added)
-
tags/1.3.7.1/includes/img/screen_options.png (added)
-
tags/1.3.7.1/includes/index.php (added)
-
tags/1.3.7.1/includes/integrations.php (added)
-
tags/1.3.7.1/includes/js (added)
-
tags/1.3.7.1/includes/js/index.php (added)
-
tags/1.3.7.1/includes/js/omits.js (added)
-
tags/1.3.7.1/includes/js/results-back.js (added)
-
tags/1.3.7.1/includes/js/results-front.js (added)
-
tags/1.3.7.1/includes/js/results-front.min.js (added)
-
tags/1.3.7.1/includes/js/scan-multi.js (added)
-
tags/1.3.7.1/includes/js/scan-single.js (added)
-
tags/1.3.7.1/includes/js/settings.js (added)
-
tags/1.3.7.1/includes/loader.php (added)
-
tags/1.3.7.1/includes/menu.php (added)
-
tags/1.3.7.1/includes/msteams.php (added)
-
tags/1.3.7.1/includes/omits.php (added)
-
tags/1.3.7.1/includes/page-export.php (added)
-
tags/1.3.7.1/includes/page-help.php (added)
-
tags/1.3.7.1/includes/page-link-search.php (added)
-
tags/1.3.7.1/includes/page-results.php (added)
-
tags/1.3.7.1/includes/page-scan-multi.php (added)
-
tags/1.3.7.1/includes/page-scan-single.php (added)
-
tags/1.3.7.1/includes/page-settings.php (added)
-
tags/1.3.7.1/includes/page.php (added)
-
tags/1.3.7.1/includes/results.php (added)
-
tags/1.3.7.1/includes/scan-multi.php (added)
-
tags/1.3.7.1/includes/scan.php (added)
-
tags/1.3.7.1/includes/test_files (added)
-
tags/1.3.7.1/includes/test_files/Jubiläum-A-und-B.pdf (added)
-
tags/1.3.7.1/index.php (added)
-
tags/1.3.7.1/readme.txt (added)
-
tags/1.3.7.1/uninstall.php (added)
-
trunk/broken-link-notifier.php (modified) (1 diff)
-
trunk/includes/helpers.php (modified) (3 diffs)
-
trunk/includes/results.php (modified) (9 diffs)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
broken-link-notifier/trunk/broken-link-notifier.php
r3475895 r3481332 4 4 * Plugin URI: https://pluginrx.com/plugin/broken-link-notifier/ 5 5 * Description: Get notified when someone loads a page with a broken link 6 * Version: 1.3.7 6 * Version: 1.3.7.1 7 7 * Requires at least: 5.9 8 8 * Tested up to: 6.9 -
broken-link-notifier/trunk/includes/helpers.php
r3475895 r3481332 1646 1646 // If the match is local, easy check 1647 1647 } elseif ( str_starts_with( $link, home_url() ) || ( str_starts_with( $link, '/' ) && !str_starts_with( $link, '//' ) ) ) { 1648 1649 // Skip replytocom and pagination links 1650 if ( str_contains( $link, 'replytocom' ) || preg_match( '/\/page\/\d+(\/|$|\?)/', $link ) ) { 1651 return [ 1652 'type' => 'good', 1653 'code' => 200, 1654 'text' => 'Skipping internal pagination or reply link', 1655 'link' => $link 1656 ]; 1657 } 1648 1658 1649 1659 // Check locally first … … 1651 1661 1652 1662 // It may be redirected or an archive page, so let's check status anyway 1653 // return $this->check_url_status_code( $link );1654 1663 $status = $this->check_url_status_code( $link ); 1655 1664 $CACHE->set_cached_link( $status ); … … 1669 1678 1670 1679 // Return the status 1671 // return $this->check_url_status_code( $link );1672 1680 $status = $this->check_url_status_code( $link ); 1673 1681 $CACHE->set_cached_link( $status ); -
broken-link-notifier/trunk/includes/results.php
r3475895 r3481332 295 295 public function already_added( $link ) { 296 296 global $wpdb; 297 298 297 $table_name = $wpdb->prefix . $this->table_name; 299 298 $link_clean = sanitize_text_field( $link ); 300 $link_hash = md5( strtolower( untrailingslashit( $link_clean ) ) ); 299 300 // 1. New Hash 301 $url_parts = explode( '?', $link_clean ); 302 $url_parts[ 0 ] = untrailingslashit( $url_parts[ 0 ] ); 303 $new_hash = md5( strtolower( implode( '?', $url_parts ) ) ); 304 305 // 2. Old Hash 306 $old_hash = md5( strtolower( untrailingslashit( $link_clean ) ) ); 301 307 302 308 $exists = $wpdb->get_var( 303 309 $wpdb->prepare( 304 "SELECT id FROM $table_name WHERE link_hash = %s LIMIT 1", 305 $link_hash 310 "SELECT id FROM $table_name WHERE link_hash = %s OR link_hash = %s LIMIT 1", 311 $new_hash, 312 $old_hash 306 313 ) 307 314 ); 308 315 309 return ! empty( $exists );316 return ! empty( $exists ); 310 317 } // End already_added() 311 318 … … 323 330 324 331 $link = sanitize_text_field( $args[ 'link' ] ); 325 $link_normalized = strtolower( untrailingslashit( $link ) ); 332 333 $url_parts = explode( '?', $link ); 334 $url_parts[ 0 ] = untrailingslashit( $url_parts[ 0 ] ); 335 $link_normalized = strtolower( implode( '?', $url_parts ) ); 326 336 $link_hash = md5( $link_normalized ); 327 337 … … 335 345 ); 336 346 337 if ( ! $source_url ) {347 if ( ! $source_url ) { 338 348 return __( 'Invalid source:', 'broken-link-notifier' ) . ' ' . $source_url; 339 349 } … … 354 364 'created_at' => current_time( 'mysql' ), 355 365 ], 356 [ '%s', '%s','%s','%s','%d','%s','%s','%s','%d','%d','%s' ]366 [ '%s', '%s', '%s', '%s', '%d', '%s', '%s', '%s', '%d', '%d', '%s' ] 357 367 ); 358 368 … … 373 383 public function remove( $link ) { 374 384 global $wpdb; 375 376 385 $table_name = $wpdb->prefix . $this->table_name; 377 $link_hash = md5( strtolower( untrailingslashit( sanitize_text_field( $link ) ) ) ); 378 379 $deleted = $wpdb->delete( 380 $table_name, 381 [ 'link_hash' => $link_hash ], 382 [ '%s' ] 386 $link = sanitize_text_field( $link ); 387 388 // 1. New Normalized Hash 389 $url_parts = explode( '?', $link ); 390 $url_parts[ 0 ] = untrailingslashit( $url_parts[ 0 ] ); 391 $new_hash = md5( strtolower( implode( '?', $url_parts ) ) ); 392 393 // 2. Old Logic Hash (Legacy) 394 $old_hash = md5( strtolower( untrailingslashit( $link ) ) ); 395 396 // Try to delete by either hash 397 $deleted = $wpdb->query( 398 $wpdb->prepare( 399 "DELETE FROM $table_name WHERE link_hash = %s OR link_hash = %s", 400 $new_hash, 401 $old_hash 402 ) 383 403 ); 384 404 385 return ( $deleted > 0 );405 return ( false !== $deleted && $deleted > 0 ); 386 406 } // End remove() 387 407 … … 605 625 } 606 626 627 // Validate that the URL belongs to this site and exists 628 $site_url = site_url(); 629 if ( ! str_starts_with( $source_url, $site_url ) ) { 630 wp_send_json_error( 'External source URLs are not permitted.' ); 631 } 632 633 // Check for Post ID with full URL 634 $post_id = url_to_postid( $source_url ); 635 636 // If not found, check without query parameters 637 if ( ! $post_id ) { 638 $clean_url = strtok( $source_url, '?' ); 639 $post_id = url_to_postid( $clean_url ); 640 } 641 642 // If it's not a post/page and it's not the homepage, it's likely a 404 or invalid 643 if ( ! $post_id && $source_url !== trailingslashit( $site_url ) && $source_url !== $site_url ) { 644 wp_send_json_error( 'Source URL does not exist on this site.' ); 645 } 646 607 647 // Initiate helpers 608 648 $HELPERS = new BLNOTIFIER_HELPERS; … … 672 712 $this->notify( $notify, $count_notify, $all_links, $source_url ); 673 713 714 $current_user_id = get_current_user_id(); 715 674 716 // Add posts 675 717 foreach ( $notify as $location => $n ) { … … 681 723 'link' => $status[ 'link' ], 682 724 'source' => $source_url, 683 'author' => get_current_user_id(),725 'author' => $current_user_id, 684 726 'location' => $location, 685 727 'method' => 'visit' … … 698 740 'link' => $status[ 'link' ], 699 741 'source' => $source_url, 700 'author' => get_current_user_id(),742 'author' => $current_user_id, 701 743 'location' => $location, 702 744 'method' => 'visit' -
broken-link-notifier/trunk/readme.txt
r3475895 r3481332 5 5 Tested up to: 6.9 6 6 Requires PHP: 7.4 7 Stable tag: 1.3.7 7 Stable tag: 1.3.7.1 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.txt … … 127 127 128 128 == Changelog == 129 = 1.3.7.1 = 130 * Tweak: Skipping internal pagination and reply links 131 * Tweak: Performance update to not call get_current_user_id() on every link 132 * Fix: Reporting sources that don't exist if bots are trying to go somewhere that don't exist and get a 404 page without redirecting 133 129 134 = 1.3.7 = 130 135 * Update: Changed storage of broken links from custom post type to custom database table
Note: See TracChangeset
for help on using the changeset viewer.