Esempio n. 1
0
        $refresh = new Refresh($api);
        $refresh->refresh();
        $success = 'The cache is updated for ' . $api->lang . ' language.';
        include 'templates/book.php';
    }
    if ($title === '') {
        include 'templates/book.php';
    } else {
        $creator = BookCreator::forApi($api, $format, $options);
        try {
            list($book, $file) = $creator->create($title);
        } catch (WSExportInvalidArgumentException $exception) {
            throw new HttpException('Unsupported Media Type', 415);
        }
        header('X-Robots-Tag: none');
        header('Content-Description: File Transfer');
        header('Content-Type: ' . $creator->getMimeType());
        header('Content-Disposition: attachment; filename="' . $title . '.' . $creator->getExtension() . '"');
        header('Content-length: ' . filesize($file));
        readfile($file);
        unlink($file);
        flush();
        CreationLog::singleton()->add($book, $format);
    }
} catch (Exception $exception) {
    if ($exception instanceof HttpException) {
        header('HTTP/1.1 ' . $exception->getCode() . ' ' . $exception->getMessage());
    }
    $error = htmlspecialchars($exception->getMessage());
    include 'templates/book.php';
}
Esempio n. 2
0
<?php

$wsexportConfig = ['basePath' => '..', 'tempPath' => '../temp', 'stat' => true];
function normalizeFormat($format)
{
    $parts = explode('-', $format);
    return $parts[0];
}
include_once __DIR__ . '/../book/init.php';
date_default_timezone_set('UTC');
$date = getdate();
$month = isset($_GET['month']) ? intval($_GET['month']) : $date['mon'];
$year = isset($_GET['year']) ? intval($_GET['year']) : $date['year'];
$stat = CreationLog::singleton()->getTypeAndLangStats($month, $year);
$val = [];
$total = [];
foreach ($stat as $format => $temp) {
    $format = normalizeFormat($format);
    foreach ($temp as $lang => $num) {
        if ($lang === '') {
            $lang = 'oldwiki';
        }
        $val[$lang][$format] += $num;
        $total[$format] += $num;
    }
}
ksort($val);
ksort($total);
include 'templates/stat.php';