This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
DarkenedEvil's profile picture

[CCC] ComputerCraft Cloud!

Started by DarkenedEvil, 29 May 2013 - 08:06 PM
DarkenedEvil #1
Posted 29 May 2013 - 10:06 PM
ComputerCraft Cloud

by

DarkenedEvil


Overview:
Welcome one and welcome all to my newest CC invention! Its called the CC Cloud or CCC for short! Currently in the development stage this program aims to add a cloud to MC with the use of CC and a website!

Disclaimer:
Before I post anything related to the program I must note: Don't upload passwords and usernames!(until I incorporate some sort of encryption to protect files!)

Description:
CCC or ComputerCraft Cloud will have a computer program that communicates with a web page after a file is uploaded or downloaded. The web page (coded in PHP) will receive and distribute all requests all on one page so no files can be found by just checking the source. When downloading something the computer will send the request with the file name, then the web page will find that page (if it exists) and send back the page URL for the computer to download. When uploading something the computer sends a request to the web page with the file and the web page then puts the file in its correct location to be downloaded later. Also after sending the file to where it needs to be the webpage responds to the computer telling it whether things went ok or not.

Uses:
  • Creating a file or text on one server and easily downloading and using it on another.
  • Easily have private and public files for multiple computers or servers
  • Create an account and safely store files!
  • Many other uses!
What is done currently:
There is a brand new version since I just got back from something. It is almost all re-written. It makes it 10x better and more efficient with each person getting a username defined by themselves(Soon to have a login system). Also soon to come is the ability to delete a file.
What I have done so far for the uploading.
http://pastebin.com/rFcLkAWc
What I have done for the downloading.
http://pastebin.com/Jcqdv9xG


ToDo:
1) Create login function to allow users to have their own files
2) Have shared files(anyone can download the file)
3) Create installer
4) Make a create user function
5) Encrypt passwords(Most important)
6) Store things in a database(First thing to be done. If I can figure it out.)
7) Be able to delete files

Other Notes:
AGAIN this is in development meaning no releases only programs released AS IS so please give feedback and be patient.

I am also looking for a person who can help me with encryption and/or databases.

Please question/comment/give feedback!
1lann #2
Posted 30 May 2013 - 12:48 AM

os.pullEvent = os.pullEventRaw
_G.shell = shell
Why is that necessary? O_o. Makes it look malicious.
ElvishJerricco #3
Posted 30 May 2013 - 01:45 AM
Line 17:


if #tArgs == 0 or 1 then

Won't work as I assume you mean it to. Lua will split this into the following boolean logic:


