feat: add videodb media index with Docker stack

- Add videodb PHP/MySQL media collection manager (Blu-ray, DVD, CD)
- Dockerfile: PHP 8.1 + Apache with GD/mysqli/exif extensions
- docker-compose.yml: app on port 6761 + MySQL 8.0 with health checks
- docker-entrypoint.sh: auto-generates config.inc.php from env vars,
  waits for MySQL, initializes DB schema idempotently
- init-db.php: CLI schema installer using app's own prefix_query() logic
- Persistent volumes for DB, cache, and cover images

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-11 09:49:52 +02:00
commit f55c91276e
1230 changed files with 252321 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
<?php
if (empty($_REQUEST['list'])) {
header('Location: phpThumb.demo.demo.php');
exit;
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Demo of phpThumb() - thumbnails created by PHP using GD and/or ImageMagick</title>
<link rel="stylesheet" type="text/css" href="/style.css" title="style sheet">
<link rel="shortcut icon" type="image/x-icon" href="http://phpthumb.sourceforge.net/thumb.ico">
<meta http-equiv="Content-type" content="text/html;charset=UTF-8">
</head>
<body style="background-color: #C5C5C5;">
<?php
$dh = opendir('.');
while ($file = readdir($dh)) {
if (is_file($file) && ($file[0] != '.') && ($file != basename(__FILE__))) {
switch ($file) {
case 'phpThumb.demo.object.simple.php':
case 'phpThumb.demo.object.php':
echo '<code>'.str_replace(' ', '&nbsp;', str_pad(filesize($file), 10, ' ', STR_PAD_LEFT)).'</code> '.$file.' (cannot work as a live demo)<br>';
break;
default:
echo '<code>'.str_replace(' ', '&nbsp;', str_pad(filesize($file), 10, ' ', STR_PAD_LEFT)).'</code> <a href="'.$file.'">'.$file.'</a><br>';
break;
}
}
}
?>
</body>
</html>

View File

@@ -0,0 +1,311 @@
///////////////////////////////////////////////////////////////////////////////
//
// This code taken from:
// http://www.aspandjavascript.co.uk/javascript/javascript_api/
//
//
// Conditions of Use (from http://www.aspandjavascript.co.uk/about/conditions.asp)
//
// The Begging Bowl
// ================
// Though the code on the site is free, building, testing and maintaining dHTML
// code is a nasty laborious business and takes up a lot of time. If you use
// code from ASPAndJavaScript.co.uk in a commercial website, or for a paying
// client or use software from the site in a commercial environment, we politely
// invite you to consider making a donation of $20 (or whatever you consider
// appropriate) to help support the site.
//
// Donations can be made through PayPal using the button on the left of the page,
// or "in kind" through our Amazon Wish List (click the link and search for
// jamesdoz@hotmail.com). Donations go towrds the hosting costs of the site.
//
// You can also offer support by visiting our sister site ComputerBookPrices.com
// and using the price comparison system to find great deals on computer books
// and manuals.
//
//
// Copyright
// =========
// All code available on this site is copyrighted to James Austin (unless
// otherwise stated) and must retain any copyright messages.
//
//
// Disclaimer
// ==========
// All code on the site is available to download for free. No liability is
// accepted for any loss or damage, financial or otherwise arising from the
// viewing or use of this web site or any of its contents.
//
//
// Technical Support
// =================
// As stated above, we accept no liability for the contents of the site and do
// not guarantee to offer technical support for it. We do, however, appreciate
// feedback and always try to answer any questions and queries as thouroughly
// as time allows.
//
// If you have problems using the code or just questions about how it all works,
// please contact us at jamesdoz@hotmail.com, bug reports can be submitted to
// the same address
//
// Please include as much information as possible with your query, such as
// operating system, browser etc. Error messages and screenshots (where
// applicable) are helpful too.
//
///////////////////////////////////////////////////////////////////////////////
function sniffBrowsers() {
var ns4 = document.layers;
var op5 = (navigator.userAgent.indexOf("Opera 5")!=-1) ||(navigator.userAgent.indexOf("Opera/5")!=-1);
var op6 = (navigator.userAgent.indexOf("Opera 6")!=-1) ||(navigator.userAgent.indexOf("Opera/6")!=-1);
var agt=navigator.userAgent.toLowerCase();
var mac = (agt.indexOf("mac")!=-1);
var ie = (agt.indexOf("msie") != -1);
var mac_ie = mac && ie;
}
function getStyleObject(objectId) {
if(document.getElementById && document.getElementById(objectId)) {
return document.getElementById(objectId).style;
} else if (document.all && document.all(objectId)) {
return document.all(objectId).style;
} else if (document.layers && document.layers[objectId]) {
return getObjNN4(document,objectId);
} else {
return false;
}
}
function changeObjectVisibility(objectId, newVisibility) {
var styleObject = getStyleObject(objectId, document);
if(styleObject) {
styleObject.visibility = newVisibility;
return true;
} else {
return false;
}
}
function findImage(name, doc) {
var i, img;
for (i = 0; i < doc.images.length; i++) {
if (doc.images[i].name == name) {
return doc.images[i];
}
}
for (i = 0; i < doc.layers.length; i++) {
if ((img = findImage(name, doc.layers[i].document)) != null) {
img.container = doc.layers[i];
return img;
}
}
return null;
}
function getImage(name) {
if (document.layers) {
return findImage(name, document);
}
return null;
}
function getObjNN4(obj,name)
{
var x = obj.layers;
var foundLayer;
for (var i=0;i<x.length;i++)
{
if (x[i].id == name)
foundLayer = x[i];
else if (x[i].layers.length)
var tmp = getObjNN4(x[i],name);
if (tmp) foundLayer = tmp;
}
return foundLayer;
}
function getElementHeight(Elem) {
if (ns4) {
var elem = getObjNN4(document, Elem);
return elem.clip.height;
} else {
var elem;
if(document.getElementById) {
var elem = document.getElementById(Elem);
} else if (document.all){
var elem = document.all[Elem];
}
if (op5) {
xPos = elem.style.pixelHeight;
} else {
xPos = elem.offsetHeight;
}
return xPos;
}
}
function getElementWidth(Elem) {
if (ns4) {
var elem = getObjNN4(document, Elem);
return elem.clip.width;
} else {
var elem;
if(document.getElementById) {
var elem = document.getElementById(Elem);
} else if (document.all){
var elem = document.all[Elem];
}
if (op5) {
xPos = elem.style.pixelWidth;
} else {
xPos = elem.offsetWidth;
}
return xPos;
}
}
function getElementLeft(Elem) {
if (ns4) {
var elem = getObjNN4(document, Elem);
return elem.pageX;
} else {
var elem;
if(document.getElementById) {
var elem = document.getElementById(Elem);
} else if (document.all){
var elem = document.all[Elem];
}
xPos = elem.offsetLeft;
tempEl = elem.offsetParent;
while (tempEl != null) {
xPos += tempEl.offsetLeft;
tempEl = tempEl.offsetParent;
}
return xPos;
}
}
function getElementTop(Elem) {
if (ns4) {
var elem = getObjNN4(document, Elem);
return elem.pageY;
} else {
if(document.getElementById) {
var elem = document.getElementById(Elem);
} else if (document.all) {
var elem = document.all[Elem];
}
yPos = elem.offsetTop;
tempEl = elem.offsetParent;
while (tempEl != null) {
yPos += tempEl.offsetTop;
tempEl = tempEl.offsetParent;
}
return yPos;
}
}
function getImageLeft(myImage) {
var x, obj;
if (document.layers) {
var img = getImage(myImage);
if (img.container != null)
return img.container.pageX + img.x;
else
return img.x;
} else {
return getElementLeft(myImage);
}
return -1;
}
function getImageTop(myImage) {
var y, obj;
if (document.layers) {
var img = getImage(myImage);
if (img.container != null)
return img.container.pageY + img.y;
else
return img.y;
} else {
return getElementTop(myImage);
}
return -1;
}
function getImageWidth(myImage) {
var x, obj;
if (document.layers) {
var img = getImage(myImage);
return img.width;
} else {
return getElementWidth(myImage);
}
return -1;
}
function getImageHeight(myImage) {
var y, obj;
if (document.layers) {
var img = getImage(myImage);
return img.height;
} else {
return getElementHeight(myImage);
}
return -1;
}
function moveXY(myObject, x, y) {
obj = getStyleObject(myObject)
if (ns4) {
obj.top = y;
obj.left = x;
} else {
if (op5) {
obj.pixelTop = y;
obj.pixelLeft = x;
} else {
obj.top = y + 'px';
obj.left = x + 'px';
}
}
}
function changeClass(Elem, myClass) {
var elem;
if(document.getElementById) {
var elem = document.getElementById(Elem);
} else if (document.all){
var elem = document.all[Elem];
}
elem.className = myClass;
}
function changeImage(target, source) {
var imageObj;
if (ns4) {
imageObj = getImage(target);
if (imageObj) imageObj.src = eval(source).src;
} else {
imageObj = eval('document.images.' + target);
if (imageObj) imageObj.src = eval(source).src;
}
}
function changeBGColour(myObject, colour) {
if (ns4) {
var obj = getObjNN4(document, myObject);
obj.bgColor=colour;
} else {
var obj = getStyleObject(myObject);
if (op5) {
obj.background = colour;
} else {
obj.backgroundColor = colour;
}
}
}

View File

@@ -0,0 +1,580 @@
<?php
//////////////////////////////////////////////////////////////
// phpThumb() by James Heinrich <info@silisoftware.com> //
// available at http://phpthumb.sourceforge.net //
// and/or https://github.com/JamesHeinrich/phpThumb //
//////////////////////////////////////////////////////////////
/// //
// phpThumb.demo.check.php //
// James Heinrich <info@silisoftware.com> //
// //
// Configuration analyzer for phpThumb settings and server //
// settings that may affect phpThumb performance //
// Live demo is at http://phpthumb.sourceforge.net/demo/ //
// //
//////////////////////////////////////////////////////////////
die('For security reasons, this demo is disabled by default. Please comment out line '.__LINE__.' in '.basename(__FILE__));
$ServerInfo['gd_string'] = 'unknown';
$ServerInfo['gd_numeric'] = 0;
//ob_start();
if (!include_once '../phpthumb.functions.php' ) {
ob_end_flush();
die('failed to include_once("../phpthumb.functions.php")');
}
if (!include_once '../phpthumb.class.php' ) {
//ob_end_flush();
die('failed to include_once("../phpthumb.class.php")');
}
//ob_end_clean();
$phpThumb = new phpThumb();
if (file_exists('../phpThumb.config.php') && include_once '../phpThumb.config.php' ) {
foreach ($PHPTHUMB_CONFIG as $key => $value) {
$phpThumb->setParameter('config_'.$key, $value);
}
} else {
echo '<div style="color: red; border: 1px red dashed; font-weight: bold; padding: 10px; margin: 10px; display: inline-block;">Error reading ../phpThumb.config.php</div><br>';
}
$ServerInfo['gd_string'] = phpthumb_functions::gd_version(true);
$ServerInfo['gd_numeric'] = phpthumb_functions::gd_version(false);
$ServerInfo['im_version'] = $phpThumb->ImageMagickVersion();
$gd_info = gd_info();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>phpThumb configuration analyzer</title>
<link rel="stylesheet" type="text/css" href="/style.css" title="style sheet">
</head>
<body style="background-color: #CCCCCC;">
This demo analyzes your settings (phpThumb.config.php and server/PHP) for <a href="http://phpthumb.sourceforge.net"><b>phpThumb()</b></a>.<br>
<br>
<table border="1">
<tr><th colspan="8">&lt;-- bad . . . . . good --&gt;</th></tr>
<tr>
<td style="background-color: red;" >&nbsp;&nbsp;&nbsp;&nbsp;</td>
<td style="background-color: orange;" >&nbsp;&nbsp;&nbsp;&nbsp;</td>
<td style="background-color: yellow;" >&nbsp;&nbsp;&nbsp;&nbsp;</td>
<td style="background-color: olive;" >&nbsp;&nbsp;&nbsp;&nbsp;</td>
<td style="background-color: darkgreen;" >&nbsp;&nbsp;&nbsp;&nbsp;</td>
<td style="background-color: green;" >&nbsp;&nbsp;&nbsp;&nbsp;</td>
<td style="background-color: lightgreen;">&nbsp;&nbsp;&nbsp;&nbsp;</td>
<td style="background-color: lime;" >&nbsp;&nbsp;&nbsp;&nbsp;</td>
</tr>
</table>
<table border="1" cellspacing="0" cellpadding="2">
<tr style="background-color: #EEEEEE;"><th>Setting</th><th colspan="2">Value</th><th>Comments</th></tr>
<?php
$versions['raw'] = array(
'latest' => phpthumb_functions::SafeURLread('http://phpthumb.sourceforge.net/?latestversion=1', $dummy),
'this' => $phpThumb->phpthumb_version,
);
foreach ($versions['raw'] as $key => $value) {
preg_match('#^([0-9\\.]+)\\-?(([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2}))?#i', $value, $matches);
@list($huge, $major, $minor) = @explode('.', @$matches[1]);
@list($year, $month, $day, $hour, $min) = @$matches[3];
$versions['base'][$key] = $matches[1];
$versions['huge'][$key] = $huge;
$versions['major'][$key] = $major;
$versions['minor'][$key] = $minor;
$versions['stamp'][$key] = $matches[2];
$versions['year'][$key] = $year;
$versions['month'][$key] = $month;
$versions['day'][$key] = $day;
$versions['hour'][$key] = $hour;
$versions['min'][$key] = $min;
$versions['date'][$key] = @mktime($hour, $min, 0, $month, $day, $year);
}
$downloadlatest = 'Download the latest version from <a href="https://github.com/JamesHeinrich/phpThumb/">https://github.com/JamesHeinrich/phpThumb/</a>';
echo '<tr><th nowrap>Latest phpThumb version:</th><th colspan="2">'.$versions['raw']['latest'].'</th><td>'.$downloadlatest.'</td></tr>';
echo '<tr><th nowrap>This phpThumb version:</th><th colspan="2" style="background-color: ';
if (!$versions['base']['latest']) {
// failed to get latest version number
echo 'white';
$message = 'Latest version unknown.<br>'.$downloadlatest;
} elseif (phpthumb_functions::version_compare_replacement($versions['base']['this'], $versions['base']['latest'], '>')) {
// new than latest, must be beta version
echo 'lightblue';
$message = 'This must be a pre-release beta version. Please report bugs to <a href="mailto:info@silisoftware.com">info@silisoftware.com</a>';
} elseif (($versions['base']['latest'] == $versions['base']['this']) && ($versions['stamp']['this'] > $versions['stamp']['latest'])) {
// new than latest, must be beta version
echo 'lightblue';
$message = 'You must be using a pre-release beta version. Please report bugs to <a href="mailto:info@silisoftware.com">info@silisoftware.com</a>';
} elseif ($versions['base']['latest'] == $versions['base']['this']) {
// latest version
echo 'lime';
$message = 'You are using the latest released version.';
} elseif ($versions['huge']['latest'].$versions['major']['latest'] == $versions['huge']['this'].$versions['major']['this']) {
echo 'olive';
$message = 'One (or more) minor version(s) have been released since this version.<br>'.$downloadlatest;
} elseif ((float) ($versions[ 'huge'][ 'latest'].str_pad($versions[ 'major'][ 'latest'], 2, '0', STR_PAD_LEFT)) < (float) ($versions[ 'huge'][ 'this'].str_pad($t_major, 2, '0', STR_PAD_LEFT))) {
echo 'yellow';
$message = 'One (or more) major version(s) have been released since this version, you really should upgrade.<br>'.$downloadlatest;
} else {
echo 'orange';
$message = 'Fundamental changes have been made since this version.<br>'.$downloadlatest;
}
echo ';">'.$phpThumb->phpthumb_version;
echo '</th><td>'.$message.'.<br></td></tr>';
echo '<tr><th>phpThumb.config.php:</th><th colspan="2" style="background-color: ';
if (file_exists('../phpThumb.config.php') && !file_exists('../phpThumb.config.php.default')) {
if (!defined('phpThumbConfigFileVersion') || phpthumb_functions::version_compare_replacement($versions['base']['this'], phpThumbConfigFileVersion, '>')) {
echo 'red;">"phpThumb.config.php" version does not match phpThumb version. Please be sure to use the config file from the phpThumb distribution (copy any customized settings to the .default file, then rename "phpThumb.config.php.default" to "phpThumb.config.php")';
} else {
echo 'lime;">"phpThumb.config.php" exists and "phpThumb.config.php.default" does not';
}
} elseif (file_exists('../phpThumb.config.php') && file_exists('../phpThumb.config.php.default')) {
echo 'yellow;">"phpThumb.config.php" and "phpThumb.config.php.default" both exist';
} elseif (!file_exists('../phpThumb.config.php') && file_exists('../phpThumb.config.php.default')) {
echo 'red;">rename "phpThumb.config.php.default" to "phpThumb.config.php"';
} else {
echo 'red;">"phpThumb.config.php" not found';
}
echo '</th><td>"phpThumb.config.php.default" that comes in the distribution must be renamed to "phpThumb.config.php" before phpThumb.php can be used. Avoid having both files present to minimize confusion.</td></tr>';
echo '<tr><th>phpThumb.config.php<br>[disable_debug]</th>';
echo '<th colspan="2" style="background-color: '.($PHPTHUMB_CONFIG['disable_debug'] ? 'lime' : 'red').'">'.($PHPTHUMB_CONFIG['disable_debug'] ? 'true' : 'false').'</th>';
echo '<td>DO NOT DISABLE THIS ON ANY PUBLIC-ACCESSIBLE SERVER. Prevents phpThumb from displaying any information about your system. If true, phpThumbDebug and error messages will be disabled. If set to false (debug messages enabled) then debug mode will be FORCED -- ONLY debug output will be presented, no actual thumbnail (to avoid accidentally leaving debug mode enabled on a production server).</td></tr>';
echo '<tr><th>phpThumb.config.php<br>[high_security_enabled]</th>';
echo '<th colspan="2" style="background-color: '.($PHPTHUMB_CONFIG['high_security_enabled'] ? 'lime' : 'red').'">'.($PHPTHUMB_CONFIG['high_security_enabled'] ? 'true' : 'false').'</th>';
echo '<td>DO NOT DISABLE THIS ON ANY PUBLIC-ACCESSIBLE SERVER. If disabled, your server is more vulnerable to hacking attempts, both on your server and via your server to other servers. When enabled, requires "high_security_password" set to be set and requires the use of phpThumbURL() function (at the bottom of phpThumb.config.php) to generate hashed URLs.</td></tr>';
echo '<tr><th>phpThumb.config.php<br>[high_security_password]</th>';
$password_complexity = phpthumb_functions::PasswordStrength($PHPTHUMB_CONFIG['high_security_password']);
echo '<th colspan="2" style="background-color: '.(($password_complexity >= 20) ? 'lime' : ((strlen($PHPTHUMB_CONFIG['high_security_password']) > 0) ? 'orange' : 'red')).'">'.(($password_complexity >= 20) ? 'sufficiently complex' : ((strlen($PHPTHUMB_CONFIG['high_security_password']) > 0) ? 'not complex enough' : 'not set')).'</th>';
echo '<td>DO NOT DISABLE THIS ON ANY PUBLIC-ACCESSIBLE SERVER. If disabled, your server is more vulnerable to hacking attempts, both on your server and via your server to other servers. When enabled, requires "high_security_password" set to be set and requires the use of phpThumbURL() function (at the bottom of phpThumb.config.php) to generate hashed URLs.</td></tr>';
echo '<tr><th>cache directory:</th><th colspan="2">';
$orig_config_cache_directory = $phpThumb->config_cache_directory;
$phpThumb->setCacheDirectory();
echo '<div style="background-color: '.( is_dir($phpThumb->config_cache_directory) ? 'lime;">exists' : 'red;">does NOT exist').'</div>';
echo '<div style="background-color: '.(is_readable($phpThumb->config_cache_directory) ? 'lime;">readable' : 'red;">NOT readable' ).'</div>';
echo '<div style="background-color: '.(is_writable($phpThumb->config_cache_directory) ? 'lime;">writable' : 'red;">NOT writable' ).'</div>';
echo '</th><td>Original: "'.htmlspecialchars($orig_config_cache_directory).'"<br>Resolved: "'.htmlspecialchars($phpThumb->config_cache_directory).'"<br>Must exist and be both readable and writable by PHP.</td></tr>';
echo '<tr><th>cache write test:</th><th colspan="2">';
$phpThumb->rawImageData = 'phpThumb.demo.check.php_cachetest';
$phpThumb->SetCacheFilename();
echo '<div>'.htmlspecialchars($phpThumb->cache_filename ? implode(' / ', preg_split('#[/\\\\]#', $phpThumb->cache_filename)) : 'NO CACHE FILENAME RESOLVED').'</div>';
echo '<div>directory '.(is_dir(dirname($phpThumb->cache_filename)) ? 'exists' : 'does NOT exist').' (before EnsureDirectoryExists())</div>';
phpthumb_functions::EnsureDirectoryExists(dirname($phpThumb->cache_filename));
echo '<div style="background-color: '.(is_dir(dirname($phpThumb->cache_filename)) ? 'lime;">directory exists' : 'red;">directory does NOT exist').' (after EnsureDirectoryExists())</div>';
if ($fp = @fopen($phpThumb->cache_filename, 'wb')) {
fwrite($fp, 'this is a test from '.__FILE__);
fclose($fp);
echo '<div style="background-color: lime;">write test succeeded</div>';
$old_perms = substr(sprintf('%o', fileperms($phpThumb->cache_filename)), -4);
@chmod($phpThumb->cache_filename, 0644);
clearstatcache();
$new_perms = substr(sprintf('%o', fileperms($phpThumb->cache_filename)), -4);
echo '<div style="background-color: '.(($new_perms == '0644') ? 'lime' : (($new_perms > '0644') ? 'orange' : 'red')).';">chmod($phpThumb->cache_filename, 0644) from "'.htmlspecialchars($old_perms).'" resulted in permissions "'.htmlspecialchars($new_perms).'"</div>';
if (@unlink($phpThumb->cache_filename)) {
echo '<div style="background-color: lime;">delete test succeeded</div>';
} else {
echo '<div style="background-color: red;">delete test FAILED</div>';
}
$phpThumb->CleanUpCacheDirectory();
} else {
echo '<div style="background-color: red;">write test FAILED</div>';
}
//echo '</th><td>Original: "'.htmlspecialchars($orig_config_cache_directory).'"<br>Resolved: "'.htmlspecialchars($phpThumb->config_cache_directory).'"<br>Must exist and be both readable and writable by PHP.</td></tr>';
echo '</th><td>Created and deletes a sample cache file to see if you actually have create/delete permission.<br>If <i>Safe Mode</i> is enabled this is often broken.</td></tr>';
echo '<tr><th>temp directory:</th><th colspan="2">';
$orig_config_temp_directory = $phpThumb->config_temp_directory;
echo $phpThumb->phpThumb_tempnam();
echo '<div style="background-color: '.( is_dir($phpThumb->config_temp_directory) ? 'lime;">exists' : 'red;">does NOT exist').'</div>';
echo '<div style="background-color: '.(is_readable($phpThumb->config_temp_directory) ? 'lime;">readable' : 'red;">NOT readable' ).'</div>';
echo '<div style="background-color: '.(is_writable($phpThumb->config_temp_directory) ? 'lime;">writable' : 'red;">NOT writable' ).'</div>';
echo '</th><td>Original: "'.htmlspecialchars($orig_config_temp_directory).'"<br>Resolved: "'.htmlspecialchars($phpThumb->config_temp_directory).'"<br>Must exist and be both readable and writable by PHP.</td></tr>';
echo '<tr><th>PHP version:</th><th colspan="2" style="background-color: ';
if (phpthumb_functions::version_compare_replacement(PHP_VERSION, '5.0.0', '>=')) {
echo 'lime';
} elseif (phpthumb_functions::version_compare_replacement(PHP_VERSION, '4.4.2', '=')) {
echo 'darkgreen';
} elseif (phpthumb_functions::version_compare_replacement(PHP_VERSION, '4.3.3', '>=')) {
echo 'lightgreen';
} elseif (phpthumb_functions::version_compare_replacement(PHP_VERSION, '4.2.0', '>=')) {
echo 'green';
} elseif (phpthumb_functions::version_compare_replacement(PHP_VERSION, '4.1.0', '>=')) {
echo 'yellow';
} elseif (phpthumb_functions::version_compare_replacement(PHP_VERSION, '4.0.6', '>=')) {
echo 'orange';
} else {
echo 'red';
}
echo ';">'. PHP_VERSION;
echo '</th><td>PHP5 is ideal (support for numerous built-in filters which are much faster than my code).<br>PHP v4.4.2 contains a bug in fopen over HTTP (phpThumb has a workaround)<br>PHP v4.3.2+ supports imagesavealpha which is required for proper PNG/ICO output.<br>imagerotate requires PHP v4.3.0+ (but buggy before v4.3.3).<br>EXIF thumbnail extraction requires PHP v4.2.0+.<br>Most things will work back to PHP v4.1.0, and mostly (perhaps buggy) back to v4.0.6, but no guarantees for any version older than that.</td></tr>';
echo '<tr><th>GD version:</th><th colspan="2" style="background-color: ';
if ($ServerInfo['gd_numeric'] >= 2) {
if (!empty($ServerInfo['gd_string']) && false !== stripos($ServerInfo[ 'gd_string' ], 'bundled')) {
echo 'lime';
} else {
echo 'yellow';
}
} elseif (!empty($ServerInfo['im_version'])) {
echo 'orange';
} else {
echo 'red';
}
echo ';">'.(!empty($ServerInfo['gd_string']) ? $ServerInfo['gd_string'] : 'n/a');
echo '</th><td>GD2-bundled version is ideal.<br>GD2 (non-bundled) is second choice, but there are a number of bugs in the non-bundled version. imagerotate is only available in the bundled version of GD2.<br>GD1 will also (mostly) work, at much-reduced image quality and several features disabled. phpThumb can perform most operations with ImageMagick only, even if GD is not available.</td></tr>';
$IMreleaseDate = 0;
if (preg_match('# ([0-9]{2})/([0-9]{2})/([0-9]{2}) #', $ServerInfo['im_version'], $matches)) {
list($dummy, $m, $d, $y) = $matches;
if ($y < 70) {
$y += 2000;
} elseif ($y < 100) {
$y += 1900;
}
$IMreleaseDate = mktime(12, 0, 0, $m, $d, $y);
} elseif (preg_match('# ([0-9]{4})\\-([0-9]{2})\\-([0-9]{2}) #', $ServerInfo['im_version'], $matches)) {
list($dummy, $y, $m, $d) = $matches;
$IMreleaseDate = mktime(12, 0, 0, $m, $d, $y);
}
$IMversionAge = time() - $IMreleaseDate;
echo '<tr><th>ImageMagick version:</th><th colspan="2" style="background-color: ';
if ($ServerInfo['im_version']) {
if ($IMversionAge < (86400 * 365 * 1)) {
echo 'lime';
} elseif ($IMversionAge < (86400 * 365 * 2)) {
echo 'lightgreen';
} elseif ($IMversionAge < (86400 * 365 * 3)) {
echo 'green';
} elseif ($IMversionAge < (86400 * 365 * 4)) {
echo 'darkgreen';
} else {
echo 'olive';
}
} elseif (!empty($ServerInfo['gd_string'])) {
echo 'orange';
} else {
echo 'red';
}
echo ';">';
echo '<div style="color: navy; font-family: monospace;">'.htmlspecialchars($phpThumb->config_imagemagick_path);
echo ' <span style="cursor: help;" title="file_exists" >['. (int) (@file_exists($phpThumb->config_imagemagick_path)) .']</span> ';
echo ' <span style="cursor: help;" title="file_exists_ignoreopenbasedir">['. (int) $phpThumb->file_exists_ignoreopenbasedir($phpThumb->config_imagemagick_path) .']</span> ';
echo ' <span style="cursor: help;" title="is_file" >['. (int) (@is_file($phpThumb->config_imagemagick_path)) .']</span> ';
echo ' <span style="cursor: help;" title="is_readable" >['. (int) (@is_readable($phpThumb->config_imagemagick_path)) .']</span> ';
echo ' <span style="cursor: help;" title="is_executable" >['. (int) (@is_executable($phpThumb->config_imagemagick_path)) .']</span> ';
echo '</div>';
echo '<div style="color: blue; font-family: monospace;">'.htmlspecialchars($phpThumb->ImageMagickCommandlineBase()).'</div>';
echo ($ServerInfo['im_version'] ?: 'n/a');
echo ($IMreleaseDate ? '<br><br>This version of ImageMagick is '.NiceTimeFormatting($IMversionAge).' old<br>(see <a href="http://www.imagemagick.org/">www.imagemagick.org</a> for new versions)' : '');
echo '</th><td>ImageMagick is faster than GD, can process larger images without PHP memory_limit issues, can resize animated GIFs. phpThumb can perform most operations with ImageMagick only, even if GD is not available.</td></tr>';
echo '<tr><th>ImageMagick features:</th>';
if ($ServerInfo['im_version']) {
$GDfeatures['red'] = array('help', 'thumbnail', 'resize', 'crop', 'repage', 'coalesce', 'gravity', 'background', 'interlace', 'flatten', 'border', 'bordercolor', 'dither', 'quality');
$GDfeatures['orange'] = array('version', 'blur', 'colorize', 'colors', 'colorspace', 'contrast', 'contrast-stretch', 'edge', 'emboss', 'fill', 'flip', 'flop', 'gamma', array('gaussian','gaussian-blur'), 'level', 'modulate', 'monochrome', 'negate', 'normalize', 'rotate', 'sepia-tone', 'threshold', 'unsharp');
echo '<th colspan="2">|';
foreach ($GDfeatures as $missingcolor => $features) {
foreach ($features as $dummy => $feature) {
$foundOneThatWorks = false;
if (is_array($feature)) {
// sometimes feature names change, e.g. "gaussian" -> "gaussian-blur". They won't both exist in the same version of ImageMagick, but as long as one of them does then the feature will work
foreach ($feature as $alternate_feature_name) {
if ($phpThumb->ImageMagickSwitchAvailable($alternate_feature_name)) {
$foundOneThatWorks = true;
$feature = $alternate_feature_name;
break;
}
echo '| <span style="background-color: '.($foundOneThatWorks ? 'lime' : $missingcolor).';">'.htmlspecialchars($alternate_feature_name).'</span> |';
}
} else {
$foundOneThatWorks = $phpThumb->ImageMagickSwitchAvailable($feature);
echo '| <span style="background-color: '.($foundOneThatWorks ? 'lime' : $missingcolor).';">'.htmlspecialchars($feature).'</span> |';
}
}
}
echo '|</th>';
} else {
echo '<th colspan="2" style="background-color: orange;">ImageMagick not found</th>';
}
echo '<td>All of these parameters may be called by phpThumb, depending on parameters used. Green means the feature is available; red means a critical feature is missing; orange means an optional filter/feature is missing.</td></tr>';
echo '<tr><th>ImageMagick formats:</th>';
if ($ServerInfo['im_version']) {
echo '<td colspan="2"><div style="width: 100%; height: 200px; overflow: auto; font-family: monospace; white-space: pre; background-color: #FFFFFF;">'.htmlspecialchars($phpThumb->ImageMagickFormatsList()).'</div></td>';
} else {
echo '<th colspan="2" style="background-color: orange;">ImageMagick not found</th>';
}
echo '<td>ImageMagick can only read/write formats as listed here. You may need to recompile ImageMagick if you need to use a format not listed</td></tr>';
echo '<tr><th>GD features:</th><th colspan="2">';
$GDfeatures['red'] = array('JPEG Support', 'JPG Support', 'PNG Support'); // older versions would report "JPG Support", newer versions report "JPEG Support"
$GDfeatures['orange'] = array('GIF Read Support', 'GIF Create Support', 'FreeType Support');
foreach ($GDfeatures as $missingcolor => $features) {
foreach ($features as $dummy => $feature) {
if (isset($gd_info[$feature])) {
echo '<div style="background-color: '.($gd_info[$feature] ? 'lime' : $missingcolor).';">'.htmlspecialchars($feature).'</div>';
}
}
}
echo '</th><td>PNG support is required for watermarks, overlays, calls to ImageMagick and other internal operations.<br>JPG support is obviously quite useful, but ImageMagick can substitute<br>GIF read support can be bypassed with ImageMagick and/or internal GIF routines.<br>GIF create support can be bypassed with ImageMagick (if no filters are applied)<br>FreeType support is needed for TTF overlays.</td></tr>';
echo '<tr><th>GD extension "EXIF"</th><th colspan="2" style="background-color: ';
if (extension_loaded('exif')) {
echo 'lime';
} elseif (!empty($ServerInfo['gd_string'])) {
echo 'orange';
}
echo ';">'.(extension_loaded('exif') ? 'TRUE' : 'FALSE');
echo '</th><td>EXIF extension required for auto-rotate images. Also required to extract EXIF thumbnail to use as source if source image is too large for PHP memory_limit and ImageMagick is unavailable.</td></tr>';
echo '<tr><th>php_sapi_name()</th><th colspan="2" style="background-color: ';
$php_sapi_name = strtolower(function_exists('php_sapi_name') ? PHP_SAPI : '');
if (!$php_sapi_name || (preg_match('#~#', dirname($_SERVER['PHP_SELF'])) && ($php_sapi_name != 'apache'))) {
echo 'red';
} elseif ($php_sapi_name == 'cgi-fcgi') {
echo 'orange';
} elseif ($php_sapi_name == 'cgi') {
echo 'yellow';
} elseif ($php_sapi_name == 'apache') {
echo 'lime';
} else {
echo 'green';
}
echo ';">'.htmlspecialchars($php_sapi_name).'</th>';
echo '<td>SAPI mode preferred to CGI mode. FCGI mode has unconfirmed strange behavior (notably more than one space in "wmt" filter text causes errors). If not working in "apache" (SAPI) mode, <i>apache_lookup_uri()</i> will not work.</td></tr>';
echo '<tr><th>Server Software</th><th colspan="2" style="background-color: ';
$server_software = getenv('SERVER_SOFTWARE');
if (!$server_software) {
echo 'red';
} elseif (preg_match('#^Apache/([0-9\\.]+)#i', $server_software, $matches)) {
if (phpthumb_functions::version_compare_replacement($matches[1], '2.0.0', '>=')) {
echo 'lightgreen';
} else {
echo 'lime';
}
} else {
echo 'darkgreen';
}
echo ';">'.$server_software.'</th>';
echo '<td>Apache v1.x has the fewest compatibility problems. IIS has numerous annoyances. Apache v2.x is broken when lookup up <i>/~user/filename.jpg</i> style relative filenames using <i>apache_lookup_uri()</i>.</td></tr>';
echo '<tr><th>curl_version:</th><th colspan="2" style="background-color: ';
$curl_version = (function_exists('curl_version') ? curl_version() : '');
if (is_array($curl_version)) {
$curl_version = @$curl_version['version'];
}
if ($curl_version) {
echo 'lime';
} else {
echo 'yellow';
}
echo ';">'.$curl_version.'</th>';
echo '<td>Best if available. HTTP source images will be unavailable if CURL unavailable and <i>allow_url_fopen</i> is also disabled.</td></tr>';
echo '<tr style="background-color: #EEEEEE;"><th colspan="4">&nbsp;</th></tr>';
echo '<tr style="background-color: #EEEEEE;"><th>function_exists:</th><th colspan="2">Value</th><th>Comments</th></tr>';
$FunctionsExist = array(
'imagerotate' => array('orange', 'required for "ra" and "ar" filters.'),
'exif_read_data' => array('yellow', 'required for "ar" filter.'),
'exif_thumbnail' => array('yellow', 'required to extract EXIF thumbnails.'),
'memory_get_usage' => array('lightgreen', 'mostly used for troubleshooting.'),
'version_compare' => array('darkgreen', 'available in PHP v4.1.0+, internal workaround available'),
'file_get_contents' => array('darkgreen', 'available in PHP v4.3.0+, internal workaround available'),
'file_put_contents' => array('darkgreen', 'available in PHP v5.0.0+, internal workaround available'),
'is_executable' => array('yellow', 'available in PHP3, except only PHP5 for Windows. poor internal workaround available'),
'gd_info' => array('olive', 'available in PHP v4.3.0+ (with bundled GD2), internal workaround available'),
'imagetypes' => array('red', 'required for GD image output.'),
'imagecreatefromjpeg' => array('orange', 'required for JPEG source images using GD.'),
'imagecreatefromgif' => array('yellow', 'useful for GIF source images using GD.'),
'imagecreatefrompng' => array('orange', 'required for PNG source images using GD and other source image formats using ImageMagick.'),
'imagecreatefromwbmp' => array('yellow', 'required for WBMP source images using GD.'),
'imagecreatefromstring' => array('orange', 'required for HTTP and non-file image sources.'),
'imagecreatetruecolor' => array('orange', 'required for all non-ImageMagick filters.'),
'imageistruecolor' => array('olive', 'available in PHP v4.3.2+ with GD v2.0.1+'),
'imagefilter' => array('yellow', 'PHP5 only. Required for some filters (but most can use ImageMagick instead)'),
'imageautocrop' => array('yellow', 'PHP v5.5.0+, required for "ica" filter'),
);
foreach ($FunctionsExist as $function => $details) {
list($color, $description) = $details;
echo '<tr><th>'.$function.'</th><th colspan="2" style="background-color: ';
if (function_exists(strtolower($function))) {
echo 'lime;">TRUE';
} else {
echo $color.';">FALSE';
}
echo '</th><td>'.htmlspecialchars($description).'</td></tr>';
}
echo '<tr style="background-color: #EEEEEE;"><th colspan="4">&nbsp;</th></tr>';
echo '<tr style="background-color: #EEEEEE;"><th>Setting</th><th>Master Value</th><th>Local Value</th><th>Comments</th></tr>';
$SettingFeatures = array(
'magic_quotes_runtime' => array('red', 'lime', 'This setting is evil. Turn it off.'),
'magic_quotes_gpc' => array('yellow', 'lime', 'This setting is bad. Turn it off, if possible. phpThumb will attempt to work around it if it is enabled.'),
'safe_mode' => array('orange', 'lime', 'Best if off. Calls to ImageMagick will be disabled if safe_mode is set to prevent writing temp files (limiting max image resolution, no animated GIF resize). Raw image data sources (e.g. from MySQL database) may not work. Temp files may be disabled. Features will be limited. If disabled in Master but enabled in Local, edit httpd.conf and set (php_admin_value safe_mode "Off") between <VirtualHost> tags'),
'allow_url_fopen' => array('lime', 'yellow', 'Best if on. HTTP source images will be unavailable if disabled and CURL is unavailable.'),
);
foreach ($SettingFeatures as $feature => $FeaturesDetails) {
list($color_true, $color_false, $reason) = $FeaturesDetails;
echo '<tr><th>'.$feature.':</th>';
echo '<th style="background-color: '.(@get_cfg_var($feature) ? $color_true : $color_false).';">'.$phpThumb->phpThumbDebugVarDump((bool) @get_cfg_var($feature)).'</th>';
echo '<th style="background-color: '.(preg_match('#(1|ON)#i', @ini_get($feature)) ? $color_true : $color_false).';">'.$phpThumb->phpThumbDebugVarDump((bool) preg_match('#(1|ON)#i', ini_get($feature))).'</th>';
echo '<td>'.htmlspecialchars($reason).'</td></tr>';
}
$MissingFunctionSeverity = array(
'shell_exec' => 'red',
'system' => 'red',
'passthru' => 'red',
'exec' => 'red',
'curl_exec' => 'orange',
);
$DisabledFunctions[0] = explode(',', @get_cfg_var('disable_functions'));
$DisabledFunctions[1] = explode(',', @ini_get('disable_functions'));
echo '<tr><th>disable_functions:</th>';
for ($i = 0; $i <= 1; $i++) {
foreach ($DisabledFunctions[$i] as $key => $value) {
if (!empty($MissingFunctionSeverity[$value])) {
$DisabledFunctions[$i][$key] = '<span style="background-color: '.$MissingFunctionSeverity[$value].';">'.$value.'</span>';
}
}
$disabled_functions = implode(', ', $DisabledFunctions[$i]);
echo '<th style="background-color: '.($disabled_functions ? 'yellow' : 'lime').';">'.htmlspecialchars($disabled_functions).'</th>';
}
echo '<td>Best if nothing disabled. Calls to ImageMagick will be prevented if exec+system+shell_exec+passthru are disabled.</td></tr>';
echo '<tr><th>memory_limit:</th><th style="background-color: ';
$memory_limit = @get_cfg_var('memory_limit');
if (!$memory_limit) {
echo 'lime';
} elseif ($memory_limit >= 256) {
echo 'lime';
} elseif ($memory_limit >= 128) {
echo 'lightgreen';
} elseif ($memory_limit >= 64) {
echo 'green';
} elseif ($memory_limit >= 32) {
echo 'darkgreen';
} elseif ($memory_limit >= 16) {
echo 'olive';
} elseif ($memory_limit >= 8) {
echo 'yellow';
} elseif ($memory_limit >= 4) {
echo 'orange';
} else {
echo 'red';
}
echo ';">'.($memory_limit ?: '<i>unlimited</i>').'</th><th style="background-color: ';
$memory_limit_bytes = 0;
if ($memory_limit = @ini_get('memory_limit')) {
$memory_limit_bytes = intval($memory_limit);
if (strtoupper(substr($memory_limit, -1, 1)) == 'M') {
$memory_limit_bytes = substr($memory_limit, 0, -1) * 1024 * 1024;
} elseif (strtoupper(substr($memory_limit, -1, 1)) == 'G') {
$memory_limit_bytes = substr($memory_limit, 0, -1) * 1024 * 1024 * 1024;
}
}
if (!$memory_limit) {
echo 'lime';
} elseif ($memory_limit >= 256) {
echo 'lime';
} elseif ($memory_limit >= 128) {
echo 'lightgreen';
} elseif ($memory_limit >= 64) {
echo 'green';
} elseif ($memory_limit >= 32) {
echo 'darkgreen';
} elseif ($memory_limit >= 16) {
echo 'olive';
} elseif ($memory_limit >= 8) {
echo 'yellow';
} elseif ($memory_limit >= 4) {
echo 'orange';
} else {
echo 'red';
}
echo ';">'.($memory_limit ?: '<i>unlimited</i>').'</th>';
echo '<td>The higher the better. Divide by 5 to get maximum megapixels of source image that can be thumbnailed (without ImageMagick).'.($memory_limit ? ' Your setting ('.$memory_limit.') allows images up to approximately '.number_format($memory_limit_bytes / (5*1024*1024), 1).' megapixels' : '').'</td></tr>';
echo '</table>';
function NiceTimeFormatting($seconds, $precision=1, $returnparts=false) {
$sign = (($seconds < 0) ? -1 : 1);
$seconds = abs($seconds);
do {
if ($seconds < 100) {
$value = number_format($seconds, 0);
$unit = 'second'.(($seconds > 1) ? 's' : '');
break;
}
$minutes = $seconds / 60;
if ($minutes < 60) {
$value = number_format($minutes, $precision);
$unit = 'minutes';
break;
}
$hours = $seconds / 3600;
if ($hours < 24) {
$value = number_format($hours, $precision);
$unit = 'hours';
break;
}
$days = $seconds / 86400;
if ($days < 60) {
$value = number_format($days, $precision);
$unit = 'days';
break;
}
$months = $seconds / (30 * 86400);
if ($months < 12) {
$value = number_format($months, $precision);
$unit = 'months';
break;
}
$years = $seconds / (365 * 86400);
if (true) {
$value = number_format($years, $precision);
$unit = 'years';
break;
}
} while (false);
$value *= $sign;
if ($returnparts) {
return array($value, $unit);
}
return $value.' '.$unit;
}
?>
</body>
</html>

View File

@@ -0,0 +1,302 @@
<?php
//////////////////////////////////////////////////////////////
// phpThumb() by James Heinrich <info@silisoftware.com> //
// available at http://phpthumb.sourceforge.net //
// and/or https://github.com/JamesHeinrich/phpThumb //
//////////////////////////////////////////////////////////////
/// //
// phpThumb.demo.demo.php //
// James Heinrich <info@silisoftware.com> //
// //
// Demo showing a wide variety of parameters that can be //
// passed to phpThumb.php //
// Live demo is at http://phpthumb.sourceforge.net/demo/ //
// //
//////////////////////////////////////////////////////////////
die('For security reasons, this demo is disabled by default. Please comment out line '.__LINE__.' in '.basename(__FILE__));
$ServerInfo['gd_string'] = 'unknown';
$ServerInfo['gd_numeric'] = 0;
//ob_start();
if (!include_once '../phpthumb.functions.php' ) {
//ob_end_flush();
die('failed to include_once("../phpthumb.functions.php")');
}
if (!include_once '../phpthumb.class.php' ) {
//ob_end_flush();
die('failed to include_once("../phpthumb.class.php")');
}
//ob_end_clean();
$phpThumb = new phpThumb();
if (include_once '../phpThumb.config.php' ) {
foreach ($PHPTHUMB_CONFIG as $key => $value) {
$keyname = 'config_'.$key;
$phpThumb->setParameter($keyname, $value);
}
}
$ServerInfo['phpthumb_version'] = $phpThumb->phpthumb_version;
$ServerInfo['im_version'] = $phpThumb->ImageMagickVersion();
$ServerInfo['gd_string'] = phpthumb_functions::gd_version(true);
$ServerInfo['gd_numeric'] = phpthumb_functions::gd_version(false);
unset($phpThumb);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Demo of phpThumb() - thumbnails created by PHP using GD and/or ImageMagick</title>
<link rel="stylesheet" type="text/css" href="/style.css" title="style sheet">
<link rel="shortcut icon" type="image/x-icon" href="http://phpthumb.sourceforge.net/thumb.ico">
<meta http-equiv="Content-type" content="text/html;charset=UTF-8">
</head>
<body style="background-color: #C5C5C5;">
This is a demo of <a href="http://phpthumb.sourceforge.net"><b>phpThumb()</b></a> (current version: v<?php echo @$ServerInfo['phpthumb_version']; ?>)<br>
<a href="index.php?list=1">Other phpThumb() demos</a> are also available.<br>
<br>
<b>Note:</b> this server is working on GD "<?php
echo $ServerInfo['gd_string'].'"';
if ($ServerInfo['gd_numeric'] >= 2) {
echo ', so images should be of optimal quality.';
} else {
echo ', so images (especially watermarks) do not look as good as they would on GD v2.';
}
?><br>
<hr size="1">
<a href="#showpic">phpThumb.demo.showpic.php demo here</a><br>
<a href="#gd1vs2">Difference between GD1 and GD2</a><br>
<hr size="1">
<div style="border: 5px #999999 outset; width: 600px; padding: 10px; margin: 10px;">
The following images have the textured background behind them to illustrate transparency effects.
Note that some browsers, notably Internet Explorer v6 and older, are incapable of displaying alpha-channel PNGs.
See my page on the <a href="http://www.silisoftware.com/png_alpha_transparency/" target="_blank">PNG transparency problem</a>.
All current browsers (2010 and newer) display alpha-transparent PNGs with no problems.
</div>
<br>
<script type="text/javascript" defer="defer">
<!--
//var agt = navigator.userAgent.toLowerCase();
//if ((agt.indexOf("opera") == -1) && (agt.indexOf("msie 7") == -1) && (navigator.product != "Gecko")) {
// alert("You are (probably) using Internet Explorer and PNG transparency is (probably) broken");
//}
// -->
</script>
<?php
$phpThumbBase = '../phpThumb.php';
$img['background'] = 'images/lrock011.jpg';
$img['square'] = 'images/disk.jpg';
$img['landscape'] = 'images/loco.jpg';
$img['portrait'] = 'images/pineapple.jpg';
$img['unrotated'] = 'images/monkey.jpg';
$img['watermark'] = 'images/watermark.png';
$img['levels1'] = 'images/bunnies.jpg';
$img['levels2'] = 'images/lilies.jpg';
$img['anigif'] = 'images/animaple.gif';
$img['alpha'] = 'images/alpha.png';
//$img['alpha'] = 'images/North15.gif';
$img['whitespace'] = 'images/whitespace.jpg';
$img['mask1'] = 'images/mask04.png';
$img['mask2'] = 'images/mask05.png';
$img['mask3'] = 'images/mask06.png';
$img['frame1'] = 'images/frame1.png';
$img['frame2'] = 'images/frame2.png';
$img['bmp'] = 'images/winnt.bmp';
$img['tiff'] = 'images/1024-none.tiff';
$img['wmf'] = 'images/computer.wmf';
$img['pdf'] = 'images/phpThumb.com.pdf';
$img['small'] = 'images/small.jpg';
$img['big'] = 'images/big.jpg';
$png_alpha = 'Note: PNG/ICO output is 32-bit with alpha transparency, subject to <a href="http://www.silisoftware.com/png_alpha_transparency/" target="_blank">PNG transparency problem</a> in Internet Explorer';
$only_gd = '<br>(only works with GD (any version), this server is '.($ServerInfo['gd_string'] ? 'running GD "<i>'.$ServerInfo['gd_string'].'</i>" so it <b><font color="green">will</font>' : 'not running any recognized version of GD so it <b><font color="red">will not</font>').'</b> work)';
$only_gd2 = '<br>(only works with GD v2.0+, this server is running GD "<i>'.($ServerInfo['gd_string'] ? $ServerInfo['gd_string'] : 'n/a').'</i>" so it <b>'.(($ServerInfo['gd_numeric'] >= 2) ? '<font color="green">will</font>' : '<font color="red">will not</font>').'</b> work)';
$only_gd2_im = '<br>(only works with GD v2.0+ <i>or</i> ImageMagick, this server is running GD "<i>'.($ServerInfo['gd_string'] ? $ServerInfo['gd_string'] : 'n/a').'</i>" and ImageMagick "<i>'.($ServerInfo['im_version'] ? $ServerInfo['im_version'] : 'n/a').'</i>" so it <b>'.((($ServerInfo['gd_numeric'] >= 2) || $ServerInfo['im_version']) ? '<font color="green">will</font>' : '<font color="red">will not</font>').'</b> work)';
$only_php42 = '<br>(only works with PHP v4.2.0+, this server is running PHP v'. PHP_VERSION .' so it <b>'.(version_compare(PHP_VERSION, '4.2.0', '>=') ? '<font color="green">will</font>' : '<font color="red">will not</font>').'</b> work)';
$only_php43 = '<br>(only works with PHP v4.3.0+, this server is running PHP v'. PHP_VERSION .' so it <b>'.(version_compare(PHP_VERSION, '4.3.0', '>=') ? '<font color="green">will</font>' : '<font color="red">will not</font>').'</b> work)';
$only_php432 = '<br>(only works with PHP v4.3.2+, this server is running PHP v'. PHP_VERSION .' so it <b>'.(version_compare(PHP_VERSION, '4.3.2', '>=') ? '<font color="green">will</font>' : '<font color="red">will not</font>').'</b> work (correctly))';
$only_php500 = '<br>(only works with PHP v5.0.0+, this server is running PHP v'. PHP_VERSION .' so it <b>'.(version_compare(PHP_VERSION, '5.0.0', '>=') ? '<font color="green">will</font>' : '<font color="red">will not</font>').'</b> work (correctly))';
$php5_or_IM = '<br>(only works with PHP v5.0.0+ <i>or</i> ImageMagick, this server is running PHP v'. PHP_VERSION .' and "<i>'.($ServerInfo[ 'im_version'] ? $ServerInfo[ 'im_version'] : 'n/a').'</i>" so it <b>'.((version_compare(PHP_VERSION, '5.0.0', '>=') || $ServerInfo[ 'im_version']) ? '<font color="green">will</font>' : '<font color="red">will not</font>').'</b> work (correctly))';
$only_exif = '<br>(only works when the EXIF extension is loaded, so on this server it <b>'.(extension_loaded('exif') ? '<font color="green">will</font>' : '<font color="red">will not</font>').'</b> work)';
$only_im = '<br>(requires ImageMagick, this server is running "<i>'.($ServerInfo['im_version'] ? $ServerInfo['im_version'] : 'n/a').'</i>" so it <b>'.($ServerInfo['im_version'] ? '<font color="green">will</font>' : '<font color="red">will not</font>').'</b> work)';
$only_im_tiff = '<br>(requires ImageMagick compiled with TIFF delegate)';
$only_gs = '<br>(requires GhostScript)';
$Examples[] = array('getstrings' => array(''), 'description' => 'phpThumb version');
$Examples[] = array('getstrings' => array('src='.$img['square'].'&w=300'), 'description' => 'width=300px');
$Examples[] = array('getstrings' => array('src='.$img['square'].'&w=300&q=10&sia=custom-filename'), 'description' => 'width=300px, JPEGquality=10%, SaveImageAs=custom-filename');
$Examples[] = array('getstrings' => array('src='.$img['watermark'].'&w=400&aoe=1&bg=ffffff'), 'description' => 'width=400px, AllowOutputEnlargement enabled');
$Examples[] = array('getstrings' => array('src='.$img['square'].'&w=250&sx=600&sy=5&sw=100&sh=100&aoe=1'), 'description' => 'section from (600x5 - 700x105) cropped and enlarged by 250%, AllowOutputEnlargement enabled');
$Examples[] = array('getstrings' => array('src='.urlencode('http://www.silisoftware.com/images/SiliSoft.gif').'&w=100'), 'description' => 'HTTP source image'.$only_gd);
$Examples[] = array('getstrings' => array('src='.$img['square'].'&w=300&fltr[]=wmi|'.$img['watermark'].'|BL'), 'description' => 'width=300px, watermark (bottom-left, 75% opacity)'.$only_gd);
$Examples[] = array('getstrings' => array('src='.$img['square'].'&w=300&fltr[]=wmi|'.$img['watermark'].'|*|25'), 'description' => 'width=300px, watermark (tiled, 25% opacity)'.$only_gd);
$Examples[] = array('getstrings' => array('src='.$img['square'].'&w=300&fltr[]=wmi|'.$img['watermark'].'|75x50|80|75|75|45'), 'description' => 'width=300px, watermark (absolute position (75x50), rotation (45), scaling (75x75)))'.$only_gd);
$Examples[] = array('getstrings' => array('src='.$img['watermark'].'&bg=00FFFF&f=png', 'src='.$img['watermark'].'&bg=00FFFF&f=gif', 'src='.$img['watermark'].'&bg=00FFFF&f=jpeg'), 'description' => 'source image (GIF) transpancy with transparent output (PNG, GIF) vs. specified background color (JPEG)');
$Examples[] = array('getstrings' => array('src='.$img['anigif'], 'src='.$img['anigif'].'&w=25&f=gif', 'src='.$img['anigif'].'&w=25&f=png', 'src='.$img['anigif'].'&w=25&f=ico', 'src='.$img['anigif'].'&w=25&f=bmp', 'src='.$img['anigif'].'&w=25&f=jpeg'), 'description' => 'resize animated GIF. Notice how output format affects the result: GIF is animated and transparent; PNG and ICO are tranparent but not animated (first frame is rendered as a still image); JPEG and BMP are neither transparent nor animated. Any filters will disable animated resizing (may be fixed in a future version).<br>'.$only_im);
$Examples[] = array('getstrings' => array('src='.$img['anigif'], 'src='.$img['anigif'].'&sfn=0&f=png', 'src='.$img['anigif'].'&sfn=2&f=png'), 'description' => 'Specifying still-image source frame in multi-frame source images<br>'.$only_im);
$Examples[] = array('getstrings' => array('src='.$img['alpha'].'&f=png', 'src='.$img['alpha'].'&f=ico', 'src='.$img['alpha'].'&f=gif', 'src='.$img['alpha'].'&f=jpeg'), 'description' => 'PNG alpha transparency test, using test image from the <a href="http://www.silisoftware.com/png_alpha_transparency/">PNG transparency test page</a>'.$only_php432);
$Examples[] = array('getstrings' => array('src='.$img['square'].'&w=300&fltr[]=stc|FFFFFF|5|10&f=png'), 'description' => 'Create transparency from source image color'.$only_gd2);
$Examples[] = array('getstrings' => array('src='.$img['landscape'].'&w=300', 'src='.$img['landscape'].'&w=300&fltr[]=usm|80|0.5|3'), 'description' => 'normal vs. unsharp masking at default settings'.$only_gd2);
$Examples[] = array('getstrings' => array('src='.$img['landscape'].'&w=300', 'src='.$img['landscape'].'&w=300&fltr[]=blur|1', 'src='.$img['landscape'].'&w=300&fltr[]=blur|5'), 'description' => 'normal vs. blur at default (1) and heavy (5)'.$only_gd2);
$Examples[] = array('getstrings' => array('src='.$img['landscape'].'&w=300', 'src='.$img['landscape'].'&w=300&fltr[]=gblr', 'src='.$img['landscape'].'&w=300&fltr[]=sblr'), 'description' => 'normal vs. gaussian blur vs. selective blur'.$only_php500.$only_gd2);
$Examples[] = array('getstrings' => array('src='.$img['portrait'].'&w=100&h=100&far=L&bg=0000FF&f=png&fltr[]=bord|1', 'src='.$img['landscape'].'&w=100&h=100&far=T&bg=FF0000&f=png&fltr[]=bord|1', 'src='.$img['portrait'].'&w=100&h=100&far=C&bg=0000FF&f=png&fltr[]=bord|1', 'src='.$img['landscape'].'&w=100&h=100&far=B&bg=FF0000&f=png&fltr[]=bord|1', 'src='.$img['portrait'].'&w=100&h=100&far=R&bg=0000FF&f=png&fltr[]=bord|1'), 'description' => 'Forced Aspect Ratio, colored background, PNG output'.$only_gd);
$Examples[] = array('getstrings' => array('src='.$img['portrait'].'&w=150&ar=L', 'src='.$img['landscape'].'&w=150&ar=L'), 'description' => 'auto-rotate counter-clockwise to landscape from portrait &amp; lanscape'.$only_php42.$only_gd);
$Examples[] = array('getstrings' => array('src='.$img['portrait'].'&hp=100&wl=200', 'src='.$img['landscape'].'&hp=100&wl=200'), 'description' => 'auto-selection of W and H based on source image orientation');
$Examples[] = array('getstrings' => array('src='.$img['unrotated'].'&w=150&h=150', 'src='.$img['unrotated'].'&w=150&h=150&ar=x'), 'description' => 'original image vs. auto-rotated based on EXIF data'.$only_php42.$only_exif.$only_gd);
$Examples[] = array('getstrings' => array('src='.$img['landscape'].'&w=300&ra=30&bg=0000FF', 'src='.$img['landscape'].'&w=300&ra=30&f=png', 'src='.$img['alpha'].'&ra=30&f=png', 'src='.$img['alpha'].'&ra=30&f=gif'), 'description' => 'Rotated 30&deg; (counter-clockwise), width=300px, blue background vs. transparent background vs. rotated image with pre-existing alpha'.$only_php42.$only_gd);
$Examples[] = array('getstrings' => array('src='.$img['landscape'].'&w=300&h=300&far=1&bg=CCCCCC', 'src='.$img['landscape'].'&w=300&h=300&iar=1'), 'description' => 'Normal resize behavior (left) vs. Forced non-proportional resize (right)'.$only_gd);
$Examples[] = array('getstrings' => array('src='.$img['landscape'].'&w=100&h=50&zc=1', 'src='.$img['landscape'].'&w=100&zc=1', 'src='.$img['landscape'].'&h=50&zc=1', 'src='.$img['portrait'].'&w=100&h=50&zc=1', 'src='.$img['portrait'].'&w=100&zc=1', 'src='.$img['portrait'].'&h=50&zc=1'), 'description' => 'Zoom-Crop');
$Examples[] = array('getstrings' => array('src='.$img['whitespace'].'&w=100&h=100', 'src='.$img['whitespace'].'&w=100&h=100&ica=1', 'src='.$img['whitespace'].'&w=100&h=100&ica=2', 'src='.$img['whitespace'].'&w=100&h=100&ica=3', 'src='.$img['whitespace'].'&w=100&h=100&ica=4', 'src='.$img['whitespace'].'&w=100&h=100&ica=5|0.25|FFFFFF'), 'description' => 'ImageAutoCrop');
$Examples[] = array('getstrings' => array('src='.$img['landscape'].'&w=300&fltr[]=crop|50', 'src='.$img['landscape'].'&w=300&fltr[]=crop|0|0|0|0.25'), 'description' => 'crop filter');
$Examples[] = array('getstrings' => array('src='.$img['landscape'].'&w=300&fltr[]=bord|2|20|10|009900&f=png'), 'description' => '2px border, curved border corners (20px horizontal radius, 10px vertical radius)'.$only_gd);
$Examples[] = array('getstrings' => array('src='.$img['landscape'].'&w=300&fltr[]=ric|50|20&f=png'), 'description' => 'curved border corners (20px vertical radius, 50px horizontal radius)<br>'.$png_alpha.$only_gd2.$only_php432);
$Examples[] = array('getstrings' => array('src='.$img['landscape'].'&w=300&fltr[]=sat|75', 'src='.$img['landscape'].'&w=300', 'src='.$img['landscape'].'&w=300&fltr[]=sat|-100'), 'description' => 'saturation -75% vs. normal vs. -100%'.$only_gd2);
$Examples[] = array('getstrings' => array('src='.$img['landscape'].'&w=300&fltr[]=ds|75', 'src='.$img['landscape'].'&w=300', 'src='.$img['landscape'].'&w=300&fltr[]=ds|-100'), 'description' => 'desaturated 75% vs. normal vs. -100%'.$only_gd2);
$Examples[] = array('getstrings' => array('src='.$img['landscape'].'&w=300&fltr[]=clr|25|00FF00'), 'description' => 'colorized 25% to green (#00FF00)'.$only_gd2);
$Examples[] = array('getstrings' => array('src='.$img['landscape'].'&w=300&fltr[]=gray', 'src='.$img['landscape'].'&w=300&fltr[]=sep'), 'description' => 'grayscale vs. sepia'.$only_gd2);
$Examples[] = array('getstrings' => array('src='.$img['landscape'].'&w=300&fltr[]=mask|'.$img['mask3'].'&f=png', 'src='.$img['landscape'].'&w=300&fltr[]=mask|'.$img['mask1'].'&f=png', 'src='.$img['landscape'].'&w=300&fltr[]=mask|'.$img['mask2'].'&f=jpeg&bg=9900CC&q=100'), 'description' => 'Assorted alpha masks (seen below) applied<br>'.$png_alpha.$only_php432.'<br>JPEG/GIF output is flattened to "bg" background color'.$only_gd2.'<br><img src="../'.$img['mask3'].'" alt=""> <img src="../'.$img['mask1'].'" alt=""> <img src="../'.$img['mask2'].'" alt="">');
$Examples[] = array('getstrings' => array('src='.$img['landscape'].'&w=300&fltr[]=drop|5|10|000000|225&f=png', 'src='.$img['landscape'].'&w=300&fltr[]=mask|'.$img['mask3'].'&fltr[]=drop|5|10|000000|225&f=png', 'src='.$img['landscape'].'&w=300&fltr[]=drop|5|10|000000|225&fltr[]=elip&f=png', 'src='.$img['landscape'].'&w=300&fltr[]=elip&fltr[]=drop|5|10|000000|225&f=png'), 'description' => 'Drop shadow. Note how the order in which filters are applied matters.'.$only_php432.$only_gd);
$Examples[] = array('getstrings' => array('src='.$img['landscape'].'&w=300&fltr[]=elip&f=png', 'src='.$img['landscape'].'&w=300&fltr[]=elip&f=jpeg&bg=00FFFF'), 'description' => 'Ellipse<br>'.$png_alpha.$only_php432.'<br>JPEG/GIF output is flattened to "bg" background color'.$only_gd2);
$Examples[] = array('getstrings' => array('src='.$img['landscape'].'&w=300&fltr[]=flip|x', 'src='.$img['landscape'].'&w=300&fltr[]=flip|y', 'src='.$img['landscape'].'&w=300&fltr[]=flip|xy'), 'description' => 'flipped on X, Y and X+Y axes'.$only_gd);
$Examples[] = array('getstrings' => array('src='.$img['landscape'].'&w=300&fltr[]=bvl|10|FFFFFF|000000', 'src='.$img['landscape'].'&w=300&fltr[]=bvl|10|000000|FFFFFF'), 'description' => '10px bevel edge filter'.$only_php432.$only_gd);
$Examples[] = array('getstrings' => array('src='.$img['landscape'].'&w=300&fltr[]=fram|3|2|CCCCCC|FFFFFF|000000', 'src='.$img['landscape'].'&w=300&fltr[]=fram|3|2|CC9966|333333|CCCCCC'), 'description' => '3+2px frame filter'.$only_gd);
$Examples[] = array('getstrings' => array('src='.$img['landscape'].'&w=300&fltr[]=neg'), 'description' => 'Negative filter (inverted color)'.$only_gd);
$Examples[] = array('getstrings' => array('src='.$img['landscape'].'&w=300&fltr[]=th|105', 'src='.$img['landscape'].'&w=300&fltr[]=mask|'.$img['mask1'].'&fltr[]=th|105&f=png'), 'description' => 'Threshold filter; showing preserved alpha channel'.$only_php432.$only_gd);
$Examples[] = array('getstrings' => array('src='.$img['portrait'].'&w=150', 'src='.$img['portrait'].'&w=150&fltr[]=rcd|16|1', 'src='.$img['portrait'].'&w=150&fltr[]=rcd|16|0', 'src='.$img['portrait'].'&w=150&fltr[]=gray&fltr[]=rcd|8|1'), 'description' => 'ReduceColorDepth filter; original vs. 16-color dither vs. 16-color nodither vs. 4-gray dither'.$only_gd2);
$Examples[] = array('getstrings' => array('src='.$img['levels1'].'&w=150&fltr[]=hist|rgb||||BR|100&fltr[]=hist|*||||BL|100', 'src='.$img['levels1'].'&w=150&fltr[]=lvl|*|0&fltr[]=hist|rgb||||BR|100&fltr[]=hist|*||||BL|100', 'src='.$img['levels1'].'&w=150&fltr[]=lvl|*|1&fltr[]=hist|rgb||||BR|100&fltr[]=hist|*||||BL|100', 'src='.$img['levels1'].'&w=150&fltr[]=lvl|*|2&fltr[]=hist|rgb||||BR|100&fltr[]=hist|*||||BL|100', 'src='.$img['levels1'].'&w=150&fltr[]=lvl|*|3&fltr[]=hist|rgb||||BR|100&fltr[]=hist|*||||BL|100', "\n", 'src='.$img['levels2'].'&w=150&fltr[]=hist|rgb||||BR|100&fltr[]=hist|*||||BL|100', 'src='.$img['levels2'].'&w=150&fltr[]=lvl|*|0&fltr[]=hist|rgb||||BR|100&fltr[]=hist|*||||BL|100', 'src='.$img['levels2'].'&w=150&fltr[]=lvl|*|1&fltr[]=hist|rgb||||BR|100&fltr[]=hist|*||||BL|100', 'src='.$img['levels2'].'&w=150&fltr[]=lvl|*|2&fltr[]=hist|rgb||||BR|100&fltr[]=hist|*||||BL|100', 'src='.$img['levels2'].'&w=150&fltr[]=lvl|*|3&fltr[]=hist|rgb||||BR|100&fltr[]=hist|*||||BL|100'), 'description' => 'original vs. Levels filter methods (0=Internal RGB; 1=Internal Grayscale; 2=ImageMagick Contrast-Stretch; 3=ImageMagick Normalize)'.$only_gd);
$Examples[] = array('getstrings' => array('src='.$img['portrait'].'&w=300', 'src='.$img['portrait'].'&w=300&fltr[]=lvl', 'src='.$img['portrait'].'&w=300&fltr[]=wb'), 'description' => 'original vs. Levels vs. White Balance'.$only_gd);
$Examples[] = array('getstrings' => array('src='.$img['landscape'].'&w=300&fltr[]=hist|rgb', 'src='.$img['levels1'].'&w=300&fltr[]=hist|*'), 'description' => 'histograms of RGB vs. grayscale'.$only_gd);
$Examples[] = array('getstrings' => array('src='.$img['landscape'].'&w=300&fltr[]=edge'), 'description' => 'Edge Detect filter'.$php5_or_IM.$only_gd2);
$Examples[] = array('getstrings' => array('src='.$img['landscape'].'&w=300&fltr[]=emb'), 'description' => 'Emboss filter'.$php5_or_IM.$only_gd2);
$Examples[] = array('getstrings' => array('src='.$img['landscape'].'&w=300&fltr[]=mean'), 'description' => 'Mean Removal filter'.$only_php500.$only_gd2);
$Examples[] = array('getstrings' => array('src='.$img['landscape'].'&w=300&fltr[]=smth'), 'description' => 'Smooth filter'.$only_php500.$only_gd2);
$Examples[] = array('getstrings' => array('src='.$img['landscape'].'&w=300&fltr[]=gam|0.5', 'src='.$img['landscape'].'&w=300&fltr[]=gam|1.0', 'src='.$img['landscape'].'&w=300&fltr[]=gam|2.0'), 'description' => 'Gamma corrected to 0.5 vs. 1.0 (normal) vs. 2.0'.$only_gd2_im);
$Examples[] = array('getstrings' => array('src='.$img['landscape'].'&w=300', 'src='.$img['landscape'].'&w=300&fltr[]=brit|50', 'src='.$img['landscape'].'&w=300&fltr[]=brit|-50'), 'description' => 'Brightness filter (original vs. +50 vs. -50)'.$only_gd2);
$Examples[] = array('getstrings' => array('src='.$img['landscape'].'&w=300', 'src='.$img['landscape'].'&w=300&fltr[]=cont|50', 'src='.$img['landscape'].'&w=300&fltr[]=cont|-50'), 'description' => 'Contrast filter (original vs. +50 vs. -50)'.$only_gd2);
$Examples[] = array('getstrings' => array('src='.$img['portrait'].'&w=300&fltr[]=over|'.$img['frame1'].'|0', 'src='.$img['portrait'].'&w=300&fltr[]=over|'.$img['frame2'].'|1'), 'description' => 'Overlay vs. Underlay<br><br>Original over/under images:<br><table border="0"><tr><td style="padding: 20px; background-image: url(../'.$img['background'].');"><img src="../'.$img['frame1'].'" alt=""> <img src="../'.$img['frame2'].'" alt=""></td></tr></table>'.$only_gd);
$Examples[] = array('getstrings' => array('src='.$img['landscape'].'&w=300&fltr[]=wmt|phpThumb|18|C|FF0000|loki.ttf|100|5|20&f=png', 'src='.$img['landscape'].'&w=300&fltr[]=wmt|'.rawurlencode('&#9786;&#9835;&#0470;&#1694;').'|40|L|FF0000|arial.ttf|100&f=png', 'src='.$img['landscape'].'&w=300&fltr[]=wmt|copyright+'.date('Y').'|3|BR|00FF00||50&f=png', 'src='.$img['landscape'].'&w=300&fltr[]=wmt|copyright+'.date('Y').'%0AphpThumb()|3|L|00FFFF&f=png'), 'description' => 'Text overlay, TTF and built-in fonts, unicode characters (rawurlencoded HTMLentities), multiple lines, metacharacters (height, width)'.$only_gd);
$Examples[] = array('getstrings' => array('src='.$img['landscape'].'&w=300&fltr[]=wmt|thumbnail+=+^Xx^Y|3|BR|00FFFF||50&f=png', 'src='.$img['landscape'].'&w=300&fltr[]=wmt|click%0Ahere%0A^FkkB|10|L|FF00FF|arial.ttf|100|0||333399|50|y&f=png', 'src='.$img['landscape'].'&w=300&fltr[]=wmt|resized:+^Xx^Y+to+^xx^y|10|B|FFFFFF|arial.ttf|100|0||000000|100|x&f=png'), 'description' => 'metacharacters (height, width), background color, background extend'.$only_gd);
$Examples[] = array('getstrings' => array('new=FF0000&w=100&h=50&fltr[]=bvl|10&fltr[]=wmt|hello|14|C|00FFFF|arial.ttf&f=png', 'new=FF0000|25&w=150&h=50&fltr[]=bvl|10&fltr[]=wmt|25%+opaque|14|C|0066FF|arial.ttf&f=png'), 'description' => 'Image created with "new", red background, bevel, TTF text'.$only_gd);
$Examples[] = array('getstrings' => array('src='.$img['bmp'].'&w=300'), 'description' => 'BMP source, width=300px');
$Examples[] = array('getstrings' => array('src='.$img['tiff'], 'src='.$img['tiff'].'&w=300&aoe=1'), 'description' => 'TIFF source, width=300px'.$only_im.$only_im_tiff);
$Examples[] = array('getstrings' => array('src='.$img['wmf'].'&w=300'), 'description' => 'WMF source, width=300px'.$only_im);
$Examples[] = array('getstrings' => array('src='.$img['pdf'].'&w=300'), 'description' => 'PDF source, width=300px'.$only_im.$only_gs);
//$Examples[] = array('getstrings' => array(''), 'description' => '');
foreach ($Examples as $key => $ExamplesArray) {
echo '<a href="#" name="x'.$key.'" title="click to get URL link for example #'.$key.'" onClick="prompt(\'Here is the link to example #'.$key.'\', \'http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'].'#x'.$key.'\'); return false;">#'.$key.'</a>';
echo '<table border="0"><tr><td style="padding: 20px; background-image: url(../'.$img['background'].');">';
$text = '';
foreach ($ExamplesArray['getstrings'] as $dummy => $GETstring) {
if ($GETstring == "\n") {
echo '<br>';
$text .= "\n";
} else {
echo '<img border="0" src="'.htmlentities(phpThumbURL($GETstring, $phpThumbBase), ENT_QUOTES).'" title="'.htmlentities($GETstring, ENT_QUOTES).'" style="min-width: 10px; min-height: 10px; margin: 2px;">';
$text .= '<img src="'.phpThumbURL($GETstring, $phpThumbBase).'">'."\n";
}
}
echo '</td></tr></table>';
echo '<pre>'.htmlentities($text).'</pre>';
echo $ExamplesArray['description'].'<br>';
echo '<br><br><hr size="1">';
}
$PATH_INFO_examples = array(
'fltr[]=sep;200x200;'.$img['portrait'],
'f=png;fltr[]=wmt|hello;fltr[]=flip|y;fltr[]=wmt|hello;200x100;new=FF00FF',
);
echo '<a href="#" name="pathinfo" title="click to get URL link for PATH_INFO example" onClick="prompt(\'Here is the link to the PATH_INFO example\', \'http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'].'#pathinfo\'); return false;">#pathinfo</a>';
echo '<table border="0"><tr><td style="padding: 20px; background-image: url(../'.$img['background'].');">';
foreach ($PATH_INFO_examples as $key => $value) {
echo ' <img src="'.htmlentities($phpThumbBase.'/'.$value, ENT_QUOTES).'" alt=""> ';
}
echo '</td></tr></table>';
echo '<pre>';
foreach ($PATH_INFO_examples as $key => $value) {
echo htmlentities(' <img src="'.htmlentities($phpThumbBase.'/'.$value, ENT_QUOTES).'" alt=""> ')."\n";
}
echo '</pre>';
echo 'PATH_INFO example<br>';
echo '<br><br><hr size="1">';
?>
<a name="gd1vs2"></a><br>
<table border="5" cellspacing="0" cellpadding="3" width="500">
<tr>
<td colspan="4">
<b>Illustration of potential difference between GD1.x and GD2.x</b><br>
In most cases the thumbnails produced by phpThumb() on GD v1.x are perfectly
acceptable, but in some cases it may look ugly. Diagonal lines and reducing a
very large source image increase chance for bad results (the house/sky picture
has both problems). Here are three static examples:
</td>
</tr>
<tr>
<td><b>GD v2.0.15</b></td>
<td><img src="../images/PHP-GD2-kayak.jpg" width="200" height="133" border="0" alt="kayak.jpg generated with phpThumb() on GD v2.0.15"></td>
<td><img src="../images/PHP-GD2-bottle.jpg" width="100" height="152" border="0" alt="bottle.jpg generated with phpThumb() on GD v2.0.15"></td>
<td><img src="../images/PHP-GD2-sky.jpg" width="200" height="150" border="0" alt="sky.jpg generated with phpThumb() on GD v2.0.15"></td>
</tr>
<tr>
<td><b>GD v1.6.2</b></td>
<td><img src="../images/PHP-GD1-kayak.jpg" width="200" height="133" border="0" alt="kayak.jpg generated with phpThumb() on GD v1.6.2"></td>
<td><img src="../images/PHP-GD1-bottle.jpg" width="100" height="152" border="0" alt="bottle.jpg generated with phpThumb() on GD v1.6.2"></td>
<td><img src="../images/PHP-GD1-sky.jpg" width="200" height="150" border="0" alt="sky.jpg generated with phpThumb() on GD v1.6.2"></td>
</tr>
</table><br>
<hr size="1">
<br>
<a name="showpic"></a>
<b>Demo of <i>phpThumb.demo.showpic.php</i></b><br>
<br>
<?php
echo 'Small picture (400x300), window opened at wrong size (640x480):<br>';
echo '<i>(mouse-over to see calling parameters)</i><br>';
echo '<img src="../'.$img['small'].'" border="2" alt="" style="max-width: 200px; max-height: 200px;"><br>';
$SmallParams = array(
'unmodified' => '',
'text watermark' => '&fltr[]=wmt|Watermark|20|C|FF0000|arial.ttf|100',
);
foreach ($SmallParams as $description => $moreparams) {
echo '<a title="phpThumb.demo.showpic.php?src='.htmlentities($img['small'].$moreparams).'" href="#" onClick="window.open(\'phpThumb.demo.showpic.php?src='.htmlentities($img['small'].$moreparams.'&title=This+is+a+small+picture').'\', \'showpic1\', \'width=640,height=480,resizable=no,status=no,menubar=no,toolbar=no,scrollbars=no\'); return false;">'.htmlentities($description).'</a> ';
}
?>
<br>
<br>
<?php
echo 'Big picture (2272x1704), window opened at wrong size (640x480):<br>';
echo '<i>(mouse-over to see calling parameters)</i><br>';
echo '<img src="../'.$img['big'].'" border="2" alt="" style="max-width: 200px; max-height: 200px;"><br>';
$BigParams = array(
'unmodified' => '',
'width=800' => '&w=800',
'width=200, grayscale' => '&w=300&fltr[]=gray',
);
foreach ($BigParams as $description => $moreparams) {
echo '<a title="phpThumb.demo.showpic.php?src='.htmlentities($img['big'].$moreparams).'" href="#" onClick="window.open(\'phpThumb.demo.showpic.php?src='.htmlentities($img['big'].$moreparams.'&title=This+is+a+big+picture').'\', \'showpic2\', \'width=640,height=480,resizable=yes,status=no,menubar=no,toolbar=no,scrollbars=no\'); return false;">'.htmlentities($description).'</a> ';
}
?>
<br>
<hr size="1">
<?php
echo 'The source images, without manipulation:<ul>';
foreach ($img as $key => $value) {
echo '<li><a href="../'.$value.'">'.basename($value).'</a></li>';
}
echo '</ul><hr>';
?>
</body>
</html>

