Ok here it is.
INSTALL THIS AT YOUR OWN RISK! YOU'VE BEEN WARNED
This addon, at present, requires some modification of a core WoWRoster file, so plz don't install this unless you know what you're doing and are prepared for the consequences if you break it or if I miss a step in this guide...
First, we need to create 2 new tables in the wowroster database:
- Code: Select all
CREATE TABLE `bookworm_books` (
`book_id` int(10) unsigned NOT NULL auto_increment,
`hash` varchar(15) NOT NULL default '',
`title` tinytext NOT NULL,
`num_pages` tinyint(3) unsigned NOT NULL default '0',
`material` tinytext NOT NULL,
`found_by` tinytext NOT NULL,
`zone` tinytext NOT NULL,
`subzone` tinytext NOT NULL,
`x` int(11) NOT NULL default '0',
`y` int(11) NOT NULL default '0',
PRIMARY KEY (`book_id`),
UNIQUE KEY `noDUPES` (`hash`,`found_by`(254))
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=44 ;
CREATE TABLE `bookworm_pages` (
`page_id` int(10) unsigned NOT NULL auto_increment,
`book_hash` varchar(15) NOT NULL default '',
`page_num` tinyint(4) unsigned NOT NULL default '0',
`text` text NOT NULL,
PRIMARY KEY (`page_id`),
UNIQUE KEY `noDUPES` (`book_hash`,`page_num`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=237 ;
I plan to work that into the addon later, similar to siggen asking you about installing the neccessary tables... Anyway, on to the update.php modification.
Open /admin/update.php and here's a long list of modifications to allow it to accept a new file...
Search for:
- Code: Select all
$filefields[] = 'CharacterProfiler.lua';
$filefields[] = 'PvPLog.lua';
Add after:
- Code: Select all
$filefields[] = 'Bookworm.lua';
Search for:
- Code: Select all
if( isset($data['PurgeLogData']) )
{
$uploadData['PvpLogData'] = $data;
}
if( isset($data['myProfile']) )
{
$uploadData['myProfile'] = $data['myProfile'];
}
Add after:
- Code: Select all
if( isset($data['BookwormBooks']) )
{
$uploadData['BookwormBooks'] = $data['BookwormBooks'];
}
Search for:
- Code: Select all
if( is_array($uploadData['myProfile']) )
{
$updateMessages = processMyProfile($uploadData['myProfile']);
}
if( is_array($uploadData['PvpLogData']) )
{
$updatePvPMessages = processPvP($uploadData['PvpLogData']);
}
Add after:
- Code: Select all
if( is_array($uploadData['BookwormBooks']) )
{
$updateBookwormMessages = processBookworm($uploadData['BookwormBooks']);
}
Insert this function:
- Code: Select all
function processBookworm($bookwormdata)
{
global $wowdb, $roster_conf, $wordings;
$wowdb->resetMessages();
foreach ($bookwormdata['bookList'] as $bookTitle => $bookData)
{
foreach ($bookData as $sightingCount => $bookVars)
{
$hash = $bookVars['hash'];
$num_pages = $bookVars['pages'];
$material = $bookVars['material'];
foreach ($bookVars as $varName => $value)
{
if(substr($varName,0,3) == "loc"){
$found_by = $value[1];
$zone = substr($varName,4);
$subzone = $value[5];
$x = $value[3];
$y = $value[4];
}
}
for($i=1;$i<=$num_pages;$i++){
$page_num = $i;
$page_text = $bookVars["page$i"];
$query = "INSERT INTO `bookworm_pages` (book_hash, page_num, text) VALUES ('".addslashes($hash)."', '".addslashes($i)."', '".addslashes($page_text)."');";
$result = $wowdb->query( $query );
}
}
$query = "INSERT INTO `bookworm_books` (hash, title, num_pages, material, found_by, zone, subzone, x, y) VALUES ('".addslashes($hash)."', '".addslashes($bookTitle)."', '".addslashes($num_pages)."', '".addslashes($material)."', '".addslashes($found_by)."', '".addslashes($zone)."', '".addslashes($subzone)."', '".addslashes($x)."', '".addslashes($y)."');";
$result = $wowdb->query( $query );
$output .= "\"$bookTitle\" has been processed.<br />\n";
}
return $output;
}
Search for:
- Code: Select all
$updateMessages.
$updatePvPMessages.
Add after:
- Code: Select all
$updateBookwormMessages.
Search for:
- Code: Select all
print '<input type="hidden" name="data" value="'.htmlspecialchars(stripAllHtml($updateMessages.$updatePvPMessages.$rosterUpdateMessages)).'" />'."\n";
Replace with:
- Code: Select all
print '<input type="hidden" name="data" value="'.htmlspecialchars(stripAllHtml($updateMessages.$updatePvPMessages.$updateBookwormMessages.$rosterUpdateMessages)).'" />'."\n";
Search for:
- Code: Select all
$auth_message.
$updateMessages.
$updatePvPMessages.
Add after:
- Code: Select all
$updateBookwormMessages.
Now update.php should be ready to accept the new file. The only thing I DIDN'T do was add the actual html form input to upload the file. Right now you can either upload bookworm.lua in the "PvPLog" slot on the webpage and the code will sort it out, or you can upload bookworm.lua using UniUploader.
That should be all the prep work needed. Now just install the attached addon like you would any other addon and you're all set!