Jump to content

Recommended Posts

Posted

Hay ther i try to get the current date from the internet for a login system.

for now im using @mon @year ... to get current date but you could easily crack this system.

it would be nice if i could get the current date from a website or something to avoid this problem

if anyone has an idee pls tell me

gretz usbstick

sry for my bad english

Posted

This is very old, but the only example script I could find on the forum that gets time from internet. >Link

Snips & Scripts

  Reveal hidden contents

My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Posted (edited)
  On 3/31/2015 at 5:41 PM, Darknightx37 said:

hm thx for the fast reply but there is no URL or things like that to get the current time from the internet

or did i missed that part ?

its by IP adresses

Dim $ser[5]=["64.125.78.85","128.138.140.44","132.163.4.102","132.163.4.101","129.6.15.29"]

I know already you'll hit some errors because of version updates to AutoIt, but if you need some help figuring it out let us know. 

:)

EDIT: Melba23's suggestion is very good, will give you a chance to maybe work with IE functionality. ;)

Edited by MikahS

Snips & Scripts

  Reveal hidden contents

My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

  • Moderators
Posted

Darknightx37,

Scraping this site ought to be good enough for your needs. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

  Reveal hidden contents

 

Posted

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted

I need to keep your signature on standby guinness. :D

Snips & Scripts

  Reveal hidden contents

My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Posted
  On 3/31/2015 at 5:58 PM, MikahS said:

I need to keep your signature on standby guinness. :D

Haha, yes you do!

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted (edited)

and NTP

#include <Date.au3>

 msgbox(0, '' , _TimeFromNTP("pool.ntp.org"))

Func _TimeFromNTP($sNTPServer)
    Local $sData = ""
    TCPStartup()
    If TCPNameToIP($sNTPServer) = "" Then Return SetError(1)
    UDPStartup()
    $aSocket = UDPOpen(TCPNameToIP($sNTPServer), 123)
    $sStatus = UDPSend($aSocket, _MakePacket())
    While $sData = ""
        $sData = UDPRecv($aSocket, 100)
        Sleep(250)
    WEnd
    UDPCloseSocket($aSocket)
    TCPShutdown()


    $sValue = _UnsignedHexToDecimal(StringMid($sData, 83, 8))
    $aTimeZone = _Date_Time_GetTimeZoneInformation()

      If $aTimeZone[0] <> 2 Then
        $iTimeZoneOffset = ($aTimeZone[1]) * -1
    Else
        $iTimeZoneOffset = ($aTimeZone[1] + $aTimeZone[7]) * -1
    EndIf

    $sUTC = _DateAdd("s", $sValue, "1900/01/01 00:00:00")

    $sUTC = _DateAdd("n", $iTimeZoneOffset, $sUTC)

    Local $iMonth = StringMid($sUTC, 6, 2), $iDay = StringMid($sUTC, 9, 2), $iYear = StringMid($sUTC, 1, 4), _
    $iHour = StringMid($sUTC, 12, 2), $iMinute = StringMid($sUTC, 15, 2), $iSecond = StringMid($sUTC, 18, 2)

    $sOut = $iMonth & "/" & $iDay & "/" & $iYear & " " & $iHour & ":" & $iMinute & ":" & $iSecond

    return $sOut

EndFunc

Func _MakePacket()
    Local $x, $sPacket = "1b0e01000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
    While $sPacket
        $x &= Chr(Dec(StringLeft($sPacket, 2)))
        $sPacket = StringTrimLeft($sPacket, 2)
    WEnd
    Return $x
EndFunc

Func _UnsignedHexToDecimal($sInput)
    $x = StringRight($sInput, 1)
    $sInput = StringTrimRight($sInput, 1)
    Return Dec($sInput) * 16 + Dec($x)
EndFunc

*think i just changed formatting between mine and the original.

Edited by boththose

  Reveal hidden contents

Posted (edited)

boththose,

Is the code you posted different to the one you linked to? As it's common practice if no changes have been made to just post a link to the working code, thus there is a reduction in duplicate code.

Edited by guinness

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted (edited)

i did change stuff, cant remember all i changed, and a tad busy so i used the also common practice of posting what i know works and linking to where i got it from.

