| Revision 907,
1022 bytes
checked in by bogdanpasoi@…, 4 years ago
(diff) |
|
Cleaned up scripts folder.
|
-
Property svn:executable set to
*
|
| Line | |
|---|
| 1 | #! /usr/bin/env php |
|---|
| 2 | <?php |
|---|
| 3 | |
|---|
| 4 | require_once(dirname($argv[0]) . "/utilities.php"); |
|---|
| 5 | require_once(IA_ROOT_DIR."common/db/attachment.php"); |
|---|
| 6 | |
|---|
| 7 | db_connect(); |
|---|
| 8 | $fixed = $errors = 0; |
|---|
| 9 | $query = "SELECT * FROM ia_file;"; |
|---|
| 10 | $attachments = db_fetch_all($query); |
|---|
| 11 | |
|---|
| 12 | log_print("There are ".count($attachments)." attachments in the database..."); |
|---|
| 13 | foreach ($attachments as $attach) { |
|---|
| 14 | log_print("Checking {$attach['page']}/{$attach['name']}"); |
|---|
| 15 | $name = attachment_get_filepath($attach); |
|---|
| 16 | if (!file_exists($name)) { |
|---|
| 17 | log_warn("File $name doens't exist!"); |
|---|
| 18 | continue; |
|---|
| 19 | } |
|---|
| 20 | $true_size = filesize($name); |
|---|
| 21 | $db_size = $attach['size']; |
|---|
| 22 | if ($db_size != $true_size) { |
|---|
| 23 | log_print("Fixing {$attach['page']}/{$attach['name']} $db_size != $true_size"); |
|---|
| 24 | $query = sprintf("UPDATE ia_file SET size = %s WHERE id = %s", |
|---|
| 25 | $true_size, $attach['id']); |
|---|
| 26 | db_query($query); |
|---|
| 27 | log_assert(db_affected_rows() == 1); |
|---|
| 28 | $fixed++; |
|---|
| 29 | } |
|---|
| 30 | } |
|---|
| 31 | |
|---|
| 32 | log_print("Fixed ".$fixed." attachments!"); |
|---|
| 33 | |
|---|
| 34 | ?> |
|---|
Note: See
TracBrowser
for help on using the repository browser.