Plugin Directory

Changeset 428927


Ignore:
Timestamp:
08/26/2011 09:29:42 AM (15 years ago)
Author:
taehan
Message:

uexc 1.1 tag

Location:
u-extended-comment/tags
Files:
2 deleted
2 edited
34 copied

Legend:

Unmodified
Added
Removed
  • u-extended-comment/tags/1.0.1/includes/attachment.php

    r420122 r428927  
    287287
    288288function _do_download(){
    289     global $uexc;
    290    
    291     if ( !wp_verify_nonce($_GET['_wpnonce'], $this->id.'_nonce') )
    292         wp_die(__('Your nonce did not verify.', $uexc->id));
    293    
    294     $wp_upload_dir = wp_upload_dir();
    295     $filepath = str_replace($wp_upload_dir['baseurl'], $wp_upload_dir['basedir'], $_REQUEST['fileurl']);
    296     $filename = pathinfo($_REQUEST['fileurl']);
    297     $filename = $filename['basename'];
    298    
    299     if( empty($filename) || !file_exists($filepath) ) {
    300         wp_die(__('File does not exist', $uexc->id));
    301     }else{
    302         $this->_force_download($filename, file_get_contents($filepath));
    303     }
    304 }
    305 
    306 function _force_download($filename = '', $data = ''){
    307     global $uexc;
    308    
    309     if ($filename == '' OR $data == '') return FALSE;
    310    
    311     if (FALSE === strpos($filename, '.')) return FALSE;
    312    
    313     $x = explode('.', $filename);
    314     $extension = end($x);
    315    
    316     require_once('mimes.php');
    317    
    318     if ( ! isset($mimes[$extension])){
    319         $mime = 'application/octet-stream';
    320     }else{
    321         $mime = (is_array($mimes[$extension])) ? $mimes[$extension][0] : $mimes[$extension];
    322     }
    323    
    324     if (strpos($_SERVER['HTTP_USER_AGENT'], "MSIE") !== FALSE){
    325         header('Content-Type: "'.$mime.'"');
    326         header('Content-Disposition: attachment; filename="'.$filename.'"');
    327         header('Expires: 0');
    328         header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
    329         header("Content-Transfer-Encoding: binary");
    330         header('Pragma: public');
    331         header("Content-Length: ".strlen($data));
    332     }else{
    333         header('Content-Type: "'.$mime.'"');
    334         header('Content-Disposition: attachment; filename="'.$filename.'"');
    335         header("Content-Transfer-Encoding: binary");
    336         header('Expires: 0');
    337         header('Pragma: no-cache');
    338         header("Content-Length: ".strlen($data));
    339     }
    340     exit($data);
    341289}
    342290
  • u-extended-comment/tags/1.0/includes/attachment.php

    r419641 r428927  
    289289
    290290function _do_download(){
    291     global $uexc;
    292    
    293     if ( !wp_verify_nonce($_GET['_wpnonce'], $this->id.'_nonce') )
    294         wp_die(__('Your nonce did not verify.', $uexc->id));
    295    
    296     $wp_upload_dir = wp_upload_dir();
    297     $filepath = str_replace($wp_upload_dir['baseurl'], $wp_upload_dir['basedir'], $_REQUEST['fileurl']);
    298     $filename = pathinfo($_REQUEST['fileurl']);
    299     $filename = $filename['basename'];
    300    
    301     if( empty($filename) || !file_exists($filepath) ) {
    302         wp_die(__('File does not exist', $uexc->id));
    303     }else{
    304         $this->_force_download($filename, file_get_contents($filepath));
    305     }
    306 }
    307 
    308 function _force_download($filename = '', $data = ''){
    309     global $uexc;
    310    
    311     if ($filename == '' OR $data == '') return FALSE;
    312    
    313     if (FALSE === strpos($filename, '.')) return FALSE;
    314    
    315     $x = explode('.', $filename);
    316     $extension = end($x);
    317    
    318     require_once('mimes.php');
    319    
    320     if ( ! isset($mimes[$extension])){
    321         $mime = 'application/octet-stream';
    322     }else{
    323         $mime = (is_array($mimes[$extension])) ? $mimes[$extension][0] : $mimes[$extension];
    324     }
    325    
    326     if (strpos($_SERVER['HTTP_USER_AGENT'], "MSIE") !== FALSE){
    327         header('Content-Type: "'.$mime.'"');
    328         header('Content-Disposition: attachment; filename="'.$filename.'"');
    329         header('Expires: 0');
    330         header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
    331         header("Content-Transfer-Encoding: binary");
    332         header('Pragma: public');
    333         header("Content-Length: ".strlen($data));
    334     }else{
    335         header('Content-Type: "'.$mime.'"');
    336         header('Content-Disposition: attachment; filename="'.$filename.'"');
    337         header("Content-Transfer-Encoding: binary");
    338         header('Expires: 0');
    339         header('Pragma: no-cache');
    340         header("Content-Length: ".strlen($data));
    341     }
    342     exit($data);
    343291}
    344292
Note: See TracChangeset for help on using the changeset viewer.