View File

@@ -0,0 +1,105 @@
<?php
//////////////////////////////////////////////////////////////
// phpThumb() by James Heinrich <info@silisoftware.com> //
// available at http://phpthumb.sourceforge.net //
// and/or https://github.com/JamesHeinrich/phpThumb //
//////////////////////////////////////////////////////////////
/// //
// phpThumb.demo.gallery.php //
// James Heinrich <info@silisoftware.com> //
// //
// Demo showing basic usage of phpThumb in a photo gallery //
// //
//////////////////////////////////////////////////////////////
die('For security reasons, this demo is disabled by default. Please comment out line '.__LINE__.' in '.basename(__FILE__));
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>phpThumb :: sample photo gallery demo</title>
</head>
<body>
This is a demo of how you can use <a href="http://phpthumb.sourceforge.net">phpThumb()</a> in an image gallery.<br>
<hr>
<?php
$docroot = realpath((getenv('DOCUMENT_ROOT') && preg_match('#^'.preg_quote(realpath(getenv('DOCUMENT_ROOT'))).'#', realpath(__FILE__))) ? getenv('DOCUMENT_ROOT') : str_replace(dirname(@$_SERVER['PHP_SELF']), '', str_replace(DIRECTORY_SEPARATOR, '/', __DIR__ )));
$imgdir = '/images/'; // webroot-relative path to main images directory (only this and subdirectories of this will be displayed)
$thumb = '/phpThumb.php'; // webroot-relative path to "phpThumb.php"
$config = '/phpThumb.config.php'; // webroot-relative path to "phpThumb.php"
$popup = '/demo/phpThumb.demo.showpic.php'; // webroot-relative path to "phpThumb.demo.showpic.php" (only used if $use_popup == true)
$thumbnailsize = 120; // size of thumbnails in pixels when browsing gallery
$displaysize = 480; // size of large image display (popup or plain image) after clicking on thumbnail
$use_popup = true; // if true, open large image in self-resizing popup window; if false, display larger image in main window
//////////////////////////////////////////////////////////////
require_once $docroot.$config;
$dirlimit = realpath($docroot.'/'.$imgdir);
$captionfile = $docroot.'/'.$imgdir.(@$_REQUEST['dir'] ? $_REQUEST['dir'].'/' : '').'captions.txt';
if (file_exists($captionfile)) {
$filecontents = file($captionfile);
foreach ($filecontents as $key => $value) {
@list($photo, $caption) = explode("\t", $value);
$CAPTIONS[$photo] = $caption;
}
}
if (!empty($_REQUEST['pic'])) {
$alt = @$CAPTIONS[$_REQUEST['pic']] ? $CAPTIONS[$_REQUEST['pic']] : $_REQUEST['pic'];
echo '<img src="'.htmlentities(phpThumbURL('src='.urlencode($imgdir.@$_REQUEST['dir'].'/'.$_REQUEST['pic']).'&w='.$displaysize.'&h='.$displaysize, $thumb)).'" border="0" alt="'.htmlentities($alt, ENT_QUOTES).'"><br>';
echo '<div align="center">'.htmlentities(@$CAPTIONS[$_REQUEST['pic']]).'</div>';
} else {
$currentdir = realpath($docroot.'/'.$imgdir.@$_REQUEST['dir']);
if (!preg_match('#^'.preg_quote($dirlimit).'#', $currentdir)) {
echo 'Cannot browse to "'.htmlentities($currentdir).'"<br>';
} elseif ($dh = @opendir($currentdir)) {
$folders = array();
$pictures = array();
while ($file = readdir($dh)) {
if (is_dir($currentdir.'/'.$file) && ($file{0} != '.')) {
$folders[] = $file;
} elseif (preg_match('#\\.(jpe?g|gif|png|bmp|tiff?)$#i', $file)) {
$pictures[] = $file;
}
}
closedir($dh);
if (preg_match('#^'.preg_quote($dirlimit).'#', realpath($currentdir.'/..'))) {
echo '<a href="'.htmlentities($_SERVER['PHP_SELF'].'?dir='.urlencode($_REQUEST['dir'].'/..'), ENT_QUOTES).'">Parent directory</a><br>';
}
if (!empty($folders)) {
echo '<ul>';
rsort($folders);
foreach ($folders as $dummy => $folder) {
echo '<li><a href="'.htmlentities($_SERVER['PHP_SELF'].'?dir='.urlencode(@$_REQUEST['dir'].'/'.$folder), ENT_QUOTES).'">'.htmlentities($folder).'</a></li>';
}
echo '</ul>';
}
if (!empty($pictures)) {
foreach ($pictures as $file) {
$alt = (!empty($CAPTIONS[$file]) ? $CAPTIONS[$file] : $file);
echo '<table style="float: left;">'.(!empty($CAPTIONS[$file]) ? '<caption align="bottom">'.htmlentities($CAPTIONS[$file]).'</caption>' : '').'<tbody><tr><td>';
if ($use_popup) {
echo '<a title="'.htmlentities($alt, ENT_QUOTES).'" href="#" onClick="window.open(\''.$popup.'?src='.htmlentities($imgdir.@$_REQUEST['dir'].'/'.$file.'&w='.$displaysize.'&h='.$displaysize.'&title='.urlencode(@$CAPTIONS[$file] ? $CAPTIONS[$file] : $file)).'\', \'showpic\', \'width='.$displaysize.',height='.$displaysize.',resizable=no,status=no,menubar=no,toolbar=no,scrollbars=no\'); return false;">';
} else {
echo '<a title="'.htmlentities($alt, ENT_QUOTES).'" href="'.$_SERVER['PHP_SELF'].'?dir='.htmlentities(urlencode(@$_REQUEST['dir']).'&pic='.urlencode($file)).'">';
}
echo '<img src="'.htmlentities(phpThumbURL('src='.urlencode($imgdir.@$_REQUEST['dir'].'/'.$file).'&zc=1&w='.$thumbnailsize.'&h='.$thumbnailsize, $thumb)).'" border="1" width="'.$thumbnailsize.'" height="'.$thumbnailsize.'" alt="'.htmlentities($alt, ENT_QUOTES).'">';
echo '</a></td></tr></tbody></table>';
}
echo '<br clear="all">';
} else {
echo '<i>No pictures in "'.htmlentities(str_replace(realpath($docroot), '', realpath($docroot.'/'.$imgdir.@$_REQUEST['dir']))).'"</i>';
}
} else {
echo 'failed to open "'.htmlentities($currentdir).'"';
}
}
?>
</body>
</html>

