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; } } }
$messages[$date] = sprintf("Definiția '%s' are imaginea asociată '%s', dar fișierul nu există", $def->lexicon, $wotds[0]->image); continue; } if ($firstProblem == $d) { $firstProblem++; } } if ($messages) { switch ($firstProblem) { case 0: $subject = 'ACUM'; break; case 1: $subject = 'ASTĂZI'; break; case 2: $subject = 'cel târziu mâine'; break; default: $subject = sprintf("în %s zile", $firstProblem - 1); } $subject = 'Cuvântul zilei: acțiune necesară ' . $subject; smarty_assign('numDays', NUM_DAYS); smarty_assign('messages', $messages); $body = smarty_fetch('email/checkWotd.ihtml'); if ($sendEmail) { mail($MAIL_TO, $subject, $body, implode("\n", $MAIL_HEADERS)); } else { print "Subiect: {$subject}\n\n{$body}\n"; } }
$provider = util_getRequestParameter('provider'); // Display a banner for this provider $go = util_getRequestParameter('go'); // Track a click and redirect to this provider $clickurl = util_getRequestParameter('clickurl'); // Sent to us by OpenX; when displaying a banner, we have to link to this URL if ($go) { $provider = $go; $go = true; } require_once "../phplib/ads/{$provider}/{$provider}AdsModule.php"; if ($provider == 'diverta') { $bookId = util_getRequestParameter('bookId'); $book = DivertaBook::get_by_id($bookId); if (!$book) { exit; } if ($go) { $book->clicks++; $book->save(); util_redirect($book->url); } $book->impressions++; $book->save(); smarty_assign('book', $book); smarty_assign('hasImage', file_exists(util_getRootPath() . "wwwbase/img/diverta/thumb/{$book->sku}.jpg")); } smarty_assign('clickurl', str_replace('__', '&', $clickurl)); $output = smarty_fetch("ads/{$provider}.ihtml"); $output = addslashes(str_replace("\n", ' ', $output)); print "document.write(\"{$output}\");";
$type = util_getRequestParameter('t'); // RSS stuff - could be separated from the rest // TODO optimize & factorize if ($type == 'rss') { $words = WordOfTheDay::getRSSWotD(); $results = array(); foreach ($words as $w) { $item = array(); $ts = strtotime($w->displayDate); $defId = WordOfTheDayRel::getRefId($w->id); $def = Model::factory('Definition')->where('id', $defId)->where('status', ST_ACTIVE)->find_one(); smarty_assign('def', $def); smarty_assign('imageUrl', $w->getImageUrl()); smarty_assign('fullServerUrl', util_getFullServerUrl()); $item['title'] = $def->lexicon; $item['description'] = smarty_fetch('common/bits/wotdRssItem.ihtml'); $item['pubDate'] = date('D, d M Y H:i:s', $ts) . ' EEST'; $item['link'] = util_getFullServerUrl() . 'cuvantul-zilei/' . date('Y/m/d', $ts); $results[] = $item; } header("Content-type: text/xml"); smarty_assign('rss_title', 'Cuvântul zilei'); smarty_assign('rss_link', 'http://' . $_SERVER['HTTP_HOST'] . '/cuvantul-zilei/'); smarty_assign('rss_description', 'Doza zilnică de cuvinte propuse de DEXonline!'); smarty_assign('rss_pubDate', date('D, d M Y H:i:s') . ' EEST'); smarty_assign('results', $results); smarty_displayWithoutSkin('common/rss.ixml'); exit; } $today = date('Y-m-d', time()); $timestamp = $date ? strtotime($date) : time();
function dumpLexems($query, $fileName, $message) { log_scriptLog($message); $results = db_execute($query); $file = gzopen($fileName, 'wb9'); gzwrite($file, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); gzwrite($file, "<Lexems>\n"); foreach ($results as $row) { $lexem = Model::factory('Lexem')->create($row); smarty_assign('lexem', $lexem); smarty_assign('ifs', InflectedForm::loadByLexemId($lexem->id)); gzwrite($file, smarty_fetch('xmldump/lexem.ihtml')); } gzwrite($file, "</Lexems>\n"); gzclose($file); }
$identity = util_getRequestParameter('identity'); $email = util_getRequestParameter('email'); smarty_assign('identity', $identity); smarty_assign('email', $email); smarty_assign('page_title', 'Parolă uitată'); smarty_assign('suggestHiddenSearchForm', true); if (!$submitButton) { smarty_displayCommonPageWithSkin('auth/parola-uitata.ihtml'); } else { if (!$email) { FlashMessage::add('Trebuie să introduceți o adresă de e-mail.'); } else { $user = User::get_by_email($email); if ($user) { log_userLog("Password recovery requested for {$email} from " . $_SERVER['REMOTE_ADDR']); // Create the token $pt = Model::factory('PasswordToken')->create(); $pt->userId = $user->id; $pt->token = util_randomCapitalLetterString(20); $pt->save(); // Send email smarty_assign('homePage', util_getFullServerUrl()); smarty_assign('token', $pt->token); $body = smarty_fetch('email/resetPassword.ihtml'); $ourEmail = pref_getContactEmail(); $result = mail($email, "Schimbarea parolei pentru DEX online", $body, "From: DEX online <{$ourEmail}>\r\nReply-To: {$ourEmail}"); // Display a confirmation even for incorrect addresses. smarty_displayCommonPageWithSkin('auth/passwordRecoveryEmailSent.ihtml'); } } }