$sql = "SELECT e.extension, g.download_mode\n\tFROM " . EXTENSION_GROUPS_TABLE . " g, " . EXTENSIONS_TABLE . " e\n\tWHERE (g.allow_group = 1) AND (g.group_id = e.group_id)"; $result = $db->sql_query($sql); $rows = $db->sql_fetchrowset($result); $num_rows = $db->sql_numrows($result); for ($i = 0; $i < $num_rows; $i++) { $extension = strtolower(trim($rows[$i]['extension'])); $allowed_extensions[] = $extension; $download_mode[$extension] = $rows[$i]['download_mode']; } // disallowed ? if (!in_array($attachment['extension'], $allowed_extensions) && $user->data['user_level'] != ADMIN) { message_die(GENERAL_MESSAGE, sprintf($lang['Extension_disabled_after_posting'], $attachment['extension'])); } $download_mode = intval($download_mode[$attachment['extension']]); if ($thumbnail) { $thumb_exists = check_thumbnail($attachment, $upload_dir); if (!empty($thumb_exists)) { $attachment['physical_filename'] = get_physical_filename($attachment['physical_filename'], true); } else { $thumbnail = 0; } } // Update download count if (!$thumbnail) { update_attachments_stats($attachment['attach_id']); } // Determine the 'presenting'-method if ($download_mode == PHYSICAL_LINK) { $server_url = create_server_url(); if ($script_name[strlen($script_name)] != '/') { $script_name .= '/';
} echo '<br /><br />'; echo isset($lang['Sync_thumbnails']) ? $lang['Sync_thumbnails'] : 'Sync Thumbnails'; // Sync Thumbnails (if a thumbnail is no longer there, delete it) // Get all Posts/PM's with an image, go through all of them and make sure the Thumbnail exist. If it does not exist, unset the Thumbnail Flag $sql = "SELECT attach_id, physical_filename, thumbnail, extension, mimetype FROM " . ATTACHMENTS_DESC_TABLE . " WHERE extension IN('png', 'jpg', 'jpeg')"; $result = $db->sql_query($sql); echo '<br />'; $i = 0; while ($row = $db->sql_fetchrow($result)) { @flush(); echo '.'; if ($i % 50 == 0) { echo '<br />'; } $thumb_exists = check_thumbnail($row, $upload_dir); if (!empty($thumb_exists)) { $info .= sprintf($lang['Sync_thumbnail_recreated'], $row['physical_filename']) . '<br />'; $sql_thumbnail = 1; } else { $info .= sprintf($lang['Sync_thumbnail_resetted'], $row['physical_filename']) . '<br />'; $sql_thumbnail = 0; } $sql_update = "UPDATE " . ATTACHMENTS_DESC_TABLE . " SET thumbnail = " . $sql_thumbnail . " WHERE attach_id = " . (int) $row['attach_id']; $db->sql_query($sql_update); $i++; } $db->sql_freeresult($result); // Sync Thumbnails (make sure all non-existent thumbnails are deleted) - the other way around // Get all Posts/PM's with the Thumbnail Flag NOT set // Go through all of them and make sure the Thumbnail does NOT exist. If it does exist, delete it