找回密码

火车采集器软件交流官方论坛

搜索
火车采集器V9版免费下载火车浏览器 - 可视采集,万能群发,全自动脚本工具
查看: 17403|回复: 26

Wordpress 2.6-2.7 采集发布解决方案

[复制链接]
发表于 2008-12-19 18:33:43 | 显示全部楼层 |阅读模式
这个我们是写了一个接口来实现,代码公开,可以自己随意修改。使用请看模块说明。

  1. <?php
  2. include "wp-config.php"; //这里是引用原来的数据库文件.
  3. include "mysql.class.php"; //这里是引用数据库类.
  4. $DB = new Mysql(DB_HOST, DB_USER, DB_PASSWORD,DB_NAME);//初始化数据库类
  5. if(isset($_GET['action'])&&$_GET['action'] == "list")
  6. {
  7. $sql="SELECT tt.term_id,tt.term_taxonomy_id,t.name,tt.term_id,t.term_id,tt.taxonomy from ".$table_prefix."terms t,".$table_prefix."term_taxonomy tt where t.term_id=tt.term_id AND tt.taxonomy='category' ";
  8. $query=$DB->query($sql);
  9. while ($config=$DB->fetch_array($query))
  10. {
  11. echo '<<<'.$config['term_id'].'--'.$config['name'].'>>>';
  12. }
  13. }
  14. elseif(isset($_GET['action'])&&$_GET['action'] == "save")
  15. {
  16. $post=$_POST;  
  17. extract($post);
  18. ($post_title=='[标签:标题]'||$post_title=='')?die('标题为空'):'';
  19. ($post_content=='[标签:内容]'||$post_content=='')?die('内容为空'):'';
  20. ($post_category=='[分类id]'||$post_category=='')?die('分类id为空'):'';
  21. if($tag=='[标签:SY_tag]'){$tag='';}
  22. $post_date=date("Y-m-d H:i:s");
  23. $tm=time();
  24. $sql="INSERT INTO `".$table_prefix."posts` ( `post_author`, `post_date`, `post_date_gmt`, `post_content`, `post_title`, `post_category`, `post_excerpt`, `post_status`, `comment_status`, `ping_status`, `post_password`, `post_name`, `to_ping`, `pinged`, `post_modified`, `post_modified_gmt`, `post_content_filtered`, `post_parent`, `guid`, `menu_order`, `post_type`, `post_mime_type`, `comment_count`) VALUES (1, '$post_date', '$post_date', '$post_content', '$post_title', '$post_category', '$post_excerpt', 'publish', 'open', 'open', '', '$post_name', '', '', '$post_date', '$post_date', '$post_content_filtered', 0, '$guid', '$menu_order', 'post', '$post_mime_type', '$comment_count')";
  25. $query=$DB->query($sql);
  26. $postid=$DB->insert_id($sql);
  27. $sqledit="INSERT INTO `".$table_prefix."postmeta` (post_id ,meta_key ,meta_value ) VALUES ($postid,'_edit_lock','$tm'),($postid,'_edit_last',1)";
  28. $query2=$DB->query($sqledit);
  29. /*自定义字段处理方法
  30. if(!$image=='[标签:缩略]')
  31.   {
  32.         $sqledit2="INSERT INTO `".$table_prefix."postmeta` (post_id ,meta_key ,meta_value ) VALUES ($postid,'image','$image')";
  33.   $qim=$DB->query($sqledit2);
  34.   }
  35.    */

  36.     $sqlcid="INSERT INTO `".$table_prefix."term_relationships` (object_id ,term_taxonomy_id ) VALUES ($postid,'$cid')";
  37. $cidquery=$DB->query($sqlcid);
  38. if(!$tag=='')
  39.   {
  40.      $tags= array_unique(explode(",",$tag));
  41.   foreach($tags as $var)
  42.    {
  43.    $ssql="SELECT * from ".$table_prefix."terms where name='$var' ";
  44.    $squery=$DB->fetch_one_array($ssql);
  45.    if($squery)
  46.     {
  47.     $tagidss=$DB->fetch_one_array($ssql);
  48.     $tagids=$tagidss['term_id'];
  49.     $gettagid="SELECT term_taxonomy_id,term_id from ".$table_prefix."term_taxonomy where term_id='$tagids' ";
  50.     $gettag=$DB->fetch_one_array($gettagid);
  51.     $tagid=$gettag['term_taxonomy_id'];
  52.     $sqltag="INSERT INTO `".$table_prefix."term_relationships` (object_id ,term_taxonomy_id ) VALUES ($postid,'$tagid')";
  53.     $tagquery=$DB->query($sqltag);
  54.     }else{
  55.     $uc=urlencode($var);
  56.     $addtag="INSERT INTO `".$table_prefix."terms` (name,slug) VALUES ('$var','$uc')";
  57.     $addquery=$DB->query($addtag);
  58.     $addtagid=$DB->insert_id($addtag);
  59.     $addterm="INSERT INTO `".$table_prefix."term_taxonomy` (term_id,taxonomy) VALUES ('$addtagid','post_tag')";
  60.     //echo $addtag.$addterm;
  61.     $termquery=$DB->query($addterm);
  62.     $tagids=$DB->insert_id($addterm);
  63.     $sqltag="INSERT INTO `".$table_prefix."term_relationships` (object_id ,term_taxonomy_id ) VALUES ($postid,'$tagids')";
  64.     $tagquery=$DB->query($sqltag);
  65.     }
  66.    }
  67.   }
  68. echo '发布成功';
  69. }else{
  70. echo 'rq204告诉你,你没有选择任何的操作。请返回';
  71. }
  72. ?>
