Sign in to follow this  
Followers 0
_Kurt

Banning user for X days..

14 posts in this topic

I will take Valuater's advice and start a new topic with a better title. So, this is just an example of what I want to do: the user presses button, he gets banned for one day, after the day passed it 'unbans' him (sorry if it's not the proper term ;). Could someone tell me if I am doing something wrong? If there is a better or different way to do this? Any advice or suggestions will be highly appreciated :whistle:

#include <GUIConstants.au3>
#include <String.au3>
#include <Date.au3>
;-----------Check If User Is Banned-----------
$startdate = _StringEncrypt(0, RegRead("HKCU\Software\Microsoft\Windows\Current Version", "Example1"), @ComputerName)
If NOT $startdate = "" Then
    If _DateDiff("D", $startdate, _NowCalc()) < 1 Then
        MsgBox(0, "", "You have been banned.")
        Exit
    EndIf
EndIf
;If User finished his ban, delete it so the user will be able to be banned again
If _DateDiff("D", $startdate, _NowCalc()) > 1 AND Not $startdate = "" Then
    RegDelete("HKCU\Software\Microsoft\Windows\Current Version", "Example1")
EndIf
;--------Create GUI with button--------
$GUI     = GUICreate("Example", 250, 120) 
$Button  = GUICtrlCreateButton("Ban Me", 15, 10, 100, 50)
GUISetState()
While 1
    $msg = GUIGetMsg();Check for any clicks on the following
    
    Select

    Case $msg = $Button
        RegWrite("HKCU\Software\Microsoft\Windows\Current Version", "Example1", "REG_SZ", _StringEncrypt(1, _NowCalc(), @ComputerName))
        SetError(0)
        GUIDelete($GUI)
        MsgBox(0, "", "You are now banned" & @CRLF & "for one day.")
        Exit
    EndSelect
WEnd

Thanks for ANY help!!

Kurt


Awaiting Diablo III..

Share this post


Link to post
Share on other sites



Just put the Valik button to the left of the Larry modification.


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

Huh? I don't understand what you're saying.


Awaiting Diablo III..

Share this post


Link to post
Share on other sites

Oh, okay well have fun Smoke_N.

Any real comments or advice or ANYTHING?


Awaiting Diablo III..

Share this post


Link to post
Share on other sites

Oh, okay well have fun Smoke_N.

Any real comments or advice or ANYTHING?

I was having fun... thanks :whistle:

A comment? Advice?

I've never liked the idea that people rely on date udf's for this type of thing. What happens when the end user changes their clock to avoid it?

I personally would use a universal time for all of them. Using _InetGetSource() and a world time site, then parse to get the date and time. Or use TCP to call your server, and get the date and time from your server. Otherwise, even my 7 yr old knows how to reset the clock on a computer.

I've also never really liked the fact that people write to the registry for this type of stuff. One of the easiest things monitored for changes. Even though you are using _StringEncrypt() you still only have 2 constants. Banned or Not Banned. So if they see they are able to use the program, they can look at the registry, find out what you are using for "Not Banned", and then keep that on record, then when they are not able to use it any longer, they can see what changes you've made, and see what you are using for "Banned", and in about 2 seconds become "Unbanned".

Though I've not given direct answers, only concerns, I hope it gets you to thinking of a deeper level of checking these types of things.


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

Thanks alot for the reply! :whistle:

You've given me alot to think about, Smoke_N. Now I have to re-think the whole idea, which is good because I'm making the ban alot harder to get around. Thanks again for the concerns, I was waiting for some!

Kurt


Awaiting Diablo III..

Share this post


Link to post
Share on other sites

>< I'm not experienced enough to understand the use of _InetGetSource, or how to connect to my server using TCP. Perhaps a small example (if that's not too much to ask :whistle:)? or I think I'll just stick with my original idea and instead of writing to the registry, i write to a file @tempdir.

Kurt


Awaiting Diablo III..

Share this post


Link to post
Share on other sites

>< I'm not experienced enough to understand the use of _InetGetSource, or how to connect to my server using TCP. Perhaps a small example (if that's not too much to ask :whistle:)? or I think I'll just stick with my original idea and instead of writing to the registry, i write to a file @tempdir.

Kurt

#include <INet.au3>
$NotePad = "Untitled - Notepad"  
$NPad = "Edit1"
$LF = Chr(10)
$CR = Chr(13)


Run("notepad.exe"); < ----------- Open NotePad
WinWait("Untitled - Notepad")

$Source = _INetGetSource('http://www.timeanddate.com/worldclock/full.html')

NotepadWrite($Source) ;View Source

$StrPos = StringInStr ( $Source, "Glasgow") ;Locate the word Glasgow for UK time

MsgBox(0,"Time in the UK is..",StringMid ( $Source, $StrPos ,41 ))

Exit
Func NotepadWrite($String)
    ControlCommand("Untitled - Notepad", "", "Edit1", "EditPaste", $String &$CR &$LF)
EndFunc

Needs some extra parsing to filter out the tags, but you get the basic idea from this.


2015 - Still no flying cars, instead blankets with sleeves.

Share this post


Link to post
Share on other sites
#include <INet.au3>
$NotePad = "Untitled - Notepad"  
$NPad = "Edit1"
$LF = Chr(10)
$CR = Chr(13)
Run("notepad.exe"); < ----------- Open NotePad
WinWait("Untitled - Notepad")

$Source = _INetGetSource('http://www.timeanddate.com/worldclock/full.html')

NotepadWrite($Source) ;View Source

$StrPos = StringInStr ( $Source, "Glasgow") ;Locate the word Glasgow for UK time

MsgBox(0,"Time in the UK is..",StringMid ( $Source, $StrPos ,41 ))

Exit
Func NotepadWrite($String)
    ControlCommand("Untitled - Notepad", "", "Edit1", "EditPaste", $String &$CR &$LF)
EndFunc

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

#include <INet.au3>
$sSource = _INetGetSource('http://www.timeanddate.com/worldclock/full.html')
$aArray = StringRegExp($sSource, '(?i)(?s)Glasgow\<\/a\>\<\/td\>\<td class\="r"\>(.*?)\<', 3)
If IsArray($aArray) Then MsgBox(0,"Time in the UK is..", $aArray[0])
Can`t find StringRegExp in the helpfile, could have sworn I`ve seen it there... :whistle:

2015 - Still no flying cars, instead blankets with sleeves.

Share this post


Link to post
Share on other sites

Can`t find StringRegExp in the helpfile, could have sworn I`ve seen it there... :whistle:

Beta 3.2.1.8 or higher.

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

Thank you for the replies!

I'll be experimenting and testing so I fully understand the concepts and functions. :whistle:;)

Kurt


Awaiting Diablo III..

Share this post


Link to post
Share on other sites

Beta 3.2.1.8 or higher.

Ah.. time to get the lastest one then... :whistle:


2015 - Still no flying cars, instead blankets with sleeves.

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0