Guest User

Untitled

a guest
Jun 27th, 2016
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 16.44 KB | None | 0 0
  1. function config_print()
  2. shell.run("/system/apps/modules/windows_API.sys")
  3. shell.run("system/apps/config/modules.sys")
  4. open_program = true
  5. local img = paintutils.loadImage("system/images/opt_back.png")
  6. paintutils.drawImage(img, control_x, control_y)
  7. term.setBackgroundColor(colors.blue)
  8. term.setTextColor(colors.white)
  9. term.setCursorPos(control_x + 1, control_y)
  10. write("Control Panel")
  11. term.setTextColor(colors.black)
  12. term.setBackgroundColor(colors.green)
  13. term.setCursorPos(control_x + 28, control_y)
  14. write("_")
  15. term.setBackgroundColor(colors.yellow)
  16. write("o")
  17. term.setBackgroundColor(colors.red)
  18. write("X")
  19. term.setBackgroundColor(colors.white)
  20. term.setTextColor(colors.black)
  21. term.setCursorPos(control_x + 2, control_y + 2)
  22. if config_page == 0 then
  23. term.setCursorPos(control_x + 1, control_y + 2)
  24. term.setTextColor(colors.green)
  25. write("select settings from the menu")
  26. term.setTextColor(colors.black)
  27. term.setCursorPos(control_x + 3, control_y + 4)
  28. write("File Manager")
  29. term.setCursorPos(control_x + 3, control_y + 6)
  30. write("Users")
  31. term.setCursorPos(control_x + 3, control_y + 8)
  32. write("System Information")
  33. elseif config_page == 4 then --edit user
  34. edit_user()
  35. elseif config_page == 3 then --system info
  36. write("Windows version:")
  37. term.setCursorPos(control_x + 3, control_y + 3)
  38. term.setTextColor(colors.lightGray)
  39. write(win_version)
  40. term.setTextColor(colors.black)
  41.  
  42. term.setCursorPos(control_x + 2, control_y + 4)
  43. write("File manager version:")
  44. term.setCursorPos(control_x + 3, control_y + 5)
  45. term.setTextColor(colors.lightGray)
  46. write(fm_version)
  47. term.setTextColor(colors.black)
  48.  
  49. term.setCursorPos(control_x + 2, control_y + 6)
  50. write("Paint version:")
  51. term.setCursorPos(control_x + 3, control_y + 7)
  52. term.setTextColor(colors.lightGray)
  53. write(paint_version)
  54. term.setTextColor(colors.black)
  55.  
  56. term.setCursorPos(control_x + 2, control_y + 8)
  57. write("Dj version:")
  58. term.setCursorPos(control_x + 3, control_y + 9)
  59. term.setTextColor(colors.lightGray)
  60. write(Dj_version)
  61. term.setTextColor(colors.black)
  62.  
  63. term.setCursorPos(control_x + 2, control_y + 13)
  64. write("Developer: ")
  65. term.setTextColor(colors.lightGray)
  66. write(author)
  67. term.setTextColor(colors.black)
  68. term.setCursorPos(control_x + 2, control_y + 14)
  69. write("Nick on server: ")
  70. term.setTextColor(colors.lightGray)
  71. write(author_nick)
  72. term.setCursorPos(control_x + 3, control_y + 15)
  73. term.setBackgroundColor(colors.white)
  74. term.setTextColor(colors.red)
  75. write("return to Main Page")
  76. term.setTextColor(colors.black)
  77. elseif config_page == 1 then --file manager settings
  78. write("Press switch to change state")
  79. term.setCursorPos(control_x + 3, control_y + 4)
  80. write("visibility main files")
  81. if invicible == false then
  82. paintutils.drawPixel(control_x + 26, control_y + 4 ,colors.green)
  83. paintutils.drawPixel(control_x + 27, control_y + 4 ,colors.gray)
  84. else
  85. paintutils.drawPixel(control_x + 26, control_y + 4 ,colors.gray)
  86. paintutils.drawPixel(control_x + 27, control_y + 4 ,colors.red)
  87. end
  88. term.setCursorPos(control_x + 3, control_y + 6)
  89. term.setBackgroundColor(colors.white)
  90. write("visibility 'rom'")
  91. if rom_folder == false then
  92. paintutils.drawPixel(control_x + 26, control_y + 6 ,colors.green)
  93. paintutils.drawPixel(control_x + 27, control_y + 6 ,colors.gray)
  94. else
  95. paintutils.drawPixel(control_x + 26, control_y + 6 ,colors.gray)
  96. paintutils.drawPixel(control_x + 27, control_y + 6 ,colors.red)
  97. end
  98. term.setCursorPos(control_x + 3, control_y + 8)
  99. term.setBackgroundColor(colors.white)
  100. write("visibility 'system'")
  101. if system_folder == false then
  102. paintutils.drawPixel(control_x + 26, control_y + 8 ,colors.green)
  103. paintutils.drawPixel(control_x + 27, control_y + 8 ,colors.gray)
  104. else
  105. paintutils.drawPixel(control_x + 26, control_y + 8 ,colors.gray)
  106. paintutils.drawPixel(control_x + 27, control_y + 8 ,colors.red)
  107. end
  108. term.setCursorPos(control_x + 3, control_y + 10)
  109. term.setBackgroundColor(colors.white)
  110. write("show extensions")
  111. if extensions == false then
  112. paintutils.drawPixel(control_x + 26, control_y + 10 ,colors.green)
  113. paintutils.drawPixel(control_x + 27, control_y + 10 ,colors.gray)
  114. else
  115. paintutils.drawPixel(control_x + 26, control_y + 10 ,colors.gray)
  116. paintutils.drawPixel(control_x + 27, control_y + 10 ,colors.red)
  117. end
  118. term.setCursorPos(control_x + 3, control_y + 12)
  119. term.setBackgroundColor(colors.white)
  120. term.setTextColor(colors.red)
  121. write("return to Main Page")
  122. term.setTextColor(colors.black)
  123. elseif config_page == 2 then --users settings
  124. write("configuring users")
  125. term.setBackgroundColor(colors.yellow)
  126. term.setCursorPos(control_x + 20, control_y + 2)
  127. write(" New user ")
  128.  
  129. term.setBackgroundColor(colors.white)
  130. term.setCursorPos(control_x + 3, control_y + 4)
  131. write("the current user")
  132. term.setCursorPos(control_x + 3, control_y + 5)
  133. term.setTextColor(colors.lightGray)
  134. write(login[default])
  135. term.setTextColor(colors.black)
  136. i = 1
  137. term.setCursorPos(control_x + 3, control_y + 6)
  138. term.setTextColor(colors.red)
  139. write("All Users:")
  140. term.setTextColor(colors.green)
  141. while not ((login[i] == nil) or (i == 6)) do
  142. term.setCursorPos(control_x + 3, control_y + 6 + i)
  143. write(login[i])
  144. i = i + 1
  145. end
  146. term.setTextColor(colors.black)
  147.  
  148. term.setCursorPos(control_x + 3, control_y + 15)
  149. term.setBackgroundColor(colors.white)
  150. term.setTextColor(colors.red)
  151. write("return to Main Page")
  152. term.setTextColor(colors.black)
  153. else
  154. shell.run("system/config/settings-win.sys")
  155. end
  156. end
  157.  
  158. function config_button()
  159. if x == control_x + 30 and y == control_y and config and config_collapse == false then
  160. config_page = 0
  161. open_program = false
  162. start_window = false
  163. config = false
  164. config_write(invicible, rom_folder, system_folder, extensions)
  165. hub_array[config_number] = 0
  166. hub_move(config_number)
  167. hub_number = hub_number - 1
  168. config_number = 0
  169. desktop()
  170. elseif x == control_x + 28 and y == control_y and config and config_collapse == false then
  171. open_program = false
  172. start_window = false
  173. config_collapse = true
  174. desktop()
  175. elseif y == 19 and config and config_collapse then
  176. open_program = true
  177. local test = 1
  178. while test < 10 do
  179. if ((4 * test + 3) < x and (4 * test + 8) > x and hub_array[test] == 4) then
  180. config_print()
  181. config_collapse = false
  182. test = 9
  183. end
  184. test = test + 1
  185. end
  186. elseif y == 19 and config and config_collapse == false then
  187. open_program = false
  188. local test = 1
  189. while test < 10 do
  190. if ((4 * test + 3) < x and (4 * test + 8) > x and hub_array[test] == 4) then
  191. open_program = false
  192. start_window = false
  193. config_collapse = true
  194. desktop()
  195. test = 9
  196. end
  197. test = test + 1
  198. end
  199. elseif config_page == 0 and (x > control_x + 2) and (x < control_x + 15) and (y == control_y + 4) and config and config_collapse == false then
  200. config_page = 1
  201. config_print()
  202. elseif config_page == 0 and (x > control_x + 2) and (x < control_x + 15) and (y == control_y + 6) and config and config_collapse == false then
  203. config_page = 2
  204. loading_user()
  205. config_print()
  206. elseif config_page == 0 and (x > control_x + 2) and (x < control_x + 21) and (y == control_y + 8) and config and config_collapse == false then
  207. config_page = 3
  208. config_print()
  209. elseif config_page == 2 and (x > control_x + 2) and (x < control_x + 20) and (y < control_y + 15) and config and config_collapse == false then
  210. number_edit = y - (control_y + 6)
  211. if not (login[number_edit] == nil) then
  212. config_page = 4
  213. config_print()
  214. end
  215. elseif config_page == 1 and (x > control_x + 2) and (x < control_x + 22) and y == control_y + 12 and config and config_collapse == false then
  216. config_page = 0
  217. config_print()
  218. config_write(invicible, rom_folder, system_folder, extensions)
  219. elseif config_page == 1 and (x == control_x + 26 or x == control_x + 27) and y == control_y + 4 and config and config_collapse == false then
  220. invicible = not invicible
  221. if invicible == false then
  222. paintutils.drawPixel(control_x + 26, control_y + 4 ,colors.green)
  223. paintutils.drawPixel(control_x + 27, control_y + 4 ,colors.gray)
  224. else
  225. paintutils.drawPixel(control_x + 26, control_y + 4 ,colors.gray)
  226. paintutils.drawPixel(control_x + 27, control_y + 4 ,colors.red)
  227. end
  228. elseif config_page == 1 and (x == control_x + 26 or x == control_x + 27) and y == control_y + 6 and config and config_collapse == false then
  229. rom_folder = not rom_folder
  230. if rom_folder == false then
  231. paintutils.drawPixel(control_x + 26, control_y + 6 ,colors.green)
  232. paintutils.drawPixel(control_x + 27, control_y + 6 ,colors.gray)
  233. else
  234. paintutils.drawPixel(control_x + 26, control_y + 6 ,colors.gray)
  235. paintutils.drawPixel(control_x + 27, control_y + 6 ,colors.red)
  236. end
  237. elseif config_page == 1 and (x == control_x + 26 or x == control_x + 27) and y == control_y + 8 and config and config_collapse == false then
  238. system_folder = not system_folder
  239. if system_folder == false then
  240. paintutils.drawPixel(control_x + 26, control_y + 8 ,colors.green)
  241. paintutils.drawPixel(control_x + 27, control_y + 8 ,colors.gray)
  242. else
  243. paintutils.drawPixel(control_x + 26, control_y + 8 ,colors.gray)
  244. paintutils.drawPixel(control_x + 27, control_y + 8 ,colors.red)
  245. end
  246. elseif config_page == 1 and (x == control_x + 26 or x == control_x + 27) and y == control_y + 10 and config and config_collapse == false then
  247. extensions = not extensions
  248. if extensions == false then
  249. paintutils.drawPixel(control_x + 26, control_y + 10 ,colors.green)
  250. paintutils.drawPixel(control_x + 27, control_y + 10 ,colors.gray)
  251. else
  252. paintutils.drawPixel(control_x + 26, control_y + 10 ,colors.gray)
  253. paintutils.drawPixel(control_x + 27, control_y + 10 ,colors.red)
  254. end
  255. elseif (config_page == 2 or config_page == 3) and (x > control_x + 2) and (x < control_x + 22) and y == control_y + 15 and config and config_collapse == false then
  256. config_page = 0
  257. config_print()
  258. elseif config_page == 2 and (x > control_x + 19) and (x < control_x + 30) and y == control_y + 2 and config and config_collapse == false then
  259. img = paintutils.loadImage("/system/images/info_window.png")
  260. paintutils.drawImage(img, 11, 4)
  261. term.setCursorPos(13, 4)
  262. term.setBackgroundColor(colors.blue)
  263. term.setTextColor(colors.white)
  264. write("Create new User")
  265. term.setBackgroundColor(colors.white)
  266. term.setTextColor(colors.black)
  267.  
  268. if permission[default] == "admin" then
  269. term.setCursorPos(12, 6)
  270. write("Enter the Name")
  271. term.setCursorPos(12, 7)
  272. name_user = read()
  273. term.setCursorPos(12, 6)
  274. write("Enter the Password (if need)")
  275. term.setCursorPos(12, 7)
  276. write(" ")
  277. term.setCursorPos(12, 7)
  278. pass = read()
  279. if (pass == "") then
  280. term.setCursorPos(12, 6)
  281. write("Select permission ")
  282. term.setCursorPos(12, 7)
  283. write(" ")
  284. term.setCursorPos(12, 8)
  285. term.setBackgroundColor(colors.red)
  286. write("Admin")
  287. term.setCursorPos(22, 8)
  288. term.setBackgroundColor(colors.yellow)
  289. write("User")
  290. term.setCursorPos(31, 8)
  291. term.setBackgroundColor(colors.green)
  292. write("Guest")
  293. term.setCursorPos(23, 10)
  294. term.setBackgroundColor(colors.blue)
  295. write(" Done ")
  296. config_page = 5
  297. term.setBackgroundColor(colors.white)
  298. else
  299. term.setCursorPos(12, 6)
  300. write("Confirm the Password ")
  301. term.setCursorPos(12, 7)
  302. write(" ")
  303. term.setCursorPos(12, 7)
  304. if not (read() == pass) then
  305. term.setCursorPos(12, 8)
  306. write("Password is not confirmed")
  307. term.setCursorPos(12, 9)
  308. write("User is not created")
  309. sleep(1)
  310. loading_user()
  311. config_print()
  312. else
  313. term.setCursorPos(12, 6)
  314. write("Select permission ")
  315. term.setCursorPos(12, 7)
  316. write(" ")
  317. term.setCursorPos(12, 8)
  318. term.setBackgroundColor(colors.red)
  319. write("Admin")
  320. term.setCursorPos(22, 8)
  321. term.setBackgroundColor(colors.yellow)
  322. write("User")
  323. term.setCursorPos(31, 8)
  324. term.setBackgroundColor(colors.green)
  325. write("Guest")
  326. term.setCursorPos(23, 10)
  327. term.setBackgroundColor(colors.blue)
  328. write(" Done ")
  329. config_page = 5
  330. term.setBackgroundColor(colors.white)
  331. end
  332. end
  333. else
  334. no_perm()
  335. sleep(2)
  336. config_print()
  337. end
  338. elseif (config_page == 5 or config_page == 6) and x > 11 and x < 17 and y == 8 and config and config_collapse == false then
  339. term.setBackgroundColor(colors.white)
  340. term.setTextColor(colors.black)
  341. term.setCursorPos(12, 10)
  342. write("Admin")
  343. perm = "admin"
  344. elseif (config_page == 5 or config_page == 6) and x > 21 and x < 26 and y == 8 and config and config_collapse == false then
  345. term.setBackgroundColor(colors.white)
  346. term.setTextColor(colors.black)
  347. term.setCursorPos(12, 10)
  348. write("User ")
  349. perm = "user"
  350. elseif (config_page == 5 or config_page == 6) and x > 30 and x < 36 and y == 8 and config and config_collapse == false then
  351. term.setBackgroundColor(colors.white)
  352. term.setTextColor(colors.black)
  353. term.setCursorPos(12, 10)
  354. write("Guest")
  355. perm = "guest"
  356. elseif config_page == 5 and x > 22 and x < 29 and y == 10 and config and config_collapse == false then
  357. config_page = 2
  358. add_user()
  359. loading_user()
  360. config_print()
  361. elseif config_page == 4 and x > control_x + 1 and x < control_x + 15 and y == control_y + 5 and config and config_collapse == false then
  362. if permission[default] == "admin" then
  363. term.setCursorPos(control_x + 2, control_y + 13)
  364. term.setTextColor(colors.black)
  365. edit_password()
  366. config_print()
  367. else
  368. no_perm()
  369. sleep(2)
  370. config_print()
  371. end
  372. elseif config_page == 4 and x > control_x + 1 and x < control_x + 15 and y == control_y + 7 and config and config_collapse == false then
  373. if permission[default] == "admin" then
  374. term.setCursorPos(control_x + 2, control_y + 13)
  375. change_type()
  376. else
  377. no_perm()
  378. sleep(2)
  379. config_print()
  380. end
  381. elseif config_page == 4 and x > control_x + 1 and x < control_x + 15 and y == control_y + 9 and config and config_collapse == false then
  382. if permission[default] == "admin" then
  383. if not (permission[number_edit] == "admin") then
  384. user_count = user_count - 1
  385. login[number_edit] = nil
  386. reWrite_userList()
  387. config_page = 2
  388. loading_user()
  389. config_print()
  390. else
  391. create_window(11, 5, "Error", "Can't remove", "admin account", "", "", "error", nil)
  392. sleep(2)
  393. config_print()
  394. end
  395. else
  396. no_perm()
  397. sleep(2)
  398. config_print()
  399. end
  400. elseif config_page == 4 and (x > control_x + 2) and (x < control_x + 22) and y == control_y + 15 and config and config_collapse == false then
  401. config_page = 2
  402. config_print()
  403. elseif config_page == 6 and x > 22 and x < 29 and y == 10 and config and config_collapse == false then
  404. config_page = 4
  405. permission[number_edit] = perm
  406. write_users()
  407. config_print()
  408. end
  409. end
  410.  
  411.  
  412. function add_user()
  413. local s = fs.open("system/config/users.config", "a")
  414. s.writeLine("{")
  415. s.writeLine(name_user)
  416. s.writeLine(pass)
  417. s.writeLine(name_user)
  418. s.writeLine(perm)
  419. s.writeLine("}")
  420. s.close()
  421. loading_user()
  422. config_print()
  423. user_count = user_count + 1
  424. end
  425.  
  426. function config_write(inv, rom, system, type)
  427. local s = fs.open(fs.combine("users", fs.combine(user_path[default], "settings.config")), "w")
  428. s.writeLine("--file: (s1y2s3t4e5m6)")
  429. s.writeLine("--type: (settings)")
  430. if inv then
  431. s.writeLine("inv: true")
  432. else
  433. s.writeLine("inv: false")
  434. end
  435. if rom then
  436. s.writeLine("rom: true")
  437. else
  438. s.writeLine("rom: false")
  439. end
  440. if system then
  441. s.writeLine("system: true")
  442. else
  443. s.writeLine("system: false")
  444. end
  445. if type then
  446. s.writeLine("type: true")
  447. else
  448. s.writeLine("type: false")
  449. end
  450. i = 1
  451. while not (icons_array[i] == nil) do
  452. s.writeLine(icons_array[i])
  453. i = i + 1
  454. end
  455. s.close()
  456. config_print()
  457. end
  458.  
  459. function loading_user()
  460. local i = 1
  461. local a = 0
  462. local str = ""
  463. s = fs.open("system/config/users.config", "r")
  464. s.readLine()
  465. while cycle do
  466. if s.readLine() == "{" then
  467. a = a + 1
  468. for i = 1, 5 do
  469. str = s.readLine()
  470. if i == 1 then
  471. login[a] = str
  472. elseif i == 2 then
  473. password[a] = str
  474. elseif i == 3 then
  475. user_path[a] = str
  476. elseif i == 4 then
  477. permission[a] = str
  478. end
  479.  
  480. end
  481. else
  482. cycle = false
  483. end
  484. end
  485. cycle = true
  486. end
Add Comment
Please, Sign In to add comment