require("luamods/layout")
require("luamods/cgi")
require("luamods/db")

headerpath = ""
--****** Logout if Yes button is pressed ******--
if cgi.post.lgtbutton == "Yes" then
        db.terminateSession(cgi.cookie.sessionID)
	headerpath = "Set-Cookie: userID=deleted;Expires=Thu, 01-Jan-1970 00:00:01 GMT;\n"
	headerpath = headerpath.."Set-Cookie: sessionID=0;Expires=Thu, 01-Jan-1970 00:00:01 GMT;\n"
	headerpath = headerpath.."Location: index.lua\n\n"
	print(headerpath)
        exit(0)
end

header = layout.getHeader()
footer = layout.getFooter()
html = header..[[

                    <div id="info">
                        <div style="background:url(images/power.png); background-repeat:no-repeat; background-position: 20px center;">
                            <center><h1>Logout</h1></center>
                        </div>
                    </div>

                    <div class="formLayoutfull">
                        <center>
                            <h3>Are you sure you want to logout?</h3><br>                        
                            <form action="logout.lua" method="post">
                                <input type="submit" name="lgtbutton" value="Yes"/>
                                <input type="button" name="noButton" value="No" onclick="window.history.back();"/>
                            </form>
                        </center>
                    </div>

]]..footer
print( html )
