/** * Effectively logs the user in * @param string $login * @param string $passwd */ function user_login($login, $passwd) { global $input; global $template_folder; global $error; global $ezplayer_url; // 0) Sanity checks if (empty($login) || empty($passwd)) { $error = template_get_message('empty_username_password', get_lang()); view_login_form(); die; } $login_parts = explode("/", $login); // checks if runas if (count($login_parts) == 2) { if (!file_exists('admin.inc')) { $error = "Not admin. runas login failed"; view_login_form(); die; } include 'admin.inc'; //file containing an assoc array of admin users if (!isset($admin[$login_parts[0]])) { $error = "Not admin. runas login failed"; view_login_form(); die; } $_SESSION['user_is_admin'] = true; $_SESSION['user_runas'] = true; } else { if (file_exists('admin.inc')) { include 'admin.inc'; //file containing an assoc array of admin users if (isset($admin[$login])) { $_SESSION['user_is_admin'] = true; } } } $res = checkauth(strtolower($login), $passwd); if (!$res) { $error = checkauth_last_error(); view_login_form(); die; } // 1) Initializing session vars $_SESSION['ezplayer_logged'] = "user_logged"; // "boolean" stating that we're logged $_SESSION['user_login'] = $res['login']; $_SESSION['user_real_login'] = $res['real_login']; $_SESSION['user_full_name'] = $res['full_name']; $_SESSION['user_email'] = $res['email']; $_SESSION['admin_enabled'] = false; //check flash plugin or GET parameter no_flash if (!isset($_SESSION['has_flash'])) { //no noflash param when login //check flash plugin if ($input['has_flash'] == 'N') { $_SESSION['has_flash'] = false; } else { $_SESSION['has_flash'] = true; } } // 2) Initializing the ACLs acl_init($login); // 3) Setting correct language set_lang($input['lang']); // 4) Resetting the template path to the one of the language chosen template_repository_path($template_folder . get_lang()); // 5) Logging the login operation log_append("login"); log_append("user's browser : " . $_SESSION['browser_full']); // lvl, action, browser_name, browser_version, user_os, browser_full_info trace_append(array("1", "login", $_SESSION['browser_name'], $_SESSION['browser_version'], $_SESSION['user_os'], $_SESSION['browser_full'], session_id())); // 6) Displaying the page // view_main(); if (count($_SESSION['first_input']) > 0) { $ezplayer_url .= '/index.php?'; } foreach ($_SESSION['first_input'] as $key => $value) { $ezplayer_url .= "{$key}={$value}&"; } header("Location: " . $ezplayer_url); load_page(); }
/** * Effectively logs the user in * @param string $login * @param string $passwd */ function user_login($login, $passwd) { global $input; global $template_folder; global $error; global $ezmanager_url; // 0) Sanity checks if (empty($login) || empty($passwd)) { $error = template_get_message('empty_username_password', get_lang()); view_login_form(); die; } $login_parts = explode("/", $login); // checks if runas if (count($login_parts) == 2) { if (!file_exists('admin.inc')) { $error = "Not admin. runas login failed"; view_login_form(); die; } include 'admin.inc'; //file containing an assoc array of admin users if (!isset($admin[$login_parts[0]])) { $error = "Not admin. runas login failed"; view_login_form(); die; } } $res = checkauth(strtolower($login), $passwd); if (!$res) { $error = checkauth_last_error(); view_login_form(); die; } // 1) Initializing session vars $_SESSION['podman_logged'] = "LEtimin"; // "boolean" stating that we're logged $_SESSION['user_login'] = $res['login']; $_SESSION['user_real_login'] = $res['real_login']; $_SESSION['user_full_name'] = $res['full_name']; $_SESSION['user_email'] = $res['email']; //check flash plugin or GET parameter no_flash if (!isset($_SESSION['has_flash'])) { //no noflash param when login //check flash plugin if ($input['has_flash'] == 'N') { $_SESSION['has_flash'] = false; } else { $_SESSION['has_flash'] = true; } } // 2) Initializing the ACLs acl_init($login); // 3) Setting correct language set_lang($input['lang']); if (count(acl_authorized_albums_list()) == 0) { error_print_message(template_get_message('not_registered', get_lang()), false); log_append('warning', $res['login'] . ' tried to access ezmanager but doesn\'t have permission to manage any album.'); session_destroy(); view_login_form(); die; } // 4) Resetting the template path to the one of the language chosen template_repository_path($template_folder . get_lang()); // 5) Logging the login operation log_append("login"); // 6) Displaying the page header("Location: " . $ezmanager_url); view_main(); }