Файл: adultscript-2.0.3-pro/files/admin/modules/nuevo/components/prerolledit.php
Строк: 113
<?php
defined('_VALID') or die('Restricted Access!');
class VComponent_Admin_nuevo_prerolledit
{
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__preroll 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";
$data['day'] = intval(date("j",$data['expire']));
$data['month'] = intval(date("n",$data['expire']));
$data['year'] = intval(date("Y",$data['expire']));
$days=array();
for($i=1;$i<=31;$i++) $days[$i] = $i;
$year_beg=2012; $years=array();
for($i=1;$i<=38;$i++) {
$years[$i] = $year_beg;
$year_beg++;
}
$extensions = array('.png', '.jpg', '.jpeg', '.gif', '.swf', '.flv', '.mp4');
if (isset($_POST['update_ad'])) {
$data['channel'] = trim($_POST['channel']);
$data['owner'] = trim($_POST['owner']);
$data['email'] = trim($_POST['email']);
$data['url'] = trim($_POST['url']);
//$data['html5'] = trim($_POST['html5']);
$data['link'] = trim($_POST['link']);
$data['target'] = trim($_POST['target']);
$data['skip'] = intval($_POST['skip']);
$data['runtime'] = intval($_POST['runtime']);
$data['month'] = intval($_POST['month']);
$data['year'] = intval($_POST['year']);
$data['day'] = intval($_POST['day']);
$data['active'] = $_POST['active'] == '1' ? '1' : '0';
$extension = strrchr($data['url'], '.');
if (!in_array($extension, $extensions))
$errors[] = 'Invalid ad source file.';
elseif ( strlen($data['link']) < 3 )
$errors[] = 'Link URL cannot be empty!';
elseif ($data['month']<1 || $data['day']<1 || $data['year']<1)
$errors[] = 'Expire date not valid';
if ($data['month']>0 || $data['day']>0 || $data['year']>0)
$data['expire'] = mktime(0,0,0,$data['month'],$data['day'],$data['year']);
if ( !$errors ) {
$expire = mktime(0,0,0,$data['month'],$data['day'],$data['year']);
$data['expire'] = $expire;
$added = time();
if(strlen($data['owner'])>0) $owner = mysql_real_escape_string($data['owner']); else $owner='';
if(strlen($data['email'])>0) $email = mysql_real_escape_string($data['email']); else $email='';
$url = mysql_real_escape_string($data['url']);
//$html5 = mysql_real_escape_string($data['html5']);
$link = mysql_real_escape_string($data['link']);
$skip = mysql_real_escape_string($data['skip']);
$runtime = mysql_real_escape_string($data['runtime']);
$target = mysql_real_escape_string($data['target']);
$channel = mysql_real_escape_string($data['channel']);
$active = $data['active'];
$sql = "UPDATE nuevo__preroll SET channel = '$channel', owner = '$owner', email = '$email', url = '$url', skip = '$skip', link = '$link', target = '$target', runtime = '$runtime', expire = '$expire',added = '$added', active = '$active' WHERE ID = ".$id;
$this->db->query($sql);
if($this->db->affected_rows()) {
header("Location: ".ADMIN_URL.'/index.php?q=nuevo/preroll');
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::Create ad';
$tpl->errors = $errors;
$tpl->messages = $messages;
if(isset($data)) $tpl->ad = $data;
if(isset($categories)) $tpl->categories = $categories;
$tpl->pmenu = 'preroll';
if(isset($days)) $tpl->days = $days;
if(isset($years)) $tpl->years = $years;
$tpl->load(array('header', 'nuevo_prerolledit', 'footer'));
$tpl->display();
}
}
?>