Hello Guys / Girls,
I currently have a script which can be used to upload files to an FTP server.
What I am wanting to do is limit how many times it can be used to upload a file, this is to prevent flooding.
I am thinking of the Read/Write Line Command to create a file say in the users system directory or something similar.
Does anyone have a suggestion as to how this could be done, I want to limit them 3 uploads a day.
Any help with this would be great.
Daily Script Limit
Moderators: JRL, Dorian (MJT support)
- CyberCitizen
- Automation Wizard
- Posts: 724
- Joined: Sun Jun 20, 2004 7:06 am
- Location: Adelaide, South Australia
Daily Script Limit
FIREFIGHTER
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Use a registry value or ini file.
//get upload count
RegistryReadKey>HKEY_CURRENT_USER,Software\MyMacro,Uploads,count
//if not already set, set to zero
If>count=
Let>count=0
Endif
If>countcount=count+1
RegistryWriteKey>HKEY_CURRENT_USER,Software\MyMacro,Uploads,count
..
.. rest of script here ....
..
Else
MessageModal>Upload limit reached ...
Endif
//get upload count
RegistryReadKey>HKEY_CURRENT_USER,Software\MyMacro,Uploads,count
//if not already set, set to zero
If>count=
Let>count=0
Endif
If>countcount=count+1
RegistryWriteKey>HKEY_CURRENT_USER,Software\MyMacro,Uploads,count
..
.. rest of script here ....
..
Else
MessageModal>Upload limit reached ...
Endif
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
- CyberCitizen
- Automation Wizard
- Posts: 724
- Joined: Sun Jun 20, 2004 7:06 am
- Location: Adelaide, South Australia
Thank You For Your Help, I Don't Want To Use An Ini File As I Want To Keep It As One Exe, However I Could Always Have The Script Compile The Ini File.
The Script You Supplied Was Pretty Much What I Was Thinking, However Then How Would I Limit It For Only That Day, That Script Is Just Going To Continue To Check & The Count Is Only Going To Get Bigger.
Would It Be Something Like Create A Date Reg Key And Put In A Read Reg Key, Like If Date=Today Continue Else Let Date = blank.
I Know Its Not Code Above, Its More Of An Example, If You Think That Would Work, I Will Code It & Test It.
The Script You Supplied Was Pretty Much What I Was Thinking, However Then How Would I Limit It For Only That Day, That Script Is Just Going To Continue To Check & The Count Is Only Going To Get Bigger.
Would It Be Something Like Create A Date Reg Key And Put In A Read Reg Key, Like If Date=Today Continue Else Let Date = blank.
I Know Its Not Code Above, Its More Of An Example, If You Think That Would Work, I Will Code It & Test It.
FIREFIGHTER
Had a little spare time this evening so I took the liberty of modifying Marcus' code and added a date. I have the same with an ini file if you change your mind I could post it. The ini method is a little simpler for the date since you can use the ini file date as the last upload date.
Also, if you dare to do it and if your computers are on the same domain. You might consider setting the users computer date to the ftp server date. Otherwise, all a user would need to do to defeat your count is change the date on their computer. Maybe not worth the risk but the basics are remarked at the top of the script.
///set computer time to server time
///this can take a few moments
//Let>RP_WAIT=1
//Let>RP_WINDOWMODE=2
//Run>cmd /c net time \\[servername] /set /yes
//get upload count
RegistryReadKey>HKEY_CURRENT_USER,Software\MyMacro,Uploads,count
RegistryReadKey>HKEY_CURRENT_USER,Software\MyMacro,Date,today
//if not already set, set date
If>today=
Day>dd
Month>today
Year>yy
Concat>today,%dd%%yy%
RegistryWriteKey>HKEY_CURRENT_USER,Software\MyMacro,Date,today
Else
///Set today
Day>dd
Month>date_today
Year>yy
Concat>date_today,%dd%%yy%
If>date_todaytoday
Let>count=0
RegistryWriteKey>HKEY_CURRENT_USER,Software\MyMacro,Date,date_today
EndIf
EndIf
//if not already set, set count
If>count=
Let>count=0
Endif
If>countcount=count+1
RegistryWriteKey>HKEY_CURRENT_USER,Software\MyMacro,Uploads,count
..
.. rest of script here ....
..
Else
MessageModal>Upload limit reached ...
Endif
Later,
Dick
Also, if you dare to do it and if your computers are on the same domain. You might consider setting the users computer date to the ftp server date. Otherwise, all a user would need to do to defeat your count is change the date on their computer. Maybe not worth the risk but the basics are remarked at the top of the script.
///set computer time to server time
///this can take a few moments
//Let>RP_WAIT=1
//Let>RP_WINDOWMODE=2
//Run>cmd /c net time \\[servername] /set /yes
//get upload count
RegistryReadKey>HKEY_CURRENT_USER,Software\MyMacro,Uploads,count
RegistryReadKey>HKEY_CURRENT_USER,Software\MyMacro,Date,today
//if not already set, set date
If>today=
Day>dd
Month>today
Year>yy
Concat>today,%dd%%yy%
RegistryWriteKey>HKEY_CURRENT_USER,Software\MyMacro,Date,today
Else
///Set today
Day>dd
Month>date_today
Year>yy
Concat>date_today,%dd%%yy%
If>date_todaytoday
Let>count=0
RegistryWriteKey>HKEY_CURRENT_USER,Software\MyMacro,Date,date_today
EndIf
EndIf
//if not already set, set count
If>count=
Let>count=0
Endif
If>countcount=count+1
RegistryWriteKey>HKEY_CURRENT_USER,Software\MyMacro,Uploads,count
..
.. rest of script here ....
..
Else
MessageModal>Upload limit reached ...
Endif
Later,
Dick
- CyberCitizen
- Automation Wizard
- Posts: 724
- Joined: Sun Jun 20, 2004 7:06 am
- Location: Adelaide, South Australia
Thank You For Your Help, Both Dick & Marcus.
I Have Got The Program/Script Working Exactly How I Want.
You Can View The Program Here: CyberCitizen's Demo Upload Tool
I Have Got The Program/Script Working Exactly How I Want.
You Can View The Program Here: CyberCitizen's Demo Upload Tool
FIREFIGHTER