Пример #1
0
 public function index()
 {
     $CRs = new CR($this->db);
     $Actus = new Actu($this->db);
     $Streams = new Stream($this->db);
     $this->f3->set('actus', $Actus->all(10));
     $this->f3->set('streams', $Streams->find(NULL, array('order' => 'twitch_username ASC')));
     $this->f3->set('crs', $CRs->all(10));
     $this->f3->set('site_title', 'Un torrent d\'informations — thetartuffebay.org');
     $this->f3->set('page_head', 'Le premier site d\'information des tartuffes :o');
     $this->f3->set('view', 'home.htm');
 }
Пример #2
0
    if (isset($_GET['stop'])) {
        stop_stream($_GET['stop']);
        $message['type'] = "success";
        $message['message'] = "stream stopped";
    }
}
if (isset($_GET['delete'])) {
    $stream = Stream::find($_GET['delete']);
    $stream->delete();
    $message['type'] = "success";
    $message['message'] = "Stream deleted";
}
if (isset($_POST['mass_delete'])) {
    if (isset($_POST['mselect'])) {
        foreach ($_POST['mselect'] as $streamids) {
            $stream = Stream::find($streamids);
            $stream->delete();
        }
    }
    $message['type'] = "success";
    $message['message'] = "Streams deleted";
}
if (isset($_POST['mass_start'])) {
    if (isset($_POST['mselect'])) {
        foreach ($_POST['mselect'] as $streamids) {
            start_stream($streamids);
        }
    }
    $message['type'] = "success";
    $message['message'] = "Streams started";
}
Пример #3
0
function start_stream($id)
{
    $stream = Stream::find($id);
    $setting = Setting::first();
    if ($stream->restream) {
        $stream->checker = 0;
        $stream->pid = null;
        $stream->running = 1;
        $stream->status = 1;
    } else {
        $stream->checker = 0;
        $checkstreamurl = shell_exec('' . $setting->ffprobe_path . ' -analyzeduration 1000000 -probesize 9000000 -i "' . $stream->streamurl . '" -v  quiet -print_format json -show_streams 2>&1');
        $streaminfo = json_decode($checkstreamurl, true);
        if ($streaminfo) {
            $pid = shell_exec(getTranscode($stream->id));
            $stream->pid = $pid;
            $stream->running = 1;
            $stream->status = 1;
            $video = "";
            $audio = "";
            if (is_array($streaminfo)) {
                foreach ($streaminfo['streams'] as $info) {
                    if ($video == '') {
                        $video = $info['codec_type'] == 'video' ? $info['codec_name'] : '';
                    }
                    if ($audio == '') {
                        $audio = $info['codec_type'] == 'audio' ? $info['codec_name'] : '';
                    }
                }
                $stream->video_codec_name = $video;
                $stream->audio_codec_name = $audio;
            }
        } else {
            $stream->running = 1;
            $stream->status = 2;
            //TODO: need to make recursive
            if (checkPid($stream->pid)) {
                shell_exec("kill -9 " . $stream->pid);
                shell_exec("/bin/rm -r /home/fos-streaming/fos/www/" . $setting->hlsfolder . "/" . $stream->id . "*");
            }
            if ($stream->streamurl2) {
                $stream->checker = 2;
                $checkstreamurl = shell_exec('' . $setting->ffprobe_path . ' -analyzeduration 1000000 -probesize 9000000 -i "' . $stream->streamurl . '" -v  quiet -print_format json -show_streams 2>&1');
                $streaminfo = json_decode($checkstreamurl, true);
                if ($streaminfo) {
                    $pid = shell_exec(getTranscode($stream->id, 2));
                    $stream->pid = $pid;
                    $stream->running = 1;
                    $stream->status = 1;
                    $video = "";
                    $audio = "";
                    if (is_array($streaminfo)) {
                        foreach ($streaminfo['streams'] as $info) {
                            if ($video == '') {
                                $video = $info['codec_type'] == 'video' ? $info['codec_name'] : '';
                            }
                            if ($audio == '') {
                                $audio = $info['codec_type'] == 'audio' ? $info['codec_name'] : '';
                            }
                        }
                        $stream->video_codec_name = $video;
                        $stream->audio_codec_name = $audio;
                    }
                } else {
                    $stream->running = 1;
                    $stream->status = 2;
                    if (checkPid($stream->pid)) {
                        shell_exec("kill -9 " . $stream->pid);
                        shell_exec("/bin/rm -r /home/fos-streaming/fos/www/" . $setting->hlsfolder . "/" . $stream->id . "*");
                    }
                    //streamurl 3 checker
                    if ($stream->streamurl3) {
                        $stream->checker = 3;
                        $checkstreamurl = shell_exec('' . $setting->ffprobe_path . ' -analyzeduration 1000000 -probesize 9000000 -i "' . $stream->streamurl . '" -v  quiet -print_format json -show_streams 2>&1');
                        $streaminfo = json_decode($checkstreamurl, true);
                        if ($streaminfo) {
                            $pid = shell_exec(getTranscode($stream->id, 3));
                            $stream->pid = $pid;
                            $stream->running = 1;
                            $stream->status = 1;
                            $video = "";
                            $audio = "";
                            if (is_array($streaminfo)) {
                                foreach ($streaminfo['streams'] as $info) {
                                    if ($video == '') {
                                        $video = $info['codec_type'] == 'video' ? $info['codec_name'] : '';
                                    }
                                    if ($audio == '') {
                                        $audio = $info['codec_type'] == 'audio' ? $info['codec_name'] : '';
                                    }
                                }
                                $stream->video_codec_name = $video;
                                $stream->audio_codec_name = $audio;
                            }
                        } else {
                            $stream->running = 1;
                            $stream->status = 2;
                            $stream->pid = null;
                        }
                    }
                }
            }
        }
    }
    $stream->save();
}
Пример #4
0
    $error = "Username or Password is invalid";
    header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found');
    header('Status: 404 Not Found');
    die;
}
$user = User::where('username', '=', $username)->where('password', '=', $password)->where('active', '=', 1)->first();
if (!isset($_SESSION['user_id'])) {
    // TODO: secret key
    $token = !$user ? die : uniqid();
}
if ($user->exp_date != "0000-00-00") {
    if ($user->exp_date <= Carbon::today()) {
        die;
    }
}
$stream = Stream::find($id);
if (!isset($_SESSION['user_id'])) {
    !$stream ? die : "";
}
$stream->status != 1 ? die : "";
ob_end_clean();
ob_start();
ignore_user_abort(true);
$user->lastconnected_ip = $ip;
$user->last_stream = $stream->id;
$user->useragent = $_SERVER['HTTP_USER_AGENT'];
$user->save();
$url = $stream->streamurl;
if ($stream->checker == 2) {
    $url = $stream->streamurl2;
}
Пример #5
0
<?php

