| 1 | /* |
|---|
| 2 | FILE |
|---|
| 3 | tContainer 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 tcontainerfunc.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 | //uContainer: Primary Key |
|---|
| 21 | static unsigned uContainer=0; |
|---|
| 22 | //cLabel: Short label |
|---|
| 23 | static char cLabel[33]={""}; |
|---|
| 24 | //cHostname: FQDN Hostname |
|---|
| 25 | static char cHostname[65]={""}; |
|---|
| 26 | //uVeth default is no which means VENET not VETH networked container |
|---|
| 27 | static unsigned uVeth=0; |
|---|
| 28 | static char cYesNouVeth[32]={""}; |
|---|
| 29 | //uIPv4: First IPv4 Number |
|---|
| 30 | static unsigned uIPv4=0; |
|---|
| 31 | static char cuIPv4PullDown[256]={""}; |
|---|
| 32 | //uOSTemplate: Container OS Template |
|---|
| 33 | static unsigned uOSTemplate=0; |
|---|
| 34 | static char cuOSTemplatePullDown[256]={""}; |
|---|
| 35 | //uConfig: Container Config File Used on Creation |
|---|
| 36 | static unsigned uConfig=0; |
|---|
| 37 | static char cuConfigPullDown[256]={""}; |
|---|
| 38 | //uNameserver: Container Resolver Nameserver Set |
|---|
| 39 | static unsigned uNameserver=0; |
|---|
| 40 | static char cuNameserverPullDown[256]={""}; |
|---|
| 41 | //uSearchdomain: Container Resolver Searchdomain |
|---|
| 42 | static unsigned uSearchdomain=0; |
|---|
| 43 | static char cuSearchdomainPullDown[256]={""}; |
|---|
| 44 | //uDatacenter: Belongs to this Datacenter |
|---|
| 45 | static unsigned uDatacenter=0; |
|---|
| 46 | static char cuDatacenterPullDown[256]={""}; |
|---|
| 47 | //uNode: Running on this Node |
|---|
| 48 | static unsigned uNode=0; |
|---|
| 49 | static char cuNodePullDown[256]={""}; |
|---|
| 50 | //uStatus: Status of Container |
|---|
| 51 | static unsigned uStatus=0; |
|---|
| 52 | //uOwner: Record owner |
|---|
| 53 | static unsigned uOwner=0; |
|---|
| 54 | //uCreatedBy: uClient for last insert |
|---|
| 55 | static unsigned uCreatedBy=0; |
|---|
| 56 | //uCreatedDate: Unix seconds date last insert |
|---|
| 57 | static time_t uCreatedDate=0; |
|---|
| 58 | //uModBy: uClient for last update |
|---|
| 59 | static unsigned uModBy=0; |
|---|
| 60 | //uModDate: Unix seconds date last update |
|---|
| 61 | static time_t uModDate=0; |
|---|
| 62 | //uSource semi HIDDEN for now |
|---|
| 63 | static unsigned uSource=0; |
|---|
| 64 | //uBackupDate: Unix seconds date last insert |
|---|
| 65 | static time_t uBackupDate=0; |
|---|
| 66 | |
|---|
| 67 | //Extensions for searching |
|---|
| 68 | //uStatus: Container tStatus.uStatus |
|---|
| 69 | static unsigned uSearchStatus=0; |
|---|
| 70 | static char cuSearchStatusPullDown[256]={""}; |
|---|
| 71 | static unsigned uSearchStatusNot=0; |
|---|
| 72 | static char cHostnameSearch[64]={""}; |
|---|
| 73 | static char cIPv4Search[16]={""}; |
|---|
| 74 | int ReadYesNoPullDownTriState(const char *cLabel); |
|---|
| 75 | void YesNoPullDownTriState(char *cFieldName, unsigned uSelect, unsigned uMode); |
|---|
| 76 | static unsigned uSearchSource=0; |
|---|
| 77 | static char cYesNouSearchSource[32]={""}; |
|---|
| 78 | |
|---|
| 79 | static char cuClientPullDown[256]={""}; |
|---|
| 80 | static char cAutoCloneNode[256]={""}; |
|---|
| 81 | static char cunxsBindARecordJobZone[256]={""}; |
|---|
| 82 | static char gcNewContainerTZ[64]={"PST8PDT"}; |
|---|
| 83 | |
|---|
| 84 | static char *cCommands={""}; |
|---|
| 85 | |
|---|
| 86 | #define VAR_LIST_tContainer "tContainer.uContainer,tContainer.cLabel,tContainer.cHostname,tContainer.uVeth,tContainer.uIPv4,tContainer.uOSTemplate,tContainer.uConfig,tContainer.uNameserver,tContainer.uSearchdomain,tContainer.uDatacenter,tContainer.uNode,tContainer.uStatus,tContainer.uOwner,tContainer.uCreatedBy,tContainer.uCreatedDate,tContainer.uModBy,tContainer.uModDate,tContainer.uSource,tContainer.uBackupDate" |
|---|
| 87 | |
|---|
| 88 | //Local only |
|---|
| 89 | void tContainerSearchSet(unsigned uStep); |
|---|
| 90 | void tContainerNewStep(unsigned uStep); |
|---|
| 91 | void Insert_tContainer(void); |
|---|
| 92 | void Update_tContainer(char *cRowid); |
|---|
| 93 | void ProcesstContainerListVars(pentry entries[], int x); |
|---|
| 94 | |
|---|
| 95 | //In tContainerfunc.h file included below |
|---|
| 96 | void ExtProcesstContainerVars(pentry entries[], int x); |
|---|
| 97 | void ExttContainerCommands(pentry entries[], int x); |
|---|
| 98 | void ExttContainerButtons(void); |
|---|
| 99 | void ExttContainerNavBar(void); |
|---|
| 100 | void ExttContainerGetHook(entry gentries[], int x); |
|---|
| 101 | void ExttContainerSelect(void); |
|---|
| 102 | void ExttContainerSelectRow(void); |
|---|
| 103 | void ExttContainerListSelect(void); |
|---|
| 104 | void ExttContainerListFilter(void); |
|---|
| 105 | void ExttContainerAuxTable(void); |
|---|
| 106 | |
|---|
| 107 | #include "tcontainerfunc.h" |
|---|
| 108 | |
|---|
| 109 | //Table Variables Assignment Function |
|---|
| 110 | void ProcesstContainerVars(pentry entries[], int x) |
|---|
| 111 | { |
|---|
| 112 | register int i; |
|---|
| 113 | |
|---|
| 114 | |
|---|
| 115 | for(i=0;i<x;i++) |
|---|
| 116 | { |
|---|
| 117 | if(!strcmp(entries[i].name,"uContainer")) |
|---|
| 118 | sscanf(entries[i].val,"%u",&uContainer); |
|---|
| 119 | else if(!strcmp(entries[i].name,"cLabel")) |
|---|
| 120 | sprintf(cLabel,"%.32s",FQDomainName(entries[i].val)); |
|---|
| 121 | else if(!strcmp(entries[i].name,"cCommands")) |
|---|
| 122 | cCommands=entries[i].val; |
|---|
| 123 | else if(!strcmp(entries[i].name,"cHostname")) |
|---|
| 124 | sprintf(cHostname,"%.64s",FQDomainName(entries[i].val)); |
|---|
| 125 | else if(!strcmp(entries[i].name,"uVeth")) |
|---|
| 126 | sscanf(entries[i].val,"%u",&uVeth); |
|---|
| 127 | else if(!strcmp(entries[i].name,"cYesNouVeth")) |
|---|
| 128 | { |
|---|
| 129 | sprintf(cYesNouVeth,"%.31s",entries[i].val); |
|---|
| 130 | uVeth=ReadYesNoPullDown(cYesNouVeth); |
|---|
| 131 | } |
|---|
| 132 | else if(!strcmp(entries[i].name,"uIPv4")) |
|---|
| 133 | sscanf(entries[i].val,"%u",&uIPv4); |
|---|
| 134 | else if(!strcmp(entries[i].name,"cuIPv4PullDown")) |
|---|
| 135 | { |
|---|
| 136 | sprintf(cuIPv4PullDown,"%.255s",entries[i].val); |
|---|
| 137 | uIPv4=ReadPullDown("tIP","cLabel",cuIPv4PullDown); |
|---|
| 138 | } |
|---|
| 139 | else if(!strcmp(entries[i].name,"uOSTemplate")) |
|---|
| 140 | sscanf(entries[i].val,"%u",&uOSTemplate); |
|---|
| 141 | else if(!strcmp(entries[i].name,"cuOSTemplatePullDown")) |
|---|
| 142 | { |
|---|
| 143 | sprintf(cuOSTemplatePullDown,"%.255s",entries[i].val); |
|---|
| 144 | uOSTemplate=ReadPullDown("tOSTemplate","cLabel",cuOSTemplatePullDown); |
|---|
| 145 | } |
|---|
| 146 | else if(!strcmp(entries[i].name,"uConfig")) |
|---|
| 147 | sscanf(entries[i].val,"%u",&uConfig); |
|---|
| 148 | else if(!strcmp(entries[i].name,"cuConfigPullDown")) |
|---|
| 149 | { |
|---|
| 150 | sprintf(cuConfigPullDown,"%.255s",entries[i].val); |
|---|
| 151 | uConfig=ReadPullDown("tConfig","cLabel",cuConfigPullDown); |
|---|
| 152 | } |
|---|
| 153 | else if(!strcmp(entries[i].name,"uNameserver")) |
|---|
| 154 | sscanf(entries[i].val,"%u",&uNameserver); |
|---|
| 155 | else if(!strcmp(entries[i].name,"cuNameserverPullDown")) |
|---|
| 156 | { |
|---|
| 157 | sprintf(cuNameserverPullDown,"%.255s",entries[i].val); |
|---|
| 158 | uNameserver=ReadPullDown("tNameserver","cLabel",cuNameserverPullDown); |
|---|
| 159 | } |
|---|
| 160 | else if(!strcmp(entries[i].name,"uSearchdomain")) |
|---|
| 161 | sscanf(entries[i].val,"%u",&uSearchdomain); |
|---|
| 162 | else if(!strcmp(entries[i].name,"cuSearchdomainPullDown")) |
|---|
| 163 | { |
|---|
| 164 | sprintf(cuSearchdomainPullDown,"%.255s",entries[i].val); |
|---|
| 165 | uSearchdomain=ReadPullDown("tSearchdomain","cLabel",cuSearchdomainPullDown); |
|---|
| 166 | } |
|---|
| 167 | else if(!strcmp(entries[i].name,"uDatacenter")) |
|---|
| 168 | sscanf(entries[i].val,"%u",&uDatacenter); |
|---|
| 169 | else if(!strcmp(entries[i].name,"cuDatacenterPullDown")) |
|---|
| 170 | { |
|---|
| 171 | sprintf(cuDatacenterPullDown,"%.255s",entries[i].val); |
|---|
| 172 | uDatacenter=ReadPullDown("tDatacenter","cLabel",cuDatacenterPullDown); |
|---|
| 173 | } |
|---|
| 174 | else if(!strcmp(entries[i].name,"uForClient")) |
|---|
| 175 | sscanf(entries[i].val,"%u",&uForClient); |
|---|
| 176 | else if(!strcmp(entries[i].name,"cuClientPullDown")) |
|---|
| 177 | { |
|---|
| 178 | sprintf(cuClientPullDown,"%.255s",entries[i].val); |
|---|
| 179 | uForClient=ReadPullDown("tClient","cLabel",cuClientPullDown); |
|---|
| 180 | } |
|---|
| 181 | else if(!strcmp(entries[i].name,"uNode")) |
|---|
| 182 | sscanf(entries[i].val,"%u",&uNode); |
|---|
| 183 | else if(!strcmp(entries[i].name,"cuNodePullDown")) |
|---|
| 184 | { |
|---|
| 185 | sprintf(cuNodePullDown,"%.255s",entries[i].val); |
|---|
| 186 | uNode=ReadPullDown("tNode","cLabel",cuNodePullDown); |
|---|
| 187 | } |
|---|
| 188 | else if(!strcmp(entries[i].name,"uStatus")) |
|---|
| 189 | sscanf(entries[i].val,"%u",&uStatus); |
|---|
| 190 | else if(!strcmp(entries[i].name,"uOwner")) |
|---|
| 191 | sscanf(entries[i].val,"%u",&uOwner); |
|---|
| 192 | else if(!strcmp(entries[i].name,"uCreatedBy")) |
|---|
| 193 | sscanf(entries[i].val,"%u",&uCreatedBy); |
|---|
| 194 | else if(!strcmp(entries[i].name,"uCreatedDate")) |
|---|
| 195 | sscanf(entries[i].val,"%lu",&uCreatedDate); |
|---|
| 196 | else if(!strcmp(entries[i].name,"uModBy")) |
|---|
| 197 | sscanf(entries[i].val,"%u",&uModBy); |
|---|
| 198 | else if(!strcmp(entries[i].name,"uModDate")) |
|---|
| 199 | sscanf(entries[i].val,"%lu",&uModDate); |
|---|
| 200 | else if(!strcmp(entries[i].name,"uSource")) |
|---|
| 201 | sscanf(entries[i].val,"%u",&uSource); |
|---|
| 202 | else if(!strcmp(entries[i].name,"uBackupDate")) |
|---|
| 203 | sscanf(entries[i].val,"%lu",&uBackupDate); |
|---|
| 204 | else if(!strcmp(entries[i].name,"gcNewContainerTZ")) |
|---|
| 205 | sprintf(gcNewContainerTZ,"%.63s",entries[i].val); |
|---|
| 206 | |
|---|
| 207 | else if(!strcmp(entries[i].name,"cuSearchStatusPullDown")) |
|---|
| 208 | { |
|---|
| 209 | sprintf(cuSearchStatusPullDown,"%.255s",entries[i].val); |
|---|
| 210 | uSearchStatus=ReadPullDown("tStatus","cLabel",cuSearchStatusPullDown); |
|---|
| 211 | } |
|---|
| 212 | else if(!strcmp(entries[i].name,"uSearchSource")) |
|---|
| 213 | sscanf(entries[i].val,"%u",&uSearchSource); |
|---|
| 214 | else if(!strcmp(entries[i].name,"uSearchStatusNotNoCA")) |
|---|
| 215 | uSearchStatusNot=1; |
|---|
| 216 | else if(!strcmp(entries[i].name,"cYesNouSearchSource")) |
|---|
| 217 | { |
|---|
| 218 | sprintf(cYesNouSearchSource,"%.31s",entries[i].val); |
|---|
| 219 | uSearchSource=ReadYesNoPullDownTriState(cYesNouSearchSource); |
|---|
| 220 | } |
|---|
| 221 | |
|---|
| 222 | } |
|---|
| 223 | |
|---|
| 224 | //After so we can overwrite form data if needed. |
|---|
| 225 | ExtProcesstContainerVars(entries,x); |
|---|
| 226 | |
|---|
| 227 | }//ProcesstContainerVars() |
|---|
| 228 | |
|---|
| 229 | |
|---|
| 230 | void ProcesstContainerListVars(pentry entries[], int x) |
|---|
| 231 | { |
|---|
| 232 | register int i; |
|---|
| 233 | |
|---|
| 234 | for(i=0;i<x;i++) |
|---|
| 235 | { |
|---|
| 236 | if(!strncmp(entries[i].name,"ED",2)) |
|---|
| 237 | { |
|---|
| 238 | sscanf(entries[i].name+2,"%u",&uContainer); |
|---|
| 239 | //guMode=2002;//uMODE_MOD |
|---|
| 240 | guMode=6;//uMODE_EDIT |
|---|
| 241 | tContainer(""); |
|---|
| 242 | } |
|---|
| 243 | } |
|---|
| 244 | }//void ProcesstContainerListVars(pentry entries[], int x) |
|---|
| 245 | |
|---|
| 246 | |
|---|
| 247 | int tContainerCommands(pentry entries[], int x) |
|---|
| 248 | { |
|---|
| 249 | ProcessControlVars(entries,x); |
|---|
| 250 | |
|---|
| 251 | ExttContainerCommands(entries,x); |
|---|
| 252 | |
|---|
| 253 | if(!strcmp(gcFunction,"tContainerTools")) |
|---|
| 254 | { |
|---|
| 255 | if(!strcmp(gcFind,LANG_NB_LIST)) |
|---|
| 256 | { |
|---|
| 257 | tContainerList(); |
|---|
| 258 | } |
|---|
| 259 | |
|---|
| 260 | //Default |
|---|
| 261 | ProcesstContainerVars(entries,x); |
|---|
| 262 | tContainer(""); |
|---|
| 263 | } |
|---|
| 264 | else if(!strcmp(gcFunction,"tContainerList")) |
|---|
| 265 | { |
|---|
| 266 | ProcessControlVars(entries,x); |
|---|
| 267 | ProcesstContainerListVars(entries,x); |
|---|
| 268 | tContainerList(); |
|---|
| 269 | } |
|---|
| 270 | |
|---|
| 271 | return(0); |
|---|
| 272 | |
|---|
| 273 | }//tContainerCommands() |
|---|
| 274 | |
|---|
| 275 | |
|---|
| 276 | void tContainer(const char *cResult) |
|---|
| 277 | { |
|---|
| 278 | MYSQL_RES *res; |
|---|
| 279 | MYSQL_RES *res2; |
|---|
| 280 | MYSQL_ROW field; |
|---|
| 281 | |
|---|
| 282 | //Internal skip reloading |
|---|
| 283 | if(!cResult[0]) |
|---|
| 284 | { |
|---|
| 285 | if(guMode) |
|---|
| 286 | ExttContainerSelectRow(); |
|---|
| 287 | else |
|---|
| 288 | ExttContainerSelect(); |
|---|
| 289 | |
|---|
| 290 | mysql_query(&gMysql,gcQuery); |
|---|
| 291 | if(mysql_errno(&gMysql)) |
|---|
| 292 | { |
|---|
| 293 | if(strstr(mysql_error(&gMysql)," doesn't exist")) |
|---|
| 294 | { |
|---|
| 295 | CreatetContainer(); |
|---|
| 296 | unxsVZ("New tContainer table created"); |
|---|
| 297 | } |
|---|
| 298 | else |
|---|
| 299 | { |
|---|
| 300 | htmlPlainTextError(mysql_error(&gMysql)); |
|---|
| 301 | } |
|---|
| 302 | } |
|---|
| 303 | |
|---|
| 304 | res=mysql_store_result(&gMysql); |
|---|
| 305 | if((guI=mysql_num_rows(res))) |
|---|
| 306 | { |
|---|
| 307 | if(guMode==6) |
|---|
| 308 | { |
|---|
| 309 | sprintf(gcQuery,"SELECT _rowid FROM tContainer WHERE uContainer=%u" |
|---|
| 310 | ,uContainer); |
|---|
| 311 | MYSQL_RUN_STORE(res2); |
|---|
| 312 | field=mysql_fetch_row(res2); |
|---|
| 313 | sscanf(field[0],"%lu",&gluRowid); |
|---|
| 314 | gluRowid++; |
|---|
| 315 | } |
|---|
| 316 | PageMachine("",0,""); |
|---|
| 317 | if(!guMode) mysql_data_seek(res,gluRowid-1); |
|---|
| 318 | field=mysql_fetch_row(res); |
|---|
| 319 | sscanf(field[0],"%u",&uContainer); |
|---|
| 320 | sprintf(cLabel,"%.32s",field[1]); |
|---|
| 321 | sprintf(cHostname,"%.64s",field[2]); |
|---|
| 322 | sscanf(field[3],"%u",&uVeth); |
|---|
| 323 | sscanf(field[4],"%u",&uIPv4); |
|---|
| 324 | sscanf(field[5],"%u",&uOSTemplate); |
|---|
| 325 | sscanf(field[6],"%u",&uConfig); |
|---|
| 326 | sscanf(field[7],"%u",&uNameserver); |
|---|
| 327 | sscanf(field[8],"%u",&uSearchdomain); |
|---|
| 328 | sscanf(field[9],"%u",&uDatacenter); |
|---|
| 329 | sscanf(field[10],"%u",&uNode); |
|---|
| 330 | sscanf(field[11],"%u",&uStatus); |
|---|
| 331 | sscanf(field[12],"%u",&uOwner); |
|---|
| 332 | sscanf(field[13],"%u",&uCreatedBy); |
|---|
| 333 | sscanf(field[14],"%lu",&uCreatedDate); |
|---|
| 334 | sscanf(field[15],"%u",&uModBy); |
|---|
| 335 | sscanf(field[16],"%lu",&uModDate); |
|---|
| 336 | sscanf(field[17],"%u",&uSource); |
|---|
| 337 | sscanf(field[18],"%lu",&uBackupDate); |
|---|
| 338 | |
|---|
| 339 | } |
|---|
| 340 | |
|---|
| 341 | }//Internal Skip |
|---|
| 342 | |
|---|
| 343 | Header_ism3(":: OpenVZ Container",2);//2 toggle checkboxes js |
|---|
| 344 | printf("<table width=100%% cellspacing=0 cellpadding=0>\n"); |
|---|
| 345 | printf("<tr><td colspan=2 align=right valign=center>"); |
|---|
| 346 | |
|---|
| 347 | |
|---|
| 348 | printf("<input type=hidden name=gcFunction value=tContainerTools>"); |
|---|
| 349 | printf("<input type=hidden name=gluRowid value=%lu>",gluRowid); |
|---|
| 350 | if(guI) |
|---|
| 351 | { |
|---|
| 352 | if(guMode==6) |
|---|
| 353 | //printf(" Found"); |
|---|
| 354 | printf(LANG_NBR_FOUND); |
|---|
| 355 | else if(guMode==5) |
|---|
| 356 | //printf(" Modified"); |
|---|
| 357 | printf(LANG_NBR_MODIFIED); |
|---|
| 358 | else if(guMode==4) |
|---|
| 359 | //printf(" New"); |
|---|
| 360 | printf(LANG_NBR_NEW); |
|---|
| 361 | printf(LANG_NBRF_SHOWING,gluRowid,guI); |
|---|
| 362 | } |
|---|
| 363 | else |
|---|
| 364 | { |
|---|
| 365 | if(!cResult[0]) |
|---|
| 366 | //printf(" No records found"); |
|---|
| 367 | printf(LANG_NBR_NORECS); |
|---|
| 368 | } |
|---|
| 369 | if(cResult[0]) printf("%s",cResult); |
|---|
| 370 | printf("</td></tr>"); |
|---|
| 371 | printf("<tr><td valign=top width=25%%>"); |
|---|
| 372 | |
|---|
| 373 | ExttContainerButtons(); |
|---|
| 374 | |
|---|
| 375 | printf("</td><td valign=top>"); |
|---|
| 376 | // |
|---|
| 377 | OpenFieldSet("tContainer Record Data",100); |
|---|
| 378 | |
|---|
| 379 | //Custom right panel for creating search sets |
|---|
| 380 | if(guMode==12001) |
|---|
| 381 | tContainerSearchSet(1); |
|---|
| 382 | else if(guMode==12002) |
|---|
| 383 | tContainerSearchSet(2); |
|---|
| 384 | //Custom right panel for new containers |
|---|
| 385 | else if(guMode==9001) |
|---|
| 386 | tContainerNewStep(1); |
|---|
| 387 | else if(guMode==9002) |
|---|
| 388 | tContainerNewStep(2); |
|---|
| 389 | else if(guMode==9003) |
|---|
| 390 | tContainerNewStep(3); |
|---|
| 391 | else if(guMode==9004) |
|---|
| 392 | tContainerNewStep(4); |
|---|
| 393 | else if(guMode==2002 || guMode==2000) |
|---|
| 394 | tContainerInput(1); |
|---|
| 395 | else |
|---|
| 396 | tContainerInput(0); |
|---|
| 397 | |
|---|
| 398 | // |
|---|
| 399 | CloseFieldSet(); |
|---|
| 400 | |
|---|
| 401 | //Bottom table |
|---|
| 402 | printf("<tr><td colspan=2>"); |
|---|
| 403 | ExttContainerAuxTable(); |
|---|
| 404 | |
|---|
| 405 | Footer_ism3(); |
|---|
| 406 | |
|---|
| 407 | }//end of tContainer(); |
|---|
| 408 | |
|---|
| 409 | |
|---|
| 410 | void tContainerSearchSet(unsigned uStep) |
|---|
| 411 | { |
|---|
| 412 | OpenRow("<u>Set search parameters</u>","black"); |
|---|
| 413 | OpenRow("Hostname pattern","black"); |
|---|
| 414 | //Usability: Transfer from main tContainer page any current search pattern |
|---|
| 415 | if(cSearch[0]) |
|---|
| 416 | sprintf(cHostnameSearch,"%.31s",cSearch); |
|---|
| 417 | printf("<input title='SQL search pattern %% and _ allowed' type=text name=cHostnameSearch" |
|---|
| 418 | " value=\"%s\" size=40 maxlength=63 >",cHostnameSearch); |
|---|
| 419 | //Temp placement |
|---|
| 420 | printf("<td><textarea title='cHostname list for remove/add (parameters are ignored) or group execute function commands'" |
|---|
| 421 | " cols=80 wrap=soft rows=1 name=cCommands>%s</textarea></td>",cCommands); |
|---|
| 422 | |
|---|
| 423 | OpenRow("IPv4 pattern","black"); |
|---|
| 424 | printf("<input title='SQL search pattern %% and _ allowed' type=text name=cIPv4Search" |
|---|
| 425 | " value=\"%s\" size=40 maxlength=15 >",cIPv4Search); |
|---|
| 426 | OpenRow("Datacenter","black"); |
|---|
| 427 | tTablePullDown("tDatacenter;cuDatacenterPullDown","cLabel","cLabel",uDatacenter,1); |
|---|
| 428 | OpenRow("Node","black"); |
|---|
| 429 | tTablePullDown("tNode;cuNodePullDown","cLabel","cLabel",uNode,1); |
|---|
| 430 | OpenRow("Owner","black"); |
|---|
| 431 | tTablePullDownResellers(uForClient,0); |
|---|
| 432 | OpenRow("Clone","black"); |
|---|
| 433 | YesNoPullDownTriState("uSearchSource",uSearchSource,1); |
|---|
| 434 | OpenRow("Status","black"); |
|---|
| 435 | tTablePullDown("tStatus;cuSearchStatusPullDown","cLabel","cLabel",uSearchStatus,1); |
|---|
| 436 | printf("<input title='Logical NOT of selected status if any' type=checkbox name=uSearchStatusNotNoCA "); |
|---|
| 437 | if(uSearchStatusNot) |
|---|
| 438 | printf(" checked"); |
|---|
| 439 | printf("> Not"); |
|---|
| 440 | OpenRow("OSTemplate","black"); |
|---|
| 441 | tTablePullDown("tOSTemplate;cuOSTemplatePullDown","cLabel","cLabel",uOSTemplate,1); |
|---|
| 442 | |
|---|
| 443 | if(uStep==1) |
|---|
| 444 | { |
|---|
| 445 | ; |
|---|
| 446 | } |
|---|
| 447 | else if(uStep==2) |
|---|
| 448 | { |
|---|
| 449 | ; |
|---|
| 450 | } |
|---|
| 451 | |
|---|
| 452 | }//void tContainerSearchSet(unsigned uStep) |
|---|
| 453 | |
|---|
| 454 | |
|---|
| 455 | void tContainerNewStep(unsigned uStep) |
|---|
| 456 | { |
|---|
| 457 | |
|---|
| 458 | if(uStep==1) |
|---|
| 459 | { |
|---|
| 460 | OpenRow("Select an available datacenter","black"); |
|---|
| 461 | tTablePullDown("tDatacenter;cuDatacenterPullDown","cLabel","cLabel",uDatacenter,1); |
|---|
| 462 | //Helper |
|---|
| 463 | if(uNode) |
|---|
| 464 | printf("<input type=hidden name=uNode value=%u >\n",uNode); |
|---|
| 465 | OpenRow("Select an organization","black"); |
|---|
| 466 | uForClient=uOwner; |
|---|
| 467 | tTablePullDownResellers(uForClient,0); |
|---|
| 468 | //Helper |
|---|
| 469 | if(uOwner) |
|---|
| 470 | printf("<input type=hidden name=uOwner value=%u >\n",uOwner); |
|---|
| 471 | } |
|---|
| 472 | else if(uStep==2) |
|---|
| 473 | { |
|---|
| 474 | OpenRow("Selected datacenter","black"); |
|---|
| 475 | tTablePullDown("tDatacenter;cuDatacenterPullDown","cLabel","cLabel",uDatacenter,0); |
|---|
| 476 | |
|---|
| 477 | OpenRow("Selected organization","black"); |
|---|
| 478 | tTablePullDown("tClient;cuClientPullDown","cLabel","cLabel",uForClient,0); |
|---|
| 479 | |
|---|
| 480 | OpenRow("Select an available node","black"); |
|---|
| 481 | tTablePullDownDatacenter("tNode;cuNodePullDown","cLabel","cLabel",uNode,1, |
|---|
| 482 | cuDatacenterPullDown,0,uDatacenter);//0 does not use tProperty, uses uDatacenter |
|---|
| 483 | } |
|---|
| 484 | else if(uStep==3 || uStep==4) |
|---|
| 485 | { |
|---|
| 486 | |
|---|
| 487 | OpenRow("Selected datacenter","black"); |
|---|
| 488 | tTablePullDown("tDatacenter;cuDatacenterPullDown","cLabel","cLabel",uDatacenter,0); |
|---|
| 489 | |
|---|
| 490 | OpenRow("Selected organization","black"); |
|---|
| 491 | tTablePullDown("tClient;cuClientPullDown","cLabel","cLabel",uForClient,0); |
|---|
| 492 | |
|---|
| 493 | OpenRow("Selected node","black"); |
|---|
| 494 | tTablePullDown("tNode;cuNodePullDown","cLabel","cLabel",uNode,0); |
|---|
| 495 | |
|---|
| 496 | //cLabel |
|---|
| 497 | OpenRow(LANG_FL_tContainer_cLabel,"black"); |
|---|
| 498 | printf("<input title='%s' type=text name=cLabel value=\"%s\" size=40 maxlength=32 ", |
|---|
| 499 | LANG_FT_tContainer_cLabel,EncodeDoubleQuotes(cLabel)); |
|---|
| 500 | printf("></td></tr>\n"); |
|---|
| 501 | |
|---|
| 502 | //cHostname |
|---|
| 503 | OpenRow(LANG_FL_tContainer_cHostname,"black"); |
|---|
| 504 | printf("<input title='%s' type=text name=cHostname value=\"%s\" size=40 maxlength=64 " |
|---|
| 505 | ,LANG_FT_tContainer_cHostname,EncodeDoubleQuotes(cHostname)); |
|---|
| 506 | printf("></td></tr>\n"); |
|---|
| 507 | |
|---|
| 508 | //uIPv4 |
|---|
| 509 | OpenRow(LANG_FL_tContainer_uIPv4,"black"); |
|---|
| 510 | tTablePullDownOwnerAvailDatacenter("tIP;cuIPv4PullDown","cLabel","cLabel",uIPv4,1,uDatacenter,uForClient); |
|---|
| 511 | |
|---|
| 512 | //uOSTemplate |
|---|
| 513 | OpenRow(LANG_FL_tContainer_uOSTemplate,"black"); |
|---|
| 514 | tTablePullDownDatacenter("tOSTemplate;cuOSTemplatePullDown","cLabel","cLabel",uOSTemplate,1, |
|---|
| 515 | cuDatacenterPullDown,uPROP_OSTEMPLATE,0); |
|---|
| 516 | |
|---|
| 517 | //uConfig |
|---|
| 518 | OpenRow(LANG_FL_tContainer_uConfig,"black"); |
|---|
| 519 | tTablePullDownDatacenter("tConfig;cuConfigPullDown","cLabel","cLabel",uConfig,1, |
|---|
| 520 | cuDatacenterPullDown,uPROP_CONFIG,0); |
|---|
| 521 | |
|---|
| 522 | //uNameserver |
|---|
| 523 | OpenRow(LANG_FL_tContainer_uNameserver,"black"); |
|---|
| 524 | tTablePullDownDatacenter("tNameserver;cuNameserverPullDown","cLabel","cLabel",uNameserver,1, |
|---|
| 525 | cuDatacenterPullDown,uPROP_NAMESERVER,0); |
|---|
| 526 | |
|---|
| 527 | //uSearchdomain |
|---|
| 528 | OpenRow(LANG_FL_tContainer_uSearchdomain,"black"); |
|---|
| 529 | tTablePullDownDatacenter("tSearchdomain;cuSearchdomainPullDown","cLabel","cLabel",uSearchdomain,1, |
|---|
| 530 | cuDatacenterPullDown,uPROP_SEARCHDOMAIN,0); |
|---|
| 531 | |
|---|
| 532 | //Select group or allow creation of new one. |
|---|
| 533 | OpenRow("Select group","black"); |
|---|
| 534 | tTablePullDown("tGroup;cuGroupPullDown","cLabel","cLabel",uGroup,1); |
|---|
| 535 | printf(" Create new group <input title='Instead of selecting an existing group optionally enter" |
|---|
| 536 | " a new tGroup.cLabel' type=text name=cService3 value='%s' maxlength=31><br>",cService3); |
|---|
| 537 | |
|---|
| 538 | if(cunxsBindARecordJobZone[0]) |
|---|
| 539 | { |
|---|
| 540 | OpenRow("Create job for unxsBind","black"); |
|---|
| 541 | printf("<input type=checkbox name=uCreateDNSJob "); |
|---|
| 542 | if(uCreateDNSJob || uStep==3) |
|---|
| 543 | printf("checked>"); |
|---|
| 544 | else |
|---|
| 545 | printf(">"); |
|---|
| 546 | } |
|---|
| 547 | |
|---|
| 548 | //Select group or allow creation of new one. |
|---|
| 549 | OpenRow("Optional password","black"); |
|---|
| 550 | printf("<input title='Optional container password set on deployment and saved in" |
|---|
| 551 | " container property table' type=text name=cService1 value='%s' maxlength=31><br>",cService1); |
|---|
| 552 | |
|---|
| 553 | //Time zone |
|---|
| 554 | MYSQL_RES *res; |
|---|
| 555 | MYSQL_ROW field; |
|---|
| 556 | OpenRow("Time Zone","black"); |
|---|
| 557 | sprintf(gcQuery,"SELECT cValue,cComment FROM tConfiguration WHERE cLabel='cTimeZone' ORDER BY uConfiguration"); |
|---|
| 558 | mysql_query(&gMysql,gcQuery); |
|---|
| 559 | if(mysql_errno(&gMysql)) |
|---|
| 560 | htmlPlainTextError(mysql_error(&gMysql)); |
|---|
| 561 | res=mysql_store_result(&gMysql); |
|---|
| 562 | printf("<select class=type_textarea title='Select the time zone you want to use.'" |
|---|
| 563 | " name=gcNewContainerTZ >\n"); |
|---|
| 564 | printf("<option>---</option>"); |
|---|
| 565 | while((field=mysql_fetch_row(res))) |
|---|
| 566 | { |
|---|
| 567 | printf("<option value=%s",field[0]); |
|---|
| 568 | if(!strcmp(gcNewContainerTZ,field[0])) |
|---|
| 569 | printf(" selected"); |
|---|
| 570 | printf(">%s</option>",field[1]); |
|---|
| 571 | } |
|---|
| 572 | mysql_free_result(res); |
|---|
| 573 | printf("</select>\n"); |
|---|
| 574 | |
|---|
| 575 | if(cAutoCloneNode[0]) |
|---|
| 576 | { |
|---|
| 577 | char cAutoCloneSyncTime[256]={""}; |
|---|
| 578 | char cAutoCloneNode[256]={""}; |
|---|
| 579 | unsigned uTargetDatacenter=0; |
|---|
| 580 | |
|---|
| 581 | MYSQL_RES *res; |
|---|
| 582 | MYSQL_ROW field; |
|---|
| 583 | |
|---|
| 584 | OpenRow("Clone target node","black"); |
|---|
| 585 | GetConfiguration("cAutoCloneNode",cAutoCloneNode,uDatacenter,uNode,0,0); |
|---|
| 586 | if(!cAutoCloneNode[0]) |
|---|
| 587 | GetConfiguration("cAutoCloneNode",cAutoCloneNode,uDatacenter,0,0,0);//All nodes |
|---|
| 588 | sprintf(gcQuery,"SELECT uNode,uDatacenter FROM tNode WHERE cLabel='%s'",cAutoCloneNode); |
|---|
| 589 | MYSQL_RUN_STORE(res); |
|---|
| 590 | if((field=mysql_fetch_row(res))) |
|---|
| 591 | { |
|---|
| 592 | sscanf(field[0],"%u",&uTargetNode); |
|---|
| 593 | sscanf(field[1],"%u",&uTargetDatacenter); |
|---|
| 594 | tTablePullDown("tNode;cuTargetNodePullDown","cLabel","cLabel",uTargetNode,0);//disabled |
|---|
| 595 | } |
|---|
| 596 | else |
|---|
| 597 | { |
|---|
| 598 | printf("Configuration error: '%s' %u %u",cAutoCloneNode,uDatacenter,uNode); |
|---|
| 599 | } |
|---|
| 600 | |
|---|
| 601 | OpenRow("Clone start uIPv4","black"); |
|---|
| 602 | tTablePullDownOwnerAvailDatacenter("tIP;cuWizIPv4PullDown","cLabel","cLabel",uWizIPv4,1, |
|---|
| 603 | uTargetDatacenter,uForClient); |
|---|
| 604 | |
|---|
| 605 | OpenRow("Keep clone stopped","black"); |
|---|
| 606 | printf("<input type=checkbox name=uCloneStop "); |
|---|
| 607 | if(uCloneStop || uStep==3) |
|---|
| 608 | printf("checked>"); |
|---|
| 609 | else |
|---|
| 610 | printf(">"); |
|---|
| 611 | |
|---|
| 612 | OpenRow("Clone cuSyncPeriod","black"); |
|---|
| 613 | GetConfiguration("cAutoCloneSyncTime",cAutoCloneSyncTime,uDatacenter,0,0,0); |
|---|
| 614 | if(cAutoCloneSyncTime[0]) |
|---|
| 615 | sscanf(cAutoCloneSyncTime,"%u",&uSyncPeriod); |
|---|
| 616 | printf("<input title='Keep clone in sync every cuSyncPeriod seconds" |
|---|
| 617 | ". You can change this at any time via the property panel.'" |
|---|
| 618 | " type=text size=10 maxlength=7" |
|---|
| 619 | " name=uSyncPeriod value='%u'>\n",uSyncPeriod); |
|---|
| 620 | } |
|---|
| 621 | |
|---|
| 622 | if(uStep==4) |
|---|
| 623 | { |
|---|
| 624 | OpenRow("Number of containers","black"); |
|---|
| 625 | printf("<input title='Number of containers to be created'" |
|---|
| 626 | " type=text name=cService2 value='%s' maxlength=2><br>",cService2); |
|---|
| 627 | } |
|---|
| 628 | |
|---|
| 629 | }//step 3 or 4 |
|---|
| 630 | |
|---|
| 631 | }//void tContainerNewStep(unsigned uStep) |
|---|
| 632 | |
|---|
| 633 | |
|---|
| 634 | void tContainerInput(unsigned uMode) |
|---|
| 635 | { |
|---|
| 636 | |
|---|
| 637 | if(uContainer && uDatacenter) |
|---|
| 638 | { |
|---|
| 639 | char cConfigBuffer[256]={""}; |
|---|
| 640 | |
|---|
| 641 | GetConfiguration("cTrafficDirURL",cConfigBuffer,uDatacenter,0,0,0); |
|---|
| 642 | if(cConfigBuffer[0]) |
|---|
| 643 | { |
|---|
| 644 | |
|---|
| 645 | OpenRow("Graph","black"); |
|---|
| 646 | printf("<a href=%s/%u.png><img src=%s/%u.png border=0></a>\n", |
|---|
| 647 | cConfigBuffer,uContainer,cConfigBuffer,uContainer); |
|---|
| 648 | printf("</td></tr>\n"); |
|---|
| 649 | } |
|---|
| 650 | } |
|---|
| 651 | |
|---|
| 652 | //uContainer |
|---|
| 653 | OpenRow(LANG_FL_tContainer_uContainer,"black"); |
|---|
| 654 | printf("<input title='%s' type=text name=uContainer value=%u size=16 maxlength=10 ",LANG_FT_tContainer_uContainer,uContainer); |
|---|
| 655 | if(guPermLevel>=20 && uMode) |
|---|
| 656 | { |
|---|
| 657 | printf("></td></tr>\n"); |
|---|
| 658 | } |
|---|
| 659 | else |
|---|
| 660 | { |
|---|
| 661 | printf("disabled></td></tr>\n"); |
|---|
| 662 | printf("<input type=hidden name=uContainer value=%u >\n",uContainer); |
|---|
| 663 | } |
|---|
| 664 | //cLabel |
|---|
| 665 | OpenRow(LANG_FL_tContainer_cLabel,"black"); |
|---|
| 666 | printf("<input title='%s' type=text name=cLabel value=\"%s\" size=40 maxlength=32 ",LANG_FT_tContainer_cLabel, |
|---|
| 667 | EncodeDoubleQuotes(cLabel)); |
|---|
| 668 | if(guPermLevel>=0 && uMode) |
|---|
| 669 | { |
|---|
| 670 | printf("></td></tr>\n"); |
|---|
| 671 | } |
|---|
| 672 | else |
|---|
| 673 | { |
|---|
| 674 | printf("disabled></td></tr>\n"); |
|---|
| 675 | printf("<input type=hidden name=cLabel value=\"%s\">\n",EncodeDoubleQuotes(cLabel)); |
|---|
| 676 | } |
|---|
| 677 | //cHostname |
|---|
| 678 | OpenRow(LANG_FL_tContainer_cHostname,"black"); |
|---|
| 679 | printf("<input title='%s' type=text name=cHostname value=\"%s\" size=40 maxlength=64 ",LANG_FT_tContainer_cHostname, |
|---|
| 680 | EncodeDoubleQuotes(cHostname)); |
|---|
| 681 | if(guPermLevel>=0 && uMode) |
|---|
| 682 | { |
|---|
| 683 | printf("></td></tr>\n"); |
|---|
| 684 | } |
|---|
| 685 | else |
|---|
| 686 | { |
|---|
| 687 | printf("disabled></td></tr>\n"); |
|---|
| 688 | printf("<input type=hidden name=cHostname value=\"%s\">\n",EncodeDoubleQuotes(cHostname)); |
|---|
| 689 | } |
|---|
| 690 | //uVeth |
|---|
| 691 | OpenRow(LANG_FL_tContainer_uVeth,"black"); |
|---|
| 692 | if(guPermLevel>=7 && uMode) |
|---|
| 693 | YesNoPullDown("uVeth",uVeth,1); |
|---|
| 694 | else |
|---|
| 695 | YesNoPullDown("uVeth",uVeth,0); |
|---|
| 696 | //uIPv4 |
|---|
| 697 | OpenRow(LANG_FL_tContainer_uIPv4,"black"); |
|---|
| 698 | if(guPermLevel>=7 && uMode) |
|---|
| 699 | tTablePullDownOwnerAvail("tIP;cuIPv4PullDown","cLabel","cLabel",uIPv4,1); |
|---|
| 700 | else |
|---|
| 701 | tTablePullDown("tIP;cuIPv4PullDown","cLabel","cLabel",uIPv4,0); |
|---|
| 702 | //uOSTemplate |
|---|
| 703 | OpenRow(LANG_FL_tContainer_uOSTemplate,"black"); |
|---|
| 704 | if(guPermLevel>=7 && uMode) |
|---|
| 705 | tTablePullDownDatacenter("tOSTemplate;cuOSTemplatePullDown","cLabel","cLabel",uOSTemplate,1, |
|---|
| 706 | cuDatacenterPullDown,uPROP_OSTEMPLATE,0); |
|---|
| 707 | else |
|---|
| 708 | tTablePullDown("tOSTemplate;cuOSTemplatePullDown","cLabel","cLabel",uOSTemplate,0); |
|---|
| 709 | //uConfig |
|---|
| 710 | OpenRow(LANG_FL_tContainer_uConfig,"black"); |
|---|
| 711 | if(guPermLevel>=7 && uMode) |
|---|
| 712 | tTablePullDownDatacenter("tConfig;cuConfigPullDown","cLabel","cLabel",uConfig,1, |
|---|
| 713 | cuDatacenterPullDown,uPROP_CONFIG,0); |
|---|
| 714 | else |
|---|
| 715 | tTablePullDown("tConfig;cuConfigPullDown","cLabel","cLabel",uConfig,0); |
|---|
| 716 | //uNameserver |
|---|
| 717 | OpenRow(LANG_FL_tContainer_uNameserver,"black"); |
|---|
| 718 | if(guPermLevel>=7 && uMode) |
|---|
| 719 | tTablePullDownDatacenter("tNameserver;cuNameserverPullDown","cLabel","cLabel",uNameserver,1, |
|---|
| 720 | cuDatacenterPullDown,uPROP_NAMESERVER,0); |
|---|
| 721 | else |
|---|
| 722 | tTablePullDown("tNameserver;cuNameserverPullDown","cLabel","cLabel",uNameserver,0); |
|---|
| 723 | //uSearchdomain |
|---|
| 724 | OpenRow(LANG_FL_tContainer_uSearchdomain,"black"); |
|---|
| 725 | if(guPermLevel>=7 && uMode) |
|---|
| 726 | tTablePullDownDatacenter("tSearchdomain;cuSearchdomainPullDown","cLabel","cLabel",uSearchdomain,1, |
|---|
| 727 | cuDatacenterPullDown,uPROP_SEARCHDOMAIN,0); |
|---|
| 728 | else |
|---|
| 729 | tTablePullDown("tSearchdomain;cuSearchdomainPullDown","cLabel","cLabel",uSearchdomain,0); |
|---|
| 730 | //uDatacenter |
|---|
| 731 | OpenRow(LANG_FL_tContainer_uDatacenter,"black"); |
|---|
| 732 | if(guPermLevel>=7 && uMode) |
|---|
| 733 | tTablePullDown("tDatacenter;cuDatacenterPullDown","cLabel","cLabel",uDatacenter,1); |
|---|
| 734 | else |
|---|
| 735 | tTablePullDown("tDatacenter;cuDatacenterPullDown","cLabel","cLabel",uDatacenter,0); |
|---|
| 736 | //uNode |
|---|
| 737 | OpenRow(LANG_FL_tContainer_uNode,"black"); |
|---|
| 738 | if(guPermLevel>=7 && uMode) |
|---|
| 739 | tTablePullDown("tNode;cuNodePullDown","cLabel","cLabel",uNode,1); |
|---|
| 740 | else |
|---|
| 741 | tTablePullDown("tNode;cuNodePullDown","cLabel","cLabel",uNode,0); |
|---|
| 742 | //uStatus |
|---|
| 743 | OpenRow(LANG_FL_tContainer_uStatus,"black"); |
|---|
| 744 | printf("%s<input type=hidden name=uStatus value=%u >\n", |
|---|
| 745 | ForeignKey("tStatus","cLabel",uStatus),uStatus); |
|---|
| 746 | //uSource |
|---|
| 747 | OpenRow(LANG_FL_tContainer_uSource,"black"); |
|---|
| 748 | printf("%s<input type=hidden name=uSource value=%u >\n", |
|---|
| 749 | ForeignKey("tContainer","cHostname",uSource),uSource); |
|---|
| 750 | //uOwner |
|---|
| 751 | OpenRow(LANG_FL_tContainer_uOwner,"black"); |
|---|
| 752 | printf("%s<input type=hidden name=uOwner value=%u >\n", |
|---|
| 753 | ForeignKey("tClient","cLabel",uOwner),uOwner); |
|---|
| 754 | //uCreatedBy |
|---|
| 755 | OpenRow(LANG_FL_tContainer_uCreatedBy,"black"); |
|---|
| 756 | printf("%s<input type=hidden name=uCreatedBy value=%u >\n", |
|---|
| 757 | ForeignKey("tClient","cLabel",uCreatedBy),uCreatedBy); |
|---|
| 758 | //uCreatedDate |
|---|
| 759 | OpenRow(LANG_FL_tContainer_uCreatedDate,"black"); |
|---|
| 760 | if(uCreatedDate) |
|---|
| 761 | printf("%s\n\n",ctime(&uCreatedDate)); |
|---|
| 762 | else |
|---|
| 763 | printf("---\n\n"); |
|---|
| 764 | printf("<input type=hidden name=uCreatedDate value=%lu >\n",uCreatedDate); |
|---|
| 765 | //uModBy |
|---|
| 766 | OpenRow(LANG_FL_tContainer_uModBy,"black"); |
|---|
| 767 | printf("%s<input type=hidden name=uModBy value=%u >\n", |
|---|
| 768 | ForeignKey("tClient","cLabel",uModBy),uModBy); |
|---|
| 769 | //uModDate |
|---|
| 770 | OpenRow(LANG_FL_tContainer_uModDate,"black"); |
|---|
| 771 | if(uModDate) |
|---|
| 772 | printf("%s\n\n",ctime(&uModDate)); |
|---|
| 773 | else |
|---|
| 774 | printf("---\n\n"); |
|---|
| 775 | printf("<input type=hidden name=uModDate value=%lu >\n",uModDate); |
|---|
| 776 | //uBackupDate |
|---|
| 777 | OpenRow(LANG_FL_tContainer_uBackupDate,"black"); |
|---|
| 778 | if(uBackupDate) |
|---|
| 779 | printf("%s\n\n",ctime(&uBackupDate)); |
|---|
| 780 | else |
|---|
| 781 | printf("---\n\n"); |
|---|
| 782 | printf("<input type=hidden name=uBackupDate value=%lu >\n",uBackupDate); |
|---|
| 783 | printf("</tr>\n"); |
|---|
| 784 | |
|---|
| 785 | }//void tContainerInput(unsigned uMode) |
|---|
| 786 | |
|---|
| 787 | |
|---|
| 788 | void NewtContainer(unsigned uMode) |
|---|
| 789 | { |
|---|
| 790 | register int i=0; |
|---|
| 791 | MYSQL_RES *res; |
|---|
| 792 | |
|---|
| 793 | sprintf(gcQuery,"SELECT uContainer FROM tContainer WHERE uContainer=%u",uContainer); |
|---|
| 794 | MYSQL_RUN_STORE(res); |
|---|
| 795 | i=mysql_num_rows(res); |
|---|
| 796 | |
|---|
| 797 | if(i) |
|---|
| 798 | //tContainer("<blink>Record already exists"); |
|---|
| 799 | tContainer(LANG_NBR_RECEXISTS); |
|---|
| 800 | |
|---|
| 801 | //insert query |
|---|
| 802 | Insert_tContainer(); |
|---|
| 803 | if(mysql_errno(&gMysql)) htmlPlainTextError(mysql_error(&gMysql)); |
|---|
| 804 | //sprintf(gcQuery,"New record %u added"); |
|---|
| 805 | uContainer=mysql_insert_id(&gMysql); |
|---|
| 806 | uCreatedDate=luGetCreatedDate("tContainer",uContainer); |
|---|
| 807 | unxsVZLog(uContainer,"tContainer","New"); |
|---|
| 808 | if(!uMode) |
|---|
| 809 | { |
|---|
| 810 | sprintf(gcQuery,LANG_NBR_NEWRECADDED,uContainer); |
|---|
| 811 | tContainer(gcQuery); |
|---|
| 812 | } |
|---|
| 813 | |
|---|
| 814 | }//NewtContainer(unsigned uMode) |
|---|
| 815 | |
|---|
| 816 | |
|---|
| 817 | void DeletetContainer(void) |
|---|
| 818 | { |
|---|
| 819 | sprintf(gcQuery,"DELETE FROM tContainer WHERE uContainer=%u AND ( uOwner=%u OR %u>9 )" |
|---|
| 820 | ,uContainer,guLoginClient,guPermLevel); |
|---|
| 821 | MYSQL_RUN; |
|---|
| 822 | //tContainer("Record Deleted"); |
|---|
| 823 | if(mysql_affected_rows(&gMysql)>0) |
|---|
| 824 | { |
|---|
| 825 | unxsVZLog(uContainer,"tContainer","Del"); |
|---|
| 826 | tContainer(LANG_NBR_RECDELETED); |
|---|
| 827 | } |
|---|
| 828 | else |
|---|
| 829 | { |
|---|
| 830 | unxsVZLog(uContainer,"tContainer","DelError"); |
|---|
| 831 | tContainer(LANG_NBR_RECNOTDELETED); |
|---|
| 832 | } |
|---|
| 833 | |
|---|
| 834 | }//void DeletetContainer(void) |
|---|
| 835 | |
|---|
| 836 | |
|---|
| 837 | void Insert_tContainer(void) |
|---|
| 838 | { |
|---|
| 839 | sprintf(gcQuery,"INSERT INTO tContainer SET uContainer=%u,cLabel='%s',cHostname='%s',uVeth=%u," |
|---|
| 840 | "uIPv4=%u,uOSTemplate=%u,uConfig=%u,uNameserver=%u,uSearchdomain=%u," |
|---|
| 841 | "uDatacenter=%u,uNode=%u,uStatus=%u,uOwner=%u,uCreatedBy=%u," |
|---|
| 842 | "uCreatedDate=UNIX_TIMESTAMP(NOW()),uSource=%u", |
|---|
| 843 | uContainer |
|---|
| 844 | ,TextAreaSave(cLabel) |
|---|
| 845 | ,TextAreaSave(cHostname) |
|---|
| 846 | ,uVeth |
|---|
| 847 | ,uIPv4 |
|---|
| 848 | ,uOSTemplate |
|---|
| 849 | ,uConfig |
|---|
| 850 | ,uNameserver |
|---|
| 851 | ,uSearchdomain |
|---|
| 852 | ,uDatacenter |
|---|
| 853 | ,uNode |
|---|
| 854 | ,uStatus |
|---|
| 855 | ,uOwner |
|---|
| 856 | ,uCreatedBy |
|---|
| 857 | ,uSource |
|---|
| 858 | ); |
|---|
| 859 | MYSQL_RUN; |
|---|
| 860 | |
|---|
| 861 | }//void Insert_tContainer(void) |
|---|
| 862 | |
|---|
| 863 | |
|---|
| 864 | void Update_tContainer(char *cRowid) |
|---|
| 865 | { |
|---|
| 866 | sprintf(gcQuery,"UPDATE tContainer SET uContainer=%u,cLabel='%s',cHostname='%s',uVeth=%u,uIPv4=%u," |
|---|
| 867 | "uOSTemplate=%u,uConfig=%u,uNameserver=%u,uSearchdomain=%u,uDatacenter=%u," |
|---|
| 868 | "uNode=%u,uStatus=%u,uModBy=%u,uModDate=UNIX_TIMESTAMP(NOW()) WHERE _rowid=%s", |
|---|
| 869 | uContainer |
|---|
| 870 | ,TextAreaSave(cLabel) |
|---|
| 871 | ,TextAreaSave(cHostname) |
|---|
| 872 | ,uVeth |
|---|
| 873 | ,uIPv4 |
|---|
| 874 | ,uOSTemplate |
|---|
| 875 | ,uConfig |
|---|
| 876 | ,uNameserver |
|---|
| 877 | ,uSearchdomain |
|---|
| 878 | ,uDatacenter |
|---|
| 879 | ,uNode |
|---|
| 880 | ,uStatus |
|---|
| 881 | ,uModBy |
|---|
| 882 | ,cRowid); |
|---|
| 883 | MYSQL_RUN; |
|---|
| 884 | }//void Update_tContainer(void) |
|---|
| 885 | |
|---|
| 886 | |
|---|
| 887 | void ModtContainer(void) |
|---|
| 888 | { |
|---|
| 889 | register int i=0; |
|---|
| 890 | MYSQL_RES *res; |
|---|
| 891 | MYSQL_ROW field; |
|---|
| 892 | unsigned uPreModDate=0; |
|---|
| 893 | |
|---|
| 894 | //Mod select gcQuery |
|---|
| 895 | if(guPermLevel<10) |
|---|
| 896 | sprintf(gcQuery,"SELECT tContainer.uContainer,\ |
|---|
| 897 | tContainer.uModDate\ |
|---|
| 898 | FROM tContainer,tClient\ |
|---|
| 899 | WHERE tContainer.uContainer=%u\ |
|---|
| 900 | AND tContainer.uOwner=tClient.uClient\ |
|---|
| 901 | AND (tClient.uOwner=%u OR tClient.uClient=%u)" |
|---|
| 902 | ,uContainer,guLoginClient,guLoginClient); |
|---|
| 903 | else |
|---|
| 904 | sprintf(gcQuery,"SELECT uContainer,uModDate FROM tContainer\ |
|---|
| 905 | WHERE uContainer=%u" |
|---|
| 906 | ,uContainer); |
|---|
| 907 | MYSQL_RUN_STORE(res); |
|---|
| 908 | i=mysql_num_rows(res); |
|---|
| 909 | |
|---|
| 910 | //if(i<1) tContainer("<blink>Record does not exist"); |
|---|
| 911 | if(i<1) tContainer(LANG_NBR_RECNOTEXIST); |
|---|
| 912 | //if(i>1) tContainer("<blink>Multiple rows!"); |
|---|
| 913 | if(i>1) tContainer(LANG_NBR_MULTRECS); |
|---|
| 914 | |
|---|
| 915 | field=mysql_fetch_row(res); |
|---|
| 916 | sscanf(field[1],"%u",&uPreModDate); |
|---|
| 917 | if(uPreModDate!=uModDate) tContainer(LANG_NBR_EXTMOD); |
|---|
| 918 | |
|---|
| 919 | Update_tContainer(field[0]); |
|---|
| 920 | if(mysql_errno(&gMysql)) htmlPlainTextError(mysql_error(&gMysql)); |
|---|
| 921 | //sprintf(query,"record %s modified",field[0]); |
|---|
| 922 | sprintf(gcQuery,LANG_NBRF_REC_MODIFIED,field[0]); |
|---|
| 923 | uModDate=luGetModDate("tContainer",uContainer); |
|---|
| 924 | unxsVZLog(uContainer,"tContainer","Mod"); |
|---|
| 925 | tContainer(gcQuery); |
|---|
| 926 | |
|---|
| 927 | }//ModtContainer(void) |
|---|
| 928 | |
|---|
| 929 | |
|---|
| 930 | void tContainerList(void) |
|---|
| 931 | { |
|---|
| 932 | MYSQL_RES *res; |
|---|
| 933 | MYSQL_ROW field; |
|---|
| 934 | |
|---|
| 935 | ExttContainerListSelect(); |
|---|
| 936 | |
|---|
| 937 | MYSQL_RUN_STORE(res); |
|---|
| 938 | guI=mysql_num_rows(res); |
|---|
| 939 | |
|---|
| 940 | PageMachine("tContainerList",1,"");//1 is auto header list guMode. Opens table! |
|---|
| 941 | |
|---|
| 942 | //Filter select drop down |
|---|
| 943 | ExttContainerListFilter(); |
|---|
| 944 | |
|---|
| 945 | printf("<input type=text size=16 name=gcCommand maxlength=98 value=\"%s\" >",gcCommand); |
|---|
| 946 | |
|---|
| 947 | printf("</table>\n"); |
|---|
| 948 | |
|---|
| 949 | printf("<table bgcolor=#9BC1B3 border=0 width=100%%>\n"); |
|---|
| 950 | printf("<tr bgcolor=black>" |
|---|
| 951 | "<td><font face=arial,helvetica color=white>uContainer" |
|---|
| 952 | "<td><font face=arial,helvetica color=white>cLabel" |
|---|
| 953 | "<td><font face=arial,helvetica color=white>cHostname" |
|---|
| 954 | "<td><font face=arial,helvetica color=white>uVeth" |
|---|
| 955 | "<td><font face=arial,helvetica color=white>uIPv4" |
|---|
| 956 | "<td><font face=arial,helvetica color=white>uOSTemplate" |
|---|
| 957 | "<td><font face=arial,helvetica color=white>uConfig" |
|---|
| 958 | "<td><font face=arial,helvetica color=white>uNameserver" |
|---|
| 959 | "<td><font face=arial,helvetica color=white>uSearchdomain" |
|---|
| 960 | "<td><font face=arial,helvetica color=white>uDatacenter" |
|---|
| 961 | "<td><font face=arial,helvetica color=white>uNode" |
|---|
| 962 | "<td><font face=arial,helvetica color=white>uStatus" |
|---|
| 963 | "<td><font face=arial,helvetica color=white>uOwner" |
|---|
| 964 | "<td><font face=arial,helvetica color=white>uCreatedBy" |
|---|
| 965 | "<td><font face=arial,helvetica color=white>uCreatedDate" |
|---|
| 966 | "<td><font face=arial,helvetica color=white>uModBy" |
|---|
| 967 | "<td><font face=arial,helvetica color=white>uModDate" |
|---|
| 968 | "<td><font face=arial,helvetica color=white>uBackupDate</tr>"); |
|---|
| 969 | |
|---|
| 970 | mysql_data_seek(res,guStart-1); |
|---|
| 971 | |
|---|
| 972 | for(guN=0;guN<(guEnd-guStart+1);guN++) |
|---|
| 973 | { |
|---|
| 974 | field=mysql_fetch_row(res); |
|---|
| 975 | if(!field) |
|---|
| 976 | { |
|---|
| 977 | printf("<tr><td><font face=arial,helvetica>End of data</table>"); |
|---|
| 978 | Footer_ism3(); |
|---|
| 979 | } |
|---|
| 980 | if(guN % 2) |
|---|
| 981 | printf("<tr bgcolor=#BBE1D3>"); |
|---|
| 982 | else |
|---|
| 983 | printf("<tr>"); |
|---|
| 984 | time_t luTime14=strtoul(field[14],NULL,10); |
|---|
| 985 | char cBuf14[32]; |
|---|
| 986 | if(luTime14) |
|---|
| 987 | ctime_r(&luTime14,cBuf14); |
|---|
| 988 | else |
|---|
| 989 | sprintf(cBuf14,"---"); |
|---|
| 990 | time_t luTime16=strtoul(field[16],NULL,10); |
|---|
| 991 | char cBuf16[32]; |
|---|
| 992 | if(luTime16) |
|---|
| 993 | ctime_r(&luTime16,cBuf16); |
|---|
| 994 | else |
|---|
| 995 | sprintf(cBuf16,"---"); |
|---|
| 996 | time_t luTime17=strtoul(field[17],NULL,10); |
|---|
| 997 | char cBuf17[32]; |
|---|
| 998 | if(luTime17) |
|---|
| 999 | ctime_r(&luTime17,cBuf17); |
|---|
| 1000 | else |
|---|
| 1001 | sprintf(cBuf17,"---"); |
|---|
| 1002 | printf("<td><a class=darkLink href=unxsVZ.cgi?gcFunction=tContainer&uContainer=%s>" |
|---|
| 1003 | "%s<a><td>%s<td>%s<td>%s<td>%s<td>%s" |
|---|
| 1004 | "<td>%s<td>%s<td>%s<td>%s<td>%s<td>%s<td>%s<td>%s<td>%s<td>%s<td>%s<td>%s</tr>" |
|---|
| 1005 | ,field[0] |
|---|
| 1006 | ,field[0] |
|---|
| 1007 | ,field[1] |
|---|
| 1008 | ,field[2] |
|---|
| 1009 | ,field[3] |
|---|
| 1010 | ,ForeignKey("tIP","cLabel",strtoul(field[4],NULL,10)) |
|---|
| 1011 | ,ForeignKey("tOSTemplate","cLabel",strtoul(field[5],NULL,10)) |
|---|
| 1012 | ,ForeignKey("tConfig","cLabel",strtoul(field[6],NULL,10)) |
|---|
| 1013 | ,ForeignKey("tNameserver","cLabel",strtoul(field[7],NULL,10)) |
|---|
| 1014 | ,ForeignKey("tSearchdomain","cLabel",strtoul(field[8],NULL,10)) |
|---|
| 1015 | ,ForeignKey("tDatacenter","cLabel",strtoul(field[9],NULL,10)) |
|---|
| 1016 | ,ForeignKey("tNode","cLabel",strtoul(field[10],NULL,10)) |
|---|
| 1017 | ,ForeignKey("tStatus","cLabel",strtoul(field[11],NULL,10)) |
|---|
| 1018 | ,ForeignKey("tClient","cLabel",strtoul(field[12],NULL,10)) |
|---|
| 1019 | ,ForeignKey("tClient","cLabel",strtoul(field[13],NULL,10)) |
|---|
| 1020 | ,cBuf14 |
|---|
| 1021 | ,ForeignKey("tClient","cLabel",strtoul(field[15],NULL,10)) |
|---|
| 1022 | ,cBuf16 |
|---|
| 1023 | ,cBuf17 |
|---|
| 1024 | ); |
|---|
| 1025 | |
|---|
| 1026 | } |
|---|
| 1027 | |
|---|
| 1028 | printf("</table></form>\n"); |
|---|
| 1029 | Footer_ism3(); |
|---|
| 1030 | |
|---|
| 1031 | }//tContainerList() |
|---|
| 1032 | |
|---|
| 1033 | |
|---|
| 1034 | void CreatetContainer(void) |
|---|
| 1035 | { |
|---|
| 1036 | sprintf(gcQuery,"CREATE TABLE IF NOT EXISTS tContainer ( " |
|---|
| 1037 | "uContainer INT UNSIGNED PRIMARY KEY AUTO_INCREMENT," |
|---|
| 1038 | "cLabel VARCHAR(32) NOT NULL DEFAULT ''," |
|---|
| 1039 | "uOwner INT UNSIGNED NOT NULL DEFAULT 0, INDEX (uOwner)," |
|---|
| 1040 | "uCreatedBy INT UNSIGNED NOT NULL DEFAULT 0," |
|---|
| 1041 | "uCreatedDate INT UNSIGNED NOT NULL DEFAULT 0," |
|---|
| 1042 | "uBackupDate INT UNSIGNED NOT NULL DEFAULT 0," |
|---|
| 1043 | "uModBy INT UNSIGNED NOT NULL DEFAULT 0," |
|---|
| 1044 | "uModDate INT UNSIGNED NOT NULL DEFAULT 0," |
|---|
| 1045 | "uDatacenter INT UNSIGNED NOT NULL DEFAULT 0, INDEX(uDatacenter)," |
|---|
| 1046 | "UNIQUE (cLabel,uDatacenter)," |
|---|
| 1047 | "uNode INT UNSIGNED NOT NULL DEFAULT 0,INDEX (uNode)," |
|---|
| 1048 | "uStatus INT UNSIGNED NOT NULL DEFAULT 0," |
|---|
| 1049 | "uOSTemplate INT UNSIGNED NOT NULL DEFAULT 0," |
|---|
| 1050 | "cHostname VARCHAR(64) NOT NULL DEFAULT ''," |
|---|
| 1051 | "uIPv4 INT UNSIGNED NOT NULL DEFAULT 0," |
|---|
| 1052 | "uNameserver INT UNSIGNED NOT NULL DEFAULT 0," |
|---|
| 1053 | "uSearchdomain INT UNSIGNED NOT NULL DEFAULT 0," |
|---|
| 1054 | "uConfig INT UNSIGNED NOT NULL DEFAULT 0," |
|---|
| 1055 | "uVeth INT UNSIGNED NOT NULL DEFAULT 0," |
|---|
| 1056 | "uSource INT UNSIGNED NOT NULL DEFAULT 0, INDEX (uSource) )"); |
|---|
| 1057 | mysql_query(&gMysql,gcQuery); |
|---|
| 1058 | if(mysql_errno(&gMysql)) |
|---|
| 1059 | htmlPlainTextError(mysql_error(&gMysql)); |
|---|
| 1060 | }//CreatetContainer() |
|---|
| 1061 | |
|---|
| 1062 | |
|---|
| 1063 | void tTablePullDownAvail(const char *cTableName, const char *cFieldName, |
|---|
| 1064 | const char *cOrderby, unsigned uSelector, unsigned uMode) |
|---|
| 1065 | { |
|---|
| 1066 | register int i,n; |
|---|
| 1067 | char cLabel[128]; |
|---|
| 1068 | MYSQL_RES *mysqlRes; |
|---|
| 1069 | MYSQL_ROW mysqlField; |
|---|
| 1070 | |
|---|
| 1071 | char cSelectName[34]={""}; |
|---|
| 1072 | char cHidden[100]={""}; |
|---|
| 1073 | char cLocalTableName[256]={""}; |
|---|
| 1074 | char *cp; |
|---|
| 1075 | char *cMode=""; |
|---|
| 1076 | |
|---|
| 1077 | if(!uMode) |
|---|
| 1078 | cMode="disabled"; |
|---|
| 1079 | |
|---|
| 1080 | if(!cTableName[0] || !cFieldName[0] || !cOrderby[0]) |
|---|
| 1081 | { |
|---|
| 1082 | printf("Invalid input tTablePullDown()"); |
|---|
| 1083 | return; |
|---|
| 1084 | } |
|---|
| 1085 | |
|---|
| 1086 | //Extended functionality |
|---|
| 1087 | strncpy(cLocalTableName,cTableName,255); |
|---|
| 1088 | if((cp=strchr(cLocalTableName,';'))) |
|---|
| 1089 | { |
|---|
| 1090 | strncpy(cSelectName,cp+1,32); |
|---|
| 1091 | cSelectName[32]=0; |
|---|
| 1092 | *cp=0; |
|---|
| 1093 | } |
|---|
| 1094 | |
|---|
| 1095 | |
|---|
| 1096 | if(guCompany==1) |
|---|
| 1097 | sprintf(gcQuery,"SELECT _rowid,%s FROM %s WHERE uAvailable=1 ORDER BY %s", |
|---|
| 1098 | cFieldName,cLocalTableName,cOrderby); |
|---|
| 1099 | else |
|---|
| 1100 | sprintf(gcQuery,"SELECT _rowid,%s FROM %s WHERE uAvailable=1 AND uOwner=%u ORDER BY %s", |
|---|
| 1101 | cFieldName,cLocalTableName,guCompany,cOrderby); |
|---|
| 1102 | |
|---|
| 1103 | MYSQL_RUN_STORE_TEXT_RET_VOID(mysqlRes); |
|---|
| 1104 | i=mysql_num_rows(mysqlRes); |
|---|
| 1105 | |
|---|
| 1106 | if(cSelectName[0]) |
|---|
| 1107 | sprintf(cLabel,"%s",cSelectName); |
|---|
| 1108 | else |
|---|
| 1109 | sprintf(cLabel,"%s_%sPullDown",cLocalTableName,cFieldName); |
|---|
| 1110 | |
|---|
| 1111 | if(i>0) |
|---|
| 1112 | { |
|---|
| 1113 | printf("<select name=%s %s>\n",cLabel,cMode); |
|---|
| 1114 | |
|---|
| 1115 | //Default no selection |
|---|
| 1116 | printf("<option title='No selection'>---</option>\n"); |
|---|
| 1117 | |
|---|
| 1118 | for(n=0;n<i;n++) |
|---|
| 1119 | { |
|---|
| 1120 | int unsigned field0=0; |
|---|
| 1121 | |
|---|
| 1122 | mysqlField=mysql_fetch_row(mysqlRes); |
|---|
| 1123 | sscanf(mysqlField[0],"%u",&field0); |
|---|
| 1124 | |
|---|
| 1125 | if(uSelector != field0) |
|---|
| 1126 | { |
|---|
| 1127 | printf("<option>%s</option>\n",mysqlField[1]); |
|---|
| 1128 | } |
|---|
| 1129 | else |
|---|
| 1130 | { |
|---|
| 1131 | printf("<option selected>%s</option>\n",mysqlField[1]); |
|---|
| 1132 | if(!uMode) |
|---|
| 1133 | sprintf(cHidden,"<input type=hidden name=%.32s value='%.32s'>\n", |
|---|
| 1134 | cLabel,mysqlField[1]); |
|---|
| 1135 | } |
|---|
| 1136 | } |
|---|
| 1137 | } |
|---|
| 1138 | else |
|---|
| 1139 | { |
|---|
| 1140 | printf("<select name=%s %s><option title='No selection'>---</option></select>\n" |
|---|
| 1141 | ,cLabel,cMode); |
|---|
| 1142 | if(!uMode) |
|---|
| 1143 | sprintf(cHidden,"<input type=hidden name=%.32s value='0'>\n",cLabel); |
|---|
| 1144 | } |
|---|
| 1145 | printf("</select>\n"); |
|---|
| 1146 | if(cHidden[0]) |
|---|
| 1147 | printf("%s",cHidden); |
|---|
| 1148 | |
|---|
| 1149 | }//tTablePullDownAvail() |
|---|
| 1150 | |
|---|
| 1151 | |
|---|
| 1152 | void tTablePullDownOwnerAvail(const char *cTableName, const char *cFieldName, |
|---|
| 1153 | const char *cOrderby, unsigned uSelector, unsigned uMode) |
|---|
| 1154 | { |
|---|
| 1155 | register int i,n; |
|---|
| 1156 | char cLabel[256]; |
|---|
| 1157 | MYSQL_RES *mysqlRes; |
|---|
| 1158 | MYSQL_ROW mysqlField; |
|---|
| 1159 | |
|---|
| 1160 | char cSelectName[100]={""}; |
|---|
| 1161 | char cHidden[100]={""}; |
|---|
| 1162 | char cLocalTableName[256]={""}; |
|---|
| 1163 | char *cp; |
|---|
| 1164 | char *cMode=""; |
|---|
| 1165 | |
|---|
| 1166 | if(!uMode) |
|---|
| 1167 | cMode="disabled"; |
|---|
| 1168 | |
|---|
| 1169 | if(!cTableName[0] || !cFieldName[0] || !cOrderby[0]) |
|---|
| 1170 | { |
|---|
| 1171 | printf("Invalid input tTablePullDownAvail()"); |
|---|
| 1172 | return; |
|---|
| 1173 | } |
|---|
| 1174 | |
|---|
| 1175 | //Extended functionality |
|---|
| 1176 | strncpy(cLocalTableName,cTableName,255); |
|---|
| 1177 | if((cp=strchr(cLocalTableName,';'))) |
|---|
| 1178 | { |
|---|
| 1179 | strncpy(cSelectName,cp+1,99); |
|---|
| 1180 | cSelectName[99]=0; |
|---|
| 1181 | *cp=0; |
|---|
| 1182 | } |
|---|
| 1183 | |
|---|
| 1184 | |
|---|
| 1185 | if(guLoginClient==1) |
|---|
| 1186 | sprintf(gcQuery,"SELECT _rowid,%s FROM %s WHERE uAvailable=1 ORDER BY %s", |
|---|
| 1187 | cFieldName,cLocalTableName,cOrderby); |
|---|
| 1188 | else |
|---|
| 1189 | sprintf(gcQuery,"SELECT _rowid,%s FROM %s WHERE uAvailable=1 AND ( uOwner=%u OR uOwner IN" |
|---|
| 1190 | " (SELECT uClient FROM " TCLIENT " WHERE uOwner=%u)) ORDER BY %s", |
|---|
| 1191 | cFieldName,cLocalTableName,guCompany,guCompany,cOrderby); |
|---|
| 1192 | |
|---|
| 1193 | MYSQL_RUN_STORE_TEXT_RET_VOID(mysqlRes); |
|---|
| 1194 | i=mysql_num_rows(mysqlRes); |
|---|
| 1195 | |
|---|
| 1196 | if(cSelectName[0]) |
|---|
| 1197 | sprintf(cLabel,"%s",cSelectName); |
|---|
| 1198 | else |
|---|
| 1199 | sprintf(cLabel,"%s_%sPullDown",cLocalTableName,cFieldName); |
|---|
| 1200 | |
|---|
| 1201 | if(i>0) |
|---|
| 1202 | { |
|---|
| 1203 | int unsigned field0; |
|---|
| 1204 | printf("<select name=%s %s>\n",cLabel,cMode); |
|---|
| 1205 | |
|---|
| 1206 | //Default no selection |
|---|
| 1207 | printf("<option title='No selection'>---</option>\n"); |
|---|
| 1208 | |
|---|
| 1209 | for(n=0;n<i;n++) |
|---|
| 1210 | { |
|---|
| 1211 | |
|---|
| 1212 | field0=0; |
|---|
| 1213 | mysqlField=mysql_fetch_row(mysqlRes); |
|---|
| 1214 | sscanf(mysqlField[0],"%u",&field0); |
|---|
| 1215 | |
|---|
| 1216 | if(uSelector != field0) |
|---|
| 1217 | { |
|---|
| 1218 | printf("<option>%s</option>\n",mysqlField[1]); |
|---|
| 1219 | } |
|---|
| 1220 | else |
|---|
| 1221 | { |
|---|
| 1222 | printf("<option selected>%s</option>\n",mysqlField[1]); |
|---|
| 1223 | if(!uMode) |
|---|
| 1224 | sprintf(cHidden,"<input type=hidden name=%.99s value='%.99s'>\n", |
|---|
| 1225 | cLabel,mysqlField[1]); |
|---|
| 1226 | } |
|---|
| 1227 | } |
|---|
| 1228 | } |
|---|
| 1229 | else |
|---|
| 1230 | { |
|---|
| 1231 | printf("<select name=%s %s><option title='No selection'>---</option></select>\n" |
|---|
| 1232 | ,cLabel,cMode); |
|---|
| 1233 | if(!uMode) |
|---|
| 1234 | sprintf(cHidden,"<input type=hidden name=%99s value='0'>\n",cLabel); |
|---|
| 1235 | } |
|---|
| 1236 | printf("</select>\n"); |
|---|
| 1237 | if(cHidden[0]) |
|---|
| 1238 | printf("%s",cHidden); |
|---|
| 1239 | |
|---|
| 1240 | }//tTablePullDownOwnerAvail() |
|---|
| 1241 | |
|---|
| 1242 | |
|---|
| 1243 | void tTablePullDownDatacenter(const char *cTableName, const char *cFieldName, |
|---|
| 1244 | const char *cOrderby, unsigned uSelector, unsigned uMode, const char *cDatacenter, |
|---|
| 1245 | unsigned uType, unsigned uDatacenter) |
|---|
| 1246 | { |
|---|
| 1247 | register int i,n; |
|---|
| 1248 | char cLabel[256]; |
|---|
| 1249 | MYSQL_RES *mysqlRes; |
|---|
| 1250 | MYSQL_ROW mysqlField; |
|---|
| 1251 | |
|---|
| 1252 | char cSelectName[100]={""}; |
|---|
| 1253 | char cHidden[100]={""}; |
|---|
| 1254 | char cLocalTableName[256]={""}; |
|---|
| 1255 | char *cp; |
|---|
| 1256 | char *cMode=""; |
|---|
| 1257 | |
|---|
| 1258 | if(!uMode) |
|---|
| 1259 | cMode="disabled"; |
|---|
| 1260 | |
|---|
| 1261 | if(!cTableName[0] || !cFieldName[0] || !cOrderby[0]) |
|---|
| 1262 | { |
|---|
| 1263 | printf("Invalid input tTablePullDownDatacenter()"); |
|---|
| 1264 | return; |
|---|
| 1265 | } |
|---|
| 1266 | |
|---|
| 1267 | //Extended functionality |
|---|
| 1268 | sprintf(cLocalTableName,"%.255s",cTableName); |
|---|
| 1269 | if((cp=strchr(cLocalTableName,';'))) |
|---|
| 1270 | { |
|---|
| 1271 | sprintf(cSelectName,"%.99s",cp+1); |
|---|
| 1272 | *cp=0; |
|---|
| 1273 | } |
|---|
| 1274 | |
|---|
| 1275 | if(uType) |
|---|
| 1276 | //This does not work in 5.0.77 |
|---|
| 1277 | //sprintf(gcQuery,"SELECT _rowid AS uRowid,%s FROM %s WHERE" |
|---|
| 1278 | // " LOCATE('All Datacenters'," |
|---|
| 1279 | // "(SELECT cValue FROM tProperty WHERE cName='cDatacenter' AND uType=%u AND uKey=uRowid))>0" |
|---|
| 1280 | // " OR LOCATE('%s'," |
|---|
| 1281 | // "(SELECT cValue FROM tProperty WHERE cName='cDatacenter' AND uType=%u AND uKey=uRowid))>0" |
|---|
| 1282 | // " ORDER BY %s", |
|---|
| 1283 | // cFieldName,cLocalTableName,uType,cDatacenter,uType,cOrderby); |
|---|
| 1284 | |
|---|
| 1285 | //SELECT _rowid,cLabel FROM tOSTemplate WHERE _rowid IN (SELECT uKey FROM tProperty WHERE cName='cDatacenter' AND uType=8 AND (cValue='All Datacenters' OR cValue='Wilshire1')); |
|---|
| 1286 | sprintf(gcQuery,"SELECT _rowid,%s FROM %s WHERE" |
|---|
| 1287 | " _rowid IN" |
|---|
| 1288 | " (SELECT uKey FROM tProperty WHERE cName='cDatacenter' AND" |
|---|
| 1289 | " uType=%u AND (cValue='All Datacenters' OR LOCATE('%s',cValue)>0))" |
|---|
| 1290 | " ORDER BY %s", |
|---|
| 1291 | cFieldName,cLocalTableName,uType,cDatacenter,cOrderby); |
|---|
| 1292 | else |
|---|
| 1293 | sprintf(gcQuery,"SELECT _rowid,%s FROM %s WHERE uDatacenter=%u ORDER BY %s", |
|---|
| 1294 | cFieldName,cLocalTableName,uDatacenter,cOrderby); |
|---|
| 1295 | mysql_query(&gMysql,gcQuery); |
|---|
| 1296 | if(mysql_errno(&gMysql)) |
|---|
| 1297 | { |
|---|
| 1298 | printf("%s\n",mysql_error(&gMysql)); |
|---|
| 1299 | return; |
|---|
| 1300 | } |
|---|
| 1301 | mysqlRes=mysql_store_result(&gMysql); |
|---|
| 1302 | i=mysql_num_rows(mysqlRes); |
|---|
| 1303 | |
|---|
| 1304 | if(cSelectName[0]) |
|---|
| 1305 | sprintf(cLabel,"%s",cSelectName); |
|---|
| 1306 | else |
|---|
| 1307 | sprintf(cLabel,"%s_%sPullDown",cLocalTableName,cFieldName); |
|---|
| 1308 | |
|---|
| 1309 | if(i>0) |
|---|
| 1310 | { |
|---|
| 1311 | int unsigned field0; |
|---|
| 1312 | |
|---|
| 1313 | printf("<select name=%s %s>\n",cLabel,cMode); |
|---|
| 1314 | //Default no selection |
|---|
| 1315 | printf("<option title='No selection'>---</option>\n"); |
|---|
| 1316 | |
|---|
| 1317 | for(n=0;n<i;n++) |
|---|
| 1318 | { |
|---|
| 1319 | |
|---|
| 1320 | field0=0; |
|---|
| 1321 | mysqlField=mysql_fetch_row(mysqlRes); |
|---|
| 1322 | sscanf(mysqlField[0],"%u",&field0); |
|---|
| 1323 | |
|---|
| 1324 | if(uSelector != field0) |
|---|
| 1325 | { |
|---|
| 1326 | printf("<option>%s</option>\n",mysqlField[1]); |
|---|
| 1327 | } |
|---|
| 1328 | else |
|---|
| 1329 | { |
|---|
| 1330 | printf("<option selected>%s</option>\n",mysqlField[1]); |
|---|
| 1331 | if(!uMode) |
|---|
| 1332 | sprintf(cHidden,"<input type=hidden name=%.99s value='%.99s'>\n", |
|---|
| 1333 | cLabel,mysqlField[1]); |
|---|
| 1334 | } |
|---|
| 1335 | } |
|---|
| 1336 | } |
|---|
| 1337 | else |
|---|
| 1338 | { |
|---|
| 1339 | printf("<select name=%s %s><option title='No selection'>---</option></select>\n" |
|---|
| 1340 | ,cLabel,cMode); |
|---|
| 1341 | if(!uMode) |
|---|
| 1342 | sprintf(cHidden,"<input type=hidden name=%99s value='0'>\n",cLabel); |
|---|
| 1343 | } |
|---|
| 1344 | printf("</select>\n"); |
|---|
| 1345 | if(cHidden[0]) |
|---|
| 1346 | printf("%s",cHidden); |
|---|
| 1347 | |
|---|
| 1348 | }//tTablePullDownDatacenter() |
|---|
| 1349 | |
|---|
| 1350 | |
|---|
| 1351 | void tTablePullDownOwnerAvailDatacenter(const char *cTableName, const char *cFieldName, |
|---|
| 1352 | const char *cOrderby, unsigned uSelector, unsigned uMode,unsigned uDatacenter,unsigned uClient) |
|---|
| 1353 | { |
|---|
| 1354 | register int i,n; |
|---|
| 1355 | char cLabel[256]; |
|---|
| 1356 | MYSQL_RES *mysqlRes; |
|---|
| 1357 | MYSQL_ROW mysqlField; |
|---|
| 1358 | |
|---|
| 1359 | char cSelectName[100]={""}; |
|---|
| 1360 | char cHidden[100]={""}; |
|---|
| 1361 | char cLocalTableName[256]={""}; |
|---|
| 1362 | char *cp; |
|---|
| 1363 | char *cMode=""; |
|---|
| 1364 | |
|---|
| 1365 | if(!uMode) |
|---|
| 1366 | cMode="disabled"; |
|---|
| 1367 | |
|---|
| 1368 | if(!cTableName[0] || !cFieldName[0] || !cOrderby[0]) |
|---|
| 1369 | { |
|---|
| 1370 | printf("Invalid input tTablePullDownAvailDatacenter()"); |
|---|
| 1371 | return; |
|---|
| 1372 | } |
|---|
| 1373 | |
|---|
| 1374 | //Extended functionality |
|---|
| 1375 | strncpy(cLocalTableName,cTableName,255); |
|---|
| 1376 | if((cp=strchr(cLocalTableName,';'))) |
|---|
| 1377 | { |
|---|
| 1378 | strncpy(cSelectName,cp+1,99); |
|---|
| 1379 | cSelectName[99]=0; |
|---|
| 1380 | *cp=0; |
|---|
| 1381 | } |
|---|
| 1382 | |
|---|
| 1383 | |
|---|
| 1384 | sprintf(gcQuery,"SELECT _rowid,%s FROM %s WHERE uAvailable=1 AND uDatacenter=%u AND uOwner=%u ORDER BY %s", |
|---|
| 1385 | cFieldName,cLocalTableName,uDatacenter,uClient,cOrderby); |
|---|
| 1386 | |
|---|
| 1387 | MYSQL_RUN_STORE_TEXT_RET_VOID(mysqlRes); |
|---|
| 1388 | i=mysql_num_rows(mysqlRes); |
|---|
| 1389 | |
|---|
| 1390 | if(cSelectName[0]) |
|---|
| 1391 | sprintf(cLabel,"%s",cSelectName); |
|---|
| 1392 | else |
|---|
| 1393 | sprintf(cLabel,"%s_%sPullDown",cLocalTableName,cFieldName); |
|---|
| 1394 | |
|---|
| 1395 | if(i>0) |
|---|
| 1396 | { |
|---|
| 1397 | int unsigned field0; |
|---|
| 1398 | printf("<select name=%s %s>\n",cLabel,cMode); |
|---|
| 1399 | |
|---|
| 1400 | //Default no selection |
|---|
| 1401 | printf("<option title='No selection'>---</option>\n"); |
|---|
| 1402 | |
|---|
| 1403 | for(n=0;n<i;n++) |
|---|
| 1404 | { |
|---|
| 1405 | |
|---|
| 1406 | field0=0; |
|---|
| 1407 | mysqlField=mysql_fetch_row(mysqlRes); |
|---|
| 1408 | sscanf(mysqlField[0],"%u",&field0); |
|---|
| 1409 | |
|---|
| 1410 | if(uSelector != field0) |
|---|
| 1411 | { |
|---|
| 1412 | printf("<option>%s</option>\n",mysqlField[1]); |
|---|
| 1413 | } |
|---|
| 1414 | else |
|---|
| 1415 | { |
|---|
| 1416 | printf("<option selected>%s</option>\n",mysqlField[1]); |
|---|
| 1417 | if(!uMode) |
|---|
| 1418 | sprintf(cHidden,"<input type=hidden name=%.99s value='%.99s'>\n", |
|---|
| 1419 | cLabel,mysqlField[1]); |
|---|
| 1420 | } |
|---|
| 1421 | } |
|---|
| 1422 | } |
|---|
| 1423 | else |
|---|
| 1424 | { |
|---|
| 1425 | printf("<select name=%s %s><option title='No selection'>---</option></select>\n" |
|---|
| 1426 | ,cLabel,cMode); |
|---|
| 1427 | if(!uMode) |
|---|
| 1428 | sprintf(cHidden,"<input type=hidden name=%99s value='0'>\n",cLabel); |
|---|
| 1429 | } |
|---|
| 1430 | printf("</select>\n"); |
|---|
| 1431 | if(cHidden[0]) |
|---|
| 1432 | printf("%s",cHidden); |
|---|
| 1433 | |
|---|
| 1434 | }//tTablePullDownOwnerAvailDatacenter() |
|---|
| 1435 | |
|---|