<html>
<head>
<title>pagecounter Source</title>
</head>
<body>
<plaintext>
pagecounter.ctf

#!/bin/sh /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.
    </body>
</html>


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

url = Request().ServerVariables("SCRIPT_NAME")
if url = null then
    url = Request().ServerVariables("PATH_TRANSLATED")
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

