Compatability issues with phpbb recent topics plugin ?

I’ve recently run into a compatibility problem with my phpbb topic plugin, basically I tried to copy the code I did ( the ob_start / stop buffer thing ) and I found that the second time I ran the loop it didn’t work !

Anyway in lieu of working on an admin interface for setting up the phpbb connection I’m solving this, if anyone is having a similar issue please let me know.

Oh, and this might be of interest…

———- Forwarded message ———-
From: Nick
Date: 12-Mar-2007 11:38
Subject: Re: Recent phpBB Topics on WordPress Plugin
To: Paul Stokes

Hi Paul,

You can do this by playing with the SQL statement in the plugin, for example

SELECT * FROM $TOPIC_TABLE WHERE forum_id != 1 ORDER BY topic_time DESC LIMIT $limit

would exclude topics from forum 1

hope that helps,
Nick

On 11/03/07, Paul Stokes wrote:

Hello,

First I must say what a great plug-in you have here!
Is there a way to keep the hidden forums topic hidden?
Thanks
-Paul

Recent phpBB Topics on WordPress Plugin

UPDATE: This Plugin has been updated, the latest version is available on wordpress.org please comment on the new post, thanks.

Written primarily for my wife to use in the future, but I’ve developed a pluging that allows you to post a list of recent phpBB threads/topics within wordpress.

If found this plugin by Brandon Alexander but it wasn’t right for my needs, firstly he looks up usernames from phpBB, now my phpBB & wordpress installs don’t share databases and I thought it was a bit of a security risk giving wordpress access to my users password hashes… and secondly that plugin gives a list of recent posts, not what I wanted, and wanted threads (topics).

This is the 1st version, the massive fault with it is that you have to edit the file (to tell it where to find phpBB), I’m not yet smart enough to include an admin interface.

Installation: Download phpbb_recent_topics.txt and save as phpbb_recent_topics.php in your wordpress plugins directory. Edit the file, and change these bits to your appropriate settings…

$PHPBBDB = "phpbb_database"; // phpBB db name
$TOPIC_TABLE = "phpbb_topics"; // phpbb topics table
$SITEURL = "http://www.domain.com/phpbb"; //Forum (phpbb) URL

A bit about Database configuration.
If wordpress & phpBB share a DB already then set $PHPBBDB to DB_NAME and everything will be fine, else you’re going to need to GRANT the wordpress user read access to phpBB.

How to GRANT wordpress read only access to phpBB ?
If you don’t know it already you need to find your wordpress mysql user id, it’ll be in wp-config.php

define('DB_USER', 'wp_user');     // Your MySQL username

and you should have already found your phpbb database & table for the above.
You need to type the following syntax into your mysql database

GRANT SELECT ON phpbb_database.phpbb_topics TO wp_user@localhost;

this can be achieved by logging into phpmyadmin as your phpbb user, selecting SQL and pasting the correct GRANT into the text box.

Plugin Usage.
The plugin can be used in two ways, for those who don’t like editing templates you can call (type)

{phpbb_recent_topics}

from any post or page, and it will be replaced with an list of the last 5 topics.

For those who want to include the list in a sidebar template or similar, call the following function: phpbb_topics(), something like

 if ( function_exists('phpbb_topics') ) { phpbb_topics(5); }

where by the number 5 can be replaced with anything less that 10, and that’ll be the number of topics returned.

Hopefully that all makes sense, feel free to contact me with problems.

UPDATE: Comments about combatability issues here please.

bbCode plugin for bbPress

I’ve ported the bbCode Plugin for WordPress by Jeff Moore to bbPress, seems to work fine; not all the bbCode is marked up as it’s not allowed by default with bbPress, I plan to fix that in version 0.2, but for now Enjoy !

Download bbCode Plugin for bbPress

Installation is simple in the current implementation of bbpress, just rename bbpress_bbcode.txt to bbpress_bbcode.php and place in your my-plugins directory (See bbpPress documentation for full details.)

This plugin has been tested on v0.75 & 1.0-Alpha so hopefully will work on anything in the middle.

Root Cookie WordPress – Plugin updated !

UPDATE: This Plugin has been updated, see please the new post, thanks.

Unless there’s a security risk, I’m always slow to upgrade my blog to the latest & greatest WP, the reason is plugins, when there’s a major revision update, plugins cause problems, so it’s usually best to wait for the maintainers to fix them before upgrading.

Anyway, I started to test the upgrade, and realised that I had a plugin that didn’t work, and yes you guessed it, it was the one I wrote ! – DOH !

It appears that v2.1 was more fussy about pluggable functions, but a quick fix and it’s done, so I give you…

