Previous Thread
Next Thread
Print Thread
Hop To
#202305 12/01/2007 9:55 PM
Joined: Feb 2007
Posts: 57
journeyman
journeyman
Joined: Feb 2007
Posts: 57
I'm trying to write ASP code to add a new user directly into the MySQL database. I have everything figured out except for two fields: the password and registration time.

Does anyone know how to generate the proper hash code for a given password? I don't know much PHP, but any help at all would be great, and might save me a few hours of mulling through the source.

Also, can anyone explain how the datecodes are stored in the database? It's probably some MySQL standard, but I usually deal with Access and SQL Server, so if anyone knows how it stores, or the proper ASP translation code, or if there's a way to put the date & time right into the SQL statement, that would be great.

Note: we're running UBB Threads v7.1...I think.

Thanks a lot!!

Shane


RnJpZW5kc2hpcCB3aXRoIHRoZSB3b3JsZCBpcyBob3N0aWxpdH
kgdG93YXJkcyBHb2QuICBKYW1lcyA0OjQ=
Shane #202306 12/01/2007 10:01 PM
Joined: Apr 2007
Posts: 3,940
Likes: 1
SD Offline
Former Developer
Former Developer
Joined: Apr 2007
Posts: 3,940
Likes: 1
md5(txtPassword) smile

SD #202307 12/01/2007 10:02 PM
Joined: Apr 2007
Posts: 3,940
Likes: 1
SD Offline
Former Developer
Former Developer
Joined: Apr 2007
Posts: 3,940
Likes: 1
and time is simply unix time smile

http://www.captain.at/review-unixtime-javascript.php

.NET example:

TimeSpan ts = (DateTime.UtcNow - new DateTime(1970,1,1,0,0,0));
double unixTime = ts.TotalSeconds;

smile

SD #202310 12/01/2007 10:28 PM
Joined: Feb 2007
Posts: 57
journeyman
journeyman
Joined: Feb 2007
Posts: 57
Thanks, that should help! **wikipedia, what's md5?** **google, some code please?**

http://en.wikipedia.org/wiki/Md5
http://rossm.net/Electronics/Computers/Software/ASP/
http://en.wikipedia.org/wiki/Unix_time

Now I have everything figured out except how to convert local time to UTC from within VBScript. I'd probably have to write a COM component to do it, but it's not that important, I guess. I'd hard-code it, but then it'd be messed up during DST. LMK if anyone has any other ideas. Thanks again!!


RnJpZW5kc2hpcCB3aXRoIHRoZSB3b3JsZCBpcyBob3N0aWxpdH
kgdG93YXJkcyBHb2QuICBKYW1lcyA0OjQ=
Shane #202311 12/01/2007 10:49 PM
Joined: Feb 2007
Posts: 57
journeyman
journeyman
Joined: Feb 2007
Posts: 57
No, I couldn't stop there. With some more help from Google, I wrote the VB6 COM component to get the current unix time:
Code
Option Explicit

Private Type FILETIME
    dwLowDateTime As Long
    dwHighDateTime As Long
End Type
Private Type SYSTEMTIME
    wYear As Integer
    wMonth As Integer
    wDayOfWeek As Integer
    wDay As Integer
    wHour As Integer
    wMinute As Integer
    wSecond As Integer
    wMilliseconds As Integer
End Type

Private Declare Function FileTimeToLocalFileTime Lib "kernel32" (lpFileTime As FILETIME, lpLocalFileTime As FILETIME) As Long
Private Declare Function LocalFileTimeToFileTime Lib "kernel32" (lpLocalFileTime As FILETIME, lpFileTime As FILETIME) As Long
Private Declare Function FileTimeToSystemTime Lib "kernel32" (lpFileTime As FILETIME, lpSystemTime As SYSTEMTIME) As Long
Private Declare Function SystemTimeToFileTime Lib "kernel32" (lpSystemTime As SYSTEMTIME, lpFileTime As FILETIME) As Long

' Convert a Date into a SYSTEMTIME.
Private Sub DateToSystemTime(ByVal the_date As Date, ByRef _
    system_time As SYSTEMTIME)
    With system_time
        .wYear = Year(the_date)
        .wMonth = Month(the_date)
        .wDay = Day(the_date)
        .wHour = Hour(the_date)
        .wMinute = Minute(the_date)
        .wSecond = Second(the_date)
    End With
