Insert new post in to wordpress from php

This code snippet should let you add a new post to your wordpress database 2.5.1

require_once('wp-config.php');

// create post object
class wm_mypost {
    var $post_title;
    var $post_content;
    var $post_status;    /* publish, private */
    var $post_author;    /* author user id (optional) */
    var $post_name;      /* slug (optional) */
    var $post_type;      /* 'page' or 'post' (optional, defaults to 'post') */
    var $comment_status; /* open or closed for commenting (optional) */
    var $post_category ; 
}

// initialize post object
$wm_mypost = new wm_mypost();
$wm_mypost->post_title    = "Title2 ". date( 'r' );
$wm_mypost->post_content  = "content3";
$wm_mypost->post_status   = 'publish'; 
$wm_mypost->post_author   = 1;

// Catagorys
$post_category = split("," , "one");
foreach($post_category as $key=>$val) {
    $post_category[$key] = get_cat_ID($val);
}
$wm_mypost->post_category =  $post_category ; 

// Optional; uncomment as needed
// $wm_mypost->post_type = 'page';
// $wm_mypost->comment_status = 'closed';

// feed object to wp_insert_post
$post_ID = wp_insert_post($wm_mypost);
echo date( 'r' ) . "\n";
echo "post_ID:". $post_ID . "\n"; 

How to install PHPBB 3.0.1

This tutorial will walk you thou the steps to install PHPBB3 on your system.

Intro

PHPBB3 has become one of the more popular bulletin board system (AKA, BBS, or forums) available. It is used for all types of websites, from corporate websites, online stores, online hobby groups, ect.  One of the main selling points for many people that use PHPBB is the strong community of developers developing mods and themes. PHPBB is an open source project released under (General Public License) that started in 2000 by James Atkinson (now a former team member) has come a long way in the last 8 years. As PHPBB grew and became more popular and as its install base reached over 100,000 sites, it started getting targeted by hackers and script kiddies. Forums would be filled with spam comments, links to porn/adult sites, and people trying to sell perscription medication it turned a lot of people away from PHPBB on to other forum systems. The newer versions of PHPBB2 and PHPBB3 made spam and robot prevention a major concern and the exploits that allow robots and script kiddies to make new posts have been reduced significantly.

Requirements (^)

For this tutorial we will be use a apache.org on a UNIX based web server hosted on dreamhost.com using mysql.com for the database.

Directions

1) Download the latest stable version of PHPBB (We are using PHPBB3.0.1)
2) Extract the archive to your desktop, preserving the file tree. (C:\temp\PHPBB3)
3) Upload the contents of the archive to your web server. (/abluestar.com/temp/phpBB3/)
4) Browse to the installation page

5) Click the install tab at the top of the page. Then click the “Proceed to next step” button.

6) On this page your system will be checked for the basic requirements.

7) Enter your database settings

8 ) Set up the boards administrative user

9) Set Advanced settings. Most of these settings can be left as there defaults or changed later.

10) Create database tables. This page creates the nessary tables on your database for the forum system to store your settings.

11) Final stage, this is just a conformation page that everything has been installed correctly. You can now browse to the install directory.

12) Main page. At this stage you should delete the /install/ directory from the PHPBB3 folder.

13) At this point you can log in to your forums adminitation panle and configure your forums to suit your needs, but this beyond the scope of this tutorial.

This tutorial was written for COMP2920, Steven Smethurst, B.J. Wilson, Dennis Warren

How to block spam on a wordpress Blog

To help stop spam activate the Akismet plugin.

  1. Login to your wordpress blog
  2. On the right hand side there is a pugin button, click it
  3. Activate Akismet plugin (download here if its not all ready installed)
  4. Get a Wordpress API key http://wordpress.com/api-keys/ (its free)
  5. Set the Wordpress API key in the Akismet settings page.

99.98 % of spam will automatically be rejected. You should check the spam folder every once in a while to remove false positives.

PHP strip non alphanumeric

On EveryDayFiction.com, in the titles of the posts our editors insisted on including a non alphanumeric character.
The little dot that separates the title from the author. This causes havoc with a lot of my scripts and is really freaking annoying.

This handy little function strips all the non  alphanumeric character from the string.

