Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Dec 17th, 2005, 3:15 PM   #21
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Location: Waterloo, Ontario
Posts: 1,835
Rep Power: 5 Sane will become famous soon enough
Send a message via MSN to Sane
Okay, I'll explain the system I have working.

loginrequest is a simple function that takes two POST arguments from the two html forms. If the username is found in the users folder then it encrypts the password in md5 and matches it to that of the encrypted password in their data file from the users bin.

If they match, it creates a data file named their IP address, containing their userID (for me, 1) and a unique sessionID up to 25 random letters.

A cookie is then stored on the user's computer containing the exact same sessionID.

Then when you try to access modifyscores it opens up the data file named your IP address. If there is no data file named your IP it knows you haven't logged in. If there is, it sorts through all your cookies until it finds one with a matching session ID. Once that is found, it displays the data corresponding to the userID in the data file.

=D

And I think I'm going to stick with how I have it working right now. I like it how Python generates the html, because then I can combine elements from pages easily. What do <head> <body> and <html> tags do?
Sane is offline   Reply With Quote
Old Dec 17th, 2005, 3:42 PM   #22
Jessehk
The Oblivious One
 
Jessehk's Avatar
 
Join Date: May 2005
Location: Ontario, Canada
Posts: 641
Rep Power: 4 Jessehk is on a distinguished road
Quote:
Originally Posted by Sane
=D

And I think I'm going to stick with how I have it working right now. I like it how Python generates the html, because then I can combine elements from pages easily. What do <head> <body> and <html> tags do?
There are html and xhtml tutorials all over the place.
__________________
Dr. Zoidberg: [ecstatic] I'm going to a movie... with FRIENDS!
Jessehk is offline   Reply With Quote
Old Dec 17th, 2005, 4:02 PM   #23
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Quote:
What do <head> <body> and <html> tags do?
You MUST find at least a cursory explanation of HTML. Hell, even 2.0 will do.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Dec 17th, 2005, 4:24 PM   #24
Arevos
Programming Guru
 
Arevos's Avatar
 
Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5 Arevos is on a distinguished road
Quote:
Originally Posted by Sane
Then when you try to access modifyscores it opens up the data file named your IP address. If there is no data file named your IP it knows you haven't logged in. If there is, it sorts through all your cookies until it finds one with a matching session ID. Once that is found, it displays the data corresponding to the userID in the data file.
That's probably the best method to do it; sites such as livejournal give the user the option of binding sessions to IP addresses.

But I think you might have made it a little complicated for yourself. I think you could you take advantage of CherryPy's sessions, like so:
if cherrypy.session.has_key("ipaddress"):
   if cherrypy.request.remoteAddr != cherrypy.session["ipaddress"]:
      return "Warning! IP Address doesn't match!"
else:
   cherrypy.session["ipaddress"] = cherrypy.request.remoteAddr

# output page normally

Quote:
Originally Posted by Sane
What do <head> <body> and <html> tags do?
The makeup of a HTML file is:
<html>
 <head>
  ...
 </head>
 <body>
  ...
 </body>
</html>
The head contains all the parts of a HTML document that aren't directly displayed, such as the title, metatags, stylesheets and other such information. The body contains all the parts that are displayed.

So if we take your index page, it should look more like so:
<html>
<head>
 <TITLE>Jammers Base  v0.6  (O2Jam Scoring Site)</TITLE>
 <style type="text/css">
   h1 {
      border-width: 1;
      border: solid;
      text-align: center;
      border-right:2px solid #000;
      border-bottom:2px solid #000;
      margin-right:15px;
      padding-bottom:20px;
      }
   body {
      background-image: url(http://cold.byethost2.com/~Sane/bgimage.png);
   }
 </style>
</head>
<body>

<P ALIGN="RIGHT">
<form action="http://jammersbase.dyndns.org/loginrequest"
      method="POST">
Username: <input type="text" name="username">
Password: <input type="password" name="password">
<input type="submit" value="Login">
</form>
</P>
<BR>

<CENTER>
Welcome to Jammers Base!<BR>
The O2Jam Player's base for tracking O2Jam scores!<BR>
<BR>

<form action="http://jammersbase.dyndns.org/viewprofile"
      method="GET">
UserID: <input type="text" name="userID">
<input type="submit" value="View">
</form>

<BR>You are Visiter #62

</CENTER>

<BR><BR>
<HR>

<I>Programmed by <a href="/mail to:dr.sane@gmail.com">Saney</a>.<BR>
Powered by <a href="http://pycherry.org">PyCherry 2.1</a>.<BR>
Programmed in Python 2.4 for Dynamic HTML and CSS Display.<BR>
Hosted by DynamicNetworkServices.</I><BR>

<FONT COLOR='WHITE'><FONT SIZE='0'>

<br/><br/>Build time: 0.015s, Page size: 1.19KB

</body>
</html>
The HTML you have on your site at the moment is a bit random, to say the least :o
Arevos is offline   Reply With Quote
Old Dec 17th, 2005, 5:05 PM   #25
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Location: Waterloo, Ontario
Posts: 1,835
Rep Power: 5 Sane will become famous soon enough
Send a message via MSN to Sane
That's because the html is all dynamically generated and drawn step by step through different functions. And it's not as if I know HTML very well ^^.
Sane is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 2:47 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC