Esempio n. 1
0
function lib_baidusitemap(&$ctag, &$refObj)
{
    global $dsql, $envs;
    //属性处理
    $attlist = "type|code";
    FillAttsDefault($ctag->CAttribute->Items, $attlist);
    extract($ctag->CAttribute->Items, EXTR_SKIP);
    $reval = "";
    if (!$dsql->IsTable("#@__plus_baidusitemap_setting")) {
        return '没安百度站内搜索模块';
    }
    $site_id = baidu_get_setting('site_id');
    if (empty($site_id)) {
        return '尚未绑定站点ID,请登录系统后台绑定';
    }
    if ($type == 'code') {
        $reval .= <<<EOT
<script type="text/javascript">document.write(unescape('%3Cdiv id="bdcs"%3E%3C/div%3E%3Cscript charset="utf-8" src="http://znsv.baidu.com/customer_search/api/js?sid={$site_id}') + '&plate_url=' + (encodeURIComponent(window.location.href)) + '&t=' + (Math.ceil(new Date()/3600000)) + unescape('"%3E%3C/script%3E'));</script>
EOT;
    }
    return $reval;
}
Esempio n. 2
0
        echo json_encode(array('status' => 0));
        exit;
    }
    $siteurl = baidu_get_setting('siteurl');
    $token = baidu_get_setting('pingtoken');
    $sign = md5($siteurl . $token);
    if ($checksign == $sign) {
        $data = baidu_set_setting('site_id', $site_id);
        echo json_encode(array('status' => 1));
    }
    //if (!$checksign || strlen($checksign) !== 32 ){
    //    exit();
    //}
} elseif ($dopost == 'success') {
    $site_id = baidu_get_setting('site_id');
    $siteurl = baidu_get_setting('siteurl');
    if (empty($site_id)) {
        ShowMsg("当前系统尚无绑定站点ID,请在系统后台百度站内搜索模块中绑定!", "javascript:;");
        exit;
    }
    $msg = <<<EOT
<div style="padding:20px; color:#000;line-height:22px">
<table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#DADADA">
\t<tbody>
\t\t<tr bgcolor="#FFFFFF">
\t\t\t<td colspan="2" height="100">
\t\t\t\t<table width="98%" border="0" cellspacing="1" cellpadding="1">
\t\t\t\t\t<tbody>
\t\t\t\t\t\t<tr>
\t\t\t\t\t\t\t<td width="16%" height="30">站点地址:</td>
\t\t\t\t\t\t\t<td width="84%" style="text-align:left;"><span style="color:black">{$siteurl}</span>
Esempio n. 3
0
EOT;
    $msg = "<div style=\"line-height:36px;\">{$msg}</div><script type=\"text/javascript\">\nfunction isGoUrl(url,msg)\n{\n\tif(confirm(msg))\n\t{\n\t\twindow.location.href=url;\n\t} else {\n\t\treturn false;\n\t}\n}\n</script>";
    $wintitle = '百度站内搜索';
    $wecome_info = '百度站内搜索 》';
    $win = new OxWindow();
    $win->AddTitle($wintitle);
    $win->AddMsgItem($msg);
    $winform = $win->GetWindow('hand', '&nbsp;', false);
    $win->Display();
} else {
    //返回成功信息
    $siteurl = baidu_get_setting('siteurl');
    $setupmaxaid = baidu_get_setting('setupmaxaid');
    $lastuptime_all = date('Y-m-d', baidu_get_setting('lastuptime_all'));
    $lastuptime_inc = date('Y-m-d', baidu_get_setting('lastuptime_inc'));
    $site_id = baidu_get_setting('site_id');
    if (empty($site_id)) {
        header('location:?dopost=bind');
        exit;
    }
    $site_id_msg = $submitall_msg = '';
    if (empty($site_id)) {
        $site_id_msg = '<font color="red">尚未绑定站点ID,请点击</font><a href="?dopost=bind_site_id" style="color:blue">[绑定站点ID]</a><font color="red">完成绑定</font>';
    }
    if (!empty($site_id) and empty($lastuptime_all)) {
        //header('location:?dopost=auth&action=resubmit');
        //exit;
        $submitall_msg = '<font color="red">尚未提交全量索引,点击</font><a href="?dopost=auth&action=resubmit" style="color:blue">[提交全量索引]</a><font color="red">进行提交,提交5个小时后才有搜索结果</font>';
    }
    $bdarcs = new BaiduArticleXml();
    $bdarcs->setSitemapType(1);
    function toXml()
    {
        global $dsql, $cfg_webname, $cfg_basehost, $cfg_soft_lang;
        $addonQuery = $limitQuery = "";
        if (!empty($this->Typeid)) {
            $addonQuery .= "AND arc.typeid=" . intval($this->Typeid);
            $typeinfos = $this->getType($this->Typeid);
        }
        if ($this->SitemapType == 2) {
            $setupmaxaid = baidu_get_setting('setupmaxaid');
            $addonQuery .= "AND arc.id>" . intval($setupmaxaid);
        }
        $this->Start = intval($this->Start);
        //var_dump($typeinfos);exit();
        if (!empty($this->Row)) {
            $limitQuery = "LIMIT  {$this->Start}," . intval($this->Row);
        }
        $query = "SELECT arc.*,arc.senddate AS pubdate,tp.typedir,tp.typename,tp.isdefault,tp.defaultname,tp.namerule,\n\t\t\ttp.namerule2,tp.ispart,tp.moresite,tp.siteurl,tp.sitepath,at.body\n\t\t\tFROM `{$this->MainTable}` arc LEFT JOIN `#@__arctype` tp ON arc.typeid=tp.id\n            LEFT JOIN `#@__addonarticle` at ON arc.id=at.aid\n\t\t\tWHERE arc.arcrank=0 AND arc.arcrank > -1 AND arc.channel=1 {$addonQuery} ORDER BY arc.senddate DESC {$limitQuery}";
        //var_dump($query);
        $dsql->SetQuery($query);
        $dsql->Execute('dd');
        $xmlstr = '<?xml version="1.0" encoding="UTF-8"?>
<urlset>';
        $setupmaxaid = 0;
        while ($row = $dsql->GetArray('dd')) {
            $row['id'] = isset($row['aid']) ? $row['aid'] : $row['id'];
            $row['filename'] = $row['arcurl'] = GetFileUrl($row['id'], $row['typeid'], $row['senddate'], $row['title'], 1, 0, $row['namerule'], $row['typedir'], 0, '', $row['moresite'], $row['siteurl'], $row['sitepath']);
            $row['showdate'] = Mydate('Y-m-d', $row['pubdate']);
            $row['priority'] = 0;
            $row['body'] = isset($row['body']) ? Html2Text($row['body']) : '';
            $row['body'] = empty($row['body']) ? $row['description'] : $row['body'];
            //var_dump($row);exit;
            if (preg_match("#c#", $row['flag'])) {
                $row['priority'] = '1.0';
            }
            if (!isset($typeinfos)) {
                $typeinfos = $this->getType($row['typeid']);
            }
            //var_dump($typeinfo);exit();
            //var_dump($row);
            $row['source'] = trim(Html2Text($row['source']));
            $row['title'] = baidu_strip_invalid_xml($row['title']);
            $row['body'] = baidu_strip_invalid_xml($row['body']);
            $addstr = $copyrightstr = $yearstr = "";
            $copyrightstr = !empty($row['source']) ? "\r\n\t\t\t\t\t<copyrightHolder><name><![CDATA[{$row['source']}]]></name></copyrightHolder>" : '';
            $addstr .= empty($row['litpic']) ? "" : "\r\n\t\t\t\t\t<image><![CDATA[{$row['litpic']}]]></image>";
            $yearstr = Mydate('Y', $row['pubdate']);
            $rowxmlstr = <<<EOT
\t
\t<url>
\t\t\t<loc><![CDATA[{$cfg_basehost}{$row['filename']}]]></loc>
\t\t\t<lastmod>{$row['showdate']}</lastmod>
\t\t\t<changefreq>always</changefreq>
\t\t\t<priority>{$row['priority']}</priority>
\t\t\t<data>
\t\t\t\t<Webpage>
\t\t\t\t\t<name><![CDATA[{$row['title']}]]></name>
\t\t\t\t\t<url><![CDATA[{$cfg_basehost}{$row['filename']}]]></url>
\t\t\t\t\t<provider>
\t\t\t\t\t\t<name><![CDATA[{$cfg_webname}]]></name>
\t\t\t\t\t\t<url><![CDATA[{$cfg_basehost}]]></url>
\t\t\t\t\t</provider>
\t\t\t\t\t<description><![CDATA[{$row['description']}]]></description>
                    <text><![CDATA[{$row['body']}]]></text>
                    <keywords><![CDATA[{$row['keywords']}]]></keywords>
\t\t\t\t\t<breadcrumb><![CDATA[{$typeinfos['position']}]]></breadcrumb>
\t\t\t\t\t{$addstr}
                    <isPartOf>
\t\t\t\t\t\t<name><![CDATA[{$typeinfos['typename']}]]></name>
\t\t\t\t\t\t<url><![CDATA[{$cfg_basehost}{$typeinfos['typelink']}]]></url>
\t\t\t\t\t</isPartOf>
                    {$copyrightstr}
\t\t\t\t\t<copyrightYear>{$yearstr}</copyrightYear>
\t\t\t\t</Webpage>
\t\t\t</data>
\t\t</url>
EOT;
            if ($cfg_soft_lang == 'gb2312') {
                $rowxmlstr = gb2utf8($rowxmlstr);
            }
            //var_dump($rowxmlstr);exit;
            $xmlstr .= $rowxmlstr;
        }
        //exit($xmlstr);
        $xmlstr .= "\r\n</urlset>";
        //$xmldata['content'] = $xmlstr;
        return $xmlstr;
    }
Esempio n. 5
0
}
if (!isset($searchtype)) {
    $searchtype = 'titlekeyword';
} else {
    $searchtype = preg_replace("#[^a-z]#i", '', $searchtype);
}
if (!isset($keyword)) {
    if (!isset($q)) {
        $q = '';
    }
    $keyword = $q;
}
$oldkeyword = $keyword = FilterSearch(stripslashes($keyword));
if (function_exists('baidu_get_setting')) {
    $site_id = baidu_get_setting('site_id');
    $lastuptime_all = baidu_get_setting('lastuptime_all');
    $addquery = '';
    if ($searchtype == 'title') {
        $addquery = '&stp=1';
    }
    // 需要提交全量索引后5个小时内才能够进行跳转
    if (!empty($site_id) and time() - $lastuptime_all > 60 * 60 * 5) {
        $row = $dsql->GetOne("SELECT spwords FROM `#@__search_keywords` WHERE keyword='" . addslashes($keyword) . "'; ");
        if (!is_array($row)) {
            $inquery = "INSERT INTO `#@__search_keywords`(`keyword`,`spwords`,`count`,`result`,`lasttime`)\n          VALUES ('" . addslashes($keyword) . "', '" . addslashes($keyword) . "', '1', '0', '" . time() . "'); ";
            $dsql->ExecuteNoneQuery($inquery);
        } else {
            $dsql->ExecuteNoneQuery("UPDATE `#@__search_keywords` SET count=count+1,lasttime='" . time() . "' WHERE keyword='" . addslashes($keyword) . "'; ");
        }
        $keyword = urlencode($keyword);
        $baidu_search_url = "http://zhannei.baidu.com/cse/search?s={$site_id}&entry=1&q={$keyword}{$addquery}";
    $dopost = '';
}
if (empty($action)) {
    $action = '';
}
if ($dopost == 'checkurl') {
    $checksign = $_GET['checksign'];
    if (!$checksign || strlen($checksign) !== 32) {
        exit;
    }
    $data = baidu_get_setting('checksign', true);
    if ($data && $data['svalue'] == $checksign && time() - $data['stime'] < 30) {
        echo $data['svalue'];
    }
} elseif ($dopost == 'sitemap_index') {
    if (empty($_GET['pwd']) || $_GET['pwd'] != ($bdpwd = baidu_get_setting('bdpwd'))) {
        baidu_header_status(404);
        return 1;
    }
    $pagesize = empty($pagesize) ? 0 : intval($pagesize);
    $sitemap_type = 0;
    if ($type == 'indexall') {
        $sitemap_type = 1;
    } elseif ($type == 'indexinc') {
        $sitemap_type = 2;
    }
    $bdarcs = new BaiduArticleXml();
    $start = $pagesize * $bdarcs->Row;
    $bdarcs->setSitemapType($sitemap_type);
    $bdarcs->Start = $start;
    echo $bdarcs->toXml();
Esempio n. 7
0
        $liststr .= "&nbsp;&nbsp;&nbsp;{$typestr} {$arr['url']}<br/>\r\n";
    }
    //返回成功信息
    $msg = "\r\n    {$liststr}";
    $msg = "<div style=\"line-height:20px;\">    {$msg}</div>";
    $wintitle = '您已经提交的索引列表:';
    $wecome_info = '<a href=\'baidusitemap_main.php\'>索引操作</a> 》百度结构化数据地图::索引操作';
    $win = new OxWindow();
    $win->AddTitle($wintitle);
    $win->AddMsgItem($msg);
    $winform = $win->GetWindow('hand', '&nbsp;', false);
    $win->Display();
} else {
    //返回成功信息
    $siteurl = baidu_get_setting('siteurl');
    $setupmaxaid = baidu_get_setting('setupmaxaid');
    $lastuptime_all = date('Y-m-d', baidu_get_setting('lastuptime_all'));
    $lastuptime_inc = date('Y-m-d', baidu_get_setting('lastuptime_inc'));
    $bdarcs = new BaiduArticleXml();
    $bdarcs->setSitemapType(1);
    $maxaid = $bdarcs->getMaxAid();
    $msg = "     请选择您需要的操作:\r\n    <a href='javascript:isGoUrl(\"baidusitemap_main.php?dopost=auth\",\"是否确定提交增量索引?\");'><u>提交增量索引</u></a>\r\n    &nbsp;&nbsp;\r\n    <a href='javascript:isGoUrl(\"baidusitemap_main.php?dopost=auth&action=resubmit\",\"是否确定重新提交全量索引?\");' ><u>重新提交全量索引</u></a>\r\n    &nbsp;&nbsp;\r\n    <a href='baidusitemap_main.php?dopost=viewsub'><u>查看提交索引</u></a>\r\n    &nbsp;&nbsp;\r\n    <a href='baidusitemap_main.php?dopost=checkupdate'><u>检查插件更新</u></a>\r\n    &nbsp;&nbsp;\r\n<br />\r\n<div style=\"padding:20px; color:#666\">\r\n插件信息:<br />\r\n站点地址:<span style='color:black'><b>{$siteurl}</b></span><br />\r\n最后提交文档ID:<span style='color:black'><b>{$setupmaxaid}</b></span>,当前文档最新ID:<span style='color:black'><b>{$maxaid}</b></span><br />\r\n增量索引最后提交:<span style='color:black'><b>{$lastuptime_all}</b></span><br />\r\n全量索引最后提交:<span style='color:black'><b>{$lastuptime_inc}</b></span><br />\r\n<hr/>\r\n功能说明:<br />\r\n【提交增量索引】\r\n用于提交更新频率较频繁的索引,一般是全量索引提交完成后,每次更新少量内容后进行增量索引提交;<br />\r\n【重新提交全量索引】\r\n重新对全站的百度地图索引进行提交;<br />\r\n<span style=\"color:red\">注:点击提交后可能等待时间较长,请耐心等待。</span><br />\r\n</div>\r\n  ";
    $msg = "<div style=\"line-height:36px;height:280px\">{$msg}</div><script type=\"text/javascript\">\r\nfunction isGoUrl(url,msg)\r\n{\r\n\tif(confirm(msg))\r\n\t{\r\n\t\twindow.location.href=url;\r\n\t} else {\r\n\t\treturn false;\r\n\t}\r\n}\r\n</script>";
    $wintitle = '提交百度结构化数据地图索引!';
    $wecome_info = '百度结构化数据地图::索引操作';
    $win = new OxWindow();
    $win->AddTitle($wintitle);
    $win->AddMsgItem($msg);
    $winform = $win->GetWindow('hand', '&nbsp;', false);
    $win->Display();
}
Esempio n. 8
0
function baidu_delsitemap($site, $type = 0, $sign)
{
    global $dsql, $cfg_plus_dir;
    $siteurl = baidu_get_setting('siteurl');
    $token = baidu_get_setting('pingtoken');
    $bdpwd = baidu_get_setting('bdpwd');
    $sign = md5($siteurl . $token);
    $type = intval($type);
    $addWhere = "";
    if ($type > 0) {
        $indexurl = $siteurl . "{$cfg_plus_dir}/baidusitemap.php?dopost=sitemap_urls&pwd={$bdpwd}&type={$type}";
        $submiturl = "http://zz.baidu.com/api/opensitemap/deletesitemap?siteurl=" . urlencode($siteurl) . "&indexurl=" . urlencode($indexurl) . "&tokensign=" . urlencode($sign);
        $ret = baidu_http_send($submiturl);
        $delQuery = "DELETE FROM `#@__plus_baidusitemap_list` WHERE `type`='{$type}';";
        $dsql->ExecuteNoneQuery($delQuery);
        return true;
    }
    return false;
}