Файл: adultscript-2.0.3-pro/files/admin/templates/default/extend/ajax/manage_player_category.plugin.php
Строк: 77
<?php
defined('_VALID') or die('Restricted Access!');
function ajax_plugin_manage_player_category()
{
$data = array('status' => 0, 'code' => '', 'msg' => '', 'debug' => '');
if (isset($_POST['cat_id']) OR isset($_POST['options'])) {
$cat_id = (isset($_POST['cat_id'])) ? (int) trim($_POST['cat_id']) : NULL;
if (isset($_POST['options'])) {
parse_str($_POST['options'], $options);
$cat_id = (int) $options['cat_id'];
}
$db = VF::factory('database');
$db->query("SELECT cat_id FROM #__video_categories WHERE cat_id = ".$cat_id." LIMIT 1");
if ($db->affected_rows()) {
if (isset($options)) {
$adv_text_id = (int) $options['adv_text'];
$adv_image_id = (int) $options['adv_image'];
$adv_videos = (array) $options['adv_video'];
$adv_video = array();
foreach ($adv_videos as $key => $value) {
$adv_video[$value] = 1;
}
$db->query("UPDATE #__video_categories
SET adv_text_id = ".$adv_text_id.",
adv_image_id = ".$adv_image_id.",
adv_video = '".$db->escape(serialize($adv_video))."'
WHERE cat_id = ".$cat_id."
LIMIT 1");
}
$db->query("SELECT adv_id, adv_name
FROM #__adv_player
WHERE type = 'text'
AND status = '1'");
$advs_text = $db->fetch_rows();
$db->query("SELECT adv_id, adv_name
FROM #__adv_player
WHERE type = 'image'
AND status = '1'");
$advs_image = $db->fetch_rows();
$db->query("SELECT adv_id, adv_name, position
FROM #__adv_player
WHERE type = 'video'
AND status = '1'");
$advs_video = $db->fetch_rows();
$db->query("SELECT adv_image_id, adv_text_id, adv_video
FROM #__video_categories
WHERE cat_id = ".$cat_id."
LIMIT 1");
$sponsor = $db->fetch_assoc();
$adv_text = $sponsor['adv_text_id'];
$adv_image = $sponsor['adv_image_id'];
$adv_video = ($sponsor['adv_video'] != '') ? unserialize($sponsor['adv_video']) : array();
$code = array();
$code[] = '<form id="manage-player-form" method="post" action="'.BASE_URL.'/?q=ajax&s=manage_player_category&d=backend">';
$code[] = '<input name="cat_id" type="hidden" id="cat_id" value="'.$cat_id.'" />';
$code[] = '<fieldset>';
$code[] = '<legend>Text Advertising</legend>';
$code[] = '<select name="adv_text" id="adv_text">';
$code[] = '<option value="0">None</option>';
foreach ($advs_text as $adv) {
$selected = ($adv['adv_id'] == $adv_text) ? ' selected="selected"' : '';
$code[] = '<option value="'.$adv['adv_id'].'"'.$selected.'>'.e($adv['adv_name']).'</option>';
}
$code[] = '</select>';
$code[] = '</fieldset>';
$code[] = '<fieldset>';
$code[] = '<legend>Image Advertising</legend>';
$code[] = '<select name="adv_image" id="adv_image">';
$code[] = '<option value="0">None</option>';
foreach ($advs_image as $adv) {
$selected = ($adv['adv_id'] == $adv_image) ? ' selected="selected"' : '';
$code[] = '<option value="'.$adv['adv_id'].'"'.$selected.'>'.e($adv['adv_name']).'</option>';
}
$code[] = '</select>';
$code[] = '</fieldset>';
$code[] = '<fieldset>';
$code[] = '<legend>Video Advertising</legend>';
$code[] = '<select name="adv_video[]" id="adv_video" multiple size="10" style="min-height: 100px;">';
$code[] = '<option value="0">None</option>';
foreach ($advs_video as $adv) {
$selected = (isset($adv_video[$adv['adv_id']])) ? ' selected="selected"' : '';
$type = ($adv['position'] == '0') ? 'pre-roll' : 'mid-roll';
$type = ($adv['position'] == '-1') ? 'post-roll' : $type;
$code[] = '<option value="'.$adv['adv_id'].'"'.$selected.'>'.e($adv['adv_name']).' ('.$type.')</option>';
}
$code[] = '</select>';
$code[] = '</fieldset>';
$code[] = '</form>';
$data['status'] = 1;
$data['code'] = implode("n", $code);
} else {
$data['code'] = '<div class="none">Invalid video category! What exactly did you click!?</div>';
}
} else {
$data['msg'] = 'Invalid ajax request!';
}
return json_encode($data);
}