roundcubemail/program/include/rcmail.php
public function upload_progress()
    {
        $params = array(
            'action' => $this->action,
            'name'   => rcube_utils::get_input_value('_progress', rcube_utils::INPUT_GET),
        );

        if (function_exists('uploadprogress_get_info')) {
            $status = uploadprogress_get_info($params['name']);

            if (!empty($status)) {
                $params['current'] = $status['bytes_uploaded'];
                $params['total']   = $status['bytes_total'];
            }
        }

        if (!isset($status) && filter_var(ini_get('apc.rfc1867'), FILTER_VALIDATE_BOOLEAN)
            && ini_get('apc.rfc1867_name')
        ) {
            $prefix = ini_get('apc.rfc1867_prefix');
            $status = apc_fetch($prefix . $params['name']);

            if (!empty($status)) {
                $params['current'] = $status['current'];
                $params['total']   = $status['total'];
            }
        }

        if (!isset($status) && filter_var(ini_get('session.upload_progress.enabled'), FILTER_VALIDATE_BOOLEAN)
            && ini_get('session.upload_progress.name')
        ) {
            $key = ini_get('session.upload_progress.prefix') . $params['name'];

            $params['total']   = $_SESSION[$key]['content_length'];
            $params['current'] = $_SESSION[$key]['bytes_processed'];
        }

        if (!empty($params['total'])) {
            $total = $this->show_bytes($params['total'], $unit);
            switch ($unit) {
            case 'GB':
                $gb      = $params['current']/1073741824;
                $current = sprintf($gb >= 10 ? "%d" : "%.1f", $gb);
                break;
            case 'MB':
                $mb      = $params['current']/1048576;
                $current = sprintf($mb >= 10 ? "%d" : "%.1f", $mb);
                break;
            case 'KB':
                $current = round($params['current']/1024);
                break;
            case 'B':
            default:
                $current = $params['current'];
                break;
            }

            $params['percent'] = round($params['current']/$params['total']*100);
            $params['text']    = $this->gettext(array(
                'name' => 'uploadprogress',
                'vars' => array(
                    'percent' => $params['percent'] . '%',
                    'current' => $current,
                    'total'   => $total
                )
            ));
        }

        $this->output->command('upload_progress_update', $params);
        $this->output->send();
    }
public function upload_progress()
    {
        $params = array(
            'action' => $this->action,
            'name'   => rcube_utils::get_input_value('_progress', rcube_utils::INPUT_GET),
        );

        if (function_exists('uploadprogress_get_info')) {
            $status = uploadprogress_get_info($params['name']);

            if (!empty($status)) {
                $params['current'] = $status['bytes_uploaded'];
                $params['total']   = $status['bytes_total'];
            }
        }

        if (!isset($status) && filter_var(ini_get('apc.rfc1867'), FILTER_VALIDATE_BOOLEAN)
            && ini_get('apc.rfc1867_name')
        ) {
            $prefix = ini_get('apc.rfc1867_prefix');
            $status = apc_fetch($prefix . $params['name']);

            if (!empty($status)) {
                $params['current'] = $status['current'];
                $params['total']   = $status['total'];
            }
        }

        if (!isset($status) && filter_var(ini_get('session.upload_progress.enabled'), FILTER_VALIDATE_BOOLEAN)
            && ini_get('session.upload_progress.name')
        ) {
            $key = ini_get('session.upload_progress.prefix') . $params['name'];

            $params['total']   = $_SESSION[$key]['content_length'];
            $params['current'] = $_SESSION[$key]['bytes_processed'];
        }

        if (!empty($params['total'])) {
            $total = $this->show_bytes($params['total'], $unit);
            switch ($unit) {
            case 'GB':
                $gb      = $params['current']/1073741824;
                $current = sprintf($gb >= 10 ? "%d" : "%.1f", $gb);
                break;
            case 'MB':
                $mb      = $params['current']/1048576;
                $current = sprintf($mb >= 10 ? "%d" : "%.1f", $mb);
                break;
            case 'KB':
                $current = round($params['current']/1024);
                break;
            case 'B':
            default:
                $current = $params['current'];
                break;
            }

            $params['percent'] = round($params['current']/$params['total']*100);
            $params['text']    = $this->gettext(array(
                'name' => 'uploadprogress',
                'vars' => array(
                    'percent' => $params['percent'] . '%',
                    'current' => $current,
                    'total'   => $total
                )
            ));
        }

        $this->output->command('upload_progress_update', $params);
        $this->output->send();
    }
public function upload_progress ( ) { $ params = array ( 'action' => $ this -> action , 'name' => rcube_utils :: get_input_value ( '_progress' , rcube_utils :: INPUT_GET ) , ) ; if ( function_exists ( 'uploadprogress_get_info' ) ) { $ status = uploadprogress_get_info ( $ params [ 'name' ] ) ; if ( ! empty ( $ status ) ) { $ params [ 'current' ] = $ status [ 'bytes_uploaded' ] ; $ params [ 'total' ] = $ status [ 'bytes_total' ] ; } } if ( ! isset ( $ status ) && filter_var ( ini_get ( 'apc.rfc1867' ) , FILTER_VALIDATE_BOOLEAN ) && ini_get ( 'apc.rfc1867_name' ) ) { $ prefix = ini_get ( 'apc.rfc1867_prefix' ) ; $ status = apc_fetch ( $ prefix . $ params [ 'name' ] ) ; if ( ! empty ( $ status ) ) { $ params [ 'current' ] = $ status [ 'current' ] ; $ params [ 'total' ] = $ status [ 'total' ] ; } } if ( ! isset ( $ status ) && filter_var ( ini_get ( 'session.upload_progress.enabled' ) , FILTER_VALIDATE_BOOLEAN ) && ini_get ( 'session.upload_progress.name' ) ) { $ key = ini_get ( 'session.upload_progress.prefix' ) . $ params [ 'name' ] ; $ params [ 'total' ] = $ _SESSION [ $ key ] [ 'content_length' ] ; $ params [ 'current' ] = $ _SESSION [ $ key ] [ 'bytes_processed' ] ; } if ( ! empty ( $ params [ 'total' ] ) ) { $ total = $ this -> show_bytes ( $ params [ 'total' ] , $ unit ) ; switch ( $ unit ) { case 'GB' : $ gb = $ params [ 'current' ] / 1073741824 ; $ current = sprintf ( $ gb >= 10 ? "%d" : "%.1f" , $ gb ) ; break ; case 'MB' : $ mb = $ params [ 'current' ] / 1048576 ; $ current = sprintf ( $ mb >= 10 ? "%d" : "%.1f" , $ mb ) ; break ; case 'KB' : $ current = round ( $ params [ 'current' ] / 1024 ) ; break ; case 'B' : default : $ current = $ params [ 'current' ] ; break ; } $ params [ 'percent' ] = round ( $ params [ 'current' ] / $ params [ 'total' ] * 100 ) ; $ params [ 'text' ] = $ this -> gettext ( array ( 'name' => 'uploadprogress' , 'vars' => array ( 'percent' => $ params [ 'percent' ] . '%' , 'current' => $ current , 'total' => $ total ) ) ) ; } $ this -> output -> command ( 'upload_progress_update' , $ params ) ; $ this -> output -> send ( ) ; }
File upload progress handler.
File upload progress handler .