Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if not term.isColor() then
- error('This program works on advanced computers only')
- end
- --Made by MinerMan132 C:
- --Released on December 5th 2019
- --Do not modify this code
- if not fs.exists('tempdat/') then
- fs.makeDir('tempdat/')
- end
- local safe = true
- function draw()
- term.setBackgroundColor(colors.cyan)
- term.clear()
- term.setTextColor(colors.gray)
- term.setCursorPos(2,17)
- write('Made by MinerMan132')
- term.setCursorPos(2,18)
- write('Released on December 5th, 2019')
- term.setCursorPos(2,19)
- term.setTextColor(colors.red)
- write('Do not modify this program')
- term.setTextColor(colors.black)
- term.setCursorPos(15,7)
- write('Website URL')
- term.setCursorPos(2,7)
- write('Safe Mode')
- term.setCursorPos(5,4)
- term.setTextColor(colors.gray)
- write("Entering the URL 'help' will redirect")
- term.setCursorPos(5,5)
- write("you to the help page.")
- term.setCursorPos(3,8)
- term.setTextColor(colors.black)
- if safe then
- term.setBackgroundColor(colors.lime)
- write('O')
- else
- term.setBackgroundColor(colors.red)
- write('|')
- end
- paintutils.drawLine(15,8,50,8,colors.lightGray)
- end
- local function webget(ad)
- local check = true
- if http.request(ad) then
- check = true
- else
- check = false
- end
- if check then
- local site = http.get(ad)
- local web = {}
- local cweb = {}
- repeat
- local line = site.readLine()
- if line ~= nil then
- table.insert(web,line)
- end
- until line == nil
- local hts
- local hte
- for i,v in ipairs(web) do
- if string.find(v,'</cc>') and hte == nil then
- hte = i
- elseif string.find(v,'<cc>') and hts == nil then
- hts = i
- end
- end
- if not hts or not hte then
- return false
- end
- for pos = hts+1,hte-1 do
- table.insert(cweb,web[pos])
- end
- return cweb
- else
- return false
- end
- end
- function evcheck()
- while true do
- local ev = {os.pullEvent('mouse_click')}
- if ev[3] == 3 and ev[4] == 8 then
- local x,y = term.getCursorPos()
- local color1 = term.getTextColor()
- local color2 = term.getBackgroundColor()
- term.setCursorPos(3,8)
- term.setTextColor(colors.black)
- if safe then
- safe = false
- term.setBackgroundColor(colors.red)
- write('|')
- else
- safe = true
- term.setBackgroundColor(colors.lime)
- write('O')
- end
- term.setCursorPos(x,y)
- term.setTextColor(color1)
- term.setBackgroundColor(color2)
- end
- end
- end
- local webcon
- local webname
- function readcheck()
- local report
- local input
- repeat
- paintutils.drawLine(15,8,50,8,colors.lightGray)
- term.setCursorPos(15,8)
- term.setBackgroundColor(colors.lightGray)
- term.setTextColor(colors.gray)
- input = read()
- if input == 'help' then
- input = 'https://minraclient.github.io/Minra/'
- end
- report = webget(input)
- if report == false then
- term.setBackgroundColor(colors.cyan)
- term.setCursorPos(10,9)
- term.setTextColor(colors.red)
- write('Website not found/website incompatable')
- sleep(2)
- term.setCursorPos(10,9)
- term.clearLine()
- end
- until report ~= false
- webcon = report
- webname = input
- end
- local sweblist = {}
- if not http.request('https://minraclient.github.io/trusted_sources/') then
- error('Verified website list offline or unreachable, contact creator.')
- end
- local sweb = http.get('https://minraclient.github.io/trusted_sources/')
- repeat
- local line = sweb.readLine()
- if line ~= nil then
- table.insert(sweblist,line)
- end
- until line == nil
- table.remove(sweblist,1)
- table.remove(sweblist,1)
- table.remove(sweblist,#sweblist-1)
- table.remove(sweblist,#sweblist)
- while true do
- local skip = false
- draw()
- webcon = {}
- parallel.waitForAny(readcheck,evcheck)
- if webname and safe then
- local check = false
- for i,v in pairs(sweblist) do
- if webname == v then
- check = true
- end
- end
- if not check then
- term.setTextColor(colors.red)
- term.setBackgroundColor(colors.cyan)
- term.setCursorPos(6,9)
- write('This website is not on the pre-approved list.')
- term.setCursorPos(6,10)
- write('Please disable safe mode to visit unlisted')
- term.setCursorPos(6,11)
- write('websites.')
- sleep(6)
- skip = true
- for y = 9,11 do
- term.setCursorPos(1,y)
- term.clearLine()
- end
- end
- end
- if not skip then
- local name = 'tempdat/temp'..tostring(math.random(1,2^10))
- if fs.exists(name) then
- fs.delete(name)
- end
- local tempfile = fs.open(name,'w')
- for i,v in ipairs(webcon) do
- tempfile.writeLine(v)
- end
- tempfile.close()
- shell.run(name)
- fs.delete(name)
- end
- end
Add Comment
Please, Sign In to add comment