function strip_non_alnum($str) {
$str = preg_replace(’~^(\s*)(.*?)(\s*)$~m’, “\\2″, $str);
$str = ereg_replace(”[^[:alnum:] ]”,”",$str);
return $str ;
}

Not alowing comments

I was browsing warrenellis.com website the other day and tuned in to his 4am pod cast.
After it was done I went to leave a comment only to find that comments have been turned off.

Instead he suggest that you make a comment on your own site and use a track back to his website.
Warren Ellis is a decently big fish on the intarweb(s) so he actually gets track back.
I checked Technorati 5600 links with an authority: 1,349 thats damn good.
Comparatively EveryDayFiction.com has 140 links and an authority 83.

Its a good idea.
Lots of link backs so his Google rank goes up.
When someone comments on one of his posts, all of there readers also hear about it and more people view his site.

Anyways as for my comment.

Cialis pills. Generic cialis tadalafil mg pills nextag com….

Keeping track of your comments

One problem i have is that while i am browsing around the internet making comments on peoples blogs i often forgot to check back in a week to see if there are any responses.

Some people have ‘Subscribe to comments via email’ plugin installed but it dosn’t work one blogs that get 100+ comments per post.

Subscribe to comments via email

This is a popular solution for many web site developers, its a little check box at the bottom of each post that lets your users get a email notification automatically when ever someone replies to the post. Easly installed on most blogging platforms with a plugin.

The Advantages
Easy install, Simple for the users.

The Disadvantage
It can get annoying to get 100+ comments on a post that is very popular.

coComment.com

There is also online service called coComment.com that tries to create a list of all your online conversations. It works by installing a browser plug-in that checks the pages for certain HTML elements and inserts a coComments bar. When you post a comment on a supported blogging platform such as Wordpress, Blogger, Flicker, Digg, Type pad, and others it copies the comment and adds it to your online profile. When someone replies to the post you are altered with a icon in your browser.

The Advantage
It creates a clean easy to read list of posts where there have been replies since you last made a comment, and its dead simple to use.

The Disadvantage
The problem is that it doesn’t always work, for me it worked about 80% of the time but not all the time.

Conclusion

There is no prefect solution that I can find for keeping track of all your comments but coComments is probably the easiest one to use even if it doesn’t work all the time.

Mistakes I have made

mistake.gifThese are some of the mistakes I have made over the past few years with Blogging and web design. These mistakes have cost me hours of extra work and in some cases months headache’s. Hopefully you can learn from my mistakes and save yourself some time.

  • Used a sub directory - When you browse to this blog you will might have noticed that its stored in a sub directory (’http://www.abluestar.com/blog/’) instead of the base directory (’http://www.abluestar.com/’). This is bad for SEO and but I didn’t know that when I first installed this blog. I just used my hosts default directory (’/blog/’) and now its too late to go back and fix it there are already too many links set up.
    Lesson learned: Use your base directory for your blog.
  • Used sub domains - When ever I created a new project I would create a new sub domain for it (projectx.abluestar.com). It made things really easy to sort and organize but Search engines saw it as two different sites and when one project when up the others where not effected.
    Lesson learned: Use sub directories not sub domains
  • Used my host as my registrar - I registered all my domains with my host, when I out grew my host and went searching for a new one, my old host made it extremely hard to tranfer/forward all my domains to the new server. It took months to get everything reorganized. Now I use one company as a registrar and anther as my host.
    Lesson learned: Don’t get stuck with one company.
  • Everything in one basket - Similar to the last one, All my domains, and my websites where hosted by one company in one location. The companies servers when down for 2 days and all my projects died over night. It was disastrous on how many uses I lost in two days. it wouldn’t have been so bad to clean up if only one or two sites dropped out but all at once created a lot of extra work for me over the next months.
    Lesson learned: Don’t put everything in one basket even if its easier.
  • No clear theme - This was a big one for me, I had lots of ideas for posts but no general theme for the website. For the first few months my website was a filled with random posts with nothing to do with each other. It was impossible to do any marketing for. At the end of 3 months I had 10 subscribers all people I knew. After I switched to a unique website theme ‘Games games and more games‘ it became much easier and at the end of the first month I had 30 new subscribers.
    Lesson learned: Define your theme from the start.
  • English - My English was/is appalling, its one of the biggest faults I have. I re-read some of my posts from 4-5 years ago and there completely unreadable, they where so bad that I couldn’t even figure out what I was talking about. Over the past few years I have spent a lot of time trying to improve my English skills, there not great but there better then they once were.
    Lesson learned: Learn English before you try to blog.
  • Writing for myself - Most posts from last year and earlier where written for me. I often used the word ‘I’, and ‘myself’. I ignored the readers needs and wrote the posts for myself as if I was bragging that I was able to solve a problem. I wouldn’t have thought that to make a big difference but as soon as I started using words like ‘you’ and ‘yourself’ I started getting a lot more comments, and more links. I stopped ignoring my users needs and they stopped ignoring me.
    Lesson learned: Write for your users not yourself.
  • Action words - It may sound stupid but I never told the users what I expected them to do with the information that I gave them. For example in this post ‘I expect you to learn from my mistakes and try and avoid them’. The action words are right in the first paragraph and there clear on what this posts is all about. Once you are done reading this post you should have a clear idea of what you need to do next.
    Lesson learned: Tell the readers what to do.
  • Too many RSS feeds - This one was a big for me, every web site that I enjoyed reading I subscribed to. My thinking was that if I organized the data properly it would make it a lot easier to read and I would save time. The problem was that after three months I had 150 RSS feeds and I was getting 400+ new posts a day, I spent 6+ hours a day reading nothing but RSS feeds and I still wasn’t catching up. Because I was spending so much time reading other peoples posts, my post quality dropped and I lost readers on my website. I have since removed all but 10 RSS feeds, and I get around 20 posts a day, much more manageable.
    Lesson learned: Less feeds more quality
  • Ran out of ideas - When I started my first blog I had lots of ideas. After the first 6 months I couldn’t think of anything, I couldn’t even remember all the ideas that I had at the start. So I went to a park with a sketch book and pounded out 25 new ideas over the next few hours. Now I keep this sketch book where ever I go. When ever I have an idea I write it down, no matter how stupid it may seem. When ever I am stuck for an idea I open the book and search for an idea that I have not posted about.
    Lesson learned: Keep an idea book.

Where I went wrong

things_that_can_go_wrong.jpgToday I read a post by Jane May at John chow dot com, The Secrets of Picking A Niche its a good read if you got 7 mins to spare. The article talks about how to pick the right Niche or subject for your blog or upcoming website. It got me thinking about my own Niche blog Games games and more games and I realized where I went wrong.

  • Time to reflect
    I spent a lot of time thinking about what I would like to write about. I wrote a big list of all the things that I enjoy in life and one of them happened to be boardgames. When I started writing the blog I was running a weekly boardgames night where 6-10 would get together every Sunday and play games. I had been doing this for about 3-4 months and I had collected about 50 different unique games and I was always on the search for new games.
  • How’s the competition?
    When I was searching for games to play I found there was basically 2 major competitors, both of them have very old fashion websites cluttered and annoying to read. I would have no problem creating a better web2.0 style site that would function and look a lot better.
  • Will you be able to write enough?
    Tons, games have been played for thousands of years and everyone has there own version of each game. I have been writing about games for 2 months now and I have barely scratched the surface of dice games.
  • How can you monetize this topic?
    It shouln’t be that hard, people look for the rules to a games and when they find it they might want the accessory’s for the game. Or they might be interested in other versions of the game. Books on games, electronic versions, etc.

So good so far right?
Well the last one was hard for me to gage until I had been working on the site for a few months.

  • Is your niche on the rise?
    One of the reasons that there are not too many off line games sites is that not too many people go searching for new games. When I was learning games to write about I asked my friends. When they learned about games they learned it from word of mouth. Not too many people search the internet for rules and if they do they are looking for something very specific. Its also hard to get a community for offline games, once someone has found what they where looking for they leave and rarely come back, with no community its hard to keep the site going and its even harder to get your users to submit content for the site.

So My games site probably will never have a community, and there is almost no chance that people will subscribe to the RSS feed. People come get what they want and leave.

So I should give up right?
No! My games site is a perfect example of timeless content, the content on this site will still be valid in 5-10 years or more. As the amount of content increases the site will be come more valuable.

Also I enjoy writing about games, I’m learning a lot and I’m having fun writing about them. I won’t get a community but I will be the only person in the city that knows 10,000 different card and dice games, any game that I don’t know I should be able to make a good guess at the rules. I wont be famous on the internet like John chow dot com but I will be populare in my own city and thats enough for me.

Removing the Nofollow link

bzlogo.pngBack in the day, there was a major problem with people posting garbage comments on blogs or forms so they could get back links to there site. Every time they made a new post they would get anther back link and there ranking would rise.

Then google and yahoo introduced the nofollow link parameter that tells a search engine not to add rank to link in a comments section. Over night all the sites that have been posting garbage on blogs and forms dropped out of the ranking. The level of garbage comments dropped significantly but so did the lagitamit comments too. Since people where not getting any benefit from making a comment people stoped taking the time to leave them.

Then someone came up with the Dofollow WordPress plugin that removed the Nofollow parameter from links in the comment section of sites, presumably to get more people to comment. Fight spam not blogs

This would have worked fine if only a small number of people used this plugin and no one knew who used it. But they created a list of all the people using the plugin. This list is a spammers paradise, 1000s of blogs with out the NoFollow parameter. They can make a useless comment on each and every one to get a back link and there ranking will rise.

Also the context value of outgoing links in your posts would drop because there would be so many outgoing links. In other words the value that search engines would give your links that you made in your post that people are commenting about would drop.

The follow plugin seems like a good idea, rewarding people that make good comments. But having a list of people that use the plugin is just asking for trouble.

With this post I can go thou the list of people using the follow plugin and create a comment with a link back to this post, increasing my ranking.

I found out about this plugin from image promoting the Dofollow plugin on jonlee.ca

Edit
While looking around for people to spam this post on I found a post by randaclay.com that talks about a plugin that only removes the no follow link for trackbacks. This is a much better idea, for one it rewards the people that talk about and link to your content. Instead of people who make spam comments.

utrackback_ifollow.gif

Resize thumbnails in Wordpress

I get asked this question lot, how to change the default size of the thumbnail that wordpress creates when you upload an image. There are two different ways of doing it depending on what version of your Wordpress you have installed.

If you have Wordpress prior to 2.1
Open /wp-admin/inline-uploading.php and look for the following code:
if ( $imagedata['width'] > 128 && $imagedata['width'] >= $imagedata['height'] * 4 / 3 )
$thumb = wp_create_thumbnail($file, 128);
elseif ( $imagedata['height'] > 96 )
$thumb = wp_create_thumbnail($file, 96);

The default max size is 128 x 96. You can change these numbers to whatever you like, although you must keep the proper aspect ratio (4 / 3).
For example, to double the size of the thumbnails, replace 128 with 256, and 96 with 192. Be sure to change both sets of numbers - they are each listed in the code twice.

Instructions for WordPress 2.1 or 2.2 and later
Open /wp-admin/admin-functions.php and look for the following code:
$max_side = apply_filters( 'wp_thumbnail_max_side_length', 128, $attachment_id, $file );

This works a bit differently than earlier versions of WordPress. The number specified here (128 by default) is the maximum size of either dimension. You can still just change this to whatever number you like though.

Technorati faves

technoratiicon.gifTechnorati is becoming one of the biggest players in blogging. Its a great tool for ranking one site against anther and its also a search engine of content. Before I make a post I do a quick search on Technorati and see who else has written about it. After I make a post I search Technorati for other blogs that might benefit from my content and posts comments on there blogs.

Technorati has a neat feature where you can add blogs to your favorite list, it generates a single RSS feed of all the posts and its great for building good back links. Some people got it in there mind that they could make a viral cross linking scheme to build your fave count in Technorati.

I found this via Msdanielle.com post You Fave My Blog, I’ll Fave Yours: A Technorati Experiment

Here’s how it goes:
1. Click Here and Add me to your Technorati Favorites List
2. Leave a comment on this post that you’ve added me. Put YOUR Technorati Favorite URL in the comment so I can add you too.
3. I’ll add you to my Technorati Favorites list once I receive your comment.
Then copy and paste this stuff and follow the directions in to your blog.
***Start Copying Here:***

Here are the rules:

  1. Write a short introduction paragraph about how you found the list, including a link to the blog post that referred you to it.
  2. Copy the rules and entire list below and post it on your blog. To avoid duplicate content and increase the number of keywords to each site, change up the titles of the blogs. Just don’t change the links.
  3. Take the “My New Faves” and move them into “The Original Faves” list along with your site. Make sure all links are working properly.
  4. Add 3 blogs to your Technorati Favorites and link them in the “My New Faves” section. Don’t forget to add the “Fave Me” link next to the new blogs (i.e. http://technorati.com/faves?sub=addfavbtn&add=http://www.yourfavesdomain.com)
  5. Add Everyone on this list to your Technorati Favorites List by clicking on “Fave this Site.” Those who want good kharma will fave you back. If not, you will for sure get the benefits of faves from the bloggers who continue this list after you.

My New Faves

Games games and more games Fave this Site
Without Really Trying Fave this Site
Criticaloddness Fave this Site

The Original Faves

Steven Smethurst Fave this Site
Danny Dang
Fave this Site
ReFormatThis Fave this Site
Little Money Fave this Site
MrGaryLee
- Fave this Site
DoshDosh - Fave this Site
NateWhitehill
- Fave this Site
MsDanielle - Fave this Site
JeffKee - Fave this Site
ScribbleOnTheWall - Fave this Site
JimiMorrisonsHead - Fave this Site
JonLee - Fave this Site
Samanathon - Fave this Site
EatDrinknBeMerry - Fave this Site
TheManOfSilver
- Fave this Site
HannesJohnson - Fave this Site
MyDandelionPatch
- Fave this Site
NathanDrach - Fave this Site
SiteLogic - Fave this Site
JuliesJournal - Fave this Site
TeaAndSlippers - Fave this Site
EdLau - Fave this Site
QMusings - Fave this Site
StephenFung - Fave this Site

***End Copying Here***