*looks like i must have had an issue with timezone and not liked the output, nor did i need the ability to actually set the time....maybe something else but i think its just moved around rather than changed.

Edited by boththose

  Reveal hidden contents

Posted

NTP servers are pretty stable and reliable, just because it's their only purpose to be a primary or secondary time server for Internet own time reference.

  Reveal hidden contents

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Posted
  On 3/31/2015 at 7:31 PM, Darknightx37 said:

this is pritty instable cause the server is often not avalebil can you maybe give me an example foranother website like this where i can get the time from a url?

What jchd said. Though I have found the site to be stable for me.

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted

#Include <StructureConstants.au3>
#Include <Date.au3>

Func _NTP_FT($sServer, $fLocal = True)

;~  http://book.itep.ru/4/44/sntp4416.htm

    Local $tNTP = DllStructCreate('byte Header[4];byte RootDelay[4];byte RootDispersion[4];byte ReferenceIdentifier[4];byte ReferenceTimestamp[8];byte OriginateTimestamp[8];byte ReceiveTimestamp[8];byte TransmitTimestamp[8];byte KeyIdentifier[4];byte MessageDigest[16]')
    Local $tPacket = DllStructCreate('byte Packet[68]', DllStructGetPtr($tNTP))
    Local $bPacket = 0, $tFT, $tQW, $aSocket, $aResult

;~  0x1B000000 = 00011011 00000000 00000000 00000000b (LI = 00b VN = 011b Mode = 011b Stratum = 00000000b Poll = 00000000b Precision = 00000000b)
    $tNTP.Header = Binary('0x1B000000')
    UDPStartup()
    If @Error Then
        Return SetError(1, 0, 0)
    EndIf
    $aSocket = UDPOpen(TCPNameToIP($sServer), 123)
    If @Error Then
        ; Nothing
    Else
        UDPSend($aSocket, $tPacket.Packet)
        If @Error Then
            ; Nothing
        Else
            While 1
                $bPacket = UDPRecv($aSocket, 68, 1)
                If (@Error) Or ($bPacket) Then
                    ExitLoop
                EndIf
                Sleep(100)
            WEnd
        EndIf
    EndIf
    UDPCloseSocket($aSocket)
    UDPShutdown()
    If Not $bPacket Then
        Return SetError(2, 0, 0)
    EndIf
    $tFT = DllStructCreate($tagFILETIME)
    If $fLocal Then
        $tQW = DllStructCreate('uint64 Timestamp')
    Else
        $tQW = DllStructCreate('uint64 Timestamp', DllStructGetPtr($tFT))
    EndIf
    $tPacket.Packet = $bPacket
    $tQW.Timestamp = Dec(StringMid(DllStructGetData($tNTP, 'TransmitTimestamp'), 3, 8), 2) * 10000000 + 94354848000000000
    If $fLocal Then
        $aResult = DllCall('kernel32.dll', 'bool', 'FileTimeToLocalFileTime', 'struct*', $tQW, "struct*", $tFT)
        If (@Error) Or (Not $aResult[0]) Then
            Return SetError(3, 0, 0)
        EndIf
    EndIf
    Return $tFT
EndFunc   ;==>_NTP_FT

$tFT = _NTP_FT('pool.ntp.org')

ConsoleWrite(_Date_Time_FileTimeToStr($tFT) & @CRLF)

Posted (edited)

@Yashied
why its return:

  Quote

01/01/1900 02:00:01

Edited by mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

Au3.3.10.2 return 1

Au3.3.13.20 return 0

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

  On 4/1/2015 at 8:59 AM, mLipok said:

@Yashied

why its return:

01/01/1900 02:00:01

on

Au3.3.13.20 this rerturn empty string.

but then I try again with Au3.3.10.2 and again empty string.

It is strange behavior.

 

  On 4/1/2015 at 9:23 AM, Yashied said:

What AutoIt version? Please check the following:

 

Dec(StringMid(DllStructGetData($tNTP, 'TransmitTimestamp'), 3, 8), 2)

 

  On 4/1/2015 at 9:36 AM, Yashied said:

I'm using 3.3.12.0

and what result you have ?

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...