Ignore:
Timestamp:
Feb 18, 2013, 12:20:10 PM (11 years ago)
Author:
mistic100
Message:
  • add support for semi-private Vimeo videos
  • escape tags
  • compatible with safe_mode=On
  • deactivate autosize
File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/gvideo/admin/add.php

    r19213 r20804  
    77if (isset($_POST['add_video']))
    88{
     9  $_POST['url'] = trim($_POST['url']);
    910  // check inputs
    1011  if (empty($_POST['url']))
     
    1213    array_push($page['errors'], l10n('Please fill the video URL'));
    1314  }
    14   if ( !empty($_POST['url']) and ($video = parse_video_url($_POST['url'], isset($_POST['safe_mode']))) === false )
     15  else if ( ($video = parse_video_url($_POST['url'], isset($_POST['safe_mode']))) === false )
    1516  {
    1617    if (isset($_POST['safe_mode']))
     
    2829  if (count($page['errors']) == 0)
    2930  {
    30     // download thumbnail
    31     $thumb_ext = empty($video['thumbnail']) ? 'jpg' : get_extension($video['thumbnail']);
    32     $thumb_name = $video['type'].'-'.$video['video_id'].'-'.uniqid().'.'.$thumb_ext;
    33     $thumb_source = $conf['data_location'].$thumb_name;
    34     if ( empty($video['thumbnail']) or download_remote_file($video['thumbnail'], $thumb_source) !== true )
    35     {
    36       $thumb_source = $conf['data_location'].get_filename_wo_extension($thumb_name).'.jpg';
    37       copy(GVIDEO_PATH.'mimetypes/'.$video['type'].'.jpg', $thumb_source);
    38     }
    39    
    40     if (isset($_POST['add_film_frame']))
    41     {
    42       add_film_frame($thumb_source);
    43     }
    44    
    45     // add image and update infos
    46     $image_id = add_uploaded_file($thumb_source, $thumb_name, array($_POST['category']));
    47    
    48     $updates = array(
    49       'name' => pwg_db_real_escape_string($video['title']),
    50       'author' => pwg_db_real_escape_string($video['author']),
    51       'is_gvideo' => 1,
    52       );
    53      
    54     if ( $_POST['sync_description'] and !empty($video['description']) )
    55     {
    56       $updates['comment'] = pwg_db_real_escape_string($video['description']);
    57     }
    58     if ( $_POST['sync_tags'] and !empty($video['tags']) )
    59     {
    60       set_tags(get_tag_ids(implode(',', $video['tags'])), $image_id);
    61     }
    62    
    63     single_update(
    64       IMAGES_TABLE,
    65       $updates,
    66       array('id' => $image_id),
    67       true
    68       );
    69    
    70     // register video
    7131    if ($_POST['size_common'] == 'true')
    7232    {
     
    8242      $_POST['autoplay'] = '';
    8343    }
     44    $_POST['add_film_frame'] = isset($_POST['add_film_frame']);
    8445   
    85     $insert = array(
    86       'picture_id' => $image_id,
    87       'url' => $video['url'],
    88       'type' => $video['type'],
    89       'video_id' => $video['video_id'],
    90       'width' => $_POST['width'],
    91       'height' => $_POST['height'],
    92       'autoplay' => $_POST['autoplay'],
    93       );
    94      
    95     single_insert(
    96       GVIDEO_TABLE,
    97       $insert
    98       );
    99      
     46   
     47    $image_id = add_video($video, $_POST);
     48   
     49   
    10050    $query = '
    10151SELECT id, name, permalink
     
    13787  get_ini_size('post_max_filesize', false);
    13888 
     89if (!isset($_POST['safe_mode']))
     90{
     91  $_POST['safe_mode'] = !test_remote_download();
     92}
     93
    13994// template
    14095$template->assign(array(
Note: See TracChangeset for help on using the changeset viewer.