View File

@@ -0,0 +1,85 @@
<?php
//////////////////////////////////////////////////////////////
// phpThumb() by James Heinrich <info@silisoftware.com> //
// available at http://phpthumb.sourceforge.net //
// and/or https://github.com/JamesHeinrich/phpThumb //
//////////////////////////////////////////////////////////////
/// //
// phpThumb.demo.object.php //
// James Heinrich <info@silisoftware.com> //
// //
// Example of how to use phpthumb.class.php as an object //
// //
//////////////////////////////////////////////////////////////
// Note: phpThumb.php is where the caching code is located, if
// you instantiate your own phpThumb() object that code is
// bypassed and it's up to you to handle the reading and
// writing of cached files, if appropriate.
die('For security reasons, this demo is disabled by default. Please comment out line '.__LINE__.' in '.basename(__FILE__));
require_once '../phpthumb.class.php';
// create phpThumb object
$phpThumb = new phpThumb();
// create 3 sizes of thumbnail
$thumbnail_widths = array(160, 320, 640);
$capture_raw_data = false; // set to true to insert to database rather than render to screen or file (see below)
foreach ($thumbnail_widths as $thumbnail_width) {
// this is very important when using a single object to process multiple images
$phpThumb->resetObject();
// set data source -- do this first, any settings must be made AFTER this call
$phpThumb->setSourceFilename('images/loco.jpg'); // for static demo only
//$phpThumb->setSourceFilename($_FILES['userfile']['tmp_name']);
// or $phpThumb->setSourceData($binary_image_data);
// or $phpThumb->setSourceImageResource($gd_image_resource);
// PLEASE NOTE:
// You must set any relevant config settings here. The phpThumb
// object mode does NOT pull any settings from phpThumb.config.php
//$phpThumb->setParameter('config_document_root', '/home/groups/p/ph/phpthumb/htdocs/');
//$phpThumb->setParameter('config_cache_directory', '/tmp/persistent/phpthumb/cache/');
// set parameters (see "URL Parameters" in phpthumb.readme.txt)
$phpThumb->setParameter('w', $thumbnail_width);
//$phpThumb->setParameter('h', 100);
//$phpThumb->setParameter('fltr', 'gam|1.2');
//$phpThumb->setParameter('fltr', 'wmi|../watermark.jpg|C|75|20|20');
// set options (see phpThumb.config.php)
// here you must preface each option with "config_"
$phpThumb->setParameter('config_output_format', 'jpeg');
$phpThumb->setParameter('config_imagemagick_path', '/usr/local/bin/convert');
//$phpThumb->setParameter('config_allow_src_above_docroot', true); // needed if you're working outside DOCUMENT_ROOT, in a temp dir for example
// generate & output thumbnail
$output_filename = './thumbnails/'.basename($_FILES['userfile']['name']).'_'.$thumbnail_width.'.'.$phpThumb->config_output_format;
if ($phpThumb->GenerateThumbnail()) { // this line is VERY important, do not remove it!
$output_size_x = imagesx($phpThumb->gdimg_output);
$output_size_y = imagesy($phpThumb->gdimg_output);
if ($output_filename || $capture_raw_data) {
if ($capture_raw_data && $phpThumb->RenderOutput()) {
// RenderOutput renders the thumbnail data to $phpThumb->outputImageData, not to a file or the browser
$mysqli->query("INSERT INTO `table` (`thumbnail`) VALUES ('".mysqli_real_escape_string($phpThumb->outputImageData)."') WHERE (`id` = '".mysqli_real_escape_string($id)."')");
} elseif ($phpThumb->RenderToFile($output_filename)) {
// do something on success
echo 'Successfully rendered:<br><img src="'.$output_filename.'">';
} else {
// do something with debug/error messages
echo 'Failed (size='.$thumbnail_width.'):<pre>'.implode("\n\n", $phpThumb->debugmessages).'</pre>';
}
$phpThumb->purgeTempFiles();
} else {
$phpThumb->OutputThumbnail();
}
} else {
// do something with debug/error messages
echo 'Failed (size='.$thumbnail_width.').<br>';
echo '<div style="background-color:#FFEEDD; font-weight: bold; padding: 10px;">'.$phpThumb->fatalerror.'</div>';
echo '<form><textarea rows="10" cols="60" wrap="off">'.htmlentities(implode("\n* ", $phpThumb->debugmessages)).'</textarea></form><hr>';
}
}

