Jump to content

Reading file off internet and doing specific commands


Recommended Posts

Hey, basically I want my program to access a file from my freewebs page.

Example:

http://halconknights.webs.com/teststuff.txt

and read stuff from that to assign/Update variables

$Version

$Update

What I need to know is how to set up that .txt file to assign/update the variables and then have my program access the internet to that page/file and read it and assign them.

Link to comment
Share on other sites

You can upload a Ini file to your site. Then use InetGet() or InetRead() with your app to grab the info.

Particularly take a look at the example provided in the Help File with InetGet(), once the file is downloaded to your pc, your app than could call the variables with IniRead()

Edited by Realm

My Contributions: Unix Timestamp: Calculate Unix time, or seconds since Epoch, accounting for your local timezone and daylight savings time. RegEdit Jumper: A Small & Simple interface based on Yashied's Reg Jumper Function, for searching Hives in your registry. 

Link to comment
Share on other sites

You can upload a Ini file to your site. Then use InetGet() or InetRead() with your app to grab the info.

Particularly take a look at the example provided in the Help File with InetGet(), once the file is downloaded to your pc, your app than could call the variables with IniRead()

InetGet() would download the file, but Could I use InetRead() to read that file instead of having to download it?

Link to comment
Share on other sites

Yes you could, but I have'nt found a way to read directly from interent like IniRead. So you would have to grab your variables with a StringRegEx() or something similar, Look at the example provide in the Help File with InetRead(), $sData, would be all the text from the file, so it would read much like FileRead() does from your pc.

If you are worried about your app becoming Time consuming....InetGet() with small text files, is actually pretty fast...I have an app the uses InetGet() to download a Ini file (that contains 4 sections and about 10 keys per section), then my app reads the ini for 2 elements, and deletes the temp file it created, all in under 2 seconds, maybe faster, since it process a few other commands as well.

Edit: InetRead() delivers the text file in binary, so to make it readable by your app, you will have to include BinaryToString()

Edited by Realm

My Contributions: Unix Timestamp: Calculate Unix time, or seconds since Epoch, accounting for your local timezone and daylight savings time. RegEdit Jumper: A Small & Simple interface based on Yashied's Reg Jumper Function, for searching Hives in your registry. 

Link to comment
Share on other sites

Well, I was able to get the information using this

$Ini = InetRead("http://halconknights.webs.com/Info.ini")

$Ini = BinaryToString($Ini)

MsgBox(4096, "Result", $Ini)

Except if I do it like this I am probably not sure if I am able to use IniRead() function. Just wanted to bring that up while I still experiment so I can hear your insight on this.

Edit: I forgot you said something about not being able to use IniRead() on this. If that is the case(which I will still be experimenting) I could just use a .txt file for what I need and try the StringRegEx() stuff.

Edit2: Ill experiment with InetGet() as well.

Edited by KurogamineNox
Link to comment
Share on other sites

I think it would be easier to just Download the file. I found the command line so even if they somehow edited the file it would reforce download to undo any changes(something similar lol) I added the deletion method to help out also. Similar to yours maybe(never saw your coding) but probably similar. I really do not need a lot of keys anyways as Ill be only using some keys for just a few things like updates and version# and what not.

InetGet("http://halconknights.webs.com/Info.ini","Info.ini",1)
$var = IniRead("Info.ini", "Version", "key", "NotFound")
MsgBox(4096, "Result", $var)
FileExists("Info.ini")
FileDelete("Info.ini")
Link to comment
Share on other sites

If you are afraid of them altering the file after it has been downloaded, you can do a few things to keep them from doing so, like downloading it to a folder they probably wouldn't look in the first place, 2nd you change the attributes to hidden once downloaded.

here is an example of what I do, when I don't want them to interfere with it. I added to pull all the info, which if stored Globally, can be called at anytime from your app. I included a way to set file to hidden incase, you dont want to delete it, and keep it for later use.

Local $hDownload = InetGet("http://halconknights.webs.com/Info.ini", @TempDir & "\update.ini", 1, 1)
Do
    Sleep(250)
