1 | <?php |
---|
2 | // +-----------------------------------------------------------------------+ |
---|
3 | // | Piwigo - a PHP based photo gallery | |
---|
4 | // +-----------------------------------------------------------------------+ |
---|
5 | // | Copyright(C) 2008-2012 Piwigo Team http://piwigo.org | |
---|
6 | // | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net | |
---|
7 | // | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick | |
---|
8 | // +-----------------------------------------------------------------------+ |
---|
9 | // | This program is free software; you can redistribute it and/or modify | |
---|
10 | // | it under the terms of the GNU General Public License as published by | |
---|
11 | // | the Free Software Foundation | |
---|
12 | // | | |
---|
13 | // | This program is distributed in the hope that it will be useful, but | |
---|
14 | // | WITHOUT ANY WARRANTY; without even the implied warranty of | |
---|
15 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
---|
16 | // | General Public License for more details. | |
---|
17 | // | | |
---|
18 | // | You should have received a copy of the GNU General Public License | |
---|
19 | // | along with this program; if not, write to the Free Software | |
---|
20 | // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
---|
21 | // | USA. | |
---|
22 | // +-----------------------------------------------------------------------+ |
---|
23 | |
---|
24 | if(!defined("PHPWG_ROOT_PATH")) die ("Hacking attempt!"); |
---|
25 | |
---|
26 | |
---|
27 | // +-----------------------------------------------------------------------+ |
---|
28 | // | Basic checks | |
---|
29 | // +-----------------------------------------------------------------------+ |
---|
30 | |
---|
31 | check_status(ACCESS_ADMINISTRATOR); |
---|
32 | |
---|
33 | check_input_parameter('image_id', $_GET, false, PATTERN_ID); |
---|
34 | |
---|
35 | $admin_photo_base_url = get_root_url().'admin.php?page=photo-'.$_GET['image_id']; |
---|
36 | $self_url = GVIDEO_ADMIN.'-photo&image_id='.$_GET['image_id']; |
---|
37 | |
---|
38 | // +-----------------------------------------------------------------------+ |
---|
39 | // | Tabs | |
---|
40 | // +-----------------------------------------------------------------------+ |
---|
41 | include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php'); |
---|
42 | $tabsheet = new tabsheet(); |
---|
43 | $tabsheet->set_id('photo'); |
---|
44 | $tabsheet->select('gvideo'); |
---|
45 | $tabsheet->assign(); |
---|
46 | |
---|
47 | // +-----------------------------------------------------------------------+ |
---|
48 | // | Picture infos | |
---|
49 | // +-----------------------------------------------------------------------+ |
---|
50 | global $gvideo; |
---|
51 | |
---|
52 | $query = ' |
---|
53 | SELECT * |
---|
54 | FROM '.IMAGES_TABLE.' |
---|
55 | WHERE id = '.$_GET['image_id'].' |
---|
56 | ;'; |
---|
57 | $picture = pwg_db_fetch_assoc(pwg_query($query)); |
---|
58 | |
---|
59 | |
---|
60 | // +-----------------------------------------------------------------------+ |
---|
61 | // | Update properties | |
---|
62 | // +-----------------------------------------------------------------------+ |
---|
63 | if (isset($_POST['save_properties'])) |
---|
64 | { |
---|
65 | // check inputs |
---|
66 | if (empty($_POST['url'])) |
---|
67 | { |
---|
68 | array_push($page['errors'], l10n('Please fill the video URL')); |
---|
69 | } |
---|
70 | if ( !empty($_POST['url']) and ($video = parse_video_url($_POST['url'])) === false ) |
---|
71 | { |
---|
72 | array_push($page['errors'], l10n('Unable to contact host server')); |
---|
73 | } |
---|
74 | |
---|
75 | if (count($page['errors']) == 0) |
---|
76 | { |
---|
77 | include_once(GVIDEO_PATH.'include/functions.inc.php'); |
---|
78 | include_once(PHPWG_ROOT_PATH . 'admin/include/functions_upload.inc.php'); |
---|
79 | |
---|
80 | // download thumbnail |
---|
81 | $thumb_name = $video['type'].'-'.$video['id'].'-'.uniqid().'.'.get_extension($video['thumbnail']); |
---|
82 | $thumb_source = $conf['data_location'].$thumb_name; |
---|
83 | if (download_remote_file($video['thumbnail'], $thumb_source) !== true) |
---|
84 | { |
---|
85 | $thumb_source = $conf['data_location'].get_filename_wo_extension($thumb_name).'.jpg'; |
---|
86 | copy(GVIDEO_PATH.'mimetypes/'.$video['type'].'.jpg', $thumb_source); |
---|
87 | } |
---|
88 | |
---|
89 | // add image and update infos |
---|
90 | $image_id = add_uploaded_file($thumb_source, $thumb_name, null, null, $_GET['image_id']); |
---|
91 | |
---|
92 | $updates = array( |
---|
93 | 'name' => pwg_db_real_escape_string($video['title']), |
---|
94 | 'comment' => pwg_db_real_escape_string($video['description']), |
---|
95 | 'author' => pwg_db_real_escape_string($video['author']), |
---|
96 | 'is_gvideo' => 1, |
---|
97 | ); |
---|
98 | |
---|
99 | single_update( |
---|
100 | IMAGES_TABLE, |
---|
101 | $updates, |
---|
102 | array('id' => $_GET['image_id']), |
---|
103 | true |
---|
104 | ); |
---|
105 | |
---|
106 | // register video |
---|
107 | if ($_POST['size_common'] == 'true') |
---|
108 | { |
---|
109 | $_POST['width'] = $_POST['height'] = ''; |
---|
110 | } |
---|
111 | if ($_POST['autoplay_common'] == 'true') |
---|
112 | { |
---|
113 | $_POST['autoplay'] = ''; |
---|
114 | } |
---|
115 | |
---|
116 | $updates = array( |
---|
117 | 'url' => $video['url'], |
---|
118 | 'type' => $video['type'], |
---|
119 | 'video_id' => $video['id'], |
---|
120 | 'width' => $_POST['width'], |
---|
121 | 'height' => $_POST['height'], |
---|
122 | 'autoplay' => $_POST['autoplay'], |
---|
123 | ); |
---|
124 | |
---|
125 | single_update( |
---|
126 | GVIDEO_TABLE, |
---|
127 | $updates, |
---|
128 | array('picture_id' => $_GET['image_id']), |
---|
129 | true |
---|
130 | ); |
---|
131 | |
---|
132 | array_push($page['infos'], l10n('Video successfully updated')); |
---|
133 | unset($_POST); |
---|
134 | } |
---|
135 | } |
---|
136 | |
---|
137 | // +-----------------------------------------------------------------------+ |
---|
138 | // | Update thumbnail (from Photo Update) | |
---|
139 | // +-----------------------------------------------------------------------+ |
---|
140 | if (isset($_FILES['photo_update'])) |
---|
141 | { |
---|
142 | include_once(PHPWG_ROOT_PATH.'admin/include/functions_upload.inc.php'); |
---|
143 | |
---|
144 | if ($_FILES['photo_update']['error'] !== UPLOAD_ERR_OK) |
---|
145 | { |
---|
146 | array_push($page['errors'], |
---|
147 | file_upload_error_message($_FILES['photo_update']['error']) |
---|
148 | ); |
---|
149 | } |
---|
150 | else |
---|
151 | { |
---|
152 | add_uploaded_file( |
---|
153 | $_FILES['photo_update']['tmp_name'], |
---|
154 | $_FILES['photo_update']['name'], |
---|
155 | null, |
---|
156 | null, |
---|
157 | $_GET['image_id'] |
---|
158 | ); |
---|
159 | |
---|
160 | array_push($page['infos'], l10n('The thumbnail was updated')); |
---|
161 | } |
---|
162 | } |
---|
163 | |
---|
164 | // +-----------------------------------------------------------------------+ |
---|
165 | // | Add film frame | |
---|
166 | // +-----------------------------------------------------------------------+ |
---|
167 | if ( function_exists('imagecreatetruecolor') and isset($_GET['add_film_frame']) ) |
---|
168 | { |
---|
169 | include_once(GVIDEO_PATH . '/include/functions.inc.php'); |
---|
170 | include_once(PHPWG_ROOT_PATH . 'admin/include/functions_upload.inc.php'); |
---|
171 | |
---|
172 | $thumb_source = $conf['data_location'].$picture['file']; |
---|
173 | |
---|
174 | add_film_frame($picture['path'], $thumb_source); |
---|
175 | add_uploaded_file($thumb_source, $picture['file'], null, null, $_GET['image_id']); |
---|
176 | |
---|
177 | redirect($self_url); |
---|
178 | } |
---|
179 | |
---|
180 | |
---|
181 | // +-----------------------------------------------------------------------+ |
---|
182 | // | Template | |
---|
183 | // +-----------------------------------------------------------------------+ |
---|
184 | if (empty($gvideo['height'])) |
---|
185 | { |
---|
186 | $gvideo['size_common'] = 'true'; |
---|
187 | } |
---|
188 | if (empty($gvideo['autoplay'])) |
---|
189 | { |
---|
190 | $gvideo['autoplay_common'] = 'true'; |
---|
191 | } |
---|
192 | |
---|
193 | if (function_exists('imagecreatetruecolor')) |
---|
194 | { |
---|
195 | $template->assign('U_ADD_FILM_FRAME', $self_url.'&add_film_frame=1'); |
---|
196 | } |
---|
197 | |
---|
198 | $template->assign(array( |
---|
199 | 'F_ACTION' => $self_url, |
---|
200 | 'GVIDEO' => $gvideo, |
---|
201 | 'TN_SRC' => DerivativeImage::thumb_url($picture).'?'.time(), |
---|
202 | 'TITLE' => render_element_name($picture), |
---|
203 | )); |
---|
204 | |
---|
205 | $template->set_filename('gvideo_content', dirname(__FILE__).'/template/photo.tpl'); |
---|
206 | |
---|
207 | ?> |
---|