Problem with php code.

Started on the old forum in November 2013 · view the original in the archive · old links redirect here

3 replies · 351 views · started 13 years ago · 1 min read

3 participants
armanshuva5 Newbie · 5 posts #1

anybody here can add mime types force download in this code? for support download to mobile browser, content like mp3,java,sis,zip . i will pay u if u are from bangladesh.

 // DOWNLOADING FILE
    
    function download()
    {
        $result = $this->controllerObj->dbObj->getDInfo( $this->id );
        
        if ( ! empty( $result ))
        {
            if ( is_file( $result->path ) )
            {
                $typeArray = array ( 'jpg' , 'gif' , 'jpeg' , 'png' );
                
                $name = str_replace( ".$result->type" , " (YourSite.Com).$result->type" , $result->name );
                
                $this->controllerObj->dbObj->updateDtime( $this->id );
                
                $type = strtolower( $result->type );
                
                if ( in_array( $type , $typeArray ))
                {
                    $size = ( isset($_GET['size'] ) )? (int)$_GET['size'] : 1;
                    
                    if ( $what = $this->controllerObj->resizeImage( $type , $result->path , $size ) == 1 )
                    {
                        $size = filesize( './apanel/tmp/raw.jpg' );
                        $path = './apanel/tmp/raw.jpg';    
                    }
                    else
                    {
                        $path = $result->path;
                        $size = $result->size;
                    }
                }
                else
                {
                    $size = $result->size;
                    $path = $result->path;
                }
                
                header( "Pragma: public" );
                header( "Expires: 0" );
                header( "Content-Description: File Transfer");
                header( "Content-Type: application/octet-stream" );
                header( "Cache-Control: must-revalidate post-check = 0 pre-check = 0" );
                header( "Cache-Control: public" );
                header( "Content-Length: $size" );
                header( "Content-Disposition: attactment; filename=\"$name\"" );
                header( "Content-Transfer-Encoding: binary\n" );
                
                readfile( $path );
                
                exit();
            }
            else
            {
                $this->index();
            }
        }
        else
        {
            $this->index();
        }
    }[PHP]
something else Fellow · 2,296 posts #2

something like this:

    function download() 
    { 
        $result = $this->controllerObj->dbObj->getDInfo( $this->id ); 
         
        if ( ! empty( $result )) 
        { 
            if ( is_file( $result->path ) ) 
            { 
                $typeArray = array ( 'jpg' , 'gif' , 'jpeg' , 'png' ); 
                 
                $name = str_replace( ".$result->type" , " (YourSite.Com).$result->type" , $result->name ); 
                 
                $this->controllerObj->dbObj->updateDtime( $this->id ); 
                 
                $type = strtolower( $result->type ); 
                 
                if ( in_array( $type , $typeArray )) 
                { 
                    $size = ( isset($_GET['size'] ) )? (int)$_GET['size'] : 1; 
                     
                    if ( $what = $this->controllerObj->resizeImage( $type , $result->path , $size ) == 1 ) 
                    { 
                        $size = filesize( './apanel/tmp/raw.jpg' ); 
                        $path = './apanel/tmp/raw.jpg';     
                    } 
                    else 
                    { 
                        $path = $result->path; 
                        $size = $result->size; 
                    } 
                } 
                else 
                { 
                    $size = $result->size; 
                    $path = $result->path; 
                } 
				
	$ext = array ( 

  // archives 
  'zip' => 'application/zip', 
  'tar' => 'application/x-tar', 
  'tgz' => 'application/x-compressed-tar', 
  'tar.gz' => 'application/x-compressed-tar', 
  'rar' => 'application/x-rar-compressed', 

  // documents 
  'pdf' => 'application/pdf', 
  'doc' => 'application/msword', 
  'xls' => 'application/vnd.ms-excel', 
  'ppt' => 'application/vnd.ms-powerpoint', 
   
  // executables 
  'exe' => 'application/octet-stream', 

  // images 
  'gif' => 'image/gif', 
  'png' => 'image/png', 
  'jpg' => 'image/jpeg', 
  'jpeg' => 'image/jpeg', 

  // audio 
  'mp3' => 'audio/mpeg', 
  'wav' => 'audio/x-wav', 

  // video 
  'mpeg' => 'video/mpeg', 
  'mpg' => 'video/mpeg', 
  'mpe' => 'video/mpeg', 
  'mp4' => 'video/mp4', 
  'mov' => 'video/quicktime', 
  'avi' => 'video/x-msvideo', 
  'wmv' => 'video/x-ms-wmv', 
  'mov' => 'video/quicktime', 

  // mobile 
  'sis' => 'application/vnd.sybian.install', 
  'jar' => 'application/java-archive', 
  '3gp' => 'application/octet-stream', 
  'nth' => 'application/vnd.nok-s40theme', 
  'thm' => 'application/vnd.eri.thm', 
  'amr' => 'audio/amr', 
  'sisx' => 'application/octet-stream', 
  'mid' => 'audio/midi', 
  'swf' => 'application/x-shockwave-flash', 
  'jad' => 'text/vnd.sun.j2me.app-descriptor' 

	);  

                 
                header( "Pragma: public" ); 
                header( "Expires: 0" ); 
                header( "Content-Description: File Transfer"); 
                header( "Content-Type: ".$ext[$type]); 
                header( "Cache-Control: must-revalidate post-check = 0 pre-check = 0" ); 
                header( "Cache-Control: public" ); 
                header( "Content-Length: $size" ); 
                header( "Content-Disposition: attactment; filename=\"$name\"" ); 
                header( "Content-Transfer-Encoding: binary\n" ); 
                 
                readfile( $path ); 
                 
                exit(); 
            } 
            else 
            { 
                $this->index(); 
            } 
        } 
        else 
        { 
            $this->index(); 
        } 
    }
	
	