Until InetGetInfo($hDownload, 2)    ; Check if the download is complete.
InetClose($hDownload) ; Close the handle to release resourcs.

;Change File attributs to Hidden:
FileSetAttrib(@TempDir & "\update.ini", "+H"); I usually don't worry about this step, since it reads and deletes in under a second.

;Read Your keys in:
$ver_key=IniRead(@TempDir & "\update.ini","Version","key",-1)
$dwnld_key=IniRead(@TempDir & "\update.ini","Download","key",-1)
$accsd_key=IniRead(@TempDir & "\update.ini","Accessed","key",-1)
$lc_msg_key=IniRead(@TempDir & "\update.ini","LCmsg","key",-1)
$c_msg=IniRead(@TempDir & "\update.ini","Cmsg","key",-1)

FileDelete(@TempDir & "\update.ini")

Other ways to hide the file deeper, are to choose different folders such as the Windows, or another Common Folder. You can also change the file extension such as .dat or .config. many file extensions are still viewable by IniRead().

Also, after you download the file, you could encypt the information making it more impossible for the users to read and interpret.

Edited by Realm

My Contributions: Unix Timestamp: Calculate Unix time, or seconds since Epoch, accounting for your local timezone and daylight savings time. RegEdit Jumper: A Small & Simple interface based on Yashied's Reg Jumper Function, for searching Hives in your registry. 

Link to comment
Share on other sites

If you are afraid of them altering the file after it has been downloaded, you can do a few things to keep them from doing so, like downloading it to a folder they probably wouldn't look in the first place, 2nd you change the attributes to hidden once downloaded.

here is an example of what I do, when I don't want them to interfere with it. I added to pull all the info, which if stored Globally, can be called at anytime from your app. I included a way to set file to hidden incase, you dont want to delete it, and keep it for later use.

Local $hDownload = InetGet("http://halconknights.webs.com/Info.ini", @TempDir & "\update.ini", 1, 1)
Do
    Sleep(250)
Until InetGetInfo($hDownload, 2)    ; Check if the download is complete.
InetClose($hDownload) ; Close the handle to release resourcs.

;Change File attributs to Hidden:
FileSetAttrib(@TempDir & "\update.ini", "+H"); I usually don't worry about this step, since it reads and deletes in under a second.

;Read Your keys in:
$ver_key=IniRead(@TempDir & "\update.ini","Version","key",-1)
$dwnld_key=IniRead(@TempDir & "\update.ini","Download","key",-1)
$accsd_key=IniRead(@TempDir & "\update.ini","Accessed","key",-1)
$lc_msg_key=IniRead(@TempDir & "\update.ini","LCmsg","key",-1)
$c_msg=IniRead(@TempDir & "\update.ini","Cmsg","key",-1)

FileDelete(@TempDir & "\update.ini")

Other ways to hide the file deeper, are to choose different folders such as the Windows, or another Common Folder. You can also change the file extension such as .dat or .config. many file extensions are still viewable by IniRead().

Also, after you download the file, you could encypt the information making it more impossible for the users to read and interpret.

Could I Use the .txt extension and still read the .ini commands from it? on freewebs.com if its a .txt I can edit it right on the website while .ini cant be edited.

Link to comment
Share on other sites

As far as I know you can use any extension. I have successfully tested with .dat, .config, .txt, .ini

Personally I like the .config because the user cannot open that file directly, like you can with .txt, or .ini

Not to mention I encrypt my data before uploading it to my website. and have my app decrypt it before assigning it to a variable

IniRead() does not look for file type... it looks for sections and keys in the file.

My Contributions: Unix Timestamp: Calculate Unix time, or seconds since Epoch, accounting for your local timezone and daylight savings time. RegEdit Jumper: A Small & Simple interface based on Yashied's Reg Jumper Function, for searching Hives in your registry. 

Link to comment
Share on other sites

As far as I know you can use any extension. I have successfully tested with .dat, .config, .txt, .ini

Personally I like the .config because the user cannot open that file directly, like you can with .txt, or .ini

