PDA

View Full Version : [RELEASE v2] Run a SQL query directly from your admin contorl panel


Chen
24 Aug 2001, 10:04
Description:
I see a lot of people here who are trying to fix a problem or install a hack, sometimes requires them to run a SQL query on their database, and just don't know quite how.
I know you can use Telnet, but not everyone has access, and I know there's phpMyAdmin, but who needs all that when you just need to update a table or add a field.
Of course running select queries with this is not very useful, but I'm working on changing that.


Main Features:
- Run a single query
- Run multiple queries
- Option to show / not show query after execution
- Confirmation page


Demo:
1.
http://forum.t-cove.com/query1.gif
2.
http://forum.t-cove.com/query2.gif
3.
http://forum.t-cove.com/query3.gif
4.
http://forum.t-cove.com/query4.gif


Installation:
1. Unzip query.php from the attached zip file and upload to your admin folder.

2. In index.php (under your admin folder), replace
<tr><td>
<table width="100%" border="0" cellspacing="0" cellpadding="2" id="navtable">
<?php maketableheader("Options"); ?>
</table>
<a href="options.php?s=<?php echo $session[sessionhash]; ?>&action=options"> Change options </a>
</td></tr>
with
<tr><td>
<table width="100%" border="0" cellspacing="0" cellpadding="2" id="navtable">
<?php maketableheader("Options"); ?>
</table>
<a href="options.php?s=<?php echo $session[sessionhash]; ?>&action=options"> Change options </a>
</td></tr>

<tr><td>
<table width="100%" border="0" cellspacing="0" cellpadding="2" id="navtable">
<?php maketableheader("SQL Queries"); ?>
</table>
<a href="query.php?s=<?php echo $session[sessionhash]; ?>"> Run a SQL query </a>
</td></tr>


That's it - can it get any more simple? :)
Feedback, requests, future ideas and anything else is more than welcome. :D

joecrow
24 Aug 2001, 10:08
kool thanks for the hack m8 keep up the good work.

Bane
24 Aug 2001, 10:08
Great Idea FireFly! Off to install this one :) Great thinking.

orca
24 Aug 2001, 11:20
Agree with Bane

/me is off installing...

orca
24 Aug 2001, 11:32
Worked like a charm. But I have a suggestion:

If I want to run a query which gives a result, e.g. the example query from mySQL

select BENCHMARK(1000000,encode("hello","goodbye"));


it should display the result. Now it only repeats the query again since I set this option to yes.

Chen
24 Aug 2001, 12:34
Thanks all for the comments.

Originally posted by FireFly
Of course running select queries with this is not very useful, but I'm working on changing that.
Orca, I'll see what I can do. :)
(btw, are you a female or a male? I've been wondering for days now :p)

Thomas P
24 Aug 2001, 16:15
As far as I know he's male (right?)
Great hack btw :D
-Tom

eva2000
24 Aug 2001, 16:15
interesting hack.. :)

butty
24 Aug 2001, 16:51
great hack, so easy 2 install even me gran could have installed it!! :)

Chen
24 Aug 2001, 22:16
I've been working on this alot today.
I wanna go to sleep, and I don't have time to create new screen shots, edit posts and such, so I'm just going to post this new file here and when I wake up I'll sort everything.

This has support for basic queries, such as
SELECT ... FROM ... WHERE
Basically almost everything, except for AS. Don't try using AS, it will not work.

To install this simply upload the new file and overwrite the old one.

A basic screen shot is available in the zip file. *yawn*

Please post any feedback and suggestions about this, so I could fix / add anything to the new re-release! Thanks! :)

Wayne Luke
24 Aug 2001, 23:19
This isn't as fancy but it can run every query MySQL can process. It gives columnized results and it works on all versions of vBulletin. This is probably my first hack ever for vBulletin and I have been using it successfully for the last year.

Just rename it query.php and put a link for it in index.php.

Chen
25 Aug 2001, 08:26
So you're saying I wasted a day of my life? :p
Thanks Wayne. :)