include 'config.php';
logincheck();
$setting = Setting::first();
$stream = Stream::find($_GET['id']);
$streamurl = $setting->hlsfolder . "/" . $stream->id . "_.m3u8";
echo $template->view()->make('play')->with('streamurl', $streamurl)->render();
Пример #6
0
 public function index()
 {
     $Streams = new Stream($this->db);
     $this->f3->set('streams', $Streams->find(NULL, array('order' => 'twitch_username ASC')));
     $this->f3->set('view', 'stream/list.htm');
 }
Пример #7
0
function start_stream($id)
{
    $stream = Stream::find($id);
    $setting = Setting::first();
    $stream->checker = 0;
    $checkstreamurl = shell_exec('/usr/bin/timeout 15s ' . $setting->ffprobe_path . ' -analyzeduration 10000000 -probesize 9000000 -i "' . $stream->streamurl . '" -v  quiet -print_format json -show_streams 2>&1');
    $streaminfo = (array) json_decode($checkstreamurl);
    if (count($streaminfo) > 0) {
        $pid = shell_exec(getTranscode($stream->id));
        $stream->pid = $pid;
        $stream->running = 1;
        $stream->status = 1;
        if (isset($streaminfo->streams)) {
            foreach ((array) $streaminfo->streams as $info) {
                if ($info->codec_type == 'video') {
                    $stream->video_codec_name = $info->codec_long_name;
                } else {
                    if ($info->codec_type == 'audio') {
                        $stream->audio_codec_name = $info->codec_long_name;
                    }
                }
            }
        }
    } else {
        $stream->running = 1;
        $stream->status = 2;
        //need to make recursive
        ////streamurl 2 checker
        shell_exec("kill -9 " . $stream->pid);
        shell_exec("/bin/rm -r /usr/local/nginx/html/" . $setting->hlsfolder . "/" . $stream->id . "*");
        if ($stream->streamurl2) {
            $stream->checker = 2;
            echo "checking stream 2";
            $checkstreamurl = shell_exec('/usr/bin/timeout 15s ' . $setting->ffprobe_path . ' -analyzeduration 10000000 -probesize 9000000 -i "' . $stream->streamurl2 . '" -v  quiet -print_format json -show_streams 2>&1');
            $streaminfo = (array) json_decode($checkstreamurl);
            if (count($streaminfo) > 0) {
                echo getTranscode($stream->id, 2);
                $pid = shell_exec(getTranscode($stream->id, 2));
                $stream->pid = $pid;
                $stream->running = 1;
                $stream->status = 1;
                if (isset($streaminfo->streams)) {
                    foreach ((array) $streaminfo->streams as $info) {
                        if ($info->codec_type == 'video') {
                            $stream->video_codec_name = $info->codec_long_name;
                        } else {
                            if ($info->codec_type == 'audio') {
                                $stream->audio_codec_name = $info->codec_long_name;
                            }
                        }
                    }
                }
            } else {
                $stream->running = 1;
                $stream->status = 2;
                shell_exec("kill -9 " . $stream->pid);
                shell_exec("/bin/rm -r /usr/local/nginx/html/" . $setting->hlsfolder . "/" . $stream->id . "*");
                //streamurl 3 checker
                if ($stream->streamurl3) {
                    $stream->checker = 3;
                    $checkstreamurl = shell_exec('/usr/bin/timeout 15s ' . $setting->ffprobe_path . ' -analyzeduration 10000000 -probesize 9000000 -i "' . $stream->streamurl3 . '" -v  quiet -print_format json -show_streams 2>&1');
                    $streaminfo = (array) json_decode($checkstreamurl);
                    if (count($streaminfo) > 0) {
                        $pid = shell_exec(getTranscode($stream->id, 3));
                        $stream->pid = $pid;
                        $stream->running = 1;
                        $stream->status = 1;
                        if (isset($streaminfo->streams)) {
                            foreach ((array) $streaminfo->streams as $info) {
                                if ($info->codec_type == 'video') {
                                    $stream->video_codec_name = $info->codec_long_name;
                                } else {
                                    if ($info->codec_type == 'audio') {
                                        $stream->audio_codec_name = $info->codec_long_name;
                                    }
                                }
                            }
                        }
                    } else {
                        $stream->running = 1;
                        $stream->status = 2;
                        $stream->pid = null;
                    }
                }
            }
        }
    }
    $stream->save();
}