找回密码

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

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

WordPress 火车采集器采集解决方案

[复制链接]
发表于 2009-3-8 15:56:27 | 显示全部楼层 |阅读模式
此活动开展时间:3.8-3.15.依据 火车采集器"采集解决方案"计划
请大家针对wordpress提出您最想要的模块及说明.我会在这里每天整理相关数据的.
请大家推荐您使用正常的模块或是提交一下正确的模块需要改进的方面.谢谢合作!


备注:此为严肃帖,下边灌水或做其它无关事的朋友将得到扣分,禁言或删号的待遇.
下边的代码不全,有修改的地方可以自己添加上.

  1. <?php
  2. include "./wp-config.php"; //这里是引用原来的数据库文件.
  3. $DB = new Mysql(DB_HOST, DB_USER, DB_PASSWORD,DB_NAME);//初始化数据库类
  4. if(isset($_GET['action'])&&$_GET['action'] == "list")
  5. {
  6. $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' ";
  7. $query=$DB->query($sql);
  8. while ($config=$DB->fetch_array($query))
  9. {
  10. echo '<<<'.$config['term_id'].'--'.$config['name'].'>>>';
  11. }
  12. }
  13. elseif(isset($_GET['action'])&&$_GET['action'] == "save")
  14. {
  15. extract($_POST);
  16. ($post_title=='[标签:标题]'||$post_title=='')?die('标题为空'):'';
  17. ($post_content=='[标签:内容]'||$post_content=='')?die('内容为空'):'';
  18. ($post_category=='[分类id]'||$post_category=='')?die('分类id为空'):'';
  19. if($tag=='[标签:SY_tag]'){$tag='';}
  20. $post_date=date("Y-m-d H:i:s");
  21. $tm=time();
  22. $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')";
  23. //die($sql);
  24. $query=$DB->query($sql);
  25. $postid=$DB->insert_id($sql);
  26. $sqledit="INSERT INTO `".$table_prefix."postmeta` (post_id ,meta_key ,meta_value ) VALUES ($postid,'_edit_lock','$tm'),($postid,'_edit_last',1)";
  27. $query2=$DB->query($sqledit);
  28. /*自定义字段处理方法
  29. if(!$image=='[标签:缩略]')
  30.   {
  31.         $sqledit2="INSERT INTO `".$table_prefix."postmeta` (post_id ,meta_key ,meta_value ) VALUES ($postid,'image','$image')";
  32.   $qim=$DB->query($sqledit2);
  33.   }
  34.    */
  35.     $sqlcid="INSERT INTO `".$table_prefix."term_relationships` (object_id ,term_taxonomy_id ) VALUES ($postid,'$post_category')";
  36. $cidquery=$DB->query($sqlcid);
  37. if(!$tag=='')
  38.   {
  39.      $tags= array_unique(explode(",",$tag));
  40.   foreach($tags as $var)
  41.    {
  42.    $ssql="SELECT * from ".$table_prefix."terms where name='$var' ";
  43.    $squery=$DB->fetch_one_array($ssql);
  44.    if($squery)
  45.     {
  46.     $tagidss=$DB->fetch_one_array($ssql);
  47.     $tagids=$tagidss['term_id'];
  48.     $gettagid="SELECT term_taxonomy_id,term_id from ".$table_prefix."term_taxonomy where term_id='$tagids' ";
  49.     $gettag=$DB->fetch_one_array($gettagid);
  50.     $tagid=$gettag['term_taxonomy_id'];
  51.     $sqltag="INSERT INTO `".$table_prefix."term_relationships` (object_id ,term_taxonomy_id ) VALUES ($postid,'$tagid')";
  52.     $tagquery=$DB->query($sqltag);
  53.     }else{
  54.     $uc=urlencode($var);
  55.     $addtag="INSERT INTO `".$table_prefix."terms` (name,slug) VALUES ('$var','$uc')";
  56.     $addquery=$DB->query($addtag);
  57.     $addtagid=$DB->insert_id($addtag);
  58.     $addterm="INSERT INTO `".$table_prefix."term_taxonomy` (term_id,taxonomy) VALUES ('$addtagid','post_tag')";
  59.     //echo $addtag.$addterm;
  60.     $termquery=$DB->query($addterm);
  61.     $tagids=$DB->insert_id($addterm);
  62.     $sqltag="INSERT INTO `".$table_prefix."term_relationships` (object_id ,term_taxonomy_id ) VALUES ($postid,'$tagids')";
  63.     $tagquery=$DB->query($sqltag);
  64.     }
  65.    }
  66.   }
  67.   //这里用来处理评论回复
  68.   //INSERT INTO `wp_comments` (`comment_ID`, `comment_post_ID`, `comment_author`, `comment_author_email`, `comment_author_url`, `comment_author_IP`, `comment_date`, `comment_date_gmt`, `comment_content`, `comment_karma`, `comment_approved`, `comment_agent`, `comment_type`, `comment_parent`, `user_id`) VALUES(1, 1, '$replayer', '', '$rwebsite', '', '2009-03-15 12:30:07', '2009-03-15 12:30:07', '$replaycontent', 0, '1', '', '', 0, 0)
  69. echo '发布成功';
  70. }else{
  71. echo 'rq204告诉你,你没有选择任何的操作。请返回';
  72. }









  73. //下边是数据库类
  74. /**
  75. * 数据库操作类
  76. * @copyright (c) 2008, Emlog All Rights Reserved
  77. * @version emlog-2.7.0
  78. * $Id: C_mysql.php 590 2008-07-31 02:12:36Z emloog $
  79. */
  80. class MySql {
  81. var $queryCount = 0;
  82. var $conn;
  83. var $result;
  84. function MySql($dbHost = '', $dbUser = '', $dbPass = '', $dbName = '')
  85. {
  86.   if(!$this->conn = @mysql_connect($dbHost, $dbUser, $dbPass))
  87.   {
  88.    die("连接数据库失败,可能是mysql数据库用户名或密码错误");
  89.   }
  90.   if($this->getMysqlVersion() >'4.1')
  91.   {
  92.    mysql_query("SET NAMES 'utf8'");
  93.   }
  94.   @mysql_select_db($dbName, $this->conn) OR die("未找到指定数据库");
  95. }
  96. /**
  97.   * 关闭数据库连接
  98.   *
  99.   * @return boolean
  100.   */
  101. function close()
  102. {
  103.   return mysql_close($this->conn);
  104. }
  105. /**
  106.   * 发送查询语句
  107.   *
  108.   * @param string $sql
  109.   * @return boolean
  110.   */
  111. function query($sql)
  112. {
  113.   $this->result = @ mysql_query($sql,$this->conn);
  114.   $this->queryCount++;
  115.   if(!$this->result)
  116.   {
  117.    die("SQL语句执行错误:$sql <br />".$this->geterror());
  118.   } else {
  119.    return $this->result;
  120.   }
  121. }
  122. /**
  123.   * 从结果集中取得一行作为关联数组,或数字数组
  124.   *
  125.   * @param resource $query
  126.   * @return array
  127.   */
  128. function fetch_array($query)
  129. {
  130.   return mysql_fetch_array($query);
  131. }

  132. /**
  133.   * 取得结果集中一条记录
  134.   *
  135.   * @param resource $query
  136.   * @return integer
  137.   */
  138. function fetch_row($query)
  139. {
  140.   return mysql_fetch_row($query);
  141. }
  142. /**
  143.   * 取得行的数目
  144.   *
  145.   * @param resource $query
  146.   * @return integer
  147.   */
  148. function num_rows($query)
  149. {
  150.   return mysql_num_rows($query);
  151. }
  152. /**
  153.   * 取得结果集中字段的数目
  154.   *
  155.   * @param resource $query
  156.   * @return integer
  157.   */
  158. function num_fields($query)
  159. {
  160.   return mysql_num_fields($query);
  161. }
  162. /**
  163.   * 取得上一步 INSERT 操作产生的 ID
  164.   *
  165.   * @return integer
  166.   */
  167. function insert_id()
  168. {
  169.   return mysql_insert_id($this->conn);
  170. }


  171. function fetch_one_array($sql)
  172. {
  173.   $this->result = $this->query($sql);
  174.   return $this->fetch_array($this->result);
  175. }
  176. /**
  177.   * 获取mysql错误
  178.   *
  179.   * @return unknown
  180.   */
  181. function geterror()
  182. {
  183.   return mysql_error();
  184. }
  185. /**
  186.   * 取得数据库版本信息
  187.   *
  188.   * @return string
  189.   */
  190. function getMysqlVersion()
  191. {
  192.   return mysql_get_server_info();
  193. }
  194. /**
  195.   * 返回显系统错误信息
  196.   *
  197.   * @param unknown_type $info
  198. */
  199. }
  200. ?>
