Esempio n. 1
0
/**
 * @param int $userId
 */
function preventMultipleLogin($userId)
{
    $table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE);
    $userId = intval($userId);
    if (api_get_settings('prevent_multiple_simultaneous_login') === 'true') {
        if (!empty($userId) && !api_is_anonymous()) {
            $isFirstLogin = Session::read('first_user_login');
            if (empty($isFirstLogin)) {
                $sql = "SELECT login_id FROM {$table}\n                        WHERE login_user_id = " . $userId . " LIMIT 1";
                $result = Database::query($sql);
                $loginData = array();
                if (Database::num_rows($result)) {
                    $loginData = Database::fetch_array($result);
                }
                $userIsReallyOnline = user_is_online($userId);
                // Trying double login.
                if (!empty($loginData) && $userIsReallyOnline == true) {
                    session_regenerate_id();
                    Session::destroy();
                    header('Location: ' . api_get_path(WEB_PATH) . 'index.php?loginFailed=1&error=multiple_connection_not_allowed');
                    exit;
                } else {
                    // First time
                    Session::write('first_user_login', 1);
                }
            }
        }
    }
}
Esempio n. 2
0
                    }
                } else {
                    $user_info = api_get_user_info($user_id);
                }
            } else {
                $user_info = api_get_user_info($user_id);
            }
        }
    }
}
if ($user_info['user_id'] == api_get_user_id()) {
    $isSelfUser = true;
} else {
    $isSelfUser = false;
}
$userIsOnline = user_is_online($user_id);
$libpath = api_get_path(LIBRARY_PATH);
require_once $libpath . 'magpierss/rss_fetch.inc';
$ajax_url = api_get_path(WEB_AJAX_PATH) . 'message.ajax.php';
$socialAjaxUrl = api_get_path(WEB_AJAX_PATH) . 'social.ajax.php';
$javascriptDir = api_get_path(LIBRARY_PATH) . 'javascript/';
api_block_anonymous_users();
$locale = api_get_language_isocode();
// Add Jquery scroll pagination plugin
$htmlHeadXtra[] = api_get_js('jscroll/jquery.jscroll.js');
// Add Jquery Time ago plugin
$htmlHeadXtra[] = api_get_asset('jquery-timeago/jquery.timeago.js');
$timeAgoLocaleDir = $javascriptDir . 'jquery-timeago/locales/jquery.timeago.' . $locale . '.js';
if (file_exists($timeAgoLocaleDir)) {
    $htmlHeadXtra[] = api_get_js('jquery-timeago/locales/jquery.timeago.' . $locale . '.js');
}
Esempio n. 3
0
     $send_mail = Display::return_icon('mail_send_na.png', get_lang('SendMail'), '', ICON_SIZE_MEDIUM);
 }
 echo $send_mail;
 if (!empty($student_id) && !empty($_GET['course'])) {
     // Only show link to connection details if course and student were defined in the URL
     echo '<a href="access_details.php?student=' . $student_id . '&course=' . Security::remove_XSS($_GET['course']) . '&origin=' . $origin . '&cidReq=' . Security::remove_XSS($_GET['course']) . '&id_session=' . $sessionId . '">' . Display::return_icon('statistics.png', get_lang('AccessDetails'), '', ICON_SIZE_MEDIUM) . '</a>';
 }
 if (api_can_login_as($student_id)) {
     echo '<a href="' . api_get_path(WEB_CODE_PATH) . 'admin/user_list.php?action=login_as&user_id=' . $student_id . '&sec_token=' . $token . '">' . Display::return_icon('login_as.png', get_lang('LoginAs'), null, ICON_SIZE_MEDIUM) . '</a>';
 }
 if ($alloAssignSkill) {
     echo Display::url(Display::return_icon('skill-badges.png', get_lang('AssignSkill'), null, ICON_SIZE_MEDIUM), api_get_path(WEB_CODE_PATH) . 'badge/assign.php?' . http_build_query(['user' => $student_id]));
 }
 echo '</div>';
 // is the user online ?
 if (user_is_online($_GET['student'])) {
     $online = get_lang('Yes');
 } else {
     $online = get_lang('No');
 }
 // get average of score and average of progress by student
 $avg_student_progress = $avg_student_score = 0;
 $course_code = isset($_GET['course']) ? Security::remove_XSS($_GET['course']) : null;
 if (CourseManager::is_user_subscribed_in_course($user_info['user_id'], $course_code, true)) {
     $avg_student_progress = Tracking::get_avg_student_progress($user_info['user_id'], $course_code, array(), $sessionId);
     //the score inside the Reporting table
     $avg_student_score = Tracking::get_avg_student_score($user_info['user_id'], $course_code, array(), $sessionId);
 }
 $avg_student_progress = round($avg_student_progress, 2);
 // time spent on the course
 $courseInfo = api_get_course_info($course_code);
Esempio n. 4
0
function getPlayerStorage($player_id, $storage, $online = false)
{
    if ($online) {
        $online = user_is_online($player_id);
    }
    if (!$online) {
        // user is offline (false), we may safely proceed:
        $player_id = (int) $player_id;
        $storage = (int) $storage;
        return mysql_select_single("SELECT `value` FROM `player_storage` WHERE `key`='{$storage}' AND `player_id`='{$player_id}';");
    } else {
        return false;
    }
}
Esempio n. 5
0
include_once $_SERVER['DOCUMENT_ROOT'] . '/Contacts/models/debug.php';
include_once $_SERVER['DOCUMENT_ROOT'] . '/Contacts/views/alerts.php';
include_once $_SERVER['DOCUMENT_ROOT'] . '/Contacts/models/user/sel_user.php';
include_once $_SERVER['DOCUMENT_ROOT'] . '/Contacts/models/user/upt_user.php';
$debug = isset($_SESSION['debug']) && $_SESSION['debug'] == "on" ? 1 : 0;
if ($debug) {
    dump($_SESSION, "SESSION");
    dump($_POST, "POST");
}
$ip = client_ip();
$confid = isset($_POST['cnf']) ? trim($_POST['cnf']) : 0;
$userid = isset($_SESSION['userid']) ? $_SESSION['userid'] : 0;
$timeout = isset($_SESSION['timeout']) ? $_SESSION['timeout'] : 0;
$username = isset($_SESSION['username']) ? $_SESSION['username'] : 0;
$isLoggedIn = isset($_SESSION['isLoggedIn']) ? $_SESSION['isLoggedIn'] : 0;
if ($isLoggedIn && $userid && ($Records = user_is_online($userid, $username, $confid, $ip, $_SERVER['HTTP_USER_AGENT'], $timeout))) {
    update_user_status($userid, $isLoggedIn, $ip, $_SERVER['HTTP_USER_AGENT']);
    $action = isset($_POST['act']) ? $_POST['act'] : 0;
    switch ($action) {
        case 'get_persons':
            $items = isset($_POST['itm']) ? $_POST['itm'] : 0;
            $page = isset($_POST['pg']) ? $_POST['pg'] : 0;
            include_once $_SERVER['DOCUMENT_ROOT'] . '/Contacts/views/content/persons.php';
            break;
        case 'get_person':
            $personid = isset($_POST['pid']) ? $_POST['pid'] : 0;
            include_once $_SERVER['DOCUMENT_ROOT'] . '/Contacts/views/content/person.php';
            break;
        case 'add_person':
            echo "Add person code here!";
            include_once $_SERVER['DOCUMENT_ROOT'] . '/Contacts/models/content/ins_person.php';
Esempio n. 6
0
    /**
     * Shows the avatar block in social pages
     *
     * @param string highlight link possible values: group_add, home, messages, messages_inbox, messages_compose ,messages_outbox ,invitations, shared_profile, friends, groups search
     * @param int group id
     * @param int user id
     *
     */
    public static function show_social_avatar_block($show = '', $group_id = 0, $user_id = 0)
    {
        if (empty($user_id)) {
            $user_id = api_get_user_id();
        }

        $show_groups = array(
            'groups',
            'group_messages',
            'messages_list',
            'group_add',
            'mygroups',
            'group_edit',
            'member_list',
            'invite_friends',
            'waiting_list',
            'browse_groups'
        );

        // get count unread message and total invitations
        $count_unread_message = MessageManager::get_number_of_messages(true);
        $count_unread_message = !empty($count_unread_message) ? Display::badge($count_unread_message) : null;

        $number_of_new_messages_of_friend = SocialManager::get_message_number_invitation_by_user_id(api_get_user_id());
        $group_pending_invitations = GroupPortalManager::get_groups_by_user(api_get_user_id(), GROUP_USER_PERMISSION_PENDING_INVITATION, false);
        $group_pending_invitations = count($group_pending_invitations);
        $total_invitations = $number_of_new_messages_of_friend + $group_pending_invitations;
        $total_invitations = (!empty($total_invitations) ? Display::badge($total_invitations) : '');
        $showUserImage = user_is_online($user_id) || api_is_platform_admin();

        $html = '<div>';
        if (in_array($show, $show_groups) && !empty($group_id)) {
            //--- Group image
            $group_info = GroupPortalManager::get_group_data($group_id);
            $big = GroupPortalManager::get_picture_group($group_id, $group_info['picture_uri'], 160, GROUP_IMAGE_SIZE_BIG);

            $html .= '<div class="social-content-image">';
            $html .= '<div class="well social-background-content">';
            $html .= Display::url('<img src='.$big['file'].' class="social-groups-image" /> </a><br /><br />', api_get_path(WEB_CODE_PATH).'social/groups.php?id='.$group_id);
            if (GroupPortalManager::is_group_admin($group_id, api_get_user_id())) {
                $html .= '<div id="edit_image" class="hidden_message" style="display:none">
                            <a href="'.api_get_path(WEB_CODE_PATH).'social/group_edit.php?id='.$group_id.'">'.
                    get_lang('EditGroup').'</a></div>';
            }
            $html .= '</div>';
            $html .= '</div>';
        } else {
            if ($showUserImage) {
                $img_array = UserManager::get_user_picture_path_by_id($user_id, 'web', true, true);
            } else {
                $img_array = UserManager::get_user_picture_path_by_id(null, 'web', true, true);
            }
            $big_image = UserManager::get_picture_user($user_id, $img_array['file'], '', USER_IMAGE_SIZE_BIG);
            $big_image = $big_image['file'].'?'.uniqid();
            $normal_image = $img_array['dir'].$img_array['file'].'?'.uniqid();

            //--- User image

            $html .= '<div class="well social-background-content">';
            if ($img_array['file'] != 'unknown.jpg') {
                $html .= '<a class="thumbnail thickbox" href="'.$big_image.'"><img src='.$normal_image.' /> </a>';
            } else {
                $html .= '<img src='.$normal_image.' width="110px" />';
            }
            if (api_get_user_id() == $user_id) {
                $html .= '<div id="edit_image" class="hidden_message" style="display:none">';
                $html .= '<a href="'.api_get_path(WEB_CODE_PATH).'auth/profile.php">'.get_lang('EditProfile').'</a></div>';
            }
            $html .= '</div>';
        }
        $html .= '</div>';
        return $html;
    }
Esempio n. 7
0
    }
    unset($_SESSION['userid']);
    unset($_SESSION['timeout']);
    unset($_SESSION['username']);
    unset($_SESSION['isLoggedIn']);
    unset($_SESSION['becomeLogin']);
}
$confid = isset($_GET['cnf']) ? $_GET['cnf'] : 0;
$userid = isset($_SESSION['userid']) ? $_SESSION['userid'] : 0;
$timeout = isset($_SESSION['timeout']) ? $_SESSION['timeout'] : 0;
$username = isset($_SESSION['username']) ? $_SESSION['username'] : 0;
$isLoggedIn = isset($_SESSION['isLoggedIn']) ? $_SESSION['isLoggedIn'] : 0;
$becomeLogin = isset($_SESSION['becomeLogin']) ? $_SESSION['becomeLogin'] : 0;
$ip = client_ip();
if ($becomeLogin) {
    unset($_SESSION['becomeLogin']);
    $timeout = get_option("timeout", $userid);
    $_SESSION['timeout'] = $timeout ? $timeout : 1;
    //dump($_SESSION,"SESSION");
} else {
    if ($isLoggedIn) {
        if (NULL == ($Records = user_is_online($userid, $username, trim($confid), $ip, $_SERVER['HTTP_USER_AGENT'], $timeout))) {
            /*Logout user*/
            logout();
            $isLoggedIn = 0;
            $userid = 0;
            $username = 0;
            $_SESSION['warning'] = "<b>activity.php:</b><br />The timeout of your connection has ended, you have disconnected automatically!";
        }
    }
}
Esempio n. 8
0
/**
 * Finds all the information about a user.
 * If no parameter is passed you find all the information about the current user.
 * @param int  $user_id
 * @param bool $checkIfUserOnline
 * @param bool $showPassword
 * @param bool $loadExtraData
 *
 * @return array $user_info user_id, lastname, firstname, username, email, etc
 * @author Patrick Cool <*****@*****.**>
 * @author Julio Montoya
 * @version 21 September 2004
 */
