Файл: adultscript-2.0.3-pro/files/admin/modules/nuevo/components/tickeredit.php
Строк: 78
<?php
defined('_VALID') or die('Restricted Access!');
class VComponent_Admin_nuevo_tickeredit
{
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__ticker WHERE ID = '".$id."' LIMIT 1";
$this->db->query($sql);
$data= $this->db->fetch_assoc();
if (isset($_POST['update_ad'])) {
$data['content'] = trim($_POST['content']);
$data['start'] = intval(trim($_POST['start']));
$data['runtime'] = intval(trim($_POST['runtime']));
$data['scrollspeed'] = intval(trim($_POST['scrollspeed']));
$data['opacity'] = intval($_POST['opacity']);
$data['position'] = trim($_POST['position']);
$data['active'] = $_POST['active'];
$data['url'] = trim($_POST['url']);
$data['target'] = trim($_POST['target']);
if ( strlen($data['content'])<1 )
$errors[] = "Message text cannot be blank";
if ($data['start']<1)
$errors[] = "Start time cannot be 0 or blank";
if ($data['runtime']<3)
$errors[] = "Runtime cannot be less than 3 secoonds";
if ($data['opacity']<25 || $data['opacity']>100)
$errors[] = "Opacity value must be betwee 25-100";
if ( !$errors ) {
$sql = "UPDATE nuevo__ticker SET content = '".mysql_real_escape_string($data['content'])."', start ='".mysql_real_escape_string($data['start'])."', runtime ='".mysql_real_escape_string($data['runtime'])."', scrollspeed ='".mysql_real_escape_string($data['scrollspeed'])."', opacity ='".mysql_real_escape_string($data['opacity'])."', position ='".mysql_real_escape_string($data['position'])."', url ='".mysql_real_escape_string($data['url'])."', target ='".mysql_real_escape_string($data['target'])."', addtime ='".mysql_real_escape_string(time())."', active ='".mysql_real_escape_string($data['active'])."' WHERE ID = '".mysql_real_escape_string($id)."'";
$this->db->query($sql);
if($this->db->affected_rows()) {
header("Location: ".ADMIN_URL.'/index.php?q=nuevo/ticker');
die();
} else {
$errors[] = 'Error while saving data in database.';
}
}
}
}
$tpl = &VF::factory('template');
$tpl->menu = 'nuevo';
$tpl->submenu = 'nuevo_ads';
$tpl->meta_title = 'Admin::Nuevo::Ticker edit';
$tpl->errors = $errors;
$tpl->messages = $messages;
if(isset($data)) $tpl->ad = $data;
$tpl->pmenu = 'ticker';
$tpl->load(array('header', 'nuevo_tickeredit', 'footer'));
$tpl->display();
}
}
?>