Файл: adultscript-2.0.3-pro/files/admin/modules/photo/components/server_edit.php
Строк: 49
<?php
defined('_VALID') or die('Restricted Access!');
class VComponent_Admin_photo_server_edit extends VModule_Admin_photo
{
public function __construct()
{
parent::__construct();
}
public function render()
{
$db = VF::factory('database');
$errors = array();
$messages = array();
$server = array();
$id = (isset($_GET['id'])) ? (int) trim($_GET['id']) : 0;
$this->db->query("SELECT server_id FROM #__photo_servers WHERE server_id = ".$id." LIMIT 1");
if ($this->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');
$url = $filter->get('url');
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 ($url == '') {
$errors[] = 'Progressive streaming URL field cannot be left blank!';
} elseif (!VValid::url($url)) {
$errors[] = 'Progressive streaming URL is not a valid URL address!';
}
$server['ftp_root'] = $ftp_root;
$server['status'] = $status;
if (!$errors) {
$this->db->query("UPDATE #__photo_servers
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)."',
url = '".$db->escape($url)."',
status = '".$status."'
WHERE server_id = ".$id."
LIMIT 1");
$messages[] = 'Server updated!';
}
}
$this->db->query("SELECT * FROM #__photo_servers WHERE server_id = ".$id." LIMIT 1");
$server = $this->db->fetch_assoc();
}
$tpl = VF::factory('template');
$tpl->menu = 'photo';
$tpl->submenu = 'photo_server';
$tpl->meta_title = 'Photo::Server::Edit';
$tpl->errors = $errors;
$tpl->messages = $messages;
$tpl->server = $server;
$tpl->load(array('header', 'photo_server_edit', 'footer'));
$tpl->display();
}
}