Example #1
0
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());
}
Example #2
0
function smarty_init()
{
    $smarty = new Smarty();
    $smarty->template_dir = util_getRootPath() . 'templates';
    $smarty->compile_dir = util_getRootPath() . 'templates_c';
    $smarty->assign('wwwRoot', util_getWwwRoot());
    $smarty->assign('cssRoot', util_getCssRoot());
    $smarty->assign('imgRoot', util_getImgRoot());
    $smarty->assign('sources', Model::factory('Source')->order_by_desc('isOfficial')->order_by_asc('displayOrder')->find_many());
    $smarty->assign('sUser', session_getUser());
    $smarty->assign('is_mirror', pref_isMirror());
    $smarty->assign('nick', session_getUserNick());
    $smarty->assign('contact_email', pref_getContactEmail());
    $smarty->assign('hostedBy', pref_getHostedBy());
    $smarty->assign('currentYear', date("Y"));
    $smarty->assign('bannerType', pref_getServerPreference('bannerType'));
    $smarty->assign('developmentMode', pref_getServerPreference('developmentMode'));
    $smarty->assign('isMobile', util_isMobile());
    smarty_registerFunction($smarty, 'getDebugInfo', 'smarty_function_getDebugInfo');
    $smarty->assign('GLOBALS', $GLOBALS);
    $GLOBALS['smarty_theSmarty'] = $smarty;
}
Example #3
0
    if (!StringUtil::validateAlphabet($lexemId, '0123456789')) {
        $lexemId = '';
    }
    $lexem = Lexem::get_by_id($lexemId);
    if ($lexem) {
        $lexems = array($lexem);
        $cuv = $lexem->formNoAccent;
    } else {
        $lexems = array();
        $cuv = NULL;
    }
}
if ($lexemId) {
    SmartyWrap::assign('paradigmLink', util_getWwwRoot() . "lexem/{$cuv}/{$lexemId}/paradigma");
} else {
    SmartyWrap::assign('paradigmLink', util_getWwwRoot() . "definitie/{$cuv}/paradigma");
}
if ($cuv) {
    $cuv = StringUtil::cleanupQuery($cuv);
}
// Normal search
if ($searchType == SEARCH_INFLECTED) {
    $lexems = Lexem::searchInflectedForms($cuv, $hasDiacritics);
    if (count($lexems) == 0) {
        $cuv_old = StringUtil::tryOldOrthography($cuv);
        $lexems = Lexem::searchInflectedForms($cuv_old, $hasDiacritics);
    }
}
// Maps lexems to arrays of inflected forms (some lexems may lack inflections)
// Also compute the text of the link to the paradigm div,
// which can be 'conjugări', 'declinări' or both
Example #4
0
// 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;
Example #5
0
<?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));
Example #6
0
        $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);
