From 401a35fc77a0d541c709432d2da2f6f260343f17 Mon Sep 17 00:00:00 2001 From: hendrowicaksono Date: Tue, 7 Jun 2016 09:47:44 +0700 Subject: [PATCH] Set only user with uid 1 can do database health and do repairment. Performance reason. --- admin/default/home.php | 49 ++++++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 23 deletions(-) diff --git a/admin/default/home.php b/admin/default/home.php index e7814bf..6fc48aa 100755 --- a/admin/default/home.php +++ b/admin/default/home.php @@ -77,39 +77,42 @@ $warnings[] = __('Installer folder is still exist inside your server. Please remove it or rename to another name for security reason.'); } +if ($_SESSION['uid'] === '1') { + $warnings[] = __('You are logged in as Super User. With great power comes great responsibility.'); + // check need to be repaired mysql database + $query_of_tables = $dbs->query('SHOW TABLES'); + $num_of_tables = $query_of_tables->num_rows; + $prevtable = ''; + $is_repaired = false; -// check need to be repaired mysql database -$query_of_tables = $dbs->query('SHOW TABLES'); -$num_of_tables = $query_of_tables->num_rows; -$prevtable = ''; -$is_repaired = false; - -if (isset ($_POST['do_repair'])) { + if (isset ($_POST['do_repair'])) { if ($_POST['do_repair'] == 1) { - while ($row = $query_of_tables->fetch_row()) { - $sql_of_repair = 'REPAIR TABLE '.$row[0]; - $query_of_repair = $dbs->query ($sql_of_repair); - } + while ($row = $query_of_tables->fetch_row()) { + $sql_of_repair = 'REPAIR TABLE '.$row[0]; + $query_of_repair = $dbs->query ($sql_of_repair); + } } -} + } -while ($row = $query_of_tables->fetch_row()) { + while ($row = $query_of_tables->fetch_row()) { $query_of_check = $dbs->query('CHECK TABLE '.$row[0]); while ($rowcheck = $query_of_check->fetch_assoc()) { - if (!(($rowcheck['Msg_type'] == "status") && ($rowcheck['Msg_text'] == "OK"))) { - if ($row[0] != $prevtable) { - echo '
  • Table '.$row[0].' might need to be repaired.
  • '; - } - $prevtable = $row[0]; - $is_repaired = true; + if (!(($rowcheck['Msg_type'] == "status") && ($rowcheck['Msg_text'] == "OK"))) { + if ($row[0] != $prevtable) { + echo '
  • Table '.$row[0].' might need to be repaired.
  • '; } + $prevtable = $row[0]; + $is_repaired = true; + } } + } + if (($is_repaired) && !isset($_POST['do_repair'])) { + echo '
  • '; + } } -if (($is_repaired) && !isset($_POST['do_repair'])) { - echo '
  • '; -} -// if there any warnings + +// if there are any warnings if ($warnings) { echo '
    '; echo '