static function init() { self::$theSmarty = new Smarty(); self::$theSmarty->template_dir = util_getRootPath() . 'templates'; self::$theSmarty->compile_dir = util_getRootPath() . 'templates_c'; self::$theSmarty->inheritance_merge_compiled_includes = false; // This allows variable names in {include} tags self::assign('wwwRoot', util_getWwwRoot()); self::assign('imgRoot', util_getImgRoot()); self::assign('sources', Model::factory('Source')->order_by_desc('isOfficial')->order_by_asc('displayOrder')->find_many()); self::assign('sUser', session_getUser()); self::assign('nick', session_getUserNick()); self::assign('currentYear', date("Y")); self::assign('isMobile', util_isMobile()); self::assign('suggestNoBanner', util_suggestNoBanner()); self::assign('cfg', Config::getAll()); self::assign('GLOBALS', $GLOBALS); self::$theSmarty->registerPlugin('function', 'getDebugInfo', array('SmartyWrap', 'getDebugInfo')); }
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; }
static function init() { self::$theSmarty = new Smarty(); self::$theSmarty->template_dir = util_getRootPath() . 'templates'; self::$theSmarty->compile_dir = util_getRootPath() . 'templates_c'; self::assign('wwwRoot', util_getWwwRoot()); self::assign('imgRoot', util_getImgRoot()); self::assign('staticServer', Config::get('static.url')); self::assign('sources', Model::factory('Source')->order_by_desc('isOfficial')->order_by_asc('displayOrder')->find_many()); self::assign('sUser', session_getUser()); self::assign('is_mirror', Config::get('global.mirror')); self::assign('nick', session_getUserNick()); self::assign('contact_email', Config::get('global.contact')); self::assign('hostedBy', Config::get('global.hostedBy')); self::assign('currentYear', date("Y")); self::assign('bannerType', Config::get('banner.type')); self::assign('developmentMode', Config::get('global.developmentMode')); self::assign('isMobile', util_isMobile()); self::assign('suggestNoBanner', util_suggestNoBanner()); self::assign('acEnable', Config::get('search.acEnable')); self::assign('acMinChars', Config::get('search.acMinChars')); self::assign('GLOBALS', $GLOBALS); self::$theSmarty->registerPlugin('function', 'getDebugInfo', array('SmartyWrap', 'getDebugInfo')); }
<?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');
<?php require_once "../phplib/util.php"; require_once "../phplib/ads/adsModule.php"; // Display a custom ad 50% of the times if (rand(0, 99) < 50) { AdsModule::runAllModules(null, null); } $widgets = Preferences::getWidgets(session_getUser()); $numEnabledWidgets = array_reduce($widgets, function ($result, $w) { return $result + $w['enabled']; }); $wordCount = Definition::getWordCount(); $wordCountRough = $wordCount - $wordCount % 10000; SmartyWrap::assign('page_title', 'Dicționar explicativ al limbii române'); SmartyWrap::assign('onHomePage', '1'); SmartyWrap::assign('letters', preg_split('//u', 'aăâbcdefghiîjklmnopqrsștțuvwxyz')); SmartyWrap::assign('words_total', util_formatNumber($wordCount, 0)); SmartyWrap::assign('words_rough', util_formatNumber($wordCountRough, 0)); SmartyWrap::assign('words_last_month', util_formatNumber(Definition::getWordCountLastMonth(), 0)); SmartyWrap::assign('widgets', $widgets); SmartyWrap::assign('numEnabledWidgets', $numEnabledWidgets); /* WotD part */ $wotd = WordOfTheDay::getTodaysWord(); if (!$wotd) { WordOfTheDay::updateTodaysWord(); $wotd = WordOfTheDay::getTodaysWord(); } $defId = WordOfTheDayRel::getRefId($wotd->id); $def = Model::factory('Definition')->where('id', $defId)->where('status', ST_ACTIVE)->find_one(); SmartyWrap::assign('thumbUrl', $wotd->getThumbUrl());
<?php require_once "../../phplib/util.php"; set_time_limit(0); // If no GET arguments are set, print usage and return. if (count($_GET) == 0) { SmartyWrap::addCss('polar'); SmartyWrap::displayWithoutSkin('update3Instructions.tpl'); return; } util_enforceGzipEncoding(); header('Content-type: text/xml'); $export = util_getRequestParameter('export'); $timestamp = util_getRequestIntParameter('timestamp'); $version = util_getRequestParameterWithDefault('version', '3.0'); if ($export && util_isDesktopBrowser() && !session_getUser()) { SmartyWrap::display('bits/updateError.tpl'); exit; } if ($export == 'sources') { SmartyWrap::assign('sources', Model::factory('Source')->find_many()); SmartyWrap::displayWithoutSkin('xml/update3Sources.tpl'); } else { if ($export == 'inflections') { SmartyWrap::assign('inflections', Model::factory('Inflection')->order_by_asc('id')->find_many()); SmartyWrap::displayWithoutSkin('xml/update3Inflections.tpl'); } else { if ($export == 'abbrev') { SmartyWrap::assign('abbrev', AdminStringUtil::loadRawAbbreviations()); SmartyWrap::displayWithoutSkin('xml/update3Abbrev.tpl'); } else {
function session_getSkin() { // Check for user preferences and anonymous preferences $user = session_getUser(); $skin = $user && $user->skin ? $user->skin : session_getCookieSetting('skin'); if ($skin && session_isValidSkin($skin)) { return $skin; } // Check if the user has a mobile device if (util_isMobile()) { return Config::get('global.mobileSkin'); } // Return the default skin return Config::get('global.desktopSkin'); }
function util_assertNotLoggedIn() { if (session_getUser()) { util_redirect(util_getWwwRoot()); } }
require_once "../../phplib/util.php"; // Allow this script to run indefinitely long set_time_limit(0); // If no GET arguments are set, print usage and return. if (count($_GET) == 0) { SmartyWrap::displayWithoutSkin('updateInstructions.tpl'); return; } $acceptEncoding = isset($_SERVER['HTTP_ACCEPT_ENCODING']) ? $_SERVER['HTTP_ACCEPT_ENCODING'] : ""; if (strstr($acceptEncoding, "gzip") === FALSE) { header("HTTP/1.0 403 Forbidden"); return; } $timestamp = util_getRequestIntParameter('timestamp'); $version = util_getRequestParameterWithDefault('version', '1.0'); if ($timestamp !== null && util_isDesktopBrowser() && !session_getUser()) { SmartyWrap::display('bits/updateError.tpl'); exit; } header('Content-type: text/xml'); $defDbResult = db_execute("select * from Definition where status = " . Definition::ST_ACTIVE . " and sourceId in (select id from Source where canDistribute) " . "and modDate >= '{$timestamp}' order by modDate, id"); $lexemDbResult = Lexem::loadNamesByMinModDate($timestamp); $sourceMap = createSourceMap(); userCache_init(); $currentLexem = array(0, ''); // Force loading a lexem on the next comparison. print "<!DOCTYPE dict [\n"; print " <!ENTITY diams \"♦\">\n"; print " <!ENTITY loz \"◊\">\n"; print " <!ENTITY rsquo \"’\">\n"; print "]>\n";
function populate(&$lexem, &$original, $lexemForm, $lexemNumber, $lexemDescription, $lexemComment, $needsAccent, $hyphenations, $pronunciations, $variantOfId, $structStatus, $modelType, $modelNumber, $restriction, $lmTags, $isLoc, $sourceIds) { $lexem->form = AdminStringUtil::formatLexem($lexemForm); $lexem->formNoAccent = str_replace("'", '', $lexem->form); $lexem->number = $lexemNumber; $lexem->description = AdminStringUtil::internalize($lexemDescription, false); $lexem->comment = trim(AdminStringUtil::internalize($lexemComment, false)); // Sign appended comments if (StringUtil::startsWith($lexem->comment, $original->comment) && $lexem->comment != $original->comment && !StringUtil::endsWith($lexem->comment, ']]')) { $lexem->comment .= " [[" . session_getUser() . ", " . strftime("%d %b %Y %H:%M") . "]]"; } $lexem->noAccent = !$needsAccent; $lexem->hyphenations = $hyphenations; $lexem->pronunciations = $pronunciations; $lexem->variantOfId = $variantOfId ? $variantOfId : null; $lexem->structStatus = $structStatus; // Create LexemModels and LexemSources $lexemModels = array(); for ($i = 1; $i < count($modelType); $i++) { $lm = Model::factory('LexemModel')->create(); $lm->lexemId = $lexem->id; $lm->setLexem($lexem); // Otherwise it will reload the original $lm->displayOrder = $i; $lm->modelType = $modelType[$i]; $lm->modelNumber = $modelNumber[$i]; $lm->restriction = $restriction[$i]; $lm->tags = $lmTags[$i]; $lm->isLoc = $isLoc[$i]; $lm->generateInflectedFormMap(); $lexemSources = array(); foreach (explode(',', $sourceIds[$i]) as $sourceId) { $ls = Model::factory('LexemSource')->create(); $ls->sourceId = $sourceId; $lexemSources[] = $ls; } $lm->setSources($lexemSources); $lexemModels[] = $lm; } $lexem->setLexemModels($lexemModels); }
} } if ($lexemDescription !== null) { $lexem->description = AdminStringUtil::internalize($lexemDescription, false); } if ($lexemTags !== null) { $lexem->tags = AdminStringUtil::internalize($lexemTags, false); } if ($lexemSources !== null) { $lexem->source = join(',', $lexemSources); } if ($lexemComment !== null) { $newComment = trim(AdminStringUtil::internalize($lexemComment, false)); $oldComment = trim($lexem->comment); if (StringUtil::startsWith($newComment, $oldComment) && $newComment != $oldComment && !StringUtil::endsWith($newComment, ']]')) { $newComment .= " [[" . session_getUser() . ", " . strftime("%d %b %Y %H:%M") . "]]\n"; } else { if ($newComment) { $newComment .= "\n"; } } $lexem->comment = $newComment; } if ($lexemIsLoc !== null) { $lexem->isLoc = $lexemIsLoc != ''; } if ($lexemNoAccent !== null) { $lexem->noAccent = $lexemNoAccent != ''; } // The new model type, number and restrictions can come from three sources: // $similarModel, $similarLexemName or ($modelType, $modelNumber,
function session_getSkin() { $user = session_getUser(); $skin = $user && $user->skin ? $user->skin : session_getCookieSetting('skin'); if ($skin && session_isValidSkin($skin)) { return $skin; } else { $skins = pref_getServerPreference('skins'); return $skins[0]; } }
function session_getSkin() { $user = session_getUser(); $skin = $user && $user->skin ? $user->skin : session_getCookieSetting('skin'); if ($skin && session_isValidSkin($skin)) { return $skin; } else { $skins = Config::get('global.skins'); return $skins[0]; } }
function util_suggestNoBanner() { if (isset($_SERVER['REQUEST_URI']) && preg_match('/(masturba|fute)/', $_SERVER['REQUEST_URI'])) { return true; // No banners on certain obscene pages } if (session_getUser() && session_getUser()->noAdsUntil > time()) { return true; // User is an active donor } return false; }