コード例 #1
0
ファイル: api.php プロジェクト: ConnorChristie/GrabViews
 /**
  * Returns the list of online users
  * 
  * @param	string  $api_key		Authentication Key
  * @param 	string  $api_module		Module
  * @param	string	$sep_character	Separator character
  * @return	string	xml
  */
 public function fetchOnlineUsers($api_key, $api_module, $sep_character = ',')
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $api_key = IPSText::md5Clean($api_key);
     $api_module = IPSText::parseCleanValue($api_module);
     //-----------------------------------------
     // Authenticate
     //-----------------------------------------
     if ($this->__authenticate($api_key, $api_module, 'fetchOnlineUsers') !== FALSE) {
         //-----------------------------------------
         // Add log
         //-----------------------------------------
         $this->addLogging($api_key);
         if (!ipsRegistry::$settings['au_cutoff']) {
             ipsRegistry::$settings['au_cutoff'] = 15;
         }
         $cut_off = ipsRegistry::$settings['au_cutoff'] * 60;
         $time = time() - $cut_off;
         $rows = array();
         $ar_time = time();
         $this->registry->DB()->build(array('select' => '*', 'from' => 'sessions', 'where' => "running_time > {$time}"));
         $this->registry->DB()->execute();
         //-----------------------------------------
         // FETCH...
         //-----------------------------------------
         while ($r = $this->registry->DB()->fetch()) {
             $rows[$r['running_time'] . '.' . $r['id']] = $r;
         }
         krsort($rows);
         //-----------------------------------------
         // cache all printed members so we
         // don't double print them
         //-----------------------------------------
         $cached = array();
         foreach ($rows as $result) {
             $last_date = ipsRegistry::getClass('class_localization')->getTime($result['running_time']);
             //-----------------------------------------
             // Bot?
             //-----------------------------------------
             if (isset($result['uagent_type']) && $result['uagent_type'] == 'search') {
                 //-----------------------------------------
                 // Seen bot of this type yet?
                 //-----------------------------------------
                 if (!$cached[$result['member_name']]) {
                     $active['NAMES'][] = $result['member_name'];
                     $cached[$result['member_name']] = 1;
                 } else {
                     //-----------------------------------------
                     // Yup, count others as guest
                     //-----------------------------------------
                     $active['GUESTS']++;
                 }
             } else {
                 if (!$result['member_id'] or !$result['member_name']) {
                     $active['GUESTS']++;
                 } else {
                     if (empty($cached[$result['member_id']])) {
                         $cached[$result['member_id']] = 1;
                         $result['member_name'] = IPSMember::makeNameFormatted($result['member_name'], $result['member_group']);
                         /* Reset login type in case the board/group setting got changed */
                         $result['login_type'] = IPSMember::isLoggedInAnon(array('login_anonymous' => $result['login_type']), $result['member_group']);
                         if ($result['login_type']) {
                             if ($this->registry->member()->getProperty('g_access_cp')) {
                                 $active['NAMES'][] = "<a href='" . $this->registry->getClass('output')->buildSEOUrl("showuser={$result['member_id']}", 'public', $result['seo_name'], 'showuser') . "' title='{$last_date}'>{$result['member_name']}</a>*";
                                 $active['ANON']++;
                             } else {
                                 $active['ANON']++;
                             }
                         } else {
                             $active['MEMBERS']++;
                             $active['NAMES'][] = "<a href='" . $this->registry->getClass('output')->buildSEOUrl("showuser={$result['member_id']}", 'public', $result['seo_name'], 'showuser') . "' title='{$last_date}'>{$result['member_name']}</a>";
                         }
                     }
                 }
             }
         }
         $active['TOTAL'] = $active['MEMBERS'] + $active['GUESTS'] + $active['ANON'];
         //-----------------------------------------
         // Return info
         //-----------------------------------------
         $this->classApiServer->apiSendReply($active);
         exit;
     }
 }
コード例 #2
0
 /**
  * Process Logout
  *
  * @param	int		ID number
  * @param	string	md5( IPS Connect Key (see login method) . ID number )
  * @param	string	Redirect URL, Base64 encoded
  * @param	string	md5( IPS Connect Key . $redirect )
  * @return	mixed	If the redirect URL is provided, this function should redirect the user to that URL
  *					If blank, will output blank screen
  */
 public function logout($id, $key, $redirect, $redirectHash)
 {
     if ($key != md5($this->masterKey . $id)) {
         $this->_return(base64_encode($this->settings['board_url']));
     }
     IPSCookie::set("ipsconnect_" . md5($this->settings['board_url'] . '/interface/ipsconnect/ipsconnect.php'), '0', 1, 0, FALSE, FALSE);
     $member = IPSMember::load(intval($id), 'none', 'id');
     if ($member['member_id']) {
         IPSCookie::set("member_id", "0");
         IPSCookie::set("pass_hash", "0");
         if (is_array($_COOKIE)) {
             foreach ($_COOKIE as $cookie => $value) {
                 if (stripos($cookie, $this->settings['cookie_id'] . 'ipbforumpass') !== false and !strstr($value, 'mobileApp')) {
                     IPSCookie::set(str_replace($this->settings['cookie_id'], "", $cookie), '-', -1);
                 }
             }
         }
         $this->member->sessionClass()->convertMemberToGuest();
         $privacy = intval(IPSMember::isLoggedInAnon($member));
         IPSMember::save($member['member_id'], array('core' => array('login_anonymous' => "{$privacy}&0", 'last_activity' => IPS_UNIX_TIME_NOW)));
         IPSLib::runMemberSync('onLogOut', $member);
         $this->han_login->logoutCallback($member);
         /* Run any custom code */
         $this->_runCustom('logout', array($member));
     }
     if ($redirect) {
         $redirect = $redirectHash == md5($this->masterKey . $redirect) ? $redirect : base64_encode($this->settings['board_url']);
     }
     $this->_return($redirect);
 }
コード例 #3
0
ファイル: login.php プロジェクト: ConnorChristie/GrabViews
 /**
  * Log a user out
  *
  * @param	integer		Flag to check md5 key
  * @return	mixed		Error message or array [0=immediate|redirect, 1=words to show, 2=URL to send to]
  */
 public function doLogout($check_key = true)
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     if ($check_key) {
         $key = $this->request['k'];
         # Check for funny business
         if ($key != $this->member->form_hash) {
             $this->registry->getClass('output')->showError('bad_logout_key', 2012);
         }
     }
     //-----------------------------------------
     // Set some cookies
     //-----------------------------------------
     IPSCookie::set("member_id", "0", 1, 0, FALSE, TRUE);
     IPSCookie::set("pass_hash", "0", 1, 0, FALSE, TRUE);
     if (IPSCookie::get("ipsconnect_" . md5($this->settings['board_url'] . '/interface/ipsconnect/ipsconnect.php'))) {
         IPSCookie::set("ipsconnect_" . md5($this->settings['board_url'] . '/interface/ipsconnect/ipsconnect.php'), '0', 1, 0, FALSE, FALSE);
     }
     //-----------------------------------------
     // IPS Connect
     //-----------------------------------------
     foreach ($this->caches['login_methods'] as $k => $data) {
         if ($data['login_folder_name'] == 'ipsconnect' and $data['login_enabled']) {
             $ipsConnectSettings = unserialize($data['login_custom_config']);
             IPSCookie::set("ipsconnect_" . md5($ipsConnectSettings['master_url']), '0', 1, 0, FALSE, FALSE);
         }
     }
     if (is_array($_COOKIE)) {
         foreach ($_COOKIE as $cookie => $value) {
             if (stripos($cookie, $this->settings['cookie_id'] . 'ipbforumpass') !== false and !strstr($value, 'mobileApp')) {
                 IPSCookie::set(str_replace($this->settings['cookie_id'], "", $cookie), '-', -1);
             }
         }
     }
     //-----------------------------------------
     // Do it..
     //-----------------------------------------
     $this->member->sessionClass()->convertMemberToGuest();
     $privacy = intval(IPSMember::isLoggedInAnon($this->memberData));
     IPSMember::save($this->memberData['member_id'], array('core' => array('login_anonymous' => "{$privacy}&0", 'last_activity' => IPS_UNIX_TIME_NOW)));
     //-----------------------------------------
     // Logout callbacks...
     //-----------------------------------------
     IPSLib::runMemberSync('onLogOut', $this->memberData);
     $this->han_login->logoutCallback($this->memberData);
     //-----------------------------------------
     // Return..
     //-----------------------------------------
     $url = "";
     if ($this->request['return'] and $this->request['return'] != "") {
         $return = urldecode($this->request['return']);
         if (strpos($return, "http://") === 0) {
             return array('immediate', '', $return);
         }
     }
     return array('redirect', $this->lang->words['thanks_for_logout'], $this->settings['board_url']);
 }
コード例 #4
0
 /**
  * loginWithoutCheckingCredentials: Just log the user in.
  * DOES NOT CHECK FOR A USERNAME OR PASSWORD.
  * << USE WITH CAUTION >>
  *
  * @param	int			Member ID to log in
  * @param	boolean		Set cookies
  * @return	mixed		FALSE on error or array [0=Words to show, 1=URL to send to] on success
  */
 public function loginWithoutCheckingCredentials($memberID, $setCookies = TRUE)
 {
     //-----------------------------------------
     // Load member
     //-----------------------------------------
     $member = IPSMember::load($memberID, 'all,members_partial');
     if (!$member['member_id']) {
         return FALSE;
     }
     //-----------------------------------------
     // Is this a partial member?
     // Not completed their sign in?
     //-----------------------------------------
     if ($member['members_created_remote']) {
         if (isset($member['full']) and !$member['full']) {
             //-----------------------------------------
             // If this is a resume, i.e. from Facebook,
             // timenow won't be set
             //-----------------------------------------
             if (!$member['timenow']) {
                 $partial = $this->DB->buildAndFetch(array('select' => 'partial_date', 'from' => 'members_partial', 'where' => 'partial_member_id=' . $member['member_id']));
                 $member['timenow'] = $partial['partial_date'];
             }
             return array($this->registry->getClass('class_localization')->words['partial_login'], $this->settings['base_url'] . 'app=core&amp;module=global&amp;section=register&amp;do=complete_login&amp;mid=' . $member['member_id'] . '&amp;key=' . $member['timenow']);
         } elseif ($member['partial_member_id']) {
             $this->DB->delete('members_partial', "partial_member_id={$member['partial_member_id']}");
         }
     }
     //-----------------------------------------
     // Generate a new log in key
     //-----------------------------------------
     $_ok = 1;
     $_time = $this->settings['login_key_expire'] ? time() + intval($this->settings['login_key_expire']) * 86400 : 0;
     $_sticky = $_time ? 0 : 1;
     $_days = $_time ? $this->settings['login_key_expire'] : 365;
     if (!$member['member_login_key'] or $this->settings['login_key_expire'] and time() > $member['member_login_key_expire']) {
         $member['member_login_key'] = IPSMember::generateAutoLoginKey();
         $core['member_login_key'] = $member['member_login_key'];
         $core['member_login_key_expire'] = $_time;
     }
     //-----------------------------------------
     // Cookie me softly?
     //-----------------------------------------
     if ($setCookies) {
         IPSCookie::set("member_id", $member['member_id'], 1, 0, FALSE, TRUE);
         IPSCookie::set("pass_hash", $member['member_login_key'], $_sticky, $_days, FALSE, TRUE);
         IPSCookie::set("ipsconnect_" . md5($this->settings['board_url'] . '/interface/ipsconnect/ipsconnect.php'), '1', $_sticky, $_days, FALSE, FALSE);
     } else {
         IPSCookie::set("member_id", $member['member_id'], 0, 0, FALSE, TRUE);
         IPSCookie::set("pass_hash", $member['member_login_key'], 0, 0, FALSE, TRUE);
         IPSCookie::set("ipsconnect_" . md5($this->settings['board_url'] . '/interface/ipsconnect/ipsconnect.php'), '1', 0, 0, FALSE, FALSE);
     }
     //-----------------------------------------
     // Remove any COPPA cookies previously set
     //-----------------------------------------
     IPSCookie::set("coppa", '0', 0);
     //-----------------------------------------
     // Update profile if IP addr missing
     //-----------------------------------------
     if ($member['ip_address'] == "" or $member['ip_address'] == '127.0.0.1') {
         $core['ip_address'] = $this->registry->member()->ip_address;
     }
     //-----------------------------------------
     // Create / Update session
     //-----------------------------------------
     $privacy = IPSMember::isLoggedInAnon($member);
     $session_id = $this->registry->member()->sessionClass()->convertGuestToMember(array('member_name' => $member['members_display_name'], 'member_id' => $member['member_id'], 'member_group' => $member['member_group_id'], 'login_type' => $privacy));
     if (!empty($this->request['referer']) and $this->request['section'] != 'register') {
         if (stripos($this->request['referer'], 'section=register') or stripos($this->request['referer'], 'section=login') or stripos($this->request['referer'], 'section=lostpass')) {
             $url = $this->settings['base_url'];
         } else {
             $url = str_replace('&amp;', '&', $this->request['referer']);
             //$url = str_replace( "{$this->settings['board_url']}/index.{$this->settings['php_ext']}", "", $url );
             //$url = str_replace( "{$this->settings['board_url']}/", "", $url );
             //$url = str_replace( "{$this->settings['board_url']}", "", $url );
             //$url = preg_replace( "#^(.+?)\?#", ""	, $url );
             $url = preg_replace('#s=(\\w){32}#', "", $url);
             $url = ltrim($url, '?');
         }
     } else {
         $url = $this->settings['base_url'];
     }
     //-----------------------------------------
     // Set our privacy status
     //-----------------------------------------
     $core['login_anonymous'] = intval($privacy) . '&1';
     $core['failed_logins'] = '';
     $core['failed_login_count'] = 0;
     IPSMember::save($member['member_id'], array('core' => $core));
     //-----------------------------------------
     // Clear out any passy change stuff
     //-----------------------------------------
     $this->DB->delete('validating', 'member_id=' . $this->registry->member()->getProperty('member_id') . ' AND lost_pass=1');
     //-----------------------------------------
     // Run member sync
     //-----------------------------------------
     IPSLib::runMemberSync('onLogin', $member);
     //-----------------------------------------
     // Redirect them to either the board
     // index, or where they came from
     //-----------------------------------------
     if (!empty($this->request['return'])) {
         $return = urldecode($this->request['return']);
         if (strpos($return, "http://") === 0 || strpos($return, "https://") === 0) {
             return array($this->registry->getClass('class_localization')->words['partial_login'], $return);
         }
     }
     //-----------------------------------------
     // Still here?
     //-----------------------------------------
     //return array( $this->registry->getClass('class_localization')->words['partial_login'], str_replace( '?&', '?', $url . '&s=' . $session_id ) );
     return array($this->registry->getClass('class_localization')->words['partial_login'], str_replace('?&', '?', $url));
 }
コード例 #5
0
 /**
  * Set up a member
  *
  * @return	@e void
  */
 protected static function setUpMember()
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $cache = ipsRegistry::cache()->getCache('group_cache');
     //-----------------------------------------
     // Unpack cache
     //-----------------------------------------
     if (isset(self::$data_store['members_cache'])) {
         self::$data_store['_cache'] = IPSMember::unpackMemberCache(self::$data_store['members_cache']);
     } else {
         self::$data_store['_cache'] = array();
     }
     if (!isset(self::$data_store['_cache']['friends']) or !is_array(self::$data_store['_cache']['friends'])) {
         self::$data_store['_cache']['friends'] = array();
     }
     //-----------------------------------------
     // Unpack ignored users
     //-----------------------------------------
     if (isset(self::$data_store['ignored_users'])) {
         self::$data_store['_ignoredUsers'] = @unserialize(self::$data_store['ignored_users']);
     } else {
         self::$data_store['_ignoredUsers'] = array();
     }
     //-----------------------------------------
     // Set up main 'display' group
     //-----------------------------------------
     if (is_array($cache[self::$data_store['member_group_id']])) {
         self::$data_store = array_merge(self::$data_store, $cache[self::$data_store['member_group_id']]);
     }
     //-----------------------------------------
     // Work out permissions
     //-----------------------------------------
     self::$data_store = self::instance()->setUpSecondaryGroups(self::$data_store);
     /* Ensure we don't have a ,, string */
     self::$data_store['org_perm_id'] = IPSText::cleanPermString(self::$data_store['org_perm_id']);
     self::instance()->perm_id = !empty(self::$data_store['org_perm_id']) ? self::$data_store['org_perm_id'] : self::$data_store['g_perm_id'];
     self::instance()->perm_id_array = explode(",", self::instance()->perm_id);
     //-----------------------------------------
     // Synchronise the last visit and activity times if
     // we have some in the member profile
     //-----------------------------------------
     if (!self::$data_store['last_activity']) {
         self::$data_store['last_activity'] = IPS_UNIX_TIME_NOW;
     }
     //-----------------------------------------
     // If there hasn't been a cookie update in 2 hours,
     // we assume that they've gone and come back
     //-----------------------------------------
     if (!self::$data_store['last_visit']) {
         //-----------------------------------------
         // No last visit set, do so now!
         //-----------------------------------------
         ipsRegistry::DB()->update('members', array('last_visit' => self::$data_store['last_activity'], 'last_activity' => IPS_UNIX_TIME_NOW), "member_id=" . self::$data_store['member_id'], true);
         self::$data_store['last_visit'] = self::$data_store['last_activity'];
     } else {
         if (IPS_UNIX_TIME_NOW - self::$data_store['last_activity'] > 300) {
             //-----------------------------------------
             // If the last click was longer than 5 mins ago and this is a member
             // Update their profile.
             //-----------------------------------------
             $be_anon = IPSMember::isLoggedInAnon(self::$data_store);
             ipsRegistry::DB()->update('members', array('login_anonymous' => "{$be_anon}&1", 'last_activity' => IPS_UNIX_TIME_NOW), 'member_id=' . self::$data_store['member_id'], true);
         }
     }
     //-----------------------------------------
     // Group promotion based on time since joining
     //-----------------------------------------
     /* Are we checking for auto promotion? */
     if (self::$data_store['g_promotion'] != '-1&-1') {
         /* Are we checking for post based auto incrementation? 0 is post based, 1 is date based, so...  */
         if (self::$data_store['gbw_promote_unit_type']) {
             list($gid, $gdate) = explode('&', self::$data_store['g_promotion']);
             if ($gid > 0 and $gdate > 0) {
                 if (self::$data_store['joined'] <= time() - $gdate * 86400) {
                     IPSMember::save(self::$data_store['member_id'], array('core' => array('member_group_id' => $gid)));
                     /* Now reset the members group stuff */
                     self::$data_store = array_merge(self::$data_store, $cache[$gid]);
                     self::$data_store = self::instance()->setUpSecondaryGroups(self::$data_store);
                     self::instance()->perm_id = !empty(self::$data_store['org_perm_id']) ? self::$data_store['org_perm_id'] : self::$data_store['g_perm_id'];
                     self::instance()->perm_id_array = explode(",", self::instance()->perm_id);
                 }
             }
         }
     }
 }
