/* Checks if the supplied md5 file hash is currently recorded inside of the database, attached to a non-deleted post */
function check_md5($md5, $board) {
global $tc_db;
$results = $tc_db->GetAll("SELECT COUNT(*) FROM `".TC_DBPREFIX."posts_".mysql_real_escape_string($board)."` WHERE `imagemd5` = '".mysql_real_escape_string($md5)."' AND `IS_DELETED` = 0 LIMIT 1");
if ($results[0][0]>0) {
$results = $tc_db->GetAll("SELECT `id`, `threadid` FROM `".TC_DBPREFIX."posts_".mysql_real_escape_string($board)."` WHERE `imagemd5` = '".mysql_real_escape_string($md5)."' AND `IS_DELETED` = 0 LIMIT 1");
/* We want the first (and only) row */
$results = $results[0];
$real_threadid = ($results[1]==0) ? $results[0] : $results[1];
return array($real_threadid, $results[0]);
} else {
return false;
}
}