Example #1
0
function plugin_brokenlink_action()
{
    global $vars, $_brokenlink_msg;
    $retval = array('msg' => $_brokenlink_msg['msg_title'], 'body' => '');
    if (empty($vars['page'])) {
        $retval['body'] = $_brokenlink_msg['msg_param_error'];
        return $retval;
    }
    // ユーザ認証されていない
    $id = Auth::check_auth();
    if (empty($id)) {
        $retval['body'] = $_brokenlink_msg['msg_not_access'];
        return $retval;
    }
    if (!exist_plugin('xbel')) {
        $retval['body'] = $_brokenlink_msg['msg_not_found_xbel'];
        return $retval;
    }
    $links = xbel::get_link_list($vars['page']);
    $data = '';
    foreach ($links as $href => $aname) {
        $rc = http_request($href, 'HEAD');
        switch ($rc['rc']) {
            case 200:
                // Ok
            // Ok
            case 301:
                // Moved Permanently
            // Moved Permanently
            case 401:
                // Unauthorized
                continue;
            default:
                $data .= '-[[' . $aname . '>' . $href . ']] (' . $rc['rc'] . ")\n";
        }
    }
    if ($data == '') {
        $data = $_brokenlink_msg['msg_all_ok'];
    }
    $retval['body'] = RendererFactorty::factory($data);
    return $retval;
}
Example #2
0
 function get_link_list($page)
 {
     $links = $tmp = array();
     $data = get_source($page, TRUE, TRUE);
     $html = convert_html($data);
     preg_match_all("'href=\"(https?://[^\"]+).*?>(.*?)<'si", $html, $tmp, PREG_PATTERN_ORDER);
     $str_redirect = get_cmd_absuri('redirect', '', 'u=');
     $spos = PKWK_USE_REDIRECT ? strlen($str_redirect) : 0;
     $ctr = count($tmp[1]);
     for ($i = 0; $i < $ctr; $i++) {
         if (xbel::is_ignore($tmp[1][$i])) {
             continue;
         }
         // 名称が無い場合
         if (empty($tmp[2][$i])) {
             continue;
         }
         $aname = trim($tmp[2][$i]);
         if ($aname == '') {
             continue;
         }
         // Redirect を有効にしている場合の対応
         if (strpos($tmp[1][$i], $str_redirect) === FALSE) {
             $href = $tmp[1][$i];
         } else {
             $href = rawurldecode(substr($tmp[1][$i], $spos));
         }
         // HREF でサマリする
         $links[$href] = $aname;
     }
     // GreyBox 対応
     preg_match_all("'GB_showFullScreen\\(\\'(.*?)\\'\\, \\'(.*?)\\'\\);\"'si", $html, $tmp, PREG_PATTERN_ORDER);
     $ctr = count($tmp[1]);
     for ($i = 0; $i < $ctr; $i++) {
         $links[$tmp[2][$i]] = $tmp[1][$i];
     }
     return $links;
 }