pastebin - collaborative debugging

pastebin is a collaborative debugging tool allowing you to share and modify code snippets while chatting on IRC, IM or a message board.

This site is developed to XHTML and CSS2 W3C standards. If you see this paragraph, your browser does not support those standards and you need to upgrade. Visit WaSP for a variety of options.

PHP pastebin - collaborative debugging tool View Help


Posted by Crio on Mon 8 Jun 19:03
report abuse | download | new post

  1. <?php
  2.         class vbox7{
  3.                 public $url = null;
  4.                 public $code = null;
  5.                 public  $title = null;
  6.                 public  $thumbnail = null;
  7.                 public  $flvUrl = null;
  8.                 public  $subtitles = null;
  9.                 public  $subtitlesExtension = 'srt';
  10.                 public function __construct($url, $subs = 'srt'){
  11.                         if(preg_match("/.*play:([a-fA-F0-9]{8})/",$url, $match)){
  12.                                 $this->url = $match[0];
  13.                                 $this->code = $match[1];
  14.                                
  15.                                 $src = file_get_contents($this->url);
  16.                                 if(preg_match("/<title>(.*) \/ Vbox7<\/title>/", $src, $found)){
  17.                                         $this->title = $found[1];
  18.                                 }
  19.                                
  20.                                 $src = file_get_contents("http://www.vbox7.com/etc/ext.do?key=".$this->code);
  21.                                 if(preg_match("/&flv_addr=(.*?)&jpg_addr=(.*?)&subsEnabled=(?:true&subsData=)?(.*?)$/", $src, $parts)){
  22.                                         $this->flvUrl = "http://".$parts[1];
  23.                                         $this->thumbnail = "http://".$parts[2];
  24.                                         if($parts[3]){
  25.                                                 if($subs == 'srt'){
  26.                                                         $subs = new SRTFile(json_decode($parts[3]));
  27.                                                 }else{
  28.                                                         $subs = new SUBFile(json_decode($parts[3]));
  29.                                                         $this->subtitlesExtension = 'sub';
  30.                                                 }
  31.                                                 $this->subtitles = $subs->parse();
  32.                                         }
  33.                                 }
  34.                         }else{
  35.                                 throw new Exception("&#1053;&#1077;&#1074;&#1072;&#1083;&#1080;&#1076;&#1077;&#1085; &#1083;&#1080;&#1085;&#1082;");
  36.                         }
  37.                 }
  38.         }
  39.         /**
  40.          * SRT File Class
  41.          *      1\r\n
  42.          *  00:00:04,680 --> 00:00:08,500\r\n
  43.          *  &#1050;&#1086;&#1081; &#1076;&#1072;&#1076;&#1077; &#1080;&#1076;&#1077;&#1103;&#1090;&#1072;?\r\n
  44.          *  - &#1058;&#1080;.\r\n
  45.          *  \r\n
  46.          *
  47.          */
  48.         class SRTFile{
  49.                 private $source = null;
  50.                 public function __construct($src){
  51.                         if($src)
  52.                                 $this->source = $src;
  53.                 }
  54.                
  55.                 public function parse(){
  56.                         $number = 1;
  57.                         $return = "";
  58.                         for($i=0; $i<sizeof($this->source);$i++){
  59.                                 $return .= ($i+1) . "\r\n";
  60.                                 $return .= $this->formatTime($this->source[$i]->f) . " --> " . $this->formatTime($this->source[$i]->t) . "\r\n";
  61.                                 $return .= $this->source[$i]->s . "\r\n";
  62.                                 $return .= "\r\n";
  63.                         }
  64.                         return $return;
  65.                 }
  66.                 private function leadingNull($number){
  67.                         if($number < 10) return "0".$number;
  68.                         return $number;
  69.                 }
  70.                
  71.                 private function formatTime($seconds){
  72.                         $hours = $this->leadingNull((int)($seconds/360));
  73.                         $minutes =$this->leadingNull((int)($seconds/60));
  74.                         $seconds = $this->leadingNull($seconds - (((int)($seconds/360))*360 + ((int)($seconds/60))*60));
  75.                         return $hours.":".$minutes.":".$seconds.",000";
  76.                 }
  77.         }
  78.        
  79.         /**
  80.          * SUB File Class
  81.          * {from*fps}{to*fps}Content(nl as |)\r\n
  82.          *
  83.          */
  84.         class SUBFile{
  85.                 private $source = NULL;
  86.                 public function __construct($src){
  87.                         if($src)
  88.                                 $this->source = $src;
  89.                 }
  90.                
  91.                 public function parse($fps = 30){
  92.                         //&#1057;&#1074;&#1072;&#1083;&#1080;&#1093; 2-3 &#1082;&#1083;&#1080;&#1087;&#1072; &#1086;&#1090; vbox7 &#1080; &#1074;&#1089;&#1080;&#1095;&#1082;&#1080;&#1090;&#1077; &#1073;&#1103;&#1093;&#1072; &#1089; FPS 30.0 &#1090;&#1072;&#1082;&#1072;, &#1095;&#1077; &#1075;&#1086; &#1086;&#1089;&#1090;&#1072;&#1074;&#1103;&#1084; &#1090;&#1072;&#1082;&#1072; &#1087;&#1086; &#1087;&#1086;&#1076;&#1088;&#1072;&#1079;&#1073;&#1080;&#1088;&#1072;&#1085;&#1077;.
  93.                         $return = "";
  94.                         for($i=0; $i<sizeof($this->source);$i++){
  95.                                 $return .= "{". $fps * $this->source[$i]->f ."}{" . $fps * $this->source[$i]->t . "}" . $this->newLineFix($this->source[$i]->s) . "\r\n";
  96.                         }
  97.                         return $return;
  98.                 }
  99.                
  100.                 public function newLineFix($string){
  101.                         $nl = array("\r\n", "\r", "\n");
  102.                         return str_replace($nl, "|", $string);
  103.                 }
  104.         }
  105. ?>

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with @@


Remember me so that I can delete my post