Skip to content

Commit

Permalink
scratchcard
Browse files Browse the repository at this point in the history
  • Loading branch information
shiolife committed Apr 15, 2024
0 parents commit ab42710
Show file tree
Hide file tree
Showing 28 changed files with 2,193 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.DS_Store
.idea/workspace.xml
.idea/tasks.xml
rescue/
config.php
notes
notes.js
faq.txt
27 changes: 27 additions & 0 deletions 404.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8"/>
<meta name="description" content="Koalas to the Max, a site made with love by Vadim Ogievetsky for Annie Albagli">
<meta name="keywords" content="Koalas Max Vadim Ogievetsky Annie Albagli D3 Canvas SVG Koala Maximization">
<link rel="stylesheet" media="screen, print" href="koala.css"/>
<title>Koala Not Found</title>
<script type="text/javascript">

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-17409200-2']);
_gaq.push(['_trackPageview']);

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

</script>
</head>
<body>
<div class="not-found"><a href="http://koalastothemax.com">Koala</a> not found</div>
<script src="//comebackhome.org/js/comebackhome.bundle.min.js"></script>
</body>
</html>
26 changes: 26 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Copyright (c) 2012, Vadim Ogievetsky
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

* The name Vadim Ogievetsky may not be used to endorse or promote products
derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL VADIM OGIEVETSKY BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
60 changes: 60 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Introducation

Exploration of pixalized koalas*.

(*may include animals other than koalas)

Made with love by [Vadim Ogievetsky](http://vadim.ogievetsky.com) for [Annie Albagli](http://anniealbagli.com)

Powered by [Mike Bostock](http://bost.ocks.org/mike/)'s [D3](http://d3js.org/)


# Usage

## Custom images

Supported URLs are:

1. DOMAIN
The just the page domain / loads one of the default files

2. DOMAIN?BA5E64==
Where BA5E64== is a UTF-8 base64 encoded string of one of the following things:

1. An image URL

Example: `http://i.imgur.com/cz1Jb.jpg`

Use that URL image instead of the default one.

2. A JSON string representing an array of URLs

Example: `["http://i.imgur.com/cz1Jb.jpg","http://i.imgur.com/Q5IqH.jpg"]`

Pick one of the images at random and use that instead of the default one.

3. A JSON string representing an object with the keys 'images', 'background' and 'hideNote'

Example: `{"background":"#000","images":["http://i.imgur.com/cz1Jb.jpg","http://i.imgur.com/Q5IqH.jpg"]}`

images (required): Pick one of the images at random and use that instead of the default one.

background (optional): Use the value of background as the page background.

hideNote (optional): Hide the mention on the bottom.

3. DOMAIN?image_url

Where image URL is an actual image URL this is for backwards compatibility.

Example: `http://i.imgur.com/cz1Jb.jpg`

This is how putting in a custom image used to work.

4. DOMAIN#a_string

This will redirect to DOMAIN?b64(a_string)

This should be used to construct things as above.

Note: where DOMAIN is usually http://koalastothemax.com
Binary file added astley.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions d3.min.js

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions example_config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?
// Rename this file to config.php after editing the fields bellow
$garbage = "some_garbage_string_to_be_used_for_redneck_encryption";

// How to generate the hashed filename form the URL.
function get_filename($url) {
// Make sure path/to/cache/dir exists
return "path/to/cache/dir/" . md5('something_to_prepend_' . $url . '_sometihng_to_append') . ".extension";
}
?>
Binary file added favicon.ico
Binary file not shown.
Binary file added favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
75 changes: 75 additions & 0 deletions image-server.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<?
require('config.php');

function my_urlencode($string) {
return str_replace(' ', '%20', $string);
}

try {
$ok = true;

// Check if the URL is set
if($ok && isset($_GET["url"])) {
// Get the URL and decode to remove any %20, etc
$url = urldecode($_GET["url"]);

// Hash the url
$filename = get_filename($url);
} else {
// No URL set so error
header('HTTP/1.0 400 Bad Request');
echo "No URL was specified";
$ok = false;
}

if($ok) {
if(file_exists($filename)) {
// Send cached file

$file = file_get_contents($filename, false, NULL, strlen($garbage));
} else {
// Load the image and save the file if valid image if found

// Get the contents of the URL
$file = file_get_contents(my_urlencode($url));

// Check if it is an image
$img = @imagecreatefromstring($file);
if($img) {
$max = 800;
$w = imagesx($img);
$h = imagesy($img);
if ($w > $max || $h > $max) {
// Resize the image if needed
$scale = min($max / $w, $max / $h);
$new_w = intval($scale * $w);
$new_h = intval($scale * $h);
$new_img = imagecreatetruecolor($new_w, $new_h);
imagecopyresampled($new_img, $img, 0, 0, 0, 0, $new_w, $new_h, $w, $h);
imagedestroy($img);
imagejpeg($new_img, $filename);
$file = file_get_contents($filename);
}

file_put_contents($filename, $garbage);
file_put_contents($filename, $file, FILE_APPEND);
} else {
// The requested file is not an image
header('HTTP/1.0 400 Bad Request');
print "Invalid image specified";
$ok = false;
}
}
}

if($ok) {
header('Content-Type: image');
print($file);
}

} catch (Exception $e) {
header('HTTP/1.0 500 Internal Server Error');
echo "Internal Server Error";
$ok = false;
}
?>
Binary file added img/dog.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/kitten.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/koalas.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/koalas1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/koalas2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/koalas3.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/lion.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/otter.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/owls.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/pandas.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit ab42710

Please sign in to comment.