[17307] | 1 | <?php |
---|
[26470] | 2 | defined('GVIDEO_PATH') or die('Hacking attempt!'); |
---|
[17307] | 3 | |
---|
| 4 | include_once(GVIDEO_PATH.'include/functions.inc.php'); |
---|
| 5 | include_once(PHPWG_ROOT_PATH . 'admin/include/functions_upload.inc.php'); |
---|
| 6 | |
---|
[26470] | 7 | |
---|
[17307] | 8 | if (isset($_POST['add_video'])) |
---|
| 9 | { |
---|
[20804] | 10 | $_POST['url'] = trim($_POST['url']); |
---|
[28268] | 11 | $_POST['add_film_frame'] = isset($_POST['add_film_frame']); |
---|
| 12 | |
---|
| 13 | if ($_POST['mode'] == 'provider') |
---|
[17307] | 14 | { |
---|
[28268] | 15 | // check inputs |
---|
| 16 | if (empty($_POST['url'])) |
---|
[19213] | 17 | { |
---|
[28268] | 18 | $page['errors'][] = l10n('Please fill the video URL'); |
---|
[19213] | 19 | } |
---|
[29627] | 20 | else if ( ($video = parse_video_url($_POST['url'], $safe_mode)) === false ) |
---|
[19213] | 21 | { |
---|
[29627] | 22 | $page['errors'][] = l10n('an error happened'); |
---|
| 23 | } |
---|
| 24 | else |
---|
| 25 | { |
---|
| 26 | if ($safe_mode === true) |
---|
[28268] | 27 | { |
---|
[29627] | 28 | $page['warnings'][] = l10n('Unable to contact host server'); |
---|
| 29 | $page['warnings'][] = l10n('Video data like description and thumbnail might be missing'); |
---|
[28268] | 30 | } |
---|
[29627] | 31 | |
---|
[28268] | 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); |
---|
[17383] | 47 | } |
---|
[28268] | 48 | } |
---|
| 49 | else |
---|
| 50 | { |
---|
| 51 | $_POST['embed_code'] = trim($_POST['embed_code']); |
---|
| 52 | |
---|
| 53 | if (empty($_POST['embed_code'])) |
---|
[19056] | 54 | { |
---|
[28268] | 55 | $page['errors'][] = l10n('Please fill the embed code'); |
---|
[19056] | 56 | } |
---|
[28268] | 57 | else |
---|
[17383] | 58 | { |
---|
[28268] | 59 | $image_id = add_video_embed($_POST); |
---|
[17383] | 60 | } |
---|
[28268] | 61 | } |
---|
| 62 | |
---|
| 63 | if (isset($image_id)) |
---|
| 64 | { |
---|
[17432] | 65 | $query = ' |
---|
| 66 | SELECT id, name, permalink |
---|
| 67 | FROM '.CATEGORIES_TABLE.' |
---|
| 68 | WHERE id = '.$_POST['category'].' |
---|
| 69 | ;'; |
---|
| 70 | $category = pwg_db_fetch_assoc(pwg_query($query)); |
---|
| 71 | |
---|
[26470] | 72 | $page['infos'][] = l10n( |
---|
| 73 | 'Video successfully added. <a href="%s">View</a>', |
---|
[17383] | 74 | make_picture_url(array( |
---|
| 75 | 'image_id' => $image_id, |
---|
| 76 | 'category' => array( |
---|
[17432] | 77 | 'id' => $category['id'], |
---|
| 78 | 'name' => $category['name'], |
---|
| 79 | 'permalink' => $category['permalink'], |
---|
[17383] | 80 | ), |
---|
| 81 | )) |
---|
[26470] | 82 | ); |
---|
[17383] | 83 | unset($_POST); |
---|
[17307] | 84 | } |
---|
| 85 | } |
---|
| 86 | |
---|
| 87 | // categories |
---|
| 88 | $query = ' |
---|
[26470] | 89 | SELECT id, name, uppercats, global_rank |
---|
[17307] | 90 | FROM '.CATEGORIES_TABLE.' |
---|
| 91 | ;'; |
---|
| 92 | display_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 | |
---|
[20804] | 104 | if (!isset($_POST['safe_mode'])) |
---|
| 105 | { |
---|
| 106 | $_POST['safe_mode'] = !test_remote_download(); |
---|
| 107 | } |
---|
| 108 | |
---|
[17307] | 109 | // template |
---|
| 110 | $template->assign(array( |
---|
| 111 | 'upload_max_filesize' => $upload_max_filesize, |
---|
| 112 | 'upload_max_filesize_shorthand' => $upload_max_filesize_shorthand, |
---|
[17383] | 113 | 'gd_available' => function_exists('imagecreatetruecolor'), |
---|
[17307] | 114 | 'gvideo' => $conf['gvideo'], |
---|
| 115 | 'POST' => @$_POST, |
---|
| 116 | )); |
---|
| 117 | |
---|
[26470] | 118 | $template->set_filename('gvideo_content', realpath(GVIDEO_PATH . 'admin/template/add.tpl')); |
---|