Add image thumbnail cache, do lots of adjustments
parent
ac1e937dfd
commit
0489caabca
@ -0,0 +1,11 @@
|
|||||||
|
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
|
# Redirect 404'd thumbnail requests to a script that will generate them.
|
||||||
|
|
||||||
|
RewriteEngine on
|
||||||
|
|
||||||
|
RewriteCond %{REQUEST_FILENAME} !-d
|
||||||
|
RewriteCond %{REQUEST_FILENAME} !-f
|
||||||
|
RewriteRule ^(.*)/?$ handle_404.php?file=$1 [QSA,L]
|
@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
*/
|
||||||
|
|
||||||
|
require_once __DIR__ . "/../required.php";
|
||||||
|
|
||||||
|
$fileparts = explode(".", end(explode("/", $_GET['file'])));
|
||||||
|
|
||||||
|
if (count($fileparts) != 3 || !preg_match("/[0-9]+/", $fileparts[1]) || $fileparts[2] != "jpg") {
|
||||||
|
http_response_code(403);
|
||||||
|
die("Invalid filename.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!preg_match("/^[A-Za-z0-9\-!_]+$/", $fileparts[0])) {
|
||||||
|
http_response_code(403);
|
||||||
|
die("Encoded image URL invalid, refusing to parse.");
|
||||||
|
}
|
||||||
|
|
||||||
|
$url = Base64::decode($fileparts[0]);
|
||||||
|
|
||||||
|
if (!filter_var($url, FILTER_VALIDATE_URL)) {
|
||||||
|
http_response_code(403);
|
||||||
|
die("Invalid URL.");
|
||||||
|
}
|
||||||
|
|
||||||
|
//header("Content-Type: image/jpeg");
|
||||||
|
echo Thumbnail::addThumbnailToCache($url, (int) $fileparts[1]);
|
@ -0,0 +1,3 @@
|
|||||||
|
This folder is for the thumbnail cache.
|
||||||
|
|
||||||
|
This file is so Git doesn't remove the folder.
|
@ -1,4 +1,5 @@
|
|||||||
{
|
{
|
||||||
"Home": "Home",
|
"Overview": "Overview",
|
||||||
"Form": "Form"
|
"News": "News",
|
||||||
|
"Headlines": "Headlines"
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,53 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Alternative Base64 encoding/decoding that's safe for filenames and URLs.
|
||||||
|
*/
|
||||||
|
class Base64 {
|
||||||
|
|
||||||
|
const STANDARD_CHARS = ['+', '/', '='];
|
||||||
|
const ALTERNATE_CHARS = ['-', '!', '_'];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Encode $data into "alternate" Base64.
|
||||||
|
* @param mixed $data
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function encode($data): string {
|
||||||
|
return self::toAlternate(base64_encode($data));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Decode "alternate" Base64 into the original data.
|
||||||
|
* @param string $base64
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public static function decode(string $base64) {
|
||||||
|
return base64_decode(self::toStandard($base64));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert "alternate" Base64 into standard Base64.
|
||||||
|
* @param string $base64
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function toStandard(string $base64): string {
|
||||||
|
return str_replace(self::ALTERNATE_CHARS, self::STANDARD_CHARS, $base64);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert standard Base64 into URL and filename safe "alternate" Base64.
|
||||||
|
* @param string $base64
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function toAlternate(string $base64): string {
|
||||||
|
return str_replace(self::STANDARD_CHARS, self::ALTERNATE_CHARS, $base64);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
*/
|
||||||
|
|
||||||
|
class Weather_DarkSky extends Weather {
|
||||||
|
|
||||||
|
}
|
@ -1,26 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file demonstrates creating a form with the FormBuilder class.
|
|
||||||
*/
|
|
||||||
|
|
||||||
$form = new FormBuilder("Sample Form", "fas fa-code", "", "GET");
|
|
||||||
|
|
||||||
$form->setID("sampleform");
|
|
||||||
|
|
||||||
$form->addHiddenInput("page", "form");
|
|
||||||
|
|
||||||
$form->addInput("name", "John", "text", true, null, null, "Your name", "fas fa-user", 6, 5, 20, "John(ny)?|Steve", "Invalid name, please enter John, Johnny, or Steve.");
|
|
||||||
$form->addInput("location", "", "select", true, null, ["1" => "Here", "2" => "There"], "Location", "fas fa-map-marker");
|
|
||||||
$form->addInput("textbox", "Hello world", "textarea", true, null, null, "Text area", "fas fa-font");
|
|
||||||
$form->addInput("box", "1", "checkbox", true, null, null, "I agree to the terms of service");
|
|
||||||
|
|
||||||
$form->addButton("Submit", "fas fa-save", null, "submit", "savebtn");
|
|
||||||
|
|
||||||
$form->generate();
|
|
Loading…
Reference in New Issue