专注ECSHOP第九年
始自2007,服务二千多商户,不断为您增光溢彩

ECSHOP BAIDUPING插件-搜索引擎收录利器快速提升收录

插件名称:ECSHOP-搜索引擎收录利器快速提升收录

  适用版本:本版本在ECSHOP 2.7.3基础上所开发测试通过

  使用方法:

  如您的ECSHOP 没改过 admin/goods.php 和 admin/article.php 可直接覆盖

  已经改过文件 可看下面的说明:

  打开您的文件:admin/goods.php约1148行增加下面的代码

/* Baidu Ping 2014/10/27 星期一*/
$is_ping = $db->getOne(“SELECT is_ping FROM “.$ecs->table(‘goods’) .” where goods_id ='{$goods_id}’ “);
if($goods_id && $is_ping==”0”){
include_once(ROOT_PATH . ADMIN_PATH.’/includes/lib_ping.php’);
ping_baidu(‘goods’ , $catgory_id , $goods_id);
$db->query(“UPDATE ” . $ecs->table(‘goods’) . ” SET is_ping=’1′ WHERE `goods_id`='{$goods_id}'”);
}
/* Baidu Ping 2014/10/27 星期一*/

  打开admin/article.php 在 189 行后面插入 如下代码

/* Baidu Ping 2014/10/27 星期一*/
$is_ping = $db->getOne(“SELECT is_ping FROM “.$ecs->table(‘article’) .” where article_id ='{$article_id}’ “);
if($article_id && $is_ping==”0”){
include_once(ROOT_PATH . ADMIN_PATH.’/includes/lib_ping.php’);
ping_baidu(‘article’ , $_POST[‘article_cat’] , $article_id);
$db->query(“UPDATE ” . $ecs->table(‘article’) . ” SET is_ping=’1′ WHERE `article_id`='{$article_id}'”);
}

admin/includes/lib_ping.php内容:
2014/10/27 星期一
// +——————————————————————————————–
///**
// * +===================================================
// * // 搜索引擎快速收录插件,如有BUG请联系本人!!
// * +===================================================
/// */

if(!defined(‘IN_ECS’)) {
exit(‘Access Denied’);
}

$_G = array();
$_G[‘jntoo_ping’][‘status’] = ‘1’; // 开启 百度搜索引擎 快速收录功能
$_G[‘jntoo_ping’][‘count’] = ‘0’; // 开启 PING 功能统计

function ping_baidu($type , $cid , $gid){
ping::post_newthread_message($type , $cid , $gid);
}

class ping{
static function post_newthread_message( $type , $cid , $gid ){
global $_G,$tid;
$ping = $_G[‘jntoo_ping’];
if($ping[‘status’] == ‘1’){

$ret = jntoo_pingjntoo::postping($type , $cid , $gid);

if($ret && $ping[‘count’] == ‘1’)
{
$file = dirname(__FILE__) . ‘/’;
$data = include $file . ‘count.php’;
if($ret){
$data[‘yes’]++;
}else{
$data[‘no’]++;
}

$content = ““;
file_put_contents($file . ‘count.php’ , $content);
}
}
}
}

class jntoo_pingjntoo {

static function postping($type , $cid , $gid){

$navtitle = $GLOBALS[‘_CFG’][‘shop_title’];
if(EC_CHARSET != ‘utf-8’){
$navtitle = ecs_iconv(‘gbk’ , ‘utf-8’ , $navtitle);
}

$hosturl = $GLOBALS[‘ecs’]->url();

$url = $hosturl . build_uri($type , array( ($type == ‘goods’ ? ‘gid’ : ‘aid’) => $gid ) , ”);
$rss_url = $hosturl . ‘feed.php?cat=’.$cid.($type == ‘article’ ? ‘&type=article_cat’ : ”);

$data = self::getData($navtitle , $hosturl , $url , $rss_url);
//echo $url;exit;
$ret = self::ping(‘http://ping.baidu.com/ping/RPC2’ , $data);
if($ret[‘code’] == 200)
{
return true;
}else{
return false;
}
}

static function getData($navtitle , $hosturl , $url , $rss_url){
$t = ‘?xml version=”1.0″ encoding=”UTF-8″?>
weblogUpdates.extendedPing ‘.$navtitle.’ ‘.$hosturl.’ ‘.$url.’ ‘.$rss_url.’
‘;
return $t;
}

static function ping($url , $data){
if(function_exists(‘curl_init’) && function_exists(‘curl_exec’)){
$ci = curl_init();
curl_setopt($ci, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
curl_setopt($ci, CURLOPT_CONNECTTIMEOUT, 20);
curl_setopt($ci, CURLOPT_TIMEOUT, 60);
curl_setopt($ci, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ci, CURLOPT_ENCODING, “”);
curl_setopt($ci, CURLOPT_SSL_VERIFYPEER, false);
$header = array();
$header[] = ‘User-Agent: request’;
$header[] = ‘Content-Type: text/xml’;

curl_setopt($ci, CURLOPT_POST, TRUE);
curl_setopt($ci, CURLOPT_POSTFIELDS, $data);

curl_setopt($ci , CURLOPT_HTTPHEADER , $header);
curl_setopt($ci, CURLOPT_URL, $url );
curl_setopt($ci, CURLINFO_HEADER_OUT, TRUE );
$ret = array();

$ret[‘response’] = curl_exec($ci);
$ret[‘code’] = curl_getinfo($ci, CURLINFO_HTTP_CODE);
$ret[‘http_info’] = curl_getinfo($ci);
curl_close ($ci);
return $ret;
}else{
$timeout = 60;
$urlarr = parse_url($url);

$errno = ”;
$errstr = ”;
$transports = ”;
$responseText = ”;
if($urlarr[‘scheme’] == ‘https’) {
$transports = ‘ssl://’;
$urlarr[‘port’] = ‘443’;
} else {
$transports = ‘tcp://’;
$urlarr[‘port’] = ’80’;
}
$method = ‘POST’;
$fpflag = 0;

$out = $method.’ ‘. $urlarr[‘path’] .” HTTP/1.0\r\n”;

$header .= “User-Agent: request\r\n”;
$header .= “Content-type: text/xml\r\n”;
$header .= “Content-length: “.strlen($postfields).”\r\n”;

$header .= “Host: “.$urlarr[‘host’].”\r\n”;
$header .= “Connection: close\r\n\r\n”;

$out .= $header . $data;

$fp = @fsockopen($transports . $urlarr[‘host’] , $urlarr[‘port’] , $errno , $errstr , $timeout);
if(!$fp){
$context = array(
‘http’ => array(
‘method’ => $method,
‘header’ => $header,
‘content’ => $data,
‘timeout’ => $timeout,
),
);

$path = $urlarr[‘path’] ? $urlarr[‘path’].($urlarr[‘query’] ? ‘?’.$urlarr[‘query’] : ”) : ‘/’;

$context = stream_context_create($context);
$fp = @fopen($matches[‘scheme’].’:’.$urlarr[‘port’].$path, ‘b’, false, $context);
$fpflag = 1;
}

if(!$fp) {
return ”;
} else {
stream_set_blocking($fp, true);
stream_set_timeout($fp, $timeout);
@fwrite($fp, $out);
$status = stream_get_meta_data($fp);
if(!$status[‘timed_out’]) {
while (!feof($fp) && !$fpflag) {
if(($header = @fgets($fp)) && ($header == “\r\n” || $header == “\n”)) {
break;
}
}
$return = stream_get_contents($fp);
}
@fclose($fp);
return array(‘response’ => $return , ‘http_info’ => $header , ‘code’ => 200);
}
}
return ”;
}
}
?>

赞(0) 打赏
未经允许不得转载:阿牛ECSHOP » ECSHOP BAIDUPING插件-搜索引擎收录利器快速提升收录
分享到: 更多 (0)
1

评论 抢沙发

阿牛ECSHOP 更专业 更方便

关于我们联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