FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » FUDforum » FUDforum Suggestions » API function to authenticate users
Show: Today's Messages :: Unread Messages :: Show Polls :: Message Navigator
| Subscribe to topic | Bookmark topic 
Switch to threaded view of this topic Create a new topic Submit Reply
API function to authenticate users [message #27175] Mon, 29 August 2005 13:16 Go to next message
naudefj is currently offline  naudefj   South Africa
Messages: 3624
Registered: December 2004
Karma: 17
Senior Member
Administrator
Core Developer
remove from buddy list
ignore all messages by this user
Can you please add a function like this to "forum_login.php" or "fudapi.inc.php"?

<?php
function external_fud_authenticate($username$password) {
  ...
  return 
0;  // Invalid username or password
  
...
  return 
$user_id;  // Username and password is valid
}
?>


Best regards.

Frank
Re: API function to authenticate users [message #27176 is a reply to message #27175] Mon, 29 August 2005 13:36 Go to previous messageGo to next message
Ilia is currently offline  Ilia   Canada
Messages: 13241
Registered: January 2002
Karma: 0
Senior Member
Administrator
Core Developer
add to buddy list
ignore all messages by this user
Sure,
http://cvs.prohost.org/c/index.cgi/FUDforum/chngview?cn=7278


FUDforum Core Developer
Re: API function to authenticate users [message #27178 is a reply to message #27176] Mon, 29 August 2005 15:15 Go to previous messageGo to next message
naudefj is currently offline  naudefj   South Africa
Messages: 3624
Registered: December 2004
Karma: 17
Senior Member
Administrator
Core Developer
remove from buddy list
ignore all messages by this user
That was quick! Thank you very much.

Can you please also apply this patch (untested):

--- forum_login.php.old 2005-08-29 14:11:34.000000000 -0500
+++ forum_login.php     2005-08-29 14:12:06.000000000 -0500
@@ -49,7 +49,7 @@
        eval(str_replace('<?php', '', substr_replace($data, '', strpos($data, 'require'))));

        /* db.inc needs certain vars inside the global scope to work, so we export them */
-       foreach (array('FUD_OPT_1', 'DBHOST', 'DBHOST_USER', 'DBHOST_PASSWORD', 'DBHOST_DBNAME') as $v) {
+       foreach (array('FUD_OPT_1', 'DBHOST', 'DBHOST_USER', 'DBHOST_PASSWORD', 'DBHOST_DBNAME', 'DATA_DIR') as $v) {
                $GLOBALS[$v] = $$v;
        }


Best regards.

Frank
Re: API function to authenticate users [message #27179 is a reply to message #27178] Mon, 29 August 2005 15:19 Go to previous messageGo to next message
Ilia is currently offline  Ilia   Canada
Messages: 13241
Registered: January 2002
Karma: 0
Senior Member
Administrator
Core Developer
add to buddy list
ignore all messages by this user
Applied with a small modification, which is what I suspect inspired the need for this patch.

http://cvs.prohost.org/c/index.cgi/FUDforum/chngview?cn=7280


FUDforum Core Developer
Re: API function to authenticate users [message #27184 is a reply to message #27179] Mon, 29 August 2005 16:21 Go to previous messageGo to next message
naudefj is currently offline  naudefj   South Africa
Messages: 3624
Registered: December 2004
Karma: 17
Senior Member
Administrator
Core Developer
remove from buddy list
ignore all messages by this user
Yes, thank you!

I also had to add the following lines to prevent errors:

--- forum_login.php.old 2005-08-29 15:19:14.000000000 -0500
+++ forum_login.php     2005-08-29 15:15:02.000000000 -0500
@@ -39,6 +39,21 @@

 function external_get_user_by_auth($login,$passwd)
 {
+       /* load forum config */
+       $data = file_get_contents($GLOBALS['PATH_TO_FUD_FORUM_GLOBALS_PHP']);
+       eval(str_replace('<?php', '', substr_replace($data, '', strpos($data, 'require'))));
+
+       /* db.inc needs certain vars inside the global scope to work, so we export them */
+       foreach (array('FUD_OPT_1', 'DBHOST', 'DBHOST_USER', 'DBHOST_PASSWORD', 'DBHOST_DBNAME', 'DATA_DIR') as $v) {
+               $GLOBALS[$v] = $$v;
+       }
+
+        if (!$GLOBALS['PATH_TO_FUD_FORUM_DB_INC']) {
+                require_once $GLOBALS['DATA_DIR'] . 'include/theme/default/db.inc';
+        } else {
+                require_once $GLOBALS['PATH_TO_FUD_FORUM_DB_INC'];
+        }
+
        return q_singleval("SELECT id FROM ".$DBHOST_TBL_PREFIX."users WHERE login='".addslashes($login)."' AND passwd='".md5($passwd)."'");
 }


I'm sure you will be able to optimize it further...

Best regards.

Frank
Re: API function to authenticate users [message #27193 is a reply to message #27184] Mon, 29 August 2005 17:15 Go to previous message
Ilia is currently offline  Ilia   Canada
Messages: 13241
Registered: January 2002
Karma: 0
Senior Member
Administrator
Core Developer
add to buddy list
ignore all messages by this user
http://cvs.prohost.org/c/index.cgi/FUDforum/chngview?cn=7284

FUDforum Core Developer
Quick Reply
Formatting Tools:   
  Switch to threaded view of this topic Create a new topic
Previous Topic: "Save outgoing PM" toggle in User CP-->Settings and form
Next Topic: mark topics as bookmark in fudforum
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sun Oct 22 22:43:20 EDT 2017

Total time taken to generate the page: 0.00637 seconds