thieumao

autodownvideo.php

Feb 24th, 2014
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.59 KB | None | 0 0
  1. <?php
  2. // Ham xu ly thoi gian. VD: 20140212 -> 2014/02/12
  3. function format_date2($input){
  4.     //$input    = "20140215";
  5.     $nam    = substr($input,0,4);
  6.     $thang  = substr($input,-4,2);
  7.     $ngay   = substr($input,-2,2);
  8.     $output = $nam . "/" . $thang . "/" . $ngay;
  9.     return $output;
  10. }
  11.  
  12. // Ham lay chuoi cuoi. VD: spain/la-liga-highlights -> la-liga-highlights
  13. function getStrEnd($strInput){
  14.     if (strlen($strInput)<1){
  15.         return "null";
  16.     }
  17.     $mang = explode("/", $strInput);
  18.     if ( strlen($mang[count($mang)-1])<1 ){
  19.         return $mang[count($mang)-2];
  20.     } else {
  21.         return $mang[count($mang)-1];
  22.     }
  23. }
  24.  
  25. // Truyen tham so vao
  26. include "ClassDownload.php";
  27. require '/var/www/9football.net/wp-config.php';
  28. $conn = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD) or die("Can't connect this database");
  29. mysql_select_db(DB_DATABASE, $conn);
  30. $sql    = "SELECT * FROM ourmatch WHERE LENGTH(videoserver1)<5";
  31. $result = mysql_query($sql);
  32.  
  33. if ($result) {
  34.     // select thanh cong
  35.     while ($row = mysql_fetch_array($result)) {
  36.         $i++;
  37.         echo "<br><br><br>";
  38.         echo $i . " " . $row["ten"];
  39.         $downlink = $row["video1"];
  40.         $thumuc = format_date2($row["thoigian"]) . "/" . getStrEnd($row["chuyenmuc"]);
  41.         echo "<br>";
  42.         echo $thumuc;
  43.  
  44.         $down = new ClassDownload($downlink, $thumuc);
  45.         $linkserver = $down->getLinkdaup();
  46.         echo "<br>";
  47.         echo $linkserver;
  48.  
  49.         $pid = $row["pid"];
  50.         $sqlupdate = "UPDATE ourmatch SET videoserver1='$linkserver' WHERE pid='$pid'";
  51.         mysql_query($sqlupdate);
  52.        
  53.     }
  54.     if ($i<1){
  55.         echo "<br>Khong them bai viet nao do khong co bai viet moi<br>";
  56.     }
  57. } else {
  58.     echo "Sai cau lenh SQL";
  59. }
  60. ?>
Advertisement
Add Comment
Please, Sign In to add comment