HEX
Server: Apache/2.4.59 (Debian)
System: Linux skycube.cz 4.19.0-25-amd64 #1 SMP Debian 4.19.289-2 (2023-08-08) x86_64
User: ilya (534)
PHP: 7.3.31-1~deb10u7
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,
Upload Files
File: /var/www/ilya/data/www/kamforum.ru/modules/gallery/img_ctrl.php
<?php
/*
+--------------------------------------------------------------------------
|   Invision Gallery Module v<#VERSION#>
|   ========================================
|   by Adam Kinder
|   (c) 2001 - 2005 Invision Power Services
|   http://www.invisionpower.com
|   ========================================
|   Email: adam@invisionpower.com
+---------------------------------------------------------------------------
|   > Date December 18, 2005, 4:59 pm
|   > Release f5ba00991bc63895d988f560e497967f
|   > Main Module
|   > Original Script written by Joshua Williams
|	> $Id$
+---------------------------------------------------------------------------
*/


/**
* Main/Image Control
*
* Sends an image to the browser, permissions and settings
* are checked to ensure that the user can view the image
*
* @package		Gallery
* @subpackage 	Main
* @author   	Adam Kinder
* @version		<#VERSION#>
* @since 		1.0
*/

    class img_ctrl
    {
        var $ipsclass;
        var $glib;
        var $output;
        var $info;
        var $html;

    	/**
    	 * img_view::start()
    	 * 
		 * Begins execution of this module, $param is used as an entry point into the
		 * module.
		 * 
    	 * @param string $param
    	 * @return none
    	 **/
    	function start( $param="" )
    	{
            // -------------------------------------------------------
            // Check Auth
            // -------------------------------------------------------            
	        if( $this->ipsclass->member['id'] )
    	    {
    	        $perms = explode( ':', $this->ipsclass->member['gallery_perms'] );           
    	        if( ! $perms[0] ) exit;
    	    }     

            // -------------------------------------------------------
            // What's our entry point?
            // -------------------------------------------------------
            switch( $param )
            {
                case 'view':
                    $this->display_image();
                break;

            }

        }

        /**
         * img_ctrl::display_image()
		 * 
		 * Sends the image to a browser.  Checks for hotlinking, bandwidth useage,
		 * permissions.
         * 
         * @return none
         **/
        function display_image()
        {
        	/**
        	* Get image information
        	**/		
        	$this->ipsclass->input['img'] = $this->glib->validate_int( $this->ipsclass->input['img'] );
        	$image = $this->glib->get_image_info( $this->ipsclass->input['img'] );
        	
        	/**
        	* Physical location
        	**/
        	$image_loci = "{$this->ipsclass->vars['gallery_images_path']}/{$image['directory']}/";
        	
        	/**
        	* Thumbnail, med, or full image?
        	**/
        	if( !empty( $this->ipsclass->input['tn'] ) )
        	{
        		$theimg = "{$image_loci}tn_{$image['masked_file_name']}";
        	}
        	else 
        	{
        		$theimg = ( $this->ipsclass->input['file'] == 'med' ) ? "{$image_loci}{$image['medium_file_name']}" : "{$image_loci}{$image['masked_file_name']}";
        	}
	        
      
            /**
            * Finally, display the image
            **/
            header("Content-Type: {$image['file_type']}");
            header("Content-Disposition: inline; filename={$theimg}");
            readfile( $theimg );

            /**
            * Exit out 
            **/
            exit();
        }

    }
?>