Example #7
0
    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) {
Example #8
0
/**
 * 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);
}
                $error = 'A intervenit o eroare la încărcare.';
            }
        }
    }
}
if ($error) {
    FlashMessage::add($error);
    util_redirect(util_getWwwRoot() . 'preferinte');
}
$user = session_getUser();
if (!$user) {
    FlashMessage::add('Nu puteți alege o imagine de profil dacă nu sunteți autentificat.');
    util_redirect(util_getWwwRoot());
}
// Remove any old files (with different extensions)
$oldFiles = glob(util_getRootPath() . "wwwbase/img/user/{$user->id}_raw.*");
foreach ($oldFiles as $oldFile) {
    unlink($oldFile);
}
$ext = pathinfo($file['name'], PATHINFO_EXTENSION);
$destFileName = util_getRootPath() . "wwwbase/img/user/{$user->id}_raw.{$ext}";
if (!move_uploaded_file($file['tmp_name'], $destFileName)) {
    FlashMessage::add('A intervenit o eroare la copierea fișierului.');
    util_redirect(util_getWwwRoot() . 'preferinte');
}
chmod($destFileName, 0666);
SmartyWrap::addCss('jcrop');
SmartyWrap::addJs('jcrop');
SmartyWrap::assign('page_title', "Editarea pozei de profil");
SmartyWrap::assign('rawFileName', "{$user->id}_raw.{$ext}");
SmartyWrap::display('editare-avatar.ihtml');
Example #10
0
 static function addJs()
 {
     // Note the priorities. This allows files to be added in any order, regardless of dependencies
     foreach (func_get_args() as $id) {
         switch ($id) {
             case 'jquery':
                 self::$jsFiles[1] = 'jquery-1.10.2.min.js';
                 break;
             case 'jqueryui':
                 self::$jsFiles[2] = 'jquery-ui-1.10.3.custom.min.js';
                 break;
             case 'jqgrid':
                 self::$jsFiles[3] = 'grid.locale-en.js?v=2';
                 self::$jsFiles[4] = 'jquery.jqGrid.min.js?v=3';
                 break;
             case 'jqnotice':
                 self::$jsFiles[5] = 'jquery.notice.js';
                 break;
             case 'jqTableDnd':
                 self::$jsFiles[6] = 'jquery.tablednd.0.8.min.js?v=1';
                 break;
             case 'tablesorter':
                 self::$jsFiles[7] = 'jquery.tablesorter.min.js?v=5';
                 self::$jsFiles[8] = 'tablesorter.dev.js?v=3';
                 break;
             case 'pager':
                 self::$jsFiles[9] = 'jquery.tablesorter.pager.min.js';
                 break;
             case 'elfinder':
                 self::$jsFiles[10] = 'elfinder.min.js?v=1';
                 break;
             case 'windowEngine':
                 self::$jsFiles[11] = 'jquery-wm.js';
                 break;
             case 'cookie':
                 self::$jsFiles[12] = 'jquery.cookie.js?v=1';
                 break;
             case 'dex':
                 self::$jsFiles[13] = 'dex.js?v=29';
                 break;
             case 'flex':
                 self::$jsFiles[14] = 'flex.js?v=2';
                 break;
             case 'hangman':
                 self::$jsFiles[15] = 'hangman.js?v=5';
                 break;
             case 'mill':
                 self::$jsFiles[16] = 'mill.js?v=3';
                 break;
             case 'wotd':
                 self::$jsFiles[17] = 'wotd.js?v=2';
                 break;
             case 'lexemEdit':
                 self::$jsFiles[18] = 'lexemEdit.js?v=15';
                 break;
             case 'jcrop':
                 self::$jsFiles[19] = 'jquery.Jcrop.min.js?v=2';
                 break;
             case 'select2':
                 self::$jsFiles[20] = 'select2.min.js?v=3';
                 break;
             case 'select2Dev':
                 self::$jsFiles[21] = 'select2Dev.js?v=7';
                 break;
             case 'visual':
                 self::$jsFiles[22] = 'visual.js?v=2';
                 break;
             case 'visualTag':
                 self::$jsFiles[23] = 'visualTag.js?v=2';
                 break;
             case 'gallery':
                 self::$jsFiles[24] = 'colorbox/jquery.colorbox-min.js';
                 self::$jsFiles[25] = 'colorbox/jquery.colorbox-ro.js';
                 self::$jsFiles[26] = 'dexGallery.js?v=2';
                 self::$jsFiles[27] = 'jcanvas.min.js';
                 break;
             case 'modelDropdown':
                 self::$jsFiles[28] = 'modelDropdown.js';
                 break;
             case 'textComplete':
                 self::$jsFiles[29] = 'jquery.textcomplete.min.js';
                 break;
             case 'definitionEdit':
                 self::$jsFiles[30] = 'definitionEdit.js';
                 break;
             default:
                 FlashMessage::add("Cannot load JS script {$id}");
                 util_redirect(util_getWwwRoot());
         }
     }
 }
Example #11
0
/**
 * 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, $lexemId, $sourceUrlName, $text, $showParadigm, $xml, $all)
{
    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' : '';
    $allPart = $all && !$showParadigm ? '/expandat' : '';
    if ($text) {
        $url = "text{$sourcePart}/{$cuv}";
    } else {
        if ($lexemId) {
            $l = Lexem::get_by_id($lexemId);
            if (!$l) {
                util_redirect(util_getWwwRoot());
            }
            $url = "lexem{$sourcePart}/{$l->formNoAccent}/{$l->id}/{$paradigmPart}";
        } else {
            $url = "definitie{$sourcePart}/{$cuv}{$paradigmPart}";
        }
    }
    util_redirect(util_getWwwRoot() . $url . $allPart);
}