/[shmookey]/portconf/index.py


UCC Code Repository

Diff of /portconf/index.py

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

revision 119 by shmookey, Wed Jun 4 14:15:39 2008 UTC revision 120 by shmookey, Thu Jun 5 07:30:56 2008 UTC
# Line 33  def GetDefaultCursor (): Line 33  def GetDefaultCursor ():
33          return defaultCursor          return defaultCursor
34    
35  # Cookie stuff  # Cookie stuff
36  cookieExpiry = time.gmtime(time.time())  sessionID = None
37  if cookieExpiry[3] == 23: cookieExpiry = cookieExpiry[:2] + (0,) + cookieExpiry[4:]  def ProcessCookie ():
38  cookie = Cookie.SimpleCookie (os.environ.get("HTTP_COOKIE", ""))          global sessionID
39  if cookie.has_key ("sid"):          cookie = Cookie.SimpleCookie (os.environ.get("HTTP_COOKIE", ""))
40          sessionID = cookie["sid"].value          if cookie.has_key ("sid"):
41          try:                  sessionID = cookie["sid"].value
42                  GetDefaultCursor ()                  try:
43          except pyaaa.InvalidSession:                          GetDefaultCursor ()
44                  # TODO: Remember when this happens to catch people trying to brute-force session IDs.                  except pyaaa.InvalidSession:
45                  Log.Message ("Invalid session ID: " + sessionID + ". Redirecting to login.", "index.py", "ERROR")                          # TODO: Remember when this happens to catch people trying to brute-force session IDs.
46                            Log.Message ("Invalid session ID: " + sessionID + ". Redirecting to login.", "index.py", "ERROR")
47                            print "Location: login.py"
48            else:
49                    # Not logged in, fail.
50                    Log.Message ("User not logged in. Redirecting to login.", "index.py", "ERROR")
51                  print "Location: login.py"                  print "Location: login.py"
 else:  
         # Not logged in, fail.  
         Log.Message ("User not logged in. Redirecting to login.", "index.py", "ERROR")  
         print "Location: login.py"  
52    
53    
54  def GetSwitchList ():  def GetSwitchList ():
# Line 209  def GetSidebar (): Line 210  def GetSidebar ():
210          <dt><a href="./">Navigation</a></dt>          <dt><a href="./">Navigation</a></dt>
211          <dd><ul>          <dd><ul>
212          <li><a href="./">Main Menu</a></li>          <li><a href="./">Main Menu</a></li>
213            """
214            if defaultCursor._admin == True: pageText += "<li><a href='./configure.py'>Configuration</a></li>"
215            pageText += """
216          <li><a href="logout.py">Log Out</a></li>          <li><a href="logout.py">Log Out</a></li>
217          </ul></dd>          </ul></dd>
218          <dt><a href="./">Switches</a></dt>          <dt><a href="./">Switches</a></dt>
# Line 222  def GetSidebar (): Line 226  def GetSidebar ():
226  switchList = []  switchList = []
227  pageBuffer = ""  pageBuffer = ""
228  pageBuffer += "Content-Type: text/html\n\n"  pageBuffer += "Content-Type: text/html\n\n"
229  pageBuffer += common.GetHeader ("Port Administration Configuration Tool", GetSidebar ())  try:
230  pageBuffer += GetBody ()          ProcessCookie ()
231            pageBuffer += common.GetHeader ("Port Administration Configuration Tool", GetSidebar ())
232            pageBuffer += GetBody ()
233    except pyaaa.DatabaseError:
234            pageBuffer += common.GetHeader ("Error - Port Administration Configuration Tool", common.GetErrorSidebar ())
235            pageBuffer += "There was a problem with the database. Please contact your system administrator."
236    except pyaaa.SessionExpired:
237            print "Location: login.py"
238            print
239  pageBuffer += common.GetFooter ()  pageBuffer += common.GetFooter ()
240    
241  print pageBuffer  print pageBuffer

Legend:
Removed from v.119  
changed lines
  Added in v.120

Managed by UCC Webmasters ViewVC Help
Powered by ViewVC 1.1.26