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,46 +6,50 @@
* @package phpMyAdmin
*/
if (!defined('PHPMYADMIN')) {
if (! defined('PHPMYADMIN')) {
exit;
}
$ID_KEY = 'APC_UPLOAD_PROGRESS';
function PMA_getUploadStatus($id) {
global $SESSION_KEY;
global $ID_KEY;
global $SESSION_KEY;
global $ID_KEY;
if (trim($id)=="")
return;
if (!array_key_exists($id, $_SESSION[$SESSION_KEY])) {
$_SESSION[$SESSION_KEY][$id] = array(
if (trim($id) == "") {
return;
}
if (! array_key_exists($id, $_SESSION[$SESSION_KEY])) {
$_SESSION[$SESSION_KEY][$id] = array(
'id' => $id,
'finished' => false,
'percent' => 0,
'total' => 0,
'complete' => 0,
'plugin' => $ID_KEY
);
'plugin' => $ID_KEY
);
}
$ret = $_SESSION[$SESSION_KEY][$id];
if (!PMA_import_apcCheck() || $ret['finished'])
return $ret;
if (! PMA_import_apcCheck() || $ret['finished']) {
return $ret;
}
$status = apc_fetch('upload_' . $id);
if ($status) {
$ret['finished'] = (bool)$status['done'];
$ret['total'] = $status['total'];
$ret['complete'] = $status['current'];
$ret['finished'] = (bool)$status['done'];
$ret['total'] = $status['total'];
$ret['complete'] = $status['current'];
if ($ret['total'] > 0)
$ret['percent'] = $ret['complete'] / $ret['total'] * 100;
if ($ret['total'] > 0) {
$ret['percent'] = $ret['complete'] / $ret['total'] * 100;
}
if ($ret['percent']==100)
$ret['finished']=(bool)true;
if ($ret['percent'] == 100) {
$ret['finished'] = (bool)true;
}
$_SESSION[$SESSION_KEY][$id] = $ret;
$_SESSION[$SESSION_KEY][$id] = $ret;
}
return $ret;

View File

@@ -6,31 +6,31 @@
* @package phpMyAdmin
*/
if (!defined('PHPMYADMIN')) {
exit;
if (! defined('PHPMYADMIN')) {
exit;
}
$ID_KEY = 'noplugin';
function PMA_getUploadStatus($id) {
global $SESSION_KEY;
global $ID_KEY;
global $SESSION_KEY;
global $ID_KEY;
if (trim($id)=="")
return;
if (!array_key_exists($id, $_SESSION[$SESSION_KEY])) {
$_SESSION[$SESSION_KEY][$id] = array(
if (trim($id) == "") {
return;
}
if (! array_key_exists($id, $_SESSION[$SESSION_KEY])) {
$_SESSION[$SESSION_KEY][$id] = array(
'id' => $id,
'finished' => false,
'percent' => 0,
'total' => 0,
'complete' => 0,
'plugin' => $ID_KEY
);
'plugin' => $ID_KEY
);
}
$ret = $_SESSION[$SESSION_KEY][$id];
return $ret;
}
?>

View File

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