Recent Topics

1 Nov 23, 2006 21:14    

I've tried searching the forum and I can't find any info on this. So I'm starting this thread.

b2evolution is suppose to support multiple domains for different blogs. However, I just found that the Captcha plugin (currently at version 1.8.4) does not support multiple domains.

I did some research into the code of the plugin and b2evolution and found that whenever the Captcha image is generated, it refers to the $baseurl through get_htsrv_url(). However, this breaks Captcha because if the current blog is under a different domain, then a different cookie is used with a different session id than that under the $baseurl. So when Captcha tries to compare the session id from the database, it doesn't match, returning false, and no Captcha image is displayed.

I have not research further into how to fix this yet as I currently don't have the time. But I'm reporting it so others may have a look into the problem as well.

2 Nov 23, 2006 23:38

This will be probably fixed with b2evo 1.9, because the get_htsrv_url() is more intelligent there.
I'm using it also on various subdomains (based on b2evo 1.9) and it works.

3 Nov 25, 2006 17:46

Sub-domains works fine, as long as you set the cookie correctly in _advance.php as shown in the documentation for multiple domain.

I actually found a potential work around to this just now, but not sure if it poses security or other blogging issues as I didn't do much testing. There maybe better way to code it, but that's the best I can come up with right now given my limited PHP knowledge.

_basic_config.php

Since the function get_htsrv_url() refers to $baseurl, by changing this:

// -- edit the line or add to end of file -- //
$baseurl = 'http://'.$_SERVER['HTTP_HOST'].'/';

Every time when the script runs, it will automatically checks and sets the $baseurl.

The site 'a.com' would have that $baseurl 'http://a.com/' and 'b.com' would have the $baseurl 'http://b.com/' If you have set up the multiple domains pointing to the same root directory, as suggested by the documentation, then no matter which $baseurl, the files and folders referred with this $baseurl would be under the same location.

_advanced.php

To make sure the cookies are properly set for its respective domains, I needed to take the domain that is currently referred to, and only taking the base domain.

Note: I have assumed that the domain is 'a.com' where the domain name only has two parts 'a' and 'com'. You can adjust to fit your own domain needs. You might need to do matching if you have domains with different roots (such as 'co.jp', 'co.hk', mixing with '.com' etc). You can also just hardcode the match and result since it is basically fixed on your server only. Sub-domains should also work with shared cookies as I'm only taking the base domain.

// -- add to end of file -- //
$temp_domain_array = explode('.',$_SERVER['HTTP_HOST']);
$temp_domain_array_count = count($temp_domain_array);
$cookie_domain = '.'.$temp_domain_array[$temp_domain_array_count - 2].
   '.'.$temp_domain_array[$temp_domain_array_count - 1];
$cookie_path = '/';

If there is any issue/problem/better coding for this, let me know so I can learn from it as well.


Form is loading...