$method_dropbox = fs_get_archive_method_dropbox(); $num_dropbox = fs_get_archive_dropbox(); ?> <div style="padding-left:10px;padding-right:10px"> <?php echo sprintf(fs_r('%s compact data older than %s'), $method_dropbox, $num_dropbox); ?> <button class="button" id="fs_archive_button" onclick="toggleArchiveOldData()"> <?php fs_e('Compact now'); ?> </button> <div style="padding-top:10px;padding-left:10px;padding-right:10px;"> <span id="fs_archive_status"><?php echo sprintf(fs_r("%s days can be compacted, database size %s"), fs_get_num_old_days(), sprintf("%.1f MB", fs_get_database_size() / (1024 * 1024))); ?> </span> </div> <?php } else { echo "<b>" . fs_r('MySQL 4.1.14 or newer is required for data compacting support') . "</b>"; } ?> </div> </td> </tr> <tr> <td class="config_cell" colspan="2"> <h3><?php fs_e('Automatic version check');
function fs_ajax_archiveOldData(&$response) { if (!fs_ajax_assert_admin($response)) { return; } $days_remains = fs_get_num_old_days(); $new_archive_seesion = false; if (!isset($_POST['num_old_days'])) { $new_archive_seesion = true; $num_old_days = $days_remains; } else { $num_old_days = $_POST['num_old_days']; } if (is_numeric($num_old_days)) { $max_days_to_archive = $_POST['max_days_to_archive']; $response['num_old_days'] = $num_old_days; // quickly return a response to the client on the fist request $DAY = 60 * 60 * 24; $archive_older_than_days = fs_get_archive_older_than(); $archive_older_than = time() - $archive_older_than_days * $DAY; if (!$new_archive_seesion) { $res = fs_archive_old_data($archive_older_than, $max_days_to_archive); } else { $res = 0; } if (is_numeric($res)) { if ($res == 0 && !$new_archive_seesion) { $response['done'] = 'true'; } else { $response['send_request'] = "action=archiveOldData&num_old_days={$num_old_days}&max_days_to_archive={$max_days_to_archive}"; } $days_remains -= $res; $done = $num_old_days - $days_remains; if ($num_old_days > 0) { $p = $done / $num_old_days * 100; } else { $p = "100%"; } $response['fields']['fs_archive_status'] = sprintf(fs_r("Compacting %s days, %s done, database size is %s"), $num_old_days, sprintf("%.1f%%", $p), sprintf("%.1f MB", fs_get_database_size() / (1024 * 1024))); $response['status'] = 'ok'; fs_ajax_send_update($response); } else { ajax_error($response, "Error : {$res}"); } } else { ajax_error($response, "Error : {$num_old_days}"); } }