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

Last change on this file since 26470 was 26470, checked in by mistic100, 10 years ago

Update for Piwigo 2.6
TODO: button on Admin Tools bar

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