<?php require_once "../../phplib/util.php"; $result = logged_query("select * from words"); $count = 0; while ($row = mysql_fetch_assoc($result)) { $def = $row['def']; // echo "DEF: [$def]\n"; $def = text_internalizeDefinition($def); // echo "INT: [$def]\n"; $htmlDef = text_htmlize($def); // echo "HTM: [$htmlDef]\n"; $dname = text_internalizeDname($row['dname']); // echo "DNM: [$dname]\n"; // TODO: Internalize the dname too, fix dname search logged_query("update words set def = '" . addslashes($def) . "', " . "htmlDef = '" . addslashes($htmlDef) . "', " . "dname = '" . addslashes($dname) . "' " . "where counter = " . $row['counter']); $count++; if ($count % 1000 == 0) { echo "Processed {$count} definitions.\n"; } } echo "Done! Processed {$count} definitions.\n";
<?php // Fix the rough guide entries entered by schemaChange.sql. Those were taken // directly from the static HTML page. require_once "../../phplib/util.php"; $result = mysql_query("select * from GuideEntry"); $now = time(); while ($row = mysql_fetch_assoc($result)) { $id = $row['Id']; $correct = $row['Correct']; $wrong = $row['Wrong']; $comments = $row['Comments']; $correct = text_internalizeDefinition($correct); $wrong = text_internalizeDefinition($wrong); $comments = text_internalizeDefinition($comments); $correctHtml = text_htmlizeWithNewlines($correct, TRUE); $wrongHtml = text_htmlizeWithNewlines($wrong, TRUE); $commentsHtml = text_htmlizeWithNewlines($comments, TRUE); $correct = addslashes($correct); $correctHtml = addslashes($correctHtml); $wrong = addslashes($wrong); $wrongHtml = addslashes($wrongHtml); $comments = addslashes($comments); $commentsHtml = addslashes($commentsHtml); mysql_query("update GuideEntry set " . "Correct = '{$correct}', " . "CorrectHtml = '{$correctHtml}', " . "Wrong = '{$wrong}', " . "WrongHtml = '{$wrongHtml}', " . "Comments = '{$comments}', " . "CommentsHtml = '{$commentsHtml}', " . "Status = 0, " . "CreateDate = {$now}, " . "ModDate = {$now} " . "where Id = {$id}"); }
assert_options(ASSERT_BAIL, 1); debug_off(); list($verbose, $fileName) = parseArguments(); $radu = User::loadByNick('raduborza'); $mdnSrc = Source::load(21); $lines = file($fileName); $linesSeen = 0; $skipped = 0; $existing = loadExistingMapByLexicon(); //$existing = array(); print "Importing " . count($lines) . " lines\n"; foreach ($lines as $count => $line) { $line = trim($line); $line = str_replace(array(chr(0x96), chr(0x84), chr(0x93), chr(228), chr(0xd) . ' ()', chr(146), chr(246), chr(160), chr(180), chr(239), chr(251), chr(252), chr(244), chr(234), chr(224), chr(145), chr(235), chr(199), chr(241), chr(154), chr(230), chr(201), chr(196), chr(171), chr(187), chr(211), chr(167), chr(151), chr(249), chr(0xd) . chr(0) . ' ()', chr(214), '\\', chr(168), '<', ' I.@ ', ' S. M.@ ', ' S. F.@ ', ' S. N.@ ', ' VB.@ ', ' LOC@ ', '; -~A@ '), array('-', '"', '"', ':a', '', "'", ':o', '', "'", ':i', '^u', ':u', '^o', '^e', '`a', ',', ':e', ',c', '~n', '', ',T', "'E", ':A', '\\201c', '\\201e', "'O", '\\00a7', '\\00b6', '`u', '', ':O', ',', '\\00a8', '< ', '@ I. ', '@ $s. m.$ ', '@ $s. f.$ ', '@ $s. n.$ ', '@ $vb.$ ', '@ $loc.$ ', ', -~A@ '), $line); verify_alpha($line, $count); $line = text_internalizeDefinition($line); $d = new Definition(); $d->userId = $radu->id; $d->sourceId = $mdnSrc->id; $d->internalRep = $line; $d->htmlRep = text_htmlize($line); $d->lexicon = text_extractLexicon($d); $d->status = ST_ACTIVE; if (array_key_exists($d->lexicon, $existing)) { $skipped++; } else { // Handle some special cases where the lexicon needs to be adjusted. if (preg_match("/^@[^@,]+ /", $d->internalRep)) { $pos = strpos($d->internalRep, '@', 1); $text = substr($d->internalRep, 1, $pos - 1); $parts = split(' ', $text);