Help - Search - Members - Calendar
Full Version: [RESOLVED] Data from a DB
StealthBot.net > StealthBot > Scripting and Plugins > Plugin Projects
DotA-Angel
Hy guyz hope some off u got some time to help me on this project... we need this script asp ... Here i start:

There is mdb DB and i want to make the bot upload some data to an FTP and from that FTP to a section on the webside.. It`s for a dota League.. and we want to post @ Site all the players ranks... acces.. I started with jack to try to make something but we got stuck.. sad.gif Maybe some 1 who knoes php can help me...
We got atm this script.

CODE
'dbtotxt
'0.1

Private Const dbtotxt_dbpath  = "C:\Program Files\StealthBot\plugins\userdb.mdb"
Private Const dbtotxt_txtpath = "C:\Program Files\StealthBot\plugins\userdb.dat"

Public Const db_Server = ""
Public Const db_Username = ""
Public Const db_Password = ""

Private db_FSO

Sub dbtotxt_Event_Load()

   Set db_FSO = CreateObject("Scripting.FileSystemObject")
   'TimerEnabled "dbtotxt", "upload", True
   TimerEnabled "dbtotxt", "upload", 120 ' 2 minutes
End Sub

Sub dbtotxt_upload_Timer()

   Set conn_ = CreateObject("ADODB.Connection")
   conn_.ConnectionString = "Driver={Microsoft Access Driver (*.mdb)};Dbq=" & dbtotxt_dbpath
   conn_.Open

   Set rows = conn_.Execute("Select * FROM `Users` ORDER BY Username")

   Do While Not rows.EOF
      d = d & rows("Username") & "|||"
      d = d & rows("Wins") & "|||"
      d = d & rows("Losses") & "|||"
      d = d & rows("Voucher") & "|||"
      d = d & rows("Lastgame") & "|||"
      d = d & rows("Experience") & "|||"
      d = d & db_get_rank(rows("Rank")) & "|||"
      d = d & rows("Patron") & "####"
      rows.MoveNext
   Loop

   Set f = db_FSO.OpenTextFile(dbtotxt_txtpath, 2, True)
   f.Write d
   f.Close

   scInet.URL = db_Server
   scInet.Username = db_Username
   scInet.Password = db_Password
   scInet.Execute scInet.URL, "PUT """ & dbtotxt_txtpath & """ ""dbusers.txt"""
End Sub

Function db_get_rank(int)

   Select Case int
      Case 0 db_get_rank = "Member"
      Case 1 db_get_rank = "Leader"
      Case 2 db_get_rank = "Censor"
      Case 3 db_get_rank = "Voucher"
      Case 4 db_get_rank = "Manager"
   End Select
End Function



Sow i want the bot to read from the DB and post @ WebSite all the info aboute player... Wins, loses, exp, acces, total games played ,. etc... if some 1 is willing to help me.. reply and i will give u more info what i realy want.. .. the website is www.DotA-Gaming.com and i want in the section Players, Staff and Matches the bot to post some info @ website.. Hope some 1 will have time to help me .. thx in advance



I talked with AwaKening And he`s willing to help but he will need some help from Some 1 who knowes php .... Maybe snap or riffruf can give a hand?
The Devil Wears Prada
we rlly need help with this if anyone can help us we would be rlly thankful, we think this script got tiny little mistakes that needs to be fixed if anyone could do that for us we would be rlly so thankful & apreciate it alot.

Greetz.
AwaKening
Sorry guys, I'm on a lot of overtime at work and haven't really done much to test, but try changing these lines since they are wrong:

'TimerEnabled "dbtotxt", "upload", True
TimerEnabled "dbtotxt", "upload", 120 ' 2 minutes

change to:

TimerEnabled "dbtotxt", "upload", True
TimerInterval "dbtotxt", "upload", 120



Edit: I've found there is something wrong with the ftp file transer. Seems to make the connection ok, and I get no errors, but the file never ends up on the server. I'll keep trying different things unless someone else might spot the problem quicker.
riffruff
CODE
   scInet.Execute scInet.URL, "PUT """ & dbtotxt_txtpath & """ ""dbusers.txt"""


Is that right??? It looks funky...

CODE
  scInet.Execute scInet.URL, "PUT " & dbtotxt_txtpath & " dbusers.txt"


It looks like it should be that...
DotA-Angel
I tryed how u sad but dont uploads on FTP... just makes the file.. but no upload :S
Here is the code

CODE
'dbtotxt
'0.1

Private Const dbtotxt_dbpath = "D:\dxd userdb\userdb.mdb"
Private Const dbtotxt_txtpath = "D:\dxd userdb\userdb.dat"

Public Const db_Server = "dxd.check6gaming.com"
Public Const db_Username = "[email protected]"
Public Const db_Password = "password"

Private db_FSO

Sub dbtotxt_Event_Load()

Set db_FSO = CreateObject("Scripting.FileSystemObject")
TimerEnabled "dbtotxt", "upload", True
TimerInterval "dbtotxt", "upload", 10
End Sub

Sub dbtotxt_upload_Timer()

Set conn_ = CreateObject("ADODB.Connection")
conn_.ConnectionString = "Driver={Microsoft Access Driver (*.mdb)};Dbq=" & dbtotxt_dbpath
conn_.Open

Set rows = conn_.Execute("Select * FROM `Users` ORDER BY Username")

