$val2) $_GET[$val1] = htmlspecialchars($val2); // define used vairables define_var(array('language','id','id2','query','login_user','login_pass','show')); $data['body'] = ''; $data['name'] = ''; $data['error'] = array(); $data['success'] = array(); // check for wrong logins if ((!is_numeric($_SESSION['kannel_wrong'])) or ($_SESSION['kannel_wrong']=='')) $_SESSION['kannel_wrong'] = 0; $db = @mysql_connect($sql_hostname,$sql_username,$sql_password) or die(header('location: '.$base['url'].'/closed.html')); mysql_select_db($sql_database,$db) or die(header('location: '.$base['url'].'/closed.html')); // in first visit update statistics and take user IP if ($_SESSION['kannel_ip'] == ''){ log_action('1'); $_SESSION['kannel_ip'] = getenv("REMOTE_ADDR"); if ($_SESSION['kannel_ip'] == '') $_SESSION['kannel_ip'] = $_SERVER['REMOTE_HOST']; if ($_SESSION['kannel_ip'] == '') $_SESSION['kannel_ip'] = $_SERVER['REMOTE_ADDR']; if ($_SESSION['kannel_ip'] == '') $_SESSION['kannel_ip'] = 'unkown'; } // values from url if ($_GET['query'] != ''){ $pieces = explode("/", $_GET['query']); for ($i = 0; $i < count($pieces); $i++) $_GET['id'.$i] = $pieces[$i]; } if (isset($_GET['id1'])) $_GET['id'] = $_GET['id1']; // take all languages $data['lang'] = array(); $result = q("select id,name,meta_lang from kannel_settings_meta order by order_nr asc"); while($myrow = a($result)) $data['lang'][$myrow['id']] = $myrow; // if no language, then choose one if ($_SESSION['kannel_lang'] == ''){ if ((isset($_COOKIE['kannel_lang'])) and ($_COOKIE['kannel_lang']!='')){ $_SESSION['kannel_lang'] = $_COOKIE['kannel_lang']; }else{ $_SESSION['kannel_lang'] = '1'; } setcookie('kannel_lang',$_SESSION['kannel_lang'],time()+864000); } // change language if ($_GET['language'] != ''){ foreach($data['lang'] as $val){ if ($_GET['language']==$val['meta_lang']) $_SESSION['kannel_lang'] = $val['id']; } setcookie('kannel_lang',$_SESSION['kannel_lang'],time()+864000); } // if not logged in, then make possible facebook login and take user data if ($_SESSION['kannel_id'] == ''){ require_once('include/facebook.php'); $facebook = new Facebook(array( 'appId' => $base['facebook']['appId'], 'secret' => $base['facebook']['secret'], )); $user = $facebook->getUser(); if ($user){ try { $facebook_user_profile = $facebook->api('/me'); } catch (FacebookApiException $e) { error_log($e); $user = null; } }else{ $loginUrl = $facebook->getLoginUrl(array('scope' => 'email')); $loginUrl = str_replace("&", "&",$loginUrl); } // if not logged in and we have data about you if ($user){ require_once('include/facebook_login.php'); } } // login user if (($_POST['login_user'] != '') and ($_POST['login_pass']!='') and ($_SESSION['kannel_wrong'] < 3)){ $myrow = aq("select id from kannel_users where username=? and pass=? limit 1",array(strtolower($_POST['login_user']),$_POST['login_pass'])); if (isset($myrow['id'])){ $_SESSION['kannel_wrong'] = 0; $_SESSION['kannel_id'] = $myrow['id']; log_action('9'); q("insert into kannel_log_logins set user_id=?, user_ip=?, time_login=?",array($_SESSION['kannel_id'],$_SESSION['kannel_ip'],date('Y-m-d H:i:s'))); }else{ $_SESSION['kannel_wrong']++; header('location: '.$base['url'].'/'.$data['lang'][$_SESSION['kannel_lang']]['meta_lang'].'/remember/?error=1'); exit; } } // logout user if ($_GET['id'] == 'logout'){ $_GET['id'] = ''; $_SESSION['kannel_id'] = ''; if (isset($_SESSION['fb_'.$base['facebook']['appId'].'_code'])) $_SESSION['fb_'.$base['facebook']['appId'].'_code'] = ''; if (isset($_SESSION['fb_'.$base['facebook']['appId'].'_access_token'])) $_SESSION['fb_'.$base['facebook']['appId'].'_access_token'] = ''; if (isset($_SESSION['fb_'.$base['facebook']['appId'].'_user_id'])) $_SESSION['fb_'.$base['facebook']['appId'].'_user_id'] = ''; header('location: '.$base['url']); exit; } // take user information if ($_SESSION['kannel_id'] != ''){ q("update kannel_users set time_last=? where id=? limit 1",array(date("Y-m-d H:i:s"),$_SESSION['kannel_id'])); $me = aq("select * from kannel_users where id=? limit 1",array($_SESSION['kannel_id'])); if ($me['status'] == 0){ $_SESSION['kannel_id'] = ''; if (isset($_SESSION['fb_'.$base['facebook']['appId'].'_code'])) $_SESSION['fb_'.$base['facebook']['appId'].'_code'] = ''; if (isset($_SESSION['fb_'.$base['facebook']['appId'].'_access_token'])) $_SESSION['fb_'.$base['facebook']['appId'].'_access_token'] = ''; if (isset($_SESSION['fb_'.$base['facebook']['appId'].'_user_id'])) $_SESSION['fb_'.$base['facebook']['appId'].'_user_id'] = ''; header('location: '.$base['url'].'/'.$data['lang'][$_SESSION['kannel_lang']]['meta_lang'].'/user_closed'); exit; } } // take metadata information $data['metadata'] = aq("select * from kannel_settings_meta where id=? limit 1",array($_SESSION['kannel_lang'])); // take ad text $ad_text = aq("select * from kannel_settings where tag='ad_text' limit 1"); // if you first time come, then what page i show if ($_GET['id'] == '') $_GET['id'] = 'front'; // take language file if (file_exists('upload/lang_'.$_SESSION['kannel_lang'].'.php')) require_once('upload/lang_'.$_SESSION['kannel_lang'].'.php'); // inner data -> php if (($_GET['id'] != '') and (file_exists('scripts/'.$_GET['id'].'.php'))) include('scripts/'.$_GET['id'].'.php'); // inner data -> design if (($_GET['id'] != '') and (file_exists('tpl/'.$_GET['id'].'_tpl.php'))){ ob_start(); include('tpl/'.$_GET['id'].'_tpl.php'); $data['body'] = ob_get_contents(); ob_end_clean(); } // global design if ($data['body'] == ''){ ob_start(); include('tpl/coming_tpl.php'); $data['body'] = ob_get_contents(); ob_end_clean(); } ob_start(); include('img/base_tpl.php'); $data['body'] = ob_get_contents(); ob_end_clean(); // debug for hidden errors $errors = 0; if ($debug =='1'){ if ((strpos($data['body'], 'Warning:')) !== false){ echo('WARNING!!!
'); $errors++; } if ((strpos($data['body'], 'Parse error:')) !== false){ echo('PARSE ERRROR!!!
'); $errors++; } if ((strpos($data['body'], 'Notice:')) !== false){ echo('NOTICE!!!
'); $errors++; } } // close databse connection mysql_close(); // remove things, what are not needed $data['body'] = str_replace("", " -->",$data['body']); $data['body'] = preg_replace('//', '', $data['body']); $data['body'] = str_replace("\t", " ", $data['body']); $data['body'] = str_replace(" ", " ",$data['body']); $data['body'] = str_replace(" ", " ",$data['body']); $data['body'] = str_replace(" ", " ",$data['body']); $data['body'] = str_replace(" ", " ",$data['body']); $data['body'] = str_replace(" \r\n", "\r\n",$data['body']); $data['body'] = str_replace(" \r", "\r",$data['body']); $data['body'] = str_replace(" \n", "\n",$data['body']); $data['body'] = str_replace("\r\n\r\n\r\n", "\r\n",$data['body']); $data['body'] = str_replace("\r\n\r\n", "\r\n",$data['body']); $data['body'] = str_replace("\r\r\r", "\r",$data['body']); $data['body'] = str_replace("\r\r", "\r",$data['body']); $data['body'] = str_replace("\n\n\n", "\n",$data['body']); $data['body'] = str_replace("\n\n", "\n",$data['body']); echo(trim($data['body'])); ?>