コード例 #6
0
 /**
  * Reset a member if they are logged in
  *
  * @return	@e void
  */
 protected function _resetMember()
 {
     if ($this->memberData['member_id']) {
         $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/handlers/han_login.php', 'han_login');
         $this->han_login = new $classToLoad($this->registry);
         $this->han_login->init();
         //-----------------------------------------
         // Set some cookies
         //-----------------------------------------
         IPSCookie::set("member_id", "0");
         IPSCookie::set("pass_hash", "0");
         if (is_array($_COOKIE)) {
             foreach ($_COOKIE as $cookie => $value) {
                 if (stripos($cookie, $this->settings['cookie_id'] . "ipbforum") !== false) {
                     IPSCookie::set(str_replace($this->settings['cookie_id'], "", $cookie), '-', -1);
                 }
             }
         }
         //-----------------------------------------
         // Logout callbacks...
         //-----------------------------------------
         $this->han_login->logoutCallback($this->memberData);
         //-----------------------------------------
         // Do it..
         //-----------------------------------------
         $this->member->sessionClass()->convertMemberToGuest();
         $privacy = intval(IPSMember::isLoggedInAnon($this->memberData));
         IPSMember::save($this->memberData['member_id'], array('core' => array('login_anonymous' => "{$privacy}&0", 'last_activity' => IPS_UNIX_TIME_NOW)));
     }
 }
コード例 #7
0
 /**
  * Returns an array of active users
  *
  * @return	array
  */
 public function getActiveUserDetails()
 {
     $active = array('TOTAL' => 0, 'NAMES' => array(), 'GUESTS' => 0, 'MEMBERS' => 0, 'ANON' => 0);
     if ($this->settings['show_active'] && $this->memberData['gbw_view_online_lists']) {
         if (!$this->settings['au_cutoff']) {
             $this->settings['au_cutoff'] = 15;
         }
         //-----------------------------------------
         // Get the users from the DB
         //-----------------------------------------
         $cut_off = $this->settings['au_cutoff'] * 60;
         $time = time() - $cut_off;
         $rows = array();
         $ar_time = time();
         if ($this->memberData['member_id']) {
             $rows = array($ar_time . '.' . md5(microtime()) => array('id' => 0, 'login_type' => IPSMember::isLoggedInAnon($this->memberData), 'running_time' => $ar_time, 'seo_name' => $this->memberData['members_seo_name'], 'member_id' => $this->memberData['member_id'], 'member_name' => $this->memberData['members_display_name'], 'member_group' => $this->memberData['member_group_id']));
         }
         $this->DB->build(array('select' => 's.id, s.member_id, s.member_name, s.seo_name, s.login_type, s.running_time, s.member_group, s.uagent_type', 'from' => array('sessions' => 's'), 'where' => "running_time > {$time}", 'add_join' => array(array('select' => 'm.member_banned', 'from' => array('members' => 'm'), 'where' => 'm.member_id=s.member_id', 'type' => 'left'))));
         $this->DB->execute();
         //-----------------------------------------
         // FETCH...
         //-----------------------------------------
         while ($r = $this->DB->fetch()) {
             $rows[$r['running_time'] . '.' . $r['id']] = $r;
         }
         krsort($rows);
         //-----------------------------------------
         // cache all printed members so we
         // don't double print them
         //-----------------------------------------
         $cached = array();
         foreach ($rows as $result) {
             //-----------------------------------------
             // Skip Banned
             //-----------------------------------------
             if ($result['member_banned']) {
                 continue;
             }
             //-----------------------------------------
             // Bot?
             //-----------------------------------------
             if (isset($result['uagent_type']) && $result['uagent_type'] == 'search') {
                 /* Skipping bot? */
                 if (!$this->settings['spider_active']) {
                     continue;
                 }
                 //-----------------------------------------
                 // Seen bot of this type yet?
                 //-----------------------------------------
                 if (!$cached[$result['member_name']]) {
                     $active['NAMES'][] = IPSMember::makeNameFormatted($result['member_name'], $result['member_group']);
                     $cached[$result['member_name']] = 1;
                 } else {
                     //-----------------------------------------
                     // Yup, count others as guest
                     //-----------------------------------------
                     $active['GUESTS']++;
                 }
             } else {
                 if (!$result['member_id'] or !$result['member_name']) {
                     $active['GUESTS']++;
                 } else {
                     if (empty($cached[$result['member_id']])) {
                         $cached[$result['member_id']] = 1;
                         $result['member_name'] = IPSMember::makeNameFormatted($result['member_name'], $result['member_group']);
                         /* Reset login type in case the board/group setting got changed */
                         $result['login_type'] = IPSMember::isLoggedInAnon(array('login_anonymous' => $result['login_type']), $result['member_group']);
                         if ($result['login_type']) {
                             if ($this->memberData['g_access_cp'] || $this->memberData['member_id'] == $result['member_id']) {
                                 $active['NAMES'][] = IPSMember::makeProfileLink($result['member_name'], $result['member_id'], $result['seo_name']) . "*";
                                 $active['ANON']++;
                             } else {
                                 $active['ANON']++;
                             }
                         } else {
                             $active['MEMBERS']++;
                             $active['NAMES'][] = IPSMember::makeProfileLink($result['member_name'], $result['member_id'], $result['seo_name']);
                         }
                     }
                 }
             }
         }
         $active['TOTAL'] = $active['MEMBERS'] + $active['GUESTS'] + $active['ANON'];
         $this->users_online = $active['TOTAL'];
     }
     $this->lang->words['active_users'] = sprintf($this->lang->words['active_users'], $this->settings['au_cutoff']);
     return $active;
 }
