|
此活动开展时间:3.8-3.15.依据 火车采集器"采集解决方案"计划
请大家针对wordpress提出您最想要的模块及说明.我会在这里每天整理相关数据的.
请大家推荐您使用正常的模块或是提交一下正确的模块需要改进的方面.谢谢合作!
备注:此为严肃帖,下边灌水或做其它无关事的朋友将得到扣分,禁言或删号的待遇.
下边的代码不全,有修改的地方可以自己添加上.-
- <?php
- include "./wp-config.php"; //这里是引用原来的数据库文件.
- $DB = new Mysql(DB_HOST, DB_USER, DB_PASSWORD,DB_NAME);//初始化数据库类
- if(isset($_GET['action'])&&$_GET['action'] == "list")
- {
- $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' ";
- $query=$DB->query($sql);
- while ($config=$DB->fetch_array($query))
- {
- echo '<<<'.$config['term_id'].'--'.$config['name'].'>>>';
- }
- }
- elseif(isset($_GET['action'])&&$_GET['action'] == "save")
- {
- extract($_POST);
- ($post_title=='[标签:标题]'||$post_title=='')?die('标题为空'):'';
- ($post_content=='[标签:内容]'||$post_content=='')?die('内容为空'):'';
- ($post_category=='[分类id]'||$post_category=='')?die('分类id为空'):'';
- if($tag=='[标签:SY_tag]'){$tag='';}
- $post_date=date("Y-m-d H:i:s");
- $tm=time();
- $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')";
- //die($sql);
- $query=$DB->query($sql);
- $postid=$DB->insert_id($sql);
- $sqledit="INSERT INTO `".$table_prefix."postmeta` (post_id ,meta_key ,meta_value ) VALUES ($postid,'_edit_lock','$tm'),($postid,'_edit_last',1)";
- $query2=$DB->query($sqledit);
- /*自定义字段处理方法
- if(!$image=='[标签:缩略]')
- {
- $sqledit2="INSERT INTO `".$table_prefix."postmeta` (post_id ,meta_key ,meta_value ) VALUES ($postid,'image','$image')";
- $qim=$DB->query($sqledit2);
- }
- */
- $sqlcid="INSERT INTO `".$table_prefix."term_relationships` (object_id ,term_taxonomy_id ) VALUES ($postid,'$post_category')";
- $cidquery=$DB->query($sqlcid);
- if(!$tag=='')
- {
- $tags= array_unique(explode(",",$tag));
- foreach($tags as $var)
- {
- $ssql="SELECT * from ".$table_prefix."terms where name='$var' ";
- $squery=$DB->fetch_one_array($ssql);
- if($squery)
- {
- $tagidss=$DB->fetch_one_array($ssql);
- $tagids=$tagidss['term_id'];
- $gettagid="SELECT term_taxonomy_id,term_id from ".$table_prefix."term_taxonomy where term_id='$tagids' ";
- $gettag=$DB->fetch_one_array($gettagid);
- $tagid=$gettag['term_taxonomy_id'];
- $sqltag="INSERT INTO `".$table_prefix."term_relationships` (object_id ,term_taxonomy_id ) VALUES ($postid,'$tagid')";
- $tagquery=$DB->query($sqltag);
- }else{
- $uc=urlencode($var);
- $addtag="INSERT INTO `".$table_prefix."terms` (name,slug) VALUES ('$var','$uc')";
- $addquery=$DB->query($addtag);
- $addtagid=$DB->insert_id($addtag);
- $addterm="INSERT INTO `".$table_prefix."term_taxonomy` (term_id,taxonomy) VALUES ('$addtagid','post_tag')";
- //echo $addtag.$addterm;
- $termquery=$DB->query($addterm);
- $tagids=$DB->insert_id($addterm);
- $sqltag="INSERT INTO `".$table_prefix."term_relationships` (object_id ,term_taxonomy_id ) VALUES ($postid,'$tagids')";
- $tagquery=$DB->query($sqltag);
- }
- }
- }
- //这里用来处理评论回复
- //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)
- echo '发布成功';
- }else{
- echo 'rq204告诉你,你没有选择任何的操作。请返回';
- }
- //下边是数据库类
- /**
- * 数据库操作类
- * @copyright (c) 2008, Emlog All Rights Reserved
- * @version emlog-2.7.0
- * $Id: C_mysql.php 590 2008-07-31 02:12:36Z emloog $
- */
- class MySql {
- var $queryCount = 0;
- var $conn;
- var $result;
- function MySql($dbHost = '', $dbUser = '', $dbPass = '', $dbName = '')
- {
- if(!$this->conn = @mysql_connect($dbHost, $dbUser, $dbPass))
- {
- die("连接数据库失败,可能是mysql数据库用户名或密码错误");
- }
- if($this->getMysqlVersion() >'4.1')
- {
- mysql_query("SET NAMES 'utf8'");
- }
- @mysql_select_db($dbName, $this->conn) OR die("未找到指定数据库");
- }
- /**
- * 关闭数据库连接
- *
- * @return boolean
- */
- function close()
- {
- return mysql_close($this->conn);
- }
- /**
- * 发送查询语句
- *
- * @param string $sql
- * @return boolean
- */
- function query($sql)
- {
- $this->result = @ mysql_query($sql,$this->conn);
- $this->queryCount++;
- if(!$this->result)
- {
- die("SQL语句执行错误:$sql <br />".$this->geterror());
- } else {
- return $this->result;
- }
- }
- /**
- * 从结果集中取得一行作为关联数组,或数字数组
- *
- * @param resource $query
- * @return array
- */
- function fetch_array($query)
- {
- return mysql_fetch_array($query);
- }
- /**
- * 取得结果集中一条记录
- *
- * @param resource $query
- * @return integer
- */
- function fetch_row($query)
- {
- return mysql_fetch_row($query);
- }
- /**
- * 取得行的数目
- *
- * @param resource $query
- * @return integer
- */
- function num_rows($query)
- {
- return mysql_num_rows($query);
- }
- /**
- * 取得结果集中字段的数目
- *
- * @param resource $query
- * @return integer
- */
- function num_fields($query)
- {
- return mysql_num_fields($query);
- }
- /**
- * 取得上一步 INSERT 操作产生的 ID
- *
- * @return integer
- */
- function insert_id()
- {
- return mysql_insert_id($this->conn);
- }
- function fetch_one_array($sql)
- {
- $this->result = $this->query($sql);
- return $this->fetch_array($this->result);
- }
- /**
- * 获取mysql错误
- *
- * @return unknown
- */
- function geterror()
- {
- return mysql_error();
- }
- /**
- * 取得数据库版本信息
- *
- * @return string
- */
- function getMysqlVersion()
- {
- return mysql_get_server_info();
- }
- /**
- * 返回显系统错误信息
- *
- * @param unknown_type $info
- */
- }
- ?>
复制代码 |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?加入会员
x
|