Location: PHPKode > projects > MembersGear > membersgear/config/user_and_admin_authentication_check.php
<?php

//user_and_admin_authentication_check.php

if(defined('WEB_URL') and !isLoopBack_check_membersGear()) {
    
      $webUrlParts = parse_url(WEB_URL);
  
    if(isset($webUrlParts['host'])) {
        
        if( trim( $webUrlParts['host'] ) != trim( $_SERVER['HTTP_HOST'] ) ) {
            
            $currentUrl = $_SERVER['REQUEST_URI'];
            
            header('location:' . $webUrlParts['scheme'] .'://' . $webUrlParts['host'] . $_SERVER['REQUEST_URI']); die;
            echo "<script language=\"javascript\" type=\"text/javascript\">";
            echo "window.location.href = '".$webUrlParts['scheme'] .'://' . $webUrlParts['host'] . $_SERVER['REQUEST_URI']."';";
            echo "</script>";
            die;
            
        }  

        
    }
  
  }
  
  global $_MEMBERSGEAR_SESSION;
  
  foreach($_SESSION as $key=>$val){
  
    $_MEMBERSGEAR_SESSION['membersgear_session'][$key]=$val;
  
  }
   
  require_once INCLUDE_DIR."/users_signup_class.php";
  require_once INCLUDE_DIR."/product_class.php"; 
  $users_signup_class =new users_signup_class();
  $productobj=new product_class();
   
   if(isset( $_SESSION[SESSION_PREFIX.'UserID']))
   {
        if($users_signup_class->phpbbStatuscheck())
        {   mysql_select_db(MEMBERSGEAR_DB_NAME);
            $phpBBProduct=phpBB_get_product_id();
            $proId=$productobj->checkForActiveSubscription($_SESSION[SESSION_PREFIX.'UserID'],$phpBBProduct);
            $userDat=$users_signup_class->getUserDataByUserName($_SESSION[SESSION_PREFIX.'UserName']); 
            if($phpBBProduct==$proId)
            {
                
              $password=decrypt($userDat[0]['password'],$userDat[0]['secretsalt']);
              phpBB_Login($userDat[0]['username'],$password);
              mysql_select_db(MEMBERSGEAR_DB_NAME);
             }
              
        }
   
   }
  else
   {
    
      if($users_signup_class->phpbbStatuscheck())
       {
          
          if(strpos($_SERVER['HTTP_REFERER'],"forum")>0)
           {
            
             phpBB_logout(); 
             $_SERVER['REQUEST_URI']='';
              mysql_select_db(MEMBERSGEAR_DB_NAME);    
           } 
       }
       
         $pos=strpos($_SERVER['QUERY_STRING'],'WpRedirectBack');
         if($pos===false)
               $_SERVER['QUERY_STRING']=''; 
         else{
               $redirectStr=substr($_SERVER['QUERY_STRING'],($pos+15));
                //$_SERVER['REQUEST_URI']=$redirectStr;
                $loginbackUrl=WEB_URL."/user_login.php?externalurl=".$redirectStr;
                Redirect($loginbackUrl,true);
               // echo "<script language='javascript' type='text/javascript'>"."window.location.href='".$loginbackUrl."';</script>";
             }  
                    
           /*          if($users_signup_class->wordpressStatuscheck()){  
                     
                              $wordpressReqquiredFile= wordpress_physical_path();

                              $referer=$_SERVER['HTTP_REFERER'];
                              $refererParseUrl=parse_url($referer);
                              $refererHost=$refererParseUrl['host']; 
                              
                              if($refererHost!="" ){      
                                   
                                    $dirWordpress=wordpress_physical_path_dir()."wp-config.php";        
                                    if(file_exists($dirWordpress)){
                              
                                    require_once($dirWordpress); 
                                    assign_sessions();
                                    $url=wordpress_getWordpressUrl(); 
                                    $wordpress_parse_url=parse_url($url);
                                    $wordpress_host=$wordpress_parse_url['host'];

                                
                                     if($refererHost==$wordpress_host){
                                         
                                        wordpress_remove_cookies();
                                         $_SERVER['REQUEST_URI']='';
                                     
                                     }

                                    
                              }   
                              
                        }   
                    
                    } */
   
   } 
                      
    //Validate users if not authenticated 
    if(IsMemberDirectoryRequested())
    {
        if(!$users_config->IsAuthenticated(false))
            Redirect(WEB_URL.'/user_login.php?url='.urlencode($_SERVER['REQUEST_URI']),true);
    }


    //Validate Admins if not authenticated    
    if(IsAdminDirectoryRequested())
    {
        if(!$users_config->IsAuthenticated(true))
            Redirect(WEB_URL.'/admin/admin_login.php?url='.urlencode($_SERVER['REQUEST_URI']),true);
    }   

   if(isset($_SERVER['HTTP_REFERER']))
   {
        if (!(strpos($_SERVER['HTTP_REFERER'],'admin_users_v.php') >= 0 && (isset($_GET['action']) && isset($_GET['username']) && isset($_GET['useremail']))))
        {
            //Redirect User to member page if already authenticated 
            if($users_config->IsAuthenticated(false))
            {
                if(!isset($_GET['url']))
                {
                    if(strpos($_SERVER['REQUEST_URI'],'user_login.php'))
                        Redirect(WEB_URL.'/member/user_default_page.php',true); 
                                
                }
            }
            //Redirect Admin to member page if already authenticated 
            if($users_config->IsAuthenticated(true))
            {
                if(!isset($_GET['url']))
                {
                    if(strpos($_SERVER['REQUEST_URI'],'admin_login.php'))
                        Redirect(WEB_URL.'/admin/index.php',true); 
                                
                }
            }
        } 
   } 
      
      
    Clear_Browser_Cache();
                    
 
?>
Return current item: MembersGear