End Sub

' Convert a SYSTEMTIME into a Date.
Private Sub SystemTimeToDate(system_time As SYSTEMTIME, _
    ByRef the_date As Date)
    With system_time
        the_date = DateSerial(.wYear, .wMonth, .wDay) + _
                   TimeSerial(.wHour, .wMinute, .wSecond)
    End With
End Sub

' Convert a local time to UTC.
Public Function LocalTimeToUTC(ByVal the_date As Date) As _
    Date
Dim system_time As SYSTEMTIME
Dim local_file_time As FILETIME
Dim utc_file_time As FILETIME

    ' Convert it into a SYSTEMTIME.
    DateToSystemTime the_date, system_time

    ' Convert it to a FILETIME.
    SystemTimeToFileTime system_time, local_file_time

    ' Convert it to a UTC time.
    LocalFileTimeToFileTime local_file_time, utc_file_time

    ' Convert it to a SYSTEMTIME.
    FileTimeToSystemTime utc_file_time, system_time

    ' Convert it to a Date.
    SystemTimeToDate system_time, the_date

    LocalTimeToUTC = the_date
End Function

' Convert a UTC time into local time.
Public Function UTCToLocalTime(ByVal the_date As Date) As _
    Date
Dim system_time As SYSTEMTIME
Dim local_file_time As FILETIME
Dim utc_file_time As FILETIME

    ' Convert it into a SYSTEMTIME.
    DateToSystemTime the_date, system_time

    ' Convert it to a UTC time.
    SystemTimeToFileTime system_time, utc_file_time

    ' Convert it to a FILETIME.
    FileTimeToLocalFileTime utc_file_time, local_file_time

    ' Convert it to a SYSTEMTIME.
    FileTimeToSystemTime local_file_time, system_time

    ' Convert it to a Date.
    SystemTimeToDate system_time, the_date

    UTCToLocalTime = the_date
End Function

Public Function UTCToUnixTime(the_date As Date) As Long
  UTCToUnixTime = CLng(DateDiff("s", #1/1/1970#, the_date))
End Function

Public Function UnixNow() As Long
  UnixNow = UTCToUnixTime(LocalTimeToUTC(Now()))
End Function

Public Function LocalTimeToUnixTime(the_date As Date) As Long
  LocalTimeToUnixTime = UTCToUnixTime(LocalTimeToUTC(the_date))
End Function


RnJpZW5kc2hpcCB3aXRoIHRoZSB3b3JsZCBpcyBob3N0aWxpdH
kgdG93YXJkcyBHb2QuICBKYW1lcyA0OjQ=
Shane #202316 12/02/2007 12:45 AM
Joined: Nov 2006
Posts: 3,095
Likes: 1
Carpal Tunnel
Carpal Tunnel
Joined: Nov 2006
Posts: 3,095
Likes: 1
We use scripts on KiXtart.org to slice and dice date and time to and from many formats.

All self contained scripts that just need to be called with the parameters of what you're looking for.


Link Copied to Clipboard
ShoutChat
Comment Guidelines: Do post respectful and insightful comments. Don't flame, hate, spam.
Recent Topics
spam issues
by ECNet - 03/19/2024 11:45 PM
Looking for a forum
by azr - 03/15/2024 11:26 PM
Editing Links in Post
by Outdoorking - 03/15/2024 9:31 AM
Question on barkrowler and the like
by Mors - 02/29/2024 6:51 PM
Member Permissions Help
by domspeak - 02/27/2024 6:31 PM
Who's Online Now
3 members (rootman, Gizmo, Nightcrawler), 562 guests, and 186 robots.
Key: Admin, Global Mod, Mod
Random Gallery Image
Latest Gallery Images
Los Angeles
Los Angeles
by isaac, August 6
3D Creations
3D Creations
by JAISP, December 30
Artistic structures
Artistic structures
by isaac, August 29
Stones
Stones
by isaac, August 19
Powered by UBB.threads™ PHP Forum Software 8.0.0
(Preview build 20230217)