pagecounter.ctf

#!/bin/bash /ss/bin/ss.exe
<html>
    <head>
        <title>Page Counter</title>
    </head>
    <body>
        <h1>Page Counter</h1>

        This page was accessed <%=call(path() + separator() +"page_counter.cef")%> times.

        <p>
        [ <a href="./pagecounter.ctf">refresh</a> ]
    </body>
</html>



==================================================
page_counter.cef

url = Request().env("PATH_TRANSLATED")
if isNull(url) then
    url = Request().env("SCRIPT_FILENAME")
end

url = encode(url)

props = Properties()

fh = File(getProperty("user.dir", ".") + separator() + "page_counters")
if fh.exists() then
    is = FileInputStream(fh)
    props.load(is)
    is.close()

    page_counter = Integer(props.getProperty(url, "0")) + 1
else
    page_counter = 1
end

props.put(url, String(page_counter))

os = FileOutputStream(fh)
props.save(os, "page counters")
os.close()

return page_counter




