thieumao

xxxxautopost.php

Feb 20th, 2014
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.73 KB | None | 0 0
  1. <?php
  2.  
  3. // Ham xu ly thoi gian
  4. function format_date($input){
  5.     //$input    = "20140215";
  6.     $nam    = substr($input,0,4);
  7.     $thang  = substr($input,-4,2);
  8.     $ngay   = substr($input,-2,2);
  9.     $output = $ngay . "/" . $thang . "/" . $nam;
  10.     return $output;
  11. }
  12.  
  13. // Ham lay ID chuyen muc
  14. function getIDChuyenMuc($ten){
  15.     $input = $ten;
  16.     $output = 1;
  17.     if ($input == "germany/bundesliga-highlights") {
  18.         //$output = 4;
  19.         $output = "Bundesliga";
  20.     }
  21.     if ($input == "spain/la-liga-highlights") {
  22.         //$output = 3;
  23.         $output = "La Liga";
  24.     }
  25.     if ($input == "france/ligue-1-highlights") {
  26.         //$output = 6;
  27.         $output = "Ligue 1";
  28.     }
  29.     if ($input == "england/premier-league-highlights") {
  30.         //$output = 2;
  31.         $output = "Premier League";
  32.     }
  33.     if ($input == "italy/serie-a-highlights") {
  34.         //$output = 5;
  35.         $output = "Serie A";
  36.     }
  37.     if ($input == "europe/uefa-champions-league-highlights") {
  38.         //$output = 9;
  39.         $output = "UEFA Champion League";
  40.     }
  41.     if ($input == "europe/uefa-europa-league-highlights") {
  42.         //$output = 10;
  43.         $output = "UEFA Europa League";
  44.     }
  45.     return $output;
  46. }
  47.  
  48.  
  49. // Truyen tham so vao
  50. require '/var/www/9football.net/wp-config.php';
  51. $conn = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD) or die("Can't connect this database");
  52. mysql_select_db(DB_DATABASE, $conn);
  53. $sql    = "SELECT * FROM ourmatch WHERE bookmark=0 ORDER BY thoigian ASC";
  54. $result = mysql_query($sql);
  55.  
  56. include("xxxxClassGetIDPhoto.php");
  57. include('xxxxClassXMLRPClientWordPress.php');
  58. $objXMLRPClientWordPress = new XMLRPClientWordPress("http://9football.net/xmlrpc.php" , "thieumao" , "12345678a@");
  59.  
  60. if ($result) {
  61.     // select thanh cong
  62.  
  63.     while ($row = mysql_fetch_array($result)) {
  64.        
  65.         $pid = $row["pid"];
  66.         $title = $row["ten"];
  67.         $body = "";
  68.         //$category = $row["chuyenmuc"];
  69.         $category = getIDChuyenMuc($row["chuyenmuc"]);
  70.         echo "----------> " . $category;
  71.         $introtext = "";
  72.         $imageFull = $row["anhserver"];
  73.         //$thumbnail = $imageFull;
  74.         $linksource = $row["video1"];
  75.         $linkserver = "";
  76.         $linkyoutube= "";
  77.         $linkdropbox = "";
  78.         //$matchtime = $row["thoigian"];
  79.         $matchtime = format_date($row["thoigian"]);
  80.         $ishot = "";
  81.        
  82.         // Copy va Lay ID hinh anh vao wordpress
  83.         $layid = new xxxxClassGetIDPhoto($imageFull);
  84.         $idhinhanh = $layid->getIdanh();
  85.            
  86.         echo $row["pid"];
  87.         echo $row["ten"];
  88.         $objXMLRPClientWordPress->create_post_football($title, $body, $category, $introtext, $idhinhanh, $idhinhanh, $linksource, $linkserver, $linkyoutube, $linkdropbox, $matchtime, $ishot);
  89.         $i++;
  90.         echo "Thanh cong $i <br>";
  91.  
  92.         $sqlupdate = "UPDATE ourmatch SET bookmark=1 WHERE pid=$pid";
  93.         mysql_query($sqlupdate);
  94.     }
  95.     if ($i<1){
  96.         echo "<br>Khong them bai viet nao do khong co bai viet moi<br>";
  97.     }
  98. } else {
  99.     echo "Sai cau lenh SQL";
  100. }
  101. ?>
Advertisement
Add Comment
Please, Sign In to add comment