Root Cookie, Version: 1.1

Standard wordpress plugin rules apply, save as root-cookie.php, stick it in your wp-content/plugins directly and activate, log-out (or clear your cookies) and when you log in you’ll get a cookie with the full domain path… happy days !

Avatar BBPress Plugin Browser

I’ve been playing with bbpress, by default there are no Avatars, I’ve made a little adjustment to the plugin by Joshua Hutchins

Here is my Forum Post: Avatar  bbPress plugin browser

I wrote an extra function for your plugin so that the avatar can be displayed on the profile page…

function profile_avatar() {
global $user;
if ( get_avatar_loc ( $user->ID ) ) {
echo ‘<img src=”‘ . get_avatar_loc( $user->ID ) . ‘” alt=”‘ . $user->user_login . ‘s Avatar”‘ . ‘ />’;
}
}

Styles & img sizes could be added into the tag as desired…. then in profile.php template, add…

<?php if ( function_exists(‘profile_avatar’) ) { profile_avatar(); } ?>

hope that helps :-)

Blog CheckUp – WordPress: Improve with SEO

I noticed the other day, that the google rank for linickx.com has dropped from a respectable 4, to a pitiful 0 !

The reason for the drop is obvious, November & December have been busy real work months for me, and I’ve not been able to post much online.. no art, no php, no comments, nothing ! Now photomatt has recently blogged about the disconnect between productive good techies and people who have time to blog, so I won’t go into it here; I will just say that I agree, and I think my blog reflects that. What I didn’t realise about my google rank is that the age of your links contributes to your overall PR. So although all those other links to linickx.com still exist on the web they’re getting older so they must not count as much; of course this is speculation, google keep to themselves how their ranking is made up, but it’s the only thing that’s changed.

Anyway to get back on the map I thought I’d better take a look at these SEO posts I’ve been seeing about the place (which I guess this is yet another of ! )

1st step – site maps !
Now I already had a sitemap, powered by Arne Brachhold’s wordpress plug in , but it doesn’t hurt to check it’s working every now & again; to do this I logged into google sitemaps and checked out the reports, basically it’ll tell you if there have been any errors, remembers errors mean google can’t view the page properly, which in turn effects it’s PR. I had a couple (4) of “404 Not founds”, so I went through my posts and fixed them.

Validate your pages !
Search engines can’t see your site, they can only read the html code, and if that’s wrong, then so will the index and PR be. I’d gotten out of the habit of checking pages, you’ll notice at the bottom of my theme is a link to say this site is valid, it’s really important that after posting you click this to make sure it works; if it doesn’t, well all is lost before you start.

Page & Post titles
All the articles talk about setting your page titles correctly, I’d noticed ages ago that anaylitics showed the same title for stuff but I’d never gotten round to looking at it. It turns out I’d made a “school boy error” on my custom theme, and the <title> tag within my html didn’t grab the post title from wordpress – DOH ! It was eaily fixed by adding <?php the_title(); ?> into header.php. If you didn’t write your theme there is a plugin that can do it for you…. sadly neither of these fix the titles for my custom scripts, so I guess I’ll have to stick that back on the to-do list !

Meta Tags
Back in the day” meta tags where the way serach engines classified your site, but abuse of the keywords tag, by repeating words to improve PR, means that they’re not as important as they used to be. Today though, I’m on the search engine offensive apart from spam I’m willing to try anything. This wordpress plugin does the job for you. The advantage of using the plugin, rather than setting them in my theme, means that the description can be dynamially added based on the post, rather than having the same description for all pages, the more words that people search for that hit me, the better !

Related Posts
Search engines need a way to weave through your site, in the past I’ve relied on my web site map (not the same as sitemap.xml) to do the job, but it appears that this is not enough, so I went for the related entries wordpress plugin, the good thing about the latest version is that the formatting can be done within the wordpress admin interface. (The reason this is good, as it means minimal changes to my theme php, which is when problems occur.)

Share This !
At the beginning of what is becoming a marathon post, I talked about my PR being related to incoming links (i.e. links to linickx.com). In the past I’ve just had a small “Bookmark Page” link on each post, this link would then submit the page to del.icio.us for people to share, well alex king has written a share this plugin to expand the idea, but for any service. I like the idea alot, now all I need to do is to find a way to submit my posts to all the services automagically.

Nothing to do with SEO
The final change I’ve made was to install a snap plugin, now this will have no effect on my PR, but it is quite cool, what it does is add a little floating window preview any external links, allowing readers to take a glimpse of what they’re clicking on before they actually click. To be honest, I’ve not yest decided if this is a good thing or annoying, but would be cool is if it could be plugged into mcafee site advisor so that users could see if it’s a safe link before clicking it.

