Plugin Directory

Changeset 1200617


Ignore:
Timestamp:
07/16/2015 11:57:46 PM (11 years ago)
Author:
flashcentury
Message:

ver. 0.6.0

Location:
broken-link-manager
Files:
246 added
3 edited

Legend:

Unmodified
Added
Removed
  • broken-link-manager/trunk/config/functions.php

    r1194050 r1200617  
    150150    $wpdb->query("DELETE FROM " . TABLE_WBLM . " WHERE active = 0");
    151151}
     152
     153
     154function _custom_redirect(){
     155  global $wp_query;
     156  global $wpdb;
     157  if ( $wp_query->is_404() ){
     158    $referer  = isset($_SERVER['HTTP_REFERER']) ? esc_url_raw($_SERVER['HTTP_REFERER']) : 'Direct';
     159    $useragent  = isset($_SERVER['HTTP_USER_AGENT']) ? sanitize_text_field($_SERVER['HTTP_USER_AGENT']) : null;
     160    $ip  = isset($_SERVER['REMOTE_ADDR']) ? sanitize_text_field($_SERVER['REMOTE_ADDR']) : null;
     161    $current_time = current_time('mysql');
     162    $https  = isset($_SERVER['HTTPS']) ? 's' : null;
     163    $brokenUrl = 'http' . $https . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
     164    $brokenUrl = esc_url_raw($brokenUrl);
     165   
     166
     167    $url_check = $wpdb->get_row("SELECT * FROM " . TABLE_WBLM . "  WHERE old_url = '$brokenUrl' limit 1"); 
     168    $urlID  = isset($url_check->id) ? $url_check->id : null;
     169
     170    if($urlID){
     171        if(SAVE_URL_STATS){
     172        $urlHit = $url_check->hit + 1;
     173        $wpdb->query("UPDATE " . TABLE_WBLM . " SET `hit` = '$urlHit' WHERE id = '$urlID'");
     174        }
     175        if($url_check->new_url){
     176            $redirectedUrl = $url_check->new_url;
     177        }else{
     178            $redirectedUrl = 0;
     179            if(SAVE_URL_LOG){
     180                if(REDIRECT_DEFAULT_URL){$http_statu = 301;}else{$http_statu = 404;}
     181                $wpdb->query("INSERT INTO " . TABLE_WBLM_LOG . " (`url`, `date`, `referer`, `useragent`, `ip`, `broken`, `http_statu`) VALUES ('$urlID', '$current_time', '$referer', '$useragent', '$ip', '1', '$http_statu')");           
     182            }//SAVE_URL_LOG
     183        }
     184    }else{
     185        $redirectedUrl = 0;
     186        if(SAVE_BROKEN_URLS){
     187            $datum = parse_url($brokenUrl);
     188            $parts = pathinfo($datum['path']);
     189            $ext  = isset($parts['extension']) ? $parts['extension'] : 'page';
     190            $wpdb->query("INSERT INTO " . TABLE_WBLM . " (`old_url`, `type`, `hit`) VALUES ('$brokenUrl', '$ext', '1')");
     191                if(SAVE_URL_LOG){
     192                    if(REDIRECT_DEFAULT_URL){$http_statu = 301;}else{$http_statu = 404;}
     193                    $newUrl = $wpdb->get_row("SELECT id FROM " . TABLE_WBLM . " where `old_url` = '$brokenUrl'");
     194                    $newUrlID = $newUrl->id;
     195                    $wpdb->query("INSERT INTO " . TABLE_WBLM_LOG . " (`url`, `date`, `referer`, `useragent`, `ip`, `broken`, `http_statu`) VALUES ('$newUrlID', '$current_time', '$referer', '$useragent', '$ip', '1', '$http_statu')");           
     196                }//SAVE_URL_LOG
     197            }//SAVE_BROKEN_URLS
     198    }
     199   
     200    if ($redirectedUrl){
     201        if(SAVE_URL_LOG){
     202            $wpdb->query("INSERT INTO " . TABLE_WBLM_LOG . " (`url`, `date`, `referer`, `useragent`, `ip`, `redirect`, `http_statu`) VALUES ('$urlID', '$current_time', '$referer', '$useragent', '$ip', '1', '301')");
     203            }
     204        wp_redirect(esc_url_raw($redirectedUrl), 301 );
     205        exit;
     206    }else{
     207    if(SEND_EMAIL){
     208        //URL BELIRTILMEMIS --> MAIL GONDERILIYOR
     209        add_filter('wp_mail_content_type',create_function('', 'return "text/html";'));
     210       
     211        $mail_contenHTML = '<h2>Warning!</h2><br> Broken Link : ' . $brokenUrl;
     212       
     213        $to = TO_EMAIL;
     214        $subject = __('Warning! Broken Link ', 'wblm');
     215        $headers[] = 'From: Broken Link Manager <'.FROM_EMAIL.'> ';
     216        if(CC_EMAIL){ $headers[] = 'Cc: '. CC_EMAIL;}
     217        if(BCC_EMAIL){ $headers[] = 'Bcc: '. BCC_EMAIL;}
     218       
     219        wp_mail( $to, $subject, $mail_contenHTML, $headers, $attachments );
     220    }
     221        if(REDIRECT_DEFAULT_URL){
     222        //No URL --> Redirected Default URL
     223        wp_redirect(DEFAULT_URL, 301 );
     224        exit;
     225        }
     226    }
     227  }
     228}
     229
     230
    152231if($settingsSaveFunc){ wpslSettingsSave(); }
    153232if($editURLFunc){ wpslEditURL(); }
  • broken-link-manager/trunk/readme.txt

    r1194050 r1200617  
    44Requires at least: 3.0
    55Tested up to: 4.2.2
    6 Stable tag: 0.5.5
     6Stable tag: 0.6.0
    77Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=8NYR3F4RVTBHS
    88
     
    4949== Changelog ==
    5050
     51= 0.6.0 =
     52* Take measure against XSS attack
     53
    5154= 0.5.5 =
    5255* Some security measures were taken
    5356* Fixed small bug
    54 
    5557
    5658= 0.5.0 =
  • broken-link-manager/trunk/wblm.php

    r1194050 r1200617  
    44Plugin URI: https://wordpress.org/plugins/broken-link-manager
    55Description: WBLM -> Wordpress Broken Link Manager. This plugin helps you check, organise and monitor your broken backlinks.
    6 Version: 0.5.5
     6Version: 0.6.0
    77Author: Hüseyin Kocak
    88Author URI: http://k-78.de
     
    232232register_activation_hook( __FILE__, 'create_wblm_table' );
    233233/*************************************************************************************
    234  *  FONCTIONS
     234 *  FUNCTIONS
    235235 *************************************************************************************/
    236236add_action('template_redirect', '_custom_redirect');
    237 function _custom_redirect(){
    238   global $wp_query;
    239   global $wpdb;
    240   if ( $wp_query->is_404() ){
    241     $referer  = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : 'Direct';
    242     $useragent  = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : null;
    243     $ip  = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : null;
    244     $current_time = current_time('mysql');
    245     $https  = isset($_SERVER['HTTPS']) ? 's' : null;
    246     $brokenUrl = 'http' . $https . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
    247 
    248     $url_check = $wpdb->get_row("SELECT * FROM " . TABLE_WBLM . "  WHERE old_url = '$brokenUrl' limit 1"); 
    249     $urlID  = isset($url_check->id) ? $url_check->id : null;
    250 
    251     if($urlID){
    252         if(SAVE_URL_STATS){
    253         $urlHit = $url_check->hit + 1;
    254         $wpdb->query("UPDATE " . TABLE_WBLM . " SET `hit` = '$urlHit' WHERE id = '$urlID'");
    255         }
    256         if($url_check->new_url){
    257             $redirectedUrl = $url_check->new_url;
    258         }else{
    259             $redirectedUrl = 0;
    260             if(SAVE_URL_LOG){
    261                 if(REDIRECT_DEFAULT_URL){$http_statu = 301;}else{$http_statu = 404;}
    262                 $wpdb->query("INSERT INTO " . TABLE_WBLM_LOG . " (`url`, `date`, `referer`, `useragent`, `ip`, `broken`, `http_statu`) VALUES ('$urlID', '$current_time', '$referer', '$useragent', '$ip', '1', '$http_statu')");           
    263             }//SAVE_URL_LOG
    264         }
    265     }else{
    266         $redirectedUrl = 0;
    267         if(SAVE_BROKEN_URLS){
    268             $datum = parse_url($brokenUrl);
    269             $parts = pathinfo($datum['path']);
    270             $ext  = isset($parts['extension']) ? $parts['extension'] : 'page';
    271             $wpdb->query("INSERT INTO " . TABLE_WBLM . " (`old_url`, `type`, `hit`) VALUES ('$brokenUrl', '$ext', '1')");
    272                 if(SAVE_URL_LOG){
    273                     if(REDIRECT_DEFAULT_URL){$http_statu = 301;}else{$http_statu = 404;}
    274                     $newUrl = $wpdb->get_row("SELECT id FROM " . TABLE_WBLM . " where `old_url` = '$brokenUrl'");
    275                     $newUrlID = $newUrl->id;
    276                     $wpdb->query("INSERT INTO " . TABLE_WBLM_LOG . " (`url`, `date`, `referer`, `useragent`, `ip`, `broken`, `http_statu`) VALUES ('$newUrlID', '$current_time', '$referer', '$useragent', '$ip', '1', '$http_statu')");           
    277                 }//SAVE_URL_LOG
    278             }//SAVE_BROKEN_URLS
    279     }
    280    
    281     if ($redirectedUrl){
    282         if(SAVE_URL_LOG){
    283             $wpdb->query("INSERT INTO " . TABLE_WBLM_LOG . " (`url`, `date`, `referer`, `useragent`, `ip`, `redirect`, `http_statu`) VALUES ('$urlID', '$current_time', '$referer', '$useragent', '$ip', '1', '301')");
    284             }
    285         wp_redirect($redirectedUrl, 301 );
    286         exit;
    287     }else{
    288     if(SEND_EMAIL){
    289         //URL BELIRTILMEMIS --> MAIL GONDERILIYOR
    290         add_filter('wp_mail_content_type',create_function('', 'return "text/html";'));
    291        
    292         $mail_contenHTML = '<h2>Warning!</h2><br> Broken Link : ' . $brokenUrl;
    293        
    294         $to = TO_EMAIL;
    295         $subject = __('Warning! Broken Link ', 'wblm');
    296         $headers[] = 'From: Broken Link Manager <'.FROM_EMAIL.'> ';
    297         if(CC_EMAIL){ $headers[] = 'Cc: '. CC_EMAIL;}
    298         if(BCC_EMAIL){ $headers[] = 'Bcc: '. BCC_EMAIL;}
    299        
    300         wp_mail( $to, $subject, $mail_contenHTML, $headers, $attachments );
    301     }
    302         if(REDIRECT_DEFAULT_URL){
    303         //No URL --> Redirected Default URL
    304         wp_redirect(DEFAULT_URL, 301 );
    305         exit;
    306         }
    307     }
    308   }
    309 }
     237
    310238function createBaclinksMenu() {
    311239    $menu_wblm_dashboard = add_menu_page("Broken Backlinks", "Broken Backlinks", 'manage_options', "wblm-dashboard", "menuDashboardFunc", WBLM_ICON);
Note: See TracChangeset for help on using the changeset viewer.