<?php $measurements = []; $dimensions = []; $totalWrappingPaperInSquareFeet = 0; $length = 0; $width = 0; $height = 0; $filename = "advent-day-two-input.txt"; $handle = fopen($filename, "r"); $contents = fread($handle, filesize($filename)); fclose($handle); $measurements = getDimensions($contents); $totalWrappingPaperInSquareFeet = parseDimensions($dimensions, $measurements); $totalRibbonInCubicFeet = parseDimensionsForRibbon($dimensions, $measurements); function getSurfaceArea($length, $width, $height) { $surfaceArea = 2 * ($length * $width) + 2 * ($width * $height) + 2 * ($length * $height); return $surfaceArea; } function getSlack($length, $width, $height) { $zAxisByXAxis = $length * $width; $xAxisByYAxis = $width * $height; $zAxisByYAxis = $length * $height; if ($zAxisByXAxis < $xAxisByYAxis && $zAxisByXAxis < $zAxisByYAxis) { return $zAxisByXAxis; } elseif ($xAxisByYAxis < $zAxisByYAxis) { return $xAxisByYAxis; } else { return $zAxisByYAxis;
require_once 'Gd2.php'; require_once 'S3.php'; define('MAX_TRIES', 10); //Settings $accessKey = ''; $secretKey = ''; $bucket = ''; $website = ''; $dimensions = ''; $redownloadImages = false; $overwriteThumbs = true; $recalculateThumbs = false; $compareThumbsBySize = false; //Prepare parameters $dimensions = parseDimensions($dimensions, $website); //Prepare values $imgPrefix = $website . '/full/'; $imgPrefixLen = strlen($imgPrefix); $imgPathLen = $imgPrefixLen + 4; //Initialise S3 object $s3 = new S3($accessKey, $secretKey, true); //Get list of images from the bucket $images = $s3->getBucket($bucket, $imgPrefix); $imgNumber = 1; $totalImgs = count($images); echo 'Number of images: ', $totalImgs, "\n"; if (!$totalImgs) { exit('No images in the bucket'); } $_reuploadThumbs = $overwriteThumbs || $compareThumbsBySize;