Hello everyone,
Well, this one's been a much-traveled hack. I installed this on version 2.2.8, even knowing there were problems, because I wanted to see if I could find out some way of helping with a couple of the problems - this is a very cool hack and I hate to see it go to waste.
One of the main concerns appears to be the query load. Because of the way the hack works, even with Link's fix, there is an insane amount of queries -per post- to process the display of items.
Vivi actually saw that this was a problem and posted a fix wayyy back in the early pages of the thread. However, the fix missed a step, and I wasn't able to properly get a good display going without the load until recently.
Basically, I applied Vivi's fix, and included the one step he missed when he first posted it. I believe this should help on the server load and reduce the queries to nil.
Since I have limited experience with php and mySQL, try this out at your own risk. Be sure to backup the files you're hacking.
1. showthread.php edits (do this step TWICE since there are two instances in the code)
In showthread.php, find the following:
Quote:
post.*,post.username AS postusername,post.ipaddress AS ip,user.*,userfield.*,".iif($forum[allowicons],'icon.title as icontitle,icon.iconpath,','')."
|
replace it with:
Quote:
post.*,post.username AS postusername,post.ipaddress AS ip,user.*,userfield.*,items_user.*,".iif($forum[allowicons],'icon.title as icontitle,icon.iconpath,','')."
|
find:
Quote:
LEFT JOIN userfield ON userfield.userid=user.userid
|
add this BELOW:
Quote:
LEFT JOIN items_user ON items_user.userid=user.userid
|
2. admin/functions.php edits
find the original hack of functions.php for the item shop, as instructed by the installer. It should be something like this (link's fix is similar-looking):
Quote:
global $DB_site;
$nr=1;
while ($nr <= 50) {
$catstuff=$DB_site->query_first("SELECT * FROM items_cats WHERE id=$nr");
$its=$DB_site->query("SELECT * FROM items WHERE cat=$nr ORDER BY name $asds");
if(sizeof($catstuff)==16) {
if($catstuff[type]==1) {
$uid=$DB_site->query_first("SELECT item0,points0,description0,icon0,itid0 FROM items_user WHERE userid=$post[userid]");
if($uid[0]!='No Item') {
$post[items] .= "<a href=\"itemshop.php?action=view&id=$uid[4]\"><img src=\"https://vborg.vbsupport.ru/greentek/itemshop/prs.gif\" border=\"0\"></a> ";
} else {
$post[items] .= "<img src=\"https://vborg.vbsupport.ru/greentek/itemshop/No Item.gif\" border=\"0\"> ";
}
} else {
$uid=$DB_site->query_first("SELECT item$nr,points$nr,description$nr,icon$nr,itid$nr FROM items_user WHERE userid=$post[userid]");
if($uid[0]!='No Item') {
if(empty($uid[3])) {
$post[items] .= "<a href=\"itemshop.php?action=view&id=$uid[4]\"><img src=\"https://vborg.vbsupport.ru/greentek/itemshop/$uid[0].gif\" border=\"0\"></a> ";
} else {
$post[items] .= "<a href=\"itemshop.php?action=view&id=$uid[4]\"><img src=\"https://vborg.vbsupport.ru/greentek/itemshop/$uid[3].gif\" border=\"0\"></a> ";
}
} else {
$post[items] .= "<img src=\"https://vborg.vbsupport.ru/greentek/itemshop/No Item.gif\" border=\"0\"> ";
}
}
} else {
break;
}
$nr++;
}
|
replace it with:
Quote:
if($post[item0]!='No Item') {
$post[items] .= "<a href=\"itemshop.php?action=view&id=$post[itid0]\"><img src=\"https://vborg.vbsupport.ru/greentek/itemshop/prs.gif\" border=\"0\"></a> ";
} else {
$post[items] .= "<img src=\"https://vborg.vbsupport.ru/greentek/itemshop/No Item.gif\" border=\"0\"> ";
}
$nr=1;
while ($nr <= 3) {
$xc="item$nr";
if($post[$xc]!='No Item') {
$xvv = "item$nr";
$xv = "itid$nr";
$xvvv = "icon$nr";
if(empty($post[$xvvv])) {
$post[items] .= "<a href=\"itemshop.php?action=view&id=$post[$xv]\"><img src=\"https://vborg.vbsupport.ru/greentek/itemshop/$post[$xvv].gif\" border=\"0\"></a> ";
} else {
$post[items] .= "<a href=\"itemshop.php?action=view&id=$post[$xv]\"><img src=\"https://vborg.vbsupport.ru/greentek/itemshop/$post[$xvvv].gif\" border=\"0\"></a> ";
}
} else {
$post[items] .= "<img src=\"https://vborg.vbsupport.ru/greentek/itemshop/No Item.gif\" border=\"0\"> ";
}
$nr++;
}
|
(NOTE: be sure to change https://vborg.vbsupport.ru/greentek to imagesfolder, i.e. the word "imagesfolder" enclosed in curly braces, when you cut and paste this!)
You should now have a less bloated bunch of code to process the images and items for each poster in a thread. As an added bonus, since the items_user is now LEFT JOIN'd to the $post array, you can individually call items by fieldname in the array. I do this because I don't like to see icons, but names. It varies depending on your categories and such, but if you use
$post[item1]
When editing your postbit, you should get the text name for the item in that category in your postbit, if you want a different one, try [item2], [item3], etc.
I hope this works and that it helps some of you out.