orca
25 Aug 2001, 09:18
Originally posted by FireFly
Orca, I'll see what I can do. :)
(btw, are you a female or a male? I've been wondering for days now :p)

Just checked: Still all male. ;)

Pie'oh'pah
25 Aug 2001, 12:50
Thumbs up dude

This is some serious hack! Small, easy to do and running fine! :D

Thnx

-Alex

webhost
25 Aug 2001, 17:51
Thanks For the hack Firefly, This will make things alot easier.

Fred
24 Sep 2001, 05:26
Got a weird error. I did what you said, then when I clicked on the link on the side to add a query. It went to the page, and above it all had this:

Fatal error: Call to undefined function: getrowbg() in /usr/accountname/forum/admin/query.php on line 66

[VbbFr]Elie
24 Sep 2001, 06:58
It's looking to work but what horible look (wluke file)
One small problem ... If there is HTML in table, there is not keep caracter and translate in HTML in the page ...

Sorry about my bad english :)

GetMeHosted.com
24 Sep 2001, 19:34
Simple, and a all around Great Feature!

Thanks...


God Bless,

Mike Gaidin
25 Sep 2001, 00:03
Great hack FireFly!!!! :D

I love this one. Good job!

JJR512
25 Sep 2001, 00:20
This is a good idea, but it definitely needs some way to view the output. For example, I'd like to be able to run this query and see the list it gives me:
SELECT username FROM user WHERE dct='X' ORDER BY username ASC
(Which involves a custom field in my user table.)

cyrus
25 Sep 2001, 11:28
Is this similar to TELNET ?? ( which I have but it would be easier to do it through here ! )

Also, how acn I make a DB BACKUP through this ??

thanks

Chen
25 Sep 2001, 14:19
JJR512, I understand that the code wluke posted does that.
Like he said, it's not fancy or anythin, but works.

Cyrus, no, not really.
This is more like (a very very lite version of) phpMyAdmin, not Telnet.
Although most of the commands you can use in Telnet you can use here (SELECT, UPDATE, INSERT, DELETE, ALTER queries, stuff like that), I'm not sure how you can do a backup from here.
And don't forget there is a backup utility in vBulletin. :)

JJR512
26 Sep 2001, 06:20
I have had an error with wluke's version. I don't know if there was a thread for that or not, so I don't know where else to put this but here, sorry.

This is the query I attempted to run:
SELECT username FROM user WHERE dct='2' ORDER BY username ASC

This is the error message I received:
Database error in vBulletin Control Panel: Invalid SQL: E
mysql error: You have an error in your SQL syntax near 'E' at line 1
mysql error number: 1064
Date: Wednesday 26th of September 2001 01:16:53 AM
Script: /forums/admin/query.php?action=run
Referer: http://216.118.105.52/forums/admin/w-query.php

JohnBradshaw
26 Sep 2001, 10:15
This has got to be one of the best hacks I have ever seen! Much better then having sort out MyAdmin!

YourHostSucks
27 Sep 2001, 21:04
This is very handy and works like a charm (most of the time) :)

Thanks!

TheComputerGuy
04 Nov 2001, 13:29
This is just the update for 2.20 Enjoy...Follow all other instructions

In the admin/index.php
Find:
// ***
makenavoption("Add","announcement.php?action=add","|");
makenavoption("Modify","announcement.php?action=modify");
makenavselect("Announcements");
// ***

Above that place this:
makenavoption("Run MySQL","query.php?s=<?php echo $session[sessionhash]; ?>");
makenavselect("MySQL Query");

And save and upload

And upload the Query.php to your admin folder....

Enjoy...
Chris

xug
04 Nov 2001, 19:12
Very Cool Hack

Thank you FireFly.

|DarkManX|
04 Nov 2001, 20:05
thanks GREAT HACK!!

SirSteve
08 Nov 2001, 03:46
Works great!

Harvey
20 Mar 2002, 13:28
just another query.php, if I may post it.

features:
- run nearly every command MySQL understands
- select the database
- HTML-Tags are shown as HTML-Tags

