Changeset 1144:4af82896ca3d for admin/media.php
- Timestamp:
- 06/04/13 22:51:35 (11 years ago)
- Branch:
- default
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
admin/media.php
r1039 r1144 10 10 # 11 11 # -- END LICENSE BLOCK ----------------------------------------- 12 13 /* Upload backend14 -------------------------------------------------------- */15 if (!empty($_POST['swfupload']))16 {17 header('content-type: text/plain');18 try19 {20 if (empty($_POST['sess_id']) || empty($_POST['sess_uid'])) {21 throw new Exception('No credentials.');22 }23 define('DC_AUTH_SESS_ID',$_POST['sess_id']);24 define('DC_AUTH_SESS_UID',$_POST['sess_uid']);25 26 require dirname(__FILE__).'/../inc/admin/prepend.php';27 28 if (!$core->auth->check('media,media_admin',$core->blog->id)) {29 throw new Exception('Permission denied.');30 }31 32 $d = isset($_POST['d']) ? $_POST['d'] : null;33 $core->media = new dcMedia($core);34 $core->media->chdir($d);35 $core->media->getDir();36 $dir =& $core->media->dir;37 38 if (empty($_FILES['Filedata'])) {39 throw new Exception('No file to upload.');40 }41 42 files::uploadStatus($_FILES['Filedata']);43 $core->media->uploadFile($_FILES['Filedata']['tmp_name'],$_FILES['Filedata']['name']);44 45 echo 'ok';46 }47 catch (Exception $e) {48 echo __('Error:').' '.__($e->getMessage());49 }50 exit;51 }52 53 12 54 13 /* HTML page … … 175 134 if ($dir && !empty($_FILES['upfile'])) 176 135 { 177 try 178 { 179 files::uploadStatus($_FILES['upfile']); 180 181 $f_title = (isset($_POST['upfiletitle']) ? $_POST['upfiletitle'] : ''); 182 $f_private = (isset($_POST['upfilepriv']) ? $_POST['upfilepriv'] : false); 183 184 $core->media->uploadFile($_FILES['upfile']['tmp_name'],$_FILES['upfile']['name'],$f_title,$f_private); 185 http::redirect($page_url.'&d='.rawurlencode($d).'&upok=1'); 186 } 187 catch (Exception $e) 188 { 189 $core->error->add($e->getMessage()); 190 } 191 } 192 136 $upfile = array('name' => $_FILES['upfile']['name'][0], 137 'type' => $_FILES['upfile']['type'][0], 138 'tmp_name' => $_FILES['upfile']['tmp_name'][0], 139 'error' => $_FILES['upfile']['error'][0], 140 'size' => $_FILES['upfile']['size'][0] 141 ); 142 143 try { 144 files::uploadStatus($upfile); 145 146 $core->media->uploadFile($upfile['tmp_name'],$upfile['name']); 147 148 if (!empty($_SERVER['HTTP_X_REQUESTED_WITH'])) { 149 header('Content-type: application/json'); 150 $message = array(); 151 $message['files'][] = array('name' => $upfile['name']); 152 153 echo json_encode($message); 154 exit(); 155 } else { 156 http::redirect($page_url.'&d='.rawurlencode($d).'&upok=1'); 157 } 158 } catch (Exception $e) { 159 if (!empty($_SERVER['HTTP_X_REQUESTED_WITH'])) { 160 header('Content-type: application/json'); 161 $message = array(); 162 $message['files'][] = array('name' => $upfile['name'], 163 'error' => $e->getMessage() 164 ); 165 echo json_encode($message); 166 exit(); 167 } else { 168 $core->error->add($e->getMessage()); 169 } 170 } 171 } 193 172 194 173 # Removing item … … 215 194 } 216 195 } 217 218 196 219 197 # DISPLAY confirm page for rmdir & rmfile … … 245 223 246 224 call_user_func($open_f,__('Media manager'), 247 '<script type="text/javascript">'."\n".248 "//<![CDATA["."\n".249 dcPage::jsVar('dotclear.candyUpload_force_init',$user_ui_enhanceduploader)."\n".250 "//]]>".251 "</script>".252 225 dcPage::jsLoad('js/_media.js'). 253 ($core_media_writable ? dcPage::js CandyUpload(array('d='.$d)) : '')226 ($core_media_writable ? dcPage::jsUpload(array('d='.$d)) : '') 254 227 ); 255 228 … … 339 312 } 340 313 314 341 315 if ($core_media_writable) 342 316 { … … 344 318 345 319 echo 346 '<div class="col">'. 347 '<fieldset id="add-file-f"><legend>'.__('Add files').'</legend>'. 348 '<p>'.__('Please take care to publish media that you own and that are not protected by copyright.').'</p>'. 349 '<form id="media-upload" class="clear" action="'.html::escapeURL($page_url).'" method="post" enctype="multipart/form-data">'. 350 '<div>'.form::hidden(array('MAX_FILE_SIZE'),DC_MAX_UPLOAD_SIZE). 351 $core->formNonce().'</div>'. 352 '<p><label for="upfile">'.__('Choose a file:'). 353 ' ('.sprintf(__('Maximum size %s'),files::size(DC_MAX_UPLOAD_SIZE)).')'. 354 '<input type="file" id="upfile" name="upfile" size="20" />'. 355 '</label></p>'. 356 '<p><label for="upfiletitle">'.__('Title:').form::field(array('upfiletitle','upfiletitle'),35,255).'</label></p>'. 357 '<p><label for="upfilepriv" class="classic">'.form::checkbox(array('upfilepriv','upfilepriv'),1).' '. 358 __('Private').'</label></p>'; 359 if (!$user_ui_enhanceduploader) { 360 echo 361 '<p class="form-help info">'.__('To send several files at the same time, you can activate the enhanced uploader in'). 362 ' <a href="preferences.php?tab=user-options">'.__('My preferences').'</a></p>'; 363 } 364 echo 365 '<p><input type="submit" value="'.__('Send').'" />'. 366 form::hidden(array('d'),$d).'</p>'. 367 '</fieldset>'. 368 '</form>'. 369 '</div>'; 320 '<div class="col">'. 321 '<fieldset id="add-file-f"><legend>'.__('Add files').'</legend>'. 322 '<p>'.__('Please take care to publish media that you own and that are not protected by copyright.').'</p>'. 323 ' <form id="fileupload" action="'.html::escapeURL($page_url).'" method="POST" enctype="multipart/form-data">'. 324 '<div>'.form::hidden(array('MAX_FILE_SIZE'),DC_MAX_UPLOAD_SIZE). 325 $core->formNonce().'</div>'. 326 '<div class="fileupload-buttonbar">'. 327 '<span class="button-add button"><label for="upfile">'.__('Add files').'</label>'. 328 '<input type="file" id="upfile" name="upfile[]" size="20" multiple="multiple" data-url="'.html::escapeURL($page_url).'" />'. 329 '</span>'. 330 '<button type="submit" class="button start"><span>'.__('Send').'</span></button>'. 331 '</div>'. 332 '<table role="presentation" class="table table-striped"><tbody class="files" data-toggle="modal-gallery" data-target="#modal-gallery"></tbody></table>'. 333 form::hidden(array('d'),$d).'</p>'. 334 '</fieldset>'. 335 '</form>'. 336 '</div>'; 370 337 371 338 echo
Note: See TracChangeset
for help on using the changeset viewer.