// get client addr $rem_adre = $_SERVER['REMOTE_ADDR']; // get location $location = $_SERVER['PHP_SELF']; // make dotted domaniname $xmpp_host_dotted = str_replace("_", ".", $xmpp_host); // init session $sess = new session(); // db connection: $bazaj = db_e_connect($db_ejabberd); db_connect($mod_logdb); // user name - we hold it in session, lets fetch it... $token = $sess->get('uid_l'); // authentication checks. Ensure if session data is not altered... (only when we are inside Jorge) if (!preg_match("/index.php/i", $location)) { if (check_registered_user($bazaj, $sess) != "t") { header("Location: index.php?act=logout"); exit; } // we need user_id but only if we are not in not_enabled mode: if (!preg_match("/not_enabled.php/i", $_SERVER['PHP_SELF'])) { $user_id = get_user_id($token, $xmpp_host); if (!ctype_digit($user_id)) { print 'Ooops...error(0.1)'; exit; } } // domain check. prevent floating auth between jorge instalations on multiple domains if ($sess->get('host') != $xmpp_host or !$sess->get('host')) { header("Location: index.php?act=logout"); exit;
} } } } // create db_manager object $db = new db_manager(MYSQL_HOST, MYSQL_NAME, MYSQL_USER, MYSQL_PASS, "mysql", "{$xmpp_host}"); $db->set_debug(SQL_DEBUG); // create encryption object $enc = new url_crypt(ENC_KEY); // username (token) define(TOKEN, $sess->get('uid_l')); //debug debug(DEBUG, "User session:" . TOKEN); // authentication checks. Ensure if session data is not altered... (only when we are inside Jorge) if (!preg_match("/index.php/i", $location)) { if (check_registered_user($sess, $ejabberd_rpc, $enc) !== true) { header("Location: index.php?act=logout"); exit; } // Load language file based on current session debug(DEBUG, "Selecting initial language after authentication"); if ($sess->get('language')) { // Validate language setting in session if (is_language_supported($sess->get('language'), $language_support) === true) { debug(DEBUG, "Language selection ok."); require 'lang/' . $sess->get('language') . '.php'; } else { debug(DEBUG, "Language in session was altered! Overwritting value..."); require 'lang/' . $language_support[default_language][0] . '.php'; $sess->set('language', $language_support[default_language][0]); }