Ejemplo n.º 1
0
/**
 * Returns the contents of the log file.
 *
 * @since 3.9.6
 */
function wprss_get_log()
{
    if (!file_exists(wprss_log_file())) {
        wprss_clear_log();
    }
    $contents = file_get_contents(wprss_log_file(), '');
    // Trim the log file to a fixed number of chars
    $limit = 10000;
    if (strlen($contents) > $limit) {
        file_put_contents(wprss_log_file(), substr($contents, 0, $limit));
        return wprss_get_log();
    } else {
        return $contents;
    }
}
Ejemplo n.º 2
0
/**
 * Downloads the log file.
 *
 * @since 4.7.8
 */
function wprss_download_log()
{
    if (!file_exists(wprss_log_file())) {
        wprss_clear_log();
    } else {
        $file = wprss_log_file();
        header('Content-Description: File Transfer');
        header('Content-type: text/plain');
        header('Content-Disposition: attachment; filename="error-log.txt"');
        header('Expires: 0');
        header('Cache-Control: must-revalidate');
        header('Pragma: public');
        header('Content-Length: ' . filesize($file));
        readfile($file);
        exit;
    }
}