Welcome Guest. Please Login or Register  


You are here: Index > Advanced Electron Forums > Mods > Topic : Help needed...


News:

Group Message
Hello Guest,

Welcome to the AEF Board. AEF is getting better and better and is also becoming more popular.
Take a few seconds to Register, its free, and it inspires us to work harder and improve on whatever we can improve on.
Give us some feedback, and tell your buddies about AEF!

Thanks,
The AEF Team



Threaded Mode | Print  

 Help needed..., Integrated log-in (0 Replies, Read 4980 times)
zbdblues
Group: Member
Post Group: Newbie
Posts: 7
Status:
hi everyone, i'm using AEF 1.0.6 with MKPortal and everythings fine but need some help integrating it's log-in with another script called Question2Answer.
Q2A has been designed to sgare it's database with other scripts, but has a complicated procedure which goes a little over my head. The people at Q2A are friendly but don't like to help much if you aren't an expert in Php.
Here's brief details of what i need to know:
1) function qa_get_mysql_user_column_type()
I used return 'VARCHAR(32)';
2) Until you edit this function, don't show login, register or logout links

        return array(
            'login' => null,
            'register' => null,
            'logout' => null
        );
The two examples are:
Example 1 - using absolute URLs, suitable if:
       
        * Your Q2A site:      http://qa.mysite.com/
        * Your login page:    http://www.mysite.com/login
        * Your register page:  http://www.mysite.com/register
        * Your logout page:    http://www.mysite.com/logout
       
        return array(
            'login' => 'http://www.mysite.com/login',
            'register' => 'http://www.mysite.com/register',
            'logout' => 'http://www.mysite.com/logout',
        );
       
    */
   
    /*
        Example 2 - using relative URLs, suitable if:
       
        * Your Q2A site:      http://www.mysite.com/qa/
        * Your login page:    http://www.mysite.com/login.php
        * Your register page:  http://www.mysite.com/register.php
        * Your logout page:    http://www.mysite.com/logout.php
   
        return array(
            'login' => $relative_url_prefix.'../login.php',
            'register' => $relative_url_prefix.'../register.php',
            'logout' => $relative_url_prefix.'../logout.php',
        );
Which do i use and how?
3) qa_get_logged_in_user()
The two examples are:
Example 1 - suitable if:
       
        * You store the login state and user in a PHP session
        * You use textual user identifiers that also serve as public usernames
        * Your database is shared with the Q2A site
        * Your database has a users table that contains emails
        * The administrator has the user identifier 'admin'
       
        session_start();

        if ($_SESSION['is_logged_in']) {
            $userid=$_SESSION['logged_in_userid'];

            $qa_db_connection=qa_db_connection();
           
            $result=mysql_fetch_assoc(
                mysql_query(
                    "SELECT email FROM users WHERE userid='".mysql_real_escape_string($userid, $qa_db_connection)."'",
                    $qa_db_connection
                )
            );
           
            if (is_array($result))
                return array(
                    'userid' => $userid,
                    'publicusername' => $userid,
                    'email' => $result['email'],
                    'level' => ($userid=='admin') ? QA_USER_LEVEL_ADMIN : QA_USER_LEVEL_BASIC
                );
        }
       
        return null;
    */
   
    /*
        Example 2 - suitable if:
       
        * You store a session ID inside a cookie
        * You use numerical user identifiers
        * Your database is shared with the Q2A site
        * Your database has a sessions table that maps session IDs to users
        * Your database has a users table that contains usernames, emails and a flag for admin privileges
       
        if ($_COOKIE['sessionid']) {
            $qa_db_connection=qa_db_connection();
           
            $result=mysql_fetch_assoc(
                mysql_query(
                    "SELECT userid, username, email, admin_flag FROM users WHERE userid=".
                    "(SELECT userid FROM sessions WHERE sessionid='".mysql_real_escape_string($_COOKIE['session_id'] , $qa_db_connection)."')",
                    $qa_db_connection
                )
            );
           
            if (is_array($result))
                return array(
                    'userid' => $result['userid'],
                    'publicusername' => $result['username'],
                    'email' => $result['email'],
                    'level' => $result['admin_flag'] ? QA_USER_LEVEL_ADMIN : QA_USER_LEVEL_BASIC
                );
        }
       
        return null;

4) function qa_get_userids_from_public($publicusernames)
The two examples are:
Example 1 - suitable if:
       
        * You use textual user identifiers that are also shown publicly

        $publictouserid=array();
       
        foreach ($publicusernames as $publicusername)
            $publictouserid[$publicusername]=$publicusername;
       
        return $publictouserid;
    */

    /*
        Example 2 - suitable if:
       
        * You use numerical user identifiers
        * Your database is shared with the Q2A site
        * Your database has a users table that contains usernames
       
        $publictouserid=array();
           
        if (count($publicusernames)) {
            $qa_db_connection=qa_db_connection();
           
            $escapedusernames=array();
            foreach ($publicusernames as $publicusername)
                $escapedusernames[]="'".mysql_real_escape_string($publicusername, $qa_db_connection)."'";
           
            $results=mysql_query(
                'SELECT username, userid FROM users WHERE username IN ('.implode(',', $escapedusernames).')',
                $qa_db_connection
            );
   
            while ($result=mysql_fetch_assoc($results))
                $publictouserid[$result['username']]=$result['userid'];
        }
       
        return $publictouserid;

5) function qa_get_public_from_userids($userids)
The two examples are:
Example 1 - suitable if:
       
        * You use textual user identifiers that are also shown publicly

        $useridtopublic=array();
       
        foreach ($userids as $userid)
            $useridtopublic[$userid]=$userid;
       
        return $useridtopublic;
    */

    /*
        Example 2 - suitable if:
       
        * You use numerical user identifiers
        * Your database is shared with the Q2A site
        * Your database has a users table that contains usernames
       
        $useridtopublic=array();
       
        if (count($userids)) {
            $qa_db_connection=qa_db_connection();
           
            $escapeduserids=array();
            foreach ($userids as $userid)
                $escapeduserids[]="'".mysql_real_escape_string($userid, $qa_db_connection)."'";
           
            $results=mysql_query(
                'SELECT username, userid FROM users WHERE userid IN ('.implode(',', $escapeduserids).')',
                $qa_db_connection
            );
   
            while ($result=mysql_fetch_assoc($results))
                $useridtopublic[$result['userid']]=$result['username'];
        }
       
        return $useridtopublic;
    */

    }
Can anyone help me to understand which on of each example i use, and how?
I really would like to add the question 2 answer site to aef.
IP: --   

« Previous    Next »

Threaded Mode | Print  



Jump To :


Members who read this topic
zbdblues, Sammael, antros


Users viewing this topic
1 guests, 0 users.


All times are GMT. The time now is May 21, 2018, 5:08 am.

  Powered By AEF 1.1.0 Preview © 2007-2011 AEF Group. All rights reservedQueries: 12  |  Page Created In:0.035