Вход Регистрация
Файл: adultscript-2.0.3-pro/files/admin/modules/video/components/manage.php
Строк: 447
<?php
defined
('_VALID') or die('Restricted Access!');
set_time_limit(0);
class 
VComponent_Admin_video_manage extends VModule_Admin_video
{
    protected 
$db;
    private 
$cfg;
    private 
$filter;
    private 
$option;
    private 
$vcfg;
    public function 
__construct()
    {
        
$this->cfg        VF::cfg('core.config');
        
$this->vcfg        VF::cfg('module.video');
        
$this->db        VF::factory('database');
        
$this->filter    VF::factory('filter');
        
$this->option    = array(
            
'video_id' => '''mobile' => '''ext' => '',
            
'title' => '''username' => '''channel' => '',
            
'category' => '''status' => '''flagged' => '',
            
'method' => '''server' => '''add_time' => '',
            
'sort' => 'v.video_id''order' => 'DESC''display' => 10
        
);
        
asort($this->option);
    }
    
    public function 
render()
    {
        
$statuses   = array(
            
'0' => 'Suspended',
            
'1' => 'Published',
            
'2' => 'Waiting Approval',
            
'3' => 'Uploading',
            
'4' => 'Converting',
            
'5' => 'Grabbing',
            
'6' => 'Queued',
            
'7' => 'Error',
            
'8' => 'Deleted'
        
);
        
        
$reasons    = array(
              
1    => 'Inappropriate',
              
2    => 'Underage',
              
3     => 'Copyright',
              
4    => 'Not Playing',
              
5    => 'Other'
        
);
        
        
$errors        = array();
        
$messages    = array();
        
$warnings    = array();

        
$categories        $this->get_video_categories();
        
        if (isset(
$_POST['action']) && isset($_POST['video_id'])) {
            
$action        $this->filter->get('action');
            
$video_id    $this->filter->get('video_id''INTEGER');
            if (
$video_id) {
                if (
$action == 'suspend' OR $action == 'activate') {
                    
$status = ($action == 'suspend') ? 1;
                    
$msg    = ($action == 'suspend') ? 'suspended' 'activated';
                    
$this->db->query("UPDATE #__video SET status = ".$status." WHERE video_id = ".$video_id." LIMIT 1");
                    
$messages[] = 'Video '.$msg.'!';
                } elseif (
$action == 'delete') {
                    
$this->delete_video($video_id);
                    
$messages[] = 'Video deleted!';
                } elseif (
$action == 'unassign') {
                    
$this->db->query("UPDATE #__video SET adv = 0 WHERE video_id = ".$video_id." LIMIT 1");
                    
$messages[] = 'Banner unassigned!';
                } elseif (
$action == 'sponsor') {
                    
$this->db->query("UPDATE #__video SET sponsor = 0 WHERE video_id = ".$video_id." LIMIT 1");
                    
$messages[] = 'Sponsor removed!';
                } elseif (
$action == 'convert') {
                    
$this->convert_video($video_id);
                    
$messages[] = 'Video conversion started in background!';
                } else {
                    
$errors[] = 'Invalid action! What exactly did you click!?';
                }
            } else {
                
$errors[] = 'Invalid video id! Are you sure this video exists!?';
            } 
        }
        
        if (isset(
$_POST['sub_action'])) {
            
$action    $this->filter->get('sub_action');
            
$ids    str_replace('&amp;''&'$this->filter->get('sub_ids'));
            if (!empty(
$ids)) {
                
parse_str($ids$vids);
                if (
$action == 'shedule') {
                    
$time    strtotime($this->filter->get('sub_date'));
                    
$date    date('Y-m-d'$time);
                    foreach (
array_keys($vids) as $key) {
                        
$video_id    = (int) $key;
                        
$this->db->query("SELECT video_id
                                          FROM #__video_shedule
                                          WHERE video_id = "
.$video_id."
                                          LIMIT 1"
);
                        if (
$this->db->affected_rows()) {
                            
$this->db->query("UPDATE #__video_shedule
                                              SET shedule_date = '"
.$date."'
                                              WHERE video_id = "
.$video_id."
                                              LIMIT 1"
);
                        } else {
                            
$this->db->query("INSERT INTO #__video_shedule
                                              SET video_id = "
.(int) $video_id.",
                                                  shedule_date = '"
.$date."'");
                        }
                    }
                    
$messages[] = 'Selected videos sheduled to go live on '.date('d M Y'$time);
                } elseif (
$action == 'shuffle') {
                } elseif (
$action == 'assign') {
                    
$adv_id    = (int) ($_POST['sub_id']);
                    if (
$adv_id) {
                        
$this->db->query("UPDATE #__video
                                          SET adv = "
.$adv_id."
                                          WHERE video_id IN ("
.implode(','array_keys($vids)).")");
                        
$messages[] = 'Advertising banner was assigned to the selected videos!';
                    } else {
                        
$errors[] = 'Please select a advertising banner!';
                    }
                } elseif (
$action == 'sponsor') {
                } else {
                    
$errors[] = 'Invalid action! What exactly did you select!?';
                }
            } else {
                
$errors[] = 'Please select at least one video!';
            }
        }
        
        if (isset(
$_POST['submit_actions'])) {
            
$action    $this->filter->get('action');
            
$ids    $this->get_checkbox_ids();
            if (
$ids) {
                if (
$action == 'suspend' OR $action == 'activate') {
                    
$status     = ($action == 'suspend') ? 1;
                    
$msg        = ($action == 'suspend') ? 'suspended' 'activated';
                    
$this->db->query("UPDATE #__video SET status = ".$status." WHERE video_id IN (".implode(','array_values($ids)).")");
                    
$messages[] = 'Selected videos '.$msg.'!';
                } elseif (
$action == 'delete') {
                    foreach (
$ids as $id) {
                        
$this->delete_video($id);
                    }
                    
$messages[] = 'Selected videos deleted!';
                } elseif (
$action == 'mark') {
                    
VHelper::load('module.video.manage');
                    foreach (
$ids as $id) {
                        
VHelper_video_manage::mark_deleted($id);
                    }
                    
$messages[]    = 'Selected videos marked as deleted!';
                } elseif (
$action == 'unassign') {
                    
$this->db->query("UPDATE #__video SET adv = 0 WHERE video_id IN (".implode(','$ids).")");
                    
$messages[] = 'Removed advertising from selected videos!';
                } elseif (
$action == 'unsponsor') {
                    
$this->db->query("UPDATE #__video SET sponsor = 0 WHERE video_id IN (".implode(','array_values($ids)).")");
                    
$messages[] = 'Removed sponsor from selected videos!';
                } elseif (
$action == 'premium') {
                    
$this->db->query("UPDATE #__video SET premium = '1' WHERE video_id IN (".implode(','array_values($ids)).")");
                    
$messages[] = 'Selected videos marked as premium!';
                } elseif (
$action == 'feature') {
                    foreach (
$ids as $id) {
                        
$this->db->query("UPDATE #__video
                                          SET featured = '1'
                                          WHERE video_id = "
.$id."
                                          LIMIT 1"
);
                        
$this->db->query("INSERT INTO #__video_featured
                                          SET video_id = "
.$id.",
                                              feature_time = "
.time());
                    }
                    
$messages[] = 'Featured selected videos!';
                } elseif (
$action == 'unfeature') {
                    
$ids    implode(','array_values($ids));
                    
$this->db->query("UPDATE #__video
                                      SET featured = '0'
                                      WHERE video_id IN ("
.$ids.")");
                    
$this->db->query("DELETE FROM #__video_featured
                                      WHERE video_id IN ("
.$ids.")");
                    
$messages[] = 'Unfeatured selected videos!';
                } elseif (
$action == 'shuffle') {
                    
$this->db->query("UPDATE #__video
                                      SET add_time = "
.time().",
                                          add_date = '"
.date('Y-m-d h:i:s')."'
                                      WHERE video_id IN ("
.implode(','array_values($ids)).")");
                    
$messages[] = 'Selected videos shuffled!';
                } elseif (
$action == 'thumb') {
                    foreach (
$ids as $video_id) {
                        
$this->generate_thumbs($video_id);
                    }
                    
                    
$messages[] = 'Thumbs generated for selected video(s)!';
                } elseif (
$action == 'duration') {
                    foreach (
$ids as $video_id) {
                        
$this->generate_duration($video_id);
                    }
                    
                    
$messages[] = 'Duration generated for selected video(s)!';
                } elseif (
$action == 'mobile') {
                    if (
$this->convert_mobile_already()) {
                        
$warnings[]    = 'Mobile conversion already running!';
                    } else {
                        
$this->convert_mobile($ids);
                        
$messages[]    = 'Selected videos are being converted to mobile in the background!';
                    }
                } elseif (
$action == 'categorize') {
                    
$this->categorize($ids$categories);
                } elseif (
$action == 'synonyms') {
                    
$this->synonyms($ids);
                } else {
                    
$errors[] = 'Invalid action! What exactly did you select!?';
                }
            } else {
                
$errors[] = 'Please select at least one video!';
            }
        }
        
        
$page            = (isset($_GET['page']) && is_numeric($_GET['page'])) ? (int) $_GET['page'] : 1;

        
$reset            FALSE;
        if (isset(
$_GET['c']) && is_numeric($_GET['c'])) {
            
$this->option['category'] = (int) $_GET['c'];
            
$reset        TRUE;
        }
        
        if (isset(
$_GET['f']) && is_numeric($_GET['f'])) {
            
$this->option['flagged'] = (string) intval($_GET['f']);
            
$submenu 'video_flagged';
            
$reset        TRUE;
        }

        if (isset(
$_GET['s']) && is_numeric($_GET['s'])) {
            
$this->option['status'] = (string) intval($_GET['s']);
            
$submenu 'video_approve';
            
$reset        TRUE;
        }
        
        if (isset(
$_GET['u'])) {
            
$this->option['username'] = (string) trim($_GET['u']);
            
$reset        TRUE;
        }
        
        if (isset(
$_GET['t'])) {
            
$this->option['channel'] = (string) trim($_GET['t']);
            
$reset        TRUE;
        }
        
        
$submenu    'video_manage';
        if (!isset(
$_POST['submit_reset']) && !isset($_GET['r']) && !$reset) {
            if (isset(
$_SESSION['search_video_option'])) {
                
$option $_SESSION['search_video_option'];
                  if (
array_diff_assoc($this->option$option)) {
                      
$warnings[] = 'Results are selected based on your search criteria/options! If you want to see all results please reset the current search!';
                      
$this->option $option;
                  }
            }
        }        
        
        
$search         $this->search_videos();
        
$videos_total   $this->db->get_field($search['sql_count'], 'total_videos');
        
$pagination     VPagination::get($page$videos_total$search['display']);
        
$videos         $this->db->get_rows($search['sql']." LIMIT ".$pagination['limit']);
        
        
$tpl VF::factory('template');
        
$tpl->menu            'video';
        
$tpl->submenu        $submenu;
        
$tpl->meta_title    'Admin::Video::Manage';
        
$tpl->option        $this->option;
        
$tpl->mserver        = ($this->vcfg['multi_server'] == '1') ? TRUE FALSE;
        
$tpl->errors        $errors;
        
$tpl->messages        $messages;
        
$tpl->warnings        $warnings;
        
$tpl->statuses        $statuses;
        
$tpl->reasons        $reasons;
        
$tpl->categories    $categories;

        
$tpl->servers        VModel::load('server''video'true)->servers();      
        
$tpl->channels      VModel::load('channel''channel'true)->channels(
            array(
'c.channel_id''c.name'),
            array(
'sort' => 'c.name''order' => 'ASC')
        );
        
        
$tpl->videos        $videos;
        
$tpl->pagination    $pagination;
        
$tpl->advs            $this->get_video_advs();
        
$tpl->load(array('header''video_manage''footer'));
        
$tpl->display();
    }
    
    private function 
get_video_categories()
    {
        
$this->db->query("SELECT cat_id, parent_id, name, auto_term
                          FROM #__video_categories
                          ORDER BY slug ASC"
);
        
        return 
$this->db->fetch_rows();
    }
    
    private function 
get_video_advs()
    {
        return 
$this->db->get_rows("SELECT a.adv_id, a.adv_name
                                    FROM #__adv_groups AS g
                                    INNER JOIN #__adv AS a ON (a.adv_group_id = g.adv_group_id AND a.status = '1')
                                    WHERE g.adv_group_slug = 'video-player'
                                    ORDER BY a.adv_name ASC"
);
    }
    
    private function 
search_videos()
    {
        
$sql        "SELECT v.*, u.username, f.reason, s.server_name,
                              GROUP_CONCAT(vc.cat_id) aS category,
                              GROUP_CONCAT(c.name) AS name
                       FROM #__video AS v
                       LEFT JOIN #__video_category AS vc ON (vc.video_id = v.video_id)
                       LEFT JOIN #__video_categories AS c ON (c.cat_id = vc.cat_id)
                       LEFT JOIN #__video_flags AS f ON (f.video_id = v.video_id)
                       LEFT JOIN #__user AS u ON (u.user_id = v.user_id)
                       LEFT JOIN #__server AS s ON (s.server_id = v.server)"
;
        
$sql_count    "SELECT COUNT(*) AS total_videos
                       FROM #__video AS v"
;
        
        
$sql_add    ' WHERE';
        if (isset(
$_POST['submit_search'])) {
            
$this->option['title']        = $this->filter->get('title');
            
$this->option['tags']        = $this->filter->get('tags');
            
$this->option['username']    = $this->filter->get('username');
            
$this->option['category']    = $this->filter->get('category');
            
$this->option['flagged']    = $this->filter->get('flagged');
            
$this->option['status']        = $this->filter->get('status');
            
$this->option['video_id']    = $this->filter->get('video_id');
            
$this->option['method']        = $this->filter->get('method');
            
$this->option['server']        = $this->filter->get('server');
            
$this->option['ext']        = $this->filter->get('ext');
            
$this->option['mobile']        = $this->filter->get('mobile');
            
$this->option['channel']    = $this->filter->get('channel');
            
$this->option['add_time']    = $this->filter->get('add_time');
            
$this->option['sort']        = $this->filter->get('sort');
            
$this->option['order']        = $this->filter->get('order');
            
$this->option['display']    = (int) trim($_POST['display']);
        }

        if (
$this->option['category'] != '') {
            
$sql        .= $sql_add." vc.cat_id = ".(int) $this->option['category'];
            
$sql_count     "SELECT COUNT(DISTINCT v.video_id) AS total_videos
                            FROM #__video AS v
                            LEFT JOIN #__video_category AS vc ON (vc.video_id = v.video_id)"
;
            
$sql_count    .= $sql_add." vc.cat_id = ".(int) $this->option['category'];
            
$sql_add     ' AND';
        }
        
        if (
$this->option['video_id'] != '') {
            
$sql        .= $sql_add." v.video_id = ".(int) $this->option['video_id'];
            
$sql_count    .= $sql_add." v.video_id = ".(int) $this->option['video_id'];
            
$sql_add     ' AND';
        }
                
        if (
$this->option['mobile'] != '') {
            
$sql        .= $sql_add." v.mobile = '".(int) $this->option['mobile']."'";
            
$sql_count    .= $sql_add." v.mobile = '".(int) $this->option['mobile']."'";
            
$sql_add     ' AND';
        }

        if (
$this->option['title'] != '') {
            
$sql        .= $sql_add." v.title LIKE '%".$this->db->escape($this->option['title'])."%'";
            
$sql_count    .= $sql_add." v.title LIKE '%".$this->db->escape($this->option['title'])."%'";
            
$sql_add     ' AND';
        }
        
        if (
$this->option['channel'] != '') {
            
$sql        .= $sql_add." v.channel_id = ".(int) $this->option['channel_id'];
            
$sql_count    .= $sql_add." v.channel_id = ".(int) $this->option['channel_id'];
            
$sql_add     ' AND';
        }

        if (
$this->option['server'] != '') {
            
$sql        .= $sql_add." v.server = ".(int) $this->option['server'];
            
$sql_count    .= $sql_add." v.server = ".(int) $this->option['server'];
            
$sql_add     ' AND';
        }
        
        if (
$this->option['username'] != '') {
            
$this->db->query("SELECT user_id FROM #__user WHERE username = '".$this->db->escape($this->option['username'])."' LIMIT 1");
            if (
$this->db->affected_rows()) {
                
$user_id $this->db->fetch_field('user_id');
                
$sql        .= $sql_add." v.user_id = ".$user_id;
                
$sql_count    .= $sql_add." v.user_id = ".$user_id;
                
$sql_add     ' AND';
            }
        }
        
        if (
$this->option['flagged'] != '') {
            
$sql        .= $sql_add." v.flagged = '".(int) $this->option['flagged']."'";
            
$sql_count    .= $sql_add." v.flagged = '".(int) $this->option['flagged']."'";
            
$sql_add     ' AND';
        }
        
        if (
$this->option['status'] != '') {
            
$sql        .= $sql_add." v.status = ".(int) $this->option['status'];
            
$sql_count    .= $sql_add." v.status = ".(int) $this->option['status'];
            
$sql_add     ' AND';
        }
        
        if (
$this->option['ext'] != '') {
            if (
$this->option['ext'] == 'hd') {
                
$sql        .= $sql_add." v.hd = 1";
                
$sql_count    .= $sql_add." v.hd = 1";
                
$sql_add     ' AND';                
            } else {
                
$sql        .= $sql_add." v.ext = '".$this->db->escape($this->option['ext'])."' AND v.embed_code = ''";
                
$sql_count    .= $sql_add." v.ext = '".$this->db->escape($this->option['ext'])."' AND v.embed_code = ''";
                
$sql_add     ' AND';
            }
        }
        
        if (
$this->option['method'] != '') {
            if (
$this->option['method'] == 'hosted') {
                
$sql        .= $sql_add." v.embed_code = '' AND v.url = ''";
                
$sql_count    .= $sql_add." v.embed_code = '' AND v.url = ''";
                
$sql_add     ' AND';                
            } elseif (
$this->option['method'] == 'hotlink') {
                
$sql        .= $sql_add." v.url != ''";
                
$sql_count    .= $sql_add." v.url != ''";
                
$sql_add     ' AND';                
            } elseif (
$this->option['method'] == 'embed') {
                
$sql        .= $sql_add." v.embed_code != ''";
                
$sql_count    .= $sql_add." v.embed_code != ''";
                
$sql_add     ' AND';                
            }
        }
        
        if (
$this->option['add_time'] != '') {
            if (
$this->option['add_time'] == 'today') {
                  
$start_time  strtotime('today');
                
$end_time    $start_time+86400;
                
$sql        .= $sql_add." v.add_time > ".$start_time." AND v.add_time < ".$end_time;
                
$sql_count  .= $sql_add." v.add_time > ".$start_time." AND v.add_time < ".$end_time;
                
$sql_add     ' AND';
            } elseif (
$this->option['add_time'] == 'yesterday') {
                
$start_time  strtotime('yesterday');
                
$end_time    $start_time+86400;
                
$sql        .= $sql_add." v.add_time > ".$start_time." AND v.add_time < ".$end_time;
                
$sql_count  .= $sql_add." v.add_time > ".$start_time." AND v.add_time < ".$end_time;            
                
$sql_add     ' AND';
            } elseif (
$this->option['add_time'] == 'week') {
                
$now         time();
                
$start_time = (date('w'$now) === 1) ? strtotime('today'$now) : strtotime('last Monday'$now);
                
$sql        .= $sql_add." v.add_time > ".$start_time;
                
$sql_count  .= $sql_add." AND v.add_time > ".$start_time;
                
$sql_add     ' AND';
            } elseif (
$this->option['add_time'] == 'month') {
                
$start_time strtotime('first day of '.date('F Y'));
                
$sql        .= $sql_add." v.add_time > ".$start_time;
                
$sql_count  .= $sql_add." v.add_time > ".$start_time;
                
$sql_add     ' AND';
            } elseif (
$this->option['add_time'] == 'year') {
                
$start_time strtotime(date('Y').'-01-01');
                
$sql        .= $sql_add." v.add_time > ".$start_time;
                
$sql_count  .= $sql_add." v.add_time > ".$start_time;            
            }
        }
        
        
$_SESSION['search_video_option'] = $this->option;
        
        return array(
            
'sql' => $sql" GROUP BY v.video_id ORDER BY ".$this->option['sort']." ".$this->option['order'],
            
'sql_count' => $sql_count,
            
'display' => $this->option['display']
        );
    }

    private function 
get_checkbox_ids()
    {
        
$ids = array();
        foreach (
$_POST as $key => $value) {
            if (
strpos($key'checkbox_video_') !== FALSE) {
                
$ids[] = (int) str_replace('checkbox_video_'''$key);
            }
        }
            
        return 
$ids;
    }
    
    private function 
generate_duration($video_id)
    {
          
VHelper::load('module.video.manage');
          
VHelper_video_manage::duration($video_id);
    }
    
    private function 
generate_thumbs($video_id)
    {
          
VHelper::load('module.video.manage');
          
VHelper_video_manage::thumbs($video_id);
    }
    
    private function 
convert_mobile($ids)
    {
          
$cmd    VF::cfg_item('php_cli_path').' '.BASE_DIR.'/modules/video/scripts/mobile.php '.implode(' '$ids);
          
exec(escapeshellcmd($cmd). ' >/dev/null &');
    }
    
    private function 
convert_mobile_already()
    {
          
$cmd_convert    VF::cfg_item('php_cli_path').' '.BASE_DIR.'/modules/video/scripts/mobile.php';
          
$cmd        "ps ax | grep '".$cmd_convert."' | grep -v grep";
          
exec($cmd$output);
          return (isset(
$output['0'])) ? true false;    
    }
    
    private function 
categorize($ids$categories)
    {
          
$this->db->query("
              SELECT v.video_id, v.title, v.description,
                     GROUP_CONCAT(t.name) AS tags,
                     GROUP_CONCAT(c.cat_id) AS categories
              FROM #__video AS v
              LEFT JOIN #__video_tags AS t ON (t.video_id = v.video_id)
              LEFT JOIN #__video_category AS c ON (c.video_id = v.video_id)
              WHERE v.video_id IN ("
.implode(','array_values($ids)).")
              GROUP BY v.video_id
          "
);
          
          
$videos        $this->db->fetch_rows();
          
          foreach (
$videos as $video) {
              
$matched        = array();
              
$video_id        = (int) $video['video_id'];
              
$current        explode(','$video['categories']);
              
$title            $video['title'];
              
$description    $video['description'];
              
$tags            explode(','$video['tags']);
              
              foreach (
$categories as $category) {
                  
$cat_id        = (int) $category['cat_id'];
                  
$keywords    explode(','$category['auto_term']);
                  
                  foreach (
$keywords as $keyword) {
                      
$keyword    trim($keyword);
                      
                      if (
stripos($title$keyword) !== false) {
                          if (!
in_array($cat_id$matched)) {
                              
$matched[] = $cat_id;
                          }
                      }
                      
                      if (
$description != '') {
                          if (
stripos($description$keyword) !== false) {
                              if (!
in_array($cat_id$matched)) {
                                  
$matched[] = $cat_id;
                              }
                          }
                      }
                      
                      if (
$tags) {
                          foreach (
$tags as $tag) {
                              if (
stripos(trim($tag), $keyword) !== false) {
                                  if (!
in_array($cat_id$matched)) {
                                      
$matched[] = $cat_id;
                                  }
                              }
                          }
                      }
                  }
              }
              
              
$matched    array_flip($matched);
              
$current    array_flip($current);
              
              foreach (
$matched as $cat_id => $value) {
                  if (isset(
$current[$cat_id])) {
                      unset(
$matched[$cat_id]);
                      unset(
$current[$cat_id]);
                  }
              }
              
              if (
$matched) {
                  foreach (
$matched as $cat_id => $value) {
                      
$this->db->query("
                          INSERT INTO #__video_category
                          SET cat_id = "
.$cat_id.",
                              video_id = "
.$video_id
                      
);
                      
                      
$this->db->query("
                          UPDATE #__video_categories
                          SET total_videos = total_videos+1
                          WHERE cat_id = "
.$cat_id."
                          LIMIT 1
                      "
);
                  }                  
              }
              
              if (
$current) {
                  foreach (
$current as $cat_id => $value) {
                      
$this->db->query("
                          DELETE FROM #__video_category
                          WHERE cat_id = "
.$cat_id."
                          AND video_id = "
.$video_id."
                          LIMIT 1"
                      
);
                      
                      
$this->db->query("
                          UPDATE #__video_categories
                          SET total_videos = total_videos-1
                          WHERE cat_id = "
.$cat_id."
                          LIMIT 1
                      "
);
                  }
              }              
          }                    
    }
    
    private function 
synonyms($ids)
    {
          
VHelper::load('module.video.synonyms');

          
$this->db->query("
              SELECT v.video_id, v.title, v.slug, v.description
              FROM #__video AS v
              WHERE v.video_id IN ("
.implode(','array_values($ids)).")
          "
);
          
          
$videos        $this->db->fetch_rows();
          
$max_length    VCfg::get('video.slug_max_length');
          
          foreach (
$videos as $video) {
              
$title            VHelper_video_synonyms::process($video['title']);
              
$slug            = ($title != $video['title']) ? prepare_string($titletrue$max_length) : $video['slug']; 
              
$description    = ($video['description'] != '') ? VHelper_video_synonyms::process($video['description']) : '';
              
              if (
$title == $video['title'] && $description == $video['description']) {
                  continue;
              }
              
              
$this->db->query("
                  UPDATE #__video
                  SET title = '"
.$this->db->escape($title)."',
                      slug = '"
.$this->db->escape($slug)."',
                      description = '"
.$this->db->escape($description)."'
                  WHERE video_id = "
.(int) $video['video_id']."
                  LIMIT 1
              "
);
          }
    }
}
?>
Онлайн: 1
Реклама