示例#1
0
<?php

require_once dirname(__FILE__) . '/vendors/smf/smf_2_api.php';
if (isset($_REQUEST["username"])) {
    $username = rawurldecode($_REQUEST["username"]);
    $outed = true;
    // for debug
    // $isonline=smfapi_isOnline($username)?'T':'F';
    if (smfapi_isOnline($username)) {
        $outed = smfapi_logout($username);
    }
    if (!$outed) {
        echo "<script type='text/javascript'>alert('Sorry! Failed to logout zhaohu forum! Please click logout at zhaohu forum.')</script>";
    }
}
header("Location: http://{$_SERVER['HTTP_HOST']}");
示例#2
0
/**
 * Log user online
 *
 * Logs a user online, if their settings allow it
 *
 * @param string || int $username the username, member id or email of the user
 * @return bool whether they were logged online or not
 * @since  0.1.0
 */
function smfapi_logOnline($username = '')
{
    global $smcFunc, $modSettings;
    $user_data = smfapi_getUserData($username);
    if (!$user_data) {
        return false;
    }
    if (!$user_data['show_online']) {
        return false;
    }
    if (smfapi_isOnline($username)) {
        $do_delete = true;
    } else {
        $do_delete = false;
    }
    $smcFunc['db_query']('', '
        DELETE FROM {db_prefix}log_online
        WHERE ' . ($do_delete ? 'log_time < {int:log_time}' : '') . ($do_delete && !empty($user_data['id_member']) ? ' OR ' : '') . (empty($user_data['id_member']) ? '' : 'id_member = {int:current_member}'), array('current_member' => $user_data['id_member'], 'log_time' => time() - $modSettings['lastActive'] * 60));
    $smcFunc['db_insert']($do_delete ? 'ignore' : 'replace', '{db_prefix}log_online', array('session' => 'string', 'id_member' => 'int', 'id_spider' => 'int', 'log_time' => 'int', 'ip' => 'raw', 'url' => 'string'), array(session_id(), $user_data['id_member'], 0, time(), 'IFNULL(INET_ATON(\'' . (isset($user_data['ip']) ? $user_data['ip'] : '') . '\'), 0)', ''), array('session'));
    // Mark the session as being logged.
    $_SESSION['log_time'] = time();
    // Well, they are online now.
    if (empty($_SESSION['timeOnlineUpdated'])) {
        $_SESSION['timeOnlineUpdated'] = time();
    }
    return true;
}
 /**
  * Short description
  *
  * Long description
  *
  * @param
  * @return
  */
 protected function check_ifOnline()
 {
     try {
         $this->loadApi();
     } catch (Exception $e) {
         throw new \Exception($e->getMessage());
     }
     $this->data = smfapi_isOnline($this->identifier);
 }