source: trunk/scripts/textblock-add-topic-id @ 1184

Revision 997, 2.4 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
3require_once(dirname($argv[0]) . "/utilities.php");
4require_once(IA_ROOT_DIR . "common/textblock.php");
5
6db_connect();
7db_query("ALTER TABLE `ia_textblock` ADD COLUMN `forum_topic` INT UNSIGNED DEFAULT NULL");
8db_query("ALTER TABLE `ia_textblock_revision` ADD COLUMN `forum_topic` INT UNSIGNED DEFAULT NULL");
9
10$blog_pages = db_fetch_all("SELECT * FROM `ia_blog_forum`");
11
12foreach ($blog_pages as $blog_page) {
13    $page = textblock_get_revision($blog_page["textblock"]);
14
15    $page["forum_topic"] = $blog_page["topic_id"];
16    $page["user_id"] = 1490;               // update as "bogdan2412" :)
17    $page["timestamp"] = null;
18
19    if (count(textblock_validate($page)) == 0) {
20        textblock_add_revision($page['name'], $page['title'], $page['text'],
21                               $page['user_id'], $page['security'],
22                               $page["forum_topic"], $page['timestamp'],
23                               $page['creation_timestamp'],
24                               getattr($page, 'remote_ip_info'));
25    } else {
26        log_error('Eroare la procesarea ia_blog_forum!');
27    }
28}
29
30db_query("DROP TABLE `ia_blog_forum`");
31
32
33$task_pages = db_fetch_all("SELECT `page_name` FROM `ia_task`");
34
35foreach ($task_pages as $task_page) {
36    $page = textblock_get_revision($task_page["page_name"]);
37
38    $pattern = '/==\ *smftopic\(\ *topic_id="\ *([0-9]*).*0*\ *"\ *\)\ *==/i';
39    if (preg_match($pattern, $page['text'], $matches)) {
40        $topic_id = $matches[1];
41
42        $page["text"] = preg_replace($pattern, "", $page["text"]);
43        $page["forum_topic"] = $topic_id;
44        $page["user_id"] = 1490;               // update as "bogdan2412" :)
45        $page["timestamp"] = null;
46
47        if (count(textblock_validate($page)) == 0) {
48            textblock_add_revision($page['name'], $page['title'], $page['text'],
49                                   $page['user_id'], $page['security'],
50                                   $page["forum_topic"], $page['timestamp'],
51                                   $page['creation_timestamp'],
52                                   getattr($page, 'remote_ip_info'));
53        } else {
54            log_error('Eroare la procesarea paginii ' . $page["name"] . '!');
55        }
56    } else {
57        if (stristr($page["text"], 'SmfTopic')) {
58            log_warn('Eroare de regexp pentru "'.$task['id'].'"!');
59        }
60        log_warn($page["name"] . " nu are nici un topic asociat");
61    }
62}
63
64?>
65
Note: See TracBrowser for help on using the repository browser.