Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $response = array();
- require_once __DIR__ . '/db_connect.php';
- require_once __DIR__ . '/db_config.php';
- echo '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />';
- $db = new DB_CONNECT();
- mysql_query('SET CHARACTER SET utf8') ;
- $cateid = isset($_GET['cateid'])?$_GET['cateid']:'0';
- if ($cateid == 0 ) {
- $sql = "SELECT cateid,pageid,pagename,pagecontent FROM detailstory";
- } else {
- $sql = "SELECT cateid,pageid,pagename,pagecontent FROM detailstory where `cateid` = '$cateid'";
- }
- $result = mysql_query($sql) or die(mysql_error());
- class XMLRPClientWordPress
- {
- var $XMLRPCURL;
- var $UserName;
- var $PassWord;
- // constructor
- public function __construct($xmlrpcurl, $username, $password)
- {
- $this->XMLRPCURL = $xmlrpcurl;
- $this->UserName = $username;
- $this->PassWord = $password;
- }
- function send_request($requestname, $params)
- {
- //$request = xmlrpc_encode_request($requestname, $params);
- $request = xmlrpc_encode_request('metaWeblog.newPost',$params,array('encoding'=>'UTF-8','escaping'=>'markup'));
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
- curl_setopt($ch, CURLOPT_URL, $this->XMLRPCURL);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_TIMEOUT, 1);
- $results = curl_exec($ch);
- curl_close($ch);
- return $results;
- }
- function create_post($title,$body,$category,$keywords='',$encoding='UTF-8')
- {
- $title = htmlentities($title,ENT_NOQUOTES,$encoding);
- $keywords = htmlentities($keywords,ENT_NOQUOTES,$encoding);
- $content = array(
- 'title'=>'Nguyễn Văn Thiệu có dấu mà 123',
- 'description'=>$body,
- 'mt_allow_comments'=>0, // 1 to allow comments
- 'mt_allow_pings'=>0, // 1 to allow trackbacks
- 'post_type'=>'truyen',
- 'mt_keywords'=>$keywords,
- 'categories'=>array($category)
- );
- $params = array(0,$this->UserName,$this->PassWord,$content,false);
- return $this->send_request('metaWeblog.newPost',$params);
- }
- function create_post_football($title,$body,$category,$introtext,$imageFull,$thumbnail,$linksource,
- $linkserver,$linkyoutube,$linkdropbox,$matchtime,$ishot,$keywords='',$encoding='UTF-8')
- {
- $title = htmlentities($title,ENT_NOQUOTES,$encoding);
- $keywords = htmlentities($keywords,ENT_NOQUOTES,$encoding);
- $content = array(
- 'title'=>$title,
- 'description'=>$body,
- 'mt_allow_comments'=>1, // 1 to allow comments
- 'mt_allow_pings'=>1, // 1 to allow trackbacks
- 'post_type'=>'clip',
- 'mt_keywords'=>$keywords,
- "custom_fields" => array(
- array( 'key' => 'introtext', 'value' => $introtext ),
- array( 'key' => '_introtext', 'value' => 'field_52f1e887ee97f'),
- array( 'key' => 'imageFull', 'value' => $imageFull ),
- array( 'key' => '_imageFull', 'value' => 'field_52f1e887ef089'),
- array( 'key' => 'thumbnail', 'value' => $thumbnail ),
- array( 'key' => '_thumbnail', 'value' => 'field_52f1e887ef759'),
- array( 'key' => 'linksource', 'value' => $linksource ),
- array( 'key' => '_linksource', 'value' => 'field_52f1e88803f57'),
- array( 'key' => 'linkserver', 'value' => $linkserver ),
- array( 'key' => '_linkserver', 'value' => 'field_52f1e88804684'),
- array( 'key' => 'linkyoutube', 'value' => $linkyoutube ),
- array( 'key' => '_linkyoutube', 'value' => 'field_52f1e88804d93'),
- array( 'key' => 'linkdropbox', 'value' => $linkdropbox ),
- array( 'key' => '_linkdropbox', 'value' => 'field_52f1e888054e4'),
- array( 'key' => 'matchtime', 'value' => $matchtime ),
- array( 'key' => '_matchtime', 'value' => 'field_52f1e88805c33'),
- array( 'key' => 'ishot', 'value' => $ishot ),
- array( 'key' => '_ishot', 'value' => 'field_52f1e888063a4'),
- ),
- 'categories'=>array($category)
- );
- $params = array(0,$this->UserName,$this->PassWord,$content,true);
- return $this->send_request('metaWeblog.newPost',$params);
- }
- function create_page($title,$body,$encoding='UTF-8')
- {
- $title = htmlentities($title,ENT_NOQUOTES,$encoding);
- $content = array(
- 'title'=>$title,
- 'description'=>$body
- );
- $params = array(0,$this->UserName,$this->PassWord,$content,true);
- return $this->send_request('wp.newPage',$params);
- }
- function display_authors()
- {
- $params = array(0,$this->UserName,$this->PassWord);
- return $this->send_request('wp.getAuthors',$params);
- }
- function sayHello()
- {
- $params = array();
- return $this->send_request('demo.sayHello',$params);
- }
- }
- function convertEncoding($str, $from = 'auto', $to = "UTF-8") {
- if($from == 'auto') $from = mb_detect_encoding($str);
- return mb_convert_encoding ($str , $to, $from);
- }
- $objXMLRPClientWordPress = new XMLRPClientWordPress(XMLRFC_LINK , XMLRFC_USER , XMLRFC_PASS);
- $dem = 0;
- if (mysql_num_rows($result) > 0) {
- $response["detailstory"] = array();
- while ($row = mysql_fetch_array($result)) {
- $dem++;
- $detailstory = array();
- $detailstory["cateid"] = $row["cateid"];
- $detailstory["pageid"] = $row["pageid"];
- $detailstory["pagename"] = $row["pagename"];
- $detailstory["pagecontent"] = $row["pagecontent"];
- echo $dem . ' - ' . $row["pagename"] . "<br>";
- if ($dem == 1329 ){
- //$tieude = convertEncoding($row["pagename"]);
- //$tieude = $row["pagename"];
- $tieude = "Nguyễn Văn Thiệu 2";
- $noidung = $row["pagecontent"];
- $chuyenmuc = "";
- $objXMLRPClientWordPress->create_post($tieude, $noidung, $chuyenmuc);
- echo "<br><br>_________<br><br>";
- echo $tieude;
- echo "<br>";
- echo $noidung;
- echo "<br><br>_________<br><br>";
- }
- array_push($response["detailstory"], $detailstory);
- }
- //echo json_encode($response);
- } else {
- $response["success"] = 0;
- $response["message"] = "No products found";
- echo json_encode($response);
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment