ZIP support
This commit is contained in:
parent
2eddc7a4ee
commit
467ccdaf48
@ -40,7 +40,7 @@
|
||||
define('ERROR_NOMOVE', 'The server failed to handle your upload.');
|
||||
define('ERROR_FILEEXT', 'Unsupported image format.');
|
||||
define('ERR_INVALIDIMG','Invalid image.');
|
||||
define('ERR_FILSIZE', 'The file was too large.');
|
||||
define('ERR_FILESIZE', 'Maximum file size: %maxsz%<br>Your file\'s size: %sz%');
|
||||
define('ERR_MAXSIZE', 'The file was too big.');
|
||||
|
||||
// For resizing, max values
|
||||
@ -48,11 +48,15 @@
|
||||
define('THUMB_HEIGHT', 200);
|
||||
|
||||
// Maximum image upload size in bytes
|
||||
define('MAX_FILESIZE', 1048576); // 10MB
|
||||
define('MAX_FILESIZE', 6930209); // 10MB
|
||||
// Maximum image dimensions
|
||||
define('MAX_WIDTH', 10000);
|
||||
define('MAX_HEIGHT', MAX_WIDTH);
|
||||
|
||||
define('ALLOW_ZIP', true);
|
||||
define('ZIP_IMAGE', 'src/zip.png');
|
||||
|
||||
|
||||
/**
|
||||
Redraw the image using GD functions to strip any excess data (commonly ZIP archives)
|
||||
WARNING: Very beta. Currently strips animated GIFs too :(
|
||||
@ -63,7 +67,7 @@
|
||||
define('REDRAW_GIF', false);
|
||||
|
||||
// Display the aspect ratio in a post's file info
|
||||
define('SHOW_RATIO', false);
|
||||
define('SHOW_RATIO', true);
|
||||
|
||||
define('DIR_IMG', 'src/');
|
||||
define('DIR_THUMB', 'thumb/');
|
||||
@ -92,7 +96,7 @@
|
||||
|
||||
define('URL_MATCH', '/^' . (@$_SERVER['HTTPS']?'https':'http').':\/\/'.$_SERVER['HTTP_HOST'] . '(' . preg_quote(ROOT, '/') . '|' . preg_quote(ROOT, '/') . '' . preg_quote(FILE_INDEX, '/') . '|' . preg_quote(ROOT, '/') . '' . str_replace('%d', '\d+', preg_quote(FILE_PAGE, '/')) . ')$/');
|
||||
|
||||
if(!defined(IS_INSTALLATION)) {
|
||||
if(!defined('IS_INSTALLATION')) {
|
||||
if(!file_exists(DIR_IMG)) @mkdir(DIR_IMG) or error("Couldn't create " . DIR_IMG . ". Install manually.");
|
||||
if(!file_exists(DIR_THUMB)) @mkdir(DIR_THUMB) or error("Couldn't create " . DIR_IMG . ". Install manually.");
|
||||
if(!file_exists(DIR_RES)) @mkdir(DIR_RES) or error("Couldn't create " . DIR_IMG . ". Install manually.");
|
||||
|
@ -1,4 +1,18 @@
|
||||
<?php
|
||||
function sprintf3($str, $vars, $delim = '%') {
|
||||
$replaces = array();
|
||||
foreach($vars as $k => $v) {
|
||||
$replaces[$delim . $k . $delim] = $v;
|
||||
}
|
||||
return str_replace(array_keys($replaces),
|
||||
array_values($replaces), $str);
|
||||
}
|
||||
|
||||
function commaize($n) {
|
||||
$n = strval($n);
|
||||
return (intval($n) < 1000) ? $n : commaize(substr($n, 0, -3)) . ',' . substr($n, -3);
|
||||
}
|
||||
|
||||
function sql_open() {
|
||||
global $sql;
|
||||
$sql = @mysql_connect(MY_SERVER, MY_USER, MY_PASSWORD) or error('Database error.');
|
||||
@ -15,6 +29,58 @@
|
||||
}
|
||||
}
|
||||
|
||||
function post($post, $OP) {
|
||||
global $sql;
|
||||
if($OP) {
|
||||
mysql_query(
|
||||
sprintf("INSERT INTO `posts` VALUES ( NULL, NULL, '%s', '%s', '%s', '%s', '%s', '%d', '%d', '%s', '%d', '%d', '%s', '%d', '%d', '%d', '%s', '%s', '%s', '%s' )",
|
||||
$post['subject'],
|
||||
$post['email'],
|
||||
$post['name'],
|
||||
$post['trip'],
|
||||
$post['body'],
|
||||
time(),
|
||||
time(),
|
||||
$post['thumb'],
|
||||
$post['thumbwidth'],
|
||||
$post['thumbheight'],
|
||||
$post['file'],
|
||||
$post['width'],
|
||||
$post['height'],
|
||||
$post['filesize'],
|
||||
$post['filename'],
|
||||
$post['filehash'],
|
||||
$post['password'],
|
||||
mysql_real_escape_string($_SERVER['REMOTE_ADDR'])
|
||||
), $sql) or error(mysql_error($sql));
|
||||
return mysql_insert_id($sql);
|
||||
} else {
|
||||
mysql_query(
|
||||
sprintf("INSERT INTO `posts` VALUES ( NULL, '%d', '%s', '%s', '%s', '%s', '%s', '%d', '%d', '%s', '%d', '%d', '%s', '%d', '%d', '%d', '%s', '%s', '%s', '%s' )",
|
||||
$post['thread'],
|
||||
$post['subject'],
|
||||
$post['email'],
|
||||
$post['name'],
|
||||
$post['trip'],
|
||||
$post['body'],
|
||||
time(),
|
||||
time(),
|
||||
$post['has_file']?$post['thumb']:null,
|
||||
$post['has_file']?$post['thumbwidth']:null,
|
||||
$post['has_file']?$post['thumbheight']:null,
|
||||
$post['has_file']?$post['file']:null,
|
||||
$post['has_file']?$post['width']:null,
|
||||
$post['has_file']?$post['height']:null,
|
||||
$post['has_file']?$post['filesize']:null,
|
||||
$post['has_file']?$post['filename']:null,
|
||||
$post['has_file']?$post['filehash']:null,
|
||||
$post['password'],
|
||||
mysql_real_escape_string($_SERVER['REMOTE_ADDR'])
|
||||
), $sql) or error(mysql_error($sql));
|
||||
return mysql_insert_id($sql);
|
||||
}
|
||||
}
|
||||
|
||||
function index($page) {
|
||||
global $sql, $board;
|
||||
|
||||
|
BIN
src/zip.png
Executable file
BIN
src/zip.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 15 KiB |
Loading…
Reference in New Issue
Block a user