View File

@@ -0,0 +1,63 @@
<?php
//////////////////////////////////////////////////////////////
// phpThumb() by James Heinrich <info@silisoftware.com> //
// available at http://phpthumb.sourceforge.net //
// and/or https://github.com/JamesHeinrich/phpThumb //
//////////////////////////////////////////////////////////////
/// //
// phpThumb.demo.object.simple.php //
// James Heinrich <info@silisoftware.com> //
// //
// Simplified example of how to use phpthumb.class.php as //
// an object -- please also see phpThumb.demo.object.php //
// //
//////////////////////////////////////////////////////////////
// Note: phpThumb.php is where the caching code is located, if
// you instantiate your own phpThumb() object that code is
// bypassed and it's up to you to handle the reading and
// writing of cached files, if appropriate.
die('For security reasons, this demo is disabled by default. Please comment out line '.__LINE__.' in '.basename(__FILE__));
require_once '../phpthumb.class.php';
// create phpThumb object
$phpThumb = new phpThumb();
$thumbnail_width = 100;
// set data source -- do this first, any settings must be made AFTER this call
if (is_uploaded_file(@$_FILES['userfile']['tmp_name'])) {
$phpThumb->setSourceFilename($_FILES['userfile']['tmp_name']);
$output_filename = './thumbnails/'.basename($_FILES['userfile']['name']).'_'.$thumbnail_width.'.'.$phpThumb->config_output_format;
} else {
$phpThumb->setSourceData(file_get_contents('..\images\disk.jpg'));
$output_filename = './thumbnails/disk_small.jpg';
}
// PLEASE NOTE:
// You must set any relevant config settings here. The phpThumb
// object mode does NOT pull any settings from phpThumb.config.php
//$phpThumb->setParameter('config_document_root', '/home/groups/p/ph/phpthumb/htdocs/');
//$phpThumb->setParameter('config_cache_directory', '/tmp/persistent/phpthumb/cache/');
// set parameters (see "URL Parameters" in phpthumb.readme.txt)
$phpThumb->setParameter('w', $thumbnail_width);
//$phpThumb->setParameter('fltr', 'gam|1.2');
//$phpThumb->setParameter('fltr', 'wmi|../watermark.jpg|C|75|20|20');
// generate & output thumbnail
if ($phpThumb->GenerateThumbnail()) { // this line is VERY important, do not remove it!
if ($phpThumb->RenderToFile($output_filename)) {
// do something on success
echo 'Successfully rendered to "'.$output_filename.'"';
} else {
// do something with debug/error messages
echo 'Failed:<pre>'.implode("\n\n", $phpThumb->debugmessages).'</pre>';
}
$phpThumb->purgeTempFiles();
} else {
// do something with debug/error messages
echo 'Failed:<pre>'.$phpThumb->fatalerror."\n\n".implode("\n\n", $phpThumb->debugmessages).'</pre>';
}

View File

@@ -0,0 +1,96 @@
<?php
//////////////////////////////////////////////////////////////
// phpThumb() by James Heinrich <info@silisoftware.com> //
// available at http://phpthumb.sourceforge.net //
// and/or https://github.com/JamesHeinrich/phpThumb //
//////////////////////////////////////////////////////////////
/// //
// phpThumb.demo.random.php //
// James Heinrich <info@silisoftware.com> //
// //
// Display a random image from a specified directory. //
// Run with no parameters for usage instructions. //
// //
//////////////////////////////////////////////////////////////
die('For security reasons, this demo is disabled by default. Please comment out line '.__LINE__.' in '.basename(__FILE__));
function SelectRandomImage($dirname='.', $portrait=true, $landscape=true, $square=true) {
// return a random image filename from $dirname
// the last 3 parameters determine what aspect ratio of images
// may be returned
$possibleimages = array();
if ($dh = opendir($dirname)) {
while ($file = readdir($dh)) {
if (is_file($dirname.'/'.$file) && preg_match('#\\.(jpg|jpeg|gif|png|tiff|bmp)$#i', $file)) {
if ($gis = @getimagesize($dirname.'/'.$file)) {
if ($portrait && ($gis[0] < $gis[1])) {
// portrait
$possibleimages[] = $file;
} elseif ($landscape && ($gis[0] > $gis[1])) {
// landscape
$possibleimages[] = $file;
} elseif ($square) {
// square
$possibleimages[] = $file;
}
}
}
}
closedir($dh);
}
if (empty($possibleimages)) {
return false;
}
if (PHP_VERSION < '4.2.0') {
mt_srand(time());
}
$randkey = mt_rand(0, count($possibleimages) - 1);
return realpath($dirname.'/'.$possibleimages[$randkey]);
}
if (@$_REQUEST['dir']) {
if (is_dir($_REQUEST['dir'])) {
if (!@$_REQUEST['o']) {
$_REQUEST['o'] = 'PLS';
}
$_REQUEST['o'] = strtoupper($_REQUEST['o']);
$portrait = (strpos(@$_REQUEST['o'], 'P') !== false);
$landscape = (strpos(@$_REQUEST['o'], 'L') !== false);
$square = (strpos(@$_REQUEST['o'], 'S') !== false);
$randomSRC = SelectRandomImage($_REQUEST['dir'], $portrait, $landscape, $square);
if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
$randomSRC = str_replace('\\', '/', preg_replace('#^'.realpath(@$_SERVER['DOCUMENT_ROOT']).'#i', '', realpath($randomSRC)));
} else {
$randomSRC = str_replace(realpath(@$_SERVER['DOCUMENT_ROOT']), '', realpath($randomSRC));
}
$otherParams = array();
foreach ($_GET as $key => $value) {
if (($key == 'dir') || ($key == 'o')) {
continue;
}
if (is_array($value)) {
foreach ($value as $vkey => $vvalue) {
$otherParams[] = urlencode($key).'['.urlencode($vkey).']='.urlencode($vvalue);
}
} else {
$otherParams[] = urlencode($key).'='.urlencode($value);
}
}
header('Location: ../phpThumb.php?src='.urlencode($randomSRC).'&'.implode('&', $otherParams));
exit;
} else {
echo htmlentities($_REQUEST['dir']).' is not a directory';
exit;
}
} else {
echo '<html><body>Usage: <b>'.basename($_SERVER['PHP_SELF']).'?dir=<i>&lt;directory&gt;</i>&amp;<i>&lt;phpThumb parameters&gt;</i></b>&amp;o=<i>(P|L|S)</i><br><br>Examples:<ul>';
echo '<li>'.basename($_SERVER['PHP_SELF']).'?./images/&o=L <i>(landscape images only)</i></li>';
echo '<li>'.basename($_SERVER['PHP_SELF']).'?./images/&o=PS <i>(portrait or square images only)</i></li>';
echo '</ul></body></html>';
}

