// start the output buffering for main content ob_start(); // if there is login action if (isset($_POST['logMeIn'])) { $username = trim(strip_tags($_POST['userName'])); $password = trim(strip_tags($_POST['passWord'])); if (!$username or !$password) { echo '<script type="text/javascript">alert(\'' . __('Please supply valid username and password') . '\');</script>'; } else { // destroy previous session set in OPAC simbio_security::destroySessionCookie(null, SENAYAN_MEMBER_SESSION_COOKIES_NAME, SENAYAN_WEB_ROOT_DIR, false); require SENAYAN_BASE_DIR . 'admin/default/session.inc.php'; // regenerate session ID to prevent session hijacking session_regenerate_id(true); // create logon class instance $logon = new admin_logon($username, $password); if ($logon->adminValid($dbs)) { // set cookie admin flag setcookie('admin_logged_in', true, time() + 14400, SENAYAN_WEB_ROOT_DIR); // write log utility::writeLogs($dbs, 'staff', $username, 'Login', 'Login success for user ' . $username . ' from address ' . $_SERVER['REMOTE_ADDR']); echo '<script type="text/javascript">'; echo 'alert(\'' . __('Welcome to Library Automation, ') . $logon->real_name . '\');'; echo 'location.href = \'admin/index.php\';'; echo '</script>'; exit; } else { // write log utility::writeLogs($dbs, 'staff', $username, 'Login', 'Login FAILED for user ' . $username . ' from address ' . $_SERVER['REMOTE_ADDR']); // message $msg = '<script type="text/javascript">';
} } // uname $_uname = isset($_COOKIE['uname']) ? trim($_COOKIE['uname']) : ''; // update password if (isset($_POST['updatePassword'])) { $cpasswd = trim($_POST['currentPasswd']); $passwd = trim($_POST['newPasswd']); $passwd2 = trim($_POST['newPasswd2']); if (empty($cpasswd)) { utility::jsAlert(__('Current password can not be empty!')); } else { if ($passwd and $passwd2 and $passwd !== $passwd2) { utility::jsAlert(__('Password confirmation does not match. See if your Caps Lock key is on!')); } else { $logon = new admin_logon($_uname, $cpasswd); if ($logon->changePasswd($dbs, $passwd2)) { // write log utility::writeLogs($dbs, 'staff', $_uname, 'Login', 'Change password SUCCESS for user ' . $_uname . ' from address ' . $_SERVER['REMOTE_ADDR']); // clear cookie setcookie('token', '', time() - 3600, SWB); setcookie('uname', '', time() - 3600, SWB); echo '<script type="text/javascript">'; echo 'alert("Password Updated. Please log in again!");'; echo 'location.href = \'index.php?p=login\';'; echo '</script>'; exit; } else { // write log utility::writeLogs($dbs, 'staff', $_uname, 'Login', 'Change password FAILED for user ' . $_uname . ' from address ' . $_SERVER['REMOTE_ADDR']); utility::jsAlert($logon->errors);