Search Results for 'code'
-
AuthorSearch Results
-
November 16, 2008 at 1:46 am #68948
chrishajer
ParticipantI am guessing there is a problem in bb-config.php right before line 20, which would be the secure auth key. My guess is something there is not escaped properly. Can you check that? A file editor that has syntax highlighting will show it right away since the string will no longer be color coded as “quoted” if a character is not escaped properly. vim is a good command line editor for this if you have a shell. Notepad++ is good too. Doesn’t matter which editor you use so long as it can do syntax highlighting for a php file.
November 16, 2008 at 12:22 am #68216In reply to: bbPress 1.0-alpha-2 released
sc0ttbeardsley
MemberOK, I’ve looked at the other thread and looked at the cookie interaction on my site and have it working. I did have to make a change to my wordpress installation to get it to work. Here is what I did:
My wordpress installation is at sacbikekitchen.org
My bbpress installation is at sacbikekitchen.org/forum/
I added the following to my /forum/bb-config.php:
$bb->cookiedomain = '.sacbikekitchen.org';
$bb->sitecookiepath = '/';
I added the following to my /wp-config.php:
define('COOKIE_DOMAIN', '.sacbikekitchen.org');
define('COOKIEPATH', '/');
Then I made a couple additions to the wp-includes/pluggable.php file:
Around line 596 I added:
setcookie(LOGGED_IN_COOKIE, $logged_in_cookie, $expire, '/forum/', COOKIE_DOMAIN);
setcookie($auth_cookie_name, $auth_cookie, $expire, '/forum/bb-plugins', COOKIE_DOMAIN);
setcookie($auth_cookie_name, $auth_cookie, $expire, '/forum/my-plugins', COOKIE_DOMAIN);
setcookie($auth_cookie_name, $auth_cookie, $expire, '/forum/bb-admin', COOKIE_DOMAIN);
Around line 620 I added:
setcookie(LOGGED_IN_COOKIE, ' ', time() - 31536000, '/forum/', COOKIE_DOMAIN);
setcookie(AUTH_COOKIE, ' ', time() - 31536000, '/forum/bb-plugins', COOKIE_DOMAIN);
setcookie(AUTH_COOKIE, ' ', time() - 31536000, '/forum/my-plugins', COOKIE_DOMAIN);
setcookie(AUTH_COOKIE, ' ', time() - 31536000, '/forum/bb-admin', COOKIE_DOMAIN);
Hope it helps…
November 15, 2008 at 10:42 pm #4266Topic: Unable to import BBFX (maximum execution time)
in forum Troubleshootingvadi
MemberHi,
I’m receiving the following error when importing an eximported bbfx file:
Fatal error: Maximum execution time of 30 seconds exceeded in /var/www/forums/bb-plugins/bbxf/importer/bbxf-parse.php on line 99The line in question is
preg_match ('|<' . preg_quote ($element) . '.*?>.*?</' . preg_quote ($element) . '>|s', $data, $items);, which looks okay…Is there anything I can do to fix it? I was kind of relying on this plugin for importing, didn’t want to mess with databases directly.
November 15, 2008 at 8:24 pm #68664In reply to: Alpha 2 and WP 2.6.3 Integrated Install Failed
mazzhe
MemberI have the same problem… I have installed today wp2.6.3 and bbp1.0-alpha1(fr), and I have the same “minor” problem : no forum. I’m happy it’s not a “major” problem !
November 14, 2008 at 9:38 pm #68908In reply to: WPMU integration
Klark0
MemberI count the number of blogs and the number of the posts using two queries. All posts from all the other blogs are copied to blog_id 1. So i do like so
$count_posts = wp_count_posts();
echo $count_posts->publish;and
$stats = get_sitestats();
$tmp_blog_count = number_format ($stats[ 'blogs' ] );
print "".$tmp_blog_count." blogs";Can bbpress grab those ?
November 14, 2008 at 8:17 pm #68710chrishajer
Participantdefine('AUTH_SALT', 'AUTHSALT');
define('LOGGED_IN_SALT', 'LOGGEDINSALT');Where did you add those?
Also, can you do a fresh installation? It’s possible something was not entered properly into one of the fields. There is a lot of text to read to get all the cookie settings right.
November 14, 2008 at 7:59 pm #68566In reply to: 1.0a2 + 2.6x cookies: so close!
jonkristian
MemberHm, turns out I still have trouble accessing admin panel in bbpress. Straange, I tested it with login via both bbpress and wp the last time, however now, it doesn’t seem to work.

