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