Файл: adultscript-2.0.3-pro/files/admin/modules/nuevo/components/overlayedit.php
Строк: 73
<?php
defined('_VALID') or die('Restricted Access!');
class VComponent_Admin_nuevo_overlayedit
{
private $db;
private $cache;
private $filter;
public function __construct()
{
$this->db = VF::factory('database');
$this->cache = VF::factory('cache');
$this->filter = VF::factory('filter');
}
public function render()
{
$errors = array();
$messages = array();
$warnings = array();
$id = ( isset($_GET['id']) && is_numeric($_GET['id']) ) ? trim($_GET['id']) : NULL;
settype($id, 'integer');
if ( !$id ) {
$errors[] = 'Invalid ad ID. This ad does not exist!';
} else {
$sql = "SELECT * FROM nuevo__overlay WHERE ID = '".$id."' LIMIT 1";
$this->db->query($sql);
$data= $this->db->fetch_assoc();
if($data['views']>0)
$data['CTR'] = number_format(round(($data['hits']/$data['views']),2), 2, '.', '');
else
$data['CTR'] = "0,00";
if (isset($_POST['update_ad'])) {
$data['owner'] = trim($_POST['owner']);
$data['email'] = trim($_POST['email']);
$data['title'] = trim($_POST['title']);
$data['media'] = trim($_POST['media']);
$data['url'] = trim($_POST['url']);
$data['target'] = trim($_POST['target']);
$data['channel'] = trim($_POST['channel']);
$data['start'] = intval($_POST['start']);
$data['pause'] = intval($_POST['pause']);
$data['delay'] = intval($_POST['delay']);
$data['active'] = intval($_POST['pause']);
if ( strlen($data['title'])<3 )
$errors[] = "Overlay title cannot be blank";
elseif ( strlen($data['media'])<5 )
$errors[] = "Overlay source URL cannot be blank";
elseif ($data['start']<1)
$errors[] = "Start time must be greater than 0";
if ( !$errors ) {
$sql = "UPDATE nuevo__overlay SET title = '".mysql_real_escape_string($data['title'])."', owner = '".mysql_real_escape_string($data['owner'])."', email = '".mysql_real_escape_string($data['email'])."', media ='".mysql_real_escape_string($data['media'])."', url ='".mysql_real_escape_string($data['url'])."', target ='".mysql_real_escape_string($data['target'])."', channel ='".mysql_real_escape_string($data['channel'])."', start ='".mysql_real_escape_string($data['start'])."', pause ='".mysql_real_escape_string($data['pause'])."', delay ='".mysql_real_escape_string($data['delay'])."',active ='".mysql_real_escape_string($data['active'])."' WHERE ID ='".$id."'";
$this->db->query($sql);
if($this->db->affected_rows()) {
header("Location: ".ADMIN_URL.'/index.php?q=nuevo/overlay');
die();
} else {
$errors[] = 'Error while saving data in database.';
}
}
}
}
$sql = "SELECT cat_id, parent_id, name, slug, total_videos, status
FROM #__video_categories
ORDER BY slug, parent_id ASC";
$categories = $this->db->get_rows($sql);
$tpl = &VF::factory('template');
$tpl->menu = 'nuevo';
$tpl->submenu = 'nuevo_ads';
$tpl->meta_title = 'Admin::Nuevo::Overlay edit';
$tpl->errors = $errors;
$tpl->messages = $messages;
$tpl->categories = $categories;
if(isset($data)) $tpl->ad = $data;
$tpl->pmenu = 'overlay';
$tpl->load(array('header', 'nuevo_overlayedit', 'footer'));
$tpl->display();
}
}
?>