if (#tArgs is equal to 0) or (1 is a non-nil, non-false value).

Because 1 is always a non-nil, non-false value, this logic will always return true. You might imagine a solution would be


if #tArgs == (0 or 1) then

but that won't work either. "or" statements returns the first value to be non-nil and non-false. So this is really saying


if #tArgs is equal to (0, or if that's nil or false, check 1)

And since 0 is not false or nil, it will check if #tArgs is 0, all the time. The only solution is to do two different equality checks.


if #tArgs == 0 or #tArgs == 1 then

The logic translates to


if #tArgs is equal to 0, or if #tArgs is equal to 1

I only wrote so much because it's a rookie mistake and a commonly recurring one if you don't learn about it. So I hope this cleared that up.
DarkenedEvil #4
Posted 30 May 2013 - 02:35 PM

os.pullEvent = os.pullEventRaw
_G.shell = shell
Why is that necessary? O_o. Makes it look malicious.
That was necessary because for some reason it wouldn't run shell.run so I had to use that(before I took out shell.run)
DarkenedEvil #5
Posted 30 May 2013 - 02:37 PM
Line 17:


if #tArgs == 0 or 1 then

Won't work as I assume you mean it to. Lua will split this into the following boolean logic:


if (#tArgs is equal to 0) or (1 is a non-nil, non-false value).

Because 1 is always a non-nil, non-false value, this logic will always return true. You might imagine a solution would be


if #tArgs == (0 or 1) then

but that won't work either. "or" statements returns the first value to be non-nil and non-false. So this is really saying


if #tArgs is equal to (0, or if that's nil or false, check 1)

And since 0 is not false or nil, it will check if #tArgs is 0, all the time. The only solution is to do two different equality checks.


if #tArgs == 0 or #tArgs == 1 then

The logic translates to


if #tArgs is equal to 0, or if #tArgs is equal to 1

I only wrote so much because it's a rookie mistake and a commonly recurring one if you don't learn about it. So I hope this cleared that up.
Thank you for the help. I did find it useful but as I said in the OP it is not close to being done I only posted that here to make it official. Bug testing and adding a login begins today!
jesusthekiller #6
Posted 01 June 2013 - 05:37 PM
No one uses shell.run() :P/> <– Kidding

Do:

local function run(path)
  pcall(loadfile(path))
end


Note: It will not work with CraftOS programs.
DarkenedEvil #7
Posted 01 June 2013 - 06:34 PM
No one uses shell.run() :P/> <– Kidding

Do:

local function run(path)
  pcall(loadfile(path))
end


Note: It will not work with CraftOS programs.

I don't use any external programs now so its all within one program so i dont need it any more but thanks:D
1lann #8
Posted 01 June 2013 - 11:33 PM

os.pullEvent = os.pullEventRaw
_G.shell = shell
Why is that necessary? O_o. Makes it look malicious.
That was necessary because for some reason it wouldn't run shell.run so I had to use that(before I took out shell.run)
Why is the os.pullEvent = os.pullEventRaw necessary then?
DarkenedEvil #9
Posted 01 June 2013 - 11:59 PM

os.pullEvent = os.pullEventRaw
_G.shell = shell
Why is that necessary? O_o. Makes it look malicious.
That was necessary because for some reason it wouldn't run shell.run so I had to use that(before I took out shell.run)
Why is the os.pullEvent = os.pullEventRaw necessary then?
To be honest i just put it in there. but next update both will be in one program so I'm going to need it
Mads #10
Posted 02 June 2013 - 04:41 AM
No one uses shell.run() :P/>/&amp;gt;/&amp;gt; &amp;lt;– Kidding Do:
 local function run(path) pcall(loadfile(path)) end
Note: It will not work with CraftOS programs.


pcall(loadstring(io.open(path, "r"):read("*a")))
jesusthekiller #11
Posted 02 June 2013 - 07:16 AM

pcall(loadstring(io.open(path, "r"):read("*a")))

io is slower than fs (io is wrapper around fs).
And loadfile() is shorter
DarkenedEvil #12
Posted 13 August 2013 - 02:33 AM
Brand new update that added a whole new rewrite of the programs. This also adds per-user saving and downloading of files. As of now anyone can access the files but in the next update. Things will require a password to download and hopefully be on a database.
DarkEspeon #13
Posted 13 August 2013 - 02:39 AM

pcall(loadstring(io.open(path, "r"):read("*a")))

io is slower than fs (io is wrapper around fs).
And loadfile() is shorter

…. you got that backwords… fs is the wrapper around io, io is the base that needed to be coded in java, and is thus faster……
jesusthekiller #14
Posted 13 August 2013 - 09:15 AM
Also, one thing: why is it called "cloud"? It's just web storage, not cloud.
Sxw #15
Posted 13 August 2013 - 05:33 PM

pcall(loadstring(io.open(path, "r"):read("*a")))

io is slower than fs (io is wrapper around fs).
And loadfile() is shorter

…. you got that backwords… fs is the wrapper around io, io is the base that needed to be coded in java, and is thus faster……

No it's not. Go look at the io api in computercraft. /rom/Apis/io
In normal lua fs would be a wrapper but this is computercraft.
DarkenedEvil #16
Posted 13 August 2013 - 08:17 PM
Also, one thing: why is it called "cloud"? It's just web storage, not cloud.

wikipedia said:
IaaS clouds often offer additional resources such as a virtual-machine disk image library, raw (block) and file-based storage, firewalls, load balancers, IP addresses,virtual local area networks (VLANs), and software bundles

This can technically be called a cloud because it is on a webserver and it offers file-based storage. If you want me to change the name I will, but I just think that it is correct.
jesusthekiller #17
Posted 14 August 2013 - 07:03 AM
I get your point, but it is not *real* cloud :P/>
MudkipTheEpic #18
Posted 14 August 2013 - 10:57 PM
I get your point, but it is not *real* cloud :P/>
The following is a smartarse remark.

A *real* cloud is made of vapors, therefore cannot hold any computer data.
jesusthekiller #19
Posted 15 August 2013 - 06:09 AM
So you agree with me that it is not real cloud? :3
DarkenedEvil #20
Posted 15 August 2013 - 05:58 PM
I get your point, but it is not *real* cloud :P/>
The following is a smartarse remark.

A *real* cloud is made of vapors, therefore cannot hold any computer data.

Now we're getting serious….but, it can still be called a real cloud because those vapors have electrons and electrons move from one atom to another creating a charge. That charge can then be used to power the internet!(Yah thats right, the internet is powered by clouds)
Mitchfizz05 #21
Posted 17 August 2013 - 05:01 AM
I get your point, but it is not *real* cloud :P/>
The following is a smartarse remark.

A *real* cloud is made of vapors, therefore cannot hold any computer data.

Now we're getting serious….but, it can still be called a real cloud because those vapors have electrons and electrons move from one atom to another creating a charge. That charge can then be used to power the internet!(Yah thats right, the internet is powered by clouds)
What if there are no clouds =O - No internet! Never!!!