复制代码

本帖子中包含更多资源

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

x
发表于 2009-3-8 18:42:47 | 显示全部楼层
本帖最后由 kiss2008 于 2009-3-8 18:45 编辑

希望官方出个WP的评论模块。
具体要求的标签名称:
标题
内容
标签(Tags)
回复内容(多条评论内容,随机用户名、发布时间随机递增)

版本要求:支持WP中英文的2.65及以上。

先谢了。
发表于 2009-3-12 02:09:18 | 显示全部楼层
希望官方出个WP的2.7的发布模块和评论模块
发表于 2009-4-29 16:49:53 | 显示全部楼层
先做个记号。等到用的时候来下载
发表于 2009-9-20 04:28:49 | 显示全部楼层
太好了,又明白一些
发表于 2009-9-27 17:40:28 | 显示全部楼层
学习了很多  谢谢
发表于 2009-10-2 19:07:38 | 显示全部楼层
太好了。。就是现在看不懂~~
发表于 2009-10-10 00:57:56 | 显示全部楼层
学习中~~ 哈哈   !!!
发表于 2009-10-11 22:02:05 | 显示全部楼层
先做个记号。等到用的时候来下载
头像被屏蔽
发表于 2009-10-21 11:15:39 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
您需要登录后才可以回帖 登录 | 加入会员

本版积分规则

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

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

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

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

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