function api_get_user_info($user_id = 0, $checkIfUserOnline = false, $showPassword = false, $loadExtraData = false)
{
    if (empty($user_id)) {
        $userFromSession = Session::read('_user');
        if (isset($userFromSession)) {
            return _api_format_user($userFromSession);
        }
        // @todo trigger an exception here
        return false;
    }
    $sql = "SELECT * FROM " . Database::get_main_table(TABLE_MAIN_USER) . "\n            WHERE id='" . intval($user_id) . "'";
    $result = Database::query($sql);
    if (Database::num_rows($result) > 0) {
        $result_array = Database::fetch_array($result);
        if ($checkIfUserOnline) {
            $use_status_in_platform = user_is_online($user_id);
            $result_array['user_is_online'] = $use_status_in_platform;
            $user_online_in_chat = 0;
            if ($use_status_in_platform) {
                $user_status = UserManager::get_extra_user_data_by_field($user_id, 'user_chat_status', false, true);
                if (intval($user_status['user_chat_status']) == 1) {
                    $user_online_in_chat = 1;
                }
            }
            $result_array['user_is_online_in_chat'] = $user_online_in_chat;
        }
        if ($loadExtraData) {
            $fieldValue = new ExtraFieldValue('user');
            $result_array['extra'] = $fieldValue->getAllValuesForAnItem($user_id);
        }
        $user = _api_format_user($result_array, $showPassword);
        return $user;
    }
    return false;
}
Esempio n. 9
0
/**
 * Finds all the information about a user.
 * If no parameter is passed you find all the information about the current user.
 * @param int $user_id
 * @return array $user_info user_id, lastname, firstname, username, email, etc
 * @author Patrick Cool <*****@*****.**>
 * @author Julio Montoya
 * @version 21 September 2004
 */
