1<?php
2
3require '../../../inc/utf8.php';
4
5$query =
6"SELECT tasks.md5, tasks.page, tasks.text
7 FROM tasks
8-- WHERE text like '%&%;%'";
9
10$sqlite = sqlite_open('../../../data/meta/do.sqlite');
11
12sqlite_exec($sqlite, 'BEGIN TRANSACTION');
13$res = sqlite_query($sqlite, $query);
14sqlite_num_rows($res);
15
16while ($row = sqlite_fetch_array($res)) {
17    $row['tasks.text'] = trim(html_entity_decode(strip_tags($row['tasks.text']), ENT_QUOTES, 'UTF-8'));
18    $md5 = md5(utf8_strtolower(preg_replace('/\s/', '', $row['tasks.text'])) .
19               $row['tasks.page']);
20    sqlite_exec($sqlite, 'UPDATE tasks SET text = \'' . sqlite_escape_string($row['tasks.text']) . '\', ' .
21                                  'md5 = \'' . $md5 . '\' WHERE md5 = \'' . $row['tasks.md5'] . '\'
22                                  AND page = \'' . $row['tasks.page'] . '\'');
23    sqlite_exec($sqlite, 'UPDATE task_status SET md5 = \'' . $md5 . '\' WHERE md5 = \'' . $row['tasks.md5'] . '\'
24                                  AND page = \'' . $row['tasks.page'] . '\'');
25}
26sqlite_exec($sqlite, 'COMMIT');
27
28sqlite_close($sqlite);
29