Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
jalbarracinv authored Dec 27, 2021
1 parent 8ab3ba8 commit d4535be
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 15 deletions.
27 changes: 14 additions & 13 deletions bbs.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def do_welcome(connection):
#SEND HEADER FILE (.SEQ)
# print ("STATUS > will send seq")
send_ln(connection, "\n\n") #sends text
send_seq(connection, "welcome.seq") #sends a seq file to screen
send_seq(connection, "seq/welcome.seq") #sends a seq file to screen

#THIS SECTION SENDS RANDOM THINGS (FOR YOU TO LEARN HOW)
send_cr(connection, "red") #cbmcursor sends color red code
Expand All @@ -57,6 +57,14 @@ def do_welcome(connection):
send_ln(connection, "up1")
cursorxy(connection,1,25)
send_ln(connection, "down25")
cursorxy(connection,10,20)
get_char(connection)

send_cr(connection, "clear") #sends a coded cursor
send_cr(connection, "home") #sends a coded cursor
send_seq(connection, "seq/colaburger.seq")
cursorxy(connection,30,5)
get_char(connection)

def do_login(connection):

Expand All @@ -74,7 +82,7 @@ def do_login(connection):

if (uname=="new"):
uname,realid = do_newuser(connection)
print("new user created")
print("NEW user created")
break

connection.send(cbmencode("Password: "))
Expand All @@ -97,16 +105,14 @@ def do_login(connection):

# Check if there is a match
if(realpass==upass):
print("match!!")
break
else:
send_ln(connection, "\n\nIncorrect username or password.\n\n")
attempts=attempts+1
if (attempts>=maxtries):
connection.send(cbmencode("\n\nSorry maximum number of attempts reached..\n\n"))
connection.close()
print("ok")
print("uname->",uname,"realid->",realid)
print("JUST LOGGED IN -> uname->",uname,"realid->",realid)
return uname,realid;

def do_newuser(connection):
Expand Down Expand Up @@ -136,11 +142,9 @@ def do_newuser(connection):
if(myresult == None and uname!="" and uname !="new"):
send_ln(connection, "Your username is: "+uname+"\nAre you sure? (y/n): ")
letter=get_char(connection)
print("letra: ",letter)
send_ln(connection, "\n\n")
attempts=attempts+1
if(letter=="y" or letter=="Y"):
print("YES!")
break
else:
send_ln(connection, "\nError: User already exists.\n")
Expand All @@ -159,7 +163,6 @@ def do_newuser(connection):
send_ln(connection, "\nRepeat your password: ")
pass2=input_pass(connection) #input_line function reads a line
if(pass1!="" and pass2==pass1):
print("->"+pass1+"<-")
break
attempts=attempts+1
if attempts >= maxtries:
Expand All @@ -176,7 +179,6 @@ def do_newuser(connection):
send_ln(connection, "\nRepeat your email: ")
mail2=input_line(connection) #input_line function reads a line
if(mail1!="" and mail2==mail1):
print("email matches!")
break
attempts=attempts+1
if attempts >= maxtries:
Expand All @@ -191,14 +193,14 @@ def do_newuser(connection):
mycursor.execute(query)
mydb.commit() #imperative
realid=mycursor.lastrowid
print("new id:",realid)
print("NEW User just registered with id:",realid)
return uname,realid;

def do_bucle(connection,namex,idx):

while True:
#Clears Screen and sends MENU
print("USER -> ",namex,"->",idx)
print("USER -> ",namex,"->",idx,"Main Menu") #Outputs for sysop
send_ln(connection, "\n\nChoose an option: ")
bucl=get_char(connection)
print(bucl)
Expand All @@ -215,10 +217,9 @@ def user_session(connection):
send_cr(connection,"clear")
send_cr(connection,"home")
send_ln(connection, "Connected. Hit any key...")
bucl=get_char(connection)
bucl=input_line(connection)

do_welcome(connection)
time.sleep(6)

userx,idx = do_login(connection)

Expand Down
13 changes: 11 additions & 2 deletions funct.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,15 @@ def input_line(connection):
print("no data - closed connection")
connection.close()
break
if (data==b'\xff' or data==b'\xfb' or data==b'\x00' or data==b'\x01' or data==b'\xfd'):
if (data==b'\xff' or data==b'\xe6' or data==b'\xfe' or data==b'\xfb' or data==b'\x00' or data==b'\x01' or data==b'\xfd'):
data=b''
if (data==b'\xff\xfb\x01'):
data=b''
if (data==b'\xff\xfb\x00'):
data=b''
if (data==b'\xff\xfb\x00\xff\xfd\x00'):
data=b''
if (data==b'\xff\xfb\x00\xff\xfb\x00'):
data=b''
if (data==b'\xff\xfb\x01\xff\xfb\x00\xff\xfd\x00'):
data=b''
Expand Down Expand Up @@ -197,7 +205,8 @@ def get_char(connection):

#this is to send the SEQ file to the user (useful for petscii graphics portions)
def send_seq(connection, filen):
print (filen)
print("inicio send_seq")
print("FN->",filen)
with open(filen, "rb") as f:
nb=b''
byte = f.read(1)
Expand Down

0 comments on commit d4535be

Please sign in to comment.