Плейлисты
Пример настройки роутера для просмотра UDP потоков своего провайдера
Код: Выделить всё
<?php
set_time_limit (1);
error_reporting(0);
$OpenWebif = "192.168.7.102"; //Изменить на свой локальный ip адрес
$file_m3u = 'http://'.$OpenWebif.'/web/services.m3u?bRef=1:7:1:0:0:0:0:0:0:0:FROM%20BOUQUET%20"userbouquet.dbe00.tv"%20ORDER%20BY%20bouquet';
/*$file_m3u = 'http://'.$OpenWebif.'/web/services.m3u?bRef=1:7:1:0:0:0:0:0:0:0:FROM%20BOUQUET%20"userbouquet.dbe02.tv"%20ORDER%20BY%20bouquet';*/
$hevc = "0"; //0 - выключить преобразование в hevc/1 - включить преобразование в hevc
$var_page = $_SERVER['QUERY_STRING'];
$user_agent = $_SERVER['HTTP_USER_AGENT'];
$server_name = $_SERVER['SERVER_NAME'];
$server_http_host = $_SERVER['HTTP_HOST'];
$server_port = $_SERVER['SERVER_PORT'];
$server_addr = $_SERVER['SERVER_ADDR'];
$current_m3u = file_get_contents($file_m3u);
if ($hevc == "1"){$hevc_url = "?bitrate=1500000?width=720?height=480?vcodec=h265?aspectratio=2?interlaced=0";}
print '#EXTM3U url-tvg="http://teleguide.info/download/new3/xmltv.xml.gz" cache=1000 deinterlace=8 aspect-ratio=16:9 audio-track=ru tvg-shift=0 m3uautoload=1
#EXTVLCOPT--http-reconnect=true
';
$current_m3u_t = explode("#EXTINF", $current_m3u);
$i = -1;
foreach($current_m3u_t as $c){
$url_block = explode("#EXTINF", $c);
$url_block = $url_block[0];
$tvg_name = explode('tvg-name="', $url_block);
$tvg_name = explode("\"", $tvg_name[1]);
$tvg_name = $tvg_name[0];
$tvg_name = str_replace(" ","_",$tvg_name);
$tvg_id = explode('tvg-id="', $url_block);
$tvg_id = explode("\"", $tvg_id[1]);
$tvg_id = $tvg_id[0];
$tvg_logo = explode('tvg-logo="', $url_block);
$tvg_logo = explode("\"", $tvg_logo[1]);
$tvg_logo = $tvg_logo[0];
$tvg_chno = explode('tvg-chno="', $url_block);
$tvg_chno = explode("\"", $tvg_chno[1]);
$tvg_chno = $tvg_chno[0];
$chenal_name = explode(",", $url_block);
$chenal_name = explode("\n", $chenal_name[1]);
$chenal_name = $chenal_name[0];
$chenal_name = preg_replace("/ {2,}/"," ",$chenal_name);
$i++;
$tvglogo = "$tvg_id.png";
$tvglogo = str_replace(":","_",$tvglogo);
$tvglogo = str_replace("_.png",".png",$tvglogo);
/*$tvglogo = "http://$OpenWebif/images/$tvglogo";*/
$tvglogouri = "http://homerouter.cpe:88/i/$tvg_name.png";
if ($tvg_logo !== ""){$tvg_logos = "tvg-logo=\"$tvglogouri\"";}else{$tvg_logos = "";}
if ($tvg_name !== ""){$tvg_names = "tvg-name=\"$tvg_name\"";}else{$tvg_names = "";}
if ($tvg_chno !== ""){$tvg_chnos = "tvg-chno=\"$tvg_chno\"";}else{$tvg_chnos = "";}
if ($tvg_id !== ""){$tvg_ids = "tvg-id=\"$tvg_id\"";}else{$tvg_ids = "";}
$chenal_url = "http://$OpenWebif:8001/$tvg_id$hevc_url";
/*$EXTVLCOPT = "#EXTVLCOPT:http-user-agent=Dalvik\n#EXTVLCOPT:program=$tvg_chno\n";*/
if ($i!=0){$echo = "#EXTINF:-1 aspect-ratio=16:9 $tvg_chnos $tvg_ids $tvg_logos $tvg_names,$chenal_name\n$EXTVLCOPT$chenal_url\n";}
$echo = str_replace(" "," ", $echo);
$echo = str_replace(" ,",",", $echo);
echo $echo;
}
exit();
?>
Код: Выделить всё
opkg update
opkg upgrade
Код: Выделить всё
opkg install nginx
Код: Выделить всё
opkg install php7-fastcgi
opkg install php7-mod-curl
opkg install php7-mod-iconv
opkg install php7-mod-json
opkg install php7-mod-mbstring
opkg install php7-mod-session
opkg install php7-mod-simplexml
opkg install php7-mod-xml
opkg install php7-mod-zip
opkg install php7-mod-dom
#дополнительные пакеты
#opkg install php7-mod-pdo
#opkg install php7-mod-pdo-mysql
Код: Выделить всё
cat > "/opt/etc/nginx/nginx.conf" <<EOF
user nobody nobody;
worker_processes 1;
events {
worker_connections 64;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile off;
keepalive_timeout 65;
server {
listen 88;
server_name localhost;
charset utf-8;
location / {
root /opt/share/www;
index index.php index.html index.htm;
}
error_page 404 /404.html;
error_page 403 /403.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /opt/share/nginx/html;
}
location ~ \.php\$ {
root /opt/share/www;
fastcgi_pass unix:/opt/var/run/php-fcgi.sock;
fastcgi_index index.php;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
}
}
EOF
Код: Выделить всё
rm /opt/etc/nginx/fastcgi_params
cat > "/opt/etc/nginx/fastcgi_params" <<EOF
fastcgi_param QUERY_STRING \$query_string;
fastcgi_param REQUEST_METHOD \$request_method;
fastcgi_param CONTENT_TYPE \$content_type;
fastcgi_param CONTENT_LENGTH \$content_length;
fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
fastcgi_param SCRIPT_NAME \$fastcgi_script_name;
fastcgi_param REQUEST_URI \$request_uri;
fastcgi_param DOCUMENT_URI \$document_uri;
fastcgi_param DOCUMENT_ROOT \$document_root;
fastcgi_param SERVER_PROTOCOL \$server_protocol;
fastcgi_param REQUEST_SCHEME \$scheme;
fastcgi_param HTTPS \$https if_not_empty;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/\$nginx_version;
fastcgi_param REMOTE_ADDR \$remote_addr;
fastcgi_param REMOTE_PORT \$remote_port;
fastcgi_param SERVER_ADDR \$server_addr;
fastcgi_param SERVER_PORT \$server_port;
fastcgi_param SERVER_NAME \$server_name;
fastcgi_param REDIRECT_STATUS 200;
EOF
Код: Выделить всё
rm /opt/etc/init.d/S79php-fcgi
cat > "/opt/etc/init.d/S79php-fcgi" <<EOF
#!/bin/sh
export PHP_FCGI_CHILDREN=''
ENABLED=yes
PROCS=php-fcgi
ARGS="-b /opt/var/run/php-fcgi.sock &"
PREARGS=""
DESC=\$PROCS
PATH=/opt/bin:/opt/sbin:/opt/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
. /opt/etc/init.d/rc.func
EOF
chmod +x /opt/etc/init.d/S79php-fcgi
Код: Выделить всё
cat > "/opt/etc/php.ini" <<EOF
[PHP]
zend.ze1_compatibility_mode = Off
engine = On
precision = 12
y2k_compliance = On
output_buffering = Off
zlib.output_compression = Off
implicit_flush = Off
unserialize_callback_func =
serialize_precision = 100
disable_functions =
disable_classes =
expose_php = On
max_execution_time = 30
max_input_time = 30
memory_limit = 4M
error_reporting = E_ALL & ~E_NOTICE & ~E_STRICT
display_errors = On
display_startup_errors = Off
log_errors = Off
log_errors_max_len = 512
ignore_repeated_errors = Off
ignore_repeated_source = Off
report_memleaks = On
track_errors = Off
;error_log = /opt/var/log/php_errors.log
;error_log = syslog
variables_order = "EGPCS"
request_order = "GP"
register_globals = Off
register_long_arrays = Off
register_argc_argv = On
auto_globals_jit = On
post_max_size = 4M
magic_quotes_runtime = Off
magic_quotes_sybase = Off
auto_prepend_file =
auto_append_file =
default_mimetype = "text/html"
doc_root = "/opt/share/www"
user_dir =
extension_dir = "/opt/lib/php"
enable_dl = On
cgi.fix_pathinfo=1
file_uploads = On
upload_tmp_dir = "/tmp"
upload_max_filesize = 1M
max_file_uploads = 2
allow_url_fopen = On
allow_url_include = Off
;from="john@doe.com"
user_agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36"
default_socket_timeout = 30
EOF
mkdir /opt/share/www
/opt/etc/init.d/S80nginx start
Код: Выделить всё
/opt/etc/init.d/rc.unslung restart