set('language',$c_language); debug(DEBUG,"Language found, loading file: $c_language.php"); require("lang/".$c_language.".php"); $language_found = true; } else{ setcookie("jorge_language",$language_support[default_language][0],time()+2592000); $sess->set('language',$language_support[default_language][0]); debug(DEBUG,"Language not found in selection, using defaults"); require('lang/'.$language_support[default_language][0].'.php'); } } // get client addr $rem_adre = $_SERVER['REMOTE_ADDR']; // something for mac users $mac_user = get_user_agent($_SERVER); // location $location=$_SERVER['PHP_SELF']; // init html helper $html = new render_html(); if (!preg_match("/index.php/i",$location)) { if ($sess->get('vhost') === null) { header("Location: index.php?act=logout"); } if (array_key_exists($sess->get('vhost'), $vhosts) === false) { header("Location: index.php?act=logout"); } define(XMPP_HOST,$sess->get('vhost')); $rpc_host = check_rpc_server($vhosts[XMPP_HOST],$rpc_port); debug(DEBUG,"Active RPC host: $rpc_host"); // in case no RPC servers are available stop jorge if ($rpc_host===false) { print "
Currently service is unavailable. Please try again later.
Please logout
"; exit; } // create rpc object $ejabberd_rpc = new rpc_connector("$rpc_host","$rpc_port",XMPP_HOST); $xmpp_host = str_replace(".","_", XMPP_HOST); } else{ // check if selected host exist in configuration if (array_key_exists($_POST['vhost'], $vhosts) === true) { $rpc_host = check_rpc_server($vhosts[$_POST['vhost']],$rpc_port); debug(DEBUG,"Selecting RPC server during login: $rpc_host"); if ($rpc_host === false) { print "
Currently service is unavailable. Please try again later.
Please logout
"; exit; } else { define(XMPP_HOST,$_POST['vhost']); $ejabberd_rpc = new rpc_connector("$rpc_host","$rpc_port",XMPP_HOST); $xmpp_host = str_replace(".","_", XMPP_HOST); } } else{ unset($_POST['inpLogin']); unset($_POST['inpPass']); // Try to recreate db object... if ($_GET['act'] === "logout") { if ($sess->get('vhost')!="") { $xmpp_host = str_replace(".","_", $sess->get('vhost')); } } } } // 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]); } } // we need user_id but only if we are not in not_enabled mode: if(!preg_match("/not_enabled.php/i",$_SERVER['PHP_SELF'])) { $db->get_user_id(TOKEN); $user_id = $db->result->user_id; // create user_id instance $db->set_user_id($user_id); } } // check if user have admin rights if (in_array(TOKEN, $vhosts_admins[XMPP_HOST]) === true) { define(ADMIN_NAME,TOKEN); } // run only for admins if (TOKEN === ADMIN_NAME) { $time_start=getmicrotime(); } // If language not set or not found in cookie, set default language if (preg_match("/index.php/i",$location) OR preg_match("/not_enabled.php/i",$location)) { // Set defaults only if language was not selected if ($language_found !== true) { if (is_language_supported($_COOKIE["jorge_language"],$language_support) === true) { debug(DEBUG,"Setting language according to cookie"); require('lang/'.$_COOKIE["jorge_language"].'.php'); $sess->set('language',$_COOKIE["jorge_language"]); } else { debug(DEBUG,"Language cookie not found, using defaults"); require('lang/'.$language_support[default_language][0].'.php'); $sess->set('language',$language_support[default_language][0]); } } } // Get language from session $lang=$sess->get('language'); $html->headers(' '); if (preg_match("/main.php/i",$location)) { $html->headers(' '); } $html->headers(' '); // prevent loading includes as long as user is not admin. if (TOKEN==ADMIN_NAME) { $html->headers(''); } $html->headers(' Jorge Beta '); ?>