armanshuva5 Newbie · 5 posts #3

something else wrote: something like this:

    function download() 
    { 
        $result = $this->controllerObj->dbObj->getDInfo( $this->id ); 
         
        if ( ! empty( $result )) 
        { 
            if ( is_file( $result->path ) ) 
            { 
                $typeArray = array ( 'jpg' , 'gif' , 'jpeg' , 'png' ); 
                 
                $name = str_replace( ".$result->type" , " (YourSite.Com).$result->type" , $result->name ); 
                 
                $this->controllerObj->dbObj->updateDtime( $this->id ); 
                 
                $type = strtolower( $result->type ); 
                 
                if ( in_array( $type , $typeArray )) 
                { 
                    $size = ( isset($_GET['size'] ) )? (int)$_GET['size'] : 1; 
                     
                    if ( $what = $this->controllerObj->resizeImage( $type , $result->path , $size ) == 1 ) 
                    { 
                        $size = filesize( './apanel/tmp/raw.jpg' ); 
                        $path = './apanel/tmp/raw.jpg';     
                    } 
                    else 
                    { 
                        $path = $result->path; 
                        $size = $result->size; 
                    } 
                } 
                else 
                { 
                    $size = $result->size; 
                    $path = $result->path; 
                } 
				
	$ext = array ( 

  // archives 
  'zip' => 'application/zip', 
  'tar' => 'application/x-tar', 
  'tgz' => 'application/x-compressed-tar', 
  'tar.gz' => 'application/x-compressed-tar', 
  'rar' => 'application/x-rar-compressed', 

  // documents 
  'pdf' => 'application/pdf', 
  'doc' => 'application/msword', 
  'xls' => 'application/vnd.ms-excel', 
  'ppt' => 'application/vnd.ms-powerpoint', 
   
  // executables 
  'exe' => 'application/octet-stream', 

  // images 
  'gif' => 'image/gif', 
  'png' => 'image/png', 
  'jpg' => 'image/jpeg', 
  'jpeg' => 'image/jpeg', 

  // audio 
  'mp3' => 'audio/mpeg', 
  'wav' => 'audio/x-wav', 

  // video 
  'mpeg' => 'video/mpeg', 
  'mpg' => 'video/mpeg', 
  'mpe' => 'video/mpeg', 
  'mp4' => 'video/mp4', 
  'mov' => 'video/quicktime', 
  'avi' => 'video/x-msvideo', 
  'wmv' => 'video/x-ms-wmv', 
  'mov' => 'video/quicktime', 

  // mobile 
  'sis' => 'application/vnd.sybian.install', 
  'jar' => 'application/java-archive', 
  '3gp' => 'application/octet-stream', 
  'nth' => 'application/vnd.nok-s40theme', 
  'thm' => 'application/vnd.eri.thm', 
  'amr' => 'audio/amr', 
  'sisx' => 'application/octet-stream', 
  'mid' => 'audio/midi', 
  'swf' => 'application/x-shockwave-flash', 
  'jad' => 'text/vnd.sun.j2me.app-descriptor' 

	);  

                 
                header( "Pragma: public" ); 
                header( "Expires: 0" ); 
                header( "Content-Description: File Transfer"); 
                header( "Content-Type: ".$ext[$type]); 
                header( "Cache-Control: must-revalidate post-check = 0 pre-check = 0" ); 
                header( "Cache-Control: public" ); 
                header( "Content-Length: $size" ); 
                header( "Content-Disposition: attactment; filename=\"$name\"" ); 
                header( "Content-Transfer-Encoding: binary\n" ); 
                 
                readfile( $path ); 
                 
                exit(); 
            } 
            else 
            { 
                $this->index(); 
            } 
        } 
        else 
        { 
            $this->index(); 
        } 
    }
	
	

