Share » Forums » Developer » Authenticating by IP?

Authenticating by IP?

Authenticating by IP?

Thursday 29 December 2005 1:19:27 am - 1 reply

Modified on Thursday 29 December 2005 11:46:21 am by Petter Arneson

Author Message

Kristian Hole

Friday 30 December 2005 4:15:43 am

Hi

This is a patch for 3.5.1 which allows one specific user to log in from one specific IP. You can probably get some idea about how to do something like you want from this.

--- pre_check.php.orig  2005-04-06 15:24:51.020472000 +0200
+++ pre_check.php       2005-04-06 16:10:16.603120456 +0200
@@ -84,6 +84,21 @@
     $requireUserLogin = ( $ini->variable( "SiteAccessSettings", "RequireUserLogin" ) == "true" );
     $check = null;
     $http =& eZHTTPTool::instance();
+
+       //---LOGINONIP-HACK
+    if ( $ini->hasVariable( 'LoginOnIP', 'IPAddress' ) && $ini->hasVariable( 'LoginOnIP', 'UserID' )
+         && $_SERVER['REMOTE_ADDR'] == trim( $ini->variable( 'LoginOnIP', 'IPAddress' ) ) )
+    {
+        include_once( 'kernel/classes/datatypes/ezuser/ezuser.php' );
+        $userID = ( int ) $ini->variable( 'LoginOnIP', 'UserID' );
+        $user = eZUser::fetch( $userID );
+        if ( ! is_object( $user ) )
+            eZDebug::writeDebug( "Unable to fetch user with id $userID for IP login", "LoginOnIP" );
+        else
+            eZUser::setCurrentlyLoggedInUser( $user, $userID );
+    }
+       //---/LOGINONIP-HACK
+
     if ( !$requireUserLogin )
         return null;
 //     $uri =& $GLOBALS['eZRequestedURI'];

Kristian

http://ez.no/ez_publish/documenta...tricks/show_which_templates_are_used
http://ez.no/doc/ez_publish/techn...te_operators/miscellaneous/attribute

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu