Пример #1
0
<?php

$relPath = "./../pinc/";
include_once $relPath . 'base.inc';
include_once $relPath . 'misc.inc';
// check that caller is localhost or bail
if (!requester_is_localhost()) {
    die("You are not authorized to perform this request.");
}
if (!$site_supports_metadata) {
    echo 'genthumbs.php: $site_supports_metadata is false, so exiting.';
    exit;
}
set_time_limit(90);
//this module looks for projects that do not have thumbs generated and generates them
$result = mysql_query("SELECT projectid, state FROM projects WHERE state = 'project_md_first' AND thumbs = 'no' LIMIT 1");
$projectid = mysql_result($result, 0, "projectid");
$state = mysql_result($result, 0, "state");
//make thumbs directory
$dest_project_dir = "{$projects_dir}/{$projectid}/thumbs";
if (!file_exists($dest_project_dir)) {
    mkdir("{$dest_project_dir}", 0777);
    chmod("{$dest_project_dir}", 0777);
}
$result = mysql_query("SELECT image FROM {$projectid}");
$numrows = mysql_num_rows($result);
$rownum = 0;
while ($rownum < $numrows) {
    //while ($row = mysql_fetch_row($result)) {
    $imagename = mysql_result($result, $rownum, "image");
    //setup our source and destination images
<?php

$relPath = '../pinc/';
include_once $relPath . 'base.inc';
include_once $relPath . 'misc.inc';
include_once $relPath . 'Stopwatch.inc';
// check that caller is localhost or bail
if (!requester_is_localhost() && php_sapi_name() != 'cli') {
    die("You are not authorized to perform this request.");
}
// Download the XML version of the Project Gutenberg catalog,
// extract desired data from it, and put that into a MySQL table.
//
// So far, the only desired data is the list of formats
// in which each etext is available.
//
// This script should probably be invoked nightly via crontab.
header('Content-type: text/plain');
set_time_limit(300);
$display_mapping = array('application/epub+zip' => 'EPUB', 'application/msword' => 'MS Word', 'application/ogg' => 'Ogg Audio', 'application/pdf' => 'PDF', 'application/postscript' => 'Postscript', 'application/prs.plucker' => 'Plucker', 'application/prs.tei' => 'TEI', 'application/prs.tex' => 'TeX', 'application/vnd.palm' => 'Palm', 'application/x-iso9660-image' => 'ISO CD/DVD Image', 'application/x-mobipocket-ebook' => 'Mobipocket', 'application/x-mslit-ebook' => 'MS Lit for PocketPC', 'application/x-qioo-ebook' => 'QiOO', 'application/x-tomeraider-ebook' => 'TomeRaider eBook', 'application/xml' => 'XML', 'audio/midi' => 'MIDI', 'audio/mp4' => 'MP4 Audio', 'audio/mpeg' => 'MPEG Audio', 'audio/ogg' => 'Ogg Audio', 'audio/x-ms-wma' => 'MS Audio', 'audio/x-wav' => 'MS Wave Audio', 'image/gif' => 'GIF', 'image/jpeg' => 'JPEG', 'image/png' => 'PNG', 'image/svg+xml' => 'SVG Image', 'image/tiff' => 'TIFF', 'text/css' => 'CSS Stylesheet', 'text/html' => 'HTML', 'text/plain' => 'Text', 'text/rtf' => 'RTF', 'text/x-rst' => 'reStructuredText', 'text/xml' => 'XML', 'video/mpeg' => 'MPEG Video', 'video/quicktime' => 'Quicktime Video', 'video/x-msvideo' => 'MS Video');
$start_from_scratch = TRUE;
$remote_catalog_url = "http://www.gutenberg.org/cache/epub/feeds/rdf-files.tar.bz2";
$local_compressed_file = "/tmp/rdf-files.tar.bz2";
$local_tar_file = "/tmp/rdf-files.tar";
$local_catalog_dir = "{$dyn_dir}/pg/catalog";
// -------------------------------
$trace = TRUE;
if ($trace) {
    $watch = new Stopwatch();
    $watch->start();
}