/[shmookey]/portconf/index.py


UCC Code Repository

Diff of /portconf/index.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 115 by shmookey, Thu May 29 08:33:56 2008 UTC revision 117 by shmookey, Tue Jun 3 07:49:09 2008 UTC
# Line 24  cgitb.enable () Line 24  cgitb.enable ()
24    
25  form = cgi.FieldStorage ()  form = cgi.FieldStorage ()
26    
27    defaultCursor = None
28    def GetDefaultCursor ():
29            global defaultCursor
30            if defaultCursor == None:
31                    defaultCursor = pyaaa.SafeBase ()
32                    defaultCursor._Resume (sessionID)
33            return defaultCursor
34    
35  # Cookie stuff  # Cookie stuff
36  cookieExpiry = time.gmtime(time.time())  cookieExpiry = time.gmtime(time.time())
37  if cookieExpiry[3] == 23: cookieExpiry = cookieExpiry[:2] + (0,) + cookieExpiry[4:]  if cookieExpiry[3] == 23: cookieExpiry = cookieExpiry[:2] + (0,) + cookieExpiry[4:]
 else: cookieExpiry = cookieExpiry[:2] + (cookieExpiry[3]+1,) + cookieExpiry[4:]  
38  cookie = Cookie.SimpleCookie (os.environ.get("HTTP_COOKIE", ""))  cookie = Cookie.SimpleCookie (os.environ.get("HTTP_COOKIE", ""))
39  if cookie.has_key ("sid"):  if cookie.has_key ("sid"):
40          session = cookie["sid"]          sessionID = cookie["sid"].value
41            try:
42                    GetDefaultCursor ()
43            except pyaaa.InvalidSession:
44                    # TODO: Remember when this happens to catch people trying to brute-force session IDs.
45                    Log.Message ("Invalid session ID: " + sessionID + ". Redirecting to login.", "index.py", "ERROR")
46                    print "Location: login.py"
47  else:  else:
48          # Not logged in, fail.          # Not logged in, fail.
49            Log.Message ("User not logged in. Redirecting to login.", "index.py", "ERROR")
50          print "Location: login.py"          print "Location: login.py"
51    
52    
 defaultCursor = None  
 def GetDefaultCursor ():  
         global defaultCursor  
         if defaultCursor == None:  
                 defaultCursor = pyaaa.SafeBase ()  
                 defaultCursor._username = "me"  
         return defaultCursor  
   
53  def GetSwitchList ():  def GetSwitchList ():
54          global switchList          global switchList
55          if switchList == []:          if switchList == []:
# Line 203  def GetSidebar (): Line 209  def GetSidebar ():
209          <dt><a href="./">Navigation</a></dt>          <dt><a href="./">Navigation</a></dt>
210          <dd><ul>          <dd><ul>
211          <li><a href="./">Main Menu</a></li>          <li><a href="./">Main Menu</a></li>
212            <li><a href="logout.py">Log Out</a></li>
213          </ul></dd>          </ul></dd>
214          <dt><a href="./">Switches</a></dt>          <dt><a href="./">Switches</a></dt>
215          <dd><ul>          <dd><ul>

Legend:
Removed from v.115  
changed lines
  Added in v.117

Managed by UCC Webmasters ViewVC Help
Powered by ViewVC 1.1.26