Changeset 45229
- Timestamp:
- 05/11/08 09:57:54 (2 months ago)
- Files:
-
- broken-link-checker/tags/0.3.8/broken-link-checker.php (modified) (8 diffs)
- broken-link-checker/tags/0.3.8/readme.txt (modified) (2 diffs)
- broken-link-checker/tags/0.3.8/wsblc_ajax.php (modified) (3 diffs)
- broken-link-checker/trunk/broken-link-checker.php (modified) (8 diffs)
- broken-link-checker/trunk/readme.txt (modified) (2 diffs)
- broken-link-checker/trunk/wsblc_ajax.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
broken-link-checker/tags/0.3.8/broken-link-checker.php
r41385 r45229 4 4 Plugin URI: http://w-shadow.com/blog/2007/08/05/broken-link-checker-for-wordpress/ 5 5 Description: Checks your posts for broken links and missing images and notifies you on the dashboard if any are found. 6 Version: 0.3. 76 Version: 0.3.8 7 7 Author: Janis Elsts 8 8 Author URI: http://w-shadow.com/blog/ … … 21 21 var $postdata_name; 22 22 var $linkdata_name; 23 var $version='0.3. 7';23 var $version='0.3.8'; 24 24 var $myfile=''; 25 25 var $myfolder=''; … … 495 495 <div class="wrap"> 496 496 <h2><?php 497 echo ($broken_links>0)?"$broken_links Broken Links":"No broken links found"; 497 echo ($broken_links>0)?"<span id='broken_link_count'>$broken_links</span> Broken Links": 498 "No broken links found"; 498 499 ?></h2> 499 500 <br style="clear:both;" /> … … 529 530 530 531 <td>$link->link_text</td> 531 <td><a href='$link->url'>".$this->mytruncate($link->url)."</a></td> 532 <td> 533 <a href='$link->url'>".$this->mytruncate($link->url)."</a> 534 | <a href='javascript:editBrokenLink($link->id, \"$link->url\")' 535 id='link-editor-button-$link->id'>Edit</a> 536 <br /> 537 <input type='text' size='50' id='link-editor-$link->id' value='$link->url' 538 class='link-editor' style='display:none' /> 539 </td> 532 540 <td><a href='".($link->guid)."' class='edit'>View</a></td> 533 541 … … 553 561 }; 554 562 ?> 563 <style type='text/css'> 564 .link-editor { 565 font-size: 1em; 566 } 567 </style> 555 568 556 569 <script type='text/javascript'> 570 function alterLinkCounter(factor){ 571 cnt = parseInt($('broken_link_count').innerHTML); 572 cnt = cnt + factor; 573 $('broken_link_count').innerHTML = cnt; 574 } 575 557 576 function discardLinkMessage(link_id){ 558 577 $('discard_button-'+link_id).innerHTML = 'Wait...'; … … 567 586 if (re.test(response)){ 568 587 $('link-'+link_id).hide(); 588 alterLinkCounter(-1); 569 589 } else { 570 590 $('discard_button-'+link_id).innerHTML = 'Discard'; … … 590 610 if (re.test(response)){ 591 611 $('link-'+link_id).hide(); 612 alterLinkCounter(-1); 592 613 } else { 593 614 $('unlink_button-'+link_id).innerHTML = 'Unlink'; … … 598 619 ); 599 620 } 621 622 function editBrokenLink(link_id, orig_link){ 623 if ($('link-editor-button-'+link_id).innerHTML == 'Edit'){ 624 $('link-editor-'+link_id).show(); 625 $('link-editor-button-'+link_id).innerHTML = 'Save'; 626 } else { 627 $('link-editor-'+link_id).hide(); 628 new_url = $('link-editor-'+link_id).value; 629 if (new_url != orig_link){ 630 //Save the changed link 631 new Ajax.Request( 632 '<?php 633 echo get_option( "siteurl" ).'/wp-content/plugins/'.$this->myfolder.'/wsblc_ajax.php?'; 634 ?>action=edit_link&id='+link_id+'&new_url='+escape(new_url), 635 { 636 method:'post', 637 onSuccess: function(transport){ 638 var re = /OK:.*/i 639 var response = transport.responseText || ""; 640 if (re.test(response)){ 641 $('link-'+link_id).hide(); 642 alterLinkCounter(-1); 643 //alert(response); 644 } else { 645 alert(response); 646 } 647 } 648 } 649 ); 650 651 } 652 $('link-editor-button-'+link_id).innerHTML = 'Edit'; 653 } 654 } 600 655 </script> 601 656 </div> broken-link-checker/tags/0.3.8/readme.txt
r41385 r45229 3 3 Tags: links, broken, maintenance 4 4 Requires at least: 2.0.2 5 Tested up to: 2.5 6 Stable tag: 0.3. 75 Tested up to: 2.5.1 6 Stable tag: 0.3.8 7 7 8 8 This plugin will check your posts for broken links and missing images in background and notify you on the dashboard if any are found. … … 17 17 * Link checking intervals can be configured. 18 18 * New/modified posts are checked ASAP. 19 * You can unlink or edit broken links in the *Manage -> Broken Links* tab (experimental). 19 20 20 21 **How To Use It** broken-link-checker/tags/0.3.8/wsblc_ajax.php
r41385 r45229 47 47 $recheck_treshold=date('Y-m-d H:i:s', strtotime('-20 minutes')); 48 48 49 $action=isset($_GET['action'])?$_GET['action']:'run_check'; 49 if (!empty($_POST['action'])){ 50 $action = $_POST['action']; 51 } else { 52 $action=isset($_GET['action'])?$_GET['action']:'run_check'; 53 } 50 54 51 55 if($action=='dashboard_status'){ … … 179 183 180 184 die('OK: Link deleted'); 185 186 } else if ($action == 'edit_link'){ 187 //edits the link's URL inside the post 188 if (!current_user_can('edit_posts')) { 189 die("Error: You can't do that. Access denied."); 190 } 191 192 $id = intval($_GET['id']); 193 $new_url = $_GET['new_url']; 194 195 $sql="SELECT * FROM $linkdata_name WHERE id = $id LIMIT 1"; 196 $the_link=$wpdb->get_row($sql, OBJECT, 0); 197 if (!$the_link){ 198 die('Error: Link not found'); 199 } 200 $the_post = get_post($the_link->post_id, ARRAY_A); 201 if (!$the_post){ 202 die('Error: Post not found'); 203 } 204 205 $new_content = edit_the_link($the_post['post_content'], $the_link->url, $new_url); 206 if (function_exists('mysql_real_escape_string')){ 207 $new_content = mysql_real_escape_string($new_content); 208 } else { 209 $new_content = $wpdb->escape($new_content); 210 } 211 $q = "UPDATE $wpdb->posts SET post_content = '$new_content' WHERE id = $the_link->post_id"; 212 //@file_put_contents('q.txt', $q); 213 $wpdb->query($q); 214 if($wpdb->rows_affected<1){ 215 die('Error: Couldn\'t update the post ('.mysql_error().').'); 216 } 217 $wpdb->query("DELETE FROM $linkdata_name WHERE id=$id LIMIT 1"); 218 if($wpdb->rows_affected<1){ 219 die('Error: Couldn\'t remove the link record (DB error).'); 220 } 221 222 die('OK: Link changed and deleted from the list of broken links.'); 181 223 }; 182 224 … … 315 357 } 316 358 } 359 360 function edit_the_link($content, $url, $newurl){ 361 global $url_pattern, $url_to_replace, $new_url; 362 $url_to_replace = $url; 363 $new_url = $newurl; 364 $url_pattern='/(<a[\s]+[^>]*href\s*=\s*[\"\']?)([^\'\" >]+)([\'\"]+[^<>]*>)((?sU).*)(<\/a>)/i'; 365 $content = preg_replace_callback($url_pattern, edit_link_callback, $content); 366 return $content; 367 } 368 369 function edit_link_callback($matches){ 370 global $url_to_replace, $new_url, $ws_link_checker; 371 $url = $ws_link_checker->normalize_url($matches[2]); 372 $text = $matches[4]; 373 374 //echo "$url || $url_to_replace\n"; 375 if ($url == $url_to_replace){ 376 //return $text; 377 return $matches[1].$new_url.$matches[3].$text.$matches[5]; 378 } else { 379 return $matches[0]; 380 } 381 } 317 382 ?> broken-link-checker/trunk/broken-link-checker.php
r41385 r45229 4 4 Plugin URI: http://w-shadow.com/blog/2007/08/05/broken-link-checker-for-wordpress/ 5 5 Description: Checks your posts for broken links and missing images and notifies you on the dashboard if any are found. 6 Version: 0.3. 76 Version: 0.3.8 7 7 Author: Janis Elsts 8 8 Author URI: http://w-shadow.com/blog/ … … 21 21 var $postdata_name; 22 22 var $linkdata_name; 23 var $version='0.3. 7';23 var $version='0.3.8'; 24 24 var $myfile=''; 25 25 var $myfolder=''; … … 495 495 <div class="wrap"> 496 496 <h2><?php 497 echo ($broken_links>0)?"$broken_links Broken Links":"No broken links found"; 497 echo ($broken_links>0)?"<span id='broken_link_count'>$broken_links</span> Broken Links": 498 "No broken links found"; 498 499 ?></h2> 499 500 <br style="clear:both;" /> … … 529 530 530 531 <td>$link->link_text</td> 531 <td><a href='$link->url'>".$this->mytruncate($link->url)."</a></td> 532 <td> 533 <a href='$link->url'>".$this->mytruncate($link->url)."</a> 534 | <a href='javascript:editBrokenLink($link->id, \"$link->url\")' 535 id='link-editor-button-$link->id'>Edit</a> 536 <br /> 537 <input type='text' size='50' id='link-editor-$link->id' value='$link->url' 538 class='link-editor' style='display:none' /> 539 </td> 532 540 <td><a href='".($link->guid)."' class='edit'>View</a></td> 533 541 … … 553 561 }; 554 562 ?> 563 <style type='text/css'> 564 .link-editor { 565 font-size: 1em; 566 } 567 </style> 555 568 556 569 <script type='text/javascript'> 570 function alterLinkCounter(factor){ 571 cnt = parseInt($('broken_link_count').innerHTML); 572 cnt = cnt + factor; 573 $('broken_link_count').innerHTML = cnt; 574 } 575 557 576 function discardLinkMessage(link_id){ 558 577 $('discard_button-'+link_id).innerHTML = 'Wait...'; … … 567 586 if (re.test(response)){ 568 587 $('link-'+link_id).hide(); 588 alterLinkCounter(-1); 569 589 } else { 570 590 $('discard_button-'+link_id).innerHTML = 'Discard'; … … 590 610 if (re.test(response)){ 591 611 $('link-'+link_id).hide(); 612 alterLinkCounter(-1); 592 613 } else { 593 614 $('unlink_button-'+link_id).innerHTML = 'Unlink'; … … 598 619 ); 599 620 } 621 622 function editBrokenLink(link_id, orig_link){ 623 if ($('link-editor-button-'+link_id).innerHTML == 'Edit'){ 624 $('link-editor-'+link_id).show(); 625 $('link-editor-button-'+link_id).innerHTML = 'Save'; 626 } else { 627 $('link-editor-'+link_id).hide(); 628 new_url = $('link-editor-'+link_id).value; 629 if (new_url != orig_link){ 630 //Save the changed link 631 new Ajax.Request( 632 '<?php 633 echo get_option( "siteurl" ).'/wp-content/plugins/'.$this->myfolder.'/wsblc_ajax.php?'; 634 ?>action=edit_link&id='+link_id+'&new_url='+escape(new_url), 635 { 636 method:'post', 637 onSuccess: function(transport){ 638 var re = /OK:.*/i 639 var response = transport.responseText || ""; 640 if (re.test(response)){ 641 $('link-'+link_id).hide(); 642 alterLinkCounter(-1); 643 //alert(response); 644 } else { 645 alert(response); 646 } 647 } 648 } 649 ); 650 651 } 652 $('link-editor-button-'+link_id).innerHTML = 'Edit'; 653 } 654 } 600 655 </script> 601 656 </div> broken-link-checker/trunk/readme.txt
r41385 r45229 3 3 Tags: links, broken, maintenance 4 4 Requires at least: 2.0.2 5 Tested up to: 2.5 6 Stable tag: 0.3. 75 Tested up to: 2.5.1 6 Stable tag: 0.3.8 7 7 8 8 This plugin will check your posts for broken links and missing images in background and notify you on the dashboard if any are found. … … 17 17 * Link checking intervals can be configured. 18 18 * New/modified posts are checked ASAP. 19 * You can unlink or edit broken links in the *Manage -> Broken Links* tab (experimental). 19 20 20 21 **How To Use It** broken-link-checker/trunk/wsblc_ajax.php
r41385 r45229 47 47 $recheck_treshold=date('Y-m-d H:i:s', strtotime('-20 minutes')); 48 48 49 $action=isset($_GET['action'])?$_GET['action']:'run_check'; 49 if (!empty($_POST['action'])){ 50 $action = $_POST['action']; 51 } else { 52 $action=isset($_GET['action'])?$_GET['action']:'run_check'; 53 } 50 54 51 55 if($action=='dashboard_status'){ … … 179 183 180 184 die('OK: Link deleted'); 185 186 } else if ($action == 'edit_link'){ 187 //edits the link's URL inside the post 188 if (!current_user_can('edit_posts')) { 189 die("Error: You can't do that. Access denied."); 190 } 191 192 $id = intval($_GET['id']); 193 $new_url = $_GET['new_url']; 194 195 $sql="SELECT * FROM $linkdata_name WHERE id = $id LIMIT 1"; 196 $the_link=$wpdb->get_row($sql, OBJECT, 0); 197 if (!$the_link){ 198 die('Error: Link not found'); 199 } 200 $the_post = get_post($the_link->post_id, ARRAY_A); 201 if (!$the_post){ 202 die('Error: Post not found'); 203 } 204 205 $new_content = edit_the_link($the_post['post_content'], $the_link->url, $new_url); 206 if (function_exists('mysql_real_escape_string')){ 207 $new_content = mysql_real_escape_string($new_content); 208 } else { 209 $new_content = $wpdb->escape($new_content); 210 } 211 $q = "UPDATE $wpdb->posts SET post_content = '$new_content' WHERE id = $the_link->post_id"; 212 //@file_put_contents('q.txt', $q); 213 $wpdb->query($q); 214 if($wpdb->rows_affected<1){ 215 die('Error: Couldn\'t update the post ('.mysql_error().').'); 216 } 217 $wpdb->query("DELETE FROM $linkdata_name WHERE id=$id LIMIT 1"); 218 if($wpdb->rows_affected<1){ 219 die('Error: Couldn\'t remove the link record (DB error).'); 220 } 221 222 die('OK: Link changed and deleted from the list of broken links.'); 181 223 }; 182 224 … … 315 357 } 316 358 } 359 360 function edit_the_link($content, $url, $newurl){ 361 global $url_pattern, $url_to_replace, $new_url; 362 $url_to_replace = $url; 363 $new_url = $newurl; 364 $url_pattern='/(<a[\s]+[^>]*href\s*=\s*[\"\']?)([^\'\" >]+)([\'\"]+[^<>]*>)((?sU).*)(<\/a>)/i'; 365 $content = preg_replace_callback($url_pattern, edit_link_callback, $content); 366 return $content; 367 } 368 369 function edit_link_callback($matches){ 370 global $url_to_replace, $new_url, $ws_link_checker; 371 $url = $ws_link_checker->normalize_url($matches[2]); 372 $text = $matches[4]; 373 374 //echo "$url || $url_to_replace\n"; 375 if ($url == $url_to_replace){ 376 //return $text; 377 return $matches[1].$new_url.$matches[3].$text.$matches[5]; 378 } else { 379 return $matches[0]; 380 } 381 } 317 382 ?>
