Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- '// Leecher app is an automatic way to stop the seeding in BitTorrent/uTorrent client.
- '// This app works on all Win32 (MS Windows).
- '//
- '// Leecher
- '// (C) Rui Branco - rmrbranco@gmail.com
- '// Project home https://googledrive.com/host/0B5MAgOEuMAVadE1oZnJxUzVrTDA/
- '//
- '// Resources
- '// The language and compiler http://www.libertybasic.com/
- '// The compiler to make single exe and console app http://www.lbbooster.com/
- '// uTorrent software http://www.utorrent.com or BitTorrent software http://www.bittorrent.com
- '// The Webui http://www.utorrent.com/intl/en/help/guides/webui and Webui API http://forum.utorrent.com/viewtopic.php?pid=318056#p318056
- '// Support token authentication http://forum.utorrent.com/viewtopic.php?id=58111 or https://github.com/bittorrent/webui/wiki/TokenSystem
- '// Sendmail http://www.glob.com.au/sendmail/
- '// MS-DOS cmd.exe http://www.microsoft.com/resources/
- '// Changelog:
- '// 25-01-2014 - Info, the app works great and put everything need to work. I will adapt the code again when in resources exists changes
- '// 25-01-2014 - Added, token authentication
- '// 25-01-2014 - Added, a better way to rename files and folders
- '// 19-01-2014 - Added, improvements, adjustments and comments
- '// 19-01-2014 - Added, function to check if Internet connection and webui is avaiable
- '// 18-01-2014 - Fix, bugfix
- '// 17-01-2014 - Added, adapted code to new features
- '// 17-01-2014 - Added, functions to protect data in config.conf in your machine(encryption passswords only)
- '// 15-01-2014 - Info, I and my account was banned from utorrent.com and bittorrent.com forums
- '// 15-01-2014 - Fix, adapting the code to BitTorrent client
- '// 15-01-2014 - Added, support to email notifications
- '// 12-01-2014 - Added, option in config to choose stop start pause remove... actions for webui
- '// 11-01-2014 - Added, webui support.
- '// 07-01-2014 - Added, anti collision names of files and folders.
- '// 07-01-2014 - Added, several checks existence of content.
- '// 07-01-2014 - Added, retry sending wm_close command in the case of the window not closing.
- '// 06-01-2014 - Added, function to save the steps in output.log.
- '// Nomainwin somewhere in the program source code prevents the window from opening.
- '// You can uncomment if you want silent mode
- 'NOMAINWIN
- '// Put the arguments sent by BitTorrent/uTorrent in lowercase and send for strings
- argut$ = lower$(CommandLine$)
- dir$ = lower$(CommandLine$)
- title$ = lower$(CommandLine$)
- hash$ = lower$(CommandLine$)
- '// Use and get dir from appdata variable
- utdir$ = Environ$("APPDATA")
- '// Set 0 if is a first time to run app
- firsttime = 0
- '// Load config
- gosub [loadconfig]
- '// If first time to run app then create config
- if firsttime = 1 then
- gosub [createconfig]
- 'Relaod config
- gosub [loadconfig]
- end if
- '// If you change password to new password the code will encrypt the same
- if encrypta = 1 or encryptb = 1 then
- gosub [createconfig]
- 'At the end encryption passwords, go to load settings and put in strings
- gosub [loadconfig]
- end if
- '// If argument is nothing will call the sub info
- if not(argut$ <> "") then
- gosub [info]
- '// Wait the user to close the window
- wait
- '// Exit app
- end
- else
- '// If in argument exists bittorrent/utorrent word, the title will fitrate and put in strings
- if instr(argut$, "utorrent") or instr(argut$, "�torrent") or instr(argut$, "bittorrent") then
- if instr(argut$, "�torrent") or instr(argut$, "utorrent") then
- arg$ = mid$(argut$, 10, 6)
- resulta$ = "�Torrent";arg$ : defdir$ = "uTorrent"
- end if
- if instr(argut$, "bittorrent") then
- arg$ = mid$(argut$, 12, 6)
- resulta$ = "bittorrent";arg$ : defdir$ = word$(resulta$,1)
- end if
- '// Fitrate dir, title and hash and put in strings
- dir$ = word$(dir$, 4, chr$(34))
- title$ = word$(title$, 6, chr$(34))
- hash$ = word$(hash$, 8, chr$(34))
- '// Call cmd command line put the title and send info to the console window
- Run "cmd.exe /C title Leecher"
- print "Leecher - automatic way to stop the seeding in BitTorrent/uTorrent"
- print ""
- print ""
- print "Output:"
- '// Create log with sub output
- output$ = " " : gosub [output]
- output$ = "- Start ";date$();" - ";time$() : gosub [output]
- output$ = "Arg. ";argut$ : gosub [output]
- if yesno$ = "no" then output$ = "Version ";arg$ : gosub [output]
- if yesno$ = "no" then output$ = "Real Window name ";resulta$ : gosub [output]
- if yesno$ = "no" then output$ = "Dir ";dir$ : gosub [output]
- if yesno$ = "no" then output$ = "Title ";title$ : gosub [output]
- if yesno$ = "yes" then output$ = "Hash ";hash$ : gosub [output]
- '// If you config to use webui will go to webui
- if yesno$ = "yes" then
- if tokenyesno$ = "no" then
- '// The address with the data available in conf to make the request. The request is make without token auth
- address$ = "http://";login$;":";password$;"@";ip$;"/gui/?action=";action$;"&hash=";hash$
- gosub [webui]
- if instr(Buffer$, "build") then
- '// Create output
- output$ = "Action " ; action$ ; " " ; title$ : gosub [output]
- output$ = "Webui output is ok " ; Buffer$ : gosub [output]
- else
- if instr(Buffer$, "invalid request") or instr(Buffer$, "") = 0 and resulticc = 0 then
- output$ = "Webui output is not ok. You have internet connection but... login/password problem? or port problem? " ; Buffer$ : gosub [output]
- notifyemail$ = "no"
- end if
- end if
- '// Send email
- if notifyemail$ = "yes" then gosub [send.email]
- else
- '// The address with the data available in conf to make the request. The request is make with token auth
- address$ = "http://";login$;":";password$;"@";ip$;"/gui/token.html"
- gosub [webui]
- if instr(Buffer$, "token") then
- '// Create output
- output$ = "Action " ; action$ ; " " ; title$ : gosub [output]
- output$ = "Webui output is ok " ; Buffer$ : gosub [output]
- '// Get token value and make the request
- tokena$ = word$(Buffer$, 2, ";'>") : tokenresult$ = word$(tokena$, 1, "</")
- address$ = "http://";ip$;"/gui/?token=";tokenresult$;"&action=";action$;"&hash=";hash$
- gosub [webui]
- else
- if resulticc = 0 then
- output$ = "Webui output is not ok. You have internet connection but... login/password problem? or port problem? " ; Buffer$ : gosub [output]
- notifyemail$ = "no"
- end if
- end if
- '// Send email
- if notifyemail$ = "yes" then gosub [send.email]
- end if
- '// Exit app
- gosub [end]
- end if
- else
- '// If argument is nothing will call the sub info
- gosub [info]
- '// Wait the user to close the window
- wait
- '// Exit app
- end
- end if
- end if
- '// Send close command to BitTorrent/uTorrent
- gosub [sendclose]
- '// The Loop is for the case of the window have not closed
- [loop]
- '// Start perform action in torrent client
- '// -when window close rename the folder name or file name and kill the torrent file
- if ut = 0 then
- dim info$(10, 10)
- if fileExists(dir$, title$) then
- '// Get file extension
- gosub [extension]
- '// Create output. The time$() is a simple way to prevent collision of names
- output$ = "Rename file " ; dir$ ; title$ ; " as " ; dir$ ; title$ ; " - " ; time$("milliseconds") ; "." ; extension$ : gosub [output]
- '// Rename file
- name dir$ ; title$ as dir$ ; title$ ; " - " ; time$("milliseconds") ; "." ; extension$
- else
- dim info$(10,10 )
- if folderExists(dir$) then
- '// Create output. The time$() is a simple way to prevent collision of names
- output$ = "Rename folder ";dir$; " - " ; time$("milliseconds") : gosub [output]
- '// Rename folder
- name dir$ as dir$;" - " ; time$("milliseconds")
- else
- '// Create output
- output$ = "The folder or file does not exist at this location ";dir$ : gosub [output]
- end if
- end if
- dim info$(10, 10)
- if fileExists(utdir$;"\";defdir$;"\", title$;".torrent") then
- '// Create output
- output$ = "Kill torrent file ";utdir$;"\";defdir$;"\";title$;".torrent" : gosub [output]
- '// Kill .torrent file
- kill utdir$;"\";defdir$;"\";title$;".torrent"
- else
- '// Create output
- output$ = "The file .torrent does not exist at this location ";utdir$;"\";defdir$;"\";title$;".torrent" : gosub [output]
- end if
- else
- '// Retry sending close command
- gosub [sendclose]
- '// Returned from the sub, now recheck BitTorrent/uTorrent is already closed
- goto [loop]
- end if
- '// Check if client BitTorrent/uTorrent.exe exists
- dim info$(10, 10)
- if fileExists(utdir$;"\";defdir$;"\", defdir$;".exe") then
- '// Create output
- output$ = "Start ";defdir$;" ";utdir$;"\";defdir$;"\";defdir$;".exe" : gosub [output]
- '// Finally run BitTorrent/utorrent and show minimized
- run utdir$;"\";defdir$;"\";defdir$;".exe", SHOWMINIMIZED
- '// Send email
- if notifyemail$ = "yes" then gosub [send.email]
- else
- '// Create output
- output$ = "The file ";defdir$;".exe does not exist at this location ";utdir$;"\";defdir$;"\";defdir$;".exe" : gosub [output]
- end if
- '// Exit app
- gosub [end]
- '// End perform action in torrent client
- '// Location of Subs and Functions
- [end]
- '// Create output and exit app
- output$ = "- End ";date$();" - ";time$() : gosub [output]
- End
- [info]
- '// Show info
- '// Call cmd command line put the title and send info to the console window
- Run "cmd.exe /C title Leecher"
- print "-Help, using Leecher in BitTorrent/uTorrent(desktop):"
- print " "
- print "You need the exactly title of the BitTorrent/uTorrent window and parameters."
- print ""
- print "(1) In BitTorrent/uTorrent go to,"
- print " Options/preferences/UI Settings."
- print " Remove value true in (Close button closes uT to tray)"
- print ""
- print "(2) Options/preferences/UI Settings."
- print " Remove value true in (Show confirmation dialog on exit)"
- print ""
- print "(3) Options/preferences/UI Settings."
- print " Remove value true in (Confirm exit if critical seeder)"
- print ""
- print "(4) Options/preferences/Advanced/Run Program."
- print " In box (...when a torrent finishes) put app this way"
- print " "+ chr$(34) +"C:\..\.\Leecher.exe" + chr$(34) + " " + chr$(34) + "uTorrent 3.3.2" + chr$(34) + " " + chr$(34) + "%D" + chr$(34) + " " + chr$(34) + "%N" + chr$(34)
- print ""
- print ""
- print "-Help, using Leecher in BitTorrent/uTorrent with Webui(Web)"
- print ""
- print "(1) If you want to perform these actions via webui only. "
- print " go to Options/preferences/Advanced/Run Program. In box"
- print " (...when a torrent finishes) put app this way"
- print " "+ chr$(34) +"C:\..\.\Leecher.exe" + chr$(34) + " " + chr$(34) + "uTorrent 3.3.2" + chr$(34) + " " + chr$(34) + "%D" + chr$(34) + " " + chr$(34) + "%N" + chr$(34) + " " + chr$(34) + "%I" + chr$(34)
- print ""
- print "(2) Go to Options/preferences/Advanced/"
- print " search for webui.token_auth and change the value to true."
- print ""
- print "(3) Finally, open config.conf and enter the required data"
- print ""
- print ""
- print ""
- print "Leecher - an automatic way to stop the seeding in BitTorrent/uTorrent client"
- print "by Rui Branco - rmrbranco@gmail.com"
- print "Project home https://googledrive.com/host/0B5MAgOEuMAVadE1oZnJxUzVrTDA/"
- print ""
- print ""
- print "Press CTRL+C to close window"
- RETURN
- [extension]
- '// Get file extension
- extension$ = title$
- bsPos = len(title$)
- while mid$(title$, bsPos, 1) <> "." and bsPos > 0
- bsPos = bsPos - 1
- wend
- if bsPos <> 0 then extension$ = right$(title$,len(title$) - bsPos)
- RETURN
- [webui]
- '// Perform action in Webui
- '// By Brent D. Thorn, 9/2005 and modified for the purpose by Rui Branco - rmrbranco@gmail.com
- '// Verify if BitTorrent/uTorrent have webui avaiable
- ip$ = ip$ : gosub [ping]
- if resulticc = 0 then output$ = "The webui server on " ; resulta$ ; " is avaiable?" : gosub [output]
- '// Enough bytes to hold a single line of HTML
- CHUNK.SIZE = 512
- Open "wininet" For DLL As #inet
- '// Register a new user agent. Use proxy settings
- '// set up in Internet Options Control Panel.
- CallDLL #inet, "InternetOpenA", _
- "My User Agent" As Ptr, _
- 0 As Long, _ 'INTERNET_OPEN_TYPE_PRECONFIG
- _NULL As Long, _
- _NULL As Long, _
- 0 As ULong, _
- hInet As ULong
- If hInet = 0 Then [ErrExit]
- '// Open a request to a remote file
- CallDLL #inet, "InternetOpenUrlA", _
- hInet As ULong, _
- address$ As Ptr, _
- _NULL As Long, _
- 0 As Long, _
- 2147483648 As ULong, _ 'INTERNET_FLAG_RELOAD
- _NULL As Long, _
- hFile As ULong
- If hFile = 0 Then [ErrExit]
- '// Start reading in the file by chunks.
- Buffer$ = ""
- chunk$ = Space$(CHUNK.SIZE)+Chr$(0)
- Struct pdw, NumberOfBytesRead As ULong
- Do
- CallDLL #inet, "InternetReadFile", _
- hFile As ULong, _
- chunk$ As Ptr, _
- CHUNK.SIZE As ULong, _
- pdw As Struct, _
- ret As Long
- If pdw.NumberOfBytesRead.struct = 0 Then Exit Do
- Buffer$ = Buffer$ + Left$(chunk$, pdw.NumberOfBytesRead.struct)
- Loop Until 0
- [ErrExit]
- '// If you get an error, find GetLastError on MSDN. There you will find a link to a list of error codes.
- CallDLL #kernel32, "GetLastError", ret As ULong
- If ret Then output$ = "Error InternetReadFile ";ret : gosub [output]
- '// Free the handles we created and exit.
- If hFile Then _
- CallDLL #inet, "InternetCloseHandle", _
- hFile As ULong, ret As Long
- If hInet Then _
- CallDLL #inet, "InternetCloseHandle", _
- hInet As ULong, ret As Long
- '// Strangely, the next line causes LB to hang for around 45 seconds on my computer, a 2.2 GHz running XP on dial-up.
- Close #inet
- RETURN
- [output]
- '// Create and show output info
- open "output.log" for append as #log
- print #log, output$
- close #log
- print output$
- RETURN
- [sendclose]
- '// Find BitTorrent/utorrent window
- CallDLL #user32, "FindWindowA",_
- _NULL as ulong,_
- resulta$ as ptr,_
- ut as ulong
- '// Create output
- if ut = 0 then
- output$ = "Window " ; resulta$ ; " looks closed " ; ut : gosub [output]
- else
- output$ = "Get Window " ; resulta$ ; " " ; ut : gosub [output]
- end if
- '// Send Close command to BitTorrent/utorrent
- Calldll #user32, "SendMessageA", _
- ut as ulong, _
- _WM_CLOSE as long, _
- result as long
- '// Create output
- if ut = 0 then
- output$ = "Window " ; resulta$ ; " is closed ";ut : gosub [output]
- else
- output$ = "Send close to Window " ; resulta$ ; " "; ut : gosub [output]
- end if
- RETURN
- [send.email]
- '// Create sendmail.ini
- '// To send email you must have an Internet connection, will check this
- ip$ = "www.google.com:80" : gosub [ping]
- if resulticc = 0 then output$ = "You dont have internet connection!" : gosub [output]
- '// Check if sendmail exists
- dim info$(10, 10)
- if fileExists(DefaultDir$, "sendmail.exe") = 0 then
- output$ = "Email not send, sendmail.exe not exists!" : gosub [output]
- RETURN
- end if
- '// Create sendmail.ini
- open "sendmail.ini" for output as #sini
- print #sini, "[sendmail]"
- print #sini, "smtp_server=";smtpserver$
- print #sini, "smtp_port=";smtport$
- print #sini, "smtp_ssl=";smtpssl$
- print #sini, ";default_domain=";defaultdomain$
- print #sini, "error_logfile=";errorlogfile
- print #sini, ";debug_logfile=";debuglogfile$
- print #sini, "auth_username=";authusername$
- print #sini, "auth_password=";authpassword$
- print #sini, "pop3_server=";pop3server$
- print #sini, "pop3_username=";pop3username$
- print #sini, "pop3_password=";pop3password$
- print #sini, "force_sender=";forcesender$
- print #sini, "force_recipient=";forcerecipient$
- print #sini, "hostname=";hostname$
- close #sini
- '// Create a temporary file, temp.mail
- open "temp.mail" for output as #tempm
- print #tempm, "From: ";authusername$
- print #tempm, "To: ";to$
- print #tempm, "Subject: ";"Leecher: " ; title$
- print #tempm, "Content-Type: text/html"
- print #tempm, "<p>Dear " ; to$ ; ",</p>"
- print #tempm, "<p>" ; body$ ; title$ ; "</p>"
- print #tempm, "<p> </p>"
- print #tempm, "<p> </p>"
- print #tempm, "<p> </p>"
- print #tempm, "<p>-</p>"
- print #tempm, "<p>Leecher - an automatic way to stop the seeding in BitTorrent/uTorrent client.</p>Leecher project https://googledrive.com/host/0B5MAgOEuMAVadE1oZnJxUzVrTDA/"
- close #tempm
- '// Sends the email and checks the process
- SEEMASKNOCLOSEPROCESS = 64 '0x40
- Struct s, cbSize as ulong, fMask as ulong, hwnd as ulong,_
- lpVerb$ as ptr, lpFile$ as ptr, lpParameters$ as ptr ,_
- lpDirectory$ as ptr, nShow as long, hInstApp as ulong,_
- lpIDList as long, lpClass as long, hkeyClass as ulong,_
- dwHotKey as ulong, hIcon as ulong, hProcess as ulong
- s.cbSize.struct=len(s.struct)
- s.fMask.struct=SEEMASKNOCLOSEPROCESS
- s.hwnd.struct=0
- s.lpVerb$.struct="open"
- s.lpFile$.struct="cmd.exe"
- s.lpParameters$.struct="/c sendmail.exe -t < temp.mail"
- s.lpDirectory$.struct=DefaultDir$
- s.nShow.struct=_SW_HIDE
- calldll #shell32 , "ShellExecuteExA",s as struct,r as long
- if r<>0 then
- hProcess=s.hProcess.struct
- else
- output$ = "Email notification not sent, run sendmail.exe problem. Please see the logs" : gosub [output]
- RETURN
- end if
- waitResult=-1
- while waitResult<>0
- calldll #kernel32, "WaitForSingleObject",_
- hProcess as long,0 as long,_
- waitResult as long
- wend
- dim info$(10, 10)
- if fileExists(DefaultDir$, "crash.txt") = 1 or fileExists(DefaultDir$, "0") = 1 then
- output$ = "Email notification not send, Login/password problem... Please see the logs" : gosub [output]
- else
- output$ = "Email notification sent " : gosub [output]
- '// Kill old data or data created by sending error email
- if fileExists(DefaultDir$, "temp.mail") then kill "temp.mail"
- if fileExists(DefaultDir$, "sendmail.ini") then kill "sendmail.ini"
- if fileExists(DefaultDir$, "0") then kill "0"
- if fileExists(DefaultDir$, "crash.txt") then kill "crash.txt"
- if fileExists(DefaultDir$, "crash-1.txt") then kill "crash-1.txt"
- if fileExists(DefaultDir$, "crash-2.txt") then kill "crash-2.txt"
- if fileExists(DefaultDir$, "crash-3.txt") then kill "crash-3.txt"
- end if
- RETURN
- [loadconfig]
- '// Check if config exists
- dim info$(10, 10)
- if fileExists(DefaultDir$, "config.conf") then
- open "config.conf" for input as #lconf
- LINE INPUT #lconf, null$
- LINE INPUT #lconf, null$
- LINE INPUT #lconf, null$
- LINE INPUT #lconf, yesno$
- LINE INPUT #lconf, null$
- LINE INPUT #lconf, null$
- LINE INPUT #lconf, ip$
- LINE INPUT #lconf, null$
- LINE INPUT #lconf, null$
- LINE INPUT #lconf, tokenyesno$
- LINE INPUT #lconf, null$
- LINE INPUT #lconf, null$
- LINE INPUT #lconf, login$
- LINE INPUT #lconf, null$
- LINE INPUT #lconf, null$
- LINE INPUT #lconf, password$
- LINE INPUT #lconf, null$
- LINE INPUT #lconf, null$
- LINE INPUT #lconf, action$
- LINE INPUT #lconf, null$
- LINE INPUT #lconf, null$
- LINE INPUT #lconf, null$
- LINE INPUT #lconf, null$
- LINE INPUT #lconf, notifyemail$
- LINE INPUT #lconf, null$
- LINE INPUT #lconf, null$
- LINE INPUT #lconf, smtpserver$
- LINE INPUT #lconf, null$
- LINE INPUT #lconf, null$
- LINE INPUT #lconf, smtport$
- LINE INPUT #lconf, null$
- LINE INPUT #lconf, null$
- LINE INPUT #lconf, smtpssl$
- LINE INPUT #lconf, null$
- LINE INPUT #lconf, null$
- LINE INPUT #lconf, authusername$
- LINE INPUT #lconf, null$
- LINE INPUT #lconf, null$
- LINE INPUT #lconf, authpassword$
- LINE INPUT #lconf, null$
- LINE INPUT #lconf, null$
- LINE INPUT #lconf, to$
- LINE INPUT #lconf, null$
- LINE INPUT #lconf, null$
- LINE INPUT #lconf, body$
- close #lconf
- '// Decrypt passwords
- if firsttime = 0 and not(password$ = "password") and not(instr(password$, "encrypted")) then
- encrypta = 1
- end if
- if instr(password$, "encrypted") then
- encrypted$ = word$(password$,1,"encrypted")
- gosub [decrypt]
- password$ = decrypted$
- end if
- '// Decrypt passwords
- if firsttime = 0 and not(authpassword$ = "password") and not(instr(authpassword$, "encrypted")) then
- encryptb = 1
- end if
- if instr(authpassword$, "encrypted") then
- encrypted$ = word$(authpassword$,1,"encrypted")
- gosub [decrypt]
- authpassword$ = decrypted$
- end if
- else
- '// If not exist config create a default config
- firsttime = 1
- end if
- RETURN
- [createconfig]
- '// Create a default config if first time
- if firsttime = 1 then
- password$ = "password"
- authpassword$ = "password"
- end if
- '// Encrypt passwords
- if encrypta = 1 or encryptb = 1 and firsttime = 0 then
- string$ = password$
- gosub [encrypt]
- password$ = encrypted$;"encrypted"
- string$ = authpassword$
- gosub [encrypt]
- authpassword$ = encrypted$;"encrypted"
- encrypta = 0
- encryptb = 0
- end if
- open "config.conf" for output as #cconf
- print #cconf, "[Leecher, Webui CONFIG]"
- print #cconf, " "
- print #cconf, "#Use Webui [yes|no]"
- if firsttime = 1 then print #cconf, "no"
- if firsttime = 0 then print #cconf, yesno$
- print #cconf, " "
- print #cconf, "#Webui [ip:port]"
- if firsttime = 1 then print #cconf, "localhost:8080"
- if firsttime = 0 then print #cconf, ip$
- print #cconf, " "
- print #cconf, "#Use Token auth [yes|no]"
- if firsttime = 1 then print #cconf, "no"
- if firsttime = 0 then print #cconf, tokenyesno$
- print #cconf, " "
- print #cconf, "#Webui [login]"
- if firsttime = 1 then print #cconf, "jonh"
- if firsttime = 0 then print #cconf, login$
- print #cconf, " "
- print #cconf, "#Webui [password]. All passwords will be encrypted"
- print #cconf, password$
- print #cconf, " "
- print #cconf, "#Webui actions [stop|start|pause|remove]"
- if firsttime = 1 then print #cconf, "stop"
- if firsttime = 0 then print #cconf, action$
- print #cconf, " "
- print #cconf, "[Leecher, Email Notification CONFIG]"
- print #cconf, " "
- print #cconf, "#Use notification email [yes|no]"
- if firsttime = 1 then print #cconf, "no"
- if firsttime = 0 then print #cconf, notifyemail$
- print #cconf, " "
- print #cconf, "#SMTP server [smtp.gmail.com or smtp.live.com]"
- if firsttime = 1 then print #cconf, "smtp.gmail.com"
- if firsttime = 0 then print #cconf, smtpserver$
- print #cconf, " "
- print #cconf, "#SMTP Port, [25] is ok"
- if firsttime = 1 then print #cconf, "25"
- if firsttime = 0 then print #cconf, smtport$
- print #cconf, " "
- print #cconf, "#SMTP SSL [auto|yes|no], [auto] is ok"
- if firsttime = 1 then print #cconf, "auto"
- if firsttime = 0 then print #cconf, smtpssl$
- print #cconf, " "
- print #cconf, "#Auth username, send email from"
- if firsttime = 1 then print #cconf, "username@gmail.com"
- if firsttime = 0 then print #cconf, authusername$
- print #cconf, " "
- print #cconf, "#Auth password. All passwords will be encrypted"
- print #cconf, authpassword$
- print #cconf, " "
- print #cconf, "#Recipient, send email to"
- if firsttime = 1 then print #cconf, "username@gmail.com"
- if firsttime = 0 then print #cconf, to$
- print #cconf, " "
- print #cconf, "#Body, message to send for recipient"
- if firsttime = 1 then print #cconf, "The downloading the torrent has finished: "
- if firsttime = 0 then print #cconf, body$
- close #cconf
- firsttime = 0
- RETURN
- [encrypt]
- '// Encrypt
- key=3
- encrypted$=""
- for i = 1 to len(string$)
- encrypted$ = encrypted$ + chr$(asc(mid$(string$, i, 1)) xor key)
- next i
- RETURN
- [decrypt]
- '// Decrypt
- key=3
- decrypted$=""
- for i = 1 to len(encrypted$)
- decrypted$ = decrypted$ + chr$(asc(mid$(encrypted$, i, 1)) xor key)
- next i
- RETURN
- [ping]
- '// Get connected state
- lpszURL$ = "http://";ip$
- FLAG.ICC.FORCE.CONNECTION=1
- open "wininet.dll" for dll as #win
- calldll #win, "InternetCheckConnectionA",_
- lpszURL$ As ptr, _
- FLAG.ICC.FORCE.CONNECTION As Long,_
- dwReserved As Long, _
- resulticc As ulong
- close #win
- RETURN
- '// Retrieves the contents of the specified variable from the environment block of the calling process.
- Function Environ$(varName$)
- retBufr$ = space$(127) : nSize = len(retBufr$)
- CallDll #kernel32, "GetEnvironmentVariableA",_
- varName$ as ptr,_
- retBufr$ as ptr,_
- nSize as long,_
- ret as long
- Environ$ = trim$(retBufr$)
- End Function
- '// Function which can be used to test if a file exists on disk.
- function fileExists(path$, filename$)
- files path$, filename$, info$()
- fileExists = val(info$(0, 0))
- end function
- '// Function which can be used to test if a folder exists on disk.
- function folderExists(path$)
- folderExists = fileExists(path$, "nul")
- end function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement