和哥们研究淘宝客,找到微购这个程序觉得挺不错的,但是地图和RSS功能不是特别完善,于是小憩一下,做了下初级的拓展,分享给大家,开源精神嘛,大家也可以去我的网站我要购物平台去看看。

1.拓展后台seoAction.class.php

<?php
!defined("BUILD_BATCH_COUNT")&&define("BUILD_BATCH_COUNT",200);
class seoAction extends baseAction
{
//显示列表
public function index(){
$this->showindex("网站首页");
}
public function seller()
{
$this->showindex("返现商家");
}
public function search()
{
$this->showindex("逛宝贝");
}
public function album()
{
$this->showindex("专辑");
}
public function promo()
{
$this->showindex("促销活动页");
}
public function exchange_goods()
{
$this->showindex("积分商城");
}
public function cate()
{
$this->showindex("商品分类页");
}
public function item()
{
$this->showindex("商品详细页");
}
public function showindex($title)
{
$map['actionname'] = ACTION_NAME;
$info = $this->seo_mod->where($map)->find();
$this->assign('info',$info);
$this->assign('title',$title);
$this->display("index");
}
//修改
public function edit()
{
$this->seo_mod->create();
$status = $_POST['id'] ? $this->seo_mod->save() : $this->seo_mod->add(); if($status){
$this->success("操作成功!");
}else{
$this->error("操作失败!");
}
}
//伪静态设置
function rewrite(){
$this->assign('set',$this->setting);
$this->display();
}
//设置seo信息
function doEditSeo(){
if(isset($_POST["site"]["url_model"])){
$_POST["site"]["url_model"];
$address = ROOT_PATH."/index/Conf/config.php";
$configFile = file_get_contents($address);
$newFile = str_replace("'URL_MODEL' => {$this->setting['url_model']}","'URL_MODEL' => {$_POST['site']['url_model']}",$configFile);
if(!file_put_contents($address,$newFile)){
$this->error("保存伪静态模式错误!请查看目录是否有修改权限");
}
if(unlink(ROOT_PATH."/index/Runtime/~runtime.php")){
// $success = "保存数据成功";
}
//保存伪静态后缀
if(!empty($_POST['site']['html_suffix'])&&trim($_POST['site']['html_suffix'])!='/'){
$_br = "\r\n";
$_tab = "\t";
$_profile = '<?php'.$_br;
$_profile .= $_tab."//seo后缀配置文件".$_br; $_profile .= $_tab."return array(
'URL_HTML_SUFFIX'=>'{$_POST['site']['html_suffix']}'
);".$_br; $_profile .= $_br;
$_profile .= '?>'.$_br;
if (!file_put_contents(ROOT_PATH."/index/Conf/html_suffix.php", $_profile)) {
$this->error("保存后缀配置文件失败,请重试!");
}
}else{
$_br = "\r\n";
$_tab = "\t";
$_profile = '<?php'.$_br;
$_profile .= $_tab."//seo后缀配置文件".$_br; $_profile .= $_tab."return array( );".$_br; $_profile .= $_br;
$_profile .= '?>'.$_br;
if (!file_put_contents(ROOT_PATH."/index/Conf/html_suffix.php", $_profile)) {
$this->error("保存后缀配置文件失败,请重试!");
}
} $map["name"] = 'url_model';
M('setting')->where($map)->setField('data',$_POST['site']['url_model']);
$map["name"] = 'html_suffix';
M('setting')->where($map)->setField('data',trim($_POST['site']['html_suffix']));
$this->success("保存数据成功!"); }
}
//显示伪静态信息
function showRewriteRules(){
$where=array('name'=>'html_suffix');
$setting_mod=D('setting');
$html_suffix_rel=$setting_mod->where($where)->find();
$this->assign('suffix',$html_suffix_rel['data']); // $where=array('name'=>'url_model');
$url_model_rel=$setting_mod->where($where)->find();
$this->assign('url_model',$url_model_rel['data']); //
$this->display();
} function sitemap(){
if(!empty($_POST['dosubmit'])){
vendor("sitemap.WSitemap");
$_sitemap=new WSiteMap();
$lastmod=date("Y-m-d");
//首页
$_sitemap->add($this->setting['site_domain']."/index.php",$lastmod,"always","1.0");
//导航
$nav_cate = M("nav")->where("is_show=1 AND in_site!='0'")->order("sort_order")->select();
foreach($nav_cate as $v){
if($v['system']=='1')
$loc=$this->setting['site_domain']."/index.php?a=index&m=".$v['alias'];
else{
if($v['in_site']=='0')
$loc=$v['url'];
else
$loc=$this->setting['site_domain']."/index.php?a=index&m=cate&cid=".$v['items_cate_id'];
}
$_sitemap->add($loc,$lastmod,"monthly","0.7");
}
//逛宝贝热门搜索
$setting_cate = M('setting')->where("name='search_words'")->select();
$setting = explode(",",$setting_cate[0]['data']);
foreach($setting as $v)
$_sitemap->add($this->setting['site_domain']."/index.php?a=index&m=search&keywords=".$v,$lastmod,"always","0.8"); //专辑分类
$album_cate = M("album_cate")->where("status=1")->order("sort_order")->select();
foreach($album_cate as $v)
$_sitemap->add($this->setting['site_domain']."/index.php?m=album&a=index&cid=".$v['id'],$lastmod,"monthly","0.7"); //返现商家
$seller_cate = M("seller_cate")->where("status=1")->order("sort")->select();
foreach($seller_cate as $v)
$_sitemap->add($this->setting['site_domain']."/index.php?m=seller&a=index&id=".$v['id'],$lastmod,"monthly","0.9");
//读取标签
$getlabel = file_get_contents("./data/label.txt");
$label = explode(",",$getlabel);
//所有标签
$items_tags = M("items_tags")->where("status=1")->select();
foreach($items_tags as $v){
if(!preg_match("/\w|【|】|、|(|)|\/",$v['name'])){
if(in_array($v['name'],$label))
$_sitemap->add($this->setting['site_domain']."/index.php?m=cate&a=tag&id=".$v['id'],$lastmod,"always","0.9");
}
}
$data=$_sitemap->get();
//读取产品
$data = str_replace('><', ">\n<", $data);
//$data = iconv("GB2312", 'UTF-8',$data);
$data=str_replace("&","&amp;",$data);
if(file_put_contents("sitemap.xml",$_sitemap->begin().$data)){
//读取商品数据
$this->success("提交成功,接下来将分析大数据,请耐心等候...","/admin.php?m=seo&a=sitemap_items",1);
}else{
$this->error("提交失败!");
}
}
$this->display();
} public function sitemap_items(){
import('ORG.Util.Page');
vendor("sitemap.WSitemap");
$_sitemap=new WSiteMap();
$_items=M("items");
$count=!empty($_GET['count'])?$_GET['count']:0;
$nowPage=!empty($_GET['p'])?$_GET['p']:0;
!$count&&$count=$_items->where("status=1")->count("id");
$_page=new Page($count,BUILD_BATCH_COUNT);// 实例化分页类 传入总记录数
$list=$_items->order('add_time DESC')->field("id,add_time")->page($nowPage.','.$_page->listRows)->select();
foreach($list as $v){
$lastmod=date("Y-m-d",$v['add_time']);
$_sitemap->add($this->setting['site_domain']."/index.php?a=index&m=item&id=".$v['id'],$lastmod,"daily","0.9");
}
//读取产品
$data = str_replace('><', ">\n<", $_sitemap->get());
//$data = iconv("GB2312", 'UTF-8',$data);
$data=str_replace("&","&amp;",$data);
if(!file_put_contents("sitemap.xml",$data,FILE_APPEND)){
@file_put_contents("sitemap.xml",$_sitemap->end(),FILE_APPEND);
$this->error("提交失败。","/admin.php?m=seo&a=sitemap",1);
}
if($nowPage>=$_page->totalPages){
@file_put_contents("sitemap.xml",$_sitemap->end(),FILE_APPEND);
$this->success("生成完毕,共生成条".$count."记录。","/admin.php?m=seo&a=sitemap");
}else{
//生成下一页
$this->success("共".$_page->totalPages."页,第".($nowPage+1)."页,请耐心等候...","/admin.php?m=seo&a=sitemap_items&p=".($nowPage+1)."&count=".$count,1);
}
} public function item_rss(){
import('ORG.Util.Page');
vendor("rss.WRss");
$_rss=new WRss();
$_items=M("items");
$count=!empty($_GET['count'])?$_GET['count']:0;
$nowPage=!empty($_GET['p'])?$_GET['p']:0;
if(!$nowPage)
@file_put_contents("rss.xml",$_rss->begin().$_rss->site($this->setting['site_title'],$this->setting['site_domain'],$this->setting['site_description']));
!$count&&$count=$_items->where("status=1")->count("id");
$_page=new Page($count,BUILD_BATCH_COUNT);// 实例化分页类 传入总记录数
$list=$_items->order('add_time DESC')->field("id,title,img,seller_name,add_time")->page($nowPage.','.$_page->listRows)->select();
foreach($list as $v){
$lastmod=date("D d F Y h:i:s",$v['add_time']);
$link=$this->setting['site_domain']."/index.php?a=index&m=item&id=".$v['id'];
$_rss->add($v['title'],$link,$v['title']."<img src=\"{$v[img]}\"/>",$v['seller_name'],$lastmod,$link);
}
//读取产品
$data = str_replace('><', ">\n<", $_rss->get());
//$data = iconv("GB2312", 'UTF-8',$data);
$data=str_replace("&","&amp;",$data);
if(!file_put_contents("rss.xml",$data,FILE_APPEND)){
@file_put_contents("rss.xml",$_rss->end(),FILE_APPEND);
$this->error("提交失败。","/admin.php?m=seo&a=sitemap",1);
}
if($nowPage>=$_page->totalPages){
@file_put_contents("rss.xml",$_rss->end(),FILE_APPEND);
$this->success("生成完毕,共生成条".$count."记录。","/admin.php?m=seo&a=sitemap");
}else{
//生成下一页
$this->success("共".$_page->totalPages."页,第".($nowPage+1)."页,请耐心等候...","/admin.php?m=seo&a=item_rss&p=".($nowPage+1)."&count=".$count,3);
}
} public function ping(){
$ids=$_GET['ids'];
$p=isset($_GET['p'])?$_GET['p']:0;
$idsArray=explode('_',$ids);
$idsCount=count($idsArray);
if($p<$idsCount){
//百度google推送
vendor("ping.WPing");
$_ping=new WPing();
$_items=M("items");
$currentId=$idsArray[$p];
$items=$_items->where("id=".$currentId)->field("title")->find();
if(!$items){
$this->error("记录".$currentId."不存在,将推送下一条请耐心等候...","/admin.php?m=seo&a=ping&p=".($p+1)."&ids=".$ids,1);
}
$link=$this->setting['site_domain']."/index.php?a=index&m=item&id=".$currentId;
$_ping->method($this->setting['site_name'],$this->setting['site_domain'],$link,$this->setting['site_domain'].'/rss.xml');
$sb=$_ping->baidu()?"成功":"失败";
$gb=$_ping->google()?"成功":"失败";
$this->success("共".$idsCount."条记录需要需要推送,当前第".($p+1)."条,百度反馈{$sb},谷歌反馈{$gb}。请耐心等候...","/admin.php?m=seo&a=ping&p=".($p+1)."&ids=".$ids,2);
}else{
$this->success("推送完毕,共生成条".$idsCount."记录。","/admin.php?m=seo&a=sitemap");
}
}
function get_itmes_cate($pid){
$model = M('items_cate');
$map["status"] = 1;
$map["pid"] = $pid;
$list = $model->field('id')->where($map)->select();
foreach($list as $v){
$id .= $v['id'].",";
}
$pid = trim($id,",");
$maps["status"] = 1;
$maps["pid"] = array('in',$pid);
$lists = $model->field('id,name')->where($maps)->select();
foreach($lists as $v){
$str .= "<a href='/index.php?a=index&m=cate&cid=".$v['id']."'>{$v['name']}</a>";
}
return $str;
}
function test(){
$items_tags = M("items_tags")->where("status=1")->select();
foreach($items_tags as $v){
if(!preg_match("/\w|【|】|、|(|)|\/",$v['name'])){
echo $v['name']."&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;http://www.qianbao.cn/index.php?m=cate&a=tag&id=".$v['id']."</br>";
}
}
}
}
?>

追加系统Vendar需要的库文件RSS、Sitemap、Ping

/includes/thinkphp/Extend/Vendar/ping/WPing.php

<?php
/**
+------------------------------------------------------------------------------
* 通知搜索引擎过来抓去最新发布的内容。秒收不是梦
* 目前仅支持Google和Baidu
+------------------------------------------------------------------------------
*/
class WPing {
public $method, $callback;
public function method($site_name,$site_url,$update_url,$update_rss) {
$this->method = "
<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<methodCall>
<methodName>weblogUpdates.extendedPing</methodName>
<params>
<param><value>{$site_name}</value></param>
<param><value>{$site_url}</value></param>
<param><value>{$update_url}</value></param>
<param><value>{$update_rss}</value></param>
</params>
</methodCall>";
return $this->method;
} public function _post($url, $postvar) {
$ch=curl_init ();
$headers=array ("POST " . $url . " HTTP/1.0", "Content-type: text/xml;charset=\"utf-8\"", "Accept: text/xml", "Content-length: " . strlen ( $postvar ) );
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_POST,1);
curl_setopt($ch,CURLOPT_HTTPHEADER,$headers);
curl_setopt($ch,CURLOPT_POSTFIELDS,$postvar);
$res=curl_exec($ch);
curl_close($ch);
return $res;
} public function google() {
$this->callback = $this->_post ( 'http://blogsearch.google.com/ping/RPC2', $this->method );
return strpos ( $this->callback, "<boolean>0</boolean>" ) ? true : false;
} public function baidu() {
$this->callback = $this->_post ( 'http://ping.baidu.com/ping/RPC2', $this->method );
return strpos ( $this->callback, "<int>0</int>" ) ? true : false;
} }
?>

/includes/thinkphp/Extend/Vendar/rss/WRss.php

<?php
class WRss{
private $urls="";
public function add($title,$link,$description,$author,$pubDate,$guid=0,$share=true){
!empty($title)&&$tmp.="<title>{$title}</title>";
!empty($link)&&$tmp.="<link>{$link}</link>";
!empty($description)&&$tmp.="<description>{$description}</description>";
!empty($author)&&$tmp.="<author>{$author}</author>";
!empty($pubDate)&&$tmp.="<pubDate>{$pubDate}</pubDate>";
!empty($guid)&&$tmp.="<guid>{$guid}</guid >";
$this->urls.="<item>".$tmp."</item>";
} public function get($charset="UTF-8"){
return $this->urls;
} public function begin(){
return '<?xml version="1.0" encoding="UTF-8"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0"><channel>';
} public function end(){
return "</channel></rss>";
} public function site($title,$link,$description,$managingEditor="mengdj@outlook.com",$webMaster="mengdj@outlook.com"){
return "<title>{$title}</title><link>{$link}</link><description>{$description}</description><managingEditor>{$managingEditor}</managingEditor><webMaster>{$webMaster}</webMaster>";
}
}
?>

/includes/thinkphp/Extend/Vendar/sitemap/WSitemap.php

<?php
class WSiteMap{
private $urls="";
public function add($loc,$lastmod,$changefreq=0,$priority=0){
!empty($loc)&&$tmp.="<loc>{$loc}</loc>";
!empty($loc)&&$tmp.="<lastmod>{$lastmod}</lastmod>";
!empty($loc)&&$tmp.="<changefreq>{$changefreq}</changefreq>";
!empty($loc)&&$tmp.="<priority>{$priority}</priority>";
$this->urls.="<url>".$tmp."</url>";
} public function get($charset="UTF-8"){
return $this->urls;
} public function begin(){
return '<?xml version="1.0" encoding="UTF-8"?><urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
} public function end(){
return "</urlset>";
}
}
?>

另外修改了thinkphp默认的Page类文件,其实也就开放了一个统计页数的属性

修改完成后再后台添加对应的菜单就可以了,祝你好运。另外还有个拍拍平台采集插件,需要的可联系我。¥5元免费使用升级,哈哈...,当是资助开发了。

文件以及目录可在此处下载:http://files.cnblogs.com/mengdejun/wyao.in.zip

php源码zend加密和解密方案:http://re.paipai.com/tws/...

wego微购RSS、Sitemap、Ping、腾讯拍拍网购采集插件的更多相关文章

  1. 让wego微购购物分享系统采集拍拍数据功能之腾讯paipai功能采集插件

    wego是一款很不错的导购系统,无论前后台设计风格和功能都还不错,可有时我们的确需要一些自定义的功能,毕竟万千世界,大家都做一样的东西,采集同样的数据,能不烦吗?哈哈,今天就奉献上一个wego拍拍采集 ...

  2. 高性能高可用的微服务框架TarsGo的腾讯实践

    conference/2.3 高性能高可用的微服务框架TarsGo的腾讯实践 - 陈明杰.pdf at master · gopherchina/conferencehttps://github.co ...

  3. Ionic2中集成腾讯Bugly之自定义插件

    Ionic2混合开发,入坑系列:Ionic2中集成腾讯Bugly之自定义插件 1.编写Bugly.js代码 var exec = require('cordova/exec'); module.exp ...

  4. JeeWx全新版本发布!捷微二代微信活动平台1.0发布!活动插件持续开源更新!

    JeeWx捷微二代微信活动平台 (专业微信营销活动平台,活动插件持续更新ing~)    终于等到你!还好我没放弃! 在团队持续多年的努力下,Jeewx微信管家和H5活动平台不断更新迭代,积累了许许多 ...

  5. 腾讯用过的插件jQuery twentytwenty 效果对比

    在线实例 左右对比 上下对比 使用方法 <div class="twentytwenty-container">     <img src="/api/ ...

  6. 智芯微版本的智能配变融合终端交流采集APP

    1.  交采APP基本原理 通过SPI总线周期性的召测交流采集底板的“实时数据”,对“实时数据”变换.加工.统计分析得到“分析数据”和“统计数据”后,通过MQTT总线把这些数据同步到“数据中心”供其他 ...

  7. 深度观察:腾讯收购大众点评背景下的O2O大格局

    [亿欧导读] 腾讯入股大众点评获得20%股权,详情解读:①大众点评:独立自主为底线,要钱大于要流量:②腾讯:承认原生活服务O2O失败,丰富移动支付应用场景:③美团承受压力,拉手窝窝继续苦等买家:④BA ...

  8. 腾讯ISUX网页前端代码分析

    看了一下腾讯ISUX网页,无论是pc端还是移动端,展示都挺好看的,先对其代码进行分析如下: 1,先看前三行代码 <!DOCTYPE html> <!-- 腾讯 ISUX 是腾讯集团核 ...

  9. 【BUG】wego购物分享系统未登陆分享宝贝时查看宝贝自动新增产品数据

    1.登录微购http://demo.wego360.com/站. 2.分享宝贝功能检索第三方平台商品数据. 1.登录微购http://demo.wego360.com/站. 2.分享宝贝功能检索第三方 ...

随机推荐

  1. Ubuntu 上安装 MongoDB

    官方安装文档:https://docs.mongodb.com/manual/installation/ 安装环境: mongodb-linux-x86_64-ubuntu1404-3.2.6.tgz ...

  2. Effective C++ 之 Item 2:尽量以 const, enum, inline 替换 #define

    Effective C++ Chapter 1. 让自己习惯C++(Accustoming Yourself to C++) Item 2. 尽量以 const, enum, inline 替换 #d ...

  3. hdu 4784 Dinner Coming Soon(spfa + 优先队列)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4784 思路:建图,对于同一个universe来说,就按题目给的条件相连,对于相邻的universe,连 ...

  4. IM服务器的架构

    一. 总的构架结构示意图: 如上图所示,目前系统总的分成六个模块, 分别为网络/协议解析模块,用户帐号管理模块,消息处理模块,动作处理模块,数据均衡处理模块,客户状态处理模块 . 正常流程应该这么实现 ...

  5. 我的 Unity2D 屏幕适配

    以下方法纯属我YY,切勿当真!!! 确定一个设计尺寸,比如 devWidth = 960,devHeight = 640, 按照这个尺寸进行设计游戏. 方式一: 不管什么屏幕尺寸,都和设计的尺寸对应. ...

  6. 【SSM】拦截器的原理、实现

    一.背景: 走过了双11,我们又迎来了黑色星期五,刚过了黑五,双12又将到来.不管剁手的没有剁手的,估计这次都要剁手了!虽然作为程序猿的我,没有钱但是我们长眼睛了,我们关注到的是我们天猫.淘宝.支付宝 ...

  7. html5 head头标签

    桌面端开发中,meta标签通常用来为搜索引擎优化(SEO)及 robots定义页面主题,或者是定义用户浏览器上的cookie:它可以用于鉴别作者,设定页面格式,标注内容提要和关键字:还可以设置页面使其 ...

  8. Mock方法介绍

    1 现有的单元测试框架单元测试是保证程序正确性的一种有效的测试手段,对于不同的开发语言,通常都能找到相应的单元框架. 借助于这些单测框架的帮助,能够使得我们编写单元测试用例的过程变得便捷而优雅.框架帮 ...

  9. 【前台 】字符串和js对象的相互转化

    利用原生JSON对象,将对象转为字符串 var jsObj = {}; jsObj.testArray = [1,2,3,4,5]; jsObj.name = 'CSS3'; jsObj.date = ...

  10. 【spring bean】 spring中bean之间的引用以及内部bean

    在spring中会有如下的几种情况: 1.在当前容器中,(即在spring.xml这一个配置文件中),一个bean引用了另一个bean. 使用 1>  <ref  bean="另 ...