Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?
- define('ROOT_PATH', './');
- require_once 'include/header.php';
- if($config['environment'] == "production" && ($_SERVER['SERVER_NAME'] == "scard.klsogo.com.my" || $_SERVER['SERVER_NAME'] == "www.scard.klsogo.com.my")){
- header('Location: https://scard.sogo.com.my/');
- exit();
- }
- //header("Location: https://www.sogo.com.my/maintenance/"); // Under Mainenance
- /*
- $whitelist = array('10.0.43.107','10.0.43.108','10.0.43.109','10.0.43.110','10.0.43.111','10.0.43.112','10.0.43.113','10.0.26.163','10.0.26.70','10.0.26.152','10.0.26.111');
- if (!in_array($_SERVER['REMOTE_ADDR'], $whitelist)){
- header('Location: https://scard.klsogo.com.my/');
- exit();
- }*/
- // Scheduled maintenance
- $maintenance_start = '2018-04-28 23:00:00';
- $maintenance_end = '2018-04-29 01:00:00';
- $today_date = date('Y-m-d H:i:s', strtotime( date('Y-m-d H:i:s') ) );
- $ip_allowed = array("10.3.3.197", "10.3.5.107", "10.0.43.113", "10.3.3.198","10.3.7.242","115.164.93.109",'10.3.3.196','10.3.3.194','10.3.7.242','10.0.26.166','10.0.26.53','10.3.4.86','162.158.26.61','10.3.5.108','10.3.1.234','10.3.4.239',"10.3.5.107");
- //echo $_SERVER['REMOTE_ADDR'];exit();
- if( $today_date >= $maintenance_start && $today_date <= $maintenance_end && !(in_array($_SERVER['REMOTE_ADDR'],$ip_allowed)) ){
- header("Location: https://www.sogo.com.my/maintenance/");
- }
- if( $today_date < $maintenance_start ){
- $start = date('l, jS F g:i A', strtotime($maintenance_start));
- $end = date('l, jS F g:i A', strtotime($maintenance_end));
- $tpl->assign('maintenance', "There will be a scheduled maintenance from ".$start." till ".$end.". Your understanding is much appreciated");
- }
- array_walk($_POST, 'array_striptags');
- $internal_ip = explode('.', $_SERVER['REMOTE_ADDR']);
- if ($internal_ip[0] == '10') {
- $internal = true;
- $tpl->assign('internal', 1);
- }
- if ($_SERVER['SERVER_NAME'] != "scard.sogo.com.my" && $_SERVER['SERVER_NAME'] != "localhost" && $_SERVER['SERVER_NAME'] != "10.0.43.103") {
- //header("Location: https://scard.sogo.com.my/");
- }
- // Log URL of every page load, to allow page resume after user login
- if (isset($_POST['redirect_url']) && $_POST['redirect_url']) {
- if (!isset($_SESSION['redirect']['current'])) {
- $_SESSION['redirect']['previous'] = $_POST['redirect_url'];
- $_SESSION['redirect']['current'] = $_POST['redirect_url'];
- } else if (isset($_SESSION['redirect']['current']) && $_SESSION['redirect']['current'] != $_POST['redirect_url']) {
- $_SESSION['redirect']['previous'] = $_SESSION['redirect']['current'];
- $_SESSION['redirect']['current'] = $_POST['redirect_url'];
- }
- //$user->store_session();
- exit();
- }
- if (isset($_POST['get_redirect_url']) && $_POST['get_redirect_url']) {
- if($config['environment'] == "production") {
- die(json_encode($_SESSION['redirect']));
- } elseif($config['environment'] == "development") {
- die(json_encode(array('previous' => $config['site_path'])));
- }
- }
- // User Session Status & Update
- if (isset($_SESSION['user']['user_id']) && $_SESSION['user']['user_id']) {
- foreach ($_SESSION['user'] as $k => $v) {
- $user_session[$k] = base64_decode($v);
- }
- $user_session['customer_code'] = str_replace(" ", "", $user_session['customer_code']);
- /* $user_session = $user->get_user_info( $user_session['user_id'] );
- if( isset( $user_session['birthdate'] ) && $user_session['birthdate'] )
- $user_session['birthdate'] = date( "d/m/Y", $user_session['birthdate'] ); */
- if (isset($_SESSION["LAST_ACTIVITY"])) {
- if (time() - $_SESSION["LAST_ACTIVITY"] > 1800) { // last request was more than 30 minutes ago
- header("Location: {$config['site_path']}user/log_out");
- } else {
- $_SESSION["LAST_ACTIVITY"] = time(); // update last activity time stamp
- }
- } else {
- $_SESSION["LAST_ACTIVITY"] = time(); // set new activity session
- }
- $tpl->assign("user_session", $user_session);
- // check if session still active or not
- $db->query(sprintf("SELECT * FROM user_session WHERE user_id='%d' AND is_active='1' AND session_id='%s'", $user_session['user_id'], $user_session['session_id']));
- if (!$db->num_rows()) { // user session not active
- header("Location: {$config['site_path']}user/log_out");
- }
- // check if multiple logins exist
- $db->query(sprintf("SELECT * FROM user_session WHERE user_id='%d' AND is_active='1' AND session_id!='%s'", $user_session['user_id'], $user_session['session_id']));
- if ($db->num_rows()) {
- // check if notify is true
- $db->query(sprintf("SELECT * FROM user_session WHERE user_id='%d' AND session_id='%s'", $user_session['user_id'], $user_session['session_id']));
- $session = $db->fetch_array();
- if ($session[0]['notify'] == 1) {
- $tpl->assign('multiple_login', '1');
- }
- }
- //$tpl->assign('multiple_login', '1');
- if ($_SERVER['SERVER_NAME'] != "localhost") {
- // Integration
- include_once 'class/soap.php';
- $soap_c = new Soap();
- $result_expiry_date = $soap_c->callService('U_ChkMemberExpiry', array(
- 'UserID' => 'test1',
- 'password' => 'password',
- 'customer_code' => $user_session['customer_code'],
- 'store' => '',
- 'member_level' => '',
- 'member_type' => '',
- 'gender' => '',
- 'contact_id' => ''
- ));
- //echo '<pre>'; print_r( $result_expiry_date ); echo '</pre>'; die();
- $expiry_date = $result_expiry_date['message']['U_ChkMemberExpiryResult']['diffgram']['NewDataSet']['T']['expiry_date'];
- //$expiry_date = "2013-02-28 12:49:44.987+08:00";
- //die( $expiry_date );
- $url = @$_GET['function'];
- if ((strtotime('now') > strtotime($expiry_date)) && ($url != "show_page" && $url != "summary" && $url != "edit" && $url != "update_account" && $url != "update_preferences" && $url != "renewal" && $url != "renewal_payment" && $url != "renewal_response" && $url != "renewal_complete" && $url != "renewal_fail" && $url != "load_points_info" && $url != "load_cart_info" && $url != "check_voucher" && $url != "load_list_info")) {
- $tpl->assign('url', $url);
- header("Location: {$config['site_path']}scard/renewal");
- } else {
- if ((strtotime('now') < strtotime($expiry_date)) && $user_session['is_temp'] == 1 && ($url != "edit" && $url != "update_account" && $url != "load_points_info" && $url != "load_cart_info")) {
- header("Location: {$config['site_path']}account/edit/password");
- }
- }
- }
- }
- // Body Content Trigger
- if (isset($_GET['mod']) && $_GET['mod']) {
- if ($_GET['mod'] == 'blog' && isset($_GET['page_id']) && $_GET['page_id']) {
- $tpl->assign("content", file_get_contents("{$config['site_path']}blog.php?page_id={$_GET['page_id']}"));
- $tpl->assign("body", $tpl->fetch('blog.tpl'));
- } else {
- // module name recovery for alert_list as global stripslash removed 'alert' from the name
- $_GET['mod'] = ($_GET['mod'] == '_list') ? 'alert_list' : $_GET['mod'];
- $_GET['function'] = ($_GET['function'] == '_list') ? 'alert_list' : $_GET['function'];
- $mod_path = 'module/front/' . $_GET['mod'] . '.php';
- if (file_exists($mod_path)) {
- include_once $mod_path;
- } else {
- $tpl->assign("message_fail", array("$_GET[mod] module not found!"));
- $tpl->assign("body", $tpl->fetch('message.tpl'));
- }
- }
- } else {
- // Banner Generation
- $db->query(sprintf("SELECT * FROM banner WHERE location='%s' AND status='1' ORDER BY sort", 'home_main'));
- $banner = $db->fetch_array();
- $tpl->assign('banner', $banner);
- // Banner Generation
- $db->query(sprintf("SELECT * FROM banner WHERE location='%s' AND status='1' ORDER BY sort LIMIT 3", 'home_sub'));
- $banner_sub = $db->fetch_array();
- $tpl->assign('banner_sub', $banner_sub);
- $tpl->assign("body", $tpl->fetch('home.tpl') . @$config['site_home']);
- }
- $db->query(sprintf("SELECT * FROM category WHERE parent_id='0' AND is_active='1' ORDER BY sort"));
- $category = $db->fetch_array();
- $tpl->assign('category', $category);
- // Main Menu Generation
- $db->query(sprintf("SELECT * FROM selection WHERE category='Page' AND value!=''"));
- if ($db->num_rows()) {
- $selection = $db->fetch_array();
- for ($i = 0; $i < count($selection); $i++) {
- $db->query(sprintf("SELECT * FROM page WHERE category='%s' AND unlisted='0' ORDER BY sort", $selection[$i]['value']));
- if ($db->num_rows()) {
- $tpl->assign(str_replace(array(' ', '&'), array('_', 'and'), strtolower($selection[$i]['value'])) . "_menu", $db->fetch_array());
- }
- }
- }
- // Footer Generation
- $db->query(sprintf("SELECT * FROM hotline ORDER BY `column`"));
- $tpl->assign('hotline', $db->fetch_array());
- $db->query(sprintf("SELECT * FROM footer ORDER BY `column`"));
- $footer_links = $db->fetch_array();
- if( $config['environment'] == 'development' ){
- foreach ($footer_links as $k => $v) {
- $footer_links[$k]['content'] = str_replace("//scard.sogo.com.my/", "//10.0.43.103/mwp-mobile/", $v['content']);
- }
- }
- $tpl->assign('footer', $footer_links);
- if (isset($_GET['mobile'])) {
- $tpl->display('index2.tpl');
- }
- $tpl->display('index.tpl');
- require_once 'include/footer.php';
Add Comment
Please, Sign In to add comment