| 1 | /* |
|---|
| 2 | FILE |
|---|
| 3 | $Id$ |
|---|
| 4 | (Built initially by unixservice.com mysqlRAD2) |
|---|
| 5 | PURPOSE |
|---|
| 6 | Non schema-dependent table and application table related functions. |
|---|
| 7 | AUTHOR |
|---|
| 8 | (C) 2001-2009 Gary Wallis for Unixservice, LLC. |
|---|
| 9 | |
|---|
| 10 | */ |
|---|
| 11 | |
|---|
| 12 | static char cReturn[100]={""}; |
|---|
| 13 | static char cUBCName[100]={""}; |
|---|
| 14 | static long unsigned luBarrier=0; |
|---|
| 15 | static long unsigned luLimit=0; |
|---|
| 16 | |
|---|
| 17 | //ModuleFunctionProtos() |
|---|
| 18 | unsigned SetUBCJob(unsigned uContainer,char *cSet); |
|---|
| 19 | void htmlReturnLink(void); |
|---|
| 20 | void htmlGlossaryLink(char *cLabel); |
|---|
| 21 | |
|---|
| 22 | //jobqueue.c |
|---|
| 23 | unsigned SetContainerProperty(const unsigned uContainer,const char *cPropertyName,const char *cPropertyValue); |
|---|
| 24 | |
|---|
| 25 | |
|---|
| 26 | void ExtProcesstPropertyVars(pentry entries[], int x) |
|---|
| 27 | { |
|---|
| 28 | register int i; |
|---|
| 29 | for(i=0;i<x;i++) |
|---|
| 30 | { |
|---|
| 31 | if(!strcmp(entries[i].name,"cReturn")) |
|---|
| 32 | sprintf(cReturn,"%.99s",entries[i].val); |
|---|
| 33 | else if(!strcmp(entries[i].name,"luBarrier")) |
|---|
| 34 | sscanf(entries[i].val,"%lu",&luBarrier); |
|---|
| 35 | else if(!strcmp(entries[i].name,"luLimit")) |
|---|
| 36 | sscanf(entries[i].val,"%lu",&luLimit); |
|---|
| 37 | else if(!strcmp(entries[i].name,"cUBCName")) |
|---|
| 38 | sprintf(cUBCName,"%.99s",entries[i].val); |
|---|
| 39 | } |
|---|
| 40 | }//void ExtProcesstPropertyVars(pentry entries[], int x) |
|---|
| 41 | |
|---|
| 42 | |
|---|
| 43 | void ExttPropertyCommands(pentry entries[], int x) |
|---|
| 44 | { |
|---|
| 45 | |
|---|
| 46 | if(!strcmp(gcFunction,"tPropertyTools")) |
|---|
| 47 | { |
|---|
| 48 | //ModuleFunctionProcess() |
|---|
| 49 | |
|---|
| 50 | if(!strcmp(gcCommand,LANG_NB_NEW)) |
|---|
| 51 | { |
|---|
| 52 | if(guPermLevel>=7) |
|---|
| 53 | { |
|---|
| 54 | ProcesstPropertyVars(entries,x); |
|---|
| 55 | guMode=2000; |
|---|
| 56 | tProperty(LANG_NB_CONFIRMNEW); |
|---|
| 57 | } |
|---|
| 58 | } |
|---|
| 59 | else if(!strcmp(gcCommand,LANG_NB_CONFIRMNEW)) |
|---|
| 60 | { |
|---|
| 61 | if(guPermLevel>=7) |
|---|
| 62 | { |
|---|
| 63 | ProcesstPropertyVars(entries,x); |
|---|
| 64 | |
|---|
| 65 | guMode=2000; |
|---|
| 66 | //Check entries here |
|---|
| 67 | guMode=0; |
|---|
| 68 | |
|---|
| 69 | uProperty=0; |
|---|
| 70 | uCreatedBy=guLoginClient; |
|---|
| 71 | uOwner=guCompany; |
|---|
| 72 | uModBy=0;//Never modified |
|---|
| 73 | uModDate=0;//Never modified |
|---|
| 74 | NewtProperty(0); |
|---|
| 75 | } |
|---|
| 76 | } |
|---|
| 77 | else if(!strcmp(gcCommand,LANG_NB_DELETE)) |
|---|
| 78 | { |
|---|
| 79 | ProcesstPropertyVars(entries,x); |
|---|
| 80 | if(uAllowDel(uOwner,uCreatedBy)) |
|---|
| 81 | { |
|---|
| 82 | guMode=2001; |
|---|
| 83 | tProperty(LANG_NB_CONFIRMDEL); |
|---|
| 84 | } |
|---|
| 85 | else |
|---|
| 86 | tProperty("<blink>Error</blink>: Insufficient permision to del"); |
|---|
| 87 | } |
|---|
| 88 | else if(!strcmp(gcCommand,LANG_NB_CONFIRMDEL)) |
|---|
| 89 | { |
|---|
| 90 | ProcesstPropertyVars(entries,x); |
|---|
| 91 | if(uAllowDel(uOwner,uCreatedBy)) |
|---|
| 92 | { |
|---|
| 93 | guMode=5; |
|---|
| 94 | DeletetProperty(); |
|---|
| 95 | } |
|---|
| 96 | else |
|---|
| 97 | tProperty("<blink>Error</blink>: Insufficient permision to del"); |
|---|
| 98 | } |
|---|
| 99 | else if(!strcmp(gcCommand,LANG_NB_MODIFY)) |
|---|
| 100 | { |
|---|
| 101 | ProcesstPropertyVars(entries,x); |
|---|
| 102 | if(uAllowMod(uOwner,uCreatedBy)) |
|---|
| 103 | { |
|---|
| 104 | guMode=2002; |
|---|
| 105 | tProperty(LANG_NB_CONFIRMMOD); |
|---|
| 106 | } |
|---|
| 107 | else |
|---|
| 108 | tProperty("<blink>Error</blink>: Insufficient permision to mod"); |
|---|
| 109 | } |
|---|
| 110 | else if(!strcmp(gcCommand,LANG_NB_CONFIRMMOD)) |
|---|
| 111 | { |
|---|
| 112 | ProcesstPropertyVars(entries,x); |
|---|
| 113 | if(uAllowMod(uOwner,uCreatedBy)) |
|---|
| 114 | { |
|---|
| 115 | guMode=2002; |
|---|
| 116 | //Check entries here |
|---|
| 117 | guMode=0; |
|---|
| 118 | |
|---|
| 119 | uModBy=guLoginClient; |
|---|
| 120 | ModtProperty(); |
|---|
| 121 | } |
|---|
| 122 | else |
|---|
| 123 | tProperty("<blink>Error</blink>: Insufficient permision to mod"); |
|---|
| 124 | } |
|---|
| 125 | else if(!strcmp(gcCommand,"Set UBC/Diskspace")) |
|---|
| 126 | { |
|---|
| 127 | ProcesstPropertyVars(entries,x); |
|---|
| 128 | if(uAllowMod(uOwner,uCreatedBy)) |
|---|
| 129 | { |
|---|
| 130 | char cMessage[64]; |
|---|
| 131 | |
|---|
| 132 | guMode=0; |
|---|
| 133 | if(!uKey) |
|---|
| 134 | tProperty("<blink>Error</blink>: uKey==0"); |
|---|
| 135 | if(uType!=3) |
|---|
| 136 | tProperty("<blink>Error</blink>: uType!=VZContainer"); |
|---|
| 137 | if(luBarrier==0 || luLimit==0) |
|---|
| 138 | tProperty("<blink>Error</blink>: luBarrier==0 || luLimit==0"); |
|---|
| 139 | |
|---|
| 140 | sprintf(cMessage,"--%s %lu:%lu",cUBCName,luBarrier,luLimit); |
|---|
| 141 | if(SetUBCJob(uKey,cMessage)) |
|---|
| 142 | { |
|---|
| 143 | |
|---|
| 144 | sprintf(cMessage,"Set UBC --%s %lu:%lu job created ok", |
|---|
| 145 | cUBCName,luBarrier,luLimit); |
|---|
| 146 | tProperty(cMessage); |
|---|
| 147 | } |
|---|
| 148 | else |
|---|
| 149 | { |
|---|
| 150 | tProperty("<blink>Error</blink>: No job created!"); |
|---|
| 151 | } |
|---|
| 152 | } |
|---|
| 153 | else |
|---|
| 154 | tProperty("<blink>Error</blink>: Insufficient permision to mod"); |
|---|
| 155 | } |
|---|
| 156 | else if(!strcmp(gcCommand,"Set UBC/Diskspace +20%")) |
|---|
| 157 | { |
|---|
| 158 | ProcesstPropertyVars(entries,x); |
|---|
| 159 | if(uAllowMod(uOwner,uCreatedBy)) |
|---|
| 160 | { |
|---|
| 161 | char cMessage[256]; |
|---|
| 162 | char cluBarrier[32]; |
|---|
| 163 | char cluLimit[32]; |
|---|
| 164 | |
|---|
| 165 | guMode=0; |
|---|
| 166 | if(!uKey) |
|---|
| 167 | tProperty("<blink>Error</blink>: uKey==0"); |
|---|
| 168 | if(uType!=3) |
|---|
| 169 | tProperty("<blink>Error</blink>: uType!=VZContainer"); |
|---|
| 170 | if(luBarrier==0 || luLimit==0) |
|---|
| 171 | tProperty("<blink>Error</blink>: luBarrier==0 || luLimit==0"); |
|---|
| 172 | |
|---|
| 173 | luBarrier=(long unsigned)luBarrier*1.2; |
|---|
| 174 | luLimit=(long unsigned)luLimit*1.2; |
|---|
| 175 | sprintf(cluBarrier,"%lu",luBarrier); |
|---|
| 176 | sprintf(cluLimit,"%lu",luLimit); |
|---|
| 177 | sprintf(cMessage,"--%.99s %.31s:%.31s",cUBCName,cluBarrier,cluLimit); |
|---|
| 178 | if(SetUBCJob(uKey,cMessage)) |
|---|
| 179 | { |
|---|
| 180 | |
|---|
| 181 | if(!strcmp(cUBCName,"diskspace")) |
|---|
| 182 | sprintf(cMessage,"1k-blocks.luSoftlimit"); |
|---|
| 183 | else |
|---|
| 184 | sprintf(cMessage,"%.99s.luLimit",cUBCName); |
|---|
| 185 | if(SetContainerProperty(uKey,cMessage,cluBarrier)) |
|---|
| 186 | tProperty(cMessage); |
|---|
| 187 | |
|---|
| 188 | |
|---|
| 189 | if(!strcmp(cUBCName,"diskspace")) |
|---|
| 190 | sprintf(cMessage,"1k-blocks.luHardlimit"); |
|---|
| 191 | else |
|---|
| 192 | sprintf(cMessage,"%.99s.luBarrier",cUBCName); |
|---|
| 193 | if(SetContainerProperty(uKey,cMessage,cluLimit)) |
|---|
| 194 | tProperty(cMessage); |
|---|
| 195 | |
|---|
| 196 | sprintf(cMessage,"Set UBC --%s %s:%s job created ok", |
|---|
| 197 | cUBCName,cluBarrier,cluLimit); |
|---|
| 198 | tProperty(cMessage); |
|---|
| 199 | } |
|---|
| 200 | else |
|---|
| 201 | { |
|---|
| 202 | tProperty("<blink>Error</blink>: No job created!"); |
|---|
| 203 | } |
|---|
| 204 | } |
|---|
| 205 | else |
|---|
| 206 | tProperty("<blink>Error</blink>: Insufficient permision to mod"); |
|---|
| 207 | } |
|---|
| 208 | else if(!strcmp(gcCommand,"Set UBC/Diskspace -20%")) |
|---|
| 209 | { |
|---|
| 210 | ProcesstPropertyVars(entries,x); |
|---|
| 211 | if(uAllowMod(uOwner,uCreatedBy)) |
|---|
| 212 | { |
|---|
| 213 | char cMessage[256]; |
|---|
| 214 | char cluBarrier[32]; |
|---|
| 215 | char cluLimit[32]; |
|---|
| 216 | |
|---|
| 217 | guMode=0; |
|---|
| 218 | if(!uKey) |
|---|
| 219 | tProperty("<blink>Error</blink>: uKey==0"); |
|---|
| 220 | if(uType!=3) |
|---|
| 221 | tProperty("<blink>Error</blink>: uType!=VZContainer"); |
|---|
| 222 | if(luBarrier==0 || luLimit==0) |
|---|
| 223 | tProperty("<blink>Error</blink>: luBarrier==0 || luLimit==0"); |
|---|
| 224 | |
|---|
| 225 | luBarrier=(long unsigned)luBarrier*0.8; |
|---|
| 226 | luLimit=(long unsigned)luLimit*0.8; |
|---|
| 227 | sprintf(cluBarrier,"%lu",luBarrier); |
|---|
| 228 | sprintf(cluLimit,"%lu",luLimit); |
|---|
| 229 | sprintf(cMessage,"--%.99s %.31s:%.31s",cUBCName,cluBarrier,cluLimit); |
|---|
| 230 | if(SetUBCJob(uKey,cMessage)) |
|---|
| 231 | { |
|---|
| 232 | |
|---|
| 233 | if(!strcmp(cUBCName,"diskspace")) |
|---|
| 234 | sprintf(cMessage,"1k-blocks.luSoftlimit"); |
|---|
| 235 | else |
|---|
| 236 | sprintf(cMessage,"%.99s.luLimit",cUBCName); |
|---|
| 237 | if(SetContainerProperty(uKey,cMessage,cluBarrier)) |
|---|
| 238 | tProperty(cMessage); |
|---|
| 239 | |
|---|
| 240 | |
|---|
| 241 | if(!strcmp(cUBCName,"diskspace")) |
|---|
| 242 | sprintf(cMessage,"1k-blocks.luHardlimit"); |
|---|
| 243 | else |
|---|
| 244 | sprintf(cMessage,"%.99s.luBarrier",cUBCName); |
|---|
| 245 | if(SetContainerProperty(uKey,cMessage,cluLimit)) |
|---|
| 246 | tProperty(cMessage); |
|---|
| 247 | |
|---|
| 248 | sprintf(cMessage,"Set UBC --%s %s:%s job created ok", |
|---|
| 249 | cUBCName,cluBarrier,cluLimit); |
|---|
| 250 | tProperty(cMessage); |
|---|
| 251 | } |
|---|
| 252 | else |
|---|
| 253 | { |
|---|
| 254 | tProperty("<blink>Error</blink>: No job created!"); |
|---|
| 255 | } |
|---|
| 256 | } |
|---|
| 257 | else |
|---|
| 258 | tProperty("<blink>Error</blink>: Insufficient permision to mod"); |
|---|
| 259 | } |
|---|
| 260 | } |
|---|
| 261 | |
|---|
| 262 | }//void ExttPropertyCommands(pentry entries[], int x) |
|---|
| 263 | |
|---|
| 264 | |
|---|
| 265 | void htmlReturnLink(void) |
|---|
| 266 | { |
|---|
| 267 | if(cReturn[0]) |
|---|
| 268 | { |
|---|
| 269 | char *cp; |
|---|
| 270 | char cTable[32]={""}; |
|---|
| 271 | char cTableKey[32]={""}; |
|---|
| 272 | unsigned uKey=0; |
|---|
| 273 | |
|---|
| 274 | if((cp=strchr(cReturn,'_'))) |
|---|
| 275 | { |
|---|
| 276 | *cp=0; |
|---|
| 277 | sprintf(cTable,"%.31s",cReturn); |
|---|
| 278 | sprintf(cTableKey,"u%.30s",cReturn+1); |
|---|
| 279 | sscanf(cp+1,"%u",&uKey); |
|---|
| 280 | *cp='_'; |
|---|
| 281 | } |
|---|
| 282 | printf("<a class=darkLink href=unxsVZ.cgi?gcFunction=%s&%s=%u>Return to %s (%s %u)</a><p>\n", |
|---|
| 283 | cTable,cTableKey,uKey, |
|---|
| 284 | ForeignKey(cTable,"cLabel",uKey), |
|---|
| 285 | cTable, uKey); |
|---|
| 286 | printf("<input type=hidden name=cReturn value=%s>",cReturn); |
|---|
| 287 | } |
|---|
| 288 | |
|---|
| 289 | }//void htmlReturnLink(void) |
|---|
| 290 | |
|---|
| 291 | |
|---|
| 292 | void htmlUBCEdit(void) |
|---|
| 293 | { |
|---|
| 294 | char cUBCName[100]; |
|---|
| 295 | char *cp; |
|---|
| 296 | |
|---|
| 297 | sprintf(cUBCName,"%.99s",cName); |
|---|
| 298 | |
|---|
| 299 | //Provide entrance to container conf file ubc editing |
|---|
| 300 | //Expanded to allow setting of --diskspace |
|---|
| 301 | |
|---|
| 302 | if((cp=strstr(cUBCName,".luBarrier")) || (cp=strstr(cUBCName,".luLimit")) |
|---|
| 303 | || (cp=strstr(cUBCName,".luHardlimit")) |
|---|
| 304 | || (cp=strstr(cUBCName,".luSoftlimit")) ) |
|---|
| 305 | { |
|---|
| 306 | MYSQL_RES *res; |
|---|
| 307 | MYSQL_ROW field; |
|---|
| 308 | |
|---|
| 309 | |
|---|
| 310 | *cp=0; |
|---|
| 311 | sprintf(gcQuery,"SELECT uProperty,cName,cValue FROM tProperty WHERE" |
|---|
| 312 | " uType=3" |
|---|
| 313 | " AND uKey=%1$u" |
|---|
| 314 | " AND (cName='%2$s.luLimit' OR cName='%2$s.luBarrier' OR" |
|---|
| 315 | " cName='%2$s.luHardlimit' OR cName='%2$s.luSoftlimit')" |
|---|
| 316 | " ORDER BY cName DESC",uKey,cUBCName); |
|---|
| 317 | mysql_query(&gMysql,gcQuery); |
|---|
| 318 | if(mysql_errno(&gMysql)) |
|---|
| 319 | htmlPlainTextError(mysql_error(&gMysql)); |
|---|
| 320 | |
|---|
| 321 | res=mysql_store_result(&gMysql); |
|---|
| 322 | if(mysql_num_rows(res)) |
|---|
| 323 | { |
|---|
| 324 | register unsigned uFirst=0; |
|---|
| 325 | char cLimit[32]={""}; |
|---|
| 326 | char cBarrier[32]={""}; |
|---|
| 327 | |
|---|
| 328 | printf("<p><u>OpenVZ UBC/Disk Modifiable Properties</u><br>"); |
|---|
| 329 | |
|---|
| 330 | while((field=mysql_fetch_row(res))) |
|---|
| 331 | { |
|---|
| 332 | printf("<a class=darkLink href=unxsVZ.cgi?gcFunction=tProperty&uProperty=%s" |
|---|
| 333 | "&cReturn=%s>" |
|---|
| 334 | "%s=%s</a><br>\n",field[0],cReturn,field[1],field[2]); |
|---|
| 335 | if(uFirst) |
|---|
| 336 | sprintf(cLimit,"%.31s",field[2]); |
|---|
| 337 | else |
|---|
| 338 | sprintf(cBarrier,"%.31s",field[2]); |
|---|
| 339 | uFirst++; |
|---|
| 340 | |
|---|
| 341 | } |
|---|
| 342 | if(!strcmp(cUBCName,"1k-blocks")) |
|---|
| 343 | sprintf(cUBCName,"diskspace"); |
|---|
| 344 | printf("<p><input type=submit class=largeButton name=gcCommand" |
|---|
| 345 | " title='Create job for setting container UBC/Disk at current settings'" |
|---|
| 346 | " value='Set UBC/Diskspace'>\n"); |
|---|
| 347 | printf("<p><input type=submit class=lalertButton name=gcCommand" |
|---|
| 348 | " title='Create job for setting container UBC/Disk at current settings +20%%'" |
|---|
| 349 | " value='Set UBC/Diskspace +20%%'>\n"); |
|---|
| 350 | printf("<p><input type=submit class=lwarnButton name=gcCommand" |
|---|
| 351 | " title='Create job for setting container UBC/Disk at current settings -20%%'" |
|---|
| 352 | " value='Set UBC/Diskspace -20%%'>\n"); |
|---|
| 353 | printf("<input type=hidden name=luBarrier value=%s>",cBarrier); |
|---|
| 354 | printf("<input type=hidden name=luLimit value=%s>\n",cLimit); |
|---|
| 355 | printf("<input type=hidden name=cUBCName value=%s>\n",cUBCName); |
|---|
| 356 | printf("<input type=hidden name=cReturn value=%s>",cReturn); |
|---|
| 357 | } |
|---|
| 358 | mysql_free_result(res); |
|---|
| 359 | } |
|---|
| 360 | |
|---|
| 361 | }//void htmlUBCEdit(void) |
|---|
| 362 | |
|---|
| 363 | |
|---|
| 364 | void htmlUBCInfo(void) |
|---|
| 365 | { |
|---|
| 366 | char cUBCName[100]; |
|---|
| 367 | char *cp; |
|---|
| 368 | |
|---|
| 369 | sprintf(cUBCName,"%.99s",cName); |
|---|
| 370 | |
|---|
| 371 | if((cp=strstr(cUBCName,".lu"))) |
|---|
| 372 | { |
|---|
| 373 | MYSQL_RES *res; |
|---|
| 374 | MYSQL_ROW field; |
|---|
| 375 | |
|---|
| 376 | *cp=0; |
|---|
| 377 | sprintf(gcQuery,"SELECT uProperty,cName,cValue FROM tProperty WHERE" |
|---|
| 378 | " uType=3" |
|---|
| 379 | " AND uKey=%u" |
|---|
| 380 | " AND cName LIKE '%s.lu%%'" |
|---|
| 381 | " ORDER BY cName DESC",uKey,cUBCName); |
|---|
| 382 | mysql_query(&gMysql,gcQuery); |
|---|
| 383 | if(mysql_errno(&gMysql)) |
|---|
| 384 | htmlPlainTextError(mysql_error(&gMysql)); |
|---|
| 385 | |
|---|
| 386 | res=mysql_store_result(&gMysql); |
|---|
| 387 | if(mysql_num_rows(res)) |
|---|
| 388 | { |
|---|
| 389 | printf("<p><u>OpenVZ UBC Related Properties</u><br>"); |
|---|
| 390 | |
|---|
| 391 | while((field=mysql_fetch_row(res))) |
|---|
| 392 | { |
|---|
| 393 | printf("<a class=darkLink href=unxsVZ.cgi?gcFunction=tProperty&uProperty=%s" |
|---|
| 394 | "&cReturn=%s>" |
|---|
| 395 | "%s=%s</a><br>\n",field[0],cReturn,field[1],field[2]); |
|---|
| 396 | } |
|---|
| 397 | } |
|---|
| 398 | mysql_free_result(res); |
|---|
| 399 | } |
|---|
| 400 | |
|---|
| 401 | }//void htmlUBCInfo(void) |
|---|
| 402 | |
|---|
| 403 | |
|---|
| 404 | void ExttPropertyButtons(void) |
|---|
| 405 | { |
|---|
| 406 | OpenFieldSet("tProperty Aux Panel",100); |
|---|
| 407 | switch(guMode) |
|---|
| 408 | { |
|---|
| 409 | case 2000: |
|---|
| 410 | htmlReturnLink(); |
|---|
| 411 | printf("<p><u>Enter/mod data</u><br>"); |
|---|
| 412 | printf(LANG_NBB_CONFIRMNEW); |
|---|
| 413 | break; |
|---|
| 414 | |
|---|
| 415 | case 2001: |
|---|
| 416 | htmlReturnLink(); |
|---|
| 417 | printf("<p><u>Think twice</u><br>"); |
|---|
| 418 | printf(LANG_NBB_CONFIRMDEL); |
|---|
| 419 | break; |
|---|
| 420 | |
|---|
| 421 | case 2002: |
|---|
| 422 | htmlReturnLink(); |
|---|
| 423 | printf("<p><u>Review changes</u><br>"); |
|---|
| 424 | printf(LANG_NBB_CONFIRMMOD); |
|---|
| 425 | break; |
|---|
| 426 | |
|---|
| 427 | default: |
|---|
| 428 | htmlReturnLink(); |
|---|
| 429 | htmlGlossaryLink(cName); |
|---|
| 430 | printf("<u>Table Tips</u><br>"); |
|---|
| 431 | printf("In general the only properties that make sense to edit" |
|---|
| 432 | " are those that are not VZ UBC properties. The exception being" |
|---|
| 433 | " editing barrier:limit pairs for container modification" |
|---|
| 434 | " via [Set UBC/Diskspace] button. In this last case you must edit the barrier" |
|---|
| 435 | " and limit items before the system loads them again.\n"); |
|---|
| 436 | htmlUBCInfo(); |
|---|
| 437 | htmlUBCEdit(); |
|---|
| 438 | } |
|---|
| 439 | CloseFieldSet(); |
|---|
| 440 | |
|---|
| 441 | }//void ExttPropertyButtons(void) |
|---|
| 442 | |
|---|
| 443 | |
|---|
| 444 | void ExttPropertyAuxTable(void) |
|---|
| 445 | { |
|---|
| 446 | |
|---|
| 447 | }//void ExttPropertyAuxTable(void) |
|---|
| 448 | |
|---|
| 449 | |
|---|
| 450 | void ExttPropertyGetHook(entry gentries[], int x) |
|---|
| 451 | { |
|---|
| 452 | register int i; |
|---|
| 453 | |
|---|
| 454 | for(i=0;i<x;i++) |
|---|
| 455 | { |
|---|
| 456 | if(!strcmp(gentries[i].name,"uProperty")) |
|---|
| 457 | { |
|---|
| 458 | sscanf(gentries[i].val,"%u",&uProperty); |
|---|
| 459 | guMode=3002; |
|---|
| 460 | } |
|---|
| 461 | else if(!strcmp(gentries[i].name,"cReturn")) |
|---|
| 462 | { |
|---|
| 463 | sprintf(cReturn,"%.99s",gentries[i].val); |
|---|
| 464 | } |
|---|
| 465 | } |
|---|
| 466 | tProperty(""); |
|---|
| 467 | |
|---|
| 468 | }//void ExttPropertyGetHook(entry gentries[], int x) |
|---|
| 469 | |
|---|
| 470 | |
|---|
| 471 | void ExttPropertySelect(void) |
|---|
| 472 | { |
|---|
| 473 | ExtSelect("tProperty",VAR_LIST_tProperty); |
|---|
| 474 | |
|---|
| 475 | }//void ExttPropertySelect(void) |
|---|
| 476 | |
|---|
| 477 | |
|---|
| 478 | void ExttPropertySelectRow(void) |
|---|
| 479 | { |
|---|
| 480 | ExtSelectRow("tProperty",VAR_LIST_tProperty,uProperty); |
|---|
| 481 | |
|---|
| 482 | }//void ExttPropertySelectRow(void) |
|---|
| 483 | |
|---|
| 484 | |
|---|
| 485 | void ExttPropertyListSelect(void) |
|---|
| 486 | { |
|---|
| 487 | char cCat[512]; |
|---|
| 488 | |
|---|
| 489 | ExtListSelect("tProperty",VAR_LIST_tProperty); |
|---|
| 490 | |
|---|
| 491 | //Changes here must be reflected below in ExttPropertyListFilter() |
|---|
| 492 | if(!strcmp(gcFilter,"uProperty")) |
|---|
| 493 | { |
|---|
| 494 | sscanf(gcCommand,"%u",&uProperty); |
|---|
| 495 | if(guLoginClient==1 && guPermLevel>11) |
|---|
| 496 | strcat(gcQuery," WHERE "); |
|---|
| 497 | else |
|---|
| 498 | strcat(gcQuery," AND "); |
|---|
| 499 | sprintf(cCat,"tProperty.uProperty=%u ORDER BY uProperty",uProperty); |
|---|
| 500 | strcat(gcQuery,cCat); |
|---|
| 501 | } |
|---|
| 502 | else if(!strcmp(gcFilter,"cName")) |
|---|
| 503 | { |
|---|
| 504 | if(guLoginClient==1 && guPermLevel>11) |
|---|
| 505 | strcat(gcQuery," WHERE "); |
|---|
| 506 | else |
|---|
| 507 | strcat(gcQuery," AND "); |
|---|
| 508 | sprintf(cCat,"tProperty.cName LIKE '%s' ORDER BY cName,uProperty",gcCommand); |
|---|
| 509 | strcat(gcQuery,cCat); |
|---|
| 510 | } |
|---|
| 511 | else if(!strcmp(gcFilter,"uType")) |
|---|
| 512 | { |
|---|
| 513 | sscanf(gcCommand,"%u",&uType); |
|---|
| 514 | if(guLoginClient==1 && guPermLevel>11) |
|---|
| 515 | strcat(gcQuery," WHERE "); |
|---|
| 516 | else |
|---|
| 517 | strcat(gcQuery," AND "); |
|---|
| 518 | sprintf(cCat,"tProperty.uType=%u ORDER BY uType,uProperty",uType); |
|---|
| 519 | strcat(gcQuery,cCat); |
|---|
| 520 | } |
|---|
| 521 | else if(!strcmp(gcFilter,"uKey")) |
|---|
| 522 | { |
|---|
| 523 | sscanf(gcCommand,"%u",&uKey); |
|---|
| 524 | if(guLoginClient==1 && guPermLevel>11) |
|---|
| 525 | strcat(gcQuery," WHERE "); |
|---|
| 526 | else |
|---|
| 527 | strcat(gcQuery," AND "); |
|---|
| 528 | sprintf(cCat,"tProperty.uKey=%u ORDER BY uKey,uProperty",uKey); |
|---|
| 529 | strcat(gcQuery,cCat); |
|---|
| 530 | } |
|---|
| 531 | else if(!strcmp(gcFilter,"uOwner")) |
|---|
| 532 | { |
|---|
| 533 | sscanf(gcCommand,"%u",&uOwner); |
|---|
| 534 | if(guLoginClient==1 && guPermLevel>11) |
|---|
| 535 | strcat(gcQuery," WHERE "); |
|---|
| 536 | else |
|---|
| 537 | strcat(gcQuery," AND "); |
|---|
| 538 | sprintf(cCat,"tProperty.uOwner=%u ORDER BY uOwner,uProperty",uOwner); |
|---|
| 539 | strcat(gcQuery,cCat); |
|---|
| 540 | } |
|---|
| 541 | else if(1) |
|---|
| 542 | { |
|---|
| 543 | //None NO FILTER |
|---|
| 544 | strcpy(gcFilter,"None"); |
|---|
| 545 | strcat(gcQuery," ORDER BY uProperty"); |
|---|
| 546 | } |
|---|
| 547 | |
|---|
| 548 | }//void ExttPropertyListSelect(void) |
|---|
| 549 | |
|---|
| 550 | |
|---|
| 551 | void ExttPropertyListFilter(void) |
|---|
| 552 | { |
|---|
| 553 | //Filter |
|---|
| 554 | printf(" Filter on "); |
|---|
| 555 | printf("<select name=gcFilter>"); |
|---|
| 556 | if(strcmp(gcFilter,"uProperty")) |
|---|
| 557 | printf("<option>uProperty</option>"); |
|---|
| 558 | else |
|---|
| 559 | printf("<option selected>uProperty</option>"); |
|---|
| 560 | if(strcmp(gcFilter,"cName")) |
|---|
| 561 | printf("<option>cName</option>"); |
|---|
| 562 | else |
|---|
| 563 | printf("<option selected>cName</option>"); |
|---|
| 564 | if(strcmp(gcFilter,"uType")) |
|---|
| 565 | printf("<option>uType</option>"); |
|---|
| 566 | else |
|---|
| 567 | printf("<option selected>uType</option>"); |
|---|
| 568 | if(strcmp(gcFilter,"uKey")) |
|---|
| 569 | printf("<option>uKey</option>"); |
|---|
| 570 | else |
|---|
| 571 | printf("<option selected>uKey</option>"); |
|---|
| 572 | if(strcmp(gcFilter,"uOwner")) |
|---|
| 573 | printf("<option>uOwner</option>"); |
|---|
| 574 | else |
|---|
| 575 | printf("<option selected>uOwner</option>"); |
|---|
| 576 | if(strcmp(gcFilter,"None")) |
|---|
| 577 | printf("<option>None</option>"); |
|---|
| 578 | else |
|---|
| 579 | printf("<option selected>None</option>"); |
|---|
| 580 | printf("</select>"); |
|---|
| 581 | |
|---|
| 582 | }//void ExttPropertyListFilter(void) |
|---|
| 583 | |
|---|
| 584 | |
|---|
| 585 | void ExttPropertyNavBar(void) |
|---|
| 586 | { |
|---|
| 587 | printf(LANG_NBB_SKIPFIRST); |
|---|
| 588 | printf(LANG_NBB_SKIPBACK); |
|---|
| 589 | printf(LANG_NBB_SEARCH); |
|---|
| 590 | |
|---|
| 591 | //By allow new in mod we can save time duplicating similar records. |
|---|
| 592 | if(guPermLevel>=10) |
|---|
| 593 | printf(LANG_NBB_NEW); |
|---|
| 594 | |
|---|
| 595 | if(uAllowMod(uOwner,uCreatedBy)) |
|---|
| 596 | printf(LANG_NBB_MODIFY); |
|---|
| 597 | |
|---|
| 598 | if(uAllowDel(uOwner,uCreatedBy)) |
|---|
| 599 | printf(LANG_NBB_DELETE); |
|---|
| 600 | |
|---|
| 601 | if(uOwner) |
|---|
| 602 | printf(LANG_NBB_LIST); |
|---|
| 603 | |
|---|
| 604 | printf(LANG_NBB_SKIPNEXT); |
|---|
| 605 | printf(LANG_NBB_SKIPLAST); |
|---|
| 606 | printf(" \n"); |
|---|
| 607 | |
|---|
| 608 | }//void ExttPropertyNavBar(void) |
|---|
| 609 | |
|---|
| 610 | |
|---|
| 611 | unsigned SetUBCJob(unsigned uContainer,char *cSet) |
|---|
| 612 | { |
|---|
| 613 | MYSQL_RES *res; |
|---|
| 614 | MYSQL_ROW field; |
|---|
| 615 | unsigned uCount=0; |
|---|
| 616 | unsigned uDatacenter=0; |
|---|
| 617 | unsigned uNode=0; |
|---|
| 618 | |
|---|
| 619 | sprintf(gcQuery,"SELECT tNode.uDatacenter,tNode.uNode FROM tNode,tContainer WHERE" |
|---|
| 620 | " tNode.uNode=tContainer.uNode" |
|---|
| 621 | " AND tContainer.uContainer=%u",uContainer); |
|---|
| 622 | mysql_query(&gMysql,gcQuery); |
|---|
| 623 | if(mysql_errno(&gMysql)) |
|---|
| 624 | htmlPlainTextError(mysql_error(&gMysql)); |
|---|
| 625 | res=mysql_store_result(&gMysql); |
|---|
| 626 | if((field=mysql_fetch_row(res))) |
|---|
| 627 | { |
|---|
| 628 | sscanf(field[0],"%u",&uDatacenter); |
|---|
| 629 | sscanf(field[1],"%u",&uNode); |
|---|
| 630 | } |
|---|
| 631 | else |
|---|
| 632 | { |
|---|
| 633 | mysql_free_result(res); |
|---|
| 634 | return(0); |
|---|
| 635 | } |
|---|
| 636 | mysql_free_result(res); |
|---|
| 637 | |
|---|
| 638 | sprintf(gcQuery,"INSERT INTO tJob SET cLabel='SetUBCJob(%u)',cJobName='SetUBCJob'" |
|---|
| 639 | ",uDatacenter=%u,uNode=%u,uContainer=%u" |
|---|
| 640 | ",uJobDate=UNIX_TIMESTAMP(NOW())+60" |
|---|
| 641 | ",uJobStatus=1" |
|---|
| 642 | ",cJobData='%.99s'" |
|---|
| 643 | ",uOwner=%u,uCreatedBy=%u,uCreatedDate=UNIX_TIMESTAMP(NOW())", |
|---|
| 644 | uContainer, |
|---|
| 645 | uDatacenter,uNode,uContainer, |
|---|
| 646 | cSet, |
|---|
| 647 | uOwner,guLoginClient); |
|---|
| 648 | mysql_query(&gMysql,gcQuery); |
|---|
| 649 | if(mysql_errno(&gMysql)) |
|---|
| 650 | htmlPlainTextError(mysql_error(&gMysql)); |
|---|
| 651 | uCount=mysql_insert_id(&gMysql); |
|---|
| 652 | return(uCount); |
|---|
| 653 | |
|---|
| 654 | }//unsigned SetUBCJob(...) |
|---|
| 655 | |
|---|
| 656 | |
|---|
| 657 | void htmlGlossaryLink(char *cLabel) |
|---|
| 658 | { |
|---|
| 659 | MYSQL_RES *res; |
|---|
| 660 | MYSQL_ROW field; |
|---|
| 661 | |
|---|
| 662 | if(!cLabel[0]) return; |
|---|
| 663 | |
|---|
| 664 | sprintf(gcQuery,"SELECT uGlossary FROM tGlossary WHERE cLabel='%s'",cLabel); |
|---|
| 665 | mysql_query(&gMysql,gcQuery); |
|---|
| 666 | if(mysql_errno(&gMysql)) |
|---|
| 667 | htmlPlainTextError(mysql_error(&gMysql)); |
|---|
| 668 | res=mysql_store_result(&gMysql); |
|---|
| 669 | if((field=mysql_fetch_row(res))) |
|---|
| 670 | { |
|---|
| 671 | printf("Glossary entry for <a class=darkLink href=#" |
|---|
| 672 | " onClick=\"open_popup('?gcFunction=Glossary&cLabel=%1$s')\">%1$s</a><p>",cLabel); |
|---|
| 673 | |
|---|
| 674 | } |
|---|
| 675 | mysql_free_result(res); |
|---|
| 676 | |
|---|
| 677 | }//void htmlGlossaryLink() |
|---|