Regarding the setup, i followed Deadpan’s setup down to the very last line, except that i kept the hash in
$bb->logged_in_cookie = ‘wordpress_logged_in_ikeptthishashin’;
November 14, 2008 at 3:17 pm #4262Topic: reCAPTCHA for bbPress
in forum Pluginsdchest
MemberI wrote a plugin to add reCAPTCHA to user registration page. (It’s inspired by _ck_’s Human Test.)
I’ve submitted request to add it to the plugin repository, however 1) the submission form didn’t have any feedback, so I ended up with two identical requests, 2) I didn’t realize you have to put the whole readme.txt to description field of this form. Could someone fix this, and write at least a few sentences describing the submission process?
Anyway, you can download it from http://www.codingrobots.com/files/bb-recaptcha.zip
IMPORTANT: You must get an API key from the reCAPTCHA project to use it. See readme.txt.
Tested under 1.0-alpha1, may not work with previous versions on some PHP deployments.
See how it works here: http://forum.codingrobots.com/register.php
Comments and code review are welcome!
November 13, 2008 at 6:27 am #68236In reply to: Permanently deleting topics and posts
_ck_
ParticipantYou could easily turn this into a more standardized script by starting the code with
require('./bb-load.php');to load the bbPress code and check user authorization, and thenif (!bb_current_user_can(administrate)) {exit;}The
mysql_query(would become$bbdb->query(and you’d have to do aglobal $bbdb;once at the top too. Just for completeness you might want to look at some of the functions inbb-do-counts.phpin bb-admin.Actually it would be fairly easy to turn it into a full blown plugin for the admin menu.
November 13, 2008 at 6:03 am #68637In reply to: Allowing New Users to pick their own passwords
_ck_
ParticipantIt might be possible to create the MediaWiki cookie from the bbPress side and visa versa.
From the mediawiki side, you could do something as simple as
require('./bb-load.php');
wp_set_auth_cookie( (int) $user_id,0 );Which will create the bbPress cookie. Where $user_id is the user’s bbPress id. Since you are using the same user table, it should be available?
November 13, 2008 at 5:19 am #68886In reply to: [1.0 Trunk 1806] How to delete deleted messages ?
lstelie
MemberThaks,
I’ll try this way for next time, in the meantime I ended using PhpMyAdmin to delete post and tipic with status=1
I hope this fucntionality will make its way in the core because it can become a real problem.
I had a problematic user, I first deleted all his messages (deleted, but not really deleted as BBPress don’t really delete) then I deleted his account.
A few hours later he recreated his accoun and suddently all supposedly deleted messages appeared with “anonymous” has author…. very strange.
Using phpMyAdmin the problem is gone

How to use your script ?
Thanks again
November 13, 2008 at 2:18 am #66117In reply to: WordPress + bbPress Integration 101
Gregg
MemberIm integrating my second wp and bb site and this time around it seems there are some easier steps only I cant get this setup to work. I can login to the WP side fine. But when i login from bb side it just redirects to the forum homepage. It will login the person on the wp side but not let them do a thing on the bb side.
I dont have admin access until wipe out the theme and clear the cookies. its very strange.
I followed all steps correctly in the writeup. any help would be much appreciated.
here is what my bb-config file looks like
require_once('/path/to/blog/wp-blog-header.php');
// ** MySQL settings ** //
define(‘BBDB_NAME’, ‘db’); // The name of the database
define(‘BBDB_USER’, ‘user’); // Your MySQL username
define(‘BBDB_PASSWORD’, ‘pswd’); // …and password
define(‘BBDB_HOST’, ‘localhost’); // 99% chance you won’t need to change these last few
define(‘BBDB_CHARSET’, ‘utf8’); // If you are *upgrading*, and your old bb-config.php does
define(‘BBDB_COLLATE’, ”); // not have these two contstants in them, DO NOT define them
// If you are installing for the first time, leave them here
define(‘COOKIEPATH’, ‘/’ );
define(‘SITECOOKIEPATH’, ‘/’);
// Change BB_SECRET_KEY to a unique phrase. You won’t have to remember it later,
// so make it long and complicated. You can visit https://www.grc.com/passwords.htm
// to get a phrase generated for you, or just make something up.
// If you are integrating logins with WordPress, you will need to match the value
// of the “SECRET_KEY” in the WordPress file wp-config.php
define(‘BB_SECRET_KEY’, ‘secretkeydotcom’); // Change this to a unique phrase.
// If you are running multiple bbPress installations in a single database,
// you will probably want to change this.
$bb_table_prefix = ‘bb_’; // Only letters, numbers and underscores please!
// Change this to localize bbPress. A corresponding MO file for the
// chosen language must be installed to bb-includes/languages.
// For example, install de.mo to bb-includes/languages and set BB_LANG to ‘de’
// to enable German language support.
define(‘BB_LANG’, ”);
/* Stop editing */
if ( !defined(‘BB_PATH’) )
define(‘BB_PATH’, dirname(__FILE__) . ‘/’ );
require_once( BB_PATH . ‘bb-settings.php’ );
$bb->wp_siteurl = ‘http://www.site.com/blog/’;
// that’s your WordPress URL, not bbPress
$bb->wp_home = ‘http://www.site.com/blog/’;
// almost always the same as siteurl unless you tinker
$bb->wp_table_prefix = ‘wp_’;
// should almost always be wp_ unless you tinkered
$bb->user_bbdb_name = ‘db’;
// this is the MYSQL database name for *WordPress*
// you can copy it right out of WordPress !
$bb->user_bbdb_user = ‘user’;
// this is the MYSQL user name for *WordPress*
// you can copy it right out of WordPress !
$bb->user_bbdb_password = ‘pswd’;
// this is the MYSQL password for *WordPress*
// you can copy it right out of WordPress !
$bb->user_bbdb_host = ‘localhost’;
// 99.9% of the time it’s going to be localhost, unless you are on DreamHost or some other weird ISP
$bb->custom_user_table = ‘wp_users’;
// 99.9% of the time it’s going to be wp_users
$bb->custom_user_meta_table = ‘wp_usermeta’;
// 99.9% of the time it’s going to be wp_usermeta
$bb->authcookie = ‘wordpress_randomnumbers’;
// in theory you should be able to leave this out
// but this is going to be copied from WordPress cookie
// this *must* match the WordPress setting
// do NOT use the 1234567 part, use your own cookiehash from WordPress – see the note at the very bottom
$bb->cookiedomain = ‘.site.com’;
// note the leading DOT – this is important
// this *must* match the WordPress setting
$bb->cookiepath = ‘/’;
// I *highly* recommend you set the cookie path to /
// this *must* match the WordPress setting
$bb->sitecookiepath = ‘/’;
// I *highly* recommend you set the cookie path to /
// this *must* match the WordPress setting
//tried this – doesnt work with or without…ugh
$bb->usercookie = ‘wordpressuser_randomnumbers’;
$bb->passcookie = ‘wordpresspass_randomnumbers’;
November 12, 2008 at 4:04 pm #68877In reply to: “alphabetical” ordering of hot tags
_ck_
ParticipantAny guide that is for WordPress plugins should work for bbPress, it’s just that bbPress’s “hooks” (do_action, do_filter) will be named differently.
bbPress is unfortunately too young to have decent documentation yet. WordPress itself didn’t really “take off” until 2.0 beta came out.
This is essentially the plugin framework you need:
<?php
/*
Plugin Name: My Tag Sort
*/
remove_filter('sort_tag_heat_map', 'bb_sort_tag_heat_map');
add_filter('sort_tag_heat_map', 'my_sort_tag_heat_map');
function my_sort_tag_heat_map( &$tag_counts ) {
// put your replacement code here
}
?>Save it as
my-tag-sort.php, put it into thebbpress/my-pluginsfolder, activate and you’re in business (well after you figure out the sort method).Typically you’d have to do a
return $tag_counts;at the end of a filter but that&on the&$tag_countsmeans it’s “passed by refererence” which is a fancy way of using the original array directly without making a copy, so the original is changed at the source when you modify it. It’s a much faster way to move large amounts of info around.November 12, 2008 at 3:46 pm #68560In reply to: 1.0a2 + 2.6x cookies: so close!
jonkristian
MemberDeadpan11 , I followed your guide and it worked excellent, however I had to keep the hash on:
$bb->logged_in_cookie = ‘wordpress_logged_in_’;
Setup, http://forums.domain.com & http://domain.com
I can now log in via the forums, and access both admin panels, and via wp, and still access both. If I log out of either, I am logged out of both.
November 12, 2008 at 12:42 pm #68874In reply to: “alphabetical” ordering of hot tags
myu
MemberThanks for reply, ck.
I didn’t know how to make plugins..
So, anywhere that say
apply_filter('___', '___');can be replaced?
Now.. about original question:
$tag_counts is
- key: raw_tag
- value: how many times topics are tagged with this tag
Googling a bit more made me realize, there’re problems associated with ordering Japanese words/strings as there’re 2 types of letters and chinese character used.
strnatcasecmp() seem to put things in order of
- hiragana in ascending
- katakana in ascending
- chinese characters in encoding#
ssetlocale(LC_COLLATE, "jp", "jpn");
ksort($tag_counts, SORT_LOCALE_STRING);shows exactly the same result.
It seems pretty impossible (for me) to order them.
I will flip it to descending, with krsort(); just so the tag “other” won’t come to start.
November 12, 2008 at 7:40 am #68899In reply to: I’m installed now how do I get readers to forums?
_ck_
ParticipantWordPress allows you to make links, go to manage->links under your control panel. Make the link
/forums/if that’s the path to your forums.There are also wordpress plugins to make menu bars, optionally you could use that and put a few primary site links in there, including one to your forums.
Technically if you wanted to place a link more prominently under your pages section, you could actually create a page for the forums and then use the rewriterules in your .htaccess to redirect the user to the actual forums.
November 11, 2008 at 8:14 pm #63069In reply to: Open Links in new window
TrishaM
ParticipantThanks _ck_ – I’ll do as suggested…….
P.S. At cafepress.com you can design your own bumper sticker! I’ve made a few of my own t-shirts that way…..perfect for when you know just what you want but can’t find it anywhere….
November 11, 2008 at 8:01 pm #63068In reply to: Open Links in new window
lstelie
MemberPeople who insist on perfect validation need to find more productive things to do with their time, there’s alot of code out there that needs to be written!

Good point
November 11, 2008 at 7:33 pm #63067In reply to: Open Links in new window
_ck_
ParticipantTrishaM, if you are using bb-tweaks.php you can just add the above code to the bottom of it and disable the target_blank filter. But it will work either way.
lstelie, there is another problem with using javascript as it increases the amount of time before the page is ready. If you are going to throw in rel=”external” you might as well do target. (In fact, you don’t even need rel=”external” as you can scan the domain for each link with javascript on the fly.) But I assure you that target will be supported in browsers ten years from now, maybe even twenty. People who insist on perfect validation need to find more productive things to do with their time, there’s alot of code out there that needs to be written!
Throw off the shackles of validation!
(I need that as a bumper sticker)
November 11, 2008 at 7:19 pm #63066In reply to: Open Links in new window
lstelie
MemberHello,
I use for a pretty long time rel=”external” more compliant and this works well.
The following bit of code is from
http://www.sitepoint.com/article/standards-compliant-world
function externalLinks() {
if (!document.getElementsByTagName) return;
var anchors = document.getElementsByTagName("a");
for (var i=0; i<anchors.length; i++) {
var anchor = anchors;
if (anchor.getAttribute("href") &&
anchor.getAttribute("rel") == "external")
anchor.target = "_blank";
}
}
window.onload = externalLinks;If JS is not activated ? well no external link but the site is prefectly working
November 11, 2008 at 4:28 pm #68487In reply to: Customizing gravatars
Ipstenu (Mika Epstein)
ModeratorOkay, having tested it a bunch of different ways, I can’t get it to work.
I want to make my own image the ‘default’ for the non-gravatard people (which works fine on WordPress).
In WordPress it’s this:
<?php echo get_avatar(get_comment_author_email(),50,'http://www.foo.com/gravatar.png');?>For bbpress we have this
post_author_avatar();on post.php. Passing the URL into that, either on it’s own or as $default doesn’t work.Using
echo bb_get_avatar( bb_get_user_email(post_author()), 48, 'http://www.foo.com/gravatar.png' );didn’t work.I’m gonna keep tossing stuff up against the wall for now.
November 11, 2008 at 3:54 pm #68873In reply to: “alphabetical” ordering of hot tags
_ck_
ParticipantIt uses the action
do_action_ref_array( 'sort_tag_heat_map', array(&$counts) );which looks like
function bb_sort_tag_heat_map( &$tag_counts ) {
uksort($tag_counts, 'strnatcasecmp');
}So it was designed to be replaced fortunately.
First to have to unhook the existing action in your plugin:
remove_filter('sort_tag_heat_map', 'bb_sort_tag_heat_map');Then put in your replacement
add_filter('sort_tag_heat_map', 'my_sort_tag_heat_map');
function my_sort_tag_heat_map( &$tag_counts ) {
// put your replacement code here
}According to this, it’s supposed to support your locale, but there is a bug:
November 11, 2008 at 3:27 pm #68559In reply to: 1.0a2 + 2.6x cookies: so close!
WebDev WaxLotus LLC
MemberSo the web-consensus is that
$bb->cookiedomain = '.domain.com';specifically the leading dot before the domain.com, is key to permitting cookies created in one subdomain to be useful in other related domains.
Darn. I thought I found my magic bullet.
November 11, 2008 at 2:28 pm #68883In reply to: Customize Topic Labels
Ipstenu (Mika Epstein)
Moderatorremove_filter('bb_topic_labels', 'bb_sticky_label', 20);worked.Now it has images
November 11, 2008 at 2:01 pm #63064In reply to: Open Links in new window
_ck_
ParticipantOkay this one is testing working.
For anyone else that wants to use this, you have to replace the domain name by hand. It’s hardcoded for speed, sorry.
All other target=”_blank” plugins should be uninstalled. Any existing links with target=”_blank” will be left in place for performance since target is not added by bbPress by default.
<?php
/*
Plugin Name: Target Nofollow External Only
Description: append target="_blank" and rel="nofollow" only on external links
Plugin URI:
Author: _ck_
Version: 0.0.1
*/
add_filter('post_text', 'target_nofollow_external_only',999); // unfortunately we have to do this on every page load and not in pre_post
function target_nofollow_external_only( $text ) {
$domain="travel-writers-exchange.com"; // domain to exclude from target and nofollow
$text = preg_replace('|<a (.*)rel=['"]nofollow['"](.+)?>|iU','<a $1$2>', $text); // strip ALL nofollow
$text = preg_replace('|<a (?
[^>]+http
//))(?!([^>]+'.$domain.'))(.+)>|iU', '<a $3 rel="nofollow" target="_blank">', $text); // add back in when needed
return $text;
}
?>I’m not happy about the performance of this technique because it has to be done in post_text for every time a page is displayed, but there’s no other easy way around bbPress/WordPress’s unfortunate use of make_clickable with hardcoded “nofollow” in post_text.
-
AuthorSearch Results