| 43 |
int count = 0; |
int count = 0; |
| 44 |
int ok = 0; |
int ok = 0; |
| 45 |
|
|
| 46 |
// Input username |
for (; !ok && count < 3; count++) |
|
while (!ok) |
|
| 47 |
{ |
{ |
| 48 |
prints("\033[1;33mΗλΚδΘλΥΚΊΕ\033[m(ΚΤΣΓΗλΚδΘλ `\033[1;36mguest\033[m', " |
prints("\033[1;33mΗλΚδΘλΥΚΊΕ\033[m(ΚΤΣΓΗλΚδΘλ`\033[1;36mguest\033[m', " |
| 49 |
"ΧΆ²αΗλΚδΘλ`\033[1;31mnew\033[m'): "); |
"ΧΆ²αΗλΚδΘλ`\033[1;31mnew\033[m'): "); |
| 50 |
iflush(); |
iflush(); |
| 51 |
|
|
| 52 |
str_input(username, sizeof(username), DOECHO); |
if (str_input(username, sizeof(username), DOECHO) < 0) |
| 53 |
count++; |
{ |
| 54 |
|
continue; |
| 55 |
|
} |
| 56 |
|
|
| 57 |
if (strcmp(username, "guest") == 0) |
if (strcmp(username, "guest") == 0) |
| 58 |
{ |
{ |
| 83 |
|
|
| 84 |
if (username[0] != '\0') |
if (username[0] != '\0') |
| 85 |
{ |
{ |
|
// Input password |
|
| 86 |
prints("\033[1;37mΗλΚδΘλΓάΒλ\033[m: "); |
prints("\033[1;37mΗλΚδΘλΓάΒλ\033[m: "); |
| 87 |
iflush(); |
iflush(); |
| 88 |
|
|
| 89 |
str_input(password, sizeof(password), NOECHO); |
if (str_input(password, sizeof(password), NOECHO) < 0) |
| 90 |
|
{ |
| 91 |
|
continue; |
| 92 |
|
} |
| 93 |
|
|
| 94 |
MYSQL *db = db_open(); |
MYSQL *db = db_open(); |
| 95 |
if (db == NULL) |
if (db == NULL) |
| 101 |
|
|
| 102 |
mysql_close(db); |
mysql_close(db); |
| 103 |
} |
} |
| 104 |
if (count >= 3 && !ok) |
} |
| 105 |
{ |
|
| 106 |
login_fail(); |
if (!ok) |
| 107 |
return -1; |
{ |
| 108 |
} |
login_fail(); |
| 109 |
|
return -1; |
| 110 |
} |
} |
| 111 |
|
|
| 112 |
return 0; |
return 0; |