Not to mention I encrypt my data before uploading it to my website. and have my app decrypt it before assigning it to a variable

IniRead() does not look for file type... it looks for sections and keys in the file.

Lol, I had no idea that IniRead() just reads anything and doesnt just have to be .ini

Link to comment
Share on other sites

As far as I know, you can use any extension or file format, I haven't tested everything. I took a moment and rewritten my example from earlier to include some simple encryption. This will show you a simple way to encrypt and decrypt your data so it is a little more obscured from the user.

To Encrypt Data as it writes to the ini file.

;Encrypt your data to be placed in your ini file.
IniWrite(@DesktopDir & "\Info.ini",Encrypt("Version"),Encrypt("key"),Encrypt("1.0")
IniWrite(@DesktopDir & "\Info.ini",Encrypt("Download"),Encrypt("key"),Encrypt("http://www.halconknights.webs.com/"))
IniWrite(@DesktopDir & "\Info.ini",Encrypt("Accessed"),Encrypt("key"),Encrypt("1"))
IniWrite(@DesktopDir & "\Info.ini",Encrypt("LCmsg"),Encrypt("key"),Encrypt("1"))
IniWrite(@DesktopDir & "\Info.ini",Encrypt("Cmsg"),Encrypt("key"),Encrypt("Welcome to My First Closed Beta Project Called Xfire Xtra! Enjoy."))

;~ ShellExecute("Notepad.exe",@DesktopDir & "\Info.ini")

Func Encrypt($eString)
    Local $passkey="MakeUpAVeryLongPassWordWithLettersNumbers&Symbols"
    Return _StringEncrypt (1, $eString, $passkey , 1 )
EndFunc ;==> Encrypt()
Func Decrypt($dString)
    Local $passkey="MakeUpAVeryLongPassWordWithLettersNumbers&Symbols"
    Return _StringEncrypt (0, $dString, $passkey , 1 )
EndFunc ;==> Decrypt()

How your app will decrypt the data from the inifile.

Local $hDownload = InetGet("http://halconknights.webs.com/Info.ini", @TempDir & "\update.ini", 1, 1) 
Do
    Sleep(250)
Until InetGetInfo($hDownload, 2)    ; Check if the download is complete.
InetClose($hDownload) ; Close the handle to release resourcs.

;Decrypt your data as you read your keys in:
$ver_key=Decrypt(IniRead(@TempDir & "\update.ini",Encrypt("Version"),Encrypt("key"),Encrypt(-1)))
$dwnld_key=Decrypt(IniRead(@TempDir & "\update.ini",Encrypt("Download"),Encrypt("key"),Encrypt(-1)))
$accsd_key=Decrypt(IniRead(@TempDir & "\update.ini",Encrypt("Accessed"),Encrypt("key"),Encrypt(-1)))
$lc_msg_key=Decrypt(IniRead(@TempDir & "\update.ini",Encrypt("LCmsg"),Encrypt("key"),Encrypt(-1)))
$c_msg=Decrypt(IniRead(@TempDir & "\update.ini",Encrypt("Cmsg"),Encrypt("key"),Encrypt(-1)))

FileDelete(@TempDir & "\update.ini")

Func Encrypt($eString)
    Local $passkey="MakeUpAVeryLongPassWordWithLettersNumbers&Symbols"
    Return _StringEncrypt (1, $eString, $passkey , 1 )
EndFunc ;==> Encrypt()
Func Decrypt($dString)
    Local $passkey="MakeUpAVeryLongPassWordWithLettersNumbers&Symbols"
    Return _StringEncrypt (0, $dString, $passkey , 1 )
EndFunc ;==> Decrypt()
Edited by Realm

My Contributions: Unix Timestamp: Calculate Unix time, or seconds since Epoch, accounting for your local timezone and daylight savings time. RegEdit Jumper: A Small & Simple interface based on Yashied's Reg Jumper Function, for searching Hives in your registry. 

Link to comment
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
 Share

  • Recently Browsing   0 members

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