コード例 #8
0
ファイル: view.php プロジェクト: ConnorChristie/GrabViews
 /**
  * Adds a recent visitor to ones profile
  *
  * @param	array 				Member information
  * @param	integer				Member id to add
  * @return	boolean
  * @since	IPB 2.2.0.2006-7-31
  */
 protected function _addRecentVisitor($member = array(), $member_id_to_add = 0)
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $member_id_to_add = intval($member_id_to_add);
     $found = 0;
     $_recent_visitors = array();
     //-----------------------------------------
     // Check...
     //-----------------------------------------
     if (!$member_id_to_add) {
         return false;
     }
     /* Logged in anonymously? */
     if (IPSMember::isLoggedInAnon($this->memberData)) {
         return false;
     }
     //-----------------------------------------
     // Sort out data...
     //-----------------------------------------
     $recent_visitors = unserialize($member['pp_last_visitors']);
     if (!is_array($recent_visitors) or !count($recent_visitors)) {
         $recent_visitors = array();
     }
     foreach ($recent_visitors as $_time => $_id) {
         if ($_id == $member_id_to_add) {
             $found = 1;
             continue;
         } else {
             $_recent_visitors[$_time] = $_id;
         }
     }
     $recent_visitors = $_recent_visitors;
     krsort($recent_visitors);
     //-----------------------------------------
     // No more than 10
     //-----------------------------------------
     if (!$found) {
         if (count($recent_visitors) > 5) {
             $_tmp = array_pop($recent_visitors);
         }
     }
     //-----------------------------------------
     // Add the visit
     //-----------------------------------------
     $recent_visitors[time()] = $member_id_to_add;
     krsort($recent_visitors);
     //-----------------------------------------
     // Update profile...
     //-----------------------------------------
     if ($member['pp_member_id']) {
         $this->DB->update('profile_portal ', array('pp_last_visitors' => serialize($recent_visitors)), 'pp_member_id=' . $member['member_id'], true);
     } else {
         $this->DB->insert('profile_portal ', array('pp_member_id' => $member['member_id'], 'pp_last_visitors' => serialize($recent_visitors)), true);
     }
     return true;
 }
