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