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

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

remove "safe mode" checkbox, now fully automatic

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'], $safe_mode)) === false )
21    {
22      $page['errors'][] = l10n('an error happened');
23    }
24    else
25    {
26      if ($safe_mode === true)
27      {
28        $page['warnings'][] = l10n('Unable to contact host server');
29        $page['warnings'][] = l10n('Video data like description and thumbnail might be missing');
30      }
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     
46      $image_id = add_video($video, $_POST);
47    }
48  }
49  else
50  {
51    $_POST['embed_code'] = trim($_POST['embed_code']);
52   
53    if (empty($_POST['embed_code']))
54    {
55      $page['errors'][] = l10n('Please fill the embed code');
56    }
57    else
58    {
59      $image_id = add_video_embed($_POST);
60    }
61  }
62 
63  if (isset($image_id))
64  {
65    $query = '
66SELECT id, name, permalink
67  FROM '.CATEGORIES_TABLE.'
68  WHERE id = '.$_POST['category'].'
69;';
70    $category = pwg_db_fetch_assoc(pwg_query($query));
71     
72    $page['infos'][] = l10n(
73      'Video successfully added. <a href="%s">View</a>', 
74      make_picture_url(array(
75        'image_id' => $image_id,
76        'category' => array(
77          'id' => $category['id'],
78          'name' => $category['name'],
79          'permalink' => $category['permalink'],
80          ),
81        ))
82      );
83    unset($_POST);
84  }
85}
86
87// categories
88$query = '
89SELECT id, name, uppercats, global_rank
90  FROM '.CATEGORIES_TABLE.'
91;';
92display_select_cat_wrapper($query, array(), 'category_parent_options');
93
94// upload limit
95$upload_max_filesize = min(
96  get_ini_size('upload_max_filesize'),
97  get_ini_size('post_max_size')
98  );
99$upload_max_filesize_shorthand = 
100  ($upload_max_filesize == get_ini_size('upload_max_filesize')) ?
101  get_ini_size('upload_max_filesize', false) :
102  get_ini_size('post_max_filesize', false);
103 
104if (!isset($_POST['safe_mode']))
105{
106  $_POST['safe_mode'] = !test_remote_download();
107}
108
109// template
110$template->assign(array(
111  'upload_max_filesize' => $upload_max_filesize,
112  'upload_max_filesize_shorthand' => $upload_max_filesize_shorthand,
113  'gd_available' => function_exists('imagecreatetruecolor'),
114  'gvideo' => $conf['gvideo'],
115  'POST' => @$_POST,
116  ));
117
118$template->set_filename('gvideo_content', realpath(GVIDEO_PATH . 'admin/template/add.tpl'));
Note: See TracBrowser for help on using the repository browser.