| 1 | /* |
|---|
| 2 | FILE |
|---|
| 3 | tAuthorize source code of unxsVZ.cgi |
|---|
| 4 | Built by mysqlRAD2.cgi (C) Gary Wallis and Hugo Urquiza 2001-2009 |
|---|
| 5 | $Id$ |
|---|
| 6 | PURPOSE |
|---|
| 7 | Schema dependent RAD generated file. |
|---|
| 8 | Program app functionality in tauthorizefunc.h while |
|---|
| 9 | RAD is still to be used. |
|---|
| 10 | */ |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | #include "mysqlrad.h" |
|---|
| 14 | //Table Variables |
|---|
| 15 | //uAuthorize: Primary Key |
|---|
| 16 | static unsigned uAuthorize=0; |
|---|
| 17 | //cLabel: Short label |
|---|
| 18 | static char cLabel[33]={""}; |
|---|
| 19 | //cIpMask: Allow user from this IP |
|---|
| 20 | static char cIpMask[21]={"0.0.0.0/0"}; |
|---|
| 21 | //uPerm: User permission level |
|---|
| 22 | static unsigned uPerm=0; |
|---|
| 23 | //uCertClient: User uClient |
|---|
| 24 | static unsigned uCertClient=0; |
|---|
| 25 | //cPasswd: Encrypted cgi login password |
|---|
| 26 | static char cPasswd[101]={""}; |
|---|
| 27 | //cClrPasswd: Optionally used non encrypted login password |
|---|
| 28 | static char cClrPasswd[33]={""}; |
|---|
| 29 | //uOwner: Record owner |
|---|
| 30 | static unsigned uOwner=0; |
|---|
| 31 | //uCreatedBy: uClient for last insert |
|---|
| 32 | static unsigned uCreatedBy=0; |
|---|
| 33 | //uCreatedDate: Unix seconds date last insert |
|---|
| 34 | static time_t uCreatedDate=0; |
|---|
| 35 | //uModBy: uClient for last update |
|---|
| 36 | static unsigned uModBy=0; |
|---|
| 37 | //uModDate: Unix seconds date last update |
|---|
| 38 | static time_t uModDate=0; |
|---|
| 39 | |
|---|
| 40 | |
|---|
| 41 | |
|---|
| 42 | #define VAR_LIST_tAuthorize "tAuthorize.uAuthorize,tAuthorize.cLabel,tAuthorize.cIpMask,tAuthorize.uPerm,tAuthorize.uCertClient,tAuthorize.cPasswd,tAuthorize.cClrPasswd,tAuthorize.uOwner,tAuthorize.uCreatedBy,tAuthorize.uCreatedDate,tAuthorize.uModBy,tAuthorize.uModDate" |
|---|
| 43 | |
|---|
| 44 | //Local only |
|---|
| 45 | void Insert_tAuthorize(void); |
|---|
| 46 | void Update_tAuthorize(char *cRowid); |
|---|
| 47 | void ProcesstAuthorizeListVars(pentry entries[], int x); |
|---|
| 48 | |
|---|
| 49 | //In tAuthorizefunc.h file included below |
|---|
| 50 | void ExtProcesstAuthorizeVars(pentry entries[], int x); |
|---|
| 51 | void ExttAuthorizeCommands(pentry entries[], int x); |
|---|
| 52 | void ExttAuthorizeButtons(void); |
|---|
| 53 | void ExttAuthorizeNavBar(void); |
|---|
| 54 | void ExttAuthorizeGetHook(entry gentries[], int x); |
|---|
| 55 | void ExttAuthorizeSelect(void); |
|---|
| 56 | void ExttAuthorizeSelectRow(void); |
|---|
| 57 | void ExttAuthorizeListSelect(void); |
|---|
| 58 | void ExttAuthorizeListFilter(void); |
|---|
| 59 | void ExttAuthorizeAuxTable(void); |
|---|
| 60 | |
|---|
| 61 | #include "tauthorizefunc.h" |
|---|
| 62 | |
|---|
| 63 | //Table Variables Assignment Function |
|---|
| 64 | void ProcesstAuthorizeVars(pentry entries[], int x) |
|---|
| 65 | { |
|---|
| 66 | register int i; |
|---|
| 67 | |
|---|
| 68 | |
|---|
| 69 | for(i=0;i<x;i++) |
|---|
| 70 | { |
|---|
| 71 | if(!strcmp(entries[i].name,"uAuthorize")) |
|---|
| 72 | sscanf(entries[i].val,"%u",&uAuthorize); |
|---|
| 73 | else if(!strcmp(entries[i].name,"cLabel")) |
|---|
| 74 | sprintf(cLabel,"%.32s",entries[i].val); |
|---|
| 75 | else if(!strcmp(entries[i].name,"cIpMask")) |
|---|
| 76 | sprintf(cIpMask,"%.20s",entries[i].val); |
|---|
| 77 | else if(!strcmp(entries[i].name,"uPerm")) |
|---|
| 78 | sscanf(entries[i].val,"%u",&uPerm); |
|---|
| 79 | else if(!strcmp(entries[i].name,"uCertClient")) |
|---|
| 80 | sscanf(entries[i].val,"%u",&uCertClient); |
|---|
| 81 | else if(!strcmp(entries[i].name,"cPasswd")) |
|---|
| 82 | sprintf(cPasswd,"%.100s",entries[i].val); |
|---|
| 83 | else if(!strcmp(entries[i].name,"cClrPasswd")) |
|---|
| 84 | sprintf(cClrPasswd,"%.32s",entries[i].val); |
|---|
| 85 | else if(!strcmp(entries[i].name,"uOwner")) |
|---|
| 86 | sscanf(entries[i].val,"%u",&uOwner); |
|---|
| 87 | else if(!strcmp(entries[i].name,"uCreatedBy")) |
|---|
| 88 | sscanf(entries[i].val,"%u",&uCreatedBy); |
|---|
| 89 | else if(!strcmp(entries[i].name,"uCreatedDate")) |
|---|
| 90 | sscanf(entries[i].val,"%lu",&uCreatedDate); |
|---|
| 91 | else if(!strcmp(entries[i].name,"uModBy")) |
|---|
| 92 | sscanf(entries[i].val,"%u",&uModBy); |
|---|
| 93 | else if(!strcmp(entries[i].name,"uModDate")) |
|---|
| 94 | sscanf(entries[i].val,"%lu",&uModDate); |
|---|
| 95 | |
|---|
| 96 | } |
|---|
| 97 | |
|---|
| 98 | //After so we can overwrite form data if needed. |
|---|
| 99 | ExtProcesstAuthorizeVars(entries,x); |
|---|
| 100 | |
|---|
| 101 | }//ProcesstAuthorizeVars() |
|---|
| 102 | |
|---|
| 103 | |
|---|
| 104 | void ProcesstAuthorizeListVars(pentry entries[], int x) |
|---|
| 105 | { |
|---|
| 106 | register int i; |
|---|
| 107 | |
|---|
| 108 | for(i=0;i<x;i++) |
|---|
| 109 | { |
|---|
| 110 | if(!strncmp(entries[i].name,"ED",2)) |
|---|
| 111 | { |
|---|
| 112 | sscanf(entries[i].name+2,"%u",&uAuthorize); |
|---|
| 113 | guMode=2002; |
|---|
| 114 | tAuthorize(""); |
|---|
| 115 | } |
|---|
| 116 | } |
|---|
| 117 | }//void ProcesstAuthorizeListVars(pentry entries[], int x) |
|---|
| 118 | |
|---|
| 119 | |
|---|
| 120 | int tAuthorizeCommands(pentry entries[], int x) |
|---|
| 121 | { |
|---|
| 122 | ProcessControlVars(entries,x); |
|---|
| 123 | |
|---|
| 124 | ExttAuthorizeCommands(entries,x); |
|---|
| 125 | |
|---|
| 126 | if(!strcmp(gcFunction,"tAuthorizeTools")) |
|---|
| 127 | { |
|---|
| 128 | if(!strcmp(gcFind,LANG_NB_LIST)) |
|---|
| 129 | { |
|---|
| 130 | tAuthorizeList(); |
|---|
| 131 | } |
|---|
| 132 | |
|---|
| 133 | //Default |
|---|
| 134 | ProcesstAuthorizeVars(entries,x); |
|---|
| 135 | tAuthorize(""); |
|---|
| 136 | } |
|---|
| 137 | else if(!strcmp(gcFunction,"tAuthorizeList")) |
|---|
| 138 | { |
|---|
| 139 | ProcessControlVars(entries,x); |
|---|
| 140 | ProcesstAuthorizeListVars(entries,x); |
|---|
| 141 | tAuthorizeList(); |
|---|
| 142 | } |
|---|
| 143 | |
|---|
| 144 | return(0); |
|---|
| 145 | |
|---|
| 146 | }//tAuthorizeCommands() |
|---|
| 147 | |
|---|
| 148 | |
|---|
| 149 | void tAuthorize(const char *cResult) |
|---|
| 150 | { |
|---|
| 151 | MYSQL_RES *res; |
|---|
| 152 | MYSQL_RES *res2; |
|---|
| 153 | MYSQL_ROW field; |
|---|
| 154 | |
|---|
| 155 | //Internal skip reloading |
|---|
| 156 | if(!cResult[0]) |
|---|
| 157 | { |
|---|
| 158 | if(guMode) |
|---|
| 159 | ExttAuthorizeSelectRow(); |
|---|
| 160 | else |
|---|
| 161 | ExttAuthorizeSelect(); |
|---|
| 162 | |
|---|
| 163 | mysql_query(&gMysql,gcQuery); |
|---|
| 164 | if(mysql_errno(&gMysql)) |
|---|
| 165 | { |
|---|
| 166 | if(strstr(mysql_error(&gMysql)," doesn't exist")) |
|---|
| 167 | { |
|---|
| 168 | CreatetAuthorize(); |
|---|
| 169 | unxsVZ("New tAuthorize table created"); |
|---|
| 170 | } |
|---|
| 171 | else |
|---|
| 172 | { |
|---|
| 173 | htmlPlainTextError(mysql_error(&gMysql)); |
|---|
| 174 | } |
|---|
| 175 | } |
|---|
| 176 | |
|---|
| 177 | res=mysql_store_result(&gMysql); |
|---|
| 178 | if((guI=mysql_num_rows(res))) |
|---|
| 179 | { |
|---|
| 180 | if(guMode==6) |
|---|
| 181 | { |
|---|
| 182 | sprintf(gcQuery,"SELECT _rowid FROM tAuthorize WHERE uAuthorize=%u" |
|---|
| 183 | ,uAuthorize); |
|---|
| 184 | macro_mySQLRunAndStore(res2); |
|---|
| 185 | field=mysql_fetch_row(res2); |
|---|
| 186 | sscanf(field[0],"%lu",&gluRowid); |
|---|
| 187 | gluRowid++; |
|---|
| 188 | } |
|---|
| 189 | PageMachine("",0,""); |
|---|
| 190 | if(!guMode) mysql_data_seek(res,gluRowid-1); |
|---|
| 191 | field=mysql_fetch_row(res); |
|---|
| 192 | sscanf(field[0],"%u",&uAuthorize); |
|---|
| 193 | sprintf(cLabel,"%.32s",field[1]); |
|---|
| 194 | sprintf(cIpMask,"%.20s",field[2]); |
|---|
| 195 | sscanf(field[3],"%u",&uPerm); |
|---|
| 196 | sscanf(field[4],"%u",&uCertClient); |
|---|
| 197 | sprintf(cPasswd,"%.100s",field[5]); |
|---|
| 198 | sprintf(cClrPasswd,"%.32s",field[6]); |
|---|
| 199 | sscanf(field[7],"%u",&uOwner); |
|---|
| 200 | sscanf(field[8],"%u",&uCreatedBy); |
|---|
| 201 | sscanf(field[9],"%lu",&uCreatedDate); |
|---|
| 202 | sscanf(field[10],"%u",&uModBy); |
|---|
| 203 | sscanf(field[11],"%lu",&uModDate); |
|---|
| 204 | |
|---|
| 205 | } |
|---|
| 206 | |
|---|
| 207 | }//Internal Skip |
|---|
| 208 | |
|---|
| 209 | Header_ism3(":: tAuthorize",0); |
|---|
| 210 | printf("<table width=100%% cellspacing=0 cellpadding=0>\n"); |
|---|
| 211 | printf("<tr><td colspan=2 align=right valign=center>"); |
|---|
| 212 | |
|---|
| 213 | |
|---|
| 214 | printf("<input type=hidden name=gcFunction value=tAuthorizeTools>"); |
|---|
| 215 | printf("<input type=hidden name=gluRowid value=%lu>",gluRowid); |
|---|
| 216 | if(guI) |
|---|
| 217 | { |
|---|
| 218 | if(guMode==6) |
|---|
| 219 | //printf(" Found"); |
|---|
| 220 | printf(LANG_NBR_FOUND); |
|---|
| 221 | else if(guMode==5) |
|---|
| 222 | //printf(" Modified"); |
|---|
| 223 | printf(LANG_NBR_MODIFIED); |
|---|
| 224 | else if(guMode==4) |
|---|
| 225 | //printf(" New"); |
|---|
| 226 | printf(LANG_NBR_NEW); |
|---|
| 227 | printf(LANG_NBRF_SHOWING,gluRowid,guI); |
|---|
| 228 | } |
|---|
| 229 | else |
|---|
| 230 | { |
|---|
| 231 | if(!cResult[0]) |
|---|
| 232 | //printf(" No records found"); |
|---|
| 233 | printf(LANG_NBR_NORECS); |
|---|
| 234 | } |
|---|
| 235 | if(cResult[0]) printf("%s",cResult); |
|---|
| 236 | printf("</td></tr>"); |
|---|
| 237 | printf("<tr><td valign=top width=25%%>"); |
|---|
| 238 | |
|---|
| 239 | ExttAuthorizeButtons(); |
|---|
| 240 | |
|---|
| 241 | printf("</td><td valign=top>"); |
|---|
| 242 | // |
|---|
| 243 | OpenFieldSet("tAuthorize Record Data",100); |
|---|
| 244 | |
|---|
| 245 | if(guMode==2000 || guMode==2002) |
|---|
| 246 | tAuthorizeInput(1); |
|---|
| 247 | else |
|---|
| 248 | tAuthorizeInput(0); |
|---|
| 249 | |
|---|
| 250 | // |
|---|
| 251 | CloseFieldSet(); |
|---|
| 252 | |
|---|
| 253 | //Bottom table |
|---|
| 254 | printf("<tr><td colspan=2>"); |
|---|
| 255 | ExttAuthorizeAuxTable(); |
|---|
| 256 | |
|---|
| 257 | Footer_ism3(); |
|---|
| 258 | |
|---|
| 259 | }//end of tAuthorize(); |
|---|
| 260 | |
|---|
| 261 | |
|---|
| 262 | void tAuthorizeInput(unsigned uMode) |
|---|
| 263 | { |
|---|
| 264 | |
|---|
| 265 | //uAuthorize |
|---|
| 266 | OpenRow(LANG_FL_tAuthorize_uAuthorize,"black"); |
|---|
| 267 | printf("<input title='%s' type=text name=uAuthorize value=%u size=16 maxlength=10 " |
|---|
| 268 | ,LANG_FT_tAuthorize_uAuthorize,uAuthorize); |
|---|
| 269 | if(guPermLevel>=20 && uMode) |
|---|
| 270 | { |
|---|
| 271 | printf("></td></tr>\n"); |
|---|
| 272 | } |
|---|
| 273 | else |
|---|
| 274 | { |
|---|
| 275 | printf("disabled></td></tr>\n"); |
|---|
| 276 | printf("<input type=hidden name=uAuthorize value=%u >\n",uAuthorize); |
|---|
| 277 | } |
|---|
| 278 | //cLabel |
|---|
| 279 | OpenRow(LANG_FL_tAuthorize_cLabel,"black"); |
|---|
| 280 | printf("<input title='%s' type=text name=cLabel value=\"%s\" size=40 maxlength=32 " |
|---|
| 281 | ,LANG_FT_tAuthorize_cLabel,EncodeDoubleQuotes(cLabel)); |
|---|
| 282 | if(guPermLevel>=0 && uMode) |
|---|
| 283 | { |
|---|
| 284 | printf("></td></tr>\n"); |
|---|
| 285 | } |
|---|
| 286 | else |
|---|
| 287 | { |
|---|
| 288 | printf("disabled></td></tr>\n"); |
|---|
| 289 | printf("<input type=hidden name=cLabel value=\"%s\">\n",EncodeDoubleQuotes(cLabel)); |
|---|
| 290 | } |
|---|
| 291 | //cIpMask |
|---|
| 292 | OpenRow(LANG_FL_tAuthorize_cIpMask,"black"); |
|---|
| 293 | printf("<input title='%s' type=text name=cIpMask value=\"%s\" size=40 maxlength=20 " |
|---|
| 294 | ,LANG_FT_tAuthorize_cIpMask,EncodeDoubleQuotes(cIpMask)); |
|---|
| 295 | if(guPermLevel>=0 && uMode) |
|---|
| 296 | { |
|---|
| 297 | printf("></td></tr>\n"); |
|---|
| 298 | } |
|---|
| 299 | else |
|---|
| 300 | { |
|---|
| 301 | printf("disabled></td></tr>\n"); |
|---|
| 302 | printf("<input type=hidden name=cIpMask value=\"%s\">\n",EncodeDoubleQuotes(cIpMask)); |
|---|
| 303 | } |
|---|
| 304 | //uPerm |
|---|
| 305 | OpenRow(LANG_FL_tAuthorize_uPerm,"black"); |
|---|
| 306 | printf("<input title='%s' type=text name=uPerm value=%u size=16 maxlength=10 " |
|---|
| 307 | ,LANG_FT_tAuthorize_uPerm,uPerm); |
|---|
| 308 | if(guPermLevel>=0 && uMode) |
|---|
| 309 | { |
|---|
| 310 | printf("></td></tr>\n"); |
|---|
| 311 | } |
|---|
| 312 | else |
|---|
| 313 | { |
|---|
| 314 | printf("disabled></td></tr>\n"); |
|---|
| 315 | printf("<input type=hidden name=uPerm value=%u >\n",uPerm); |
|---|
| 316 | } |
|---|
| 317 | //uCertClient |
|---|
| 318 | OpenRow(LANG_FL_tAuthorize_uCertClient,"black"); |
|---|
| 319 | printf("<input title='%s' type=text name=uCertClient value=%u size=16 maxlength=10 " |
|---|
| 320 | ,LANG_FT_tAuthorize_uCertClient,uCertClient); |
|---|
| 321 | if(guPermLevel>=0 && uMode) |
|---|
| 322 | { |
|---|
| 323 | printf("></td></tr>\n"); |
|---|
| 324 | } |
|---|
| 325 | else |
|---|
| 326 | { |
|---|
| 327 | printf("disabled></td></tr>\n"); |
|---|
| 328 | printf("<input type=hidden name=uCertClient value=%u >\n",uCertClient); |
|---|
| 329 | } |
|---|
| 330 | //cPasswd |
|---|
| 331 | OpenRow(LANG_FL_tAuthorize_cPasswd,"black"); |
|---|
| 332 | printf("<input title='%s' type=text name=cPasswd value=\"%s\" size=40 maxlength=100 " |
|---|
| 333 | ,LANG_FT_tAuthorize_cPasswd,EncodeDoubleQuotes(cPasswd)); |
|---|
| 334 | if(guPermLevel>=0 && uMode) |
|---|
| 335 | { |
|---|
| 336 | printf("></td></tr>\n"); |
|---|
| 337 | } |
|---|
| 338 | else |
|---|
| 339 | { |
|---|
| 340 | printf("disabled></td></tr>\n"); |
|---|
| 341 | printf("<input type=hidden name=cPasswd value=\"%s\">\n",EncodeDoubleQuotes(cPasswd)); |
|---|
| 342 | } |
|---|
| 343 | //cClrPasswd |
|---|
| 344 | OpenRow(LANG_FL_tAuthorize_cClrPasswd,"black"); |
|---|
| 345 | printf("<input title='%s' type=text name=cClrPasswd value=\"%s\" size=40 maxlength=32 " |
|---|
| 346 | ,LANG_FT_tAuthorize_cClrPasswd,EncodeDoubleQuotes(cClrPasswd)); |
|---|
| 347 | if(guPermLevel>=0 && uMode) |
|---|
| 348 | { |
|---|
| 349 | printf("></td></tr>\n"); |
|---|
| 350 | } |
|---|
| 351 | else |
|---|
| 352 | { |
|---|
| 353 | printf("disabled></td></tr>\n"); |
|---|
| 354 | printf("<input type=hidden name=cClrPasswd value=\"%s\">\n",EncodeDoubleQuotes(cClrPasswd)); |
|---|
| 355 | } |
|---|
| 356 | //uOwner |
|---|
| 357 | OpenRow(LANG_FL_tAuthorize_uOwner,"black"); |
|---|
| 358 | if(guPermLevel>=20 && uMode) |
|---|
| 359 | { |
|---|
| 360 | printf("%s<input type=hidden name=uOwner value=%u >\n",ForeignKey("tClient","cLabel",uOwner),uOwner); |
|---|
| 361 | } |
|---|
| 362 | else |
|---|
| 363 | { |
|---|
| 364 | printf("%s<input type=hidden name=uOwner value=%u >\n",ForeignKey("tClient","cLabel",uOwner),uOwner); |
|---|
| 365 | } |
|---|
| 366 | //uCreatedBy |
|---|
| 367 | OpenRow(LANG_FL_tAuthorize_uCreatedBy,"black"); |
|---|
| 368 | if(guPermLevel>=20 && uMode) |
|---|
| 369 | { |
|---|
| 370 | printf("%s<input type=hidden name=uCreatedBy value=%u >\n",ForeignKey("tClient","cLabel",uCreatedBy),uCreatedBy); |
|---|
| 371 | } |
|---|
| 372 | else |
|---|
| 373 | { |
|---|
| 374 | printf("%s<input type=hidden name=uCreatedBy value=%u >\n",ForeignKey("tClient","cLabel",uCreatedBy),uCreatedBy); |
|---|
| 375 | } |
|---|
| 376 | //uCreatedDate |
|---|
| 377 | OpenRow(LANG_FL_tAuthorize_uCreatedDate,"black"); |
|---|
| 378 | if(uCreatedDate) |
|---|
| 379 | printf("%s\n\n",ctime(&uCreatedDate)); |
|---|
| 380 | else |
|---|
| 381 | printf("---\n\n"); |
|---|
| 382 | printf("<input type=hidden name=uCreatedDate value=%lu >\n",uCreatedDate); |
|---|
| 383 | //uModBy |
|---|
| 384 | OpenRow(LANG_FL_tAuthorize_uModBy,"black"); |
|---|
| 385 | if(guPermLevel>=20 && uMode) |
|---|
| 386 | { |
|---|
| 387 | printf("%s<input type=hidden name=uModBy value=%u >\n",ForeignKey("tClient","cLabel",uModBy),uModBy); |
|---|
| 388 | } |
|---|
| 389 | else |
|---|
| 390 | { |
|---|
| 391 | printf("%s<input type=hidden name=uModBy value=%u >\n",ForeignKey("tClient","cLabel",uModBy),uModBy); |
|---|
| 392 | } |
|---|
| 393 | //uModDate |
|---|
| 394 | OpenRow(LANG_FL_tAuthorize_uModDate,"black"); |
|---|
| 395 | if(uModDate) |
|---|
| 396 | printf("%s\n\n",ctime(&uModDate)); |
|---|
| 397 | else |
|---|
| 398 | printf("---\n\n"); |
|---|
| 399 | printf("<input type=hidden name=uModDate value=%lu >\n",uModDate); |
|---|
| 400 | printf("</tr>\n"); |
|---|
| 401 | |
|---|
| 402 | |
|---|
| 403 | |
|---|
| 404 | }//void tAuthorizeInput(unsigned uMode) |
|---|
| 405 | |
|---|
| 406 | |
|---|
| 407 | void NewtAuthorize(unsigned uMode) |
|---|
| 408 | { |
|---|
| 409 | register int i=0; |
|---|
| 410 | MYSQL_RES *res; |
|---|
| 411 | |
|---|
| 412 | sprintf(gcQuery,"SELECT uAuthorize FROM tAuthorize WHERE uAuthorize=%u" |
|---|
| 413 | ,uAuthorize); |
|---|
| 414 | macro_mySQLRunAndStore(res); |
|---|
| 415 | i=mysql_num_rows(res); |
|---|
| 416 | |
|---|
| 417 | if(i) |
|---|
| 418 | //tAuthorize("<blink>Record already exists"); |
|---|
| 419 | tAuthorize(LANG_NBR_RECEXISTS); |
|---|
| 420 | |
|---|
| 421 | //insert query |
|---|
| 422 | Insert_tAuthorize(); |
|---|
| 423 | //sprintf(gcQuery,"New record %u added"); |
|---|
| 424 | uAuthorize=mysql_insert_id(&gMysql); |
|---|
| 425 | uCreatedDate=luGetCreatedDate("tAuthorize",uAuthorize); |
|---|
| 426 | unxsVZLog(uAuthorize,"tAuthorize","New"); |
|---|
| 427 | |
|---|
| 428 | if(!uMode) |
|---|
| 429 | { |
|---|
| 430 | sprintf(gcQuery,LANG_NBR_NEWRECADDED,uAuthorize); |
|---|
| 431 | tAuthorize(gcQuery); |
|---|
| 432 | } |
|---|
| 433 | |
|---|
| 434 | }//NewtAuthorize(unsigned uMode) |
|---|
| 435 | |
|---|
| 436 | |
|---|
| 437 | void DeletetAuthorize(void) |
|---|
| 438 | { |
|---|
| 439 | sprintf(gcQuery,"DELETE FROM tAuthorize WHERE uAuthorize=%u AND ( uOwner=%u OR %u>9 )" |
|---|
| 440 | ,uAuthorize,guLoginClient,guPermLevel); |
|---|
| 441 | macro_mySQLQueryHTMLError; |
|---|
| 442 | //tAuthorize("Record Deleted"); |
|---|
| 443 | if(mysql_affected_rows(&gMysql)>0) |
|---|
| 444 | { |
|---|
| 445 | unxsVZLog(uAuthorize,"tAuthorize","Del"); |
|---|
| 446 | tAuthorize(LANG_NBR_RECDELETED); |
|---|
| 447 | } |
|---|
| 448 | else |
|---|
| 449 | { |
|---|
| 450 | unxsVZLog(uAuthorize,"tAuthorize","DelError"); |
|---|
| 451 | tAuthorize(LANG_NBR_RECNOTDELETED); |
|---|
| 452 | } |
|---|
| 453 | |
|---|
| 454 | }//void DeletetAuthorize(void) |
|---|
| 455 | |
|---|
| 456 | |
|---|
| 457 | void Insert_tAuthorize(void) |
|---|
| 458 | { |
|---|
| 459 | |
|---|
| 460 | //insert query |
|---|
| 461 | sprintf(gcQuery,"INSERT INTO tAuthorize SET uAuthorize=%u,cLabel='%s',cIpMask='%s',uPerm=%u,uCertClient=%u,cPasswd='%s',cClrPasswd='%s',uOwner=%u,uCreatedBy=%u,uCreatedDate=UNIX_TIMESTAMP(NOW())", |
|---|
| 462 | uAuthorize |
|---|
| 463 | ,TextAreaSave(cLabel) |
|---|
| 464 | ,TextAreaSave(cIpMask) |
|---|
| 465 | ,uPerm |
|---|
| 466 | ,uCertClient |
|---|
| 467 | ,TextAreaSave(cPasswd) |
|---|
| 468 | ,TextAreaSave(cClrPasswd) |
|---|
| 469 | ,uOwner |
|---|
| 470 | ,uCreatedBy |
|---|
| 471 | ); |
|---|
| 472 | |
|---|
| 473 | macro_mySQLQueryHTMLError; |
|---|
| 474 | |
|---|
| 475 | }//void Insert_tAuthorize(void) |
|---|
| 476 | |
|---|
| 477 | |
|---|
| 478 | void Update_tAuthorize(char *cRowid) |
|---|
| 479 | { |
|---|
| 480 | |
|---|
| 481 | //update query |
|---|
| 482 | sprintf(gcQuery,"UPDATE tAuthorize SET uAuthorize=%u,cLabel='%s',cIpMask='%s',uPerm=%u,uCertClient=%u,cPasswd='%s',cClrPasswd='%s',uModBy=%u,uModDate=UNIX_TIMESTAMP(NOW()) WHERE _rowid=%s", |
|---|
| 483 | uAuthorize |
|---|
| 484 | ,TextAreaSave(cLabel) |
|---|
| 485 | ,TextAreaSave(cIpMask) |
|---|
| 486 | ,uPerm |
|---|
| 487 | ,uCertClient |
|---|
| 488 | ,TextAreaSave(cPasswd) |
|---|
| 489 | ,TextAreaSave(cClrPasswd) |
|---|
| 490 | ,uModBy |
|---|
| 491 | ,cRowid); |
|---|
| 492 | |
|---|
| 493 | macro_mySQLQueryHTMLError; |
|---|
| 494 | |
|---|
| 495 | }//void Update_tAuthorize(void) |
|---|
| 496 | |
|---|
| 497 | |
|---|
| 498 | void ModtAuthorize(void) |
|---|
| 499 | { |
|---|
| 500 | register int i=0; |
|---|
| 501 | MYSQL_RES *res; |
|---|
| 502 | MYSQL_ROW field; |
|---|
| 503 | unsigned uPreModDate=0; |
|---|
| 504 | |
|---|
| 505 | //Mod select gcQuery |
|---|
| 506 | if(guPermLevel<10) |
|---|
| 507 | sprintf(gcQuery,"SELECT tAuthorize.uAuthorize,\ |
|---|
| 508 | tAuthorize.uModDate\ |
|---|
| 509 | FROM tAuthorize,tClient\ |
|---|
| 510 | WHERE tAuthorize.uAuthorize=%u\ |
|---|
| 511 | AND tAuthorize.uOwner=tClient.uClient\ |
|---|
| 512 | AND (tClient.uOwner=%u OR tClient.uClient=%u)" |
|---|
| 513 | ,uAuthorize,guLoginClient,guLoginClient); |
|---|
| 514 | else |
|---|
| 515 | sprintf(gcQuery,"SELECT uAuthorize,uModDate FROM tAuthorize\ |
|---|
| 516 | WHERE uAuthorize=%u" |
|---|
| 517 | ,uAuthorize); |
|---|
| 518 | macro_mySQLRunAndStore(res); |
|---|
| 519 | i=mysql_num_rows(res); |
|---|
| 520 | |
|---|
| 521 | //if(i<1) tAuthorize("<blink>Record does not exist"); |
|---|
| 522 | if(i<1) tAuthorize(LANG_NBR_RECNOTEXIST); |
|---|
| 523 | //if(i>1) tAuthorize("<blink>Multiple rows!"); |
|---|
| 524 | if(i>1) tAuthorize(LANG_NBR_MULTRECS); |
|---|
| 525 | |
|---|
| 526 | field=mysql_fetch_row(res); |
|---|
| 527 | sscanf(field[1],"%u",&uPreModDate); |
|---|
| 528 | if(uPreModDate!=uModDate) tAuthorize(LANG_NBR_EXTMOD); |
|---|
| 529 | |
|---|
| 530 | Update_tAuthorize(field[0]); |
|---|
| 531 | if(mysql_errno(&gMysql)) htmlPlainTextError(mysql_error(&gMysql)); |
|---|
| 532 | //sprintf(query,"record %s modified",field[0]); |
|---|
| 533 | sprintf(gcQuery,LANG_NBRF_REC_MODIFIED,field[0]); |
|---|
| 534 | uModDate=luGetModDate("tAuthorize",uAuthorize); |
|---|
| 535 | unxsVZLog(uAuthorize,"tAuthorize","Mod"); |
|---|
| 536 | tAuthorize(gcQuery); |
|---|
| 537 | |
|---|
| 538 | }//ModtAuthorize(void) |
|---|
| 539 | |
|---|
| 540 | |
|---|
| 541 | void tAuthorizeList(void) |
|---|
| 542 | { |
|---|
| 543 | MYSQL_RES *res; |
|---|
| 544 | MYSQL_ROW field; |
|---|
| 545 | |
|---|
| 546 | ExttAuthorizeListSelect(); |
|---|
| 547 | macro_mySQLRunAndStore(res); |
|---|
| 548 | guI=mysql_num_rows(res); |
|---|
| 549 | |
|---|
| 550 | PageMachine("tAuthorizeList",1,"");//1 is auto header list guMode. Opens table! |
|---|
| 551 | |
|---|
| 552 | //Filter select drop down |
|---|
| 553 | ExttAuthorizeListFilter(); |
|---|
| 554 | |
|---|
| 555 | printf("<input type=text size=16 name=gcCommand maxlength=98 value=\"%s\" >",gcCommand); |
|---|
| 556 | |
|---|
| 557 | printf("</table>\n"); |
|---|
| 558 | |
|---|
| 559 | printf("<table bgcolor=#9BC1B3 border=0 width=100%%>\n"); |
|---|
| 560 | printf("<tr bgcolor=black><td><font face=arial,helvetica color=white>uAuthorize<td><font face=arial,helvetica color=white>cLabel<td><font face=arial,helvetica color=white>cIpMask<td><font face=arial,helvetica color=white>uPerm<td><font face=arial,helvetica color=white>uCertClient<td><font face=arial,helvetica color=white>cPasswd<td><font face=arial,helvetica color=white>cClrPasswd<td><font face=arial,helvetica color=white>uOwner<td><font face=arial,helvetica color=white>uCreatedBy<td><font face=arial,helvetica color=white>uCreatedDate<td><font face=arial,helvetica color=white>uModBy<td><font face=arial,helvetica color=white>uModDate</tr>"); |
|---|
| 561 | |
|---|
| 562 | |
|---|
| 563 | |
|---|
| 564 | mysql_data_seek(res,guStart-1); |
|---|
| 565 | |
|---|
| 566 | for(guN=0;guN<(guEnd-guStart+1);guN++) |
|---|
| 567 | { |
|---|
| 568 | field=mysql_fetch_row(res); |
|---|
| 569 | if(!field) |
|---|
| 570 | { |
|---|
| 571 | printf("<tr><td><font face=arial,helvetica>End of data</table>"); |
|---|
| 572 | Footer_ism3(); |
|---|
| 573 | } |
|---|
| 574 | if(guN % 2) |
|---|
| 575 | printf("<tr bgcolor=#BBE1D3>"); |
|---|
| 576 | else |
|---|
| 577 | printf("<tr>"); |
|---|
| 578 | time_t luTime9=strtoul(field[9],NULL,10); |
|---|
| 579 | char cBuf9[32]; |
|---|
| 580 | if(luTime9) |
|---|
| 581 | ctime_r(&luTime9,cBuf9); |
|---|
| 582 | else |
|---|
| 583 | sprintf(cBuf9,"---"); |
|---|
| 584 | time_t luTime11=strtoul(field[11],NULL,10); |
|---|
| 585 | char cBuf11[32]; |
|---|
| 586 | if(luTime11) |
|---|
| 587 | ctime_r(&luTime11,cBuf11); |
|---|
| 588 | else |
|---|
| 589 | sprintf(cBuf11,"---"); |
|---|
| 590 | printf("<td><input type=submit name=ED%s value=Edit> %s<td>%s<td>%s<td>%s<td>%s<td>%s<td>%s<td>%s<td>%s<td>%s<td>%s<td>%s</tr>" |
|---|
| 591 | ,field[0] |
|---|
| 592 | ,field[0] |
|---|
| 593 | ,field[1] |
|---|
| 594 | ,field[2] |
|---|
| 595 | ,field[3] |
|---|
| 596 | ,field[4] |
|---|
| 597 | ,field[5] |
|---|
| 598 | ,field[6] |
|---|
| 599 | ,ForeignKey("tClient","cLabel",strtoul(field[7],NULL,10)) |
|---|
| 600 | ,ForeignKey("tClient","cLabel",strtoul(field[8],NULL,10)) |
|---|
| 601 | ,cBuf9 |
|---|
| 602 | ,ForeignKey("tClient","cLabel",strtoul(field[10],NULL,10)) |
|---|
| 603 | ,cBuf11 |
|---|
| 604 | ); |
|---|
| 605 | |
|---|
| 606 | } |
|---|
| 607 | |
|---|
| 608 | printf("</table></form>\n"); |
|---|
| 609 | Footer_ism3(); |
|---|
| 610 | |
|---|
| 611 | }//tAuthorizeList() |
|---|
| 612 | |
|---|
| 613 | |
|---|
| 614 | void CreatetAuthorize(void) |
|---|
| 615 | { |
|---|
| 616 | sprintf(gcQuery,"CREATE TABLE IF NOT EXISTS tAuthorize ( " |
|---|
| 617 | "uAuthorize INT UNSIGNED PRIMARY KEY AUTO_INCREMENT," |
|---|
| 618 | "cLabel VARCHAR(32) NOT NULL DEFAULT ''," |
|---|
| 619 | "UNIQUE (cLabel,uOwner)," |
|---|
| 620 | "uOwner INT UNSIGNED NOT NULL DEFAULT 0," |
|---|
| 621 | "INDEX (uOwner)," |
|---|
| 622 | "uCreatedBy INT UNSIGNED NOT NULL DEFAULT 0," |
|---|
| 623 | "uCreatedDate INT UNSIGNED NOT NULL DEFAULT 0," |
|---|
| 624 | "uModBy INT UNSIGNED NOT NULL DEFAULT 0," |
|---|
| 625 | "uModDate INT UNSIGNED NOT NULL DEFAULT 0," |
|---|
| 626 | "cIpMask VARCHAR(20) NOT NULL DEFAULT ''," |
|---|
| 627 | "uPerm INT UNSIGNED NOT NULL DEFAULT 0," |
|---|
| 628 | "uCertClient INT UNSIGNED NOT NULL DEFAULT 0," |
|---|
| 629 | "cPasswd VARCHAR(100) NOT NULL DEFAULT ''," |
|---|
| 630 | "cClrPasswd VARCHAR(32) NOT NULL DEFAULT '' )"); |
|---|
| 631 | macro_mySQLQueryHTMLError; |
|---|
| 632 | |
|---|
| 633 | }//CreatetAuthorize() |
|---|
| 634 | |
|---|