/** * parse $_REQUEST['userid'] and return user for which map is displayed */ function getMapUserObj() { global $usr; // $usr is set in common.inc.php // check if map is for logged user or user want to preview someone else if (isset($_REQUEST['userid'])) { $previewUserId = intval($_REQUEST['userid']); // load User data from DB $userObj = new \lib\Objects\User\User(array('userId' => $previewUserId, 'fieldsStr' => 'user_id,latitude,longitude,username')); if ($userObj->isDataLoaded()) { //user found tpl_set_var('extrauserid', $previewUserId); return $userObj; } // preview user not found - wrong userId? // ...let's continue for currently logged user } // this is map for currently logged user // load User data from DB $userObj = new \lib\Objects\User\User(array('userId' => $usr['userid'], 'fieldsStr' => 'user_id,latitude,longitude,username')); if ($userObj->isDataLoaded()) { // user found tpl_set_var('extrauserid', ""); return $userObj; } else { // currently logged user not found - It should never happen // user not logged - redirect to login page... $usr = null; $target = urlencode(tpl_get_current_page()); tpl_redirect('login.php?target=' . $target); exit; } }
/** * get all today's active users */ public function checkAllUsersMedals() { $query = 'SELECT user_id, username, founds_count, notfounds_count, hidden_count, latitude, longitude, country, email FROM `user` WHERE (`last_login` BETWEEN DATE_SUB(NOW(), INTERVAL 24 HOUR) AND NOW()) '; $db = OcDb::instance(); $s = $db->simpleQuery($query); d($db->rowCount($s)); $timeStart = microtime(); $usersToCheck = $db->dbResultFetchAll($s); foreach ($usersToCheck as $userDbRow) { $user = new \lib\Objects\User\User(array('userDbRow' => $userDbRow)); $user->loadMedalsFromDb(); $this->checkMedalConditions($user); } $timeEnd = microtime() - $timeStart; d($timeEnd); }
private function userMedals() { /* lang test */ /* get locale from browser */ $userPrefferedLanguages = explode(';', $_SERVER['HTTP_ACCEPT_LANGUAGE']); $mostPrefferedLanguage = explode(',', $userPrefferedLanguages[0]); $locale = str_replace('-', '_', $mostPrefferedLanguage[0]); if (isset($_REQUEST['locale'])) { /* get locale from $_REQUEST*/ $locale = $_REQUEST['locale']; } $putenv = putenv("LANG={$locale}"); $setlocale = setlocale(LC_ALL, $locale); // d($locale, $putenv, $setlocale); bindtextdomain("medals", __DIR__ . '/../languages'); bind_textdomain_codeset('medals', 'UTF-8'); textdomain("medals"); // print gettext('level'); // print '<BR>'; /* end lang test*/ $ocConfig = \lib\Objects\OcConfig\OcConfig::instance(); $smarty = new \Smarty(); $smarty->setCompileDir($ocConfig->getDynamicFilesPath() . 'tmp/templates_c'); $smarty->debugging = false; $smarty->caching = false; $smarty->setTemplateDir(__DIR__ . '/../../tpl/smarty'); $smarty->setCacheDir($ocConfig->getDynamicFilesPath() . 'tmp/smarty_cache'); $user = new \lib\Objects\User\User(array('userId' => $this->request['userId'])); $user->loadMedalsFromDb(); // d($user, $user->getMedals()); /* @var $medal \lib\Objects\Medals\Medal */ foreach ($user->getMedals() as $medal) { $medal->checkConditionsForUser($user); $smartyMedals['medals'][] = array('imgSrc' => $medal->getImage(), 'name' => $medal->getName(), 'profile' => $medal->getMedalProfile(), 'level' => $medal->getLevel(), 'levelName' => $medal->getLevelName(), 'currentLevelInfo' => $medal->getLevelInfo(), 'nextLevelInfo' => $medal->getLevelInfo($medal->getLevel() + 1)); } $smartyMedals['tr'] = array('level' => _('level'), 'user' => _('user'), 'medals' => _('medals'), 'nextLevelRequirements' => _('Next level Requirements'), 'currentLevelRequirements' => _('Level achievements'), 'medalInfo' => _('Medal Profile'), 'cacheTypes' => _('Geocache types')); $smarty->assign('geocacheIcons', \cache::getCacheIconsSet()); $smarty->assign('user', $user->getUserInformation()); $smarty->assign("smartyMedals", $smartyMedals); $smarty->assign("bgImage", $this->shuffleBackgroundImage()); $smarty->display('medals.tpl'); }
global $site_name, $absolute_server_URI; if (!isset($rootpath)) { $rootpath = './'; } require_once './lib/common.inc.php'; $ocWP = $GLOBALS['oc_waypoint']; $no_tpl_build = false; //Preprocessing if ($error == false) { if ($usr == false) { //user logged in? $target = urlencode(tpl_get_current_page()); tpl_redirect('login.php?target=' . $target); } else { $db = \lib\Database\DataBaseSingleton::Instance(); $user = new \lib\Objects\User\User(array('userId' => $usr['userid'])); $user->loadExtendedSettings(); $default_country = getDefaultCountry($usr, $lang); if (isset($_REQUEST['newcache_info'])) { $newcache_info = $_REQUEST['newcache_info']; } else { $newcache_info = 1; } if ($newcache_info == 1) { // display info about register new cache $tplname = 'newcache_info'; } else { //set here the template to process $tplname = 'newcache'; } require_once $rootpath . '/lib/caches.inc.php';
$sql = "UPDATE user SET verify_all = '1' WHERE user_id = '" . intval($user_id) . "'"; mysql_query($sql) or die(mysql_error()); } if ($_GET['verify_all'] == 0 && $usr['admin']) { $sql = "UPDATE user SET verify_all = 0 WHERE user_id = " . intval($user_id); mysql_query($sql); } } // end force if (isset($_REQUEST['ignoreFoundLimit']) && $_REQUEST['ignoreFoundLimit'] != '') { $newIgnoreFoundLimit = intval($_REQUEST['ignoreFoundLimit']); $db = \lib\Database\DataBaseSingleton::Instance(); $db->multiVariableQuery('INSERT INTO user_settings (user_id, newcaches_no_limit) VALUES (:2, :1) ON DUPLICATE KEY UPDATE newcaches_no_limit = :1', $newIgnoreFoundLimit, $user->getUserId()); $db->reset(); unset($user); $user = new \lib\Objects\User\User(array('userId' => $_REQUEST['userid'])); $user->loadExtendedSettings(); } if (isset($_GET['is_active_flag']) && $_GET['is_active_flag'] == 1 && $usr['admin']) { $sql = "UPDATE user SET is_active_flag = 1 - is_active_flag, `activation_code`='' WHERE user_id = " . intval($user_id); mysql_query($sql); } if ($usr['userid'] == $super_admin_id) { tpl_set_var('remove_all_logs', '<p><img src="tpl/stdstyle/images/blue/arrow2.png" alt="" align="middle" /> <a href="removelog.php?userid=' . $user_id . '"><font color="#ff0000">' . tr('admin_users_remove_logs') . '</font></a> <img src="' . $stylepath . '/images/blue/atten-red.png" align="top" alt="" /></p>'); } else { tpl_set_var('remove_all_logs', ''); } if (checkField('countries', $lang)) { $lang_db = $lang; } else { $lang_db = "en";