Advertisement
Guest User

common.php

a guest
Oct 31st, 2014
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 27.69 KB | None | 0 0
  1. <?php
  2. if (!defined('DIR_APP'))
  3.     die('Access denied');
  4.  
  5. class Common {
  6.  
  7.     //encrypt
  8.     public static function encrypt($x, $key = PRIVATE_KEY) {
  9.         $x .=$key;
  10.         $s = '';
  11.         foreach (str_split($x) as $c)
  12.             $s.=sprintf("%02X", ord($c));
  13.         return($s);
  14.     }
  15.  
  16.     //decrypt
  17.     public static function decrypt($x, $key = PRIVATE_KEY) {
  18.         $x .=$key;
  19.         $s = '';
  20.         foreach (explode("\n", trim(chunk_split($x, 2))) as $h)
  21.             $s.=chr(hexdec($h));
  22.         return(substr($s, 0, -3));
  23.     }
  24.  
  25.     //== check number type int
  26.     function checkInt($int) {
  27.         $ktra = is_numeric($int);
  28.         if ($ktra == 0)
  29.             return 0;
  30.         else if ($ktra == 1) {
  31.             if ($int < 0)
  32.                 return 0;
  33.             else if ($int > 9999)
  34.                 return 0;
  35.             else
  36.                 return 1;
  37.         }
  38.     }
  39.  
  40.     //====substring
  41.     function cutString($strorg, $limit) {
  42.         if (strlen($strorg) <= $limit) {
  43.             return $strorg;
  44.         } else {
  45.             if (strpos($strorg, " ", $limit) > $limit) {
  46.                 $new_limit = strpos($strorg, " ", $limit);
  47.                 $new_strorg = substr($strorg, 0, $new_limit) . "...";
  48.                 return $new_strorg;
  49.             }
  50.             $new_strorg = substr($strorg, 0, $limit) . "...";
  51.             return $new_strorg;
  52.         }
  53.     }
  54.  
  55.     //=====alert & redirect
  56.     function aRedirect($strUrl = "", $msg) {
  57.         ?>
  58.         <script language="javascript">
  59.         <?php if ($msg != "") { ?>
  60.                 alert('<?php echo $msg ?>');
  61.         <?php } ?>
  62.             window.location.href='<?php echo $strUrl ?>';
  63.         </script>
  64.         <?php
  65.     }
  66.  
  67.     //generate string number
  68.     function rand_str($length = 8, $chars = '0123456789') {
  69.         // Length of character list
  70.  
  71.         $chars_length = (strlen($chars) - 1);
  72.         // Start our string
  73.         $string = $chars{rand(0, $chars_length)};
  74.         // Generate random string
  75.         for ($i = 1; $i < $length; $i = strlen($string)) {
  76.             // Grab a random character from our list
  77.             $r = $chars{rand(0, $chars_length)};
  78.             // Make sure the same two characters don't appear next to each other
  79.             if ($r != $string{$i - 1})
  80.                 $string .= $r;
  81.         }
  82.         // Return the string
  83.         return $string;
  84.     }
  85.  
  86.     //download file name
  87.  
  88.     function download_file($filename, $name) {
  89.         $file_extension = strtolower(substr(strrchr($filename, "."), 1));
  90.         switch ($file_extension) {
  91.             case "pdf": $ctype = "application/pdf";
  92.                 break;
  93.             case "exe": $ctype = "application/octet-stream";
  94.                 break;
  95.             case "zip": $ctype = "application/zip";
  96.                 break;
  97.             case "doc": $ctype = "application/msword";
  98.                 break;
  99.             case "xls": $ctype = "application/vnd.ms-excel";
  100.                 break;
  101.             case "ppt": $ctype = "application/vnd.ms-powerpoint";
  102.                 break;
  103.             case "gif": $ctype = "image/gif";
  104.                 break;
  105.             case "png": $ctype = "image/png";
  106.                 break;
  107.             case "jpeg":
  108.             case "jpg": $ctype = "image/jpg";
  109.                 break;
  110.             default: $ctype = "application/force-download";
  111.         }
  112.  
  113.         header("Pragma: public");
  114.         header("Expires: 0");
  115.         header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  116.         header("Cache-Control: private", false);
  117.         header("Content-Type: $ctype");
  118.         header("Content-Disposition: attachment; filename=\"" . basename($name . '.' . $file_extension) . "\";");
  119.         header("Content-Transfer-Encoding: binary");
  120.         header("Content-Length: " . filesize($filename));
  121.         ob_end_clean();
  122.         readfile("$filename");
  123.         exit();
  124.     }
  125.  
  126.     //format number
  127.  
  128.     function formatNumber($number, $ext = " VNĐ") {
  129.         $strResult = "";
  130.         if ($ext == "")
  131.             $strResult = number_format($number, 0, ',', '.') . " VNĐ";
  132.         else
  133.             $strResult = number_format($number, 0, ',', '.') . $ext;
  134.         return $strResult;
  135.     }
  136.  
  137.     //get next/prev week
  138.  
  139.     function getNextPrevWeek($today, $type = '+') {
  140.         $week = strtotime(date("Y-m-d", strtotime($today)) . " " . $type . "1 week");
  141.         $week = strftime("%Y-%m-%d", $week);
  142.         return $week;
  143.     }
  144.  
  145.     //get next/prev month
  146.  
  147.     function getNextPrevMonth($today, $type = '+') {
  148.         $month = strtotime(date("Y-m-d", strtotime($today)) . " " . $type . "1 month");
  149.         $month = strftime("%Y-%m-%d", $month);
  150.         return $month;
  151.     }
  152.  
  153.     /*
  154.  
  155.      * @author Vu Tran <tmvu.it@gmail.com>
  156.      *
  157.      * @param string $date - Date to be converted
  158.      * @param string $func - which function is to be used (1 for input to mysql, 2 for output from mysql)
  159.      * @local string $local - local format
  160.      */
  161.  
  162.     function dateconvert($date, $func, $local) {
  163.         if ($func == 1) { //insert conversion
  164.             if (strlen($date) > 10)
  165.                 $date = substr($date, 0, 10);
  166.             if ($local == 'en')
  167.                 list($month, $day, $year) = split('[/.-]', $date);
  168.             else
  169.                 list($day, $month, $year) = split('[/.-]', $date);
  170.             $date = "$year-$month-$day";
  171.             return $date;
  172.         }
  173.  
  174.         if ($func == 2) { //output conversion
  175.             if (strlen($date) > 10)
  176.                 $date = substr($date, 0, 10);
  177.             list($year, $month, $day) = split('[-.]', $date);
  178.             if ($local == 'en')
  179.                 $date = "$month/$day/$year";
  180.             else
  181.                 $date = "$day/$month/$year";
  182.             if ($day == '00' || $day == '')
  183.                 return "";
  184.             else
  185.                 return $date;
  186.         }
  187.     }
  188.  
  189.     //addition date
  190.  
  191.     function dateAdd($date, $month) {
  192.         $date = new DateTime($date);
  193.         $interval = new DateInterval('P' . $month . 'M');
  194.         $date->add($interval);
  195.         return $date->format('Y-m-d');
  196.     }
  197.  
  198.     //format currenccy
  199.  
  200.     function formatCurrencyMysql($str) {
  201.         if (strpos($str, '$') === false) {
  202.             $str = $str;
  203.         } else {
  204.             $str = str_replace('$', '', $str);
  205.         }
  206.         return $str;
  207.     }
  208.  
  209.     //get date
  210.  
  211.     function _getDate($date, $type = 'vn') {
  212.         $arrDate = explode(' ', $date);
  213.         $arrDateOut = explode('-', $arrDate[0]);
  214.         $theDay = "";
  215.         if ($type == 'vn') {
  216.             if ($arrDateOut[2] == '00') {
  217.                 $theDay = $arrDateOut[1] . '/' . $arrDateOut[0];
  218.             } else {
  219.                 $theDay = $arrDateOut[2] . '/' . $arrDateOut[1] . '/' . $arrDateOut[0];
  220.             }
  221.         } else {
  222.             $theDay = $arrDateOut[1] . '/' . $arrDateOut[2] . '/' . $arrDateOut[0];
  223.         }
  224.         return $theDay;
  225.     }
  226.  
  227.     function loadVideo_V2($containerVideo, $flashDiv, $w, $h, $url, $suburl, $rtmpHost = '', $httpHost = '', $appName = '', $fileName = '', $quanlity = '', $trailer = '', $nextEpisode = '', $isPlay = "false") {
  228.  
  229.         $detect = new Mobile_Detect;
  230.         $deviceType = ($detect->isMobile() ? ($detect->isTablet() ? 'tablet' : 'phone') : 'computer');
  231.  
  232.         if ($deviceType != "computer") {
  233.             $iosUrl = "http://$httpHost/$appName/mp4:$fileName.720p/playlist.m3u8";
  234.             ?>
  235.             <video width="<?php echo $w ?>px" height="<?php echo $h ?>px" controls="controls" preload="auto">
  236.                 <source src="<?php echo $iosUrl ?>" type="video/mp4"/>
  237.             </video>
  238.             <?php
  239.         } else {
  240.             $rtmpHost = "rtmp://$rtmpHost/$appName";
  241.            
  242.             if ($quanlity == "FullHD" || $quanlity == "FullHD-HD") {
  243.                 $rtmpFile['1080p'] = ",mp4:" . trim($fileName) . '.1080p';
  244.             } else {
  245.                 $rtmpFile['1080p'] = "";
  246.             }
  247.  
  248.             if ($quanlity == "SD" || $quanlity == "TS" || $quanlity == "SDHD") {
  249.                 $rtmpFile['360p'] = ",mp4:" . trim($fileName) . '.360p';
  250.             } else {
  251.                 $rtmpFile['360p'] = "";
  252.             }
  253.  
  254.             if ($quanlity == "HD" || $quanlity == "SDHD" || $quanlity == "FullHD-HD") {
  255.                 $rtmpFile['720p'] = ",mp4:" . trim($fileName) . '.720p';
  256.             } else {
  257.                 $rtmpFile['720p'] = "";
  258.             }
  259.  
  260.             if ($quanlity == "clip") {
  261.                 $rtmpFile['480p'] = ",mp4:" . trim($fileName) . '.480p';
  262.             } else {
  263.                 $rtmpFile['480p'] = "";
  264.             }
  265.  
  266.             if($_GET['p']=="livetv") $isLive="isLive=true";else $isLive="isLive=false";
  267.  
  268.             $mediaPath = "mediaPathUrl=$rtmpHost{$rtmpFile['360p']}{$rtmpFile['480p']}{$rtmpFile['720p']}{$rtmpFile['1080p']}";
  269.            
  270.             $s = "mediafilm" . (strlen($url) + 6);
  271.             ?>  
  272.  
  273.             <object width="<?php echo $w ?>" height="<?php echo $h ?>" type="application/x-shockwave-flash" id="smartplayer" data="player/smartplayer.swf?v=2508" style="background:#000">
  274.                 <param name="menu" value="false">  
  275.                 <param name="movie" value="player/smartplayer.swf?v=2508" />
  276.                 <param name="scale" value="default">  
  277.                 <param name="allowFullscreen" value="true">    
  278.                 <param name="allowScriptAccess" value="always">    
  279.                 <param name="salign" value="tl">
  280.                 <param name="wmode" value="transparent" />    
  281.                 <param name="bgcolor" value="#000000">    
  282.                 <param name="flashvars" value="configUrl=player/config.xml&amp;logoImage=player/resources/images/non_logo.png&amp;playerWidth=<?php echo $w ?>&amp;playerHeight=<?php echo $h ?>&amp;secureTokenUrl=<?php echo BASE_NAME ?>player/config.sub&amp;introXmlUrl=<?php echo $url ?>&amp;s=<?php echo $s ?>&amp;subUrl=<?php echo $suburl == "" ? "," : $suburl ?>&amp;trailerPathUrl=<?php echo $trailer ?>&amp;nextUrl=<?php echo $nextEpisode ?>&amp;autoPlay=<?php echo $isPlay; ?>&amp;isSingleFilm=<?php echo $nextEpisode != "" ? "false" : "true" ?>&amp;isFullScreen=1&amp;uid=&amp;version=2508&amp;<?php echo $isLive; ?>&amp;<?php echo $mediaPath ?>">
  283.             </object>  
  284.             <?php
  285.         }
  286.     }
  287.    
  288.     /* function loadVideo_admin($containerVideo, $flashDiv, $w, $h, $url, $suburl, $rtmpHost = '', $httpHost = '', $appName = '', $fileName = '', $quanlity = '', $trailer = '', $nextEpisode = '', $isPlay = "false") {
  289.  
  290.         $detect = new Mobile_Detect;
  291.         $deviceType = ($detect->isMobile() ? ($detect->isTablet() ? 'tablet' : 'phone') : 'computer');
  292.  
  293.         if ($deviceType != "computer") {
  294.             $iosUrl = "http://$httpHost/$appName/mp4:$fileName.720p/playlist.m3u8";
  295.             ?>
  296.             <video width="<?php echo $w ?>px" height="<?php echo $h ?>px" controls="controls" preload="auto">
  297.                 <source src="<?php echo $iosUrl ?>" type="video/mp4"/>
  298.             </video>
  299.             <?php
  300.         } else {
  301.             $rtmpHost = "rtmp://$rtmpHost/$appName";
  302.            
  303.             if ($quanlity == "FullHD" || $quanlity == "FullHD-HD") {
  304.                 $rtmpFile['1080p'] = ",mp4:" . trim($fileName) . '.1080p';
  305.             } else {
  306.                 $rtmpFile['1080p'] = "";
  307.             }
  308.  
  309.             if ($quanlity == "SD" || $quanlity == "TS" || $quanlity == "SDHD") {
  310.                 $rtmpFile['360p'] = ",mp4:" . trim($fileName) . '.360p';
  311.             } else {
  312.                 $rtmpFile['360p'] = "";
  313.             }
  314.  
  315.             if ($quanlity == "HD" || $quanlity == "SDHD" || $quanlity == "FullHD-HD") {
  316.                 $rtmpFile['720p'] = ",mp4:" . trim($fileName) . '.720p';
  317.             } else {
  318.                 $rtmpFile['720p'] = "";
  319.             }
  320.  
  321.             if ($quanlity == "clip") {
  322.                 $rtmpFile['480p'] = ",mp4:" . trim($fileName) . '.480p';
  323.             } else {
  324.                 $rtmpFile['480p'] = "";
  325.             }
  326.  
  327.             $isLive="isLive=true";
  328.  
  329.             $mediaPath = "mediaPathUrl=$rtmpHost{$rtmpFile['360p']}{$rtmpFile['480p']}{$rtmpFile['720p']}{$rtmpFile['1080p']}";
  330.             ?>  
  331.  
  332.             <object width="<?php echo $w ?>" height="<?php echo $h ?>" type="application/x-shockwave-flash" id="smartplayer" data="adcp/player/smartplayer.swf?v=1908" style="background:#000">
  333.                 <param name="menu" value="false">  
  334.                 <param name="movie" value="adcp/player/smartplayer.swf?v=1908" />
  335.                 <param name="scale" value="default">  
  336.                 <param name="allowFullscreen" value="true">    
  337.                 <param name="allowScriptAccess" value="always">    
  338.                 <param name="salign" value="tl">
  339.                 <param name="wmode" value="transparent" />    
  340.                 <param name="bgcolor" value="#000000">    
  341.                 <param name="flashvars" value="configUrl=adcp/player/config.xml&amp;logoImage=adcp/player/resources/images/non_logo.png&amp;playerWidth=<?php echo $w ?>&amp;playerHeight=<?php echo $h ?>&amp;introXmlUrl=<?php echo $url ?>&amp;subUrl=<?php echo $suburl == "" ? "," : $suburl ?>&amp;trailerPathUrl=<?php echo $trailer ?>&amp;nextUrl=<?php echo $nextEpisode ?>&amp;autoPlay=true&amp;isFullScreen=1&amp;uid=&amp;version=2008&amp;<?php echo $isLive; ?>&amp;<?php echo $mediaPath ?>">
  342.             </object>  
  343.             <?php
  344.         }
  345.     }*/
  346.    
  347.      function loadVideo_admin($containerVideo, $flashDiv, $w, $h, $url, $suburl, $rtmpHost = '', $httpHost = '', $appName = '', $fileName = '', $quanlity = '', $trailer = '', $nextEpisode = '', $isPlay = "false") {
  348.  
  349.         $detect = new Mobile_Detect;
  350.         $deviceType = ($detect->isMobile() ? ($detect->isTablet() ? 'tablet' : 'phone') : 'computer');
  351.  
  352.         if ($deviceType != "computer") {
  353.             $iosUrl = "http://$httpHost/$appName/mp4:$fileName.720p/playlist.m3u8";
  354.             ?>
  355.             <video width="<?php echo $w ?>px" height="<?php echo $h ?>px" controls="controls" preload="auto">
  356.                 <source src="<?php echo $iosUrl ?>" type="video/mp4"/>
  357.             </video>
  358.             <?php
  359.         } else {
  360.             $rtmpHost = "rtmp://$rtmpHost/$appName";
  361.            
  362.             if ($quanlity == "FullHD" || $quanlity == "FullHD-HD") {
  363.                 $rtmpFile['1080p'] = ",mp4:" . trim($fileName) . '.1080p';
  364.             } else {
  365.                 $rtmpFile['1080p'] = "";
  366.             }
  367.  
  368.             if ($quanlity == "SD" || $quanlity == "TS" || $quanlity == "SDHD") {
  369.                 $rtmpFile['360p'] = ",mp4:" . trim($fileName) . '.360p';
  370.             } else {
  371.                 $rtmpFile['360p'] = "";
  372.             }
  373.  
  374.             if ($quanlity == "HD" || $quanlity == "SDHD" || $quanlity == "FullHD-HD") {
  375.                 $rtmpFile['720p'] = ",mp4:" . trim($fileName) . '.720p';
  376.             } else {
  377.                 $rtmpFile['720p'] = "";
  378.             }
  379.  
  380.             if ($quanlity == "clip") {
  381.                 $rtmpFile['480p'] = ",mp4:" . trim($fileName) . '.480p';
  382.             } else {
  383.                 $rtmpFile['480p'] = "";
  384.             }
  385.  
  386.             if($_GET['p']=="livetv") $isLive="isLive=true";else $isLive="isLive=false";
  387.  
  388.             $mediaPath = "mediaPathUrl=$rtmpHost{$rtmpFile['360p']}{$rtmpFile['480p']}{$rtmpFile['720p']}{$rtmpFile['1080p']}";
  389.             ?>  
  390.  
  391.             <object width="<?php echo $w ?>" height="<?php echo $h ?>" type="application/x-shockwave-flash" id="smartplayer" data="adcp/player/smartplayer.swf?v=2907" style="background:#000">
  392.                 <param name="menu" value="false">  
  393.                 <param name="movie" value="adcp/player/smartplayer.swf?v=2907" />
  394.                 <param name="scale" value="default">  
  395.                 <param name="allowFullscreen" value="true">    
  396.                 <param name="allowScriptAccess" value="always">    
  397.                 <param name="salign" value="tl">
  398.                 <param name="wmode" value="transparent" />    
  399.                 <param name="bgcolor" value="#000000">    
  400.                 <param name="flashvars" value="configUrl=adcp/player/config.xml&amp;logoImage=adcp/player/resources/images/non_logo.png&amp;playerWidth=<?php echo $w ?>&amp;playerHeight=<?php echo $h ?>&amp;secureTokenUrl=<?php echo BASE_NAME ?>adcp/player/config.sub&amp;introXmlUrl=<?php echo $url ?>&amp;s=&amp;subUrl=<?php echo $suburl == "" ? "," : $suburl ?>&amp;trailerPathUrl=<?php echo $trailer ?>&amp;nextUrl=<?php echo $nextEpisode ?>&amp;autoPlay=<?php echo $isPlay; ?>&amp;isFullScreen=1&amp;uid=&amp;version=2907&amp;<?php echo $isLive; ?>&amp;<?php echo $mediaPath ?>">
  401.             </object>  
  402.             <?php
  403.         }
  404.     }
  405.    
  406.    
  407.     function loadVideo_V2_small($containerVideo, $flashDiv, $w, $h, $url, $suburl, $rtmpHost = '', $httpHost = '', $appName = '', $fileName = '', $quanlity = '', $trailer = '', $nextEpisode = '', $isPlay = "false") {
  408.  
  409.         $detect = new Mobile_Detect;
  410.         $deviceType = ($detect->isMobile() ? ($detect->isTablet() ? 'tablet' : 'phone') : 'computer');
  411.  
  412.         if ($deviceType != "computer") {
  413.             $iosUrl = "http://$httpHost/$appName/mp4:$fileName.720p/playlist.m3u8";
  414.             ?>
  415.             <video width="<?php echo $w ?>px" height="<?php echo $h ?>px" controls="controls" preload="auto">
  416.                 <source src="<?php echo $iosUrl ?>" type="video/mp4"/>
  417.             </video>
  418.             <?php
  419.         } else {
  420.             $rtmpHost = "rtmp://$rtmpHost/$appName";
  421.            
  422.             if ($quanlity == "FullHD" || $quanlity == "FullHD-HD") {
  423.                 $rtmpFile['1080p'] = ",mp4:" . trim($fileName) . '.1080p';
  424.             } else {
  425.                 $rtmpFile['1080p'] = "";
  426.             }
  427.  
  428.             if ($quanlity == "SD" || $quanlity == "TS" || $quanlity == "SDHD") {
  429.                 $rtmpFile['360p'] = ",mp4:" . trim($fileName) . '.360p';
  430.             } else {
  431.                 $rtmpFile['360p'] = "";
  432.             }
  433.  
  434.             if ($quanlity == "HD" || $quanlity == "SDHD" || $quanlity == "FullHD-HD") {
  435.                 $rtmpFile['720p'] = ",mp4:" . trim($fileName) . '.720p';
  436.             } else {
  437.                 $rtmpFile['720p'] = "";
  438.             }
  439.  
  440.             if ($quanlity == "clip") {
  441.                 $rtmpFile['480p'] = ",mp4:" . trim($fileName) . '.480p';
  442.             } else {
  443.                 $rtmpFile['480p'] = "";
  444.             }
  445.            
  446.             if($_GET['p']=="livetv") $isLive="isLive=true";else $isLive="isLive=false";
  447.             $mediaPath = "mediaPathUrl=$rtmpHost{$rtmpFile['360p']}{$rtmpFile['480p']}{$rtmpFile['720p']}{$rtmpFile['1080p']}";
  448.             ?>  
  449.  
  450.             <object width="<?php echo $w ?>" height="<?php echo $h ?>" type="application/x-shockwave-flash" id="smartplayer" data="player_small/smartplayer.swf?v=1808" style="background:#000">
  451.                 <param name="menu" value="false">  
  452.                 <param name="movie" value="player_small/smartplayer.swf?v=1808" />
  453.                 <param name="scale" value="default">  
  454.                 <param name="allowFullscreen" value="true">    
  455.                 <param name="allowScriptAccess" value="always">    
  456.                 <param name="salign" value="tl">
  457.                 <param name="wmode" value="transparent" />    
  458.                 <param name="bgcolor" value="#000000">    
  459.                 <param name="flashvars" value="configUrl=player_small/config.xml&amp;logoImage=player_small/resources/images/non_logo.png&amp;playerWidth=<?php echo $w ?>&amp;playerHeight=<?php echo $h ?>&amp;introXmlUrl=<?php echo $url ?>&amp;subUrl=<?php echo $suburl == "" ? "," : $suburl ?>&amp;trailerPathUrl=<?php echo $trailer ?>&amp;nextUrl=<?php echo $nextEpisode ?>&amp;autoPlay=<?php echo $isPlay; ?>&amp;isFullScreen=1&amp;uid=&amp;version=1808&amp;<?php echo $isLive; ?>&amp;<?php echo $mediaPath ?>">
  460.             </object>  
  461.             <?php
  462.         }
  463.     }
  464.  
  465.     //indicator
  466.     function getIndicator() {
  467.         global $mod;
  468.         require 'nusoap/nusoap.php';
  469.         require 'wsdl/ws_function.php';
  470.         $rs = ws_indicator();
  471.  
  472.         if (stripos($rs, "Error") !== false) {
  473.             $filename = "indicator_IP.txt";
  474.             if (is_writable($filename)) {
  475.                 if (!$handle = fopen($filename, 'a')) {
  476.                     echo "Cannot open file ($filename)";
  477.                     exit;
  478.                 }
  479.                 if (fwrite($handle, $_SERVER['REMOTE_ADDR'] . " ($rs) (" . date('d-m-Y H:i:s', time()) . ")\n") === FALSE) {
  480.                     echo "Cannot write to file ($filename)";
  481.                     exit;
  482.                 }
  483.                 fclose($handle);
  484.             } else {
  485.                 echo "The file $filename is not writable";
  486.                 exit;
  487.             }
  488.             header("Location:" . BASE_NAME . "redirect/");
  489.         }
  490.         else
  491.             return $rs;
  492.     }
  493.  
  494.     //indicator
  495.     function getIndicator_service($del = null) {
  496.         global $mod, $cache_time;
  497.        
  498.         $test = $_SERVER['REMOTE_ADDR'];
  499.         $t = explode(", ", $test);
  500.         if (!empty($t[1])) {
  501.             $remote_add = $t[1];
  502.         } else {
  503.             $remote_add = $_SERVER['REMOTE_ADDR'];
  504.         }        
  505.         $indicator = Cache::get('i_' . $remote_add);
  506.         //$indicator = FALSE;
  507.         if ($indicator === FALSE) {
  508.             require_once('nusoap/nusoap.php');
  509.             $wsdl = "http://indicator.hayhaytv.vn/API/indicator_api_mem.php?wsdl";
  510.             $client = new nusoap_client($wsdl, 'wsdl');
  511.             if ($del == "deletecache") {
  512.                 $param = array($remote_add, "deletecache");
  513.                 $val = $client->call('GetLink', $param);
  514.                 $mod->redirect("index.php");
  515.             } else {
  516.                 $param = array($remote_add, "wsencrypt");
  517.             }
  518.             $val = $client->call('GetLink', $param);
  519.             $indicator = $val;
  520.             Cache::set('i_' . $remote_add, $val, TRUE, $cache_time['level_05']);
  521.         }
  522.         return $indicator;
  523.     }
  524.  
  525.     //indicator
  526.     function getIndicatorVIP_service($del = null) {
  527.         global $mod, $cache_time;
  528.  
  529.         $test = $_SERVER['REMOTE_ADDR'];
  530.         $t = explode(", ", $test);
  531.         if (!empty($t[1])) {
  532.             $remote_add = $t[1];
  533.         } else {
  534.             $remote_add = $_SERVER['REMOTE_ADDR'];
  535.         }
  536.         $indicator = Cache::get('i_vip_' . $remote_add);
  537.         //$indicator = FALSE;
  538.         if ($indicator === FALSE) {
  539.             require_once('nusoap/nusoap.php');
  540.             $wsdl = "http://indicator.hayhaytv.vn/API/indicator_api_mem_vip.php?wsdl";
  541.             $client = new nusoap_client($wsdl, 'wsdl');
  542.             if ($del == "deletecache") {
  543.                 $param = array($remote_add, "deletecache");
  544.                 $val = $client->call('GetLink', $param);
  545.                 $mod->redirect("index.php");
  546.             } else {
  547.                 $param = array($remote_add, "wsencrypt");
  548.             }
  549.             $val = $client->call('GetLink', $param);
  550.  
  551.             $indicator = $val;
  552.             Cache::set('i_vip_' . $remote_add, $val, TRUE, $cache_time['level_05']);
  553.         }
  554.         return $indicator;
  555.     }
  556.  
  557.     //indicator
  558.     function getIndicator_allow_ip($del = null) {
  559.         global $mod, $cache_time;
  560.        
  561.         $test = $_SERVER['REMOTE_ADDR'];
  562.         $t = explode(", ", $test);
  563.         if (!empty($t[1])) {
  564.             $remote_add = $t[1];
  565.         } else {
  566.             $remote_add = $_SERVER['REMOTE_ADDR'];
  567.         }        
  568.        
  569.         $indicator = Cache::get('i_deny_' . $remote_add);
  570.         //$indicator = FALSE;
  571.         if ($indicator === FALSE) {
  572.             require_once('nusoap/nusoap.php');
  573.             $wsdl = "http://indicator.hayhaytv.vn/API/indicator_allow_ip.php?wsdl";
  574.             $client = new nusoap_client($wsdl, 'wsdl');
  575.            
  576.             $param = array($remote_add, "wsencrypt");
  577.            
  578.             $val = $client->call('GetLink', $param);
  579.             $indicator = $val;
  580.             if($val == "0" || $val == "1"){
  581.                 Cache::set('i_deny_' . $remote_add, $val, TRUE, $cache_time['level_05']);
  582.             }            
  583.         }
  584.         return $indicator;
  585.     }
  586.  
  587.     //indicator
  588.     function getBalance_service($uid) {
  589.         global $mod, $cache_time;
  590.  
  591.         $paramMT['UserID'] = $uid;
  592.         $paramMT['token_key'] = TOKEN_PAYMENT;
  593.  
  594.         require_once('nusoap/nusoap.php');
  595.         $wsdl = 'http://billing.hayhaytv.vn/charge/hayhaytv_api.php?wsdl';
  596.         $client = new nusoap_client($wsdl, 'wsdl');
  597.         $rs = $client->call('MOGetBalanceID', $paramMT);
  598.         unset($client);
  599.         return $rs;
  600.     }
  601.  
  602.     function loadVideo_V3($containerVideo, $flashDiv, $w, $h, $url, $subs, $rtmpHost = '', $httpHost = '', $appName = '', $fileName = '', $quanlity = '', $trailer = '', $nextEpisode = '', $isPlay = "false") {
  603.         $rtmpHost = "rtmp://$rtmpHost/$appName/";
  604.            
  605.         if ($quanlity == "FullHD" || $quanlity == "FullHD-HD") {
  606.             $rtmpFile['1080p'] = trim($fileName) . '.1080p.mp4';
  607.         } else {
  608.             $rtmpFile['1080p'] = "";
  609.         }
  610.  
  611.         if ($quanlity == "SD" || $quanlity == "TS" || $quanlity == "SDHD") {
  612.             $rtmpFile['360p'] = trim($fileName) . '.360p.mp4';
  613.         } else {
  614.             $rtmpFile['360p'] = "";
  615.         }
  616.  
  617.         if ($quanlity == "HD" || $quanlity == "SDHD" || $quanlity == "FullHD-HD") {
  618.             $rtmpFile['720p'] = trim($fileName) . '.720p.mp4';
  619.         } else {
  620.             $rtmpFile['720p'] = "";
  621.         }
  622.  
  623.         if ($quanlity == "clip") {
  624.             $rtmpFile['480p'] = trim($fileName) . '.480p.mp4';
  625.         } else {
  626.             $rtmpFile['480p'] = "";
  627.         }
  628.  
  629.         if($_GET['p']=="livetv") $isLive="isLive=true";else $isLive="isLive=false";
  630.  
  631.         $mediaPath = "$rtmpHost{$rtmpFile['360p']}{$rtmpFile['480p']}{$rtmpFile['720p']}{$rtmpFile['1080p']}";
  632.        
  633.         if(strpos($trailer, ',mp4:') !== FASLE){
  634.             $trailer = str_replace(',mp4:', '/', $trailer) . ".mp4";
  635.         }
  636.  
  637.         ?>  
  638.         <script type="text/javascript">
  639.         var initVideoUrl = "<?php echo $mediaPath?>";  // Link chính thức của video
  640.         var initTrailerUrl = '<?php echo $trailer?>';
  641.         var adsXMLUrl = "<?php echo $url?>?t=<?php echo time()?>";
  642.         // var adsXMLUrl = "http://live.hayhaytv.vn/new_player/ads.xml";
  643.         var imageSrc = "";//background image cho player
  644.         var videoSubs = [
  645.                 <?php if ($subs):
  646.                     $default = TRUE;
  647.                     foreach ($subs as $lang => $sub_file) :
  648.                     if(!empty($sub_file)) :
  649.                         if(!$default)
  650.                             echo ',';
  651.                 ?>
  652.                 {
  653.                     file: "<?php echo $sub_file?>",
  654.                     label: "<?php echo $lang?>",
  655.                     kind: "captions",
  656.                     encoded: "<?php echo  substr($sub_file, -3) == 'srt' ? 'false' : 'true' ?>",
  657.                     "default": <?php echo $default ? 'true' : 'false'?>
  658.                 }
  659.                 <?php
  660.                         $default = !$default;
  661.                     endif;
  662.                     endforeach;
  663.                 endif;
  664.                 ?>
  665.                 ];
  666.        
  667.         var defaultObj = {duration: -1
  668.                         , position: 0
  669.                         , buffered: 0
  670.                         , fileSrc: ""
  671.                         , imageSrc: ""                      
  672.                         , userId : "-1"    //  User ID
  673.                         , isError: false
  674.                         , volume: 100
  675.                         , playerWidth: 960
  676.                         , playerHeight: 482
  677.                         };
  678.        
  679.         var playerInfo = defaultObj;
  680.         var ready = false;
  681.     </script>
  682.         <?php
  683.            
  684.     }
  685.  
  686. }
  687. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement