function export_svn_logs($project, $span, $who)
{
    $eol = "\n";
    $sql_svn = svnaccess_logs_extract($project, $span, $who);
    $col_list_svn = array('day', 'user', 'email', 'svn_access_count', 'svn_browse');
    $svn_title = array('day' => $GLOBALS['Language']->getText('project_stats_source_code_access_utils', 'subversion'), 'user' => '', 'email' => '', 'svn_access_count' => '', 'svn_browse' => '');
    $lbl_list_svn = array('day' => $GLOBALS['Language']->getText('project_export_access_logs_export', 'time'), 'user' => $GLOBALS['Language']->getText('project_export_access_logs_export', 'user'), 'email' => $GLOBALS['Language']->getText('project_export_access_logs_export', 'email'), 'svn_access_count' => $GLOBALS['Language']->getText('project_export_access_logs_export', 'access'), 'svn_browse' => $GLOBALS['Language']->getText('project_export_access_logs_export', 'file_brows'));
    $result_svn = db_query($sql_svn);
    $rows_svn = db_numrows($result_svn);
    if ($result_svn && $rows_svn > 0) {
        // Build csv for subversion access logs
        echo build_csv_header($col_list_svn, $svn_title) . $eol;
        echo build_csv_header($col_list_svn, $lbl_list_svn) . $eol;
        while ($arr_svn = db_fetch_array($result_svn)) {
            prepare_access_logs_record($project->getGroupId(), $arr_svn);
            echo build_csv_record($col_list_svn, $arr_svn) . $eol;
        }
        echo build_csv_header($col_list_svn, array()) . $eol;
    }
}
function svnaccess_logs_daily($project, $span = 7, $who = "allusers")
{
    $hp = Codendi_HTMLPurifier::instance();
    // check first if service is used by this project
    // if service not used return immediately
    if (!$project->usesSVN()) {
        print '<P><B><U>' . $GLOBALS['Language']->getText('project_stats_source_code_access_utils', 'service_disabled', $GLOBALS['Language']->getText('project_stats_source_code_access_utils', 'subversion')) . '</U></B>';
        return;
    }
    $month_name = array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'June', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
    $sql = svnaccess_logs_extract($project, $span, $who);
    // Executions will continue until morale improves.
    $res = db_query($sql);
    print '<P><B><U>' . $GLOBALS['Language']->getText('project_stats_source_code_access_utils', 'access_for_past_x_days', array($GLOBALS['Language']->getText('project_stats_source_code_access_utils', 'svn_access'), $hp->purify($span))) . '</U></B></P>';
    // if there are any days, we have valid data.
    if (($nb_downloads = db_numrows($res)) >= 1) {
        print '<P><TABLE width="100%" cellpadding=2 cellspacing=0 border=0>' . '<TR valign="top">' . '<TD><B>' . $GLOBALS['Language']->getText('project_admin_utils', 'date') . '</B></TD>' . '<TD><B>' . $GLOBALS['Language']->getText('project_export_utils', 'user') . '</B></TD>' . '<TD><B>' . $GLOBALS['Language']->getText('project_export_artifact_history_export', 'email') . '</B></TD>' . '<TD><B>' . $GLOBALS['Language']->getText('project_stats_source_code_access_utils', 'accesses') . '</B></TD>' . '<TD><B>' . $GLOBALS['Language']->getText('project_stats_source_code_access_utils', 'browsing') . '</B></TD>' . '</TR>' . "\n";
        $i = 0;
        while ($row = db_fetch_array($res)) {
            $i++;
            print '<TR class="' . util_get_alt_row_color($i) . '">' . '<TD>' . substr($row["day"], 6, 2) . ' ' . $month_name[substr($row["day"], 4, 2) - 1] . ' ' . substr($row["day"], 0, 4) . '</TD>' . '<TD> <a href="/users/' . $hp->purify($row["user_name"]) . '/">' . $hp->purify($row["user_name"]) . '</a> (' . $hp->purify($row["realname"]) . ')</TD>' . '<TD>' . $hp->purify($row["email"]) . '</TD>' . '<TD>' . $hp->purify($row["svn_access_count"]) . '</TD>' . '<TD>' . $hp->purify($row["svn_browse"]) . '</TD>' . '</TR>' . "\n";
        }
        print '</TABLE>';
    } else {
        echo '<P>' . $GLOBALS['Language']->getText('project_stats_source_code_access_utils', 'no_access', $GLOBALS['Language']->getText('project_stats_source_code_access_utils', 'svn_access'));
    }
}