Файл: adultscript-2.0.3-pro/files/admin/modules/video/components/server_edit.php
Строк: 80
<?php
defined('_VALID') or die('Restricted Access!');
class VComponent_Admin_video_server_edit
{
public function __construct()
{
}
public function render()
{
$db = VF::factory('database');
$errors = array();
$messages = array();
$server = array();
$id = (isset($_GET['id'])) ? (int) trim($_GET['id']) : 0;
$db->query("SELECT server_id FROM #__server WHERE server_id = ".$id." LIMIT 1");
if ($db->affected_rows()) {
if (isset($_POST['submit_edit'])) {
$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');
$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');
$streaming_server = $filter->get('streaming_server');
if ($server_name == '') {
$errors[] = 'Server Name field cannot be left blank!';
}
if ($ftp_host == '') {
$errors[] = 'FTP Host field cannot be left blank!';
}
if ($ftp_port === 0) {
$errors[] = 'FTP Port field cannot be left blank!';
}
if ($ftp_username == '') {
$errors[] = 'FTP Username field cannot be left blank!';
}
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!';
}
} 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!';
}
if ($lighttpd_secdownload === 1) {
if ($lighttpd_prefix == '') {
$errors[] = 'Lighttpd prefix field cannot be left blank!';
}
if ($lighttpd_key == '') {
$errors[] = 'Lighttpd key field cannot be left blank!';
}
}
} elseif ($streaming_method == 'rtmp') {
if ($rtmp_stream == '') {
$errors[] = 'RTMP Stream field cannot be left blank!';
}
} else {
$errors[] = 'Invalid streaming method! What exactly did you select!?';
}
$server['ftp_root'] = $ftp_root;
$server['status'] = $status;
$server['streaming_method'] = $streaming_method;
if (!$errors) {
$db->query("UPDATE #__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)."',
url = '".$db->escape($url)."',
streaming_server = '".$db->escape($streaming_server)."',
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."'
WHERE server_id = ".$id."
LIMIT 1");
$messages[] = 'Server updated!';
}
}
$db->query("SELECT * FROM #__server WHERE server_id = ".$id." LIMIT 1");
$server = $db->fetch_assoc();
}
$tpl = VF::factory('template');
$tpl->menu = 'video';
$tpl->submenu = 'video_server';
$tpl->meta_title = 'Video::Server::Edit';
$tpl->errors = $errors;
$tpl->messages = $messages;
$tpl->server = $server;
$tpl->load(array('header', 'video_server_edit', 'footer'));
$tpl->display();
}
}