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 | 'is_gvideo' => 1, |
---|
43 | ); |
---|
44 | |
---|
45 | single_update( |
---|
46 | IMAGES_TABLE, |
---|
47 | $updates, |
---|
48 | array('id' => $image_id), |
---|
49 | true |
---|
50 | ); |
---|
51 | |
---|
52 | // register video |
---|
53 | if ($_POST['size_common'] == 'true') |
---|
54 | { |
---|
55 | $_POST['width'] = $_POST['height'] = ''; |
---|
56 | } |
---|
57 | if ($_POST['autoplay_common'] == 'true') |
---|
58 | { |
---|
59 | $_POST['autoplay'] = ''; |
---|
60 | } |
---|
61 | |
---|
62 | $insert = array( |
---|
63 | 'picture_id' => $image_id, |
---|
64 | 'url' => $video['url'], |
---|
65 | 'type' => $video['type'], |
---|
66 | 'video_id' => $video['id'], |
---|
67 | 'width' => $_POST['width'], |
---|
68 | 'height' => $_POST['height'], |
---|
69 | 'autoplay' => $_POST['autoplay'], |
---|
70 | ); |
---|
71 | |
---|
72 | single_insert( |
---|
73 | GVIDEO_TABLE, |
---|
74 | $insert |
---|
75 | ); |
---|
76 | |
---|
77 | $query = ' |
---|
78 | SELECT id, name, permalink |
---|
79 | FROM '.CATEGORIES_TABLE.' |
---|
80 | WHERE id = '.$_POST['category'].' |
---|
81 | ;'; |
---|
82 | $category = pwg_db_fetch_assoc(pwg_query($query)); |
---|
83 | |
---|
84 | array_push($page['infos'], sprintf( |
---|
85 | l10n('Video successfully added. <a href="%s">View</a>'), |
---|
86 | make_picture_url(array( |
---|
87 | 'image_id' => $image_id, |
---|
88 | 'category' => array( |
---|
89 | 'id' => $category['id'], |
---|
90 | 'name' => $category['name'], |
---|
91 | 'permalink' => $category['permalink'], |
---|
92 | ), |
---|
93 | )) |
---|
94 | )); |
---|
95 | unset($_POST); |
---|
96 | } |
---|
97 | } |
---|
98 | |
---|
99 | // categories |
---|
100 | $query = ' |
---|
101 | SELECT id,name,uppercats,global_rank |
---|
102 | FROM '.CATEGORIES_TABLE.' |
---|
103 | ;'; |
---|
104 | display_select_cat_wrapper($query, array(), 'category_parent_options'); |
---|
105 | |
---|
106 | // upload limit |
---|
107 | $upload_max_filesize = min( |
---|
108 | get_ini_size('upload_max_filesize'), |
---|
109 | get_ini_size('post_max_size') |
---|
110 | ); |
---|
111 | $upload_max_filesize_shorthand = |
---|
112 | ($upload_max_filesize == get_ini_size('upload_max_filesize')) ? |
---|
113 | get_ini_size('upload_max_filesize', false) : |
---|
114 | get_ini_size('post_max_filesize', false); |
---|
115 | |
---|
116 | // template |
---|
117 | $template->assign(array( |
---|
118 | 'upload_max_filesize' => $upload_max_filesize, |
---|
119 | 'upload_max_filesize_shorthand' => $upload_max_filesize_shorthand, |
---|
120 | 'gd_available' => function_exists('imagecreatetruecolor'), |
---|
121 | 'gvideo' => $conf['gvideo'], |
---|
122 | 'POST' => @$_POST, |
---|
123 | )); |
---|
124 | |
---|
125 | $template->set_filename('gvideo_content', dirname(__FILE__) . '/template/add.tpl'); |
---|
126 | |
---|
127 | ?> |
---|