View File

@@ -0,0 +1,140 @@
<?php
//////////////////////////////////////////////////////////////
// phpThumb() by James Heinrich <info@silisoftware.com> //
// available at http://phpthumb.sourceforge.net //
// and/or https://github.com/JamesHeinrich/phpThumb //
//////////////////////////////////////////////////////////////
// //
// phpThumb.demo.showpic.php //
// James Heinrich <info@silisoftware.com> //
// 23 Feb 2004 //
// //
// This code is useful for popup pictures (e.g. thumbnails //
// you want to show larger, such as a larger version of a //
// product photo for example) but you don't know the image //
// dimensions before popping up. This script displays the //
// image with no window border, and resizes the window to //
// the size it needs to be (usually better to spawn it //
// large (600x400 for example) and let it auto-resize it //
// smaller), and if the image is larger than 90% of the //
// current screen area the window respawns itself with //
// scrollbars. //
// //
// Usage: //
// window.open('showpic.php?src=big.jpg&title=Big+picture', //
// 'popupwindowname', //
// 'width=600,height=400,menubar=no,toolbar=no') //
// //
// See demo linked from http://phpthumb.sourceforge.net ///
//////////////////////////////////////////////////////////////
die('For security reasons, this demo is disabled by default. Please comment out line '.__LINE__.' in '.basename(__FILE__));
$phpThumbLocation = '../phpThumb.php';
require_once '../phpThumb.config.php';
echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">';
echo '<html><head>';
if (isset($_GET['title'])) {
echo '<title>'.htmlentities($_GET['title']).'</title>';
unset($_GET['title']);
} else {
echo '<title>'.htmlentities('phpThumb :: popup window resizing demo').'</title>';
}
?>
<script type="text/javascript">
<!--
// http://www.xs4all.nl/~ppk/js/winprop.html
function CrossBrowserResizeInnerWindowTo(newWidth, newHeight) {
if (self.innerWidth) {
frameWidth = self.innerWidth;
frameHeight = self.innerHeight;
} else if (document.documentElement && document.documentElement.clientWidth) {
frameWidth = document.documentElement.clientWidth;
frameHeight = document.documentElement.clientHeight;
} else if (document.body) {
frameWidth = document.body.clientWidth;
frameHeight = document.body.clientHeight;
} else {
return false;
}
if (document.layers) {
newWidth -= (parent.outerWidth - parent.innerWidth);
newHeight -= (parent.outerHeight - parent.innerHeight);
}
// original code:
//parent.window.resizeTo(newWidth, newHeight);
// fixed code: James Heinrich, 20 Feb 2004
parent.window.resizeBy(newWidth - frameWidth, newHeight - frameHeight);
return true;
}
// -->
</script>
<script type="text/javascript" src="javascript_api.js"></script>
<?php
$allowedGETparameters = array('src','new','w','h','wp','hp','wl','hl','ws','hs','f','q','sx','sy','sw','sh','zc','bc','bg','bgt','fltr','xto','ra','ar','aoe','far','iar','maxb','hash','md5s','sfn','dpi','sia');
$additionalparameters = array();
foreach ($_GET as $key => $value) {
if (!in_array($key, $allowedGETparameters)) {
continue;
}
if (is_array($value)) {
if ($key != 'fltr') {
continue;
}
foreach ($value as $key2 => $value2) {
@$additionalparameters[$key][] = preg_replace('#[^A-Za-z0-9\\. _:/]#', '', $value2);
}
} else {
if ($key == 'src') {
// allow as passed
$additionalparameters[$key] = $value;
} else {
$additionalparameters[$key] = preg_replace('#[^A-Za-z0-9\\. _:/]#', '', $value);
}
}
}
$imagesrc = phpThumbURL($additionalparameters, $phpThumbLocation);
echo '<script type="text/javascript">';
echo 'var ns4;'."\n";
echo 'var op5;'."\n";
echo 'function setBrowserWindowSizeToImage() {'."\n";
echo 'if (!document.getElementById("imageimg")) { return false; }'."\n";
echo 'sniffBrowsers();'."\n";
echo 'var imageW = getImageWidth("imageimg");'."\n";
echo 'var imageH = getImageHeight("imageimg");'."\n";
// check for maximum dimensions to allow no-scrollbar window
echo 'if (((screen.width * 1.1) > imageW) || ((screen.height * 1.1) > imageH)) {'."\n";
// screen is large enough to fit whole picture on screen with 10% margin
echo 'CrossBrowserResizeInnerWindowTo(imageW, imageH);'."\n";
echo '} else {'."\n";
// image is too large for screen: add scrollbars by putting the image inside an IFRAME
echo 'document.getElementById("showpicspan").innerHTML = "<iframe width=\"100%\" height=\"100%\" marginheight=\"0\" marginwidth=\"0\" frameborder=\"0\" scrolling=\"on\" src=\"'.$imagesrc.'\">Your browser does not support the IFRAME tag. Please use one that does (Chrome, Firefox, etc).<br><img src=\"'.$imagesrc.'\"><\/iframe>";'."\n";
echo '}'."\n";
echo '}';
echo '</script>';
echo '</head><body style="margin: 0;" onLoad="setBrowserWindowSizeToImage();"><div id="showpicspan">';
if (!empty($_GET['src'])) {
echo '<script type="text/javascript">';
echo 'document.writeln(\'<img src="'.$imagesrc.'" border="0" id="imageimg" hspace="0" hspace="0" style="padding: 0px; margin: 0px;">\');';
echo '</script>';
} else {
echo '<pre>';
echo 'Usage:<br><br><b>'.basename(__FILE__).'?src=<i>filename</i>&amp;title=<i>Picture+Title</i></b>';
echo '</pre>';
}
?></div></body>
</html>

