~ubuntu-branches/ubuntu/lucid/phpmyadmin/lucid

« back to all changes in this revision

Viewing changes to libraries/import/upload/uploadprogress.php

  • Committer: Bazaar Package Importer
  • Author(s): Michal Čihař
  • Date: 2010-03-08 15:25:00 UTC
  • mfrom: (1.2.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20100308152500-6e8hmuqc5co39de5
Tags: 4:3.3.0-1
* New upstream version.
* Rediff debian/patches.
* Fix permissions on mediawiki export extension.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
/* vim: set expandtab sw=4 ts=4 sts=4: */
 
3
/**
 
4
*
 
5
* @version $Id: uploadprogress.php 13193 2009-12-30 13:28:30Z lem9 $
 
6
* @package phpMyAdmin
 
7
*/
 
8
if (! defined('PHPMYADMIN')) {
 
9
    exit;
 
10
}
 
11
 
 
12
$ID_KEY = "UPLOAD_IDENTIFIER";
 
13
 
 
14
function PMA_getUploadStatus($id) {
 
15
    global $SESSION_KEY;
 
16
    global $ID_KEY;
 
17
  
 
18
    if (trim($id) == "") {
 
19
        return;
 
20
    }
 
21
  
 
22
    if (! array_key_exists($id, $_SESSION[$SESSION_KEY])) {
 
23
        $_SESSION[$SESSION_KEY][$id] = array(
 
24
                    'id'       => $id,
 
25
                    'finished' => false,
 
26
                    'percent'  => 0,
 
27
                    'total'    => 0,
 
28
                    'complete' => 0,
 
29
                            'plugin'   => $ID_KEY
 
30
        );
 
31
    }
 
32
    $ret = $_SESSION[$SESSION_KEY][$id];
 
33
    
 
34
    if (! PMA_import_uploadprogressCheck() || $ret['finished']) {
 
35
        return $ret;
 
36
    }
 
37
    
 
38
    $status = uploadprogress_get_info($id);
 
39
 
 
40
    if ($status) {
 
41
        if ($status['bytes_uploaded'] == $status['bytes_total']) {
 
42
            $ret['finished'] = true;
 
43
        } else {
 
44
            $ret['finished'] = false;
 
45
        }
 
46
        $ret['total']    = $status['bytes_total'];
 
47
        $ret['complete'] = $status['bytes_uploaded'];
 
48
 
 
49
        if ($ret['total'] > 0) {
 
50
            $ret['percent'] = $ret['complete'] / $ret['total'] * 100;
 
51
        }
 
52
    } else {
 
53
       $ret = array(
 
54
                    'id'       => $id,
 
55
                    'finished' => true,
 
56
                    'percent'  => 100,
 
57
                    'total'    => $ret['total'],
 
58
                    'complete' => $ret['total'],
 
59
                    'plugin'   => $ID_KEY
 
60
                );
 
61
    }
 
62
    
 
63
    $_SESSION[$SESSION_KEY][$id] = $ret;
 
64
    
 
65
    return $ret;
 
66
}
 
67
?>