source: extensions/gvideo/admin/add.php @ 23801

Last change on this file since 23801 was 20804, checked in by mistic100, 12 years ago
  • add support for semi-private Vimeo videos
  • escape tags
  • compatible with safe_mode=On
  • deactivate autosize
File size: 2.8 KB
Line 
1<?php
2if (!defined('GVIDEO_PATH')) die('Hacking attempt!');
3
4include_once(GVIDEO_PATH.'include/functions.inc.php');
5include_once(PHPWG_ROOT_PATH . 'admin/include/functions_upload.inc.php');
6
7if (isset($_POST['add_video']))
8{
9  $_POST['url'] = trim($_POST['url']);
10  // check inputs
11  if (empty($_POST['url']))
12  {
13    array_push($page['errors'], l10n('Please fill the video URL'));
14  }
15  else if ( ($video = parse_video_url($_POST['url'], isset($_POST['safe_mode']))) === false )
16  {
17    if (isset($_POST['safe_mode']))
18    {
19      array_push($page['errors'], l10n('an error happened'));
20    }
21    else
22    {
23      array_push($page['errors'], l10n('Unable to contact host server'));
24      array_push($page['errors'], l10n('Try in safe-mode'));
25    }
26    $_POST['safe_mode'] = true;
27  }
28 
29  if (count($page['errors']) == 0)
30  {
31    if ($_POST['size_common'] == 'true')
32    {
33      $_POST['width'] = $_POST['height'] = '';
34    }
35    else if ( !preg_match('#^([0-9]+)$#', $_POST['width']) or !preg_match('#^([0-9]+)$#', $_POST['height']) )
36    {
37      array_push($page['errors'], l10n('Width and height must be integers'));
38      $_POST['width'] = $_POST['height'] = '';
39    }
40    if ($_POST['autoplay_common'] == 'true')
41    {
42      $_POST['autoplay'] = '';
43    }
44    $_POST['add_film_frame'] = isset($_POST['add_film_frame']);
45   
46   
47    $image_id = add_video($video, $_POST);
48   
49   
50    $query = '
51SELECT id, name, permalink
52  FROM '.CATEGORIES_TABLE.'
53  WHERE id = '.$_POST['category'].'
54;';
55    $category = pwg_db_fetch_assoc(pwg_query($query));
56     
57    array_push($page['infos'], sprintf(
58      l10n('Video successfully added. <a href="%s">View</a>'), 
59      make_picture_url(array(
60        'image_id' => $image_id,
61        'category' => array(
62          'id' => $category['id'],
63          'name' => $category['name'],
64          'permalink' => $category['permalink'],
65          ),
66        ))
67      ));
68    unset($_POST);
69  }
70}
71
72// categories
73$query = '
74SELECT id,name,uppercats,global_rank
75  FROM '.CATEGORIES_TABLE.'
76;';
77display_select_cat_wrapper($query, array(), 'category_parent_options');
78
79// upload limit
80$upload_max_filesize = min(
81  get_ini_size('upload_max_filesize'),
82  get_ini_size('post_max_size')
83  );
84$upload_max_filesize_shorthand = 
85  ($upload_max_filesize == get_ini_size('upload_max_filesize')) ?
86  get_ini_size('upload_max_filesize', false) :
87  get_ini_size('post_max_filesize', false);
88 
89if (!isset($_POST['safe_mode']))
90{
91  $_POST['safe_mode'] = !test_remote_download();
92}
93
94// template
95$template->assign(array(
96  'upload_max_filesize' => $upload_max_filesize,
97  'upload_max_filesize_shorthand' => $upload_max_filesize_shorthand,
98  'gd_available' => function_exists('imagecreatetruecolor'),
99  'gvideo' => $conf['gvideo'],
100  'POST' => @$_POST,
101  ));
102
103$template->set_filename('gvideo_content', dirname(__FILE__) . '/template/add.tpl');
104
105?>
Note: See TracBrowser for help on using the repository browser.