code cleanup

This commit is contained in:
Marc Delisle
2009-12-30 13:28:30 +00:00
parent 912da56db4
commit 078eedae6e
3 changed files with 58 additions and 50 deletions

View File

@@ -6,7 +6,7 @@
* @package phpMyAdmin * @package phpMyAdmin
*/ */
if (!defined('PHPMYADMIN')) { if (! defined('PHPMYADMIN')) {
exit; exit;
} }
@@ -16,9 +16,10 @@ function PMA_getUploadStatus($id) {
global $SESSION_KEY; global $SESSION_KEY;
global $ID_KEY; global $ID_KEY;
if (trim($id)=="") if (trim($id) == "") {
return; return;
if (!array_key_exists($id, $_SESSION[$SESSION_KEY])) { }
if (! array_key_exists($id, $_SESSION[$SESSION_KEY])) {
$_SESSION[$SESSION_KEY][$id] = array( $_SESSION[$SESSION_KEY][$id] = array(
'id' => $id, 'id' => $id,
'finished' => false, 'finished' => false,
@@ -30,8 +31,9 @@ function PMA_getUploadStatus($id) {
} }
$ret = $_SESSION[$SESSION_KEY][$id]; $ret = $_SESSION[$SESSION_KEY][$id];
if (!PMA_import_apcCheck() || $ret['finished']) if (! PMA_import_apcCheck() || $ret['finished']) {
return $ret; return $ret;
}
$status = apc_fetch('upload_' . $id); $status = apc_fetch('upload_' . $id);
if ($status) { if ($status) {
@@ -39,11 +41,13 @@ function PMA_getUploadStatus($id) {
$ret['total'] = $status['total']; $ret['total'] = $status['total'];
$ret['complete'] = $status['current']; $ret['complete'] = $status['current'];
if ($ret['total'] > 0) if ($ret['total'] > 0) {
$ret['percent'] = $ret['complete'] / $ret['total'] * 100; $ret['percent'] = $ret['complete'] / $ret['total'] * 100;
}
if ($ret['percent']==100) if ($ret['percent'] == 100) {
$ret['finished']=(bool)true; $ret['finished'] = (bool)true;
}
$_SESSION[$SESSION_KEY][$id] = $ret; $_SESSION[$SESSION_KEY][$id] = $ret;
} }

View File

@@ -6,7 +6,7 @@
* @package phpMyAdmin * @package phpMyAdmin
*/ */
if (!defined('PHPMYADMIN')) { if (! defined('PHPMYADMIN')) {
exit; exit;
} }
@@ -16,9 +16,10 @@ function PMA_getUploadStatus($id) {
global $SESSION_KEY; global $SESSION_KEY;
global $ID_KEY; global $ID_KEY;
if (trim($id)=="") if (trim($id) == "") {
return; return;
if (!array_key_exists($id, $_SESSION[$SESSION_KEY])) { }
if (! array_key_exists($id, $_SESSION[$SESSION_KEY])) {
$_SESSION[$SESSION_KEY][$id] = array( $_SESSION[$SESSION_KEY][$id] = array(
'id' => $id, 'id' => $id,
'finished' => false, 'finished' => false,
@@ -32,5 +33,4 @@ function PMA_getUploadStatus($id) {
return $ret; return $ret;
} }
?> ?>

View File

@@ -5,7 +5,7 @@
* @version $Id$ * @version $Id$
* @package phpMyAdmin * @package phpMyAdmin
*/ */
if (!defined('PHPMYADMIN')) { if (! defined('PHPMYADMIN')) {
exit; exit;
} }
@@ -15,10 +15,11 @@ function PMA_getUploadStatus($id) {
global $SESSION_KEY; global $SESSION_KEY;
global $ID_KEY; global $ID_KEY;
if (trim($id)=="") if (trim($id) == "") {
return; return;
}
if (!array_key_exists($id, $_SESSION[$SESSION_KEY])) { if (! array_key_exists($id, $_SESSION[$SESSION_KEY])) {
$_SESSION[$SESSION_KEY][$id] = array( $_SESSION[$SESSION_KEY][$id] = array(
'id' => $id, 'id' => $id,
'finished' => false, 'finished' => false,
@@ -30,21 +31,24 @@ function PMA_getUploadStatus($id) {
} }
$ret = $_SESSION[$SESSION_KEY][$id]; $ret = $_SESSION[$SESSION_KEY][$id];
if (!PMA_import_uploadprogressCheck() || $ret['finished']) if (! PMA_import_uploadprogressCheck() || $ret['finished']) {
return $ret; return $ret;
}
$status = uploadprogress_get_info($id); $status = uploadprogress_get_info($id);
if ($status) { if ($status) {
if ($status['bytes_uploaded']==$status['bytes_total']) if ($status['bytes_uploaded'] == $status['bytes_total']) {
$ret['finished'] = true; $ret['finished'] = true;
else } else {
$ret['finished'] = false; $ret['finished'] = false;
}
$ret['total'] = $status['bytes_total']; $ret['total'] = $status['bytes_total'];
$ret['complete'] = $status['bytes_uploaded']; $ret['complete'] = $status['bytes_uploaded'];
if ($ret['total'] > 0) if ($ret['total'] > 0) {
$ret['percent'] = $ret['complete'] / $ret['total'] * 100; $ret['percent'] = $ret['complete'] / $ret['total'] * 100;
}
} else { } else {
$ret = array( $ret = array(
'id' => $id, 'id' => $id,