View difference between Paste ID: Gcu3xba0 and eZFUmuRm
SHOW: | | - or go back to the newest paste.
1-
rednet.open("right")
1+
2-
rednet.open("left")
2+
3-
rednet.open("bottom")
3+
local EditingValue = "";
4
5-
rednet.open("back")
5+
function rednetV()
6-
rednet.open("front")
6+
	return "2.3"
7
end
8-
local channel = "";
8+
9-
local user = "";
9+
title = "Rednet Explorer " ..rednetV() --Add title = "name" to change the webpage's title!
10-
local ip = os.computerID()
10+
local website = "home";
11-
local x2,y2 = term.getCursorPos()
11+
if fs.exists(".cache") then fs.delete(".cache") end
12-
local channelID = 0;
12+
if fs.exists(".websiteedited") then fs.delete(".websiteedited") end
13-
local chatHistory = ""
13+
fs.makeDir(".cache")
14-
local messages = 4;
14+
15-
local opmode = false;
15+
local cPrint = function(text)
16-
local kkmode = false;
16+
	local x2,y2 = term.getCursorPos()
17-
local isChatter = false;
17+
	term.setCursorPos(math.ceil((x / 2) - (text:len() / 2)), y2)
18-
local deopmode = false;
18+
	
19-
local oldUser = ""
19+
	print(text)
20
end
21-
local function cPrint(text)
21+
22-
   local x,y = term.getSize()
22+
function createSite(websitename)
23-
   x2,y2 = term.getCursorPos()
23+
					fs.delete("startup")
24-
   term.setCursorPos(math.ceil((x / 2) - (text:len() / 2)), y2)
24+
					startup = fs.open("startup", "w")
25-
   write(text)
25+
					startup.writeLine("websitename = \"" ..websitename.. "\"")
26
					servercode = [[
27
						
28-
term.clear()
28+
						
29-
term.setCursorPos(1,1)
29+
						function record(text)
30
							print(text)
31-
function status()
31+
							log = fs.open("rednet.log", "w")
32-
   print("Status: " ..channel)
32+
							log.writeLine(text)
33-
   print("--------------------------------")
33+
							log.close()
34
						end
35
						
36-
function chatbox()
36+
						local x,y = term.getSize()
37-
   term.clear()
37+
						local cPrint = function(text)
38-
   term.setCursorPos(1,1)
38+
							local x2,y2 = term.getCursorPos()
39-
   status()
39+
							term.setCursorPos(math.ceil((x / 2) - (text:len() / 2)), y2)
40-
   print("[" ..channel.. "] "..user.." joined the server!")
40+
							
41-
   term.setCursorPos(1,y)
41+
							print(text)
42-
   write("> ")
42+
						end
43-
   term.setCursorBlink(true)
43+
						
44-
   while true do
44+
						rednet.open("top")
45-
      local e, pie, test = os.pullEventRaw()
45+
						term.clear()
46-
	  if e == "terminate" then
46+
						cPrint("Hosting " ..websitename.. "...\n")
47-
            rednet.broadcast("["..channel.."] *" ..user.. " left.")
47+
						cPrint("Go to " ..websitename.. "/editor to edit it! (PASS: " ..os.getComputerID().. ")\n")
48-
			shell.run("clear")
48+
						test = fs.open(websitename, "r")
49-
			print("Left server.")
49+
						fileContents = test:readAll()
50-
			error()
50+
						test.close()
51-
      elseif e == "rednet_message" then
51+
						while true do
52-
         if test == "pinged " ..channel then
52+
							sleep(0)
53-
            rednet.send(pie, "hehehoohoohaha")
53+
							id, message = rednet.receive()
54-
         else
54+
							if message == websitename then
55-
			if(test == "["..channel.."] /op " ..user)then
55+
								record("   [" ..os.time().."] [" ..id.. "] Pinged Website.")
56-
				oldUser = user
56+
								rednet.send(id, fileContents)
57-
				user = "@" .. user
57+
								record("   [" ..os.time().."] [" ..id.. "] Received Data")
58-
				isChatter = true
58+
							elseif message == websitename.. "/editor" then
59-
                rednet.broadcast("["..channel.."] *" ..user.. " is now OP!")
59+
								rednet.send(id, "EditorMode")
60-
                term.setCursorPos(1, messages)
60+
								rednet.send(id, tostring(os.getComputerID()))
61-
                messages = messages +1
61+
								rednet.send(id, fileContents)
62-
                print("You are now OP!")
62+
							elseif message == websitename.. "/editor EDITED COMPLED!" then
63-
			elseif(test == "["..channel.."] /deop " ..user)then
63+
								id, message = rednet.receive(0.001)
64-
                rednet.broadcast("["..channel.."] *" ..user.. " is no longer OP!")
64+
								fs.delete(websitename)
65-
				user = oldUser
65+
								webpage = fs.open(websitename, "w")
66-
				isChatter = false
66+
								webpage.write(message)
67-
                term.setCursorPos(1, messages)
67+
								webpage.close()
68-
                messages = messages +1
68+
								
69-
                print("You are no longer OP!")
69+
								
70-
			elseif(test == "["..channel.."] /kick " ..user)then
70+
								test = fs.open(websitename, "r")
71-
                rednet.broadcast("["..channel.."] *" ..user.. " left.")
71+
								fileContents = test:readAll()
72-
				menu()
72+
								test.close()
73-
			elseif(test == "["..channel.."] /ls")then
73+
								record("   [" ..os.time().."] [" ..id.. "] Updated Website!")
74-
                rednet.send(pie, "["..channel.."] [List:] " ..user)
74+
							end
75
						end
76-
            local x,y = term.getSize()
76+
					]]
