Exemplo n.º 1
0
function plugin_xbel_action()
{
    global $vars, $page_title, $rss_description, $whatsnew;
    $adm = empty($vars['adm']) ? 'page' : $vars['adm'];
    // ユーザ認証されていない
    $id = auth::check_auth();
    if (empty($id)) {
        $adm = 'recent';
    }
    $data = <<<EOD
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xbel PUBLIC "+//IDN python.org//DTD XML Bookmark Exchange Language 1.0//EN//XML" "http://www.python.org/topics/xml/dtds/xbel-1.0.dtd">
<xbel version="1.0">
<title><![CDATA[{$page_title}]]></title>
<desc><![CDATA[{$rss_description}]]></desc>


EOD;
    change_uri('', 1);
    // Force absoluteURI.
    switch ($adm) {
        case 'list':
            $pages = xbel::get_data();
            break;
        case 'recent':
            $pages = array($whatsnew);
            break;
            // list
        // list
        default:
            $page = empty($vars['page']) ? $whatsnew : $vars['page'];
            $pages = array($page);
            unset($page);
    }
    foreach ($pages as $page) {
        $links = xbel::get_link_list($page);
        $data .= xbel::put_body($links, $page);
    }
    $data .= "</xbel>\n";
    pkwk_common_headers();
    header('Content-type: application/xml');
    print $data;
    exit;
}
Exemplo n.º 2
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;
}