Textpattern Forum

You are not logged in. Register | Login | Help

#51 2012-03-28 15:50:22

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 5,840
Website

Re: cbe_frontauth: Connect to (and disconnect from) backend from frontend

CeBe wrote:

a clean way to determine whether the admin path is www.example.com/admin/ or admin.example.com or www.example.com/textpattern/

It’s not exactly what I’d call clean but the split and hope method is the closest I’ve found to a solution:

// Test array. Add test cases here...
$url = array(
   'http://www.example.com/admin/',
   'http://www.example.com/textpattern/',
   'https://www.example.com/admin/',
   'www.example.com/admin/',
   'example.com/admin/',
   'example.com/textpattern/',
   'admin.example.com',
);
dmp($url);

foreach ($url as $link) {
   // Remove protocol because the optional slashes get in the way of finding the domain
   $link = str_replace(array('http://', 'https://', 'ftp://'), '', $link);

   // Splittah!
   $parts = do_list($link, '/');
   $domain = array_shift($parts);
   $admin_subdir = isset($parts[0]) ? $parts[0] : '';
dmp($admin_subdir);
}

Note that the final subdomain example identifies the admin subdir as '' because you’d set your site_url up to match the subdomain… at least I hope that’s the case!

Totally untested and most likely there are corner cases where it’d fail, or it may be completely unsuitable. Discuss :-)

Last edited by Bloke (2012-03-28 15:53:52)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern.

Txp Builders – finely-crafted code, design and Txp

Offline

#52 2012-03-28 16:15:22

planeth
Plugin Author
From: Nantes, France
Registered: 2009-03-19
Posts: 109
Website

Re: cbe_frontauth: Connect to (and disconnect from) backend from frontend

Would it be too much of a hassle/not txply correct to add path/to/admin in prefs ?

Offline

#53 2012-03-28 21:53:20

CeBe
Plugin Author
From: Caen - Fr
Registered: 2010-06-25
Posts: 285
Website

Re: cbe_frontauth: Connect to (and disconnect from) backend from frontend

planeth a écrit:

Would it be too much of a hassle/not txply correct to add path/to/admin in prefs ?

For future releases, it would be lovely :) Feature request ?
Right now we have to do with what we have (or don’t). What about this :

// First determine possible admin URLs
// (do it here)
// should give the following array, order is important :

$url = array( 'www.example.com/admin'          // or 'example.com/admin', depending on preferences
            , 'www.example.com/textpattern'    // ditto
            , 'admin.example.com'
            ) ;

foreach( $url as $link )
{
    $headers = @get_headers( $adm_url = PROTOCOL . $link . '/' ) ;
    if( $headers !== false && strpos( $headers[ 0 ], '404' ) === false )
        break ;
}

// got it in $adm_url

Fully untested neither, it’s just an idea.

Last edited by CeBe (2012-03-28 21:54:38)

Offline

#54 2012-03-29 08:14:06

planeth
Plugin Author
From: Nantes, France
Registered: 2009-03-19
Posts: 109
Website

Re: cbe_frontauth: Connect to (and disconnect from) backend from frontend

AFAIK, that seems smart :)

The one problematic point is if you got an admin url like www.example.com/my-funky-unguessable-admin-name …
But since the wiki way for multi-site is admin for url, not many people will change for another name. Though it might be a wise move from a security point of vue.
My 2 cents !

Offline

#55 2012-05-20 13:30:04

Dragondz
Moderator
From: Algérie
Registered: 2005-06-12
Posts: 1,134
Website

Re: cbe_frontauth: Connect to (and disconnect from) backend from frontend

Hi claire

it seems a little bug in your code (9.1)

when i use cbe_login_with value=“email” there something showing on top of the page “array(login=“with” ! i thinked it s due to testing mode of textpattern but even on live mode it not disapear.

Cheers

Offline

#56 2012-06-04 15:16:46

CeBe
Plugin Author
From: Caen - Fr
Registered: 2010-06-25
Posts: 285
Website

Re: cbe_frontauth: Connect to (and disconnect from) backend from frontend

Dragondz a écrit:

there something showing on top of the page

Ahem… Removed a parasitic var_dump in 0.9.2.
Thank you, and sorry.

Offline

#57 2012-07-12 04:53:45

photonomad
Member
Registered: 2005-09-10
Posts: 258
Website

Re: cbe_frontauth: Connect to (and disconnect from) backend from frontend

Hello Claire,

This is an awesome plugin! I’m testing it out for the first time (along with cbe_members, smd_bio and smd_user_manager). Sometimes I login and then navigate to another page/section and I’m logged out unexpectedly (the login form shows up again). Other times, I login and everything works as it should. It is very unpredictable – happens on different pages and with different users. This has happened both on Chrome and Safari. Here is a link to my test site: http://photonomad.com/treetest/

Two sample logins (no back end privileges) are:
name: msue pw: password
name: msmith pw: password

Any ideas as to what is happening?

Thanks,
Stacey

Offline

#58 2012-07-12 05:12:20

Gocom
Developer
Registered: 2006-07-14
Posts: 4,475
Website

Re: cbe_frontauth: Connect to (and disconnect from) backend from frontend

Any change you are trying to log in with the same account to admin-side too, or you are logged in with same user in multiple browsers? In either of those scenarios, you would thrown out. Single account can only be used in single client instance.

As the test site goes, I personally see no issues. Logging in works fine, cookies are created properly, it updates session hashes and so on. Nothing out of the ordinary.


Rah-plugins | What? I’m a little confused… again :-) <txp:is_god />

Offline

#59 2012-07-12 08:08:24

CeBe
Plugin Author
From: Caen - Fr
Registered: 2010-06-25
Posts: 285
Website

Re: cbe_frontauth: Connect to (and disconnect from) backend from frontend

photonomad a écrit:

Sometimes I login and then navigate to another page/section and I’m logged out unexpectedly (the login form shows up again). Other times, I login and everything works as it should.

That’s because sometimes the URL is with www (http://www.photonomad.com), sometimes without (http://photonomad.com), these are two different domains and two different sets of cookies.

Back to the help file and read the Quick start paragraph :)

Offline

#60 2012-07-26 12:39:08

hilaryaq
Plugin Author
Registered: 2006-08-20
Posts: 139
Website

Re: cbe_frontauth: Connect to (and disconnect from) backend from frontend

I actually love you right now.


…………………
I <3 txp
…………………

Offline

Board footer

Powered by FluxBB