function baidu_savesitemap($action, $site, $type, $bdpwd, $sign)
{
    global $dsql, $cfg_plus_dir, $cfg_basehost;
    //$siteurl = $cfg_basehost;
    $siteurl = $site;
    $zzaction = '';
    $bdpwd = addslashes($bdpwd);
    if (0 == strncasecmp('save', $action, 3)) {
        $zzaction = 'savesitemap';
    } else {
        return false;
    }
    $script = '';
    $stype = '';
    $pagesize = 0;
    if (1 == $type) {
        $script = 'indexall';
        $stype = 'all';
    } else {
        if (2 == $type) {
            $script = 'indexinc';
            $stype = 'inc';
        } else {
            return false;
        }
    }
    $resource_name = 'RDF_Other_Webpage';
    $bdarcs = new BaiduArticleXml();
    $bdarcs->setSitemapType($type);
    $arctotal = $bdarcs->getTotal();
    if ($arctotal == 0) {
        return false;
    }
    $pagesize = ceil($arctotal / $bdarcs->Row);
    if ($pagesize > 0) {
        for ($i = 0; $i < $pagesize; $i++) {
            $cfg_plus_dir = str_replace("/", '', $cfg_plus_dir);
            $indexurl = $siteurl . "{$cfg_plus_dir}/baidusitemap.php?dopost=sitemap_index&type={$script}&pwd={$bdpwd}&pagesize={$i}";
            $time = time();
            $inQuery = "INSERT INTO `#@__plus_baidusitemap_list` (`url`, `type`, `create_time`, `pagesize`) VALUES ('{$indexurl}', {$type}, {$time}, {$i});";
            $rs = $dsql->ExecuteNoneQuery($inQuery);
            $submiturl = "http://zz.baidu.com/api/opensitemap/{$zzaction}?siteurl=" . urlencode($siteurl) . "&indexurl=" . urlencode($indexurl) . "&tokensign=" . urlencode($sign) . "&type=" . $stype . "&resource_name=" . $resource_name;
            $ret = baidu_http_send($submiturl);
        }
    }
    $bdarcs->setSetupMaxAid();
    return array('json' => $ret, 'url' => $submiturl);
}
예제 #2
0
function baidu_savesitemap($action, $site, $type, $bdpwd, $sign)
{
    global $dsql, $cfg_plus_dir, $cfg_basehost;
    $siteurl = baidu_get_setting('siteurl');
    $token = baidu_get_setting('pingtoken');
    $sign = md5($siteurl . $token);
    $zzaction = '';
    $bdpwd = addslashes($bdpwd);
    if (0 == strncasecmp('save', $action, 3)) {
        $zzaction = 'savesitemap';
    } else {
        return false;
    }
    $script = '';
    $stype = '';
    $pagesize = 0;
    if (1 == $type) {
        $script = 'indexall';
        $stype = 'all';
    } else {
        if (2 == $type) {
            $script = 'indexinc';
            $stype = 'inc';
        } else {
            return false;
        }
    }
    $resource_name = 'CustomSearch_Normal';
    $bdarcs = new BaiduArticleXml();
    $bdarcs->setSitemapType($type);
    $arctotal = $bdarcs->getTotal();
    if ($arctotal == 0) {
        return false;
    }
    $pagesize = ceil($arctotal / $bdarcs->Row);
    if ($pagesize > 0) {
        for ($i = 0; $i < $pagesize; $i++) {
            //$cfg_plus_dir = str_replace("/", '', $cfg_plus_dir );
            $indexurl = $siteurl . "{$cfg_plus_dir}/baidusitemap.php?dopost=sitemap_index&type={$script}&pwd={$bdpwd}&pagesize={$i}";
            $time = time();
            $inQuery = "INSERT INTO `#@__plus_baidusitemap_list` (`url`, `type`, `create_time`, `pagesize`) VALUES ('{$indexurl}', {$type}, {$time}, {$i});";
            $rs = $dsql->ExecuteNoneQuery($inQuery);
        }
    }
    if (1 == $type) {
        $bdarcs->setSetupMaxAid();
    }
    return array('json' => $ret, 'url' => $submiturl);
}