Beispiel #1
0
<?php

session_start();
require_once 'inc/data.inc';
require_once 'inc/authorize.inc';
require_permission(ASSIGN_RACER_IMAGE_PERMISSION);
require_once 'inc/photo-config.inc';
$photo_repository = photo_repository(isset($_GET['repo']) ? $_GET['repo'] : 'head');
function scan_directory($directory, $pattern)
{
    $files = array();
    $dh = @opendir($directory);
    if ($dh !== false) {
        while (($filename = readdir($dh)) !== false) {
            if (preg_match($pattern, $filename) && is_file($directory . DIRECTORY_SEPARATOR . $filename)) {
                $files[] = $filename;
            }
        }
        closedir($dh);
    }
    return $files;
}
$allfiles = scan_directory($photo_repository->directory(), "/(jpg|jpeg|png|gif|bmp)/i");
// Returns a javascript expression, suitable for onclick, to perform cropping of a particular photo.
function photo_crop_expression($basename)
{
    global $photo_repository;
    return htmlspecialchars('showPhotoCropModal(this, "' . $photo_repository->name() . '", "' . $basename . '", ' . time() . ')', ENT_QUOTES, 'UTF-8');
}
// TODO: line-height?  "End of photos" text aligns with thumbnail image bottom.
// *** Both div's are overhanging the bottom by the amount taken up by the banner and refresh button!
Beispiel #2
0
    if (isset($_SERVER['ORIG_PATH_INFO'])) {
        // Rewrite rules in Apache 2.2 may leave ORIG_PATH_INFO instead of PATH_INFO
        $path_info = 'photo.php' . $_SERVER['ORIG_PATH_INFO'];
    } else {
        // Debugging only:
        var_export($_SERVER);
        exit(0);
    }
}
$parsed = parse_photo_url($path_info);
if (!$parsed) {
    // Malformed URL
    http_response_code(404);
    exit(1);
}
$repo = photo_repository($parsed['repository']);
if (!$repo) {
    // No such repository
    http_response_code(404);
    exit(1);
}
if ($parsed['url_type'] == 'racer') {
    $file_path = read_single_value('SELECT ' . $repo->column_name() . ' FROM RegistrationInfo' . ' WHERE racerid = :racerid', array(':racerid' => $parsed['racerid']));
    if (!$file_path) {
        // No such racer
        http_response_code(404);
        exit(1);
    }
} else {
    $render = $repo->lookup($parsed['render']);
    if (!$render) {