| Revision 997,
1.1 KB
checked in by strat.cristian@…, 3 years ago
(diff) |
|
Log remote IP and X-Forwarded-For header on job submit, textblock create/edit, and attachment upload. For privacy considerations, IP addresses are only displayed to admins and helpers.
- Contains database migration script.
- Adds new simplified security action. (sensitive-info)
|
-
Property svn:executable set to
*
|
| Line | |
|---|
| 1 | #! /usr/bin/env php |
|---|
| 2 | <?php |
|---|
| 3 | |
|---|
| 4 | // Adds a `remote_ip_info` field to the following database tables: |
|---|
| 5 | // file, job, ia_textblock, ia_textblock_revision |
|---|
| 6 | |
|---|
| 7 | require_once(dirname($argv[0]) . "/utilities.php"); |
|---|
| 8 | |
|---|
| 9 | function has_remote_ip_info($table) { |
|---|
| 10 | $cols = db_fetch_all("DESCRIBE `{$table}`"); |
|---|
| 11 | log_assert($cols); |
|---|
| 12 | foreach ($cols as $column) { |
|---|
| 13 | if ('remote_ip_info' == strtolower($column['Field'])) { |
|---|
| 14 | return true; |
|---|
| 15 | } |
|---|
| 16 | } |
|---|
| 17 | return false; |
|---|
| 18 | } |
|---|
| 19 | |
|---|
| 20 | function add_remote_ip_info($table) { |
|---|
| 21 | db_query("ALTER TABLE `{$table}` ADD `remote_ip_info` VARCHAR( 128 ) NULL |
|---|
| 22 | COMMENT 'IP address of the user who created this entry.'"); |
|---|
| 23 | db_query("ALTER TABLE `{$table}` ADD INDEX ( `remote_ip_info` )"); |
|---|
| 24 | } |
|---|
| 25 | |
|---|
| 26 | db_connect(); |
|---|
| 27 | $tables = array('ia_file', 'ia_job', 'ia_textblock', |
|---|
| 28 | 'ia_textblock_revision'); |
|---|
| 29 | foreach ($tables as $table) { |
|---|
| 30 | if (!has_remote_ip_info($table)) { |
|---|
| 31 | log_print("Adding remote_ip_info for table {$table}"); |
|---|
| 32 | add_remote_ip_info($table); |
|---|
| 33 | } else { |
|---|
| 34 | log_print("Skipping {$table}"); |
|---|
| 35 | } |
|---|
| 36 | } |
|---|
| 37 | log_print("Done"); |
|---|
| 38 | |
|---|
| 39 | ?> |
|---|
Note: See
TracBrowser
for help on using the repository browser.