Файл: adultscript-2.0.3-pro/files/admin/modules/video/components/config.php
Строк: 394
<?php
defined('_VALID') or die('Restricted Access!');
define('WATERMARK', false);
class VComponent_Admin_video_config
{
private $db;
public function __construct()
{
$this->db = VF::factory('database');
}
public function render()
{
$vcfg = VF::cfg('module.video');
$groups = $this->get_user_groups();
$errors = array();
$messages = array();
$warnings = array();
if (isset($_POST['submit_config'])) {
$filter = VF::factory('filter');
$browse_category = (int) trim($_POST['browse_category']);
$browse_order = (int) trim($_POST['browse_order']);
$browse_timeline = (int) trim($_POST['browse_timeline']);
$browse_per_page = (int) trim($_POST['browse_per_page']);
$search_type = $filter->get('search_type');
$search_per_page = (int) trim($_POST['search_per_page']);
$rss = (int) trim($_POST['rss']);
$rss_type = $filter->get('rss_type');
$rss_per_page = (int) trim($_POST['rss_per_page']);
$tag_per_page = (int) trim($_POST['tag_per_page']);
$view_access = $filter->get('view_access');
$view_desc = (int) trim($_POST['view_desc']);
$view_related = (int) trim($_POST['view_related']);
$related_method = $filter->get('related_method');
$related_total = (int) trim($_POST['related_total']);
$related_per_page = (int) trim($_POST['related_per_page']);
$view_comments = (int) trim($_POST['view_comments']);
$allow_comment = (int) trim($_POST['allow_comment']);
$approve_comments = (int) trim($_POST['approve_comments']);
$comments_per_page = (int) trim($_POST['comments_per_page']);
$allow_rating = (int) trim($_POST['allow_rating']);
$rating_count = (int) trim($_POST['rating_count']);
$rating_type = $filter->get('rating_type');
$download = (int) trim($_POST['download']);
$download_perms = $filter->get('download_perms');
$upload_enabled = (int) trim($_POST['upload_enabled']);
$upload_perm = $filter->get('upload_perm');
$upload_progress = $filter->get('upload_progress');
$upload_limit = (int) trim($_POST['upload_limit']);
$max_categories = (int) trim($_POST['max_categories']);
$allowed_ext = $filter->get('video_allowed_ext');
$max_size = (int) trim($_POST['video_max_size']);
$queue = (int) trim($_POST['queue']);
$queue_limit = (int) trim($_POST['queue_limit']);
$approve = (int) trim($_POST['approve']);
$multi_server = (int) trim($_POST['multi_server']);
$amazon_s3 = (int) trim($_POST['amazon_s3']);
$s3_access_key = trim($_POST['s3_access_key']);
$s3_secret_key = trim($_POST['s3_secret_key']);
$s3_bucket = trim($_POST['s3_bucket']);
$cloudfront_url = trim($_POST['cloudfront_url']);
$nice_level = (int) trim($_POST['nice_level']);
$flv_copy = (int) trim($_POST['flv_copy']);
$mp4_reconvert = (int) trim($_POST['mp4_reconvert']);
$mp4_crf = (int) trim($_POST['mp4_crf']);
$mp4_resize = (int) trim($_POST['mp4_resize']);
$mp4_width = (int) trim($_POST['mp4_width']);
$mp4_height = (int) trim($_POST['mp4_height']);
$mp4_preset = $filter->get('mp4_preset');
$mp4_profile = $filter->get('mp4_profile');
$mp4_level = $filter->get('mp4_level');
$mp4_maxrate = (int) trim($_POST['mp4_maxrate']);
$mp4_audio_codec = $filter->get('mp4_audio_codec');
$mp4_audio_bitrate = (int) trim($_POST['mp4_audio_bitrate']);
$mp4_audio_sample = (int) trim($_POST['mp4_audio_samplerate']);
$mp4_trailer = (int) trim($_POST['mp4_trailer']);
$mp4_watermark = $vcfg['mp4_watermark'];
$mp4_watermark_pos = $filter->get('mp4_watermark_pos');
$mp4_watermark_rem = (isset($_POST['mp4_watermark_remove'])) ? true : false;
$mp4_hd_convert = (int) trim($_POST['mp4_hd_convert']);
$mp4_hd_reconvert = (int) trim($_POST['mp4_hd_reconvert']);
$mp4_hd_min_height = (int) trim($_POST['mp4_hd_min_height']);
$mp4_hd_min_width = (int) trim($_POST['mp4_hd_min_width']);
$mp4_hd_min_bitrate = (int) trim($_POST['mp4_hd_min_bitrate']);
$mp4_hd_crf = (int) trim($_POST['mp4_hd_crf']);
$mp4_hd_resize = (int) trim($_POST['mp4_hd_resize']);
$mp4_hd_width = (int) trim($_POST['mp4_hd_width']);
$mp4_hd_height = (int) trim($_POST['mp4_hd_height']);
$mp4_hd_preset = $filter->get('mp4_hd_preset');
$mp4_hd_profile = $filter->get('mp4_hd_profile');
$mp4_hd_level = $filter->get('mp4_hd_level');
$mp4_hd_maxrate = (int) trim($_POST['mp4_hd_maxrate']);
$mp4_hd_audio_codec = $filter->get('mp4_hd_audio_codec');
$mp4_hd_audio_bitrate = (int) trim($_POST['mp4_hd_audio_bitrate']);
$mp4_hd_audio_sample = (int) trim($_POST['mp4_hd_audio_samplerate']);
$mp4_hd_trailer = (int) trim($_POST['mp4_hd_trailer']);
$mp4_hd_watermark = $vcfg['mp4_hd_watermark'];
$mp4_hd_watermark_pos = $filter->get('mp4_hd_watermark_pos');
$mp4_hd_watermark_rem = (isset($_POST['mp4_hd_watermark_remove'])) ? true : false;
$mobile_convert = (int) trim($_POST['mobile_convert']);
$mobile_resize = (int) trim($_POST['mobile_resize']);
$mobile_width = (int) trim($_POST['mobile_width']);
$mobile_height = (int) trim($_POST['mobile_height']);
$mobile_preset = $filter->get('mobile_preset');
$mobile_profile = $filter->get('mobile_profile');
$mobile_level = $filter->get('mobile_level');
$mobile_crf = (int) trim($_POST['mobile_crf']);
$mobile_maxrate = (int) trim($_POST['mobile_maxrate']);
$mobile_audio_codec = $filter->get('mobile_audio_codec');
$mobile_audio_bitrate = (int) trim($_POST['mobile_audio_bitrate']);
$mobile_audio_sample = (int) trim($_POST['mobile_audio_samplerate']);
$mobile_trailer = (int) trim($_POST['mobile_trailer']);
$mobile_watermark = $vcfg['mobile_watermark'];
$mobile_watermark_pos = $filter->get('mobile_watermark_pos');
$mobile_watermark_rem = (isset($_POST['mobile_watermark_remove'])) ? true : false;
$ffmpeg_path = $filter->get('ffmpeg_path');
$ffprobe_path = $filter->get('ffprobe_path');
$yamdi_path = $filter->get('yamdi_path');
$qtfaststart_path = $filter->get('qtfaststart_path');
$log = (int) trim($_POST['log']);
$delete_orig = (int) trim($_POST['delete_orig']);
$thumb_preview = (int) trim($_POST['thumb_preview']);
$thumbs = (int) trim($_POST['thumbs']);
$thumb_width = (int) trim($_POST['thumb_width']);
$thumb_height = (int) trim($_POST['thumb_height']);
$thumb_sizes = (isset($_POST['thumb_sizes'])) ? (array) $_POST['thumb_sizes'] : array();
$thumb_resize = $filter->get('thumb_resize');
$thumb_optimize = (int) trim($_POST['thumb_optimize']);
$convert_path = $filter->get('convert_path');
$thumb_extr = $filter->get('thumb_extr');
$thumb_allowed_ext = $filter->get('thumb_allowed_ext');
$thumb_max_size = (int) trim($_POST['thumb_max_size']);
$thumb_slide = (int) trim($_POST['thumb_slide']);
$thumb_server = (int) trim($_POST['thumb_server']);
$thumb_host = $filter->get('thumb_host');
$thumb_port = (int) trim($_POST['thumb_port']);
$thumb_user = trim($_POST['thumb_user']);
$thumb_pass = trim($_POST['thumb_pass']);
$thumb_root = trim($_POST['thumb_root']);
$embed_allow = (int) trim($_POST['embed_allow']);
$embed_track = (int) trim($_POST['embed_track']);
$embed_width = (int) trim($_POST['embed_width']);
$embed_height = (int) trim($_POST['embed_height']);
$delete_enabled = (int) trim($_POST['delete_enabled']);
$delete_method = $filter->get('delete_method');
$delete_username = $filter->get('delete_username');
$title_min_length = (int) trim($_POST['title_min_length']);
$title_max_length = (int) trim($_POST['title_max_length']);
$slug_max_length = (int) trim($_POST['slug_max_length']);
$desc_min_length = (int) trim($_POST['desc_min_length']);
$desc_max_length = (int) trim($_POST['desc_max_length']);
$tags_min_length = (int) trim($_POST['tags_min_length']);
$tags_max_length = (int) trim($_POST['tags_max_length']);
$tag_max_length = (int) trim($_POST['tag_max_length']);
$tag_max_words = (int) trim($_POST['tag_max_words']);
$separate_meta = (int) trim($_POST['separate_meta']);
$subcategories = (int) trim($_POST['subcategories']);
$player = $filter->get('player');
$streaming_method = $filter->get('streaming_method');
$streaming_server = $filter->get('streaming_server');
$streaming_url = $filter->get('streaming_url');
$streaming_secure = (int) trim($_POST['streaming_secure']);
$streaming_prefix = $filter->get('streaming_prefix');
$streaming_key = $filter->get('streaming_key');
$rtmp_stream = $filter->get('rtmp_stream');
$track_views = (int) trim($_POST['track_views']);
$playlists = (int) trim($_POST['playlists']);
$playlists_per_page = (int) trim($_POST['playlists_per_page']);
$playlist_rating = (int) trim($_POST['playlist_rating']);
$playlist_rating_count = (int) trim($_POST['playlist_rating_count']);
$playlist_rating_type = $filter->get('rating_type');
$playlist_comments = (int) trim($_POST['playlist_comments']);
$playlist_allow_comment = (int) trim($_POST['playlist_allow_comment']);
$playlist_comments_per_page = (int) trim($_POST['playlist_comments_per_page']);
if ($search_type == 'complex' OR
$related_method == 'complex') {
$warnings[] = 'Please add your Sphinx host and porn in Admin -> Config!';
}
if ($ffmpeg_path && (!file_exists($ffmpeg_path) or !is_file($ffmpeg_path) or !is_executable($ffmpeg_path))) {
$warnings[] = 'Failed to find FFMpeg at '.$ffmpeg_path.'. Please check if this file exists and/or if open_basedir is enabled.';
}
if ($ffprobe_path && (!file_exists($ffprobe_path) or !is_file($ffprobe_path) or !is_executable($ffprobe_path))) {
$warnings[] = 'Failed to find ffprobe at '.$ffprobe_path.'. Please check if this file exists and/or if open_basedir is enabled.';
}
if ($qtfaststart_path && (!file_exists($qtfaststart_path) or !is_file($qtfaststart_path) or !is_executable($qtfaststart_path))) {
$warnings[] = 'Failed to find qtfaststart at '.$qtfaststart_path.'. Please check if this file exists and/or if open_basedir is enabled.';
}
if ($yamdi_path && (!file_exists($yamdi_path) or !is_file($yamdi_path) or !is_executable($yamdi_path))) {
$warnings[] = 'Failed to find yamdi at '.$yamdi_path.'. Please check if this file exists and/or if open_basedir is enabled.';
}
if ($convert_path && (!file_exists($convert_path) or !is_file($convert_path) or !is_executable($convert_path))) {
$warnings[] = 'Failed to find convert at '.$convert_path.'. Please check if this file exists and/or if open_basedir is enabled.';
}
if (isset($_FILES['mp4_watermark']) && $_FILES['mp4_watermark']['tmp_name']) {
if ($mp4_file = VUpload::process('mp4_watermark', 2, array('png'))) {
if (move_uploaded_file($mp4_file['path'], MEDIA_DIR.'/videos/wm/mp4_watermark.png')) {
$mp4_watermark = 'mp4_watermark.png';
} else {
$errors[] = 'Failed to move uploaded mp4 watermark file!';
}
} else {
$errors = array_merge($errors, VUpload::error());
}
}
if (isset($_FILES['mp4_hd_watermark']) && $_FILES['mp4_hd_watermark']['tmp_name']) {
if ($mp4_hd_file = VUpload::process('mp4_hd_watermark', 2, array('png'))) {
if (move_uploaded_file($mp4_hd_file['path'], MEDIA_DIR.'/videos/wm/mp4_hd_watermark.png')) {
$mp4_hd_watermark = 'mp4_hd_watermark.png';
} else {
$errors[] = 'Failed to move uploaded mp4 watermark file!';
}
} else {
$errors = array_merge($errors, VUpload::error());
}
}
if (isset($_FILES['mobile_watermark']) && $_FILES['mobile_watermark']['tmp_name']) {
if ($mobile_file = VUpload::process('mobile_watermark', 2, array('png'))) {
if (move_uploaded_file($mobile_file['path'], MEDIA_DIR.'/videos/wm/mobile_watermark.png')) {
$mobile_watermark = 'mobile_watermark.png';
} else {
$errors[] = 'Failed to move uploaded mp4 watermark file!';
}
} else {
$errors = array_merge($errors, VUpload::error());
}
}
if (!$errors) {
$allowed_ext = explode(',', preg_replace('/[^a-z0-9,]+/', '', $allowed_ext));
$thumb_allowed_ext = explode(',', preg_replace('/[^a-z0-9,]+/', '', $thumb_allowed_ext));
$vcfg = array();
$vcfg['components'] = array(
'browse' => 1,
'view' => 1,
'search' => 1,
'tag' => 1,
'rss' => 1,
'related' => 1
);
$vcfg['browse_category'] = $browse_category;
$vcfg['browse_order'] = $browse_order;
$vcfg['browse_timeline'] = $browse_timeline;
$vcfg['browse_per_page'] = $browse_per_page;
$vcfg['search_type'] = $search_type;
$vcfg['search_per_page'] = $search_per_page;
$vcfg['rss'] = $rss;
$vcfg['rss_type'] = $rss_type;
$vcfg['rss_per_page'] = $rss_per_page;
$vcfg['tag_per_page'] = $tag_per_page;
$vcfg['view_access'] = $view_access;
$vcfg['view_desc'] = $view_desc;
$vcfg['view_related'] = $view_related;
$vcfg['related_method'] = $related_method;
$vcfg['related_total'] = $related_total;
$vcfg['related_per_page'] = $related_per_page;
$vcfg['view_comments'] = $view_comments;
$vcfg['allow_comment'] = $allow_comment;
$vcfg['approve_comments'] = $approve_comments;
$vcfg['comments_per_page'] = $comments_per_page;
$vcfg['allow_rating'] = $allow_rating;
$vcfg['rating_count'] = $rating_count;
$vcfg['rating_type'] = $rating_type;
$vcfg['download'] = $download;
$vcfg['download_perms'] = $download_perms;
$vcfg['upload_enabled'] = $upload_enabled;
$vcfg['upload_perm'] = $upload_perm;
$vcfg['upload_progress'] = $upload_progress;
$vcfg['upload_limit'] = $upload_limit;
$vcfg['max_categories'] = $max_categories;
$vcfg['video_allowed_ext'] = $allowed_ext;
$vcfg['video_max_size'] = $max_size;
$vcfg['queue'] = $queue;
$vcfg['queue_limit'] = $queue_limit;
$vcfg['approve'] = $approve;
$vcfg['multi_server'] = $multi_server;
$vcfg['amazon_s3'] = $amazon_s3;
$vcfg['s3_access_key'] = $s3_access_key;
$vcfg['s3_secret_key'] = $s3_secret_key;
$vcfg['s3_bucket'] = $s3_bucket;
$vcfg['cloudfront_url'] = $cloudfront_url;
$vcfg['nice_level'] = $nice_level;
$vcfg['flv_copy'] = $flv_copy;
$vcfg['mp4_reconvert'] = $mp4_reconvert;
$vcfg['mp4_crf'] = $mp4_crf;
$vcfg['mp4_resize'] = $mp4_resize;
$vcfg['mp4_width'] = $mp4_width;
$vcfg['mp4_height'] = $mp4_height;
$vcfg['mp4_preset'] = $mp4_preset;
$vcfg['mp4_level'] = $mp4_level;
$vcfg['mp4_profile'] = $mp4_profile;
$vcfg['mp4_maxrate'] = $mp4_maxrate;
$vcfg['mp4_audio_codec'] = $mp4_audio_codec;
$vcfg['mp4_audio_bitrate'] = $mp4_audio_bitrate;
$vcfg['mp4_audio_samplerate'] = $mp4_audio_sample;
$vcfg['mp4_trailer'] = $mp4_trailer;
$vcfg['mp4_watermark'] = ($mp4_watermark_rem) ? false : $mp4_watermark;
$vcfg['mp4_watermark_pos'] = $mp4_watermark_pos;
$vcfg['mp4_hd_convert'] = $mp4_hd_convert;
$vcfg['mp4_hd_reconvert'] = $mp4_hd_reconvert;
$vcfg['mp4_hd_min_height'] = $mp4_hd_min_height;
$vcfg['mp4_hd_min_width'] = $mp4_hd_min_width;
$vcfg['mp4_hd_min_bitrate'] = $mp4_hd_min_bitrate;
$vcfg['mp4_hd_crf'] = $mp4_hd_crf;
$vcfg['mp4_hd_resize'] = $mp4_hd_resize;
$vcfg['mp4_hd_width'] = $mp4_hd_width;
$vcfg['mp4_hd_height'] = $mp4_hd_height;
$vcfg['mp4_hd_preset'] = $mp4_hd_preset;
$vcfg['mp4_hd_level'] = $mp4_hd_level;
$vcfg['mp4_hd_profile'] = $mp4_hd_profile;
$vcfg['mp4_hd_maxrate'] = $mp4_hd_maxrate;
$vcfg['mp4_hd_audio_codec'] = $mp4_hd_audio_codec;
$vcfg['mp4_hd_audio_bitrate'] = $mp4_hd_audio_bitrate;
$vcfg['mp4_hd_audio_samplerate'] = $mp4_hd_audio_sample;
$vcfg['mp4_hd_trailer'] = $mp4_hd_trailer;
$vcfg['mp4_hd_watermark'] = ($mp4_hd_watermark_rem) ? false : $mp4_hd_watermark;
$vcfg['mp4_hd_watermark_pos'] = $mp4_hd_watermark_pos;
$vcfg['mobile_convert'] = $mobile_convert;
$vcfg['mobile_resize'] = $mobile_resize;
$vcfg['mobile_width'] = $mobile_width;
$vcfg['mobile_height'] = $mobile_height;
$vcfg['mobile_preset'] = $mobile_preset;
$vcfg['mobile_level'] = $mobile_level;
$vcfg['mobile_profile'] = $mobile_profile;
$vcfg['mobile_crf'] = $mobile_crf;
$vcfg['mobile_maxrate'] = $mobile_maxrate;
$vcfg['mobile_audio_codec'] = $mobile_audio_codec;
$vcfg['mobile_audio_bitrate'] = $mobile_audio_bitrate;
$vcfg['mobile_audio_samplerate'] = $mobile_audio_sample;
$vcfg['mobile_trailer'] = $mobile_trailer;
$vcfg['mobile_watermark'] = ($mobile_watermark_rem) ? false : $mobile_watermark;
$vcfg['mobile_watermark_pos'] = $mobile_watermark_pos;
$vcfg['ffmpeg_path'] = $ffmpeg_path;
$vcfg['ffprobe_path'] = $ffprobe_path;
$vcfg['yamdi_path'] = $yamdi_path;
$vcfg['qtfaststart_path'] = $qtfaststart_path;
$vcfg['log'] = $log;
$vcfg['delete_orig'] = $delete_orig;
$vcfg['thumb_preview'] = $thumb_preview;
$vcfg['thumbs'] = $thumbs;
$vcfg['thumb_width'] = $thumb_width;
$vcfg['thumb_height'] = $thumb_height;
$vcfg['thumb_sizes'] = $thumb_sizes;
$vcfg['thumb_extr'] = $thumb_extr;
$vcfg['thumb_resize'] = $thumb_resize;
$vcfg['thumb_optimize'] = $thumb_optimize;
$vcfg['convert_path'] = $convert_path;
$vcfg['thumb_allowed_ext'] = $thumb_allowed_ext;
$vcfg['thumb_max_size'] = $thumb_max_size;
$vcfg['thumb_slide'] = $thumb_slide;
$vcfg['thumb_server'] = $thumb_server;
$vcfg['thumb_host'] = $thumb_host;
$vcfg['thumb_port'] = $thumb_port;
$vcfg['thumb_user'] = $thumb_user;
$vcfg['thumb_pass'] = $thumb_pass;
$vcfg['thumb_root'] = $thumb_root;
$vcfg['embed_allow'] = $embed_allow;
$vcfg['embed_track'] = $embed_track;
$vcfg['embed_width'] = $embed_width;
$vcfg['embed_height'] = $embed_height;
$vcfg['delete_enabled'] = $delete_enabled;
$vcfg['delete_method'] = $delete_method;
$vcfg['delete_username'] = $delete_username;
$vcfg['title_min_length'] = $title_min_length;
$vcfg['title_max_length'] = $title_max_length;
$vcfg['slug_max_length'] = $slug_max_length;
$vcfg['desc_min_length'] = $desc_min_length;
$vcfg['desc_max_length'] = $desc_max_length;
$vcfg['tags_min_length'] = $tags_min_length;
$vcfg['tags_max_length'] = $tags_max_length;
$vcfg['tag_max_length'] = $tag_max_length;
$vcfg['tag_max_words'] = $tag_max_words;
$vcfg['separate_meta'] = $separate_meta;
$vcfg['subcategories'] = $subcategories;
$vcfg['player'] = $player;
$vcfg['track_views'] = $track_views;
$vcfg['streaming_method'] = $streaming_method;
$vcfg['streaming_server'] = $streaming_server;
$vcfg['streaming_secure'] = $streaming_secure;
$vcfg['streaming_url'] = $streaming_url;
$vcfg['streaming_prefix'] = $streaming_prefix;
$vcfg['streaming_key'] = $streaming_key;
$vcfg['rtmp_stream'] = $rtmp_stream;
$vcfg['playlists'] = $playlists;
$vcfg['playlists_per_page'] = $playlists_per_page;
$vcfg['playlist_rating'] = $playlist_rating;
$vcfg['playlist_rating_count'] = $playlist_rating_count;
$vcfg['playlist_rating_type'] = $playlist_rating_type;
$vcfg['playlist_comments'] = $playlist_comments;
$vcfg['playlist_allow_comment'] = $playlist_allow_comment;
$vcfg['playlist_comments_per_page'] = $playlist_comments_per_page;
if (!$errors) {
$this->db->query("UPDATE #__module
SET config_cache = '".$this->db->escape(serialize($vcfg))."',
config = '".$this->db->escape(serialize($vcfg))."'
WHERE name = 'video'
LIMIT 1");
VF::cache_set('video', $vcfg, 'module');
$messages[] = 'Video Module Configuration Updated';
}
}
}
$tpl = VF::factory('template');
$tpl->menu = 'video';
$tpl->submenu = 'config';
$tpl->meta_title = 'Admin::Video::Config';
$tpl->errors = $errors;
$tpl->messages = $messages;
$tpl->warnings = $warnings;
$tpl->vcfg = VF::cfg('module.video', TRUE, TRUE);
$tpl->groups = $groups;
$tpl->audio_codecs = $this->get_supported_audio_codecs();
$tpl->load(array('header', 'video_config', 'footer'));
$tpl->display();
}
private function get_user_groups()
{
$this->db->query("SELECT group_id, name FROM #__user_groups ORDER BY group_id ASC");
if ($this->db->affected_rows()) {
return $this->db->fetch_rows();
}
die('Failed to load the user groups table!');
}
private function get_supported_audio_codecs()
{
$codecs = array('aac' => 'Native FFmpeg AAC Encoder (aac)');
$cmd = VF::cfg_item('module.video.ffmpeg_path').' -i';
exec($cmd. ' 2>&1', $output);
$output = implode('', $output);
if (strpos($output, '--enable-libfaac') !== false) {
$codecs['libfaac'] = 'Freeware Advanced Audio Coder (libfaac)';
}
if (strpos($output, '--enable-libfdk_aac') !== false) {
$codecs['libfdk_aac'] = 'Fraunhofer FDK AAC Library (libfdk_aac)';
}
return $codecs;
}
}
?>