missing features:
- multiple queries
- no confirmation

known bugs:
- select of DB only works if host/user/pass are the same as for VBB
- warning on statements wich return no result (it still works, but I don't know how to fix)

Mathiau
27 Mar 2002, 08:34
and i am one of those people who has no idea, appreciated m8!

UltimaKing
27 Mar 2002, 17:24
great hack firefly *installed*

Matt
30 Mar 2002, 15:30
FANTASTIC hack! Just what I need. Thanks :D

Mathiau
17 Apr 2002, 04:37
Hello m8

Does this work in version 2.2.5

When i did a search for

PHP:

<tr><td>
<table width="100%" border="0" cellspacing="0" cellpadding="2" id="navtable">
<?php maketableheader("Options"); ?>
</table>
<a href="options.php?s=<?php echo $session[sessionhash]; ?>&action=options"> Change options </a>
</td></tr>


i could not locat e it at all in admin/ index.php
i tried various pieces from it , but could not locate any of it...?

Frankly cause i used vbhacker, and got a error that told me to run a qeury, but i can not locate phpMyAdmin or whatever u need to run a mysql query :( (amm reading up now to find the answer)

WHAT AM I MISSING!! :(

TECK
17 Apr 2002, 09:23
VB225 Update

In admin/index.php find:makenavoption("vBulletin Options","options.php?t=0","<br>");BELOW this, add:makenavoption("MySQL Query","query.php?action=enter","<br>");Make sure you download the latest hack, located here (http://www.vbulletin.org/forum/attachment.php?s=&postid=160235).

Mathiau
17 Apr 2002, 09:44
wicked, thnx m8!!!!!!!!

TECK
17 Apr 2002, 09:57
you are more then welcome. ;)

bandersen
21 Apr 2002, 16:26
Thank you for this hack!
Installed it with no problem... on 2.2.5

pHAZE_1
22 Apr 2002, 00:47
<tr><td>
<table width="100%" border="0" cellspacing="0" cellpadding="2" id="navtable">
<?php maketableheader("Options"); ?>
</table>
<a href="options.php?s=<?php echo $session[sessionhash]; ?>&action=options"> Change options </a>
</td></tr>

i dont have anything like that in my index.php in my admin folder.

TECK
22 Apr 2002, 00:50
did you read the update i published 5 posts above? is alot easier to read first the thread to make sure there are no updates published.
http://www.vbulletin.org/forum/showthread.php?postid=241576#post241576

pHAZE_1
22 Apr 2002, 01:02
sorry i am pretty damn tired. i read the thread but must have missed that one

erdem
29 Apr 2002, 06:21
tnx for this great hack...
but i cant run this query :

INSERT INTO template (templateid,templatesetid,title,template) VALUES (NULL,-2,'memberoftheday','0||vb||0||vb||0');


is this too complex? this is for stats panel hack..

:classic:

TECK
30 Apr 2002, 03:46
try this:
http://www.vbulletin.org/forum/showthread.php?s=&threadid=37726

let us know if it helped... also try running the query without the ";" at the end, it should work on firefly's hack.

Dean C
08 May 2002, 20:13
Tried running the fifth query in the store hack which is this:

INSERT INTO store VALUES (1, 'username', 'Change Username', '500', '0', 'username.gif', 'With this action you can change your username', 'Y');
INSERT INTO store VALUES (2, 'customtitle', 'Change Custom Title', '300', '0', 'title.gif', 'With this action you can get a custom title and if you dont have one already then get one', 'Y');
INSERT INTO store VALUES (3, 'customavatar', 'Change Custom Avatar', '700', '0', 'avatar.gif', 'With this action you can get a custom avatar or if you already one you can change it...', 'Y');
INSERT INTO store VALUES (4, 'givetitle', 'Give an other user a custom title', '700', '0', 'givetitle.gif', 'With this action you can give an other user a custom title. The title that you give will be showed on every post of that user. <br><b>Tip:</b> Do it when that user dont have enough money to restore his custom title ;)', 'Y');
INSERT INTO store VALUES (5, 'donate', 'Donate money to an other user', '0', '0', 'donate.gif', 'With this "free" action you can donate money to other members.', 'Y');
INSERT INTO store VALUES (6, 'scrap', 'Scrap your yellow/red card', '700', '0', 'card.gif', 'With this action you can scrap your yellow/red card. Want to become a mod but have a yellow/red card? Do this action to begin with a new veb life ;)', 'Y');
INSERT INTO store VALUES (7, 'calendar', 'Add Calendar Event', '500', '0', 'calendar.gif', 'With this action you can add a public calendar event on the calendar', 'Y');
INSERT INTO store VALUES (8, 'glowusername', 'Add Glow To Username', '2000', '0', 'glow.gif', 'With this action you can add an attractive glowing color to your username wich you can define yourself. If you have already a glow then you can change it here aswell.', 'Y');


and now every time i try to run a query i get a database error...

i don't kno what to do ...

pHAZE_1
10 May 2002, 18:55
i have the same problem as Mist, it worked fine until the same point, now no queries work at all.. im stumped

pHAZE_1
10 May 2002, 18:56
i have the same problem as Mist, it worked fine until the same point, now no queries work at all.. i installed the updated version [post # 36] and i use 2.2.5.. *stumped..

springbok
11 May 2002, 12:23
The problem is in the line:

INSERT INTO store VALUES (5, 'donate', 'Donate money to an other user', '0', '0', 'donate.gif', 'With this "free" action you can donate money to other members.', 'Y');

Replace it with:

INSERT INTO store VALUES (5, 'donate', 'Donate money to an other user', '0', '0', 'donate.gif', 'With this free action you can donate money to other members.', 'Y');

I don't know SQL that well, but the excl. marks around "free" are causing it to fail.

Dean C
12 May 2002, 21:34
yes but both myself and phaze1 have done this on our forums and now query.php won't run queries for us...

the whole things is mucked up...

springbok
12 May 2002, 22:12
I'm not sure then. I am also running 2.2.5 and with change was able to install the store without any problems. Wish I could help more.

:disappointed:

Dean C
13 May 2002, 20:17
i ran the 5th query (the long one) as one whole wheras it sed u can run it as seperate ones...

firefly i really need ure help with this...

Dean C
21 May 2002, 20:10
i hate bumping but i really wud like to fix this guyz...

Thanks in Advance

Dean C
21 May 2002, 20:21
i hate bumping but i really wud like to fix this guyz...

Thanks in Advance

Dean C
21 May 2002, 20:23
sorry for postin twice lol... it was goin slow so i did it again...

XFLBret
04 Jun 2002, 09:31
this doesn't work with 2.2.6???

bandersen
23 Jun 2002, 00:06
I have upgraded from 2.2.5 to 2.2.6 and lost my navbar in control panel, and have problem adding it again for this hack.

Any fix or update?

TECK
23 Jun 2002, 01:52
http://www.vbulletin.org/forum/showthread.php?postid=241576#post241576

bandersen
23 Jun 2002, 03:25
Thanks.... I must be getting old... :)

EchoHype.com
25 Jul 2002, 04:12
Hmm, i followed your link nakkid...but instructions for 2.2.6?

TECK
25 Jul 2002, 04:13
the instructions are the same.

EchoHype.com
25 Jul 2002, 04:22
So you're saying that I upload that query.php file you linked me to, the text I need will be found in the index.php file?

Chen
01 Aug 2002, 20:12
Being a disgrace to coding and human race in general, I am closing this one. Use JamesUS's version of the idea, it's [insert large number here] times better.

shovel
01 Aug 2002, 20:33
&nbsp;&nbsp;&nbsp;&nbsp;Would you mind if I revamped the coding and released my own version?

Chen
01 Aug 2002, 21:03
Yes feel free.

shovel
01 Aug 2002, 21:19
&nbsp;&nbsp;&nbsp;&nbsp;Awesome. Thanks Chen.