Файл: adultscript-2.0.3-pro/files/admin/modules/video/components/server_add.php
Строк: 91
<?php
defined('_VALID') or die('Restricted Access!');
class VComponent_Admin_video_server_add
{
public function __construct()
{
}
public function render()
{
$errors = array();
$messages = array();
$server = array(
'server_name' => '',
'status' => 1,
'ftp_host' => '',
'ftp_port' => 21,
'ftp_username' => '',
'ftp_password' => '',
'ftp_root' => '',
'url' => '',
'streaming_method' => 'progressive',
'streaming_server' => 'lighttpd',
'lighttpd_url' => '',
'lighttpd_secdownload' => '0',
'lighttpd_prefix' => '',
'lighttpd_key' => '',
'rtmp_stream' => ''
);
if (isset($_POST['submit_add'])) {
$filter = VF::factory('filter');
$server_name = $filter->get('server_name');
$status = (int) trim($_POST['status']);
$ftp_host = $filter->get('ftp_host');
$ftp_port = (int) trim($_POST['ftp_port']);
$ftp_username = $filter->get('ftp_username');
$ftp_password = trim($_POST['ftp_password']);
$ftp_root = $filter->get('ftp_root');
$streaming_method = $filter->get('streaming_method');
$streaming_server = $filter->get('streaming_server');
$url = $filter->get('url');
$lighttpd_url = $filter->get('lighttpd_url');
$lighttpd_secdownload = (int) trim($_POST['lighttpd_secdownload']);
$lighttpd_prefix = $filter->get('lighttpd_prefix');
$lighttpd_key = trim($_POST['lighttpd_key']);
$rtmp_stream = $filter->get('rtmp_stream');
if ($server_name == '') {
$errors[] = 'Server Name field cannot be left blank!';
} else {
$server['server_name'] = $server_name;
}
if ($ftp_host == '') {
$errors[] = 'FTP Host field cannot be left blank!';
} else {
$server['ftp_host'] = $ftp_host;
}
if ($ftp_port === 0) {
$errors[] = 'FTP Port field cannot be left blank!';
} else {
$server['ftp_port'] = $ftp_port;
}
if ($ftp_username == '') {
$errors[] = 'FTP Username field cannot be left blank!';
} else {
$server['ftp_username'] = $ftp_username;
}
if ($streaming_method == 'progressive') {
if ($url == '') {
$errors[] = 'Progressive streaming URL field cannot be left blank!';
} elseif (!VValid::url($url)) {
$errors[] = 'Progressive streaming URL is not a valid URL address!';
} else {
$server['url'] = $url;
}
} elseif ($streaming_method == 'pseudostreaming') {
if ($lighttpd_url == '') {
$errors[] = 'Lighttpd URL field cannot be left blank!';
} elseif (!VValid::url($lighttpd_url)) {
$errors[] = 'Lighttpd URL is not a valid URL address!';
} else {
$server['lighttpd_url'] = $lighttpd_url;
}
if ($lighttpd_secdownload === 1) {
if ($lighttpd_prefix == '') {
$errors[] = 'Lighttpd prefix field cannot be left blank!';
} else {
$server['lighttpd_prefix'] = $lighttpd_prefix;
}
if ($lighttpd_key == '') {
$errors[] = 'Lighttpd key field cannot be left blank!';
} else {
$server['lighttpd_key'] = $lighttpd_key;
}
}
} elseif ($streaming_method == 'rtmp') {
if ($rtmp_stream == '') {
$errors[] = 'RTMP Stream field cannot be left blank!';
} else {
$server['rtmp_stream'] = $rtmp_stream;
}
} else {
$errors[] = 'Invalid streaming method! What exactly did you select!?';
}
$server['ftp_root'] = $ftp_root;
$server['status'] = $status;
$server['streaming_method'] = $streaming_method;
$server['streaming_server'] = $streaming_server;
if (!$errors) {
$db = VF::factory('database');
$db->query("INSERT INTO #__server
SET server_name = '".$db->escape($server_name)."',
ftp_host = '".$db->escape($ftp_host)."',
ftp_port = ".$ftp_port.",
ftp_username = '".$db->escape($ftp_username)."',
ftp_password = '".$db->escape($ftp_password)."',
ftp_root = '".$db->escape($ftp_root)."',
streaming_method = '".$db->escape($streaming_method)."',
streaming_server = '".$db->escape($streaming_server)."',
url = '".$db->escape($url)."',
lighttpd_url = '".$db->escape($lighttpd_url)."',
lighttpd_secdownload = '".$lighttpd_secdownload."',
lighttpd_prefix = '".$db->escape($lighttpd_prefix)."',
lighttpd_key = '".$db->escape($lighttpd_key)."',
rtmp_stream = '".$db->escape($rtmp_stream)."',
status = '".$status."'");
if ($db->affected_rows()) {
$messages[] = 'Server added!';
} else {
$errors[] = 'Failed to add server! Aborting...';
}
}
}
$tpl = VF::factory('template');
$tpl->menu = 'video';
$tpl->submenu = 'video_server_add';
$tpl->meta_title = 'Video::Server::Add';
$tpl->errors = $errors;
$tpl->messages = $messages;
$tpl->server = $server;
$tpl->load(array('header', 'video_server_add', 'footer'));
$tpl->display();
}
}