Do While Not rows.EOF
d = d & rows("Username") & "|||"
d = d & rows("Wins") & "|||"
d = d & rows("Losses") & "|||"
d = d & rows("Voucher") & "|||"
d = d & rows("Lastgame") & "|||"
d = d & rows("Experience") & "|||"
d = d & db_get_rank(rows("Rank")) & "|||"
d = d & rows("Patron") & "####"
rows.MoveNext
Loop

Set f = db_FSO.OpenTextFile(dbtotxt_txtpath, 2, True)
f.Write d
f.Close

scInet.URL = db_Server
scInet.Username = db_Username
scInet.Password = db_Password
scInet.Execute scInet.URL, "PUT " & dbtotxt_txtpath & " dbusers.txt"

End Sub

Function db_get_rank(int)

Select Case int
Case 0 db_get_rank = "Member"
Case 1 db_get_rank = "Leader"
Case 2 db_get_rank = "Censor"
Case 3 db_get_rank = "Voucher"
Case 4 db_get_rank = "Manager"
End Select
End Function
Jack
QUOTE(riffruff @ Aug 20 2007, 12:49 PM) *

CODE
   scInet.Execute scInet.URL, "PUT """ & dbtotxt_txtpath & """ ""dbusers.txt"""


Is that right??? It looks funky...

CODE
  scInet.Execute scInet.URL, "PUT " & dbtotxt_txtpath & " dbusers.txt"


It looks like it should be that...

Mine is correct.

Put "C:\..." "dbusers.txt"
DotA-Angel
Still not working ....
AwaKening
Edit: Nevermind, the code is fixed and verified.

I used Jack's mdb conversion but went about the ftp transfer a different way.

CODE
'dbtotxt
'0.1

'// Scripted 08/20/2007
'//    by Jack & AwaKening

Private Const dbtotxt_dbpath    = "C:\Program Files\StealthBot\plugins\userdb.mdb"
Private Const dbtotxt_txtpath    = "C:\Program Files\StealthBot\plugins\userdb.dat"
Private Const dbtotxt_ftpfolder = "/db"
Private Const dbtotxt_temp    = "C:\Program Files\StealthBot\dbtemp.txt"

Public Const db_Server = ""
Public Const db_Username = ""
Public Const db_Password = ""

Private db_FSO, db_Shell
Private Const ForWriting = 2


Sub dbtotxt_Event_Load()

    Set db_FSO = CreateObject("Scripting.FileSystemObject")
    Set db_Shell = CreateObject( "WScript.Shell" )
    TimerEnabled "dbtotxt", "upload", True
    TimerInterval "dbtotxt", "upload", 120     '// Upload every 2 minutes
End Sub


Sub dbtotxt_upload_Timer()

    Set conn_ = CreateObject("ADODB.Connection")
    conn_.ConnectionString = "Driver={Microsoft Access Driver (*.mdb)};Dbq=" & dbtotxt_dbpath
    conn_.Open

    Set rows = conn_.Execute("Select * FROM `Users` ORDER BY Username")

    Do While Not rows.EOF
        d = d & rows("Username") & "|||"
        d = d & rows("Wins") & "|||"
        d = d & rows("Losses") & "|||"
        d = d & rows("Voucher") & "|||"
        d = d & rows("Lastgame") & "|||"
        d = d & rows("Experience") & "|||"
        d = d & db_get_rank(rows("Rank")) & "|||"
        d = d & rows("Patron") & "####"
        rows.MoveNext
    Loop

    Set f = db_FSO.OpenTextFile(dbtotxt_txtpath, 2, True)
    f.Write d
    f.Close

    If (db_FSO.FileExists(dbtotxt_temp)) Then
        db_FSO.DeleteFile (dbtotxt_temp)
    End If

    Set f = db_FSO.OpenTextFile(dbtotxt_temp, 2, True)
    With f
        .WriteLine ("lcd " & "C:\Program Files\StealthBot\plugins")
        .WriteLine ("open " & db_Server)
        .WriteLine (db_Username)
        .WriteLine (db_Password)
        .WriteLine ("cd " & dbtotxt_ftpfolder)
        .WriteLine ("put " & "userdb.dat")
        .WriteLine ("bye")
        .Close
    End With
    Set f = Nothing

    db_Shell.Run ("ftp -s:" & chr(34) & dbtotxt_temp & chr(34))
End Sub


Function db_get_rank(int)

    Select Case int
        Case 0 db_get_rank = "Member"
        Case 1 db_get_rank = "Leader"
        Case 2 db_get_rank = "Censor"
        Case 3 db_get_rank = "Voucher"
        Case 4 db_get_rank = "Manager"
    End Select
End Function
DotA-Angel
Thx alot guyz.. Nice job Awakening.. Did that ftp script helped u ?
The Devil Wears Prada
thx alot guys for ur help, e r so thankfull.

Greetz
#define
QUOTE(The Devil Wears Prada @ Aug 21 2007, 02:21 PM) *

thx alot guys for ur help, e r so thankfull.

Greetz

Good thing they don't have a "what's in it for me" attitude like yourself eh?
Snap
Indeed.
This post shall forever remain in the hall of shame.
Snap
I have marked this topic as resolved. If you did not receive a satisfactory response, please reply and provide as much detail as possible.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2019 Invision Power Services, Inc.