コード例 #1
0
ファイル: db-sql.php プロジェクト: alx/blogsfera
function fs_get_num_old_days()
{
    $DAY = 60 * 60 * 24;
    $archive_older_than_days = fs_get_archive_older_than();
    $older_than = time() - $archive_older_than_days * $DAY;
    $hits = fs_hits_table();
    $sql = "SELECT DISTINCT SUBSTRING(timestamp,1,10) start, DATE_ADD(SUBSTRING(timestamp,1,10), INTERVAL 1 DAY) end FROM `{$hits}` WHERE timestamp < FROM_UNIXTIME('{$older_than}') ORDER BY `timestamp`";
    $fsdb =& fs_get_db_conn();
    $days = $fsdb->get_results($sql);
    if ($days === false) {
        return fs_db_error(false);
    }
    return count($days);
}
コード例 #2
0
ファイル: page-settings.php プロジェクト: alx/blogsfera
function fs_get_archive_dropbox()
{
    $selected = fs_get_archive_older_than();
    $arr = array();
    $arr[] = fs_mkPair(30, fs_r('One month'));
    $arr[] = fs_mkPair(60, fs_r('Two months'));
    $arr[] = fs_mkPair(90, fs_r('Three months'));
    $arr[] = fs_mkPair(180, fs_r('Half a year'));
    $arr[] = fs_mkPair(365, fs_r('One year'));
    $arr[] = fs_mkPair(365 * 2, fs_r('Two years'));
    $onchange = "saveSystemOption('archive_older_than','archive_older_than','positive_num','fs_archive_status')";
    return fs_create_dropbox($arr, $selected, 'archive_older_than', $onchange);
}
コード例 #3
0
</h3>
	<?php 
fs_e("FireStats can tranform old data to a more compact form,");
?>
<br/>
	<?php 
fs_e("This will reduce storage size and improve performance at the cost of losing some information which is not essential.");
?>
<br/>
	<?php 
fs_e("it is highly recommended that you allow FireStats to do this automatically.");
?>
<br/>
	<ul>
		<li><?php 
echo sprintf(fs_r("Click %s if you would like FireStats to automatically compact data older than %s days"), "<b>{$btyes}</b>", fs_get_archive_older_than());
?>
.</li>
		<li><?php 
echo sprintf(fs_r("Click %s if you want to compact data manually or change compacting options (From the Settings tab)"), "<b>{$btno}</b>");
?>
.</li>
	</ul>
	<div align='center' style='padding: 10px'>
		<button class='button' id='archive_manually' onclick='saveSystemOptionValue("archive_method","manual","string");closeParentWindow(this)'><?php 
echo $btno;
?>
</button>
		<span style='padding: 10px'/>
		<button class='button' id='archive_automatically' onclick='saveSystemOptionValue("archive_method","auto","string");closeParentWindow(this)'><?php 
echo $btyes;
コード例 #4
0
ファイル: ajax-handler.php プロジェクト: alx/blogsfera
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}");
    }
}