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