forked from OPSnet/Gazelle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupload-wiki.php
33 lines (25 loc) · 985 Bytes
/
upload-wiki.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
29
30
31
32
33
<?php
/* A script to import the old WhatCD wiki articles from the 10th birthday release */
require_once(__DIR__ . '/../lib/bootstrap.php');
$in = fopen($argv[1], 'r');
if ($in === false) {
exit(1);
}
$row = (string)fgets($in);
[, $ID] = explode(':', str_replace(["\n", "\r"], '', (string)fgets($in)));
[, $read] = explode(':', str_replace(["\n", "\r"], '', (string)fgets($in)));
[, $edit] = explode(':', str_replace(["\n", "\r"], '', (string)fgets($in)));
[, $date] = explode(':', str_replace(["\n", "\r"], '', (string)fgets($in)), 2);
[, $title] = explode(':', str_replace(["\n", "\r"], '', (string)fgets($in)), 2);
[, $body] = explode(':', (string)fgets($in));
$title = '[WHAT.CD] ' . trim($title);
$body = trim($body);
echo "$title\n";
while (($row = fgets($in))) {
$body .= $row;
}
Gazelle\DB::DB()->prepared_query('
INSERT INTO wiki_articles (Title, Body, MinClassRead, MinClassEdit, Date, Author)
VALUES (?, ?, 800, 800, now(), 2)
', $title, $body
);