thieumao

xautopost.php

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