Added a file hash in the database. Will be implemented later.
This commit is contained in:
parent
8849f5a2db
commit
44f3e91602
@ -43,6 +43,7 @@ CREATE TABLE IF NOT EXISTS `posts` (
|
|||||||
`fileheight` int(11) DEFAULT NULL,
|
`fileheight` int(11) DEFAULT NULL,
|
||||||
`filesize` int(11) DEFAULT NULL,
|
`filesize` int(11) DEFAULT NULL,
|
||||||
`filename` varchar(30) DEFAULT NULL,
|
`filename` varchar(30) DEFAULT NULL,
|
||||||
|
`filehash` varchar(32) DEFAULT NULL,
|
||||||
`password` varchar(20) DEFAULT NULL,
|
`password` varchar(20) DEFAULT NULL,
|
||||||
`ip` varchar(15) NOT NULL,
|
`ip` varchar(15) NOT NULL,
|
||||||
UNIQUE KEY `id` (`id`)
|
UNIQUE KEY `id` (`id`)
|
||||||
|
10
post.php
10
post.php
@ -116,6 +116,7 @@
|
|||||||
$post['width'] = $size[0];
|
$post['width'] = $size[0];
|
||||||
$post['height'] = $size[1];
|
$post['height'] = $size[1];
|
||||||
|
|
||||||
|
// Check if the image is valid
|
||||||
if($post['width'] < 1 || $post['height'] < 1) {
|
if($post['width'] < 1 || $post['height'] < 1) {
|
||||||
unlink($post['file']);
|
unlink($post['file']);
|
||||||
error(ERR_INVALIDIMG);
|
error(ERR_INVALIDIMG);
|
||||||
@ -126,7 +127,10 @@
|
|||||||
error(ERR_MAXSIZE);
|
error(ERR_MAXSIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$post['filehash'] = md5_file($post['file']);
|
||||||
$post['filesize'] = filesize($post['file']);
|
$post['filesize'] = filesize($post['file']);
|
||||||
|
|
||||||
|
// Create a thumbnail
|
||||||
$thumb = resize($post['extension'], $post['file'], $post['thumb'], THUMB_WIDTH, THUMB_HEIGHT);
|
$thumb = resize($post['extension'], $post['file'], $post['thumb'], THUMB_WIDTH, THUMB_HEIGHT);
|
||||||
$post['thumbwidth'] = $thumb['width'];
|
$post['thumbwidth'] = $thumb['width'];
|
||||||
$post['thumbheight'] = $thumb['height'];
|
$post['thumbheight'] = $thumb['height'];
|
||||||
@ -140,7 +144,7 @@
|
|||||||
|
|
||||||
if($OP) {
|
if($OP) {
|
||||||
mysql_query(
|
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' )",
|
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['subject'],
|
||||||
$post['email'],
|
$post['email'],
|
||||||
$post['name'],
|
$post['name'],
|
||||||
@ -156,12 +160,13 @@
|
|||||||
$post['height'],
|
$post['height'],
|
||||||
$post['filesize'],
|
$post['filesize'],
|
||||||
$post['filename'],
|
$post['filename'],
|
||||||
|
$post['filehash'],
|
||||||
$post['password'],
|
$post['password'],
|
||||||
mysql_real_escape_string($_SERVER['REMOTE_ADDR'])
|
mysql_real_escape_string($_SERVER['REMOTE_ADDR'])
|
||||||
), $sql) or error(mysql_error($sql));
|
), $sql) or error(mysql_error($sql));
|
||||||
} else {
|
} else {
|
||||||
mysql_query(
|
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' )",
|
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['thread'],
|
||||||
$post['subject'],
|
$post['subject'],
|
||||||
$post['email'],
|
$post['email'],
|
||||||
@ -178,6 +183,7 @@
|
|||||||
$post['has_file']?$post['height']:null,
|
$post['has_file']?$post['height']:null,
|
||||||
$post['has_file']?$post['filesize']:null,
|
$post['has_file']?$post['filesize']:null,
|
||||||
$post['has_file']?$post['filename']:null,
|
$post['has_file']?$post['filename']:null,
|
||||||
|
$post['has_file']?$post['filehash']:null,
|
||||||
$post['password'],
|
$post['password'],
|
||||||
mysql_real_escape_string($_SERVER['REMOTE_ADDR'])
|
mysql_real_escape_string($_SERVER['REMOTE_ADDR'])
|
||||||
), $sql) or error(mysql_error($sql));
|
), $sql) or error(mysql_error($sql));
|
||||||
|
BIN
src/error.png
Normal file
BIN
src/error.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.3 KiB |
BIN
src/ok.png
Normal file
BIN
src/ok.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
BIN
src/warning.png
Normal file
BIN
src/warning.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
Loading…
Reference in New Issue
Block a user