Файл: adultscript-2.0.3-pro/files/admin/modules/photo/components/server_add.php
Строк: 55
<?php
defined('_VALID') or die('Restricted Access!');
class VComponent_Admin_photo_server_add extends VModule_Admin_photo
{
public function __construct()
{
parent::__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' => ''
);
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');
$url = $filter->get('url');
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 ($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;
}
$server['ftp_root'] = $ftp_root;
$server['status'] = $status;
if (!$errors) {
$this->db->query("INSERT INTO #__photo_servers
SET server_name = '".$this->db->escape($server_name)."',
ftp_host = '".$this->db->escape($ftp_host)."',
ftp_port = ".$ftp_port.",
ftp_username = '".$this->db->escape($ftp_username)."',
ftp_password = '".$this->db->escape($ftp_password)."',
ftp_root = '".$this->db->escape($ftp_root)."',
url = '".$this->db->escape($url)."',
status = '".$status."'");
if ($this->db->affected_rows()) {
$messages[] = 'Server added!';
} else {
$errors[] = 'Failed to add server! Aborting...';
}
}
}
$tpl = VF::factory('template');
$tpl->menu = 'photo';
$tpl->submenu = 'photo_server_add';
$tpl->meta_title = 'Photo::Server::Add';
$tpl->errors = $errors;
$tpl->messages = $messages;
$tpl->server = $server;
$tpl->load(array('header', 'photo_server_add', 'footer'));
$tpl->display();
}
}