コード例 #9
0
ファイル: stats.php プロジェクト: mover5/imobackup
 /**
  * Show the forum leaders
  *
  * @return	@e void		[Outputs to screen]
  */
 protected function _showLeaders()
 {
     /* Load language */
     $this->lang->loadLanguageFile(array('public_online', 'public_profile'), 'members');
     /* Init */
     $st = intval($this->request['st']);
     $perpage = 25;
     $group_ids = array();
     $member_ids = array();
     $members = array();
     $forumsMembers = array();
     $pagination = '';
     $mids = array();
     $location_info = array();
     $whereClause = array();
     /* Work out who our super mods / mods aer */
     foreach ($this->cache->getCache('group_cache') as $i) {
         if ($i['g_is_supmod']) {
             $group_ids[$i['g_id']] = '*';
         } elseif ($i['g_access_cp']) {
             $group_ids[$i['g_id']] = array();
         }
     }
     $modCache = $this->cache->getCache('moderators');
     $modCache = is_array($modCache) && count($modCache) ? $modCache : array();
     foreach ($modCache as $i) {
         if ($i['is_group'] && !$this->caches['group_cache'][$i['group_id']]['gbw_hide_leaders_page']) {
             if (isset($group_ids[$i['group_id']])) {
                 if (is_array($group_ids[$i['group_id']])) {
                     $group_ids[$i['group_id']][$i['forum_id']] = ipsRegistry::getClass('class_forums')->forum_by_id[$i['forum_id']]['name'];
                 }
             } else {
                 $group_ids[$i['group_id']] = array($i['forum_id'] => ipsRegistry::getClass('class_forums')->forum_by_id[$i['forum_id']]['name']);
             }
         } else {
             if ($i['member_id']) {
                 $member_ids[$i['member_id']] = $i['member_id'];
                 $forumsMembers[$i['member_id']][$i['forum_id']] = ipsRegistry::getClass('class_forums')->forum_by_id[$i['forum_id']]['name'];
             }
         }
     }
     /* Custom Fields */
     $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/customfields/profileFields.php', 'customProfileFields');
     $custom_fields_class = new $classToLoad();
     //-----------------------------------------
     // Get em
     //-----------------------------------------
     /* Got groups? */
     if (count($group_ids)) {
         $whereClause[] = $this->DB->buildWherePermission(array_keys($group_ids), 'm.member_group_id', FALSE);
     }
     /* Got members? */
     if (count($member_ids)) {
         $whereClause[] = $this->DB->buildWherePermission(array_keys($member_ids), 'm.member_id', FALSE);
     }
     /* So we got something? If not skip the whole thing.. */
     if (count($whereClause)) {
         /* Get a count */
         $count = $this->DB->buildAndFetch(array('select' => 'count(*) as dracula', 'from' => array('members' => 'm'), 'where' => implode(' OR ', $whereClause)));
         if ($count['dracula']) {
             /* Sort out pagination */
             $pagination = $this->registry->output->generatePagination(array('totalItems' => $count['dracula'], 'itemsPerPage' => $perpage, 'currentStartValue' => $st, 'baseUrl' => "app=forums&module=extras&section=stats&do=leaders"));
             /* Fetch the ones we want */
             $this->DB->build(array('select' => 'm.*, m.member_id as my_member_id', 'from' => array('members' => 'm'), 'add_join' => array(array('select' => 'pp.*', 'from' => array('profile_portal' => 'pp'), 'where' => 'pp.pp_member_id=m.member_id', 'type' => 'left'), array('select' => 'pf.*', 'from' => array('pfields_content' => 'pf'), 'where' => 'pf.member_id=m.member_id', 'type' => 'left')), 'where' => implode(' OR ', $whereClause), 'order' => 'm.members_display_name', 'limit' => array($st, $perpage)));
             $e = $this->DB->execute();
             while ($r = $this->DB->fetch($e)) {
                 /* Reset member ID just in case.. */
                 $r['member_id'] = $r['my_member_id'];
                 $members[$r['member_id']] = IPSMember::buildDisplayData($r);
             }
             /* Now fetch session data */
             $this->DB->build(array('select' => '*', 'from' => 'sessions', 'where' => 'member_id IN (' . implode(',', array_keys($members)) . ')'));
             $this->DB->execute();
             while ($r = $this->DB->fetch()) {
                 if (!$r['id'] or IPSMember::isLoggedInAnon($members[$r['member_id']])) {
                     $location_info[$r['member_id']] = '';
                 } else {
                     $location_info[$r['member_id']] = IPSMember::getLocation($r);
                 }
             }
             //-----------------------------------------
             // Display
             //-----------------------------------------
             foreach ($members as $k => $member) {
                 $forums = isset($member_ids[$member['member_id']]) ? $member_ids[$member['member_id']] : array();
                 if ($forums == '*') {
                     $forums = $this->lang->words['leader_all_forums'];
                 } else {
                     $forums = array();
                     foreach ($group_ids as $gid => $fs) {
                         if (IPSMember::isInGroup($member, $gid)) {
                             if ($fs == '*') {
                                 $forums = $this->lang->words['leader_all_forums'];
                                 break;
                             } else {
                                 foreach ($fs as $f_id => $f_name) {
                                     if (!isset($forums[$f_id]) && $this->registry->getClass('class_forums')->forumsCheckAccess($f_id, 0, 'forum', array(), true)) {
                                         $forums[$f_id] = $f_name;
                                     }
                                 }
                             }
                         }
                     }
                     /* Now merge in member specific */
                     if (!is_string($forums) && !empty($forumsMembers[$member['member_id']])) {
                         foreach ($forumsMembers[$member['member_id']] as $f_id => $f_name) {
                             if (!isset($forums[$f_id]) && $this->registry->getClass('class_forums')->forumsCheckAccess($f_id, 0, 'forum', array(), true)) {
                                 $forums[$f_id] = $f_name;
                             }
                         }
                     }
                 }
                 /* Do not list if the user cannot see the forums this mod is a mod of - Bug report 36929 */
                 if (empty($forums)) {
                     unset($members[$k]);
                     continue;
                 }
                 $members[$k]['forums'] = $forums;
                 $members[$k]['online_extra'] = isset($location_info[$k]['online_extra']) ? $location_info[$k]['online_extra'] : '';
                 $members[$k]['last_active'] = $members[$k]['member_id'] == $this->memberData['member_id'] ? IPS_UNIX_TIME_NOW : ($members[$k]['online_extra'] ? $members[$k]['last_activity'] : $members[$k]['last_visit']);
             }
         }
     }
     $this->output .= $this->registry->getClass('output')->getTemplate('stats')->group_strip($this->lang->words['forum_leaders'], $members, $pagination);
     $this->registry->output->setTitle($this->lang->words['forum_leaders'] . ' - ' . ipsRegistry::$settings['board_name']);
     $this->registry->output->addNavigation($this->lang->words['forum_leaders'], '');
 }
