$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)) { $candidate = $matches[1]; if ($candidate < $today && file_exists("{$folder}/{$candidate}-abbrevs.xml.gz") && file_exists("{$folder}/{$candidate}-definitions.xml.gz") && file_exists("{$folder}/{$candidate}-inflections.xml.gz") && file_exists("{$folder}/{$candidate}-ldm.xml.gz") && file_exists("{$folder}/{$candidate}-lexems.xml.gz") && file_exists("{$folder}/{$candidate}-sources.xml.gz")) { return $candidate; }
$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) { $matches = array(); if (preg_match(":^{$folder}/(\\d\\d\\d\\d-\\d\\d-\\d\\d)-[a-z]+.xml.gz:", $file, $matches)) { $date = $matches[1]; if ($date < $today) { if (array_key_exists($date, $map)) {