/** * Get fireeagle location for a user * * @param midcom_db_person $user Person to fetch Plazes data for * @param boolean $cache Whether to cache the position to a log object * @return Array */ function get_fireeagle_location($user, $cache = true) { $fireeagle_access_key = $user->get_parameter('net.yahoo.fireeagle', 'access_key'); $fireeagle_access_secret = $user->get_parameter('net.yahoo.fireeagle', 'access_secret'); if ($fireeagle_access_key && $fireeagle_access_secret) { $position = $this->_fetch_fireeagle_positions($fireeagle_access_key, $fireeagle_access_secret); if (is_null($position) && !is_array($position)) { return null; } $this->import($position, $user->id); return $position; } else { $this->error = 'POSITIONING_FIREEAGLE_NO_ACCOUNT'; } return null; }
/** * Get plazes location for a user * * @param midcom_db_person $user Person to fetch Plazes data for * @param boolean $cache Whether to cache the position to a log object * @return Array */ function get_plazes_location($user, $cache = true) { $plazes_username = $user->get_parameter('org.routamc.positioning:plazes', 'username'); $plazes_password = $user->get_parameter('org.routamc.positioning:plazes', 'password'); if ($plazes_username && $plazes_password) { $positions = $this->_fetch_plazes_positions($plazes_username, $plazes_password); if (is_null($positions) && !is_array($positions)) { return null; } if ($cache) { foreach ($positions as $position) { $this->import($position, $user->id); } } return $positions[0]; } else { $this->error = 'POSITIONING_PLAZES_NO_ACCOUNT'; } return null; }
/** * Get qaiku location for a user * * @param midcom_db_person $user Person to fetch Qaiku data for * @param boolean $cache Whether to cache the position to a log object * @return Array */ function get_qaiku_location($user, $cache = true) { $qaiku_apikey = $user->get_parameter('org.routamc.statusmessage:qaiku', 'apikey'); if ($qaiku_apikey) { $positions = $this->_fetch_qaiku_positions(trim($qaiku_apikey)); if (empty($positions)) { return null; } if ($cache) { foreach ($positions as $position) { $this->import($position, $user->id); } } return $positions[0]; } else { $this->error = 'POSITIONING_QAIKU_NO_APIKEY'; } return null; }
/** * Helper function to record failed login attempts and disable account is necessary * * @param string $component the component we take the config values from * @return boolean True if further login attempts are allowed, false otherwise */ public function check_login_attempts($component = null) { $stat = true; if (is_null($component)) { $component = "org.openpsa.user"; } //max-attempts allowed & timeframe $max_attempts = midcom_baseclasses_components_configuration::get($component, 'config')->get('max_password_attempts'); $timeframe = midcom_baseclasses_components_configuration::get($component, 'config')->get('password_block_timeframe_min'); if ($max_attempts == 0 || $timeframe == 0) { return $stat; } midcom::get('auth')->request_sudo('org.openpsa.user'); $attempts = $this->_person->get_parameter("org_openpsa_user_password", "attempts"); if (!empty($attempts)) { $attempts = unserialize($attempts); if (is_array($attempts)) { $attempts = array_slice($attempts, 0, $max_attempts - 1); } } if (!is_array($attempts)) { $attempts = array(); } array_unshift($attempts, time()); /* * If the maximum number of attemps is reached and the oldest attempt * on the stack is within our defined timeframe, we block the account */ if (sizeof($attempts) >= $max_attempts && $attempts[$max_attempts - 1] >= time() - $timeframe * 60) { $this->disable_account(); $stat = false; } $attempts = serialize($attempts); $this->_person->set_parameter("org_openpsa_user_password", "attempts", $attempts); midcom::get('auth')->drop_sudo(); return $stat; }
<?php if (!midcom::get('auth')->user) { _midcom_stop_request(); } // String output mode $x = 'false'; $y = 'false'; // Interface for getting the toolbar position if (!isset($_REQUEST['position_x']) || !isset($_REQUEST['position_y'])) { switch ($GLOBALS['midcom_config']['toolbars_position_storagemode']) { case 'parameter': $person = new midcom_db_person(midcom::get('auth')->user); $x = $person->get_parameter('midcom.services.toolbars', 'position_x'); $y = $person->get_parameter('midcom.services.toolbars', 'position_y'); break; case 'cookie': if (isset($_COOKIE['midcom_services_toolbars_position'])) { $pos = $_COOKIE['midcom_services_toolbars_position']; $pos = explode('_', $pos); $x = $pos[0]; $y = $pos[1]; } break; case 'session': $session = new midcom_services_session('midcom.services.toolbars'); $x = $session->get('position_x'); $y = $session->get('position_y'); break; } echo "{$x},{$y}";