复制代码

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?加入会员

x
发表于 2008-12-19 19:30:38 | 显示全部楼层
我先到了  支持先再说

3k
发表于 2008-12-19 19:40:27 | 显示全部楼层
嘿嘿,不错哦,推荐大家使用WP,虽然刚被GG K了一站,OH MY GOD
发表于 2008-12-20 11:53:15 | 显示全部楼层
刷不出来分类,是哪里的问题?
发表于 2008-12-20 13:01:43 | 显示全部楼层
Thanks a lot.
发表于 2008-12-20 14:35:16 | 显示全部楼层
本帖最后由 kiss2008 于 2008-12-20 19:03 编辑
刷不出来分类,是哪里的问题?
月七月八 发表于 2008-12-20 11:53


找到文件夹locoy里的spl.php文件,修改里面的第二行代码,
  1. include "wp-config.php";
复制代码
替换成
  1. include "../wp-config.php";
复制代码
即可。(这时可以删除locoy文件夹里的wp-config.php文件了)

感谢rq204的开源精神,赞一个!

顺便问个问题,这个模块是模拟入库还是在线post?如果不是在线post,那能在发布的同时,可以ping吗?(不能ping,大大影响搜索引擎的收录)敬请管理员回答一下。

再次感谢!
发表于 2008-12-20 19:04:26 | 显示全部楼层
不要同时ping,最好能够隔段时间ping
发表于 2008-12-21 05:59:14 | 显示全部楼层
支持先再说
 楼主| 发表于 2008-12-21 10:59:25 | 显示全部楼层
6# kiss2008

这个是将数据post给程序,程序入库。具体ping的话你可以添加上相关代码。
发表于 2008-12-21 11:23:03 | 显示全部楼层
9# rq204

我不懂数据库的代码。rq204,你能帮个忙加个在入库时自动ping的功能代码吗?这个功能实现后,就相当于模拟在线发布了。

先谢了。
您需要登录后才可以回帖 登录 | 加入会员

本版积分规则

温馨提示:建议您联系官方定制服务,通过官方支付方式完成支付。您与其他非官方账号发生的交易,我方概不承担责任。网络有风险,交易需谨慎

QQ| 手机版|Archiver| 火车采集器官方站

Copyright © 2001-2013 Comsenz Inc.  Template by Comeings! All Rights Reserved.

Powered by Discuz! X3.4( 皖ICP备06000549 )

快速回复 返回顶部 返回列表