Пример #1
0
 /**
  * AJAX hook for the "Recheck" action.
  */
 public function ajax_recheck()
 {
     if (!current_user_can('edit_others_posts') || !check_ajax_referer('blc_recheck', false, false)) {
         die(json_encode(array('error' => __("You're not allowed to do that!", 'broken-link-checker'))));
     }
     if (!isset($_POST['link_id']) || !is_numeric($_POST['link_id'])) {
         die(json_encode(array('error' => __("Error : link_id not specified", 'broken-link-checker'))));
     }
     $id = intval($_POST['link_id']);
     $link = new blcLink($id);
     if (!$link->valid()) {
         die(json_encode(array('error' => sprintf(__("Oops, I can't find the link %d", 'broken-link-checker'), $id))));
     }
     //In case the immediate check fails, this will ensure the link is checked during the next work() run.
     $link->last_check_attempt = 0;
     $link->isOptionLinkChanged = true;
     $link->save();
     //Check the link and save the results.
     $link->check(true);
     $status = $link->analyse_status();
     $response = array('status_text' => $status['text'], 'status_code' => $status['code'], 'http_code' => empty($link->http_code) ? '' : $link->http_code, 'redirect_count' => $link->redirect_count, 'final_url' => $link->final_url);
     die(json_encode($response));
 }