Fingers crossed this will have an impact, but one thing is for sure, it won’t hurt !

Cookie Path Plugin For WordPress 2.0 (root Cookie)

UPDATE: This Plugin has been updated, the below links to the new file, but please comment on the new post, thanks.

I’ve been busy this AM, my site is a little bit integrated with WordPress, basically I call the header and footer from WP so that my custom code changes themes when WordPress does :)

I want to take it further and use the authentication cookie, so that my code recognizes me when I log in (in the same way WordPress does). In order for linickx.com to see the cookie set by linickx.com/blog, I need to change the COOKIEPATH. The change is actually quite simple, in fact the “set cookie” function is a pluggable one :D

The function / plugin I’ve written is really simple, all I’ve done is change the PATH to be / (root) that way linickx.com or linickx.com/blah can reference the cookie, and because it’s set to / the plugin can be used on any site !

To install:

  • Save root-cookie.txt in your plugins directory as root-cookie.php (Right Click – Save As)
  • From the Plugin Manager in the Dashboard, “Activate” the plugin
  • Log out, and log in again
  • Done

Now your cookie can be referenced from any custom code you may have written outside of your WordPress install directory !

h4x0r (Hacker) / The Matrix Theme for WordPress

My h4x0r Theme

I thought I’d try something different ;)

I’ve been playing with wordpress for nearly a year now, and thought it’d be cool to make a publicly available theme, I wasn’t sure on what to do so I thought I’d start with a simple pallet. My theme is a black on green code looking theme, you know the hacker site style; to make it more interesting I added some matrix references, and silly bits of php code.

The theme has been tested on wp 1.5 & 2.01 (including a blank one as requested on the codex) , there is a screenshot and I’ve also installed a theme switcher so you can demo it :D

h4x0r is available for download here, please let me know your thoughts.

Multiple Loops in WordPress

I wanted to run the wordpress loop on my php page more than once, & I don’t know if I’m the only person, but I found the offical multiple look example hard to swallow.

Google found is nima’s how to which was useful, but I wanted to take it further; the problem was I wanted a function.

This is what I came up with:

<?php
require(‘path_to_wordpress/wp-blog-header.php’);
?>

<?php
function show_posts_from_cat($MYCAT){

?>

<ul>
<?php if (have_posts()) : ?>

<?php $my_query = new WP_Query(“category_name=$MYCAT”); ?>

<?php while ($my_query->have_posts()) : $my_query->the_post(); ?>
<li>

<span class=”my-post-title”>
<span id=”post-<?php the_ID(); ?>”><a href=”<?php the_permalink() ?>” rel=”bookmark” title=”Permanent Link to <?php the_title(); ?>”><?php the_title(); ?></a></span>
<!–
<?php trackback_rdf(); ?>
–>
</span>
<small><?php the_time(‘jS F Y’) ?> <!– by <?php the_author() ?> –></small>
</li>

<?php endwhile; ?>

<?php else : ?>

<h2 class=”center”>Not Found</h2>
<p class=”center”><?php _e(“looks like there aren’t any related posts.”); ?></p>

<?php endif; ?>

</ul>

<?php
}
?>

So here’s what I found, if you just run the wordpress loop twice, the second time you run it, it’ll fail :s so my function creates a new object each time you run the loop. The object is then used to display the results, the benefit being ,each time you call the function it over-writes the object with the new results, allowing you to call the function as many times as you like, and generating fresh results every time :D

function usage: show_posts_from_cat(“Category_name”);

Good luck, let me know if you have ant problems.

Google Adsense code (javascript) in wordpress pages / posts

For ages I could not work out why google ad’s included within a wordpress page didn’t work (in fact this applies to a post too). When google support pointed out that there was <br/> ‘s in my code the penny finally dropped.

So here’s the deal, I pasted the following code into my page: (In the wordpress dashboard)

firefox ad
<!– FireFox Referral –>
<script type=”text/javascript”>
<!–
google_ad_client = “pub-6732086233580907″;
google_ad_width = 180;google_ad_height = 60;
google_ad_format = “180x60_as_rimg”;
google_cpa_choice = “CAAQyaj8zwEaCIwcWMzeycafKMu293M”;
//–>
</script>
<script type=”text/javascript” src=”http://pagead2.googlesyndication.com/pagead/show_ads.js”></script>