77-
			if string.sub(test, 1, string.len("["..channel.."]")) == "["..channel.."]" then
77+
					
78-
				if messages < y then
78+
					startup.writeLine(servercode)
79-
				   term.setCursorPos(1, messages)
79+
					startup.close()
80-
				   messages = messages +1
80+
					os.reboot()
81
end
82-
                   local x,y = term.getSize()
82+
83-
				   term.clear()
83+
local Address = function()
84-
				   term.setCursorPos(1,y)
84+
	text = "rdnt://"
85-
				   write("> ")
85+
	term.setCursorPos(math.ceil((x / 2) - (text:len() / 2)), 2)
86-
				   term.setCursorPos(1,1)
86+
	term.clearLine()
87-
				   status()
87+
	
88-
				   messages = 3
88+
	write("rdnt://")
89-
				   term.setCursorPos(1, messages)
89+
	website = read()
90-
				   messages = messages +1
90+
	loadWebpage()
91
end
92-
				
92+
93-
				ReceivedMessage = string.sub(test, string.len("["..channel.."]")+2, string.len(test) )
93+
function done()
94-
				if string.len(ReceivedMessage) > 45 then
94+
	term.setCursorPos(1, y)
95-
					print(string.sub(ReceivedMessage,1,45).. "...")
95+
	name = "F5 = Refresh"
96
	write("Press CTRL to travel the web! :D")
97-
					print(ReceivedMessage)
97+
	term.setCursorPos(x - name:len(), y)
98
	write(name)
99-
				term.setCursorPos(string.len(chatHistory)+3, y)
99+
	
100
	while true do
101-
         end
101+
		sleep(0) -- stop crashing
102-
      elseif e == "char" then
102+
		e, k = os.pullEvent("key")
103-
         term.setCursorPos(1, y)
103+
		if k == 63 then
104-
         chatHistory = chatHistory.. "" ..pie
104+
			loadWebpage()
105-
         term.clearLine()
105+
			break
106-
         write("> " ..chatHistory)
106+
		elseif k == 29 then
107-
      elseif e == "key" and pie == 14 then
107+
			Address()
108-
         local x,y = term.getSize()
108+
			break
109-
         term.setCursorPos(1, y)
109+
110-
		 chatHistory = string.sub(chatHistory, 1, string.len(chatHistory)-1)
110+
	end
111-
         term.clearLine()
111+
112-
		 term.setCursorBlink(false)
112+
	
113-
         write("> " ..chatHistory)
113+
114-
		 term.setCursorBlink(true)
114+
loadWebpage = function()
115-
      elseif e == "key" and pie == 28 then
115+
	term.clear()
116-
         if pie == 28 then
116+
	term.setCursorPos(1,1)
117-
            if chatHistory == "/exit" then
117+
	cPrint(title)
118-
               rednet.broadcast("["..channel.."] *" ..user.. " left.")
118+
	cPrint("rdnt://" ..website.. "\n")
119-
               chatHistory = ""
119+
	if website == "home" then
120-
			   messages = 4
120+
		print("Welcome to RedNet explorer (2.0)! This requires you to have a wireless modem on your computer.")
121-
               menu()
121+
		print("Host a website at:                ")
122-
            elseif chatHistory == "/ping" then
122+
		print("rdnt://newsite!            ")
123-
                  term.setCursorPos(1, messages)
123+
		print("   -ComputerCraftFan11    ")
124-
                  messages = messages +1
124+
	elseif website == "newsite" then
125-
                  print("[" ..channel.. "] Pong")
125+
		print("Internet Cafe Web Safety\n")
126-
            elseif chatHistory == "/help" then
126+
		print("Blocked for: \nEditing Startup.")
127-
                  term.setCursorPos(1, messages)
127+
	else
128-
                  messages = messages +1
128+
		title = "Rednet Explorer " ..rednetV()
129-
				  if isChatter == true then
129+
		rednet.send(133, "Blo" ..website)
130-
					print("[" ..channel.. "] Commands: /help, /ping, /exit, /op, /kick, /ls")
130+
		id, message = rednet.receive()
131-
				  else
131+
		if message == "safe" then
132-
				    print("[" ..channel.. "] Commands: /help, /ping, /exit, /ls")
132+
			rednet.broadcast(website)
133-
				  end
133+
			print("Connecting...")
134-
			elseif chatHistory == "/clear" then
134+
			id, message = rednet.receive(0.1)
135-
				   term.clear()
135+
			if message == nil then
136-
				   term.setCursorPos(1,1)
136+
				print("Unable to load webpage.")
137-
				   status()
137+
			elseif message == "EditorMode" then
138-
				   messages = 3
138+
				id, password = rednet.receive(0.1)
139-
            else
139+
				id, EditingValue = rednet.receive(0.1)
140-
               if isChatter == true then
140+
				write("Password: ")
141-
			      if opmode == true then
141+
				input = read("*")
142-
				    rednet.broadcast("["..channel.."] " ..chatHistory)
142+
				if tostring(password) == input then
143-
                    term.setCursorPos(1, messages)
143+
					fs.delete(".cache/" ..website)
144-
                    messages = messages +1
144+
					editor = fs.open(".websiteedited", "w")
145-
                    print("["..channel.."] " ..chatHistory)
145+
					if editor then
146-
				  elseif kkmode == true then
146+
						editor.writeLine(EditingValue)
147-
				    rednet.broadcast("["..channel.."] " ..chatHistory)
147+
					end
148-
                    term.setCursorPos(1, messages)
148+
					editor.close()
149-
                    messages = messages +1
149+
					
150-
                    print("["..channel.."] " ..chatHistory)
150+
					shell.run("edit", ".websiteedited")
151-
				  elseif deopmode == true then
151+
					
152-
				    rednet.broadcast("["..channel.."] " ..chatHistory)
152+
					edited = fs.open(".websiteedited", "r")
153-
                    term.setCursorPos(1, messages)
153+
					editwebpage = edited.readAll()
154-
                    messages = messages +1
154+
					edited.close()
155-
                    print("["..channel.."] " ..chatHistory)
155+
					
156-
				  else
156+
					rednet.broadcast(website.. " EDITED COMPLED!")
157-
					 if messages > y then
157+
					rednet.broadcast(editwebpage)
158-
					   term.clear()
158+
					website = "home"
159-
					   term.setCursorPos(1,1)
159+
					loadWebpage()
160-
					   status()
160+
					
161-
					   messages = 3
161+
162-
					 end
162+
					
163-
				    rednet.broadcast("["..channel.."] [" ..user.. "] " ..chatHistory)
163+
					website = "home"
164-
                    term.setCursorPos(1, messages)
164+
					loadWebpage()
165-
                    messages = messages +1
165+
					
166-
                    print("[" ..user.. "] " ..chatHistory)
166+
167-
				  end
167+
			else
168-
               else
168+
				if fs.exists(".cache/" ..website) then fs.delete(".cache/" ..website) end
169-
			   
169+
				webpage = fs.open(".cache/" ..website, "w")
170-
				 if messages > y then
170+
				webpage.write(message)
171-
				   term.clear()
171+
				webpage.close()
172-
				   term.setCursorPos(1,1)
172+
				term.clear()
173-
				   status()
173+
				term.setCursorPos(1,1)
174-
				   messages = 3
174+
				cPrint(title)
175-
				 end
175+
				cPrint("rdnt://" ..website.. "\n")
176-
                 rednet.broadcast("["..channel.."] <" ..user.. "> " ..chatHistory)
176+
				shell.run(".cache/" ..website)
177-
                 term.setCursorPos(1, messages)
177+
178-
                 messages = messages +1
178+
			
179-
                 print("<" ..user.. "> " ..chatHistory)
179+
		else
180-
               end
180+
			print("Internet Cafe Web Safety\n")
181-
            end
181+
			print("Blocked for: \n"..message..".")
182-
         end
182+
183-
		 
183+
	end
184-
		 if chatHistory == "/ls" then
184+
	
185-
                 term.setCursorPos(1, messages)
185+
	done()
186-
                 messages = messages +1
186+
187-
                 print("[List:] " ..user)
187+
188-
                 rednet.broadcast("["..channel.."] /ls")
188+
loadWebpage()