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

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

allow to add any video with direct embed code + add batch manager filter

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