public static function runAllModules($lexems, $definitions) { $adsModules = pref_getServerPreference('adsModulesH'); if ($adsModules) { foreach ($adsModules as $adsModule) { require_once util_getRootPath() . "phplib/ads/{$adsModule}/{$adsModule}AdsModule.php"; $className = ucfirst($adsModule) . 'AdsModule'; $module = new $className(); $result = $module->run(empty($lexems) ? null : $lexems, empty($definitions) ? null : $definitions); if ($result) { smarty_assign('adsProvider', $adsModule); smarty_assign('adsProviderParams', $result); break; } } } }
function pref_getLocVersions() { if (!array_key_exists('locVersions', $GLOBALS)) { $result = array(); $locParts = pref_getServerPreference('locVersions'); foreach ($locParts as $part) { $part = trim($part); if ($part) { $versionAndDate = preg_split('/ /', $part); assert(count($versionAndDate == 2)); $lv = new LocVersion(); $lv->name = trim($versionAndDate[0]); $date = trim($versionAndDate[1]); $lv->freezeTimestamp = $date == 'current' ? null : strtotime($date); $result[] = $lv; } } $GLOBALS['locVersions'] = array_reverse($result); } return $GLOBALS['locVersions']; }
/** * Saves an entry into the log table * @access public * @return boolean **/ public function logData() { //If we decide to put the logged data into a table, then call $this->insert() if (!$this->query) { return false; } try { $f = fopen(pref_getServerPreference('logPath'), 'at'); } catch (Exception $e) { try { $f = fopen(pref_getServerPreference('logPath'), 'wt'); } catch (Exception $e) { throw new Exception('Error trying to access the log file', -1, $e); } } $date = date('Y-m-d H:i:s'); $millis = DebugInfo::getRunningTimeInMillis(); $line = "[{$this->query}]\t[{$this->queryBeforeRedirect}]\t{$this->searchType}\t{$this->registeredUser}\t{$this->skin}\t" . "{$this->preferences}\t{$this->resultCount}\t{$this->resultList}\t{$this->redirect}\t{$date}\t{$millis}\n"; fwrite($f, $line); fclose($f); }
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; }
/** * Returns an array mapping user, password, host and database to their respective values. **/ function db_splitDsn($dsn = null) { $result = array(); if (!$dsn) { $dsn = pref_getServerPreference('database'); } $prefix = 'mysql://'; assert(StringUtil::startsWith($dsn, $prefix)); $dsn = substr($dsn, strlen($prefix)); $parts = preg_split("/[:@\\/]/", $dsn); assert(count($parts) == 3 || count($parts) == 4); if (count($parts) == 4) { $result['user'] = $parts[0]; $result['password'] = $parts[1]; $result['host'] = $parts[2]; $result['database'] = $parts[3]; } else { $result['user'] = $parts[0]; $result['host'] = $parts[1]; $result['database'] = $parts[2]; $result['password'] = ''; } return $result; }
<?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');
} } } smarty_assign('hasUnrecommendedForms', $hasUnrecommendedForms); if ($showParadigm) { smarty_assign('ifMaps', $ifMaps); } smarty_assign('declensionText', $declensionText); $sourceNamesArr = array(); foreach ($lexems as $l) { $sourceNamesArr[] = LexemSources::getNamesOfSources($l->source); } smarty_assign('sourceNamesArr', $sourceNamesArr); } } if (pref_getServerPreference('logSearch')) { $logDefinitions = isset($definitions) ? $definitions : array(); $log = new Log($cuv, $redirectFrom, $searchType, $redirect, $logDefinitions); $log->logData(); } $sourceList = array(); if (isset($searchResults)) { foreach ($searchResults as $row) { if (!in_array($row->source->shortName, $sourceList)) { $sourceList[] = $row->source->shortName; } } } // META tags - TODO move in a dedicated file if ($cuv) { $page_keywords = "{$cuv}, definiție {$cuv}";
util_assertModerator(PRIV_EDIT); # Select random definition to search. $count = db_getSingleValue("select count(*) from Definition where status = 0 and length(internalRep) > 250;"); $nr = rand(1, $count); $definition = db_getSingleValue("select htmlRep from Definition where status = 0 and length(internalRep) > 200 limit {$nr} ,1;"); # Parse definition and create string to search $v = explode(" ", strip_tags($definition)); $to_search = "\""; # Set string to search start + end $WORD_START = 5; $WORD_NO = 16; $to_search .= implode(" ", array_slice($v, $WORD_START, $WORD_NO)); $to_search .= "\""; $to_search = str_replace(array(",", "(", ")", "[", "]", "-", ";", "◊", "♦", "<", ">", "?", "\\", "/"), array_pad(array(), 14, ''), $to_search); $urlGoogle = "https://ajax.googleapis.com/ajax/services/search/web?v=1.0"; $apiKey = pref_getServerPreference('googleSearchApiKey'); $url = $urlGoogle . "&q=" . urlencode($to_search) . "&key=" . $apiKey; $body = util_fetchUrl($url); # now, process the JSON string $json = json_decode($body); $rezultate = $json->responseData->results; $listAll = array(); $content = ""; $messageAlert = array(); $blackList = array(); foreach ($rezultate as $iter) { # Skip dexonline.ro from results #if(stripos($iter->url, "dexonline.ro") == true) # continue; $components = parse_url($iter->url); if (StringUtil::endsWith($components['host'], 'dexonline.ro')) {
/** * Returns an array of the skin-specific preferences defined in the section skin-{$skin}. * Returns an empty array if the section is not defined. Never returns false/null. **/ function session_getSkinPreferences($skin) { $prefs = pref_getServerPreference("skin-{$skin}"); return $prefs ? $prefs : array(); }
/** * Logic that tells us whether it's ok to use the memcached server. * We don't want it for moderators because they are the ones who can alter the results and we want them to see the changes right away. */ function mc_shouldUse() { return pref_getServerPreference('memcache') && !util_isModerator(PRIV_EDIT); }