thank you very very much brother.

devilsraider Newbie · 1 posts #4
CHMOD Check/home/u448279428/public_html/install/ : [755] - >777
/home/u448279428/public_html/sys/avatar/ : [755] - >777
/home/u448279428/public_html/sys/dat/ : [755] - >777
/home/u448279428/public_html/sys/forum/files : [755] - >777
/home/u448279428/public_html/sys/gallery/48/ : [755] - >777
/home/u448279428/public_html/sys/gallery/128/ : [755] - >777
/home/u448279428/public_html/sys/gallery/640/ : [755] - >777
/home/u448279428/public_html/sys/gallery/foto/ : [755] - >777
/home/u448279428/public_html/sys/lib/stats/ : [755] - >777
/home/u448279428/public_html/sys/license/ : [755] - >777
/home/u448279428/public_html/sys/inc/ : [755] - >777
/home/u448279428/public_html/sys/fnc/ : [755] - >777
/home/u448279428/public_html/sys/loads/files/ : [755] - >777
/home/u448279428/public_html/sys/loads/mp3crop/ : [755] - >777
/home/u448279428/public_html/sys/loads/screens/14/ : [755] - >777
/home/u448279428/public_html/sys/loads/screens/48/ : [755] - >777
/home/u448279428/public_html/sys/loads/screens/128/ : [755] - >777
/home/u448279428/public_html/sys/obmen/files/ : [755] - >777
/home/u448279428/public_html/sys/obmen/screens/14/ : [755] - >777
/home/u448279428/public_html/sys/obmen/screens/48/ : [755] - >777
/home/u448279428/public_html/sys/obmen/screens/128/ : [755] - >777
/home/u448279428/public_html/sys/update/ : [755] - >777
/home/u448279428/public_html/sys/tmp/ : [755] - >777
/home/u448279428/public_html/style/themes/ : [755] - >777
Set the CHMOD 777 at /home/u448279428/public_html/install/
Set the CHMOD 777 at /home/u448279428/public_html/sys/avatar/
Set the CHMOD 777 at /home/u448279428/public_html/sys/dat/
Set the CHMOD 777 at /home/u448279428/public_html/sys/forum/files
Set the CHMOD 777 at /home/u448279428/public_html/sys/gallery/48/
Set the CHMOD 777 at /home/u448279428/public_html/sys/gallery/128/
Set the CHMOD 777 at /home/u448279428/public_html/sys/gallery/640/
Set the CHMOD 777 at /home/u448279428/public_html/sys/gallery/foto/
Set the CHMOD 777 at /home/u448279428/public_html/sys/lib/stats/
Set the CHMOD 777 at /home/u448279428/public_html/sys/license/
Set the CHMOD 777 at /home/u448279428/public_html/sys/inc/
Set the CHMOD 777 at /home/u448279428/public_html/sys/fnc/
Set the CHMOD 777 at /home/u448279428/public_html/sys/loads/files/
Set the CHMOD 777 at /home/u448279428/public_html/sys/loads/mp3crop/
Set the CHMOD 777 at /home/u448279428/public_html/sys/loads/screens/14/
Set the CHMOD 777 at /home/u448279428/public_html/sys/loads/screens/48/
Set the CHMOD 777 at /home/u448279428/public_html/sys/loads/screens/128/
Set the CHMOD 777 at /home/u448279428/public_html/sys/obmen/files/
Set the CHMOD 777 at /home/u448279428/public_html/sys/obmen/screens/14/
Set the CHMOD 777 at /home/u448279428/public_html/sys/obmen/screens/48/
Set the CHMOD 777 at /home/u448279428/public_html/sys/obmen/screens/128/
Set the CHMOD 777 at /home/u448279428/public_html/sys/update/
Set the CHMOD 777 at /home/u448279428/public_html/sys/tmp/
Set the CHMOD 777 at /home/u448279428/public_html/style/themes/

Script not ready to install what can i do now

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close