(user 2)

(IF (AND

	(= ((getsum "Net&Web:NetScript")) 978476573)
	(= ((getsum "Net&Web:Net&Web")) -988301860)
	(= ((getsum "Net&Web:Scripts/defaultNet&WebEnvs")) 778300685)
	(= ((getsum "Net&Web:Scripts/SetupPPP")) -1626810815)

	)

	(
		(Message "Latest version installed")
	)
)

(IF (= (EXISTS "Net&Web:Backup") 2)
	(

	(set restorecfg
	(askbool 
	(prompt "Do you want to restore the old files or continue the update?")
	(choices "Restore" "Update")
	(help @askbool-help)
	)
	)

	(if (= restorecfg 1)

	(
		(set n 0)
		(while (set filetocopy (select n  "Scripts/Net&WebEnvs" "Scripts/defaultNet&WebEnvs" "Scripts/LoginPATCHFILE" "Scripts/PATCHFILE" "Scripts/SetupPPP" " NetScript" " Net&Web" ""))
		(

		(set y 0)

		(set testchar "x")

		(If (= (substr filetocopy 0 1) " ")
			(
			(set filename (substr filetocopy 1))
			(set filetocopy (substr filetocopy 1))
			(set path "")
			(set testchar "/")
			)
		)

		(while (<> testchar "/")
			(
			(set testchar (substr filetocopy (- (strlen filetocopy) y) 1))
			(set filename (substr filetocopy (- (strlen filetocopy) (- y 1))))
			(set path (substr filetocopy 0 (- (strlen filetocopy) (- y 1))))
			(set y (+ y 1))
			)
		)

		(IF (= (exists ("Net&Web:%s" filetocopy)) 1)

			(copyfiles
			(source ("Net&Web:backup/%s" filename))
			(dest ("Net&Web:%s" path))
			(optional "force" "nofail")
			)

		)

		(set n (+ n 1))

		)
		)
		(Message "Previous files restored\n\nProceed to quit.")
		(exit (quiet))


	)

	)	

	)

)	
(IF (<> ((getsum "Net&Web:NetScript")) 810540554)
(	(Message "Incorrect version for this patch.\nEmail HiSoft for update information")
	(exit (quiet))
)
)

(IF (<> ((getsum "Net&Web:Scripts/defaultNet&WebEnvs")) 832406873)
(	(Message "Incorrect version for this patch.\nEmail HiSoft for update information")
	(exit (quiet))
)
)

(IF (<> ((getsum "Net&Web:Scripts/SetupPPP")) -79825476)
(	(Message "Incorrect version for this patch.\nEmail HiSoft for update information")
	(exit (quiet))
)
)

(IF (<> ((getsum "Net&Web:Net&Web")) -669739372)
(	(Message "Incorrect version for this patch.\nEmail HiSoft for update information")
	(exit (quiet))
)
)

(IF (<> (EXISTS "Net&Web:Scripts/LoginPATCHFILE") 1)
(	(Message "You have the correct version installed but some necessary files are missing. Re-install the main program and then run the update.")
	(exit (quiet))
)
)

(IF (<> (EXISTS "Net&Web:Scripts/PATCHFILE") 1)
(	(Message "You have the correct version installed but some necessary files are missing. Re-install the main program and then run the update.")
	(exit (quiet))
)
)

(IF (<> (EXISTS "Net&Web:Backup") 2)
	(makedir "Net&Web:Backup" (infos))
)

(set n 0)
(while (set filetocopy (select n "Scripts/defaultNet&WebEnvs" "Scripts/Net&WebEnvs" "Scripts/LoginPATCHFILE" "Scripts/PATCHFILE" "Scripts/SetupPPP" "NetScript" "Net&Web" ""))
	(

	(IF (= (exists ("Net&Web:%s" filetocopy)) 1)
		(copyfiles
		(source ("Net&Web:%s" filetocopy))
		(dest "Net&Web:Backup")
		)
	)
	(set n (+ n 1))

	)
)

(set n 0)
(while (set filetodelete (select n "Scripts/defaultNet&WebEnvs" "Scripts/Net&WebEnvs" "Scripts/SetupPPP" "NetScript" "Net&Web" ""))
	(
	(IF (= (exists ("Net&Web:%s" filetodelete)) 1)
		(delete ("Net&Web:%s" filetodelete))
	)
	(set n (+ n 1))
	)
)

(run "spatch -oNet&Web:Scripts/defaultNet&WebEnvs -ppatchdefenvs.pch Net&Web:Backup/defaultNet&WebEnvs")
(run "spatch -oNet&Web:Scripts/SetupPPP -ppatchsetupppp.pch Net&Web:Backup/setupppp")
(run "spatch -oNet&Web:NetScript -ppatchnetscript.pch Net&Web:Backup/NetScript")
(run "spatch -oNet&Web:Net&Web -ppatchnet&web.pch Net&Web:Backup/Net&Web")

(Message "Update Completed.\n\nSelect Proceed to exit.")
(exit (quiet))
