Вход Регистрация
Файл: adultscript-2.0.3-pro/files/admin/templates/default/extend/ajax/manage_player_default.plugin.php
Строк: 73
<?php
defined
('_VALID') or die('Restricted Access!');
function 
ajax_plugin_manage_player_default()
{
    
$data = array('status' => 0'code' => '''msg' => '''debug' => '');
    if (isset(
$_POST['player_id']) OR isset($_POST['options'])) {
          
$player_id     = (isset($_POST['player_id'])) ? (int) trim($_POST['player_id']) : NULL;
          if (isset(
$_POST['options'])) {
              
parse_str($_POST['options'], $options);
              
$player_id = (int) $options['player_id'];
          }
          
          
$db    VF::factory('database');
          
$db->query("SELECT player_id FROM #__player WHERE player_id = ".$player_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_video        = (isset($options['adv_video'])) ? (array) $options['adv_video'] : array();
                  
                  
$db->query("DELETE FROM #__adv_player_default
                              WHERE player_id = "
.$player_id);
                              
                  if (
$adv_text_id !== 0) {            
                      
$db->query("INSERT INTO #__adv_player_default
                                    SET player_id = "
.$player_id.",
                                        type = 'text',
                                        adv_id = "
.$adv_text_id);
                  }
                  
                  if (
$adv_image_id !== 0) {
                      
$db->query("INSERT INTO #__adv_player_default
                                    SET player_id = "
.$player_id.",
                                        type = 'image',
                                        adv_id = "
.$adv_image_id);
                  }
                  
                  foreach (
$adv_video as $key => $value) {
                      
$db->query("INSERT INTO #__adv_player_default
                                  SET player_id = "
.$player_id.",
                                      type = 'video',
                                      adv_id = "
.(int) $value);
                  }
              }
          
              
$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_id, type
                          FROM #__adv_player_default
                          WHERE player_id = "
.$player_id);
              
$advs        $db->fetch_rows();
              
$adv_text    NULL;
              
$adv_img    NULL;
              
$adv_video    = array();
              foreach (
$advs as $adv) {
                  if (
$adv['type'] == 'text') {
                      
$adv_text     $adv['adv_id'];
                  }
                  
                  if (
$adv['type'] == 'image') {
                      
$adv_img    $adv['adv_id'];
                  }
                  
                  if (
$adv['type'] == 'video') {
                      
$adv_video[$adv['adv_id']] = 1;
                  }
              }
              
              
$code        = array();
              
$code[]        = '<form id="manage-player-form" method="post" action="'.BASE_URL.'/?q=ajax&s=manage_player&d=backend">';
              
$code[]        = '<input name="player_id" type="hidden" id="player_id" value="'.$player_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_img) ? ' 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 player profile! What exactly did you click!?</div>';
          }
    } else {
          
$data['msg'] = 'Invalid ajax request!';
    }
    
    return 
json_encode($data);
}
Онлайн: 1
Реклама