|
| 1 | + |
| 2 | +void show_Files(); |
| 3 | +struct account |
| 4 | +{ |
| 5 | +char name[20]; |
| 6 | +char password[20]; |
| 7 | +}; |
| 8 | +void Login_Interface_GUI(); |
| 9 | +void goto_dashboard(); |
| 10 | +void goto_login(); |
| 11 | +void login_functionality() |
| 12 | +{ |
| 13 | + |
| 14 | + struct account s; |
| 15 | + FILE *fp; |
| 16 | + char u[25], p[25]; |
| 17 | + printf("\033[0;31m"); |
| 18 | + int n=1,a= 0 ,b= 0; |
| 19 | + printf("\n\t\t\t\tENTER USERNAME & PASSWORD BELOW(YOU ONLY HAVE 3 CHANCE TO ENTER)"); |
| 20 | + printf("\033[0;36m"); |
| 21 | + |
| 22 | + int i=0; |
| 23 | + int c; |
| 24 | + |
| 25 | + fp = fopen("C:\\script\\name_pass.txt","r"); |
| 26 | + while(1) |
| 27 | + { |
| 28 | + |
| 29 | + fscanf(fp,"%s", &s.name); |
| 30 | + fscanf(fp,"%s", &s.password); |
| 31 | + |
| 32 | + if(fscanf(fp,"%s %s",&s.name,&s.password)==EOF) |
| 33 | + { |
| 34 | + break; |
| 35 | + } |
| 36 | + } |
| 37 | + |
| 38 | + |
| 39 | + |
| 40 | + while(n<=3) |
| 41 | + { |
| 42 | + |
| 43 | + |
| 44 | + printf("\n\n\t\t\t\t\tUSER ID: "); |
| 45 | + scanf("%s", &u); |
| 46 | + printf("\n\t\t\t\t\tPASSWORD: "); |
| 47 | + scanf("%s",&p); |
| 48 | + a=strcmp(u, s.name); |
| 49 | + b=strcmp(p, s.password); |
| 50 | + if(a==0 && b==0) |
| 51 | + { |
| 52 | + printf("\n\t\t\t\tYou have logged in successfully."); |
| 53 | + delay(5); |
| 54 | + goto_dashboard(); |
| 55 | + break; |
| 56 | + } |
| 57 | + else |
| 58 | + { |
| 59 | + printf("\n\t\t\t\tWrong PASSWORD and/or USERNAME. Now you have %d more chance/s.",3-n); |
| 60 | + } |
| 61 | + |
| 62 | + n++; |
| 63 | + } |
| 64 | + fclose(fp); |
| 65 | + if(n==4){ |
| 66 | + printf("\033[0;31m"); |
| 67 | + printf("\n\t\t\t\tYou can't log in."); |
| 68 | + delay(300); |
| 69 | + system("cls"); |
| 70 | + goto_login(); |
| 71 | + |
| 72 | + |
| 73 | + } |
| 74 | +} |
| 75 | + |
| 76 | + |
| 77 | + |
| 78 | + |
| 79 | + |
| 80 | +int password_Validation(char *password_Info){ |
| 81 | + int digitflag=0; |
| 82 | + int upperflag=0; |
| 83 | + int lowerflag=0; |
| 84 | + int checkForPass; |
| 85 | + |
| 86 | + if(strlen(password_Info)<8) |
| 87 | + { |
| 88 | + printf("Length of your Pass is less than 8\n"); |
| 89 | + printf("try Again..."); |
| 90 | + |
| 91 | + return false; |
| 92 | + } |
| 93 | + else |
| 94 | + { |
| 95 | + for(checkForPass = 0; checkForPass<strlen(password_Info); checkForPass++) |
| 96 | + { |
| 97 | + if(isdigit(password_Info[checkForPass])) |
| 98 | + digitflag=1; |
| 99 | + if(isupper(password_Info[checkForPass])) |
| 100 | + upperflag=1; |
| 101 | + if(islower(password_Info[checkForPass])) |
| 102 | + lowerflag=1; |
| 103 | + } |
| 104 | + if(digitflag==0){ |
| 105 | + printf("\033[0;31m"); |
| 106 | + printf("\t\tNo digits "); |
| 107 | + delay(1); |
| 108 | + return false; |
| 109 | + } |
| 110 | + else if(upperflag==0){ |
| 111 | + printf("\033[0;31m"); |
| 112 | + printf("\t\tNo Upper Case Letters "); |
| 113 | + delay(1); |
| 114 | + return false; |
| 115 | + } |
| 116 | + else if(lowerflag==0){ |
| 117 | + printf("\033[0;31m"); |
| 118 | + printf("\t\tNo Lower Case Letters "); |
| 119 | + delay(1); |
| 120 | + return false; |
| 121 | + } |
| 122 | + } |
| 123 | + return true; |
| 124 | + } |
| 125 | + |
| 126 | + |
| 127 | + |
| 128 | +void Register_Na_SecondAttempt(){ |
| 129 | + int i,test, startV; |
| 130 | + char ch,FN[20],username_Info[80], password_Info[80], password_Confirmation[80], *temp; |
| 131 | + |
| 132 | + |
| 133 | + system("cls"); |
| 134 | + Register_Admin_GUI(); |
| 135 | + printf("\033[0;36m"); |
| 136 | + printf("\n\t ENTER YOU USERNAME :->>"); |
| 137 | + scanf("%s", &username_Info); |
| 138 | + giveTip4_Pass_GUI(); |
| 139 | + printf("\n\t ENTER YOU PASSWORD :->>"); |
| 140 | + printf("\033[0;30m"); |
| 141 | + scanf("%s", &password_Info); |
| 142 | + printf("\033[0;33m"); |
| 143 | + temp = password_Info; |
| 144 | + test = password_Validation(password_Info); |
| 145 | + if(test == true) |
| 146 | + { |
| 147 | + |
| 148 | + printf("\n\t CONFIRM YOU PASSWORD :->>"); |
| 149 | + printf("\033[0;30m"); |
| 150 | + scanf("%s", &password_Confirmation); |
| 151 | + if(temp == password_Confirmation) |
| 152 | + { |
| 153 | + printf("Password didn't match"); |
| 154 | + delay(5); |
| 155 | + |
| 156 | + } |
| 157 | + else{ |
| 158 | + |
| 159 | + system("cls"); |
| 160 | + FILE *fq; |
| 161 | + fq = fopen("C:\\script\\name_pass.txt", "w"); |
| 162 | + fprintf(fq,"%s %s",username_Info, password_Info); |
| 163 | + |
| 164 | + fclose(fq); |
| 165 | + Loading_GUI(); |
| 166 | + dashboard_Function(); |
| 167 | + } |
| 168 | + }else{ |
| 169 | + delay(2); |
| 170 | + system("cls"); |
| 171 | + Register_Na_SecondAttempt(); |
| 172 | + |
| 173 | + |
| 174 | + } |
| 175 | + |
| 176 | + |
| 177 | + } |
| 178 | + |
| 179 | +void Register_Na(){ |
| 180 | + |
| 181 | + |
| 182 | + |
| 183 | + int i,test, startV; |
| 184 | + char ch,FN[20],username_Info[80], password_Info[80], password_Confirmation[80], *temp; |
| 185 | + startV = getch(); |
| 186 | + if(startV == 32) |
| 187 | + { |
| 188 | + system("cls"); |
| 189 | + Register_Admin_GUI(); |
| 190 | + //kulay cyan |
| 191 | + printf("\033[0;36m"); |
| 192 | + |
| 193 | + printf("\n\t ENTER YOU USERNAME :->>"); |
| 194 | + scanf("%s", &username_Info); |
| 195 | + giveTip4_Pass_GUI(); |
| 196 | + printf("\n\t ENTER YOU PASSWORD :->>"); |
| 197 | + //kulay black |
| 198 | + printf("\033[0;30m"); |
| 199 | + scanf("%s", &password_Info); |
| 200 | + printf("\033[0;33m"); |
| 201 | + temp = password_Info; |
| 202 | + test = password_Validation(password_Info); |
| 203 | + if(test == true) |
| 204 | + { |
| 205 | + |
| 206 | + printf("\n\t CONFIRM YOU PASSWORD :->>"); |
| 207 | + printf("\033[0;30m"); |
| 208 | + scanf("%s", &password_Confirmation); |
| 209 | + if(temp == password_Confirmation) |
| 210 | + { |
| 211 | + printf("Password didn't match"); |
| 212 | + delay(5); |
| 213 | + |
| 214 | + } |
| 215 | + else{ |
| 216 | + |
| 217 | + system("cls"); |
| 218 | + FILE *fr; |
| 219 | + fr = fopen("C:\\script\\name_pass.txt", "w"); |
| 220 | + fprintf(fr,"%s %s",username_Info, password_Info); |
| 221 | + fclose(fr); |
| 222 | + Loading_GUI(); |
| 223 | + dashboard_Function(); |
| 224 | + } |
| 225 | + |
| 226 | + } |
| 227 | + |
| 228 | + } |
| 229 | + else if(startV == 27) |
| 230 | + { |
| 231 | + exit(0); |
| 232 | + } |
| 233 | + Register_Na_SecondAttempt(); |
| 234 | + } |
| 235 | + |
| 236 | + // |
| 237 | + // |
| 238 | + // |
| 239 | + void insert_new(); |
| 240 | +void change_Info() |
| 241 | +{ |
| 242 | + |
| 243 | + |
| 244 | + fclose(fopen("C:\\script\\name_pass.txt", "w")); |
| 245 | + insert_new(); |
| 246 | + |
| 247 | + |
| 248 | +} |
| 249 | + |
| 250 | +void insert_new() |
| 251 | +{ |
| 252 | + int input; |
| 253 | + system("cls"); |
| 254 | + Warning_GUI(); |
| 255 | + printf("\033[0;36m"); |
| 256 | + printf("\t\t\t\t\tDo you want to continue to change your info?\n"); |
| 257 | + printf("\t\t\t\t\tPress Space to Continue then Esc to Go back"); |
| 258 | + input = getch(); |
| 259 | + if(input == 32) |
| 260 | + { |
| 261 | + system("cls"); |
| 262 | + printf("\033[0;36m"); |
| 263 | + char username_Info[40], password_Info[40]; |
| 264 | + FILE *fpt; |
| 265 | + fpt = fopen("C:\\Box\\name_pass.txt", "w"); |
| 266 | + printf("\n\n\n\n\n\t\t\t\t\t\tEnter your new username\n\t\t\t\t\t\t"); |
| 267 | + scanf("%s",&username_Info); |
| 268 | + printf("\n\n\n\t\t\t\t\t\tEnter your new password\n\t\t\t\t\t\t"); |
| 269 | + scanf("%s",&password_Info); |
| 270 | + fprintf(fpt,"%s %s",username_Info, password_Info); |
| 271 | + fclose(fpt); |
| 272 | + printf("\n\n\n\n\t\t\t\t\t\tSucessfully change!\n\t\t\t\t\t\t"); |
| 273 | + delay(10); |
| 274 | + } |
| 275 | + else if(input == 27) |
| 276 | + { |
| 277 | + goto_dashboard(); |
| 278 | + } |
| 279 | + else{ |
| 280 | + WrongInput_GUI(); |
| 281 | + goto_dashboard(); |
| 282 | + } |
| 283 | + |
| 284 | + |
| 285 | + } |
| 286 | + |
| 287 | +void goto_login() |
| 288 | + { |
| 289 | + system("cls"); |
| 290 | + fflush(stdin); |
| 291 | + Login_Interface_GUI(); |
| 292 | + login_functionality(); |
| 293 | + Loading_GUI(); |
| 294 | + dashboard_Function(); |
| 295 | + } |
| 296 | + |
| 297 | + void goto_dashboard() |
| 298 | + { |
| 299 | + fflush(stdin); |
| 300 | + dashboard_Admin_GUI(); |
| 301 | + dashboard_Function(); |
| 302 | + } |
| 303 | + |
| 304 | + |
| 305 | + |
| 306 | + |
0 commit comments