adsense ad
<!– Adsense Referral–>
<script type=”text/javascript”>
<!–
google_ad_client = “pub-6732086233580907″;
google_ad_width = 180;
google_ad_height = 60;
google_ad_format = “180x60_as_rimg”;
google_cpa_choice = “CAAQ__qy0gEaCP_s0gMhUOtXKL3D93M”;
//–>
</script>
<script type=”text/javascript” src=”http://pagead2.googlesyndication.com/pagead/show_ads.js”></script>

and look what happens…..
firefox ad


adsense ad


WordPress adds page formatting to the java script that is posted, so if you look at the source, what you actually get is…

<!– FireFox Referal –><br />
<script type=”text/javascript”><br />
<!– <br />
google_ad_client = “pub-6732086233580907″;<br />
google_ad_width = 180;google_ad_height = 60;<br />
google_ad_format = “180x60_as_rimg”;<br />
google_cpa_choice = “CAAQyaj8zwEaCIwcWMzeycafKMu293M”; <br />
//–><br />
</script><br />
<script type=”text/javascript” src=”http://pagead2.googlesyndication.com/pagead/show_ads.js”></script><br />

… DOH !!!!!!

Implementing Adsides in wordpress

I’ve decided to take a tip from the pro’s and separate my useful content from waffle. The blogging term appears to be asides , and photomatt has simple post on how to do it. Basically the idea is, that asides content doesn’t take up as much space on your blog, so readers can easily see reference or important material, and if they’ve got some spare time read your thoughts.

Implementation is quite straight forward, assign a category for these less important posts – for me that’s blog - and then on you theme index.php add the something like the following code:

<?php if (in_category(1) && !$single) { ?>
<ul class=”asides”>
<li id=”p< ?php the_ID(); ?>“><?php echo wptexturize($post->post_content); echo ‘ ‘; comments_popup_link(‘(0)’, ‘(1)’, ‘(%)’)?> <?php edit_post_link(‘(e)’); ?></li>
</ul>
< ?php } else { ?>

Where category 1 is the number of blog – you can see this in the admin dashboard. The effect is posts in cat(1) get treated differently , on my blog I’ve removed the post content completely so you just have the titles, I think it makes things tidier.

Nagios Ping And Traceroute Tool Version 0.3

This has been on my to-do list for a long while….I have finally release a bundled package which includes bug fixes from users, a big thank you goes out to you all.

Here’s a copy of my changelog:

Version 0.3
Package bundle of 0.1 & 0.2 – Plus valid html code for exit errors.

http://www.linickx.com/blog/archives/92/nagios-ping-and-traceroute-tool-version-03/

Date: 16.12.2005

Version 0.2
Commented out hosts problem.

http://www.linickx.com/blog/archives/81/nagios-ping-tool-another-hack/

Date: 09.11.2005

Version 0.1
NagiosQL – Multiple hosts.cfg files support.

http://www.linickx.com/blog/archives/79/nagios-ping-tool-nagios-ql/

Date: 08.11.2005

Version 0
Initial Release.
Nagios Exchange Release Date: 28.09.2005

Writing a PHP Page for the googlebot / google’s cache

Here’s something cool to share.

My calcylator project is written in php, it’s one of those “on-line tools” where users can create an account, log in, and can calculate personal profit & loss sheets for ebay.

Like most websites there are “log in” sections, now these pages need to be dealt with differently for search engines & users. Search engines will not be able to log in, but you may still want to deliver some content to them. Take my example, calcylator is running google adsense, and for adsense to work the googlebot (search engine) needs to be able to “see” some content, thinking this through, every time googlebot visited the log in or other protected pages all it would see is “access denied” error pages.

To target google with some “special” content, google kindly present themselves as google in their agent string. Now php even provide a simple tutorial on distinguishing user agent, so this is all I needed to do:

<php

function find_googlebot() {

# This is where we look for the googlebot
$user_agent = $_SERVER["HTTP_USER_AGENT"];

if (preg_match (“/[Gg][Oo][Oo][Gg][Ll][Ee]/”, $user_agent )) {
return true;
}

#For debugging, uncomment this and the agent will appear in the source of the html.
#echo “<!– $user_agent –>”;

}

if (find_googlebot()) {
include(“google-content.php”);
exit;
}

?>

If I quickly run though what I’ve done. We have a function called find_googlebot , we run a test (look for the word google), if we get a match, then we return “true” and run the php google-content.

Here is a working example, if you visit http://www.calcylator.com/index.php?cmd=myhome you’ll see a login page (or your account if you log in) and google will see:

http://www.google.com/search?q=cache:25ez2GhuhDQJ:www.calcylator.com/index.php%3Fcmd%3Dmyhome+site:http://www.calcylator.com

Have fun, just remember, google cache doesn’t update that often, so if you present a mistake, you may be stuck with it for a while ;)