| 1 | /* |
|---|
| 2 | FILE |
|---|
| 3 | tLog source code template |
|---|
| 4 | Built by mysqlRAD2.cgi (C) Gary Wallis 2001-2007 |
|---|
| 5 | $Id$ |
|---|
| 6 | PURPOSE |
|---|
| 7 | Schema dependent RAD generated file. |
|---|
| 8 | Program app functionality in tlogfunc.h while |
|---|
| 9 | RAD is still to be used. |
|---|
| 10 | AUTHOR/LEGAL |
|---|
| 11 | (C) 2001-2010 Gary Wallis for Unixservice, LLC. |
|---|
| 12 | GPLv2 license applies. See LICENSE file included. |
|---|
| 13 | */ |
|---|
| 14 | |
|---|
| 15 | |
|---|
| 16 | #include "mysqlrad.h" |
|---|
| 17 | |
|---|
| 18 | //Table Variables |
|---|
| 19 | //Table Variables |
|---|
| 20 | //uLog: Primary Key |
|---|
| 21 | static unsigned uLog=0; |
|---|
| 22 | //cLabel: Short label |
|---|
| 23 | static char cLabel[65]={""}; |
|---|
| 24 | //uLogType: Log Type |
|---|
| 25 | static unsigned uLogType=0; |
|---|
| 26 | static char cuLogTypePullDown[256]={""}; |
|---|
| 27 | //cHash: Security hash to complicate tampering |
|---|
| 28 | static char cHash[33]={""}; |
|---|
| 29 | //uPermLevel: User Perm Level |
|---|
| 30 | static unsigned uPermLevel=0; |
|---|
| 31 | //uLoginClient: Client Number |
|---|
| 32 | static unsigned uLoginClient=0; |
|---|
| 33 | //cLogin: Login name |
|---|
| 34 | static char cLogin[33]={""}; |
|---|
| 35 | //cHost: Ip Address |
|---|
| 36 | static char cHost[33]={""}; |
|---|
| 37 | //uTablePK: Primar Key of the Table |
|---|
| 38 | static char uTablePK[33]={""}; |
|---|
| 39 | //cTableName: Name of the Table |
|---|
| 40 | static char cTableName[33]={""}; |
|---|
| 41 | //cMessage: Message text |
|---|
| 42 | static char cMessage[256]={""}; |
|---|
| 43 | //cServer: Server name |
|---|
| 44 | static char cServer[65]={""}; |
|---|
| 45 | //uOwner: Record owner |
|---|
| 46 | static unsigned uOwner=0; |
|---|
| 47 | //uCreatedBy: uClient for last insert |
|---|
| 48 | static unsigned uCreatedBy=0; |
|---|
| 49 | //uCreatedDate: Unix seconds date last insert |
|---|
| 50 | static time_t uCreatedDate=0; |
|---|
| 51 | //uModBy: uClient for last update |
|---|
| 52 | static unsigned uModBy=0; |
|---|
| 53 | //uModDate: Unix seconds date last update |
|---|
| 54 | static time_t uModDate=0; |
|---|
| 55 | |
|---|
| 56 | |
|---|
| 57 | |
|---|
| 58 | #define VAR_LIST_tLog "tLog.uLog,tLog.cLabel,tLog.uLogType,tLog.cHash,tLog.uPermLevel,tLog.uLoginClient,tLog.cLogin,tLog.cHost,tLog.uTablePK,tLog.cTableName,tLog.cMessage,tLog.cServer,tLog.uOwner,tLog.uCreatedBy,tLog.uCreatedDate,tLog.uModBy,tLog.uModDate" |
|---|
| 59 | |
|---|
| 60 | //Local only |
|---|
| 61 | void Insert_tLog(void); |
|---|
| 62 | void Update_tLog(char *cRowid); |
|---|
| 63 | void ProcesstLogListVars(pentry entries[], int x); |
|---|
| 64 | |
|---|
| 65 | //In tLogfunc.h file included below |
|---|
| 66 | void ExtProcesstLogVars(pentry entries[], int x); |
|---|
| 67 | void ExttLogCommands(pentry entries[], int x); |
|---|
| 68 | void ExttLogButtons(void); |
|---|
| 69 | void ExttLogNavBar(void); |
|---|
| 70 | void ExttLogGetHook(entry gentries[], int x); |
|---|
| 71 | void ExttLogSelect(void); |
|---|
| 72 | void ExttLogSelectRow(void); |
|---|
| 73 | void ExttLogListSelect(void); |
|---|
| 74 | void ExttLogListFilter(void); |
|---|
| 75 | void ExttLogAuxTable(void); |
|---|
| 76 | |
|---|
| 77 | #include "tlogfunc.h" |
|---|
| 78 | |
|---|
| 79 | //Table Variables Assignment Function |
|---|
| 80 | void ProcesstLogVars(pentry entries[], int x) |
|---|
| 81 | { |
|---|
| 82 | register int i; |
|---|
| 83 | |
|---|
| 84 | |
|---|
| 85 | for(i=0;i<x;i++) |
|---|
| 86 | { |
|---|
| 87 | if(!strcmp(entries[i].name,"uLog")) |
|---|
| 88 | sscanf(entries[i].val,"%u",&uLog); |
|---|
| 89 | else if(!strcmp(entries[i].name,"cLabel")) |
|---|
| 90 | sprintf(cLabel,"%.64s",entries[i].val); |
|---|
| 91 | else if(!strcmp(entries[i].name,"uLogType")) |
|---|
| 92 | sscanf(entries[i].val,"%u",&uLogType); |
|---|
| 93 | else if(!strcmp(entries[i].name,"cuLogTypePullDown")) |
|---|
| 94 | { |
|---|
| 95 | sprintf(cuLogTypePullDown,"%.255s",entries[i].val); |
|---|
| 96 | uLogType=ReadPullDown("tLogType","cLabel",cuLogTypePullDown); |
|---|
| 97 | } |
|---|
| 98 | else if(!strcmp(entries[i].name,"cHash")) |
|---|
| 99 | sprintf(cHash,"%.32s",entries[i].val); |
|---|
| 100 | else if(!strcmp(entries[i].name,"uPermLevel")) |
|---|
| 101 | sscanf(entries[i].val,"%u",&uPermLevel); |
|---|
| 102 | else if(!strcmp(entries[i].name,"uLoginClient")) |
|---|
| 103 | sscanf(entries[i].val,"%u",&uLoginClient); |
|---|
| 104 | else if(!strcmp(entries[i].name,"cLogin")) |
|---|
| 105 | sprintf(cLogin,"%.32s",entries[i].val); |
|---|
| 106 | else if(!strcmp(entries[i].name,"cHost")) |
|---|
| 107 | sprintf(cHost,"%.32s",entries[i].val); |
|---|
| 108 | else if(!strcmp(entries[i].name,"uTablePK")) |
|---|
| 109 | sprintf(uTablePK,"%.32s",entries[i].val); |
|---|
| 110 | else if(!strcmp(entries[i].name,"cTableName")) |
|---|
| 111 | sprintf(cTableName,"%.32s",entries[i].val); |
|---|
| 112 | else if(!strcmp(entries[i].name,"cMessage")) |
|---|
| 113 | sprintf(cMessage,"%.255s",entries[i].val); |
|---|
| 114 | else if(!strcmp(entries[i].name,"cServer")) |
|---|
| 115 | sprintf(cServer,"%.64s",entries[i].val); |
|---|
| 116 | else if(!strcmp(entries[i].name,"uOwner")) |
|---|
| 117 | sscanf(entries[i].val,"%u",&uOwner); |
|---|
| 118 | else if(!strcmp(entries[i].name,"uCreatedBy")) |
|---|
| 119 | sscanf(entries[i].val,"%u",&uCreatedBy); |
|---|
| 120 | else if(!strcmp(entries[i].name,"uCreatedDate")) |
|---|
| 121 | sscanf(entries[i].val,"%lu",&uCreatedDate); |
|---|
| 122 | else if(!strcmp(entries[i].name,"uModBy")) |
|---|
| 123 | sscanf(entries[i].val,"%u",&uModBy); |
|---|
| 124 | else if(!strcmp(entries[i].name,"uModDate")) |
|---|
| 125 | sscanf(entries[i].val,"%lu",&uModDate); |
|---|
| 126 | |
|---|
| 127 | } |
|---|
| 128 | |
|---|
| 129 | //After so we can overwrite form data if needed. |
|---|
| 130 | ExtProcesstLogVars(entries,x); |
|---|
| 131 | |
|---|
| 132 | }//ProcesstLogVars() |
|---|
| 133 | |
|---|
| 134 | |
|---|
| 135 | void ProcesstLogListVars(pentry entries[], int x) |
|---|
| 136 | { |
|---|
| 137 | register int i; |
|---|
| 138 | |
|---|
| 139 | for(i=0;i<x;i++) |
|---|
| 140 | { |
|---|
| 141 | if(!strncmp(entries[i].name,"ED",2)) |
|---|
| 142 | { |
|---|
| 143 | sscanf(entries[i].name+2,"%u",&uLog); |
|---|
| 144 | guMode=2002; |
|---|
| 145 | tLog(""); |
|---|
| 146 | } |
|---|
| 147 | } |
|---|
| 148 | }//void ProcesstLogListVars(pentry entries[], int x) |
|---|
| 149 | |
|---|
| 150 | |
|---|
| 151 | int tLogCommands(pentry entries[], int x) |
|---|
| 152 | { |
|---|
| 153 | ProcessControlVars(entries,x); |
|---|
| 154 | |
|---|
| 155 | ExttLogCommands(entries,x); |
|---|
| 156 | |
|---|
| 157 | if(!strcmp(gcFunction,"tLogTools")) |
|---|
| 158 | { |
|---|
| 159 | if(!strcmp(gcFind,LANG_NB_LIST)) |
|---|
| 160 | { |
|---|
| 161 | tLogList(); |
|---|
| 162 | } |
|---|
| 163 | |
|---|
| 164 | //Default |
|---|
| 165 | ProcesstLogVars(entries,x); |
|---|
| 166 | tLog(""); |
|---|
| 167 | } |
|---|
| 168 | else if(!strcmp(gcFunction,"tLogList")) |
|---|
| 169 | { |
|---|
| 170 | ProcessControlVars(entries,x); |
|---|
| 171 | ProcesstLogListVars(entries,x); |
|---|
| 172 | tLogList(); |
|---|
| 173 | } |
|---|
| 174 | |
|---|
| 175 | return(0); |
|---|
| 176 | |
|---|
| 177 | }//tLogCommands() |
|---|
| 178 | |
|---|
| 179 | |
|---|
| 180 | void tLog(const char *cResult) |
|---|
| 181 | { |
|---|
| 182 | MYSQL_RES *res; |
|---|
| 183 | MYSQL_RES *res2; |
|---|
| 184 | MYSQL_ROW field; |
|---|
| 185 | |
|---|
| 186 | //Internal skip reloading |
|---|
| 187 | if(!cResult[0]) |
|---|
| 188 | { |
|---|
| 189 | if(guMode) |
|---|
| 190 | ExttLogSelectRow(); |
|---|
| 191 | else |
|---|
| 192 | ExttLogSelect(); |
|---|
| 193 | |
|---|
| 194 | mysql_query(&gMysql,gcQuery); |
|---|
| 195 | if(mysql_errno(&gMysql)) |
|---|
| 196 | { |
|---|
| 197 | if(strstr(mysql_error(&gMysql)," doesn't exist")) |
|---|
| 198 | { |
|---|
| 199 | CreatetLog(); |
|---|
| 200 | unxsVZ("New tLog table created"); |
|---|
| 201 | } |
|---|
| 202 | else |
|---|
| 203 | { |
|---|
| 204 | htmlPlainTextError(mysql_error(&gMysql)); |
|---|
| 205 | } |
|---|
| 206 | } |
|---|
| 207 | |
|---|
| 208 | res=mysql_store_result(&gMysql); |
|---|
| 209 | if((guI=mysql_num_rows(res))) |
|---|
| 210 | { |
|---|
| 211 | if(guMode==6) |
|---|
| 212 | { |
|---|
| 213 | sprintf(gcQuery,"SELECT _rowid FROM tLog WHERE uLog=%u" |
|---|
| 214 | ,uLog); |
|---|
| 215 | MYSQL_RUN_STORE(res2); |
|---|
| 216 | field=mysql_fetch_row(res2); |
|---|
| 217 | sscanf(field[0],"%lu",&gluRowid); |
|---|
| 218 | gluRowid++; |
|---|
| 219 | } |
|---|
| 220 | PageMachine("",0,""); |
|---|
| 221 | if(!guMode) mysql_data_seek(res,gluRowid-1); |
|---|
| 222 | field=mysql_fetch_row(res); |
|---|
| 223 | sscanf(field[0],"%u",&uLog); |
|---|
| 224 | sprintf(cLabel,"%.64s",field[1]); |
|---|
| 225 | sscanf(field[2],"%u",&uLogType); |
|---|
| 226 | sprintf(cHash,"%.32s",field[3]); |
|---|
| 227 | sscanf(field[4],"%u",&uPermLevel); |
|---|
| 228 | sscanf(field[5],"%u",&uLoginClient); |
|---|
| 229 | sprintf(cLogin,"%.32s",field[6]); |
|---|
| 230 | sprintf(cHost,"%.32s",field[7]); |
|---|
| 231 | sprintf(uTablePK,"%.32s",field[8]); |
|---|
| 232 | sprintf(cTableName,"%.32s",field[9]); |
|---|
| 233 | sprintf(cMessage,"%.255s",field[10]); |
|---|
| 234 | sprintf(cServer,"%.64s",field[11]); |
|---|
| 235 | sscanf(field[12],"%u",&uOwner); |
|---|
| 236 | sscanf(field[13],"%u",&uCreatedBy); |
|---|
| 237 | sscanf(field[14],"%lu",&uCreatedDate); |
|---|
| 238 | sscanf(field[15],"%u",&uModBy); |
|---|
| 239 | sscanf(field[16],"%lu",&uModDate); |
|---|
| 240 | |
|---|
| 241 | } |
|---|
| 242 | |
|---|
| 243 | }//Internal Skip |
|---|
| 244 | |
|---|
| 245 | Header_ism3(":: tLog",0); |
|---|
| 246 | printf("<table width=100%% cellspacing=0 cellpadding=0>\n"); |
|---|
| 247 | printf("<tr><td colspan=2 align=right valign=center>"); |
|---|
| 248 | |
|---|
| 249 | |
|---|
| 250 | printf("<input type=hidden name=gcFunction value=tLogTools>"); |
|---|
| 251 | printf("<input type=hidden name=gluRowid value=%lu>",gluRowid); |
|---|
| 252 | if(guI) |
|---|
| 253 | { |
|---|
| 254 | if(guMode==6) |
|---|
| 255 | //printf(" Found"); |
|---|
| 256 | printf(LANG_NBR_FOUND); |
|---|
| 257 | else if(guMode==5) |
|---|
| 258 | //printf(" Modified"); |
|---|
| 259 | printf(LANG_NBR_MODIFIED); |
|---|
| 260 | else if(guMode==4) |
|---|
| 261 | //printf(" New"); |
|---|
| 262 | printf(LANG_NBR_NEW); |
|---|
| 263 | printf(LANG_NBRF_SHOWING,gluRowid,guI); |
|---|
| 264 | } |
|---|
| 265 | else |
|---|
| 266 | { |
|---|
| 267 | if(!cResult[0]) |
|---|
| 268 | //printf(" No records found"); |
|---|
| 269 | printf(LANG_NBR_NORECS); |
|---|
| 270 | } |
|---|
| 271 | if(cResult[0]) printf("%s",cResult); |
|---|
| 272 | printf("</td></tr>"); |
|---|
| 273 | printf("<tr><td valign=top width=25%%>"); |
|---|
| 274 | |
|---|
| 275 | ExttLogButtons(); |
|---|
| 276 | |
|---|
| 277 | printf("</td><td valign=top>"); |
|---|
| 278 | // |
|---|
| 279 | OpenFieldSet("tLog Record Data",100); |
|---|
| 280 | |
|---|
| 281 | if(guMode==2000 || guMode==2002) |
|---|
| 282 | tLogInput(1); |
|---|
| 283 | else |
|---|
| 284 | tLogInput(0); |
|---|
| 285 | |
|---|
| 286 | // |
|---|
| 287 | CloseFieldSet(); |
|---|
| 288 | |
|---|
| 289 | //Bottom table |
|---|
| 290 | printf("<tr><td colspan=2>"); |
|---|
| 291 | ExttLogAuxTable(); |
|---|
| 292 | |
|---|
| 293 | Footer_ism3(); |
|---|
| 294 | |
|---|
| 295 | }//end of tLog(); |
|---|
| 296 | |
|---|
| 297 | |
|---|
| 298 | void tLogInput(unsigned uMode) |
|---|
| 299 | { |
|---|
| 300 | |
|---|
| 301 | //uLog |
|---|
| 302 | OpenRow(LANG_FL_tLog_uLog,"black"); |
|---|
| 303 | printf("<input title='%s' type=text name=uLog value=%u size=16 maxlength=10 " |
|---|
| 304 | ,LANG_FT_tLog_uLog,uLog); |
|---|
| 305 | if(guPermLevel>=20 && uMode) |
|---|
| 306 | { |
|---|
| 307 | printf("></td></tr>\n"); |
|---|
| 308 | } |
|---|
| 309 | else |
|---|
| 310 | { |
|---|
| 311 | printf("disabled></td></tr>\n"); |
|---|
| 312 | printf("<input type=hidden name=uLog value=%u >\n",uLog); |
|---|
| 313 | } |
|---|
| 314 | //cLabel |
|---|
| 315 | OpenRow(LANG_FL_tLog_cLabel,"black"); |
|---|
| 316 | printf("<input title='%s' type=text name=cLabel value=\"%s\" size=64 maxlength=64 " |
|---|
| 317 | ,LANG_FT_tLog_cLabel,EncodeDoubleQuotes(cLabel)); |
|---|
| 318 | if(guPermLevel>=0 && uMode) |
|---|
| 319 | { |
|---|
| 320 | printf("></td></tr>\n"); |
|---|
| 321 | } |
|---|
| 322 | else |
|---|
| 323 | { |
|---|
| 324 | printf("disabled></td></tr>\n"); |
|---|
| 325 | printf("<input type=hidden name=cLabel value=\"%s\">\n",EncodeDoubleQuotes(cLabel)); |
|---|
| 326 | } |
|---|
| 327 | //uLogType |
|---|
| 328 | OpenRow(LANG_FL_tLog_uLogType,"black"); |
|---|
| 329 | if(guPermLevel>=7 && uMode) |
|---|
| 330 | tTablePullDown("tLogType;cuLogTypePullDown","cLabel","cLabel",uLogType,1); |
|---|
| 331 | else |
|---|
| 332 | tTablePullDown("tLogType;cuLogTypePullDown","cLabel","cLabel",uLogType,0); |
|---|
| 333 | //cHash |
|---|
| 334 | OpenRow(LANG_FL_tLog_cHash,"black"); |
|---|
| 335 | printf("<input title='%s' type=text name=cHash value=\"%s\" size=40 maxlength=32 " |
|---|
| 336 | ,LANG_FT_tLog_cHash,EncodeDoubleQuotes(cHash)); |
|---|
| 337 | if(guPermLevel>=7 && uMode) |
|---|
| 338 | { |
|---|
| 339 | printf("></td></tr>\n"); |
|---|
| 340 | } |
|---|
| 341 | else |
|---|
| 342 | { |
|---|
| 343 | printf("disabled></td></tr>\n"); |
|---|
| 344 | printf("<input type=hidden name=cHash value=\"%s\">\n",EncodeDoubleQuotes(cHash)); |
|---|
| 345 | } |
|---|
| 346 | //uPermLevel |
|---|
| 347 | OpenRow(LANG_FL_tLog_uPermLevel,"black"); |
|---|
| 348 | printf("<input title='%s' type=text name=uPermLevel value=%u size=16 maxlength=32 " |
|---|
| 349 | ,LANG_FT_tLog_uPermLevel,uPermLevel); |
|---|
| 350 | if(guPermLevel>=7 && uMode) |
|---|
| 351 | { |
|---|
| 352 | printf("></td></tr>\n"); |
|---|
| 353 | } |
|---|
| 354 | else |
|---|
| 355 | { |
|---|
| 356 | printf("disabled></td></tr>\n"); |
|---|
| 357 | printf("<input type=hidden name=uPermLevel value=%u >\n",uPermLevel); |
|---|
| 358 | } |
|---|
| 359 | //uLoginClient |
|---|
| 360 | OpenRow(LANG_FL_tLog_uLoginClient,"black"); |
|---|
| 361 | printf("<input title='%s' type=text name=uLoginClient value=%u size=16 maxlength=32 " |
|---|
| 362 | ,LANG_FT_tLog_uLoginClient,uLoginClient); |
|---|
| 363 | if(guPermLevel>=7 && uMode) |
|---|
| 364 | { |
|---|
| 365 | printf("></td></tr>\n"); |
|---|
| 366 | } |
|---|
| 367 | else |
|---|
| 368 | { |
|---|
| 369 | printf("disabled></td></tr>\n"); |
|---|
| 370 | printf("<input type=hidden name=uLoginClient value=%u >\n",uLoginClient); |
|---|
| 371 | } |
|---|
| 372 | //cLogin |
|---|
| 373 | OpenRow(LANG_FL_tLog_cLogin,"black"); |
|---|
| 374 | printf("<input title='%s' type=text name=cLogin value=\"%s\" size=40 maxlength=32 " |
|---|
| 375 | ,LANG_FT_tLog_cLogin,EncodeDoubleQuotes(cLogin)); |
|---|
| 376 | if(guPermLevel>=7 && uMode) |
|---|
| 377 | { |
|---|
| 378 | printf("></td></tr>\n"); |
|---|
| 379 | } |
|---|
| 380 | else |
|---|
| 381 | { |
|---|
| 382 | printf("disabled></td></tr>\n"); |
|---|
| 383 | printf("<input type=hidden name=cLogin value=\"%s\">\n",EncodeDoubleQuotes(cLogin)); |
|---|
| 384 | } |
|---|
| 385 | //cHost |
|---|
| 386 | OpenRow(LANG_FL_tLog_cHost,"black"); |
|---|
| 387 | printf("<input title='%s' type=text name=cHost value=\"%s\" size=40 maxlength=32 " |
|---|
| 388 | ,LANG_FT_tLog_cHost,EncodeDoubleQuotes(cHost)); |
|---|
| 389 | if(guPermLevel>=7 && uMode) |
|---|
| 390 | { |
|---|
| 391 | printf("></td></tr>\n"); |
|---|
| 392 | } |
|---|
| 393 | else |
|---|
| 394 | { |
|---|
| 395 | printf("disabled></td></tr>\n"); |
|---|
| 396 | printf("<input type=hidden name=cHost value=\"%s\">\n",EncodeDoubleQuotes(cHost)); |
|---|
| 397 | } |
|---|
| 398 | //uTablePK |
|---|
| 399 | OpenRow(LANG_FL_tLog_uTablePK,"black"); |
|---|
| 400 | printf("<input title='%s' type=text name=uTablePK value=\"%s\" size=40 maxlength=32 " |
|---|
| 401 | ,LANG_FT_tLog_uTablePK,EncodeDoubleQuotes(uTablePK)); |
|---|
| 402 | if(guPermLevel>=7 && uMode) |
|---|
| 403 | { |
|---|
| 404 | printf("></td></tr>\n"); |
|---|
| 405 | } |
|---|
| 406 | else |
|---|
| 407 | { |
|---|
| 408 | printf("disabled></td></tr>\n"); |
|---|
| 409 | printf("<input type=hidden name=uTablePK value=\"%s\">\n",EncodeDoubleQuotes(uTablePK)); |
|---|
| 410 | } |
|---|
| 411 | //cTableName |
|---|
| 412 | OpenRow(LANG_FL_tLog_cTableName,"black"); |
|---|
| 413 | printf("<input title='%s' type=text name=cTableName value=\"%s\" size=40 maxlength=32 " |
|---|
| 414 | ,LANG_FT_tLog_cTableName,EncodeDoubleQuotes(cTableName)); |
|---|
| 415 | if(guPermLevel>=7 && uMode) |
|---|
| 416 | { |
|---|
| 417 | printf("></td></tr>\n"); |
|---|
| 418 | } |
|---|
| 419 | else |
|---|
| 420 | { |
|---|
| 421 | printf("disabled></td></tr>\n"); |
|---|
| 422 | printf("<input type=hidden name=cTableName value=\"%s\">\n",EncodeDoubleQuotes(cTableName)); |
|---|
| 423 | } |
|---|
| 424 | //cMessage |
|---|
| 425 | OpenRow(LANG_FL_tLog_cMessage,"black"); |
|---|
| 426 | printf("<input title='%s' type=text name=cMessage value=\"%s\" size=40 maxlength=255 " |
|---|
| 427 | ,LANG_FT_tLog_cMessage,EncodeDoubleQuotes(cMessage)); |
|---|
| 428 | if(guPermLevel>=7 && uMode) |
|---|
| 429 | { |
|---|
| 430 | printf("></td></tr>\n"); |
|---|
| 431 | } |
|---|
| 432 | else |
|---|
| 433 | { |
|---|
| 434 | printf("disabled></td></tr>\n"); |
|---|
| 435 | printf("<input type=hidden name=cMessage value=\"%s\">\n",EncodeDoubleQuotes(cMessage)); |
|---|
| 436 | } |
|---|
| 437 | //cServer |
|---|
| 438 | OpenRow(LANG_FL_tLog_cServer,"black"); |
|---|
| 439 | printf("<input title='%s' type=text name=cServer value=\"%s\" size=40 maxlength=64 " |
|---|
| 440 | ,LANG_FT_tLog_cServer,EncodeDoubleQuotes(cServer)); |
|---|
| 441 | if(guPermLevel>=7 && uMode) |
|---|
| 442 | { |
|---|
| 443 | printf("></td></tr>\n"); |
|---|
| 444 | } |
|---|
| 445 | else |
|---|
| 446 | { |
|---|
| 447 | printf("disabled></td></tr>\n"); |
|---|
| 448 | printf("<input type=hidden name=cServer value=\"%s\">\n",EncodeDoubleQuotes(cServer)); |
|---|
| 449 | } |
|---|
| 450 | //uOwner |
|---|
| 451 | OpenRow(LANG_FL_tLog_uOwner,"black"); |
|---|
| 452 | if(guPermLevel>=20 && uMode) |
|---|
| 453 | printf("%s<input type=hidden name=uOwner value=%u >\n",ForeignKey("tClient","cLabel",uOwner),uOwner); |
|---|
| 454 | else |
|---|
| 455 | printf("%s<input type=hidden name=uOwner value=%u >\n",ForeignKey("tClient","cLabel",uOwner),uOwner); |
|---|
| 456 | //uCreatedBy |
|---|
| 457 | OpenRow(LANG_FL_tLog_uCreatedBy,"black"); |
|---|
| 458 | if(guPermLevel>=20 && uMode) |
|---|
| 459 | printf("%s<input type=hidden name=uCreatedBy value=%u >\n", |
|---|
| 460 | ForeignKey("tClient","cLabel",uCreatedBy),uCreatedBy); |
|---|
| 461 | else |
|---|
| 462 | printf("%s<input type=hidden name=uCreatedBy value=%u >\n", |
|---|
| 463 | ForeignKey("tClient","cLabel",uCreatedBy),uCreatedBy); |
|---|
| 464 | //uCreatedDate |
|---|
| 465 | OpenRow(LANG_FL_tLog_uCreatedDate,"black"); |
|---|
| 466 | if(uCreatedDate) |
|---|
| 467 | printf("%s\n\n",ctime(&uCreatedDate)); |
|---|
| 468 | else |
|---|
| 469 | printf("---\n\n"); |
|---|
| 470 | printf("<input type=hidden name=uCreatedDate value=%lu >\n",uCreatedDate); |
|---|
| 471 | //uModBy |
|---|
| 472 | OpenRow(LANG_FL_tLog_uModBy,"black"); |
|---|
| 473 | if(guPermLevel>=20 && uMode) |
|---|
| 474 | printf("%s<input type=hidden name=uModBy value=%u >\n",ForeignKey("tClient","cLabel",uModBy),uModBy); |
|---|
| 475 | else |
|---|
| 476 | printf("%s<input type=hidden name=uModBy value=%u >\n",ForeignKey("tClient","cLabel",uModBy),uModBy); |
|---|
| 477 | //uModDate |
|---|
| 478 | OpenRow(LANG_FL_tLog_uModDate,"black"); |
|---|
| 479 | if(uModDate) |
|---|
| 480 | printf("%s\n\n",ctime(&uModDate)); |
|---|
| 481 | else |
|---|
| 482 | printf("---\n\n"); |
|---|
| 483 | printf("<input type=hidden name=uModDate value=%lu >\n",uModDate); |
|---|
| 484 | printf("</tr>\n"); |
|---|
| 485 | |
|---|
| 486 | }//void tLogInput(unsigned uMode) |
|---|
| 487 | |
|---|
| 488 | |
|---|
| 489 | void NewtLog(unsigned uMode) |
|---|
| 490 | { |
|---|
| 491 | register int i=0; |
|---|
| 492 | MYSQL_RES *res; |
|---|
| 493 | |
|---|
| 494 | sprintf(gcQuery,"SELECT uLog FROM tLog WHERE uLog=%u",uLog); |
|---|
| 495 | MYSQL_RUN_STORE(res); |
|---|
| 496 | i=mysql_num_rows(res); |
|---|
| 497 | |
|---|
| 498 | if(i) |
|---|
| 499 | //tLog("<blink>Record already exists"); |
|---|
| 500 | tLog(LANG_NBR_RECEXISTS); |
|---|
| 501 | |
|---|
| 502 | //insert query |
|---|
| 503 | Insert_tLog(); |
|---|
| 504 | if(mysql_errno(&gMysql)) htmlPlainTextError(mysql_error(&gMysql)); |
|---|
| 505 | //sprintf(gcQuery,"New record %u added"); |
|---|
| 506 | uLog=mysql_insert_id(&gMysql); |
|---|
| 507 | uCreatedDate=luGetCreatedDate("tLog",uLog); |
|---|
| 508 | unxsVZLog(uLog,"tLog","New"); |
|---|
| 509 | |
|---|
| 510 | if(!uMode) |
|---|
| 511 | { |
|---|
| 512 | sprintf(gcQuery,LANG_NBR_NEWRECADDED,uLog); |
|---|
| 513 | tLog(gcQuery); |
|---|
| 514 | } |
|---|
| 515 | |
|---|
| 516 | }//NewtLog(unsigned uMode) |
|---|
| 517 | |
|---|
| 518 | |
|---|
| 519 | void DeletetLog(void) |
|---|
| 520 | { |
|---|
| 521 | sprintf(gcQuery,"DELETE FROM tLog WHERE uLog=%u AND ( uOwner=%u OR %u>9 )",uLog,guLoginClient,guPermLevel); |
|---|
| 522 | MYSQL_RUN; |
|---|
| 523 | //tLog("Record Deleted"); |
|---|
| 524 | if(mysql_affected_rows(&gMysql)>0) |
|---|
| 525 | { |
|---|
| 526 | unxsVZLog(uLog,"tLog","Del"); |
|---|
| 527 | tLog(LANG_NBR_RECDELETED); |
|---|
| 528 | } |
|---|
| 529 | else |
|---|
| 530 | { |
|---|
| 531 | unxsVZLog(uLog,"tLog","DelError"); |
|---|
| 532 | tLog(LANG_NBR_RECNOTDELETED); |
|---|
| 533 | } |
|---|
| 534 | |
|---|
| 535 | }//void DeletetLog(void) |
|---|
| 536 | |
|---|
| 537 | |
|---|
| 538 | void Insert_tLog(void) |
|---|
| 539 | { |
|---|
| 540 | sprintf(gcQuery,"INSERT INTO tLog SET uLog=%u,cLabel='%s',uLogType=%u,cHash='%s',uPermLevel=%u,uLoginClient=%u," |
|---|
| 541 | "cLogin='%s',cHost='%s',uTablePK='%s',cTableName='%s',cMessage='%s',cServer='%s',uOwner=%u," |
|---|
| 542 | "uCreatedBy=%u,uCreatedDate=UNIX_TIMESTAMP(NOW())", |
|---|
| 543 | uLog |
|---|
| 544 | ,TextAreaSave(cLabel) |
|---|
| 545 | ,uLogType |
|---|
| 546 | ,TextAreaSave(cHash) |
|---|
| 547 | ,uPermLevel |
|---|
| 548 | ,uLoginClient |
|---|
| 549 | ,TextAreaSave(cLogin) |
|---|
| 550 | ,TextAreaSave(cHost) |
|---|
| 551 | ,TextAreaSave(uTablePK) |
|---|
| 552 | ,TextAreaSave(cTableName) |
|---|
| 553 | ,TextAreaSave(cMessage) |
|---|
| 554 | ,TextAreaSave(cServer) |
|---|
| 555 | ,uOwner |
|---|
| 556 | ,uCreatedBy |
|---|
| 557 | ); |
|---|
| 558 | MYSQL_RUN; |
|---|
| 559 | }//void Insert_tLog(void) |
|---|
| 560 | |
|---|
| 561 | |
|---|
| 562 | void Update_tLog(char *cRowid) |
|---|
| 563 | { |
|---|
| 564 | sprintf(gcQuery,"UPDATE tLog SET uLog=%u,cLabel='%s',uLogType=%u,cHash='%s',uPermLevel=%u,uLoginClient=%u," |
|---|
| 565 | "cLogin='%s',cHost='%s',uTablePK='%s',cTableName='%s',cMessage='%s',cServer='%s',uModBy=%u," |
|---|
| 566 | "uModDate=UNIX_TIMESTAMP(NOW()) WHERE _rowid=%s", |
|---|
| 567 | uLog |
|---|
| 568 | ,TextAreaSave(cLabel) |
|---|
| 569 | ,uLogType |
|---|
| 570 | ,TextAreaSave(cHash) |
|---|
| 571 | ,uPermLevel |
|---|
| 572 | ,uLoginClient |
|---|
| 573 | ,TextAreaSave(cLogin) |
|---|
| 574 | ,TextAreaSave(cHost) |
|---|
| 575 | ,TextAreaSave(uTablePK) |
|---|
| 576 | ,TextAreaSave(cTableName) |
|---|
| 577 | ,TextAreaSave(cMessage) |
|---|
| 578 | ,TextAreaSave(cServer) |
|---|
| 579 | ,uModBy |
|---|
| 580 | ,cRowid); |
|---|
| 581 | MYSQL_RUN; |
|---|
| 582 | }//void Update_tLog(void) |
|---|
| 583 | |
|---|
| 584 | |
|---|
| 585 | void ModtLog(void) |
|---|
| 586 | { |
|---|
| 587 | register int i=0; |
|---|
| 588 | MYSQL_RES *res; |
|---|
| 589 | MYSQL_ROW field; |
|---|
| 590 | unsigned uPreModDate=0; |
|---|
| 591 | |
|---|
| 592 | //Mod select gcQuery |
|---|
| 593 | if(guPermLevel<10) |
|---|
| 594 | sprintf(gcQuery,"SELECT tLog.uLog,tLog.uModDate FROM tLog,tClient WHERE tLog.uLog=%u AND" |
|---|
| 595 | " tLog.uOwner=tClient.uClient AND (tClient.uOwner=%u OR tClient.uClient=%u)", |
|---|
| 596 | uLog,guLoginClient,guLoginClient); |
|---|
| 597 | else |
|---|
| 598 | sprintf(gcQuery,"SELECT uLog,uModDate FROM tLog WHERE uLog=%u",uLog); |
|---|
| 599 | |
|---|
| 600 | MYSQL_RUN_STORE(res); |
|---|
| 601 | i=mysql_num_rows(res); |
|---|
| 602 | |
|---|
| 603 | //if(i<1) tLog("<blink>Record does not exist"); |
|---|
| 604 | if(i<1) tLog(LANG_NBR_RECNOTEXIST); |
|---|
| 605 | //if(i>1) tLog("<blink>Multiple rows!"); |
|---|
| 606 | if(i>1) tLog(LANG_NBR_MULTRECS); |
|---|
| 607 | |
|---|
| 608 | field=mysql_fetch_row(res); |
|---|
| 609 | sscanf(field[1],"%u",&uPreModDate); |
|---|
| 610 | if(uPreModDate!=uModDate) tLog(LANG_NBR_EXTMOD); |
|---|
| 611 | |
|---|
| 612 | Update_tLog(field[0]); |
|---|
| 613 | if(mysql_errno(&gMysql)) htmlPlainTextError(mysql_error(&gMysql)); |
|---|
| 614 | //sprintf(query,"record %s modified",field[0]); |
|---|
| 615 | sprintf(gcQuery,LANG_NBRF_REC_MODIFIED,field[0]); |
|---|
| 616 | uModDate=luGetModDate("tLog",uLog); |
|---|
| 617 | unxsVZLog(uLog,"tLog","Mod"); |
|---|
| 618 | tLog(gcQuery); |
|---|
| 619 | |
|---|
| 620 | }//ModtLog(void) |
|---|
| 621 | |
|---|
| 622 | |
|---|
| 623 | void tLogList(void) |
|---|
| 624 | { |
|---|
| 625 | MYSQL_RES *res; |
|---|
| 626 | MYSQL_ROW field; |
|---|
| 627 | |
|---|
| 628 | ExttLogListSelect(); |
|---|
| 629 | |
|---|
| 630 | MYSQL_RUN_STORE(res); |
|---|
| 631 | guI=mysql_num_rows(res); |
|---|
| 632 | |
|---|
| 633 | PageMachine("tLogList",1,"");//1 is auto header list guMode. Opens table! |
|---|
| 634 | |
|---|
| 635 | //Filter select drop down |
|---|
| 636 | ExttLogListFilter(); |
|---|
| 637 | |
|---|
| 638 | printf("<input type=text size=16 name=gcCommand maxlength=98 value=\"%s\" >",gcCommand); |
|---|
| 639 | |
|---|
| 640 | printf("</table>\n"); |
|---|
| 641 | |
|---|
| 642 | printf("<table bgcolor=#9BC1B3 border=0 width=100%%>\n"); |
|---|
| 643 | printf("<tr bgcolor=black><td><font face=arial,helvetica color=white>uLog<td><font face=arial,helvetica color=white>" |
|---|
| 644 | "cLabel<td><font face=arial,helvetica color=white>uLogType<td><font face=arial,helvetica color=white>" |
|---|
| 645 | "cHash<td><font face=arial,helvetica color=white>uPermLevel<td><font face=arial,helvetica color=white>" |
|---|
| 646 | "uLoginClient<td><font face=arial,helvetica color=white>cLogin<td><font face=arial,helvetica color=white>" |
|---|
| 647 | "cHost<td><font face=arial,helvetica color=white>uTablePK<td><font face=arial,helvetica color=white>" |
|---|
| 648 | "cTableName<td><font face=arial,helvetica color=white>cMessage<td><font face=arial,helvetica color=white>" |
|---|
| 649 | "cServer<td><font face=arial,helvetica color=white>uOwner<td><font face=arial,helvetica color=white>" |
|---|
| 650 | "uCreatedBy<td><font face=arial,helvetica color=white>uCreatedDate<td><font face=arial,helvetica color=white>" |
|---|
| 651 | "uModBy<td><font face=arial,helvetica color=white>uModDate</tr>"); |
|---|
| 652 | |
|---|
| 653 | mysql_data_seek(res,guStart-1); |
|---|
| 654 | |
|---|
| 655 | for(guN=0;guN<(guEnd-guStart+1);guN++) |
|---|
| 656 | { |
|---|
| 657 | field=mysql_fetch_row(res); |
|---|
| 658 | if(!field) |
|---|
| 659 | { |
|---|
| 660 | printf("<tr><td><font face=arial,helvetica>End of data</table>"); |
|---|
| 661 | Footer_ism3(); |
|---|
| 662 | } |
|---|
| 663 | if(guN % 2) |
|---|
| 664 | printf("<tr bgcolor=#BBE1D3>"); |
|---|
| 665 | else |
|---|
| 666 | printf("<tr>"); |
|---|
| 667 | time_t luTime14=strtoul(field[14],NULL,10); |
|---|
| 668 | char cBuf14[32]; |
|---|
| 669 | if(luTime14) |
|---|
| 670 | ctime_r(&luTime14,cBuf14); |
|---|
| 671 | else |
|---|
| 672 | sprintf(cBuf14,"---"); |
|---|
| 673 | time_t luTime16=strtoul(field[16],NULL,10); |
|---|
| 674 | char cBuf16[32]; |
|---|
| 675 | if(luTime16) |
|---|
| 676 | ctime_r(&luTime16,cBuf16); |
|---|
| 677 | else |
|---|
| 678 | sprintf(cBuf16,"---"); |
|---|
| 679 | 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>" |
|---|
| 680 | "%s<td>%s<td>%s<td>%s<td>%s<td>%s<td>%s<td>%s<td>%s</tr>" |
|---|
| 681 | ,field[0] |
|---|
| 682 | ,field[0] |
|---|
| 683 | ,field[1] |
|---|
| 684 | ,ForeignKey("tLogType","cLabel",strtoul(field[2],NULL,10)) |
|---|
| 685 | ,field[3] |
|---|
| 686 | ,field[4] |
|---|
| 687 | ,field[5] |
|---|
| 688 | ,field[6] |
|---|
| 689 | ,field[7] |
|---|
| 690 | ,field[8] |
|---|
| 691 | ,field[9] |
|---|
| 692 | ,field[10] |
|---|
| 693 | ,field[11] |
|---|
| 694 | ,ForeignKey("tClient","cLabel",strtoul(field[12],NULL,10)) |
|---|
| 695 | ,ForeignKey("tClient","cLabel",strtoul(field[13],NULL,10)) |
|---|
| 696 | ,cBuf14 |
|---|
| 697 | ,ForeignKey("tClient","cLabel",strtoul(field[15],NULL,10)) |
|---|
| 698 | ,cBuf16 |
|---|
| 699 | ); |
|---|
| 700 | } |
|---|
| 701 | |
|---|
| 702 | printf("</table></form>\n"); |
|---|
| 703 | Footer_ism3(); |
|---|
| 704 | |
|---|
| 705 | }//tLogList() |
|---|
| 706 | |
|---|
| 707 | |
|---|
| 708 | void CreatetLog(void) |
|---|
| 709 | { |
|---|
| 710 | sprintf(gcQuery,"CREATE TABLE IF NOT EXISTS tLog (" |
|---|
| 711 | "uTablePK VARCHAR(32) NOT NULL DEFAULT ''," |
|---|
| 712 | "cHost VARCHAR(32) NOT NULL DEFAULT ''," |
|---|
| 713 | "uLoginClient INT UNSIGNED NOT NULL DEFAULT 0," |
|---|
| 714 | "cLogin VARCHAR(32) NOT NULL DEFAULT ''," |
|---|
| 715 | "uPermLevel INT UNSIGNED NOT NULL DEFAULT 0," |
|---|
| 716 | "cTableName VARCHAR(32) NOT NULL DEFAULT ''," |
|---|
| 717 | "uLog INT UNSIGNED PRIMARY KEY AUTO_INCREMENT," |
|---|
| 718 | "cLabel VARCHAR(64) NOT NULL DEFAULT ''," |
|---|
| 719 | "uOwner INT UNSIGNED NOT NULL DEFAULT 0,INDEX (uOwner)," |
|---|
| 720 | "uCreatedBy INT UNSIGNED NOT NULL DEFAULT 0," |
|---|
| 721 | "uCreatedDate INT UNSIGNED NOT NULL DEFAULT 0," |
|---|
| 722 | "uModBy INT UNSIGNED NOT NULL DEFAULT 0," |
|---|
| 723 | "uModDate INT UNSIGNED NOT NULL DEFAULT 0," |
|---|
| 724 | "cHash VARCHAR(32) NOT NULL DEFAULT ''," |
|---|
| 725 | "uLogType INT UNSIGNED NOT NULL DEFAULT 0,INDEX (uLogType)," |
|---|
| 726 | "cMessage VARCHAR(255) NOT NULL DEFAULT ''," |
|---|
| 727 | "cServer VARCHAR(64) NOT NULL DEFAULT '' )"); |
|---|
| 728 | MYSQL_RUN; |
|---|
| 729 | |
|---|
| 730 | }//CreatetLog() |
|---|
| 731 | |
|---|