Skip to content

Commit

Permalink
Set only user with uid 1 can do database health and do repairment. Pe…
Browse files Browse the repository at this point in the history
…rformance reason.
  • Loading branch information
hendrowicaksono committed Jun 7, 2016
1 parent bcd926d commit 4d8e5bc
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions admin/default/home.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,37 +85,40 @@
$repair = '';
$is_repaired = false;

if (isset ($_POST['do_repair'])) {
if ($_SESSION['uid'] === '1') {
$warnings[] = __('<strong><i>You are logged in as Super User. With great power comes great responsibility.</i></strong>');
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) {
$repair .= '<li>Table '.$row[0].' might need to be repaired.</li>';
}
$prevtable = $row[0];
$is_repaired = true;
if (!(($rowcheck['Msg_type'] == "status") && ($rowcheck['Msg_text'] == "OK"))) {
if ($row[0] != $prevtable) {
$repair .= '<li>Table '.$row[0].' might need to be repaired.</li>';
}
$prevtable = $row[0];
$is_repaired = true;
}
}
}
if (($is_repaired) && !isset($_POST['do_repair'])) {
}
if (($is_repaired) && !isset($_POST['do_repair'])) {
echo '<div class="message">';
echo '<ul>';
echo $repair;
echo '</ul>';
echo '</div>';
echo ' <form method="POST" style="margin:0 10px;">
<input type="hidden" name="do_repair" value="1">
<input type="submit" value="'.__('Click Here To Repaire The Tables').'" class="button btn btn-block btn-default">
<input type="submit" value="'.__('Click Here To Repair The Tables').'" class="button btn btn-block btn-default">
</form>';
}
}

// if there any warnings
Expand Down

0 comments on commit 4d8e5bc

Please sign in to comment.