Guest User

Untitled

a guest
Dec 5th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. <?php
  2.  
  3.  
  4. $rpcurl = $_POST[&#039;wp_url&#039;];
  5. $username = $_POST[&#039;wp_username&#039;];
  6. $password = $_POST[&#039;wp_password&#039;];
  7. $title = $_POST[&#039;post_title&#039;];
  8. $body = $_POST[&#039;post&#039;];
  9. $cat = $_POST[&#039;cat_name&#039;];
  10. $sub_cat= $_POST[&#039;sub_cat_name&#039;];
  11.  
  12. if ($sub_cat == NULL)
  13. {
  14. $category = array(
  15. "$cat"
  16. );
  17. }
  18. else
  19. {
  20. $category = array(
  21. "$cat",
  22. "$sub_cat"
  23. );
  24. }
  25.  
  26.  
  27.  
  28.  
  29.  
  30. $keywords = $_POST[&#039;post_tags&#039;];
  31.  
  32.  
  33.  
  34. function wpPostXMLRPC($title,$body,$rpcurl,$username,$password,$category,$keywords,$encoding="UTF-8")
  35. {
  36.  
  37. $title = htmlentities($title,ENT_NOQUOTES,$encoding);
  38. $keywords = htmlentities($keywords,ENT_NOQUOTES,$encoding);
  39.  
  40. $content = array(
  41. "title"=>$title,
  42. "description" =>$body,
  43. "mt_allow_comments"=>1,
  44. "mt_allow_pings"=>1,
  45. "post_type"=>"post",
  46. "mt_keywords"=>$keywords,
  47. "categories"=> $category
  48.  
  49. );
  50. $params = array(0,$username,$password,$content,true);
  51. $request = xmlrpc_encode_request("metaWeblog.newPost",$params);
  52. $ch = curl_init();
  53. curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
  54. curl_setopt($ch, CURLOPT_URL, $rpcurl);
  55. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  56. curl_setopt($ch, CURLOPT_TIMEOUT, 1);
  57. $results = curl_exec($ch);
  58. curl_close($ch);
  59. return $results;
  60. }
  61.  
  62. echo wpPostXMLRPC($title,$body,$rpcurl,$username,$password,$category,$keywords);
  63. ?>
Add Comment
Please, Sign In to add comment