コード例 #10
0
ファイル: publicSessions.php プロジェクト: mover5/imobackup
 /**
  * Create a member session
  *
  * @access	protected
  * @return	boolean		Created successfully
  */
 protected function _createMemberSession()
 {
     if (self::$data_store['member_id']) {
         //-----------------------------------------
         // Remove the defunct sessions
         //-----------------------------------------
         $this->_destroySessions("member_id=" . self::$data_store['member_id']);
         $this->session_id = md5(uniqid(microtime(), true) . $this->_member->ip_address . $this->_userAgent);
         //-----------------------------------------
         // Get module settings
         //-----------------------------------------
         $vars = $this->_getLocationSettings();
         //-----------------------------------------
         // Get useragent stuff
         // Do this before the do_update return for editor
         //-----------------------------------------
         $uAgent = $this->_processUserAgent('create');
         //-----------------------------------------
         // Force data
         //-----------------------------------------
         $this->session_data = array('uagent_key' => $uAgent['uagent_key'], 'uagent_version' => $uAgent['uagent_version'], 'uagent_type' => $uAgent['uagent_type'], 'uagent_bypass' => $uAgent['uagent_bypass'], 'id' => $this->session_id);
         //-----------------------------------------
         // Still update?
         //-----------------------------------------
         if (!$this->do_update) {
             return false;
         }
         IPSDebug::addMessage("Creating MEMBER session: " . $this->session_id);
         //-----------------------------------------
         // Insert the new session
         //-----------------------------------------
         $data = array('id' => $this->session_id, 'member_name' => self::$data_store['members_display_name'], 'seo_name' => IPSMember::fetchSeoName(self::$data_store), 'member_id' => intval(self::$data_store['member_id']), 'member_group' => self::$data_store['member_group_id'], 'login_type' => IPSMember::isLoggedInAnon(self::$data_store), 'running_time' => IPS_UNIX_TIME_NOW, 'ip_address' => $this->_member->ip_address, 'browser' => $this->_userAgent, 'in_error' => 0, 'current_appcomponent' => $this->current_appcomponent, 'current_module' => $this->current_module, 'current_section' => $this->current_section, 'location_1_type' => isset($vars['location_1_type']) ? $vars['location_1_type'] : '', 'location_1_id' => isset($vars['location_1_id']) ? intval($vars['location_1_id']) : 0, 'location_2_type' => isset($vars['location_2_type']) ? $vars['location_2_type'] : '', 'location_2_id' => isset($vars['location_2_id']) ? intval($vars['location_2_id']) : 0, 'location_3_type' => isset($vars['location_3_type']) ? $vars['location_3_type'] : '', 'location_3_id' => isset($vars['location_3_id']) ? intval($vars['location_3_id']) : 0, 'uagent_key' => $uAgent['uagent_key'], 'uagent_version' => $uAgent['uagent_version'], 'uagent_type' => $uAgent['uagent_type'], 'uagent_bypass' => intval($uAgent['uagent_bypass']));
         $this->DB->setDataType('member_name', 'string');
         $this->DB->insert('sessions', $data, true);
         //-----------------------------------------
         // If this is a member, update their last visit times, etc.
         //-----------------------------------------
         if (time() - self::$data_store['last_activity'] > $this->settings['session_expiration']) {
             //-----------------------------------------
             // Reset the topics read cookie..
             //-----------------------------------------
             list($be_anon, $loggedin) = explode('&', self::$data_store['login_anonymous']);
             $update = array('login_anonymous' => "{$be_anon}&1", 'last_visit' => self::$data_store['last_activity'], 'last_activity' => IPS_UNIX_TIME_NOW);
             //-----------------------------------------
             // Fix up the last visit/activity times.
             //-----------------------------------------
             self::$data_store['last_visit'] = self::$data_store['last_activity'];
             self::$data_store['last_activity'] = time();
         }
         IPSCookie::set("member_id", self::$data_store['member_id'], 1);
         IPSCookie::set("pass_hash", self::$data_store['member_login_key'], $this->settings['login_key_expire'] ? 0 : 1, $this->settings['login_key_expire']);
         //-----------------------------------------
         // IPS Connect
         // @link http://community.invisionpower.com/resources/bugs.html/_/ip-board/ipsconnect-cookie-expiring-and-not-renewing-with-the-forums-cookie-r42160
         //-----------------------------------------
         foreach ($this->caches['login_methods'] as $k => $data) {
             if ($data['login_folder_name'] == 'ipsconnect' and $data['login_enabled']) {
                 $ipsConnectSettings = unserialize($data['login_custom_config']);
                 if (IPSCookie::get("ipsconnect_" . md5($this->settings['board_url'] . '/interface/ipsconnect/ipsconnect.php'), FALSE)) {
                     IPSCookie::set("ipsconnect_" . md5($ipsConnectSettings['master_url']), IPSCookie::get("ipsconnect_" . md5($ipsConnectSettings['master_url']), FALSE), $this->settings['login_key_expire'] ? 0 : 1, $this->settings['login_key_expire'], FALSE, FALSE);
                 }
             }
         }
         if (IPSCookie::get("ipsconnect_" . md5($this->settings['board_url'] . '/interface/ipsconnect/ipsconnect.php'), FALSE)) {
             IPSCookie::set("ipsconnect_" . md5($this->settings['board_url'] . '/interface/ipsconnect/ipsconnect.php'), IPSCookie::get("ipsconnect_" . md5($this->settings['board_url'] . '/interface/ipsconnect/ipsconnect.php'), FALSE), $this->settings['login_key_expire'] ? 0 : 1, $this->settings['login_key_expire'], FALSE, FALSE);
         }
         $update['member_login_key_expire'] = $this->settings['login_key_expire'] ? time() + $this->settings['login_key_expire'] * 86400 : 0;
         IPSMember::save(self::$data_store['member_id'], array('core' => $update));
     } else {
         $this->_createGuestSession();
     }
     /* Before this function is called, a guest is set up via ipsRegistry::setMember(0)
        We want to override this now to provide search engine settings for the 'member' */
     if ($uAgent['uagent_type'] == 'search') {
         self::setSearchEngine($uAgent);
         /* Reset some data */
         $this->session_type = 'cookie';
         //$this->session_id   = "";
     }
     /* Set type */
     self::$data_store['_sessionType'] = 'create';
     return true;
 }
