Jump to content




File Protector - For Server Owners


  • You cannot reply to this topic
No replies to this topic

#1 CoderJohn

  • Members
  • 28 posts

Posted 09 March 2013 - 09:51 AM

This is a nifty little program for server owners. File Protector is a little thing i'm working on so that members can protect their files on a server. As of now it only protects the file from being read/edited. I haven't really had the opurtunity of working on it more than an hour, but it works in its current state.

To Install:
Stick the program in /rom/autorun/
Name it whatever you want. I prefer FileProtector.

The next version I will add osID protections. In which the user can make it where only certain computers can edit it without using a password.

[b]To add a password to a file:[/b]
1. Edit the file
2. Set the first line to --password
3. The next line is --YOURPASSWORD
4. The next line is another --ANOTHERPASSWORD or a non commented line.

All commented lines that are consecutive to the --password at the TOP of the file are passwords.
--password
--123abc
--Made by ENET

would result in two passwords. 123abc and Made by ENET

Instead you should:
--password
--123abc

--Made by ENET

--Made by ENET/MrJohnB & Lion4Ever
--Date Last Modified: 20130307

local nativeOpen = fs.open;
function fs.open(path,mode,input)
		if(fs.exists(path))then
				local handle = nativeOpen(path,"r");
				if(handle.readLine()=="--password")then
						if(input==nil)then --no password was given in the args so we need to get it ourselves.
								term.clear();
								term.setCursorPos(1,1);
								term.write("This file requires a password.");
								term.setCursorPos(5,2);
								term.write("Password: ");
								input = read("*");
						end
						input = "--"..input;
						local text = handle.readLine();
						while(text:sub(1,2)=="--")do
								if(input == text)then
										handle.close();
										return nativeOpen(path, mode);
								end
								text = handle.readLine();
						end
						handle.close();
						error("Invalid Password");
				end
		end
		return nativeOpen(path, mode);
end

Spoiler






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users