add missing return keyword

fix some issues
This commit is contained in:
Nicolas Le Goff
2012-08-20 13:45:38 +02:00
parent 5744b3bd0c
commit 155d38c7fa
2 changed files with 65 additions and 114 deletions

View File

@@ -30,7 +30,7 @@ return call_user_func(function() {
$app = new PhraseaApplication(); $app = new PhraseaApplication();
$app->before(function () use ($app) { $app->before(function () use ($app) {
$app['phraseanet.core']['Firewall']->requireSetup($app); return $app['phraseanet.core']['Firewall']->requireSetup($app);
}); });
$app->get('/', function(SilexApp $app) { $app->get('/', function(SilexApp $app) {

View File

@@ -37,12 +37,12 @@ class Bas implements ControllerProviderInterface
if (null !== $response = $app['phraseanet.core']['Firewall']->requireAdmin($app)) { if (null !== $response = $app['phraseanet.core']['Firewall']->requireAdmin($app)) {
return $response; return $response;
} }
if ( ! $app['phraseanet.core']->getAUthenticatedUser()->ACL()->has_access_to_base($app['request']->get('bas_id'), 'canadmin')) {
if ( ! $app['phraseanet.core']->getAUthenticatedUser()->ACL()->has_right_on_base($app['request']->get('bas_id'), 'canadmin')) {
$app->abort(403); $app->abort(403);
} }
}); });
/** /**
* Get a collection * Get a collection
* *
@@ -107,11 +107,8 @@ class Bas implements ControllerProviderInterface
* *
* return : HTML Response * return : HTML Response
*/ */
$controllers->delete('/{bas_id}/', $this->call('delete'))->bind('admin_collection_delete')->before(function() use ($app) { $controllers->delete('/{bas_id}/', $this->call('delete'))
if ( ! $app['phraseanet.core']->getAUthenticatedUser()->ACL()->has_right_on_base($app['request']->get('bas_id'), 'canadmin')) { ->assert('bas_id', '\d+')->bind('admin_collection_delete');
$app->abort(403);
}
});
/** /**
* Enable collection * Enable collection
@@ -126,11 +123,8 @@ class Bas implements ControllerProviderInterface
* *
* return : HTML Response * return : HTML Response
*/ */
$controllers->post('/{bas_id}/enable/', $this->call('enable'))->bind('admin_collection_enable')->before(function() use ($app) { $controllers->post('/{bas_id}/enable/', $this->call('enable'))
if ( ! $app['phraseanet.core']->getAUthenticatedUser()->ACL()->has_right_on_base($app['request']->get('bas_id'), 'canadmin')) { ->assert('bas_id', '\d+')->bind('admin_collection_enable');
$app->abort(403);
}
});
/** /**
* Disabled collection * Disabled collection
@@ -145,11 +139,8 @@ class Bas implements ControllerProviderInterface
* *
* return : HTML Response * return : HTML Response
*/ */
$controllers->post('/{bas_id}/disabled/', $this->call('disabled'))->bind('admin_collection_disabled')->before(function() use ($app) { $controllers->post('/{bas_id}/disabled/', $this->call('disabled'))
if ( ! $app['phraseanet.core']->getAUthenticatedUser()->ACL()->has_right_on_base($app['request']->get('bas_id'), 'canadmin')) { ->assert('bas_id', '\d+')->bind('admin_collection_disabled');
$app->abort(403);
}
});
/** /**
* Set new order admin * Set new order admin
@@ -164,11 +155,8 @@ class Bas implements ControllerProviderInterface
* *
* return : HTML Response * return : HTML Response
*/ */
$controllers->post('/{bas_id}/order/admins/', $this->call('setOrderAdmins'))->bind('admin_collection_order_admins')->before(function() use ($app) { $controllers->post('/{bas_id}/order/admins/', $this->call('setOrderAdmins'))
if ( ! $app['phraseanet.core']->getAUthenticatedUser()->ACL()->has_right_on_base($app['request']->get('bas_id'), 'canadmin')) { ->assert('bas_id', '\d+')->bind('admin_collection_order_admins');
$app->abort(403);
}
});
/** /**
* Set publication watermark * Set publication watermark
@@ -183,11 +171,8 @@ class Bas implements ControllerProviderInterface
* *
* return : HTML Response * return : HTML Response
*/ */
$controllers->post('/{bas_id}/publication/display/', $this->call('setPublicationDisplay'))->bind('admin_collection_submit_publication')->before(function() use ($app) { $controllers->post('/{bas_id}/publication/display/', $this->call('setPublicationDisplay'))
if ( ! $app['phraseanet.core']->getAUthenticatedUser()->ACL()->has_right_on_base($app['request']->get('bas_id'), 'canadmin')) { ->assert('bas_id', '\d+')->bind('admin_collection_submit_publication');
$app->abort(403);
}
});
/** /**
* Rename a collection * Rename a collection
@@ -202,11 +187,8 @@ class Bas implements ControllerProviderInterface
* *
* return : HTML Response * return : HTML Response
*/ */
$controllers->post('/{bas_id}/rename/', $this->call('rename'))->bind('admin_collection_rename')->before(function() use ($app) { $controllers->post('/{bas_id}/rename/', $this->call('rename'))
if ( ! $app['phraseanet.core']->getAUthenticatedUser()->ACL()->has_right_on_base($app['request']->get('bas_id'), 'canadmin')) { ->assert('bas_id', '\d+')->bind('admin_collection_rename');
$app->abort(403);
}
});
/** /**
* Rename a collection * Rename a collection
@@ -221,11 +203,8 @@ class Bas implements ControllerProviderInterface
* *
* return : HTML Response * return : HTML Response
*/ */
$controllers->post('/{bas_id}/empty/', $this->call('emptyCollection'))->bind('admin_collection_empty')->before(function() use ($app) { $controllers->post('/{bas_id}/empty/', $this->call('emptyCollection'))
if ( ! $app['phraseanet.core']->getAUthenticatedUser()->ACL()->has_right_on_base($app['request']->get('bas_id'), 'canadmin')) { ->assert('bas_id', '\d+')->bind('admin_collection_empty');
$app->abort(403);
}
});
/** /**
* Unmount a collection * Unmount a collection
@@ -240,11 +219,8 @@ class Bas implements ControllerProviderInterface
* *
* return : HTML Response * return : HTML Response
*/ */
$controllers->post('/{bas_id}/unmount/', $this->call('unmount'))->bind('admin_collection_unmount')->before(function() use ($app) { $controllers->post('/{bas_id}/unmount/', $this->call('unmount'))
if ( ! $app['phraseanet.core']->getAUthenticatedUser()->ACL()->has_right_on_base($app['request']->get('bas_id'), 'canadmin')) { ->assert('bas_id', '\d+')->bind('admin_collection_unmount');
$app->abort(403);
}
});
/** /**
* Set a new logo * Set a new logo
@@ -259,11 +235,8 @@ class Bas implements ControllerProviderInterface
* *
* return : HTML Response * return : HTML Response
*/ */
$controllers->post('/{bas_id}/picture/mini-logo/', $this->call('setLogo'))->bind('admin_collection_submit_logo')->before(function() use ($app) { $controllers->post('/{bas_id}/picture/mini-logo/', $this->call('setMiniLogo'))
if ( ! $app['phraseanet.core']->getAUthenticatedUser()->ACL()->has_right_on_base($app['request']->get('bas_id'), 'canadmin')) { ->assert('bas_id', '\d+')->bind('admin_collection_submit_logo');
$app->abort(403);
}
});
/** /**
* Delete a mini logo * Delete a mini logo
@@ -278,11 +251,8 @@ class Bas implements ControllerProviderInterface
* *
* return : HTML Response * return : HTML Response
*/ */
$controllers->delete('/{bas_id}/picture/mini-logo/', $this->call('deleteLogo'))->bind('admin_collection_delete_logo')->before(function() use ($app) { $controllers->delete('/{bas_id}/picture/mini-logo/', $this->call('deleteLogo'))
if ( ! $app['phraseanet.core']->getAUthenticatedUser()->ACL()->has_right_on_base($app['request']->get('bas_id'), 'canadmin')) { ->assert('bas_id', '\d+')->bind('admin_collection_delete_logo');
$app->abort(403);
}
});
/** /**
* Set a new logo * Set a new logo
@@ -297,11 +267,8 @@ class Bas implements ControllerProviderInterface
* *
* return : HTML Response * return : HTML Response
*/ */
$controllers->post('/{bas_id}/picture/watermark/', $this->call('setWatermark'))->bind('admin_collection_submit_logo')->before(function() use ($app) { $controllers->post('/{bas_id}/picture/watermark/', $this->call('setWatermark'))
if ( ! $app['phraseanet.core']->getAUthenticatedUser()->ACL()->has_right_on_base($app['request']->get('bas_id'), 'canadmin')) { ->assert('bas_id', '\d+')->bind('admin_collection_submit_watermark');
$app->abort(403);
}
});
/** /**
* Delete a mini logo * Delete a mini logo
@@ -316,11 +283,8 @@ class Bas implements ControllerProviderInterface
* *
* return : HTML Response * return : HTML Response
*/ */
$controllers->delete('/{bas_id}/picture/watermark/', $this->call('deleteWatermark'))->bind('admin_collection_delete_logo')->before(function() use ($app) { $controllers->delete('/{bas_id}/picture/watermark/', $this->call('deleteWatermark'))
if ( ! $app['phraseanet.core']->getAUthenticatedUser()->ACL()->has_right_on_base($app['request']->get('bas_id'), 'canadmin')) { ->assert('bas_id', '\d+')->bind('admin_collection_delete_watermark');
$app->abort(403);
}
});
/** /**
* Set a new stamp logo * Set a new stamp logo
@@ -335,11 +299,8 @@ class Bas implements ControllerProviderInterface
* *
* return : HTML Response * return : HTML Response
*/ */
$controllers->post('/{bas_id}/picture/stamp-logo/', $this->call('setStamp'))->bind('admin_collection_submit_stamp')->before(function() use ($app) { $controllers->post('/{bas_id}/picture/stamp-logo/', $this->call('setStamp'))
if ( ! $app['phraseanet.core']->getAUthenticatedUser()->ACL()->has_right_on_base($app['request']->get('bas_id'), 'canadmin')) { ->assert('bas_id', '\d+')->bind('admin_collection_submit_stamp');
$app->abort(403);
}
});
/** /**
* Delete a stamp logo * Delete a stamp logo
@@ -354,11 +315,8 @@ class Bas implements ControllerProviderInterface
* *
* return : HTML Response * return : HTML Response
*/ */
$controllers->delete('/{bas_id}/picture/stamp-logo/', $this->call('deleteStamp'))->bind('admin_collection_delete_stamp')->before(function() use ($app) { $controllers->delete('/{bas_id}/picture/stamp-logo/', $this->call('deleteStamp'))
if ( ! $app['phraseanet.core']->getAUthenticatedUser()->ACL()->has_right_on_base($app['request']->get('bas_id'), 'canadmin')) { ->assert('bas_id', '\d+')->bind('admin_collection_delete_stamp');
$app->abort(403);
}
});
/** /**
* Set a new banner * Set a new banner
@@ -373,11 +331,8 @@ class Bas implements ControllerProviderInterface
* *
* return : HTML Response * return : HTML Response
*/ */
$controllers->post('/{bas_id}/picture/banner/', $this->call('setBanner'))->bind('admin_collection_submit_banner')->before(function() use ($app) { $controllers->post('/{bas_id}/picture/banner/', $this->call('setBanner'))
if ( ! $app['phraseanet.core']->getAUthenticatedUser()->ACL()->has_right_on_base($app['request']->get('bas_id'), 'canadmin')) { ->assert('bas_id', '\d+')->bind('admin_collection_submit_banner');
$app->abort(403);
}
});
/** /**
* Delete a banner * Delete a banner
@@ -392,11 +347,8 @@ class Bas implements ControllerProviderInterface
* *
* return : HTML Response * return : HTML Response
*/ */
$controllers->delete('/{bas_id}/picture/banner/', $this->call('deleteBanner'))->bind('admin_collection_delete_banner')->before(function() use ($app) { $controllers->delete('/{bas_id}/picture/banner/', $this->call('deleteBanner'))
if ( ! $app['phraseanet.core']->getAUthenticatedUser()->ACL()->has_right_on_base($app['request']->get('bas_id'), 'canadmin')) { ->assert('bas_id', '\d+')->bind('admin_collection_delete_banner');
$app->abort(403);
}
});
/** /**
* Get document details * Get document details
@@ -464,7 +416,7 @@ class Bas implements ControllerProviderInterface
} }
} }
return $app->redirect('/admin/bas/' . $bas_id . '/'); return $app->redirect('/admin/bas/' . $bas_id . '/?operation=ok');
} }
/** /**
@@ -479,14 +431,15 @@ class Bas implements ControllerProviderInterface
$app->abort(400, _('Bad request format, only JSON is allowed')); $app->abort(400, _('Bad request format, only JSON is allowed'));
} }
$message = _('Collection empty successful');
$success = false; $success = false;
$message = _('An error occurred');
try { try {
$collection = \collection::get_from_base_id($bas_id); $collection = \collection::get_from_base_id($bas_id);
if ($collection->get_record_amount() <= 500) { if ($collection->get_record_amount() <= 500) {
$collection->empty_collection(500); $collection->empty_collection(500);
$message = _('Collection empty successful');
} else { } else {
$settings = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<tasksettings>\n<bas_id>" . $collection->get_bas_id() . "</bas_id></tasksettings>"; $settings = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<tasksettings>\n<bas_id>" . $collection->get_bas_id() . "</bas_id></tasksettings>";
\task_abstract::create($app['phraseanet.appbox'], 'task_period_emptyColl', $settings); \task_abstract::create($app['phraseanet.appbox'], 'task_period_emptyColl', $settings);
@@ -495,10 +448,10 @@ class Bas implements ControllerProviderInterface
$success = true; $success = true;
} catch (\Exception $e) { } catch (\Exception $e) {
$message = _('An error occurred');
} }
return $app->json(array('success' => $success, 'message' => $message)); return $app->json(array('success' => $success, 'msg' => $message));
} }
/** /**
@@ -519,6 +472,7 @@ class Bas implements ControllerProviderInterface
try { try {
$collection = \collection::get_from_base_id($bas_id); $collection = \collection::get_from_base_id($bas_id);
$app['phraseanet.appbox']->write_collection_pic($collection, null, \collection::PIC_PRESENTATION); $app['phraseanet.appbox']->write_collection_pic($collection, null, \collection::PIC_PRESENTATION);
$success = true;
} catch (\Exception $e) { } catch (\Exception $e) {
} }
@@ -544,6 +498,7 @@ class Bas implements ControllerProviderInterface
try { try {
$collection = \collection::get_from_base_id($bas_id); $collection = \collection::get_from_base_id($bas_id);
$app['phraseanet.appbox']->write_collection_pic($collection, null, \collection::PIC_STAMP); $app['phraseanet.appbox']->write_collection_pic($collection, null, \collection::PIC_STAMP);
$success = true;
} catch (\Exception $e) { } catch (\Exception $e) {
} }
@@ -569,6 +524,7 @@ class Bas implements ControllerProviderInterface
try { try {
$collection = \collection::get_from_base_id($bas_id); $collection = \collection::get_from_base_id($bas_id);
$app['phraseanet.appbox']->write_collection_pic($collection, null, \collection::PIC_WM); $app['phraseanet.appbox']->write_collection_pic($collection, null, \collection::PIC_WM);
$success = true;
} catch (\Exception $e) { } catch (\Exception $e) {
} }
@@ -595,6 +551,7 @@ class Bas implements ControllerProviderInterface
$collection = \collection::get_from_base_id($bas_id); $collection = \collection::get_from_base_id($bas_id);
$collection->update_logo(null); $collection->update_logo(null);
$app['phraseanet.appbox']->write_collection_pic($collection, null, \collection::PIC_WM); $app['phraseanet.appbox']->write_collection_pic($collection, null, \collection::PIC_WM);
$success = true;
} catch (\Exception $e) { } catch (\Exception $e) {
} }
@@ -620,7 +577,7 @@ class Bas implements ControllerProviderInterface
return $app->redirect('/admin/bas/' . $bas_id . '/?upload-error=too-big'); return $app->redirect('/admin/bas/' . $bas_id . '/?upload-error=too-big');
} }
if ($file->isValid()) { if ( ! $file->isValid()) {
return $app->redirect('/admin/bas/' . $bas_id . '/?upload-error=unknow-error'); return $app->redirect('/admin/bas/' . $bas_id . '/?upload-error=unknow-error');
} }
@@ -630,13 +587,13 @@ class Bas implements ControllerProviderInterface
$app['phraseanet.appbox']->write_collection_pic($collection, $file, \collection::PIC_PRESENTATION); $app['phraseanet.appbox']->write_collection_pic($collection, $file, \collection::PIC_PRESENTATION);
$app['filesystem']->remove($file->getPathname()); $app['phraseanet.core']['file-system']->remove($file->getPathname());
} catch (\Exception $e) { } catch (\Exception $e) {
return $app->redirect('/admin/bas/' . $bas_id . '/?upload-error=unknow-error'); return $app->redirect('/admin/bas/' . $bas_id . '/?upload-error=unknow-error');
} }
return $app->redirect('/admin/bas/' . $bas_id . '/'); return $app->redirect('/admin/bas/' . $bas_id . '/?operation=ok');
} }
/** /**
@@ -657,7 +614,7 @@ class Bas implements ControllerProviderInterface
return $app->redirect('/admin/bas/' . $bas_id . '/?upload-error=too-big'); return $app->redirect('/admin/bas/' . $bas_id . '/?upload-error=too-big');
} }
if ($file->isValid()) { if ( ! $file->isValid()) {
return $app->redirect('/admin/bas/' . $bas_id . '/?upload-error=unknow-error'); return $app->redirect('/admin/bas/' . $bas_id . '/?upload-error=unknow-error');
} }
@@ -667,13 +624,13 @@ class Bas implements ControllerProviderInterface
$app['phraseanet.appbox']->write_collection_pic($collection, $file, \collection::PIC_STAMP); $app['phraseanet.appbox']->write_collection_pic($collection, $file, \collection::PIC_STAMP);
$app['filesystem']->remove($file->getPathname()); $app['phraseanet.core']['file-system']->remove($file->getPathname());
} catch (\Exception $e) { } catch (\Exception $e) {
return $app->redirect('/admin/bas/' . $bas_id . '/?upload-error=unknow-error'); return $app->redirect('/admin/bas/' . $bas_id . '/?upload-error=unknow-error');
} }
return $app->redirect('/admin/bas/' . $bas_id . '/'); return $app->redirect('/admin/bas/' . $bas_id . '/?operation=ok');
} }
/** /**
@@ -694,7 +651,7 @@ class Bas implements ControllerProviderInterface
return $app->redirect('/admin/bas/' . $bas_id . '/?upload-error=too-big'); return $app->redirect('/admin/bas/' . $bas_id . '/?upload-error=too-big');
} }
if ($file->isValid()) { if ( ! $file->isValid()) {
return $app->redirect('/admin/bas/' . $bas_id . '/?upload-error=unknow-error'); return $app->redirect('/admin/bas/' . $bas_id . '/?upload-error=unknow-error');
} }
@@ -704,13 +661,13 @@ class Bas implements ControllerProviderInterface
$app['phraseanet.appbox']->write_collection_pic($collection, $file, \collection::PIC_WM); $app['phraseanet.appbox']->write_collection_pic($collection, $file, \collection::PIC_WM);
$app['filesystem']->remove($file->getPathname()); $app['phraseanet.core']['file-system']->remove($file->getPathname());
} catch (\Exception $e) { } catch (\Exception $e) {
return $app->redirect('/admin/bas/' . $bas_id . '/?upload-error=unknow-error'); return $app->redirect('/admin/bas/' . $bas_id . '/?upload-error=unknow-error');
} }
return $app->redirect('/admin/bas/' . $bas_id . '/'); return $app->redirect('/admin/bas/' . $bas_id . '/?operation=ok');
} }
/** /**
@@ -731,7 +688,7 @@ class Bas implements ControllerProviderInterface
return $app->redirect('/admin/bas/' . $bas_id . '/?upload-error=too-big'); return $app->redirect('/admin/bas/' . $bas_id . '/?upload-error=too-big');
} }
if ($file->isValid()) { if ( ! $file->isValid()) {
return $app->redirect('/admin/bas/' . $bas_id . '/?upload-error=unknow-error'); return $app->redirect('/admin/bas/' . $bas_id . '/?upload-error=unknow-error');
} }
@@ -741,13 +698,13 @@ class Bas implements ControllerProviderInterface
$app['phraseanet.appbox']->write_collection_pic($collection, $file, \collection::PIC_LOGO); $app['phraseanet.appbox']->write_collection_pic($collection, $file, \collection::PIC_LOGO);
$app['filesystem']->remove($file->getPathname()); $app['phraseanet.core']['file-system']->remove($file->getPathname());
} catch (\Exception $e) { } catch (\Exception $e) {
return $app->redirect('/admin/bas/' . $bas_id . '/?upload-error=unknow-error'); return $app->redirect('/admin/bas/' . $bas_id . '/?upload-error=unknow-error');
} }
return $app->redirect('/admin/bas/' . $bas_id . '/'); return $app->redirect('/admin/bas/' . $bas_id . '/?operation=ok');
} }
/** /**
@@ -771,7 +728,7 @@ class Bas implements ControllerProviderInterface
if ($collection->get_record_amount() > 0) { if ($collection->get_record_amount() > 0) {
$msg = _('admin::base:collection: vider la collection avant de la supprimer'); $msg = _('admin::base:collection: vider la collection avant de la supprimer');
} else { } else {
$collection->unmount_collection($appbox); $collection->unmount_collection($app['phraseanet.appbox']);
$collection->delete(); $collection->delete();
$success = true; $success = true;
$msg = _('forms::operation effectuee OK'); $msg = _('forms::operation effectuee OK');
@@ -795,10 +752,6 @@ class Bas implements ControllerProviderInterface
$app->abort(400, _('Bad request format, only JSON is allowed')); $app->abort(400, _('Bad request format, only JSON is allowed'));
} }
if (null === $name = $request->get('name')) {
$app->abort(400, _('Missing name format'));
}
$success = false; $success = false;
$msg = _('An error occured'); $msg = _('An error occured');
@@ -857,10 +810,6 @@ class Bas implements ControllerProviderInterface
$app->abort(400, _('Bad request format, only JSON is allowed')); $app->abort(400, _('Bad request format, only JSON is allowed'));
} }
if ( ! $app['phraseanet.core']->getAuthenticatedUser()->ACL()->has_right_on_base($bas_id, 'canadmin')) {
$app->abort(403);
}
if (null === $watermark = $request->get('pub_wm')) { if (null === $watermark = $request->get('pub_wm')) {
$app->abort(400, _('Missing pub_wm format')); $app->abort(400, _('Missing pub_wm format'));
} }
@@ -886,7 +835,7 @@ class Bas implements ControllerProviderInterface
* @param \Symfony\Component\HttpFoundation\Request $request * @param \Symfony\Component\HttpFoundation\Request $request
* @param integer $bas_id * @param integer $bas_id
*/ */
public function enabled(Application $app, Request $request, $bas_id) public function enable(Application $app, Request $request, $bas_id)
{ {
if ( ! $request->isXmlHttpRequest() || ! array_key_exists($request->getMimeType('json'), array_flip($request->getAcceptableContentTypes()))) { if ( ! $request->isXmlHttpRequest() || ! array_key_exists($request->getMimeType('json'), array_flip($request->getAcceptableContentTypes()))) {
$app->abort(400, _('Bad request format, only JSON is allowed')); $app->abort(400, _('Bad request format, only JSON is allowed'));
@@ -1042,7 +991,6 @@ class Bas implements ControllerProviderInterface
*/ */
public function getDetails(Application $app, Request $request, $bas_id) public function getDetails(Application $app, Request $request, $bas_id)
{ {
$databox = $app['phraseanet.appbox']->get_databox(\phrasea::sbasFromBas($bas_id));
$collection = \collection::get_from_base_id($bas_id); $collection = \collection::get_from_base_id($bas_id);
$out = array('total' => array('totobj' => 0, 'totsiz' => 0, 'mega' => '0', 'giga' => '0'), 'result' => array()); $out = array('total' => array('totobj' => 0, 'totsiz' => 0, 'mega' => '0', 'giga' => '0'), 'result' => array());
@@ -1083,21 +1031,24 @@ class Bas implements ControllerProviderInterface
} }
$out['total']['totobj'] += $outRow['amount']; $out['total']['totobj'] += $outRow['amount'];
if (extension_loaded("bcmath")) { if (extension_loaded("bcmath")) {
$out['total']['totsiz'] = bcadd($out['total']['totsiz'], $outRow['midsiz'], 0); $out['total']['totsiz'] = bcadd($out['total']['totsiz'], $outRow['midsiz'], 0);
} else { } else {
$out['total']['totsiz'] += $outRow['midsiz']; $out['total']['totsiz'] += $outRow['midsiz'];
} }
if (extension_loaded("bcmath")) if (extension_loaded("bcmath")) {
$mega = bcdiv($outRow['midsiz'], 1024 * 1024, 5); $mega = bcdiv($outRow['midsiz'], 1024 * 1024, 5);
else } else {
$mega = $outRow['midsiz'] / (1024 * 1024); $mega = $outRow['midsiz'] / (1024 * 1024);
}
if (extension_loaded("bcmath")) if (extension_loaded("bcmath")) {
$giga = bcdiv($outRow['midsiz'], 1024 * 1024 * 1024, 5); $giga = bcdiv($outRow['midsiz'], 1024 * 1024 * 1024, 5);
else } else {
$giga = $outRow['midsiz'] / (1024 * 1024 * 1024); $giga = $outRow['midsiz'] / (1024 * 1024 * 1024);
}
$outRow['mega_mid_size'] = sprintf("%.2f", $mega); $outRow['mega_mid_size'] = sprintf("%.2f", $mega);
$outRow['giga_mid_size'] = sprintf("%.2f", $giga); $outRow['giga_mid_size'] = sprintf("%.2f", $giga);