View File

@@ -0,0 +1,50 @@
//////////////////////////////////////////////////////////////////
// phpThumb() by James Heinrich <info@silisoftware.com> //
// available at http://phpthumb.sourceforge.net //
// and/or https://github.com/JamesHeinrich/phpThumb //
//////////////////////////////////////////////////////////////////
/// //
// phpThumb() included and related demos //
// ///
//////////////////////////////////////////////////////////////////
The phpThumb() distribution includes several demos, and it
should be self-evident what they do when you run them:
* phpThumb.demo.check.php - configuration checker, will check
your config file and server configuration and warn of any
potential problems
* phpThumb.demo.demo.php - shows a wide variety of samples,
basically all the different features and filters of phpThumb.
Note: sample image files are not included in the distribution
but can be downloaded from http://phpthumb.sourceforge.net/demo
* phpThumb.demo.gallery.php - basic demonstration of a photo
gallery with ability to browse subdirectories. May use
phpThumb.demo.showpic.php for fullsize popup display
* phpThumb.demo.showpic.php - auto-resizes a popup window to
match the dimensions of the image it is displaying
* phpThumb.demo.object.php - example of how to call phpThumb
as an object.
* phpThumb.demo.object.simple.php - simplified version of
phpThumb.demo.object.php with fewer options shown.
* phpThumb.demo.random.php - select & display a random thumbnail
from a directory of images.
Other people have created useful demos and/or extensions to
phpThumb(). Some of these I know of are:
(also see http://phpthumb.sourceforge.net for an updated list)
* iManager/iBrowser - http://www.j-cons.com/news/
* ThumbnailSelector - http://www.silisoftware.com/scripts/ThumbnailSelector
* Applejuice Build_Gallery - http://twofivethreetwo.com/?nav=scripts
If you know of any others you think should be mentioned here
please let me know: info@silisoftware.com