PDA

View Full Version : Dumping Queries


sabret00the
02-18-2003, 10:29 AM
I'm trying to uninstall 2 hacks, but unfortunately they didn't come with an uninstaller, i'm wondering how would i go about dumping the database queries?

Xenon
02-18-2003, 11:46 AM
ALTER TABLE tablename DROP field

or DROP TABLE tablename

sabret00the
02-18-2003, 12:30 PM
ok for example heres the first one i'm trying to drop, this is a C+P from the (karma) install file


case 2:
$query[0] = "DROP TABLE IF EXISTS point";

$query[1] = "CREATE TABLE point (newthread int(20) default NULL, reply int(20) default NULL, reply1 int(20) default NULL, reply2 int(20) default NULL, reply3 int(20) default NULL, reply4 int(20) default NULL, reply5 int(20) default NULL, replypoint1 int(20) default NULL, replypoint2 int(20) default NULL, replypoint3 int(20) default NULL, replypoint4 int(20) default NULL, replypoint5 int(20) default NULL, view1 int(20) default NULL, view2 int(20) default NULL, view3 int(20) default NULL, view4 int(20) default NULL, view5 int(20) default NULL, viewpoint1 int(20) default NULL, viewpoint2 int(20) default NULL, viewpoint3 int(20) default NULL, viewpoint4 int(20) default NULL, viewpoint5 int(20) default NULL, addpoint int(20) default NULL, penalty int(20) default NULL, maxpenalty int(20) default NULL, agreepoint int(20) default NULL, dispoint int(20) default NULL, imaword char(1) default NULL, ban char(3) default NULL, expoint int(20) default '0')";

$query[2] = "DROP TABLE IF EXISTS storepoint";

$query[3] = "CREATE TABLE storepoint (uid int(200) NOT NULL default '0', newthread int(20) default NULL, reply int(20) default NULL, view int(20) default NULL, admin_mod int(20) default NULL, morereply int(20) default NULL, totalpenalty int(20) default NULL, date date default NULL, redeem_points int(20) default NULL)";

$query[4] = "DROP TABLE IF EXISTS adis";

$query[5] = "CREATE TABLE adis (postid int(20) default NULL, userid int(20) default NULL, username varchar(100) default NULL, post_userid int(20) default NULL, adis char(1) default NULL, comment varchar(255) default NULL)";

$query[6] = "DROP TABLE IF EXISTS prize";

$query[7] = "CREATE TABLE prize (prizeid varchar(25) NOT NULL default '', title varchar(100) NOT NULL default '', description text, karmapoints smallint(6) NOT NULL default '0', url varchar(150) NOT NULL default '', avatarpath varchar(100) NOT NULL default '', success_url varchar(250) NOT NULL default '', error_url varchar(250) NOT NULL default '', PRIMARY KEY (prizeid))";

$query[8] = "DROP TABLE IF EXISTS prize_exp";

$query[9] = "CREATE TABLE prize_exp (exp enum('0','1','2') NOT NULL default '0')";

$query[10] = "DROP TABLE IF EXISTS temp_point";

$query[11] = "CREATE TABLE temp_point (username varchar(200) NOT NULL default '', point int(100) NOT NULL default '0')";

$query[12] = "DROP TABLE IF EXISTS ucode";

$query[13] = "CREATE TABLE ucode (prizeid int(100) NOT NULL default '0', userid int(100) NOT NULL default '0', start_date timestamp(14) NOT NULL, redeem_date timestamp(14) NOT NULL, ucode varchar(100) NOT NULL default '', redeem enum('y','n') NOT NULL default 'n')";

$message = array(
"DROP TABLE point",
"CREATE TABLE point",
"DROP TABLE storepoint",
"CREATE TABLE storepoint",
"DROP TABLE adis",
"CREATE TABLE adis",
"DROP TABLE prize",
"CREATE TABLE prize",
"DROP TABLE prize_exp",
"CREATE TABLE prize_exp",
"DROP TABLE temp_point",
"CREATE TABLE temp_point",
"DROP TABLE ucode",
"CREATE TABLE ucode"
);

head("Creating tables...");
print "<br>";
if ($action=='setsql') {
mysql_connect($servername, $dbusername, $dbpassword);
mysql_select_db($dbname);
$failed = 0;
for ($i=0; $i<14; $i++) {
$result = mysql_query($query[$i]);
if ($result) {
print "<table border=0 width=30% align=center>";
print "<tr><td><font face=verdana size=2>$message[$i] successful.</font></td></tr>";
print "</table>";

}
else {
print "<p align=center>$message[$i] not successful.</p><br>";
print "mysql_error($result)<br>";
$failed = 1;
}
}
echo "</p>";
if (!$failed) {
print "<form action=$script method=post>\n";
print "<p align=center>\n";
print "<input type=submit value='Next' style='font-family: Verdana; font-weight: bold;'>\n";
print "<input type=hidden name=page value=3>\n";
print "<input type=hidden name=action value=modify>\n";
print "</p>\n";
print "</form>\n";
}
}
foot();
break;



and the second is here (from mood5 hack)


// ******************* STEP 2 *******************
if ($step==2) {

echo "Editing the <i>user</i> table ... ";
$DB_site->query("ALTER TABLE user ADD mood varchar(25) NOT NULL");
echo("<br><b>mood field added!<p><br>\n");
$DB_site->query("ALTER TABLE user ADD reason varchar(25) NOT NULL");
echo("<br><b>reason field added!<p><br>\n");
$DB_site->query("ALTER TABLE user ADD drate varchar(10) NOT NULL");
echo("<br><b>drate field added!<p><br>\n");
$DB_site->query("ALTER TABLE user ADD off varchar(25) NOT NULL");
echo("<br><b>off field added!<p><br>\n");
$DB_site->query("ALTER TABLE user ADD time varchar(18) NOT NULL");
echo("<br><b>time field added!<p><br>\n");
$DB_site->query("ALTER TABLE user ADD today varchar(18) NOT NULL");
echo("<br><b>today field added!<p><br>\n");
$DB_site->query("ALTER TABLE user ADD comments varchar(250) NOT NULL");
echo("<br><b>comments field added!<p><br>\n");
echo("<br><b>Database Manipulation Complete!<p><br>\n");
echo("<br><b>Move on to the next part!<p><br>\n");

gotonext();
}



how would i go about removing these two?

Xenon
02-18-2003, 12:51 PM
the first is very easy, because the queries are already named:
$query[0] = "DROP TABLE IF EXISTS point";
$query[2] = "DROP TABLE IF EXISTS storepoint";

$query[4] = "DROP TABLE IF EXISTS adis";


$query[6] = "DROP TABLE IF EXISTS prize";

$query[8] = "DROP TABLE IF EXISTS prize_exp";

$query[10] = "DROP TABLE IF EXISTS temp_point";


$query[12] = "DROP TABLE IF EXISTS ucode";



And seconds:
ALTER TABLE user DROP today,comments,time,off,drate,reason,mood

sabret00the
02-18-2003, 01:07 PM
ok so the second one i'd do in the phpmyadmin but what about the first should i make a php file or something 0_o

Xenon
02-18-2003, 01:19 PM
just run the queries within the strings....

sabret00the
02-18-2003, 02:43 PM
thanks alot you just helped me out loads