Example #1
0
<?php

require_once "../phplib/util.php";
$TODAY = date("Y-m-d");
$FOLDER = util_getRootPath() . '/wwwbase/download/xmldump';
$URL = 'http://dexonline.ro/download/xmldump';
if (count($_GET) == 0) {
    util_redirect("http://wiki.dexonline.ro/wiki/Update4Instructions");
}
$lastDump = getLastDumpDate($TODAY, $FOLDER);
smarty_assign('lastDump', $lastDump);
smarty_assign('url', $URL);
$lastClientUpdate = util_getRequestParameterWithDefault('last', '0');
if ($lastClientUpdate == '0') {
    // Dump the freshest full dump we have
    // TODO: return an error if there is no full dump
    smarty_assign('serveFullDump', true);
    $lastClientUpdate = $lastDump;
}
smarty_assign('diffs', getDiffsBetween($lastClientUpdate, $TODAY, $FOLDER));
header('Content-type: text/xml');
print smarty_fetch('common/update4.ihtml');
/**************************************************************************/
// Do not return a dump for today, in case it is still being built
function getLastDumpDate($today, $folder)
{
    $files = scandir($folder, 1);
    // descending
    foreach ($files as $file) {
        $matches = array();
        if (preg_match('/^(\\d\\d\\d\\d-\\d\\d-\\d\\d)-abbrevs.xml.gz$/', $file, $matches)) {
Example #2
0
<?php

require_once __DIR__ . '/../phplib/util.php';
$TODAY = date("Y-m-d");
$TODAY_TIMESTAMP = strtotime("{$TODAY} 00:00:00");
$REMOTE_FOLDER = 'download/xmldump';
$STATIC_FILES = file(Config::get('static.url') . 'fileList.txt');
$LAST_DUMP = getLastDumpDate($REMOTE_FOLDER);
$LAST_DUMP_TIMESTAMP = $LAST_DUMP ? strtotime("{$LAST_DUMP} 00:00:00") : null;
$USERS = getActiveUsers();
$FTP = new FtpUtil();
log_scriptLog("generating dump for {$TODAY}; previous dump is " . ($LAST_DUMP ? $LAST_DUMP : '-never-'));
if ($LAST_DUMP == $TODAY) {
    log_scriptLog("a dump already exists for {$TODAY}; aborting");
    die("a dump already exists for {$TODAY}; aborting\n");
}
dumpSources("{$REMOTE_FOLDER}/{$TODAY}-sources.xml.gz");
dumpInflections("{$REMOTE_FOLDER}/{$TODAY}-inflections.xml.gz");
dumpAbbrevs("{$REMOTE_FOLDER}/{$TODAY}-abbrevs.xml.gz");
dumpDefinitions("SELECT * FROM Definition WHERE sourceId IN (SELECT id FROM Source WHERE canDistribute) AND status = 0 AND modDate < {$TODAY_TIMESTAMP}", "{$REMOTE_FOLDER}/{$TODAY}-definitions.xml.gz", 'dumping definitions');
dumpLexems("SELECT * FROM Lexem where modDate < {$TODAY_TIMESTAMP}", "{$REMOTE_FOLDER}/{$TODAY}-lexems.xml.gz", 'dumping lexems and inflected forms');
dumpLdm("SELECT M.lexemId, M.definitionId FROM LexemDefinitionMap M, Definition D " . "WHERE D.id = M.definitionId AND D.sourceId in (SELECT id FROM Source WHERE canDistribute) " . "AND D.status = 0 AND M.modDate < {$TODAY_TIMESTAMP} ORDER BY M.lexemId, M.definitionId", "{$REMOTE_FOLDER}/{$TODAY}-ldm.xml.gz", 'dumping lexem-definition map');
if ($LAST_DUMP) {
    dumpDefinitions("SELECT * FROM Definition WHERE sourceId IN (SELECT id FROM Source WHERE canDistribute) " . "AND modDate >= {$LAST_DUMP_TIMESTAMP} AND modDate < {$TODAY_TIMESTAMP}", "{$REMOTE_FOLDER}/{$TODAY}-definitions-diff.xml.gz", 'dumping definitions diff');
    dumpLexems("SELECT * FROM Lexem where modDate >= {$LAST_DUMP_TIMESTAMP} AND modDate < {$TODAY_TIMESTAMP}", "{$REMOTE_FOLDER}/{$TODAY}-lexems-diff.xml.gz", 'dumping lexems and inflected forms diff');
    dumpLdmDiff("{$REMOTE_FOLDER}/{$LAST_DUMP}-ldm.xml.gz", "{$REMOTE_FOLDER}/{$TODAY}-ldm.xml.gz", "{$REMOTE_FOLDER}/{$TODAY}-ldm-diff.xml.gz");
}
removeOldDumps($REMOTE_FOLDER, $TODAY, $LAST_DUMP);
/**************************************************************************/
function getActiveUsers()
{
Example #3
0
<?php

require_once "../phplib/util.php";
$TODAY = date("Y-m-d");
$REMOTE_FOLDER = 'download/xmldump';
$STATIC_FILES = file(Config::get('static.url') . 'fileList.txt');
$URL = Config::get('static.url') . 'download/xmldump';
if (count($_GET) == 0) {
    util_redirect("http://wiki.dexonline.ro/wiki/Protocol_de_exportare_a_datelor");
}
$lastDump = getLastDumpDate($TODAY, $REMOTE_FOLDER);
SmartyWrap::assign('lastDump', $lastDump);
SmartyWrap::assign('url', $URL);
$lastClientUpdate = util_getRequestParameterWithDefault('last', '0');
if ($lastClientUpdate == '0') {
    // Dump the freshest full dump we have
    // TODO: return an error if there is no full dump
    SmartyWrap::assign('serveFullDump', true);
    $lastClientUpdate = $lastDump;
}
SmartyWrap::assign('diffs', getDiffsBetween($lastClientUpdate, $TODAY, $REMOTE_FOLDER));
header('Content-type: text/xml');
print SmartyWrap::fetch('update4.ihtml');
/**************************************************************************/
// Do not return a dump for today, in case it is still being built
function getLastDumpDate($today, $folder)
{
    global $STATIC_FILES;
    // Group existing files by date, excluding the diff files
    $map = array();
    foreach ($STATIC_FILES as $file) {
<?php

require_once "../phplib/util.php";
smarty_init();
$TODAY = date("Y-m-d");
$TODAY_TIMESTAMP = strtotime("{$TODAY} 00:00:00");
$FOLDER = util_getRootPath() . '/wwwbase/download/xmldump';
$LAST_DUMP = getLastDumpDate($FOLDER);
$LAST_DUMP_TIMESTAMP = $LAST_DUMP ? strtotime("{$LAST_DUMP} 00:00:00") : null;
$USERS = getActiveUsers();
log_scriptLog("generating dump for {$TODAY}; previous dump is " . ($LAST_DUMP ? $LAST_DUMP : '-never-'));
if ($LAST_DUMP == $TODAY) {
    log_scriptLog("a dump already exists for {$TODAY}; aborting");
    exit(1);
}
dumpSources("{$FOLDER}/{$TODAY}-sources.xml.gz");
dumpInflections("{$FOLDER}/{$TODAY}-inflections.xml.gz");
dumpAbbrevs("{$FOLDER}/{$TODAY}-abbrevs.xml.gz");
dumpDefinitions("SELECT * FROM Definition WHERE sourceId IN (SELECT id FROM Source WHERE canDistribute) AND status = 0 AND modDate < {$TODAY_TIMESTAMP}", "{$FOLDER}/{$TODAY}-definitions.xml.gz", 'dumping definitions');
dumpLexems("SELECT * FROM Lexem where modDate < {$TODAY_TIMESTAMP}", "{$FOLDER}/{$TODAY}-lexems.xml.gz", 'dumping lexems and inflected forms');
dumpLdm("SELECT M.lexemId, M.definitionId FROM LexemDefinitionMap M, Definition D " . "WHERE D.id = M.definitionId AND D.sourceId in (SELECT id FROM Source WHERE canDistribute) " . "AND D.status = 0 AND M.modDate < {$TODAY_TIMESTAMP} ORDER BY M.lexemId, M.definitionId", "{$FOLDER}/{$TODAY}-ldm.xml.gz", 'dumping lexem-definition map');
if ($LAST_DUMP) {
    dumpDefinitions("SELECT * FROM Definition WHERE sourceId IN (SELECT id FROM Source WHERE canDistribute) " . "AND modDate >= {$LAST_DUMP_TIMESTAMP} AND modDate < {$TODAY_TIMESTAMP}", "{$FOLDER}/{$TODAY}-definitions-diff.xml.gz", 'dumping definitions diff');
    dumpLexems("SELECT * FROM Lexem where modDate >= {$LAST_DUMP_TIMESTAMP} AND modDate < {$TODAY_TIMESTAMP}", "{$FOLDER}/{$TODAY}-lexems-diff.xml.gz", 'dumping lexems and inflected forms diff');
    dumpLdmDiff("{$FOLDER}/{$LAST_DUMP}-ldm.xml.gz", "{$FOLDER}/{$TODAY}-ldm.xml.gz", "{$FOLDER}/{$TODAY}-ldm-diff.xml.gz");
}
removeOldDumps($FOLDER, $TODAY, $LAST_DUMP);
/**************************************************************************/
function getActiveUsers()
{
    $results = db_execute("SELECT id, nick FROM User WHERE id IN (SELECT DISTINCT userId FROM Definition)");