コード例 #11
0
ファイル: api.php プロジェクト: ConnorChristie/GrabViews-Live
 /**
  * Returns a list (with buildProfilePhoto set) of users in an application
  *
  * @param	string		$app		Application folder/key
  * @param	array		$options	Array of options to add/override checks for the query
  * @return	@e array Array of found sessions (members, guests, bots, anons)
  *
  * <b>Filters:</b>
  * - cutoff:		Specify a different cutoff time rather than using the default setting
  * - addJoins:		Add more joins for the query
  * - addWhere:		Add more checks for the 'where' part of the query (everything is joined with ' AND ')
  * - overrideWhere:	Specify manually the 'where' part of the query, the query must be already compiled
  * - overrideGroup:	if set to true the check against the 'gbw_view_online_lists' group setting is skipped
  * - skipParsing:	If set to true the parseOnlineEntries from coreExtensions is NOT executed
  * - includeErrors:	If set to true the in_error=1 lines are loaded as well from the table
  * - excludeViewer:	If set to true skips loading the row for the current session_id, it is required to load the current member viewing the page as sessions table is not updated at this point yet but only on destruct
  * 
  * <b>Example Usage:</b>
  * @code
  * $onlineUsers = $this->getUsersIn( 'forums', array( 'cutoff' => 90 ) );
  * $onlineUsers = $this->getUsersIn( 'forums', array( 'cutoff' => 90, 'addJoins' => array( ... ), 'addWhere' => array( ... ) ) );
  * $onlineUsers = $this->getUsersIn( 'forums', array( 'overrideWhere' => "s.current_appcomponent='forums' AND (s.running_time > TIME_A OR s.running_time < TIME_B)" ) );
  * @endcode
  */
 public function getUsersIn($app, $options = array())
 {
     /* App we're checking is not even installed? */
     if (!IPSLib::appIsInstalled($app, false)) {
         return array();
     }
     /* Can't view online lists? */
     if (empty($options['overrideGroup']) && !$this->memberData['gbw_view_online_lists']) {
         return array();
     }
     /* Init vars and check options */
     $return = array('stats' => array('total' => 0, 'members' => 0, 'guests' => 0, 'bots' => 0, 'anon' => 0), 'rows' => array('members' => array(), 'bots' => array(), 'guests' => array(), 'anon' => array()), 'names' => array());
     $cutoff = empty($options['cutoff']) ? $this->settings['au_cutoff'] : $options['cutoff'];
     $limit = time() - $cutoff * 60;
     $rows = array();
     $NOWJIM = IPS_UNIX_TIME_NOW;
     $cached = array();
     /* Sort joins */
     $_joins = array(array('select' => 'm.*', 'from' => array('members' => 'm'), 'where' => 'm.member_id=s.member_id', 'type' => 'left'));
     if (isset($options['addJoins']) && is_array($options['addJoins']) && count($options['addJoins'])) {
         $_joins = array_merge($_joins, $options['addJoins']);
     }
     /* Sort where.. override? */
     if (!empty($options['overrideWhere']) && is_string($options['overrideWhere'])) {
         $where = $options['overrideWhere'];
     } else {
         /* Normal where */
         $where = array("s.current_appcomponent='" . $this->DB->addSlashes($app) . "'", 's.running_time > ' . $limit);
         /* Load error rows? */
         if (empty($options['includeErrors'])) {
             $where[] = 's.in_error=0';
         }
         /* Add more where parts */
         if (isset($options['addWhere']) && is_array($options['addWhere']) && count($options['addWhere'])) {
             $where = array_merge($where, $options['addWhere']);
         }
         $where = implode(' AND ', $where);
     }
     /* We're a viewer too? Get our session separately */
     $_extraWhere = empty($options['excludeViewer']) ? "s.id='{$this->member->session_id}' OR " : '';
     /* Dee bee */
     $this->DB->build(array('select' => 's.*, s.id as row_session_id', 'from' => array('sessions' => 's'), 'where' => "{$_extraWhere}({$where})", 'add_join' => $_joins));
     $this->DB->execute();
     while ($session = $this->DB->fetch()) {
         /* Reset for possible bad joins */
         $session['id'] = $session['row_session_id'];
         /* Update our own session properly? */
         if ($session['id'] == $this->member->session_id) {
             $session = array_merge($session, $this->member->sessionClass()->returnCurrentSession());
         }
         $rows[$session['running_time'] . '.' . $session['id']] = $session;
     }
     /* No rows? */
     if (!count($rows)) {
         return $return;
     }
     krsort($rows);
     /* Are we parsing online entries or want only the names */
     if (empty($options['skipParsing'])) {
         /* Process them */
         $filename = IPSLib::getAppDir($app) . '/extensions/coreExtensions.php';
         if (is_file($filename)) {
             $classToLoad = IPSLib::loadLibrary($filename, 'publicSessions__' . $app, $app);
             $loader = new $classToLoad();
             if (method_exists($loader, 'parseOnlineEntries')) {
                 $rows = $loader->parseOnlineEntries($rows);
             }
         }
         /* No rows? */
         if (!count($rows)) {
             return $return;
         }
     }
     /* Sort through */
     foreach ($rows as $id => $result) {
         $last_date = $this->registry->getClass('class_localization')->getTime($result['running_time']);
         /* ROBOT - or DODOT! */
         if (strstr($result['id'], '_session')) {
             $botname = preg_replace('/^(.+?)=/', "\\1", $result['id']);
             if (!$cached['srch_' . $result['member_name']]) {
                 $result = IPSMember::buildProfilePhoto($result);
                 $result['parsedMemberName'] = $result['member_name'];
                 $return['rows']['bots'][$result['id']] = $result;
                 $return['names'][$result['id']] = $result['parsedMemberName'];
                 $cached['srch_' . $result['member_name']]['count'] = 1;
             } else {
                 $cached['srch_' . $result['member_name']]['count']++;
             }
             $return['stats']['bots']++;
         } else {
             if (!$result['member_id']) {
                 $result = IPSMember::buildProfilePhoto(0);
                 $result['parsedMemberName'] = $this->lang->words['global_guestname'];
                 $return['rows']['guests'][$result['id']] = $result;
                 $return['stats']['guests']++;
             } else {
                 if (empty($cached[$result['member_id']])) {
                     $cached[$result['member_id']] = 1;
                     $result = IPSMember::buildProfilePhoto($result);
                     $result['parsedMemberName'] = IPSMember::makeNameFormatted($result['member_name'], $result['member_group']);
                     /* Reset login type in case the board/group setting got changed */
                     $result['login_type'] = IPSMember::isLoggedInAnon(array('login_anonymous' => $result['login_type']), $result['member_group_id']);
                     if ($result['login_type']) {
                         if ($this->memberData['g_access_cp'] || $this->memberData['member_id'] == $result['member_id']) {
                             $result['parsedMemberName'] = IPSMember::makeProfileLink($result['parsedMemberName'], $result['member_id'], $result['seo_name']);
                             $result['parsedMemberName'] .= '*';
                             # Add anonymous asterisk
                             $return['rows']['anon'][$result['id']] = $result;
                             $return['names'][$result['id']] = $result['parsedMemberName'];
                         }
                         $return['stats']['anon']++;
                     } else {
                         $result['parsedMemberName'] = IPSMember::makeProfileLink($result['parsedMemberName'], $result['member_id'], $result['seo_name']);
                         $return['rows']['members'][$result['id']] = $result;
                         $return['names'][$result['id']] = $result['parsedMemberName'];
                         $return['stats']['members']++;
                     }
                 }
             }
         }
     }
     /* Process bots */
     foreach ($cached as $name => $val) {
         if ($val['count'] && substr($name, 0, 5) == 'srch_') {
             foreach ($return['rows']['bots'] as $row) {
                 if ($row['parsedMemberName'] == substr($name, 5)) {
                     $return['rows']['bots'][$row['id']]['parsedMemberName'] .= ' (' . $val['count'] . ')';
                     $return['rows']['bots'][$row['id']]['member_name'] = $return['rows']['bots'][$row['id']]['parsedMemberName'];
                     $return['names'][$row['id']] = $return['rows']['bots'][$row['id']]['parsedMemberName'];
                     break;
                 }
             }
         }
     }
     $return['stats']['total'] = intval($return['stats']['bots']) + intval($return['stats']['guests']) + intval($return['stats']['anon']) + intval($return['stats']['members']);
     return $return;
 }