1 | <?php |
---|
2 | if (!defined('GVIDEO_PATH')) die('Hacking attempt!'); |
---|
3 | |
---|
4 | include_once(GVIDEO_PATH.'include/functions.inc.php'); |
---|
5 | include_once(PHPWG_ROOT_PATH . 'admin/include/functions_upload.inc.php'); |
---|
6 | |
---|
7 | if (isset($_POST['add_video'])) |
---|
8 | { |
---|
9 | // check inputs |
---|
10 | if (empty($_POST['url'])) |
---|
11 | { |
---|
12 | array_push($page['errors'], l10n('Please fill the video URL')); |
---|
13 | } |
---|
14 | if ( !empty($_POST['url']) and ($video = parse_video_url($_POST['url'])) === false ) |
---|
15 | { |
---|
16 | array_push($page['errors'], l10n('Unable to contact host server')); |
---|
17 | } |
---|
18 | |
---|
19 | if (count($page['errors']) == 0) |
---|
20 | { |
---|
21 | // download thumbnail |
---|
22 | $thumb_name = $video['type'].'-'.$video['id'].'-'.uniqid().'.'.get_extension($video['thumbnail']); |
---|
23 | $thumb_source = $conf['data_location'].$thumb_name; |
---|
24 | if (download_remote_file($video['thumbnail'], $thumb_source) !== true) |
---|
25 | { |
---|
26 | $thumb_source = $conf['data_location'].get_filename_wo_extension($thumb_name).'.jpg'; |
---|
27 | copy(GVIDEO_PATH.'mimetypes/'.$video['type'].'.jpg', $thumb_source); |
---|
28 | } |
---|
29 | |
---|
30 | if (isset($_POST['add_film_frame'])) |
---|
31 | { |
---|
32 | add_film_frame($thumb_source); |
---|
33 | } |
---|
34 | |
---|
35 | // add image and update infos |
---|
36 | $image_id = add_uploaded_file($thumb_source, $thumb_name, array($_POST['category'])); |
---|
37 | |
---|
38 | $updates = array( |
---|
39 | 'name' => pwg_db_real_escape_string($video['title']), |
---|
40 | 'comment' => pwg_db_real_escape_string($video['description']), |
---|
41 | 'author' => pwg_db_real_escape_string($video['author']), |
---|
42 | ); |
---|
43 | |
---|
44 | single_update( |
---|
45 | IMAGES_TABLE, |
---|
46 | $updates, |
---|
47 | array('id' => $image_id), |
---|
48 | true |
---|
49 | ); |
---|
50 | |
---|
51 | // register video |
---|
52 | if ($_POST['size_common'] == 'true') |
---|
53 | { |
---|
54 | $_POST['width'] = $_POST['height'] = ''; |
---|
55 | } |
---|
56 | if ($_POST['autoplay_common'] == 'true') |
---|
57 | { |
---|
58 | $_POST['autoplay'] = ''; |
---|
59 | } |
---|
60 | |
---|
61 | $insert = array( |
---|
62 | 'picture_id' => $image_id, |
---|
63 | 'url' => $video['url'], |
---|
64 | 'type' => $video['type'], |
---|
65 | 'video_id' => $video['id'], |
---|
66 | 'width' => $_POST['width'], |
---|
67 | 'height' => $_POST['height'], |
---|
68 | 'autoplay' => $_POST['autoplay'], |
---|
69 | ); |
---|
70 | |
---|
71 | single_insert( |
---|
72 | GVIDEO_TABLE, |
---|
73 | $insert |
---|
74 | ); |
---|
75 | |
---|
76 | array_push($page['infos'], sprintf( |
---|
77 | l10n('Video successfully added. <a href="%s">View</a>'), |
---|
78 | make_picture_url(array( |
---|
79 | 'image_id' => $image_id, |
---|
80 | 'category' => array( |
---|
81 | 'id' => $_POST['category'], |
---|
82 | 'name' => '', |
---|
83 | 'permalink' => '', |
---|
84 | ), |
---|
85 | )) |
---|
86 | )); |
---|
87 | unset($_POST); |
---|
88 | } |
---|
89 | } |
---|
90 | |
---|
91 | // categories |
---|
92 | $query = ' |
---|
93 | SELECT id,name,uppercats,global_rank |
---|
94 | FROM '.CATEGORIES_TABLE.' |
---|
95 | ;'; |
---|
96 | display_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 | |
---|
108 | // template |
---|
109 | $template->assign(array( |
---|
110 | 'upload_max_filesize' => $upload_max_filesize, |
---|
111 | 'upload_max_filesize_shorthand' => $upload_max_filesize_shorthand, |
---|
112 | 'gd_available' => function_exists('imagecreatetruecolor'), |
---|
113 | 'gvideo' => $conf['gvideo'], |
---|
114 | 'POST' => @$_POST, |
---|
115 | )); |
---|
116 | |
---|
117 | $template->set_filename('gvideo_content', dirname(__FILE__) . '/template/add.tpl'); |
---|
118 | |
---|
119 | ?> |
---|