| Revision 966,
884 bytes
checked in by bogdan2412, 3 years ago
(diff) |
|
Some cache fixes. Added update-mimetypes script from live.
|
-
Property svn:executable set to
*
|
| Line | |
|---|
| 1 | #! /usr/bin/env php |
|---|
| 2 | <?php |
|---|
| 3 | require_once(dirname($argv[0]) . "/utilities.php"); |
|---|
| 4 | require_once(IA_ROOT_DIR . "common/attachment.php"); |
|---|
| 5 | |
|---|
| 6 | $verbose = getattr($argv, 1, false); |
|---|
| 7 | |
|---|
| 8 | db_connect(); |
|---|
| 9 | $files = db_fetch_all("SELECT `id`, `page`, `name`, `mime_type` FROM `ia_file`"); |
|---|
| 10 | |
|---|
| 11 | $nr = 0; |
|---|
| 12 | foreach ($files as $file) |
|---|
| 13 | { |
|---|
| 14 | $mime_type = get_mime_type(attachment_get_filepath($file)); |
|---|
| 15 | if ($mime_type != $file["mime_type"]) { |
|---|
| 16 | db_query("UPDATE `ia_file` |
|---|
| 17 | SET `mime_type` = " . db_quote($mime_type) . " |
|---|
| 18 | WHERE `id` = " . db_quote($file["id"])); |
|---|
| 19 | if ($verbose) { |
|---|
| 20 | log_print("Attachment {$file["id"]} - {$file["page"]}/{$file["name"]}: Changed mime_type from '{$file["mime_type"]}' to '{$mime_type}'"); |
|---|
| 21 | } |
|---|
| 22 | } |
|---|
| 23 | $nr++; |
|---|
| 24 | |
|---|
| 25 | if ($nr % 1000 == 0) { |
|---|
| 26 | log_print("Updated mime_types for " . $nr . " files so far."); |
|---|
| 27 | } |
|---|
| 28 | } |
|---|
| 29 | |
|---|
| 30 | ?> |
|---|
| 31 | |
|---|
Note: See
TracBrowser
for help on using the repository browser.