'#191919');
$set['image blank'] = 'R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==';
$set['image close'] = 'R0lGODlhLAAKAMQZAFVVVURERM/Pz+vr6+fn59ra2t3d3eTk5NPT0+7u7hEREfz8/IiIiCIiInd3d5mZmTMzM9bW1qqqqvj4+PX19eDg4PHx8QAAAMzMzP///wAAAAAAAAAAAAAAAAAAAAAAACH5BAEAABkALAAAAAAsAAoAAAWpYCaOFjaNaKqqSROk0uWo5bnedxJcrxhfD5oJR1wBeJmfRETAYCKUWoYScR4yFoHzZHBCcUfI5bLMDDCDTGUgFRSw6EpkJF+oEcQjeWQwoGolFCIRFSUVglpOTjgYCmM9GQV+JCaBgxUiFRgJAgRFGY1kRz1NaQQEFJsLApglaSKsFQiCBRYroWWjIgdetJUIVhm8GLMLBV42KBhjZSJHAJ/ROAzNIwwGIQA7';
$set['image next'] = 'R0lGODlhOQAcAMQYAO7u7ufn5/j4+Ovr6/Hx8fX19dPT093d3c/PzzMzM+Tk5Pz8/KqqqoiIiNra2kRERGZmZhEREeDg4NbW1u/v7wAAAMzMzP///////wAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAABgALAAAAAA5ABwAAAWzIHaNZGmeaKqubOu+cCzPdG3feK7vfO//PwAwB0hYhi0CIgWoVBrIVeCIajofwprA4rBYAqOpBTEQGMAKA8VrkZyszghD275MFwND4TKwCAAWBxZ7U0xOhxUQNFsDFwR+gmwWBBcKX2FUb4iHCTOMjpAOJxOBmIabip4WjY8CfY0BYAF6CLJ+VYhydKy3lhYGBAWDF4AFC6SZJHBYUTJWUM3ORtE0WdTX2Nna29zdQyLeKyEAOw==';
$set['image prev'] = 'R0lGODlhOQAcAMQXAO7u7uDg4Nra2s/Pz9PT0/z8/NbW1vj4+PX19efn5/Hx8d3d3evr6zMzM+Tk5GZmZhEREaqqqoiIiERERMzMzAAAAP///////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAABcALAAAAAA5ABwAAAXBoCWOZGmeaKpa1+q+cCzPdG3feK7vfO//wBIgqKM0hkSbpFJBJmWACbP5lEUgU2opQKBQDAiLYGGgHBRdiqNAUYgGidojy3SOuIWCgSAeIBAHFAwWCAMMAQEWCgMFNA10dSYBAiIAZmMiCV6bCYUFDg42c3R2IpOVFAUCiRaaJgIAAwc3V1mlFlwWegZirIGJCguVBMI4UVO3AQNeBrOrIwzLFHEiBG46S1okp1UqRsmU3Sq34uXm5+jp6uvs7TMXIQA7';
$set['image loading'] = eee;
$set['image overlay'] = 'R0lGODlhIAAgAJEAAAAAADMzMyEhIQAAACH5BAQUAP8ALAAAAAAgACAAAAJvTACGmtfrGBMCUVvB1Xn7DIXPKEUmhnLptwql+JKnSrN1hyPwHPeODczdfLviKNhK0oxEmQh5U1Ka1Bn0KmTytk8htlXVdqXess6JDkfXWLX6y86muXOyfUh3/8xxpbiOBteWRzjWd7jxp3cnKFAAADs=';
// GET CONFIG
$config = array();
$config['Author'] = '';
$config['Gallery Title'] = 'designs';
$config['Thumbnail Cropped'] = 'on';
$config['Thumbnail Quality'] = 80;
$config['Thumbnail Size'] = 'normal';
$config['Thumbnail Background'] = 'black';
$config['Image Size'] = '';
$config['Sort'] = 'normal';
$config['Embedded Script'] = 'off';
$config['jQuery Path'] = 'http://www.nowhereincoming.net/jquery.min.js]';
$config['Header Image'] = '';
$config['Background'] = '#191919';
$config['Footer Color'] = '#191919';
$config['Custom CSS'] = '';
$config['Custom HTML'] = '';
$config['Home Page'] = '';
$config['Contact'] = '';
$config['Imprint'] = '';
$config['Images Dir'] = '';
$config['Images List'] = '';
$config['Exclude Images'] = '';
// SET CONFIG
if(is_file($set['config file']) && is_readable($set['config file'])) {
// Get config from Config File
$set['config file contents'] = file_get_contents($set['config file']);
preg_match_all("/\[(.*):(.*)\]/U", $set['config file contents'], $set['config file variables']);
foreach($set['config file variables'][1] as $position => $variable) if(!empty($variable))
$config[trim($variable)] = isset($set['config file variables'][2][$position]) ? trim($set['config file variables'][2][$position]) : '';
} elseif(is_writeable($set['script dir'])) {
// Create Config File if not exists
$set['open config file'] = fopen($set['config file'], 'w');
foreach($config as $variable => $value) fwrite($set['open config file'], '[' . $variable . ': ' . $value . ']' . "\r\n");
}
// FUNCTIONS
function p_encodeEmail($string) {
$emails = array();
preg_match_all('/\w[-._\w]*\w@\w[-._\w]*\w\.\w{2,6}/i', $string, $emails);
foreach((array) $emails[0] as $email) {
$encoded_string = '';
$arrCharacters = str_split($email);
foreach ($arrCharacters as $strCharacter)
$encoded_string .= sprintf('%s;', ord($strCharacter));
$string = str_replace($email, $encoded_string, $string);
}
return str_replace('mailto:', 'mailto:', $string);
}
function p_addHTTP($url) {
return !empty($url) && substr($url, 0, 7) != 'http://' ? 'http://' . $url : $url;
}
function p_getThumbnailSize($size) {
switch($size) {
case 'small' : $size = 90; break;
case 'normal' : default : $size = 150; break;
case 'large' : $size = 225; break;
}
return $size;
}
function p_html2rgb($color) {
if($color[0] == '#') $color = substr($color, 1);
if(strlen($color) == 6) list($r, $g, $b) = array($color[0] . $color[1], $color[2] . $color[3], $color[4] . $color[5]);
elseif(strlen($color) == 3) list($r, $g, $b) = array($color[0] . $color[0], $color[1] . $color[1], $color[2] . $color[2]);
else return false;
$r = hexdec($r); $g = hexdec($g); $b = hexdec($b);
return array($r, $g, $b);
}
function p_message($message) {
if(!defined('p_error')) define('p_error', $message);
}
function p_emptyCache($silent = false) {
global $set;
if(is_dir($set['cache dir'])) {
if(is_readable($set['cache dir'])) {
$cache_open = opendir($set['cache dir']);
while($item = readdir($cache_open)) if(is_file($set['cache dir'] . $item)) if(is_writeable($set['cache dir'] . $item))
unlink($set['cache dir'] . $item);
elseif($silent == true) p_message('One or more files could not be deleted. It seems that these files are write protected. Please try to change file permissions via FTP.');
} elseif($silent == true)
p_message('The cache directory is not readable. Please try to change directory permissions via FTP.');
if(is_writeable($set['cache dir'])) rmdir($set['cache dir']);
elseif($silent == true) p_message('The cache directory is write protected. Please try to change directory permissions via FTP.');
}
}
function p_getMemoryLimit() {
$memory_limit = ini_get('memory_limit');
if(is_numeric($memory_limit)) {
return $value;
} else {
$memory_limit_length = strlen($memory_limit);
$qty = substr($memory_limit, 0, $memory_limit_length - 1);
$unit = strtolower(substr($memory_limit, $memory_limit_length - 1));
switch($unit) {
case 'k': $qty *= 1024; break;
case 'm': $qty *= 1048576; break;
case 'g': $qty *= 1073741824; break;
}
return $qty;
}
}
// DATA CHECK
// PHP
if(phpversion() < 4) p_message('System error:: eee ' . phpversion());
if(!extension_loaded('gd')) p_message('System error:eee');
// Images Dir
$config['Images Dir'] = empty($config['Images Dir']) ? $set['script dir'] : trim($config['Images Dir'], '/') . '/';
if(!is_dir($config['Images Dir'])) p_message('Image directory ' . $config['Images Dir'] . ' cannot be found. Please check your configuration.');
// Convert Contact
$config['Contact'] = strpos($config['Contact'], '@') === false
? p_addHTTP($config['Contact'])
: p_encodeEmail('mailto:' . $config['Contact']);
// Validate URL's
$config['Home Page'] = p_addHTTP($config['Home Page']);
$config['Imprint'] = p_addHTTP($config['Imprint']);
// Exlude Images
$set['exclude images'] = array(
$config['Header Image']
);
$set['exclude images list'] = explode(',', $config['Exclude Images']);
foreach($set['exclude images list'] as $item) $set['exclude images'][] = trim($item);
// Thumbnail Background Color
if(isset($set['color names'][strtolower($config['Thumbnail Background'])])) $config['Thumbnail Background'] = $set['color names'][strtolower($config['Thumbnail Background'])];
$config['Thumbnail Background'] = p_html2rgb($config['Thumbnail Background']) ? p_html2rgb($config['Thumbnail Background']) : array(0, 0, 0);
// Custom HTML
if(!empty($config['Custom HTML']) && is_file($config['Custom HTML'])) $config['Custom HTML'] = file_get_contents($config['Custom HTML']);
// OUTPUT
// Thumbnail
if(isset($_GET['thumbnail']) && is_file($_GET['thumbnail'])) {
$thumbnail = array();
$thumbnail['image data'] = getimagesize($_GET['thumbnail']);
$types = array(1 => 'gif', 'jpeg', 'png', 'swf', 'psd', 'wbmp');
$thumbnail['resized file name'] = substr($_GET['thumbnail'], strrpos($_GET['thumbnail'], '/') + 1);
$thumbnail['resized file name'] = substr($thumbnail['resized file name'], 0, strrpos($thumbnail['resized file name'], '.')) . '.' . $types[$thumbnail['image data'][2]];
$thumbnail['resized width'] = p_getThumbnailSize($config['Thumbnail Size']);
$thumbnail['resized height'] = p_getThumbnailSize($config['Thumbnail Size']);
if($config['Thumbnail Cropped'] == 'on') {
if($thumbnail['image data'][0] > $thumbnail['image data'][1]) $thumbnail['resized width'] = floor(p_getThumbnailSize($config['Thumbnail Size']) * $thumbnail['image data'][0] / $thumbnail['image data'][1]);
else $thumbnail['resized height'] = floor(p_getThumbnailSize($config['Thumbnail Size']) * $thumbnail['image data'][1] / $thumbnail['image data'][0]);
} else {
if($thumbnail['image data'][0] > $thumbnail['image data'][1]) $thumbnail['resized height'] = floor(p_getThumbnailSize($config['Thumbnail Size']) * $thumbnail['image data'][1] / $thumbnail['image data'][0]);
else $thumbnail['resized width'] = floor(p_getThumbnailSize($config['Thumbnail Size']) * $thumbnail['image data'][0] / $thumbnail['image data'][1]);
}
header('content-type: image/' . $types[$thumbnail['image data'][2]]);
if(!is_file($set['cache dir'] . $thumbnail['resized file name'])) {
if(filesize($_GET['thumbnail']) > p_getMemoryLimit() && exif_thumbnail($_GET['thumbnail']) == false) {
$thumbnail['exif image'] = exif_thumbnail($_GET['thumbnail'], $thumbnail['image data'][0], $thumbnail['image data'][1], $thumbnail['image data'][2]);
$thumbnail['original image'] = imagecreatefromstring($thumbnail['exif image']);
} else {
$thumbnail['original image'] = call_user_func('imagecreatefrom' . $types[$thumbnail['image data'][2]], $_GET['thumbnail']);
}
$thumbnail['resized image'] = imagecreatetruecolor(p_getThumbnailSize($config['Thumbnail Size']), p_getThumbnailSize($config['Thumbnail Size']));
imagecopyresampled($thumbnail['resized image'], $thumbnail['original image'], 0, 0, 0, 0, $thumbnail['resized width'], $thumbnail['resized height'], $thumbnail['image data'][0], $thumbnail['image data'][1]);
if($config['Thumbnail Cropped'] == 'on') {
$thumbnail['thumbnail image'] = $thumbnail['resized image'];
} else {
$thumbnail['thumbnail image'] = imagecreatetruecolor(p_getThumbnailSize($config['Thumbnail Size']), p_getThumbnailSize($config['Thumbnail Size']));
$background_color = imagecolorallocate($thumbnail['thumbnail image'], $config['Thumbnail Background'][0], $config['Thumbnail Background'][1], $config['Thumbnail Background'][2]);
imagefill($thumbnail['thumbnail image'], 0, 0, $background_color);
imagecopymerge($thumbnail['thumbnail image'], $thumbnail['resized image'], (p_getThumbnailSize($config['Thumbnail Size']) - $thumbnail['resized width']) / 2, (p_getThumbnailSize($config['Thumbnail Size']) - $thumbnail['resized height']) / 2, 0, 0, $thumbnail['resized width'], $thumbnail['resized height'], 100);
}
if($types[$thumbnail['image data'][2]] != 'jpeg') $config['Thumbnail Quality'] = '';
if(is_writeable($set['cache dir'])) call_user_func('image' . $types[$thumbnail['image data'][2]], $thumbnail['thumbnail image'], $set['cache dir'] . $thumbnail['resized file name'], $config['Thumbnail Quality']);
call_user_func('image' . $types[$thumbnail['image data'][2]], $thumbnail['thumbnail image'], false, $config['Thumbnail Quality']);
imagedestroy($thumbnail['original image']);
imagedestroy($thumbnail['resized image']);
imagedestroy($thumbnail['thumbnail image']);
} else
readfile($set['cache dir'] . $thumbnail['resized file name']);
exit();
}
// Resized image
if(isset($_GET['image']) && is_file($_GET['image'])) {
$image['image data'] = getimagesize($_GET['image']);
$types = array(1 => 'gif', 'jpeg', 'png', 'swf', 'psd', 'wbmp');
header('content-type: image/' . $types[$image['image data'][2]]);
$image['resized file name'] = substr($_GET['image'], strrpos($_GET['image'], '/') + 1);
$image['resized file name'] = substr($image['resized file name'], 0, strrpos($image['resized file name'], '.')) . '_resized' . '.' . $types[$image['image data'][2]];
if(empty($config['Image Size'])) $config['Image Size'] = $set['fallback image size'];
$image['resize'] = ($image['image data'][0] > $config['Image Size'] || $image['image data'][1] > $config['Image Size']) ? 1 : 0;
if($image['resize'] == 1 && !is_file($set['cache dir'] . $image['resized file name'])) {
$image['resized width'] = $config['Image Size'];
$image['resized height'] = $config['Image Size'];
if($image['image data'][0] > $image['image data'][1]) $image['resized height'] = floor($config['Image Size'] * $image['image data'][1] / $image['image data'][0]);
else $image['resized width'] = floor($config['Image Size'] * $image['image data'][0] / $image['image data'][1]);
$image['original'] = call_user_func('imagecreatefrom' . $types[$image['image data'][2]], $_GET['image']);
$image['resized'] = imagecreatetruecolor($image['resized width'], $image['resized height']);
imagecopyresampled($image['resized'], $image['original'], 0, 0, 0, 0, $image['resized width'], $image['resized height'], $image['image data'][0], $image['image data'][1]);
if(is_writeable($set['cache dir'])) call_user_func('image' . $types[$image['image data'][2]], $image['resized'], $set['cache dir'] . $image['resized file name'], 90);
call_user_func('image' . $types[$image['image data'][2]], $image['resized'], false, 90);
imagedestroy($image['original']);
imagedestroy($image['resized']);
} else
readfile($image['resize'] == 1 ? $set['cache dir'] . $image['resized file name'] : $_GET['image']);
exit();
}
// Layout files
if(isset($_GET['symbol'])) {
header('content-type: image/gif');
$set['symbol name'] = 'image ' . $_GET['symbol'];
if(isset($set[$set['symbol name']])) echo base64_decode($set[$set['symbol name']]);
exit();
}
// CACHE
if(is_dir($set['cache dir']) && is_file($set['config file']) && filemtime($set['cache dir']) < filemtime($set['config file'])) p_emptyCache(true);
if(!is_dir($set['cache dir']) && is_writeable($config['Images Dir'])) mkdir($set['cache dir'], 0777);
// IMAGE LIST
// Get images
if(empty($config['Images List'])) {
// From dir
$set['images dir open'] = opendir($config['Images Dir']);
$images = array();
while($item = readdir($set['images dir open'])) {
if(is_file($config['Images Dir'] . $item) && !in_array($item, $set['exclude images'])) {
$imagedata = getimagesize($config['Images Dir'] . $item);
if($imagedata[2] == 1 || $imagedata[2] == 2 || $imagedata[2] == 3) $images[] = $item;
}
}
closedir($set['images dir open']);
} else {
// From list
if(!stristr($config['Images List'], ',') && !is_file($config['Images List'])) {
p_message('Your image list respectively a file with name ' . $config['Images List'] . ' cannot be found.');
$config['Images List'] = '';
}
if(stristr($config['Images List'], '.txt'))
$config['Images List'] = is_file($config['Images List']) ? file_get_contents($config['Images List']) : '';
$images = empty($config['Images List']) ? array() : explode(',', $config['Images List']);
for($i = 0; $i < count($images); $i++) $images[$i] = trim($images[$i]);
if(count($images) == 0) p_message('No images found. Your file list is empty.');
}
// Sort images
switch($config['Sort']) {
case 'normal' : sort($images); break;
case 'reverse' : rsort($images); break;
case 'shuffle' : shuffle($images); break;
}
// Get number of existing files
for($i = 0; $i < count($images); $i++) if(is_file($config['Images Dir'] . $images[$i])) break;
if($i == count($images)) {
p_message('No images found. The specified file(s) in Images List cannot be found.');
$images = array();
}
// Get number of images
$number_of_images = count($images);
if($number_of_images == 0) p_message('No images found. Put some images in this folder or use the [Images List: ] tag in ' . $set['config file'] . ' for a custom list (comma separated).');
// UNINSTALL
if(basename($_SERVER['PHP_SELF']) == 'uninstall.php') {
$images = array();
$number_of_images = 0;
p_emptyCache(false);
if(is_file($set['config file']) && is_writeable($set['config file'])) unlink($set['config file']);
if(!is_dir($set['cache dir']) && !is_file($set['config file'])) p_message('Uninstall report: The cache directory and the config file were deleted successfully. You can now delete this file via FTP.');
if(!is_dir($set['cache dir']) && is_file($set['config file'])) p_message('Uninstall report: The cache directory was deleted successfully. You can now delete this and all related files via FTP.');
}
// GALLERY
// Send header
if($config['Embedded Script'] == 'off' || headers_sent() == false) header('content-type: text/html; charset=utf-8');
?>
nowhere incoming designs.
|
| TM and ©
1999-2013 darkdoomer. nowhere incoming designs. all rights
reserved. | | | | |
|