function api_get_user_info($user_id = '', $check_if_user_is_online = false, $show_password = false)
{
    if ($user_id == '') {
        return _api_format_user($GLOBALS['_user']);
    }
    $sql = "SELECT * FROM " . Database::get_main_table(TABLE_MAIN_USER) . "\n            WHERE user_id='" . intval($user_id) . "'";
    $result = Database::query($sql);
    if (Database::num_rows($result) > 0) {
        $result_array = Database::fetch_array($result);
        if ($check_if_user_is_online) {
            $use_status_in_platform = user_is_online($user_id);
            $result_array['user_is_online'] = $use_status_in_platform;
            $user_online_in_chat = 0;
            if ($use_status_in_platform) {
                $user_status = UserManager::get_extra_user_data_by_field($user_id, 'user_chat_status', false, true);
                if (intval($user_status['user_chat_status']) == 1) {
                    $user_online_in_chat = 1;
                }
            }
            $result_array['user_is_online_in_chat'] = $user_online_in_chat;
        }
        $user = _api_format_user($result_array, $show_password);
        return $user;
    }
    return false;
}
Esempio n. 10
0
admin_only($user_data);
// start
// PREP: Create a function that echos player skills
function playerSkill($skills, $id)
{
    if (!$skills) {
        return 0;
    } else {
        return $skills[$id]['value'];
    }
}
// UPDATE SKILLS POST
if (isset($_POST['pid']) && (int) $_POST['pid'] > 0) {
    $pid = (int) $_POST['pid'];
    if ($config['TFSVersion'] != 'TFS_10') {
        $status = user_is_online($pid);
    } else {
        $status = user_is_online_10($pid);
    }
    if (!$status) {
        // New player level
        $level = (int) $_POST['level'];
        // Fetch stat gain for vocation
        $statgain = $config['vocations_gain'][(int) $_POST['vocation']];
        if ((int) $_POST['vocation'] !== 0) {
            // Fetch base level and stats:
            $baselevel = $config['level'];
            $basehealth = $config['health'];
            $basemana = $config['mana'];
            $basecap = $config['cap'];
        } else {
Esempio n. 11
0
        // get the path,width and height from original picture
        $big_image = $image_array['dir'].'big_'.$image_array['file'];
        $big_image_size = api_getimagesize($big_image);
        $big_image_width= $big_image_size['width'];
        $big_image_height= $big_image_size['height'];
        $url_big_image = $big_image.'?rnd='.time();

        if ($image_array['file']=='unknown.jpg') {
            echo '<img src="'.$image_array['dir'].$image_array['file'].'" border="1">';
        } else {
            echo '<input type="image" src="'.$image_array['dir'].$image_array['file'].'" onclick="return show_image(\''.$url_big_image.'\',\''.$big_image_width.'\',\''.$big_image_height.'\');"/>';
        }

        // is the user online?
        $online ='';
        if (user_is_online($userIdViewed)) {
            $online = Display::return_icon('online.gif', get_lang('OnLine'),array('style'=>'with="8"; height="8"'));
        }

        //DISPLAY TABLE HEADING
        if ($origin == 'learnpath') { $allowedToEditDef=false; $is_allowedToTrack=false; }

        //"<td>",get_lang('Tutor'),"</td>\n",
        echo	"<table width=\"80%\" border=\"0\">",

        "<tr align=\"center\" bgcolor=\"#E6E6E6\">\n",
            "<td align=\"left\">".get_lang('Name')."</td>\n",
            "<td width=\"20%\" align=\"left\">".get_lang('Description')."</td>\n";

        if ($current_session_id) {
            if ($user_info_viewed['status'] == COURSEMANAGER) {