2004-07-06, 04:37 PM
Quoted from my post at myBB Mods:
I'm posting this at both places because I need this really badly.
Ryan @ MyBB Mods Wrote:Well, I've changed it completely around from what I was gonna do originally.
I've got the database all set up with a new table called "installs" with the following: username, uid, and tid.
And when someone installs the mod their username, uid, and the tid of the thread is inserted into the table.
I got it all set up and I click install to test it. The information is inserted into the database fine, but, the install doesn't change to an uninstall link.
It's confused me...
Here's the code I used in showthread.php.
// ############################# Install Hack ##################################
// Database Stuff
if ($thread[fid]==2)
{
$installerid = $db->query("SELECT uid FROM installs WHERE tid = $tid and uid = $mybbuser[uid]");
}
// Install Link
if ($thread[fid]==2 && $installerid[uid]!=$mybbuser[uid])
{
$install="( <a href=\"showthread.php?do=install&tid=$tid\">Install This Mod</a> )";
}
else
{
$install="";
}
// Uninstall Link
if ($thread[fid]==2 && $installerid[uid]==$mybbuser[uid])
{
$uninstall="( <a href=\"showthread.php?do=uninstall&tid=$tid\">Uninstall This Mod</a> )";
}
else
{
$uninstall="";
}
// Do Install
if ($_REQUEST["do"] == "install")
{
if ($installerid[userid]!=$mybbuser[uid])
{
$db->query("
INSERT INTO installs
(username,uid,tid)
VALUES
('".addslashes($mybbuser[username])."','".$mybbuser[uid]."','".$tid."')
");
}
eval("\$message = \"".$templates->get("redirect_installed")."\";");
redirect("$settings[bbname] - Mod Installed", $message, "showthread.php?tid=$tid");
}
// Do Un-Install
if ($_REQUEST["do"] == "uninstall")
{
$db->query("
DELETE FROM installs WHERE tid = $tid AND uid = $mybbuser[uid]
");
eval("\$message = \"".$templates->get("redirect_uninstalled")."\";");
redirect("$settings[bbname] - Mod Uninstalled", $message, "showthread.php?tid=$tid");
}
// ####################### End Install Hack ####################################
Anything wrong?
I'm posting this at both places because I need this really badly.