Beispiel #1
1
function processImage($uploadDir, $filename)
{
    $uploadedFile = combine($uploadDir, $filename);
    //save exif data
    $message = "File uploaded.";
    $exif = getImageMetadata($uploadedFile);
    $dateTaken = getExifDateTaken($uploadedFile, $exif);
    if (!$dateTaken) {
        $dateTaken = getDateFromFilename($filename);
    }
    if (!$dateTaken) {
        $dateTaken = getFileDate($uploadedFile);
    }
    $exif["dateTaken"] = $dateTaken;
    $description = arrayGetCoalesce($exif, "ImageDescription", "IPTC.Caption");
    $description = trim($description);
    writeCsvFile("{$uploadedFile}.txt", $exif);
    writeTextFile("{$uploadedFile}.js", jsValue($exif));
    //resize images and keep hd version
    $sizes = getConfig("thumbnails.sizes");
    $resized = resizeMultiple($uploadDir, $filename, $sizes);
    $keep = getConfig("thumbnails.keep");
    if ($keep) {
        moveFile("{$uploadDir}/.{$keep}", $filename, $uploadDir);
        deleteDir("{$uploadDir}/.{$keep}");
        unset($resized[$keep]);
    }
    if ($dateTaken) {
        setFileDate($uploadedFile, $dateTaken);
    }
    $vars = get_defined_vars();
    $result = array();
    $exif["meal"] = selectMeal($dateTaken);
    $result["_exif"] = $exif;
    $result["success"] = true;
    return addVarsToArray($result, "filename filesize mimeType dateTaken description", $vars);
}
Beispiel #2
0
//echo jsValue($fpConfig, true, true);
$username = fpCurrentUsername();
$upload_id = reqParam("upload_id");
debugVar("username", true);
debug("Request", $_REQUEST);
debug("GET request", $_GET);
debug("POST request", $_POST);
debug("POST files", $_FILES, true);
if (!$username) {
    return errorMessage("Not logged in.");
}
if (!$upload_id) {
    return errorMessage("No File deleted.");
}
$db = new SqlManager($fpConfig);
if ($db->offline) {
    return errorMessage("DB offline. No File deleted.");
}
//if profile filters( Q_ ) : demographic
//otherwise: personal
$params = array("table" => "user_upload");
addVarsToArray($params, "username upload_id");
//$results = demographicPortrait($db, $params);
$success = $db->delete($params);
$message = $success ? "record {$upload_id} deleted." : "record id {$upload_id} not deleted.";
$db->disconnect();
//TODO delete image file: check if other records for this user use this filename. if only 1, delete file and its thumbs.
$response = array();
addVarsToArray($response, "success message upload_id");
$response["time"] = getTimer(true);
echo jsValue($response, true, true);
Beispiel #3
0
    foreach ($groups as $groupValue) {
        if ($groupValue === "NULL") {
            continue;
        }
        $params[$groupBy] = $groupValue;
        $data = demographicPortrait($db, $params, $portraitType);
        if (!count($data)) {
            continue;
        }
        setExists($data);
        $groupKey = $groupValue;
        $groupKey = "group_{$groupValue}";
        $groupKey = str_replace(":", "_", $groupKey);
        if (@$form_answers[$groupValue]) {
            $groupTitles[$groupKey] = $form_answers[$groupValue]["label"];
        } else {
            if ($interval > 1) {
                $groupTitles[$groupKey] = str_replace(":", " to ", $groupValue);
            }
        }
        debugVar("groupTitles", "print_r");
        $results[$groupKey] = $data;
    }
}
$queries = $db->getLog();
$db->disconnect();
$response = array();
$response["time"] = getTimer(true);
addVarsToArray($response, "params age years users groups groupTitles queries results");
echo jsValue($response, true);
getTimer();