Author image Andrew Pavlutkin

NAME

WWW::phpBB::Poster - phpBB forum poster

SYNOPSIS

    use WWW::phpBB::Poster;

    # scrape as guest
    my $phpbb   =   WWW::phpBB::Poster->new({
        db_host     =>  'localhost',
        db_user     =>  'root',
        db_password =>  'somepass',
        db_database =>  'forum',
        db_prefix   =>  'phpbb_',
        db_type     =>  'mysql',
        db_charset  =>  'utf8'
    });
    
    if(!$phpbb){
        die(qq[Cannot establish connection!\n]);
    }
    my $forums_list = $phpbb->getForums();
    

DESCRIPTION

I wrote this module for own purposes - exactly for generating SEO-ready forums, already filled in with some parsed data. Hope, it shall be useful for you :)

P.S. It handles only MySQL or SQLite phpBB installation.

P.P.S. It is NOT suggested for fork using - if so - you may got strange results with posts and topics. If you want to use this module with forks - please, fix it manually for InnoDB using - commiting, etc.

REQUIRED MODULES

DBI

Digest::MD5

EXPORT

None.

CONSTRUCTOR

new()

Creates a new WWW::phpBB::Poster object.

Required parameters: HASH REF

  • db_user => $mysql_user

  • db_database => $mysql_db

    Database with an already installed phpBB forum.

Optional parameters: HASH REF

  • db_host => $sql_host

    By default, sets to localhost

  • db_password => $sql_password

    By default, sets to empty

  • db_prefix => $phpbb_prefix

    By default, sets to phpbb_

  • db_port => $sql_port

    By default, sets to 3306

  • db_charset => q[CP1251]

    By default, sets to UTF8

  • db_type => q[SQLite]

    By default, sets to MySQL

PUBLIC METHODS

$phpbb->setUser()

Tries to select user from DB, if none - tries to insert user into DB. Returns ID of user.

Required parameters: HASH REF

  • login => q[Vasya]

Optional parameters: HASH REF

  • password => $phpbb_hash_password

    By default, sets with 'qwerty312', hashed with phpBB

  • email => $user_email

    By default, sets to first 10 symbols of md5(rand(100))@first 10 symbols of md5(rand(100)).ru

  • created => time

    By default, sets to current time

  • user_type => 0

    By default, sets to 0 (USER_NORMAL)

  • group_id => 2

    By default, sets to 2 (REGISTERED)

  • user_from => 'Moscow'

    By default, sets to empty value

  • user_regdate => time

    By default, sets to current time

$phpbb->getUser($intUserID)

Gets user data by ID. Returns a hash of values

  • userID

  • user_type

  • user_regdate

  • login

  • password

  • email

  • user_from

  • group_id

$phpbb->getForumList()

Selects all forums, having parent id (exactly forums, not categories) from DB. Returns a ref to an array, where first key is forum ID, and second - forum name.

$phpbb->setTopic()

Tries to select topic by title and forum id from DB, if none - tries to insert topic into DB and then makes necessary updates with other tables and increases the user post count.

Returns ID of topic.

Required parameters: HASH REF

  • title => q[My first topic]

  • text => q[Content of topic]

  • forumID => 2

  • userID => 2

    ID 1 - Anonymous ID 2 - admin

Optional parameters: HASH REF

  • created => time()

    By default, sets with current time

  • sync_forums => 0/1

    By default - 1 - syncing forum stats after topic adding;

$phpbb->getTopic($intTopicID)

Gets topic data by ID. Returns a hash of values

  • topic_title

  • forum_id

  • topic_poster

  • topic_first_poster_name

  • topic_last_poster_id

  • topic_last_poster_name

  • topic_last_post_subject

  • topic_last_post_time

  • topic_time

  • topic_first_post_id

  • topic_last_post_id

$phpbb->setPost()

Adds post content to topic.

Returns ID of post or undef if no such topic or user.

Required parameters: HASH REF

  • title => q[My first topic]

  • text => q[Content of topic]

  • forumID => 2

  • userID => 2

    ID 1 - Anonymous ID 2 - admin

Optional parameters: HASH REF

  • created => time()

    By default, sets with current time

  • sync_forums => 0/1

    By default - 1 - syncing forum stats after post adding;

  • first_post => 0/1

    By default - 0 - adds 'Re: ' to the post title;

$phpbb->getTopicList($intLimit)

Gets topics list. If limit is undefined, method will return you the whole list of topics. Return format: array of arrays - first key is topic ID, second - topic name.

$phpbb->syncForums()

Syncs forum's count of posts, topics, post_id, poster_id.

AUTHOR

Andrew Jumash, <skazo4nik@gmail.com>

COPYRIGHT AND LICENSE

Copyright (C) 2010 by Andrew Jumash, http://www.skazkin.ru

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.