function session_logout() { log_userLog('Logging out, IP=' . $_SERVER['REMOTE_ADDR']); $cookieString = session_getCookieSetting('lll'); $cookie = Cookie::get_by_cookieString($cookieString); if ($cookie) { $cookie->delete(); } setcookie("prefs[lll]", NULL, time() - 3600, '/'); unset($_COOKIE['prefs']['lll']); session_kill(); util_redirect(util_getWwwRoot()); }
$similar = Definition::get_by_id($similarId); if ($ins) { $from = $def; $to = $similar; $fstart = $dstart; $flen = $dlen; $tstart = $sstart; $tlen = $slen; } else { $from = $similar; $to = $def; $fstart = $sstart; $flen = $slen; $tstart = $dstart; $tlen = $dlen; } // copy text from $from to $to $mid = substr($from->internalRep, $fstart, $flen); if (!$tlen) { if ($tstart >= strlen($to->internalRep)) { $mid = " {$mid}"; } else { $mid = "{$mid} "; } } $to->internalRep = substr($to->internalRep, 0, $tstart) . $mid . substr($to->internalRep, $tstart + $tlen); $to->internalRep = AdminStringUtil::internalizeDefinition($to->internalRep, $to->sourceId); $to->htmlRep = AdminStringUtil::htmlize($to->internalRep, $to->sourceId); $to->save(); util_redirect("definitionEdit.php?definitionId={$defId}");
foreach ($matches as $match) { LexemDefinitionMap::associate($match->id, $definition->id); log_userLog("Associating with lexem {$match->id} ({$match->form})"); } } else { // Create a new lexem. $lexem = Lexem::create($lexemName, 'T', '1', ''); $lexem->save(); $lexem->regenerateParadigm(); LexemDefinitionMap::associate($lexem->id, $definition->id); log_userLog("Created lexem {$lexem->id} ({$lexem->form})"); } } } FlashMessage::add('Definiția a fost trimisă. Un moderator o va examina în scurt timp. Vă mulțumim!', 'info'); util_redirect('contribuie'); } } else { smarty_assign('sourceId', session_getDefaultContribSourceId()); } smarty_assign('contribSources', Model::factory('Source')->where('canContribute', true)->order_by_asc('displayOrder')->find_many()); smarty_assign('page_title', 'Contribuie cu definiții'); smarty_assign('suggestNoBanner', true); smarty_displayCommonPageWithSkin('contribuie.ihtml'); /**************************************************************************/ function deleteEmptyElements(&$v) { $result = array(); foreach ($v as $elem) { if (!empty($elem)) { $result[] = $elem;
if ($fileName) { $v = Visual::get_by_path($fileName); if (!$v) { $v = Visual::createFromFile($fileName); } util_redirect("?id={$v->id}"); } $v = Visual::get_by_id($id); if ($saveButton) { $v->lexemeId = $lexemId; $v->revised = $revised; $v->save(); util_redirect("?id={$v->id}"); } if ($addTagButton) { $vt = Model::factory('VisualTag')->create(); $vt->imageId = $v->id; $vt->lexemeId = $tagLexemId; $vt->label = $tagLabel; $vt->textXCoord = $textXCoord; $vt->textYCoord = $textYCoord; $vt->imgXCoord = $imgXCoord; $vt->imgYCoord = $imgYCoord; $vt->save(); util_redirect("?id={$v->id}"); } SmartyWrap::assign('visual', $v); SmartyWrap::assign('lexem', Lexem::get_by_id($v->lexemeId)); SmartyWrap::addCss('jqueryui-smoothness', 'jcrop', 'select2', 'jqgrid', 'jqueryui', 'gallery'); SmartyWrap::addJs('jquery', 'jqueryui', 'jcrop', 'visualTag', 'select2', 'select2Dev', 'jqgrid', 'gallery'); SmartyWrap::displayAdminPage('admin/visualTag.tpl');
// Parse or initialize the GET/POST arguments $nick = util_getRequestParameter('n'); $medalSaveButton = util_getRequestParameter('medalSaveButton'); $userId = util_getRequestParameter('userId'); $medalsGranted = util_getRequestParameter('medalsGranted'); if ($medalSaveButton) { util_assertModerator(PRIV_ADMIN); $user = User::get_by_id($userId); $user->medalMask = Medal::getCanonicalMask(array_sum($medalsGranted)); $user->save(); util_redirect(util_getWwwRoot() . "utilizator/{$user->nick}"); } $user = User::get_by_nick($nick); if (!$user) { FlashMessage::add('Utilizatorul ' . htmlspecialchars($nick) . ' nu există.'); util_redirect(util_getWwwRoot()); } $userData = array(); $user->email = StringUtil::scrambleEmail($user->email); // Find the rank of this user by number of words and number of characters $topWords = TopEntry::getTopData(CRIT_WORDS, SORT_DESC, true); $numUsers = count($topWords); $rankWords = 0; while ($rankWords < $numUsers && $topWords[$rankWords]->userNick != $nick) { $rankWords++; } $userData['rank_words'] = $rankWords + 1; if ($rankWords < $numUsers) { $topEntry = $topWords[$rankWords]; $userData['last_submission'] = $topEntry->timestamp; $userData['num_words'] = $topEntry->numDefinitions;
if ($modelId) { $parts = preg_split('/_/', $modelId); assert(count($parts) == 2); $lm = $lexem->getFirstLexemModel(); $lm->modelType = $parts[0]; $lm->modelNumber = $parts[1]; $lm->restriction = util_getRequestParameter('restr_' . $lexem->id); $lm->save(); $lm->regenerateParadigm(); } else { $lexem->comment = util_getRequestParameter('comment_' . $lexem->id); $lexem->save(); } } } util_redirect("bulkLabel.php?suffix={$suffix}"); } $reverseSuffix = StringUtil::reverse($suffix); RecentLink::createOrUpdate("Etichetare asistată: -{$suffix}"); $numLabeled = Model::factory('Lexem')->table_alias('l')->join('LexemModel', 'lm.lexemId = l.id', 'lm')->where_not_equal('lm.modelType', 'T')->where_like('l.reverse', "{$reverseSuffix}%")->count(); // Collect all the models that appear in at least 5% of the already // labeled lexems. Always select at least one model, in the unlikely case // that no model has over 5%. $models = array(); $hasInvariableModel = false; $dbResult = db_execute("select canonical, modelNumber, count(*) as c " . "from Lexem " . "join LexemModel on lexemId = Lexem.id " . "join ModelType on modelType = code " . "where modelType != 'T' " . "and reverse like '{$reverseSuffix}%' " . "group by canonical, modelNumber " . "order by c desc", PDO::FETCH_ASSOC); foreach ($dbResult as $row) { $modelType = $row['canonical']; $modelNumber = $row['modelNumber']; $count = $row['c']; if (!count($models) || $count / $numLabeled >= 0.05) {
function authenticate($clientId, $secret) { $this->fetchWellKnownConfig(); if (!$clientId || !$secret) { throw new OpenIDException('Autentificare eșuată.'); } $url = $this->wellKnownConfig['authorization_endpoint']; $nonce = util_randomCapitalLetterString(32); $state = util_randomCapitalLetterString(32); session_setVariable('openid_connect_nonce', $nonce); session_setVariable('openid_connect_state', $state); session_setVariable('openid_connect_provider', $this->provider); session_setVariable('openid_connect_client', $clientId); session_setVariable('openid_connect_secret', $secret); $params = array('client_id' => $clientId, 'openid.realm' => util_getFullServerUrl(), 'nonce' => $nonce, 'redirect_uri' => $this->getReturnTo(), 'response_type' => 'code', 'scope' => 'openid email', 'state' => $state); $url .= '?' . http_build_query($params, null, '&'); util_redirect($url); }
if ($modelType == 'V') { $pm = ParticipleModel::loadByVerbModel($modelNumber); $clonePm = Model::factory('ParticipleModel')->create(); $clonePm->verbModel = $newModelNumber; $clonePm->adjectiveModel = $pm->adjectiveModel; $clonePm->save(); } // Migrate the selected lexems. if ($chooseLexems && $lexemModelIds) { foreach ($lexemModelIds as $lexemModelId) { $lm = LexemModel::get_by_id($lexemModelId); $lm->modelNumber = $newModelNumber; $lm->save(); // It is not necessary to regenerate the paradigm for now, since // the inflected forms are identical. } } util_redirect('../admin/index.php'); exit; } } else { $newModelNumber = $modelNumber . ".1"; } $lexemModels = LexemModel::loadByCanonicalModel($modelType, $modelNumber); SmartyWrap::assign('modelType', $modelType); SmartyWrap::assign('modelNumber', $modelNumber); SmartyWrap::assign('newModelNumber', $newModelNumber); SmartyWrap::assign('lexemModels', $lexemModels); SmartyWrap::assign('errorMessage', $errorMessages); SmartyWrap::assign('recentLinks', RecentLink::loadForUser()); SmartyWrap::displayAdminPage('admin/cloneModel.tpl');
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(); $mysqlDate = date("Y-m-d", $timestamp); if ($mysqlDate < WOTD_BIG_BANG || $mysqlDate > $today) { util_redirect(util_getWwwRoot() . 'cuvantul-zilei'); } $wotd = WordOfTheDay::get_by_displayDate($mysqlDate); if (!$wotd) { // We shouldn't have missing words since the Big Bang. if ($mysqlDate != $today) { util_redirect(util_getWwwRoot() . 'cuvantul-zilei'); } WordOfTheDay::updateTodaysWord(); $wotd = WordOfTheDay::get_by_displayDate($mysqlDate); } $archive = WordOfTheDay::getArchiveWotD(date('Y', $timestamp), date('m', $timestamp)); $defId = WordOfTheDayRel::getRefId($wotd->id); $def = Definition::get_by_id($defId); $searchResults = SearchResult::mapDefinitionArray(array($def)); setlocale(LC_ALL, 'ro_RO'); $roDate = strftime("%e %B %Y", $timestamp); $pageTitle = sprintf("Cuvântul zilei: %s (%s)", $def->lexicon, $roDate); if ($mysqlDate > WOTD_BIG_BANG) { smarty_assign('prevday', date('Y/m/d', $timestamp - 86400)); } if ($mysqlDate < $today) {
/** * Search engine friendly URLs used for the search page: * 1) http://dexonline.ro/definitie[-<sursa>]/<cuvânt>[/<defId>][/paradigma] * 2) http://dexonline.ro/lexem[-<sursa>]/<cuvânt>[/<lexemId>][/paradigma] * 3) http://dexonline.ro/text[-<sursa>]/<text> * Links of the old form (search.php?...) can only come via the search form and should not contain lexemId / definitionId. */ function util_redirectToFriendlyUrl($cuv, $sourceUrlName, $text, $showParadigm, $xml) { if (strpos($_SERVER['REQUEST_URI'], '/search.php?') === false) { return; // The url is already friendly. } if ($xml) { return; } $cuv = urlencode($cuv); $sourceUrlName = urlencode($sourceUrlName); $sourcePart = $sourceUrlName ? "-{$sourceUrlName}" : ''; $paradigmPart = $showParadigm ? '/paradigma' : ''; if ($text) { $url = "text{$sourcePart}/{$cuv}"; } else { $url = "definitie{$sourcePart}/{$cuv}{$paradigmPart}"; } util_redirect(util_getWwwRoot() . $url); }
<?php require_once "../phplib/util.php"; setlocale(LC_ALL, "ro_RO.utf8"); DebugInfo::disable(); $locVersion = util_getRequestParameter('locVersion'); $modelType = util_getRequestParameter('modelType'); $modelType = ModelType::get_by_code($modelType); // Use the ModelType object from this point on if (!$locVersion || !$modelType) { FlashMessage::add('Date incorecte'); util_redirect('scrabble'); } LocVersion::changeDatabase($locVersion); $models = FlexModel::loadByType($modelType->code); $lexemModels = array(); foreach ($models as $m) { $lexemModels[] = getLexemModel($m->exponent, $modelType->code, $m->number); } SmartyWrap::addCss('paradigm'); SmartyWrap::assign('page_title', 'Modele de flexiune'); SmartyWrap::assign('models', $models); SmartyWrap::assign('lexemModels', $lexemModels); SmartyWrap::assign('locVersion', $locVersion); SmartyWrap::assign('modelType', $modelType); SmartyWrap::display('modele-flexiune.ihtml'); /*************************************************************************/ /** * Returns a LexemModel for a given word and model. Creates one if one doesn't exist. **/ function getLexemModel($form, $modelType, $modelNumber)
LexemDefinitionMap::associate($dest->id, $def->id); } // Add $dest to LOC if $src is in LOC if ($src->isLoc() && !$dest->isLoc()) { $lm = $dest->getFirstLexemModel(); $lm->isLoc = true; $lm->save(); } // Delay the deletion because we might have to merge $src with other lexems. $lexemsToDelete[] = $src; } } foreach ($lexemsToDelete as $lexem) { $lexem->delete(); } util_redirect("mergeLexems.php?modelType={$modelType}"); exit; } $PLURAL_INFLECTIONS = array(3, 11, 19, 27, 35); if ($modelType == 'T') { $whereClause = 'modelType = "T"'; } else { if ($modelType) { $whereClause = "modelType = '{$modelType}' and restriction like '%P%'"; } else { $whereClause = '(modelType = "T") or (modelType in ("M", "F", "N") and restriction like "%P%")'; } } $dbResult = db_execute("select distinct l.* " . "from Lexem l " . "join LexemModel lm on lm.lexemId = l.id " . "where {$whereClause} " . "order by formNoAccent", PDO::FETCH_ASSOC); $lexems = array(); foreach ($dbResult as $row) {
<?php require_once "../../phplib/util.php"; util_assertModerator(PRIV_EDIT); util_assertNotMirror(); $id1 = util_getRequestParameter('id1'); $id2 = util_getRequestParameter('id2'); $l1 = Lexem::get_by_id($id1); $l2 = Lexem::get_by_id($id2); $defs = Definition::loadByLexemId($l1->id); foreach ($defs as $def) { LexemDefinitionMap::associate($l2->id, $def->id); } $l1->delete(); util_redirect("lexemEdit.php?lexemId={$l2->id}");
FlashMessage::add('Am salvat descrierea.', 'info'); util_redirect('tipuri-modele.php'); } else { SmartyWrap::assign('editModelType', $mt); } } if ($editId) { // Load model type to be edited SmartyWrap::assign('editModelType', ModelType::get_by_id($editId)); } if ($deleteId) { $mt = ModelType::get_by_id($deleteId); if (validateDelete($mt)) { FlashMessage::add("Am șters tipul de model '{$mt->code}'.", 'info'); $mt->delete(); util_redirect('tipuri-modele.php'); } } // Load model type table data $modelTypes = Model::factory('ModelType')->order_by_asc('code')->find_many(); $modelCounts = array(); $lexemCounts = array(); $canDelete = array(); foreach ($modelTypes as $mt) { $numLexems = Model::factory('LexemModel')->where('modelType', $mt->code)->count(); $numDependants = Model::factory('ModelType')->where('canonical', $mt->code)->count(); $modelCounts[] = Model::factory('FlexModel')->where('modelType', $mt->code)->count(); $lexemCounts[] = $numLexems; $canDelete[] = $numLexems == 0 && $numDependants <= 1; } SmartyWrap::assign('canonicalModelTypes', ModelType::loadCanonical());
<?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) {
$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}\");";
<?php require_once "../../phplib/util.php"; util_assertModerator(PRIV_EDIT); util_assertNotMirror(); $form = util_getRequestParameter('form'); $sourceId = util_getRequestParameter('source'); $loc = util_getRequestParameter('loc'); $paradigm = util_getRequestParameter('paradigm'); $structStatus = util_getRequestParameter('structStatus'); $nick = util_getRequestParameter('nick'); $searchButton = util_getRequestParameter('searchButton'); if (!$searchButton) { util_redirect('index.php'); } $where = array(); $joins = array(); // Process the $form argument $form = StringUtil::cleanupQuery($form); list($hasDiacritics, $hasRegexp, $ignored) = StringUtil::analyzeQuery($form); $field = $hasDiacritics ? 'formNoAccent' : 'formUtf8General'; if ($hasRegexp) { $fieldValue = StringUtil::dexRegexpToMysqlRegexp($form); } else { $fieldValue = "= '{$form}'"; } $where[] = "{$field} {$fieldValue}"; // Process the $sourceId argument if ($sourceId) { $joins['definition'] = true; $where[] = "sourceId = {$sourceId}";
if ($submitButton) { // Re-rank the inflections according to the order in $inflectionIds $modelTypeMap = array(); foreach ($inflectionIds as $inflId) { $infl = Inflection::get_by_id($inflId); $rank = array_key_exists($infl->modelType, $modelTypeMap) ? $modelTypeMap[$infl->modelType] + 1 : 1; $modelTypeMap[$infl->modelType] = $rank; $infl->rank = $rank; $infl->save(); } // Add a new inflection if one is given if ($newDescription) { $infl = Model::factory('Inflection')->create(); $infl->description = $newDescription; $infl->modelType = $newModelType; $infl->rank = $modelTypeMap[$newModelType] + 1; $infl->save(); } util_redirect('flexiuni'); } // Tag inflections which can be safely deleted (only those that aren't being used by any model) $inflections = Model::factory('Inflection')->order_by_asc('modelType')->order_by_asc('rank')->find_many(); $usedInflectionIds = db_getArray('select distinct inflectionId from ModelDescription'); foreach ($inflections as $infl) { $infl->canDelete = !in_array($infl->id, $usedInflectionIds); } SmartyWrap::assign('suggestHiddenSearchForm', true); SmartyWrap::assign('inflections', $inflections); SmartyWrap::assign('modelTypes', ModelType::loadCanonical()); SmartyWrap::addJs('jqTableDnd'); SmartyWrap::display('flexiuni.tpl');
<?php define('WOTM_BIG_BANG', '2012-04-01'); require_once "../phplib/util.php"; $date = util_getRequestParameter('d'); $type = util_getRequestParameter('t'); $today = date('Y-m-01', time()); // Always use the first of the month $timestamp = $date ? strtotime($date) : time(); $mysqlDate = date("Y-m-01", $timestamp); if ($mysqlDate < WOTM_BIG_BANG || $mysqlDate > $today && !util_isModerator(PRIV_ADMIN)) { util_redirect(util_getWwwRoot() . 'cuvantul-lunii'); } $wotm = WordOfTheMonth::getWotM($mysqlDate); $def = Definition::get_by_id($wotm->definitionId); if ($type == 'url') { SmartyWrap::assign('today', $today); SmartyWrap::assign('title', $def->lexicon); SmartyWrap::displayWithoutSkin('bits/wotmurl.tpl'); exit; } $searchResults = SearchResult::mapDefinitionArray(array($def)); $cYear = date('Y', $timestamp); $cMonth = date('n', $timestamp); $nextTS = mktime(0, 0, 0, $cMonth + 1, 1, $cYear); $prevTS = mktime(0, 0, 0, $cMonth - 1, 1, $cYear); if ($mysqlDate > WOTM_BIG_BANG) { SmartyWrap::assign('prevmon', date('Y/m', $prevTS)); } if ($mysqlDate < $today || util_isModerator(PRIV_ADMIN)) { SmartyWrap::assign('nextmon', date('Y/m', $nextTS));
$deleteId = util_getRequestParameter('deleteId'); $submitButton = util_getRequestParameter('submitButton'); if ($deleteId) { $mt = MeaningTag::get_by_id($deleteId); $mtms = MeaningTagMap::get_all_by_meaningTagId($mt->id); if (count($mtms)) { FlashMessage::add("Nu pot șterge eticheta «{$mt->value}», deoarece unele sensuri o folosesc.", 'error'); } else { $mt->delete(); FlashMessage::add("Am șters eticheta «{$mt->value}».", 'info'); } util_redirect('etichete-sensuri'); } if ($submitButton) { util_assertModerator(PRIV_ADMIN); $values = explode(',', $value); foreach ($values as $value) { $value = trim($value); if ($value && !MeaningTag::get_by_value($value)) { $mt = Model::factory('MeaningTag')->create(); $mt->value = $value; $mt->save(); } } FlashMessage::add('Etichetele au fost salvate.', 'info'); util_redirect('etichete-sensuri'); } $meaningTags = Model::factory('MeaningTag')->order_by_asc('value')->find_many(); SmartyWrap::assign('meaningTags', $meaningTags); SmartyWrap::assign('page_title', 'Etichete pentru sensuri'); SmartyWrap::display('etichete-sensuri.ihtml');
throw new OpenIDException($errorDescription); } if (!$code || !$state || $state != session_get('openid_connect_state')) { throw new OpenIDException('Răspuns incorect de la server'); } if (!$provider) { throw new OpenIDException('Sesiune coruptă'); } $token = $oidc->requestToken($code); $data = $oidc->getUserInfo($token); if (!isset($data['sub'])) { throw new OpenIDException('Date incorecte de la furnizor'); } } catch (OpenIDException $e) { FlashMessage::add('Eroare la autentificare: ' . $e->getMessage()); util_redirect('login.php'); } // With OpenID connect, the user is uniquely identified by (provider, sub). // We store the provider in the User.identity field for backwards compatibility with OpenID. // We also rename the name field to fullname, plain OpenID style $data['identity'] = $provider; if (isset($data['name'])) { $data['fullname'] = $data['name']; } $user = User::get_by_identity_openidConnectSub($provider, $data['sub']); if (!$user && $oidc->getPlainOpenid()) { // This may be the first time the user logs in after the migration from // OpenID 2.0 to OpenID Connect. $user = User::get_by_identity($oidc->getPlainOpenid()); if ($user) { $user->identity = null;
$noAccent = util_getRequestParameter('noAccent_' . $lexem->id); if ($noAccent) { $lexem->noAccent = 1; $lexem->save(); } else { if ($position != -1) { $lexem->form = mb_substr($lexem->form, 0, $position) . "'" . mb_substr($lexem->form, $position); $lexem->save(); foreach ($lexem->getLexemModels() as $lm) { $lm->regenerateParadigm(); } } } } } util_redirect("placeAccents.php"); } $chars = array(); $searchResults = array(); $lexems = Model::factory('Lexem')->raw_query("select * from Lexem where form not rlike '\\'' and not noAccent order by rand() limit 10")->find_many(); foreach ($lexems as $l) { $charArray = array(); $form = mb_strtoupper($l->form); $len = mb_strlen($form); for ($i = 0; $i < $len; $i++) { $c = StringUtil::getCharAt($form, $i); $charArray[] = ctype_space($c) ? ' ' : $c; } $chars[$l->id] = $charArray; $definitions = Definition::loadByLexemId($l->id); $searchResults[$l->id] = SearchResult::mapDefinitionArray($definitions);
<?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)) {
<?php require_once "../phplib/util.php"; ini_set('max_execution_time', '3600'); define('DB_QUERY', 'select * from Lexem where isLoc order by formNoAccent'); $locVersion = util_getRequestParameter('locVersion'); $newLocVersion = util_getRequestParameter('newLocVersion'); if ($newLocVersion) { if ($locVersion == $newLocVersion) { FlashMessage::add('Ați selectat aceeași versiune LOC de două ori'); util_redirect('scrabble-loc'); } $file1 = tempnam('/tmp', 'loc_diff_'); $file2 = tempnam('/tmp', 'loc_diff_'); writeLexems($locVersion, $file1); writeLexems($newLocVersion, $file2); $diff = OS::executeAndReturnOutput("diff {$file1} {$file2} || true"); print "<pre>\n"; foreach ($diff as $line) { if (StringUtil::startsWith($line, '< ')) { print sprintf("<span style=\"color: red\">%s: %s</span>\n", $locVersion, substr($line, 2)); } else { if (StringUtil::startsWith($line, '> ')) { print sprintf("<span style=\"color: green\">%s: %s</span>\n", $newLocVersion, substr($line, 2)); } } } print "</pre>\n"; util_deleteFile($file1); util_deleteFile($file2); exit;
<?php require_once "../phplib/util.php"; $user = session_getUser(); if (!$user) { util_redirect('auth/login'); } SmartyWrap::assign('bookmarks', UserWordBookmarkDisplayObject::getByUser($user->id)); SmartyWrap::display('cuvinte-favorite.tpl');
$searchType = SEARCH_APPROXIMATE; $lexems = Lexem::searchApproximate($cuv, $hasDiacritics, true); if (count($lexems) == 1) { FlashMessage::add("Ați fost redirecționat automat la forma „{$lexems[0]->formNoAccent}”."); } else { if (!count($lexems)) { FlashMessage::add("Niciun rezultat relevant pentru „{$cuv}”."); } } } if (count($lexems) == 1 && $cuv != $lexems[0]->formNoAccent) { // Convenience redirect when there is only one correct form. We want all pages to be canonical $sourcePart = $source ? "-{$source->urlName}" : ''; session_setVariable('redirect', true); session_setVariable('init_word', $cuv); util_redirect(util_getWwwRoot() . "definitie{$sourcePart}/{$lexems[0]->formNoAccent}" . ($xml ? '/xml' : '')); } smarty_assign('lexems', $lexems); if ($searchType == SEARCH_INFLECTED) { // For successful searches, load the definitions, inflections and linguistic articles $definitions = Definition::loadForLexems($lexems, $sourceId, $cuv, $exclude_unofficial); smarty_assign('wikiArticles', WikiArticle::loadForLexems($lexems)); } if (isset($definitions)) { $searchResults = SearchResult::mapDefinitionArray($definitions); } } $conjugations = NULL; $declensions = NULL; if ($searchType == SEARCH_INFLECTED || $searchType == SEARCH_LEXEM_ID || $searchType == SEARCH_FULL_TEXT || $searchType == SEARCH_MULTIWORD) { smarty_assign('results', $searchResults);
<?php require_once "../phplib/util.php"; $submitButton = util_getRequestParameter('submitButton'); if ($submitButton) { util_assertModerator(PRIV_ADMIN); $order = 1; $ids = util_getRequestParameter("ids"); foreach ($ids as $id) { $src = Source::get_by_id($id); $src->displayOrder = $order++; $src->save(); } FlashMessage::add('Ordinea a fost salvată.', 'info'); util_redirect('surse'); } $sources = util_isModerator(PRIV_VIEW_HIDDEN) ? Model::factory('Source')->order_by_asc('displayOrder')->find_many() : Model::factory('Source')->where_not_equal('isOfficial', SOURCE_TYPE_HIDDEN)->order_by_asc('displayOrder')->find_many(); smarty_assign('sources', $sources); smarty_assign('page_title', 'Surse'); smarty_displayCommonPageWithSkin('surse.ihtml');
<?php require_once "../phplib/util.php"; require_once "../phplib/userPreferences.php"; util_assertNotLoggedIn(); $sendButton = util_getRequestParameter('send'); if ($sendButton) { $userPrefs = util_getRequestCheckboxArray('userPrefs', ','); $skin = util_getRequestParameter('skin'); session_setAnonymousPrefs($userPrefs); if (session_isValidSkin($skin)) { session_setSkin($skin); } FlashMessage::add('Preferințele au fost salvate.', 'info'); util_redirect('preferinte'); } else { $userPrefs = session_getAnonymousPrefs(); $skin = session_getSkin(); } foreach (preg_split('/,/', $userPrefs) as $pref) { if (isset($userPreferencesSet[$pref])) { $userPreferencesSet[$pref]['checked'] = true; } } smarty_assign('userPrefs', $userPreferencesSet); smarty_assign('skin', $skin); smarty_assign('availableSkins', pref_getServerPreference('skins')); smarty_assign('page_title', 'Preferințe'); smarty_displayCommonPageWithSkin('preferinte.ihtml');
} } $defs = Model::factory('Definition')->where_raw("status = 0 {$sourceClause} and binary internalRep like '%{$search}%'")->order_by_asc('id')->limit($MAX_AFFECTED)->find_many(); $searchResults = SearchResult::mapDefinitionArray($defs); foreach ($defs as $def) { $def->internalRep = str_replace($search, $replace, $def->internalRep); $ambiguousMatches = array(); $def->internalRep = AdminStringUtil::internalizeDefinition($def->internalRep, $def->sourceId, $ambiguousMatches); $def->htmlRep = AdminStringUtil::htmlize($def->internalRep, $def->sourceId); // Complete or un-complete the abbreviation review if (!count($ambiguousMatches) && $def->abbrevReview == ABBREV_AMBIGUOUS) { $def->abbrevReview = ABBREV_REVIEW_COMPLETE; } else { if (count($ambiguousMatches) && $def->abbrevReview == ABBREV_REVIEW_COMPLETE) { $def->abbrevReview = ABBREV_AMBIGUOUS; } } if ($realRun) { $def->save(); } } if ($realRun) { util_redirect("index.php"); } smarty_assign('search', $search); smarty_assign('replace', $replace); smarty_assign('sourceId', $sourceId); smarty_assign('searchResults', $searchResults); smarty_assign('allStatuses', util_getAllStatuses()); smarty_assign('recentLinks', RecentLink::loadForUser()); smarty_displayWithoutSkin('admin/bulkReplace.ihtml');
<?php require_once "../phplib/util.php"; util_assertModerator(PRIV_ADMIN); $userIds = util_getRequestParameter('userIds'); $newNick = util_getRequestParameter('newNick'); $newCheckboxes = util_getRequestParameterWithDefault("newPriv", array()); $submitButton = util_getRequestParameter('submitButton'); if ($submitButton) { foreach ($userIds as $userId) { $checkboxes = util_getRequestParameterWithDefault("priv_{$userId}", array()); $user = User::get_by_id($userId); $user->moderator = array_sum($checkboxes); $user->save(); } if ($newNick) { $user = User::get_by_nick($newNick); if ($user) { $user->moderator = array_sum($newCheckboxes); $user->save(); } else { FlashMessage::add("Numele de utilizator „{$newNick}” nu există"); util_redirect("moderatori"); } } FlashMessage::add('Modificările au fost salvate', 'info'); util_redirect("moderatori"); } smarty_assign('page_title', 'Moderatori'); smarty_assign('users', Model::factory('User')->where_not_equal('moderator', 0)->order_by_asc('nick')->find_many()); smarty_displayCommonPageWithSkin('moderatori.ihtml');