|
这个我们是写了一个接口来实现,代码公开,可以自己随意修改。使用请看模块说明。
-
- <?php
- include "wp-config.php"; //这里是引用原来的数据库文件.
- include "mysql.class.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")
- {
- $post=$_POST;
- 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')";
- $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,'$cid')";
- $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);
- }
- }
- }
- echo '发布成功';
- }else{
- echo 'rq204告诉你,你没有选择任何的操作。请返回';
- }
- ?>
复制代码 |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?加入会员
x
|