Dunno how various boards work, but here's my code that I made to search and store the ID codes and quality of items (in PHP.) Anyone tech savvy should be able to figure out how to convert it. Note that "$innards" contains the value that was given inside the tag. So if someone put in [tag]Primal Mana[/tag], then $innards should be "Primal Mana". You'll have to figure out how to declare a new tag on your board and how to get its contents. And of course you'll need to figure out how to add the thottbot script to the page.
$item_code = -1;
$quality = 0;
$db = get_db();
$db->prepare("check_thott", "SELECT code, quality FROM thott_items WHERE item_name=$1");
$db->executeQuery("check_thott", Array($innards));
if ($db->rowCount() > 0) {
$item_code = $db->result(0, "code");
$quality = $db->result(0, "quality");
}
else {
$ch = curl_init("http://thottbot.com/?s=" . urlencode($innards));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, false);
$page = curl_exec($ch);
if (curl_errno($ch) != 0) { // Thottbot errored
curl_close($ch);
}
else {
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ( // We were redirected to the specific item page
$http_code == 302
&& preg_match("/.*http:\/\/thottbot.com\/i(\d+).*/", $page, $matches) !=0
) {
$item_code = $matches[1];
$ch = curl_init("http://thottbot.com/i" . $item_code);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, false);
$page = curl_exec($ch);
if (curl_errno($ch) != 0) { // Thottbot errored
curl_close($ch);
}
else {
curl_close($ch);
if (preg_match("/.*quality(\d).*/", $page, $matches) != 0) {
$quality = $matches[1];
$db->prepare("insert_thott", "INSERT INTO thott_items (item_name, code, quality) VALUES ($1, $2, $3)");
$db->executeCommand("insert_thott", Array($innards, $item_code, $quality));
}
}
}
else {
$res = preg_match("/.*<span class=quality(\d)><a href='i(\d+)'>" . $innards . "<\/a><\/span>.*/", $page, $matches);
if ($res == 0) {
if (preg_match("/.*No search results found.*/", $page, $matches) != 0) {
$db->prepare("insert_thott", "INSERT INTO thott_items (item_name, code, quality) VALUES ($1, $2, $3)");
$db->executeCommand("insert_thott", Array($innards, "-1", 0));
}
}
else {
$quality = $matches[1];
$item_code = $matches[2];
$db->prepare("insert_thott", "INSERT INTO thott_items (item_name, code, quality) VALUES ($1, $2, $3)");
$db->executeCommand("insert_thott", Array($innards, $item_code, $quality));
}
}
}
}
if ($item_code == -1) {
$self = new HTMLObject();
$self->setTag("span");
$self->setStyle("text-decoration: underline;");
$self->set($innards);
}
else {
$self = new Link(
"http://thottbot.com/i" . $item_code,
"[" . htmlspecialchars($innards, ENT_QUOTES, "UTF-8") . "]"
);
$self->setClass("quality" . $quality);
}
---------
And here are my class definitions:
a.quality0{
color: grey;
text-decoration: none;
font-weight: bold;
}
a.quality1{
color: black;
text-decoration: none;
font-weight: bold;
}
a.quality2{
color: green;
text-decoration: none;
font-weight: bold;
}
a.quality3{
color: blue;
text-decoration: none;
font-weight: bold;
}
a.quality4{
color: purple;
text-decoration: none;
font-weight: bold;
}
a.quality5{
color: orange;
text-decoration: none;
font-weight: bold;
}
a.quality6{
color: red;
text-decoration: none;
font-weight: bold;
}