| 1 | /* |
|---|
| 2 | FILE |
|---|
| 3 | unxsVZ/main.c |
|---|
| 4 | $Id$ |
|---|
| 5 | PURPOSE |
|---|
| 6 | Main cgi interface and common functions used for all the other |
|---|
| 7 | table tx.c files and their schema independent txfunc.h files -until |
|---|
| 8 | you mess with them in non standard ways...lol. |
|---|
| 9 | |
|---|
| 10 | AUTHOR/LEGAL |
|---|
| 11 | (C) 2001-2012 Unixservice, LLC. |
|---|
| 12 | GPLv2 license applies. See LICENSE file included. |
|---|
| 13 | OTHER |
|---|
| 14 | Only tested on CentOS 5 and Firefox browser (9.0.1). |
|---|
| 15 | FREE HELP |
|---|
| 16 | support @ openisp . net |
|---|
| 17 | supportgrp @ unixservice . com |
|---|
| 18 | Join mailing list: https://lists.openisp.net/mailman/listinfo/unxsvz |
|---|
| 19 | */ |
|---|
| 20 | |
|---|
| 21 | #include "mysqlrad.h" |
|---|
| 22 | #include <ctype.h> |
|---|
| 23 | |
|---|
| 24 | #include "language.h" |
|---|
| 25 | #include "local.h" |
|---|
| 26 | |
|---|
| 27 | //Global vars |
|---|
| 28 | #define SHOWPAGE 30 |
|---|
| 29 | MYSQL gMysql; |
|---|
| 30 | unsigned long gluRowid; |
|---|
| 31 | unsigned guStart; |
|---|
| 32 | unsigned guEnd; |
|---|
| 33 | unsigned guI; |
|---|
| 34 | unsigned guN=SHOWPAGE; |
|---|
| 35 | char gcCommand[100]; |
|---|
| 36 | static char cLogKey[16]={"Ksdj458jssdUjf79"}; |
|---|
| 37 | char gcFilter[100]; |
|---|
| 38 | char gcFind[100]; |
|---|
| 39 | unsigned guMode; |
|---|
| 40 | |
|---|
| 41 | int guPermLevel=0; |
|---|
| 42 | unsigned guLoginClient=0; |
|---|
| 43 | unsigned guReseller=0; |
|---|
| 44 | unsigned guCompany=0; |
|---|
| 45 | char gcCompany[100]={""}; |
|---|
| 46 | char gcUser[100]={""}; |
|---|
| 47 | char gcHost[100]={""}; |
|---|
| 48 | char gcHostname[100]={""}; |
|---|
| 49 | |
|---|
| 50 | //SSLLoginCookie() |
|---|
| 51 | char gcCookie[1024]={""}; |
|---|
| 52 | char gcLogin[100]={""}; |
|---|
| 53 | char gcPasswd[100]={""}; |
|---|
| 54 | unsigned guSSLCookieLogin=0; |
|---|
| 55 | |
|---|
| 56 | char gcFunction[100]={""}; |
|---|
| 57 | unsigned guListMode=0; |
|---|
| 58 | char gcQuery[8192]={""}; |
|---|
| 59 | char *gcQstr=gcQuery; |
|---|
| 60 | char *gcBuildInfo="$Id$"; |
|---|
| 61 | char *gcRADStatus="Forked"; |
|---|
| 62 | |
|---|
| 63 | //Local |
|---|
| 64 | void Footer_ism3(void); |
|---|
| 65 | void Header_ism3(const char *cMsg, int iJs); |
|---|
| 66 | const char *ForeignKey(const char *cTableName, const char *cFieldName, unsigned uKey); |
|---|
| 67 | char *cEmailInput(char *cInput); |
|---|
| 68 | void GetClientOwner(unsigned uClient, unsigned *uOwner); |
|---|
| 69 | void htmlPlainTextError(const char *cError); |
|---|
| 70 | |
|---|
| 71 | //Ext |
|---|
| 72 | int iExtMainCommands(pentry entries[], int x); |
|---|
| 73 | void ExtMainContent(void); |
|---|
| 74 | void ExtMainShell(int iArgc, char *cArgv[]); |
|---|
| 75 | void DashBoard(const char *cOptionalMsg); |
|---|
| 76 | |
|---|
| 77 | //Only local |
|---|
| 78 | void ConnectDb(void); |
|---|
| 79 | void jsToggleCheckboxes(void); |
|---|
| 80 | void NoSuchFunction(void); |
|---|
| 81 | void unxsVZ(const char *cResult); |
|---|
| 82 | void InitialInstall(void); |
|---|
| 83 | const char *cUserLevel(unsigned uPermLevel); |
|---|
| 84 | int iValidLogin(int iMode); |
|---|
| 85 | void SSLCookieLogin(void); |
|---|
| 86 | void SetLogin(void); |
|---|
| 87 | void EncryptPasswdWithSalt(char *gcPasswd, char *cSalt); |
|---|
| 88 | void GetPLAndClient(char *cUser); |
|---|
| 89 | void htmlSSLLogin(void); |
|---|
| 90 | |
|---|
| 91 | //mainfunc.h for symbolic links to this program |
|---|
| 92 | void CalledByAlias(int iArgc,char *cArgv[]); |
|---|
| 93 | |
|---|
| 94 | //Testing globalization |
|---|
| 95 | pentry entries[256]; |
|---|
| 96 | entry gentries[16]; |
|---|
| 97 | int x; |
|---|
| 98 | |
|---|
| 99 | int main(int iArgc, char *cArgv[]) |
|---|
| 100 | { |
|---|
| 101 | char *gcl; |
|---|
| 102 | int cl=0; |
|---|
| 103 | |
|---|
| 104 | gethostname(gcHostname, 98); |
|---|
| 105 | |
|---|
| 106 | if(!strstr(cArgv[0],"unxsVZ.cgi")) |
|---|
| 107 | CalledByAlias(iArgc,cArgv); |
|---|
| 108 | |
|---|
| 109 | if(getenv("REMOTE_HOST")!=NULL) |
|---|
| 110 | sprintf(gcHost,"%.99s",getenv("REMOTE_HOST")); |
|---|
| 111 | |
|---|
| 112 | else if(getenv("REMOTE_ADDR")!=NULL) |
|---|
| 113 | { |
|---|
| 114 | ConnectDb(); |
|---|
| 115 | sprintf(gcHost,"%.99s",getenv("REMOTE_ADDR")); |
|---|
| 116 | } |
|---|
| 117 | else |
|---|
| 118 | { |
|---|
| 119 | ExtMainShell(iArgc,cArgv); |
|---|
| 120 | } |
|---|
| 121 | |
|---|
| 122 | |
|---|
| 123 | if(strcmp(getenv("REQUEST_METHOD"),"POST")) |
|---|
| 124 | { |
|---|
| 125 | |
|---|
| 126 | SSLCookieLogin(); |
|---|
| 127 | |
|---|
| 128 | gcl = getenv("QUERY_STRING"); |
|---|
| 129 | |
|---|
| 130 | for(x=0;gcl[0] != '\0' && x<8;x++) |
|---|
| 131 | { |
|---|
| 132 | getword(gentries[x].val,gcl,'&'); |
|---|
| 133 | plustospace(gentries[x].val); |
|---|
| 134 | unescape_url(gentries[x].val); |
|---|
| 135 | getword(gentries[x].name,gentries[x].val,'='); |
|---|
| 136 | |
|---|
| 137 | //basic anti hacker |
|---|
| 138 | escape_shell_cmd(gentries[x].val); |
|---|
| 139 | |
|---|
| 140 | //Local vars |
|---|
| 141 | if(!strcmp(gentries[x].name,"gcFunction")) |
|---|
| 142 | sprintf(gcFunction,"%.99s",gentries[x].val); |
|---|
| 143 | } |
|---|
| 144 | |
|---|
| 145 | if(gcFunction[0]) |
|---|
| 146 | { |
|---|
| 147 | if(!strcmp(gcFunction,"Main")) |
|---|
| 148 | unxsVZ(""); |
|---|
| 149 | else if(!strcmp(gcFunction,"Logout")) |
|---|
| 150 | { |
|---|
| 151 | printf("Set-Cookie: unxsVZLogin=; expires=\"Mon, 01-Jan-1971 00:10:10 GMT\"\n"); |
|---|
| 152 | printf("Set-Cookie: unxsVZPasswd=; expires=\"Mon, 01-Jan-1971 00:10:10 GMT\"\n"); |
|---|
| 153 | sprintf(gcQuery,"INSERT INTO tLog SET cLabel='logout %.99s',uLogType=6,uPermLevel=%u," |
|---|
| 154 | " uLoginClient=%u,cLogin='%.99s',cHost='%.99s',cServer='%.99s',uOwner=%u,uCreatedBy=1," |
|---|
| 155 | " uCreatedDate=UNIX_TIMESTAMP(NOW()) ON DUPLICATE KEY UPDATE " |
|---|
| 156 | " cLabel='logout %.99s',uLogType=6,uPermLevel=%u," |
|---|
| 157 | " uLoginClient=%u,cLogin='%.99s',cHost='%.99s',cServer='%.99s',uOwner=%u,uCreatedBy=1," |
|---|
| 158 | " uCreatedDate=UNIX_TIMESTAMP(NOW())", |
|---|
| 159 | gcLogin,guPermLevel,guLoginClient,gcLogin,gcHost,gcHostname,guCompany, |
|---|
| 160 | gcLogin,guPermLevel,guLoginClient,gcLogin,gcHost,gcHostname,guCompany); |
|---|
| 161 | MYSQL_RUN; |
|---|
| 162 | gcCookie[0]=0; |
|---|
| 163 | guPermLevel=0; |
|---|
| 164 | guLoginClient=0; |
|---|
| 165 | gcUser[0]=0; |
|---|
| 166 | gcCompany[0]=0; |
|---|
| 167 | guSSLCookieLogin=0; |
|---|
| 168 | htmlSSLLogin(); |
|---|
| 169 | } |
|---|
| 170 | |
|---|
| 171 | else if(!strcmp(gcFunction,"tDatacenter")) |
|---|
| 172 | ExttDatacenterGetHook(gentries,x); |
|---|
| 173 | else if(!strcmp(gcFunction,"tNode")) |
|---|
| 174 | ExttNodeGetHook(gentries,x); |
|---|
| 175 | else if(!strcmp(gcFunction,"tContainer")) |
|---|
| 176 | ExttContainerGetHook(gentries,x); |
|---|
| 177 | else if(!strcmp(gcFunction,"tProperty")) |
|---|
| 178 | ExttPropertyGetHook(gentries,x); |
|---|
| 179 | else if(!strcmp(gcFunction,"tType")) |
|---|
| 180 | ExttTypeGetHook(gentries,x); |
|---|
| 181 | else if(!strcmp(gcFunction,"tOSTemplate")) |
|---|
| 182 | ExttOSTemplateGetHook(gentries,x); |
|---|
| 183 | else if(!strcmp(gcFunction,"tNameserver")) |
|---|
| 184 | ExttNameserverGetHook(gentries,x); |
|---|
| 185 | else if(!strcmp(gcFunction,"tSearchdomain")) |
|---|
| 186 | ExttSearchdomainGetHook(gentries,x); |
|---|
| 187 | else if(!strcmp(gcFunction,"tConfig")) |
|---|
| 188 | ExttConfigGetHook(gentries,x); |
|---|
| 189 | else if(!strcmp(gcFunction,"tIP")) |
|---|
| 190 | ExttIPGetHook(gentries,x); |
|---|
| 191 | else if(!strcmp(gcFunction,"tGroupType")) |
|---|
| 192 | ExttGroupTypeGetHook(gentries,x); |
|---|
| 193 | else if(!strcmp(gcFunction,"tGroup")) |
|---|
| 194 | ExttGroupGetHook(gentries,x); |
|---|
| 195 | else if(!strcmp(gcFunction,"tGroupGlue")) |
|---|
| 196 | ExttGroupGlueGetHook(gentries,x); |
|---|
| 197 | else if(!strcmp(gcFunction,"tClient")) |
|---|
| 198 | ExttClientGetHook(gentries,x); |
|---|
| 199 | else if(!strcmp(gcFunction,"tAuthorize")) |
|---|
| 200 | ExttAuthorizeGetHook(gentries,x); |
|---|
| 201 | else if(!strcmp(gcFunction,"tTemplate")) |
|---|
| 202 | ExttTemplateGetHook(gentries,x); |
|---|
| 203 | else if(!strcmp(gcFunction,"tTemplateSet")) |
|---|
| 204 | ExttTemplateSetGetHook(gentries,x); |
|---|
| 205 | else if(!strcmp(gcFunction,"tTemplateType")) |
|---|
| 206 | ExttTemplateTypeGetHook(gentries,x); |
|---|
| 207 | else if(!strcmp(gcFunction,"tLog")) |
|---|
| 208 | ExttLogGetHook(gentries,x); |
|---|
| 209 | else if(!strcmp(gcFunction,"tLogType")) |
|---|
| 210 | ExttLogTypeGetHook(gentries,x); |
|---|
| 211 | else if(!strcmp(gcFunction,"tLogMonth")) |
|---|
| 212 | ExttLogMonthGetHook(gentries,x); |
|---|
| 213 | else if(!strcmp(gcFunction,"tMonth")) |
|---|
| 214 | ExttMonthGetHook(gentries,x); |
|---|
| 215 | else if(!strcmp(gcFunction,"tGlossary")) |
|---|
| 216 | ExttGlossaryGetHook(gentries,x); |
|---|
| 217 | else if(!strcmp(gcFunction,"tJob")) |
|---|
| 218 | ExttJobGetHook(gentries,x); |
|---|
| 219 | else if(!strcmp(gcFunction,"tJobStatus")) |
|---|
| 220 | ExttJobStatusGetHook(gentries,x); |
|---|
| 221 | else if(!strcmp(gcFunction,"tStatus")) |
|---|
| 222 | ExttStatusGetHook(gentries,x); |
|---|
| 223 | else if(!strcmp(gcFunction,"tConfiguration")) |
|---|
| 224 | ExttConfigurationGetHook(gentries,x); |
|---|
| 225 | else if(!strcmp(gcFunction,"Dashboard")) |
|---|
| 226 | unxsVZ("DashBoard"); |
|---|
| 227 | else if(!strcmp(gcFunction,"Glossary")) |
|---|
| 228 | GlossaryGetHook(gentries,x); |
|---|
| 229 | } |
|---|
| 230 | |
|---|
| 231 | unxsVZ(ISPNAME); |
|---|
| 232 | |
|---|
| 233 | }//end get method interface section |
|---|
| 234 | |
|---|
| 235 | //Post method interface |
|---|
| 236 | cl = atoi(getenv("CONTENT_LENGTH")); |
|---|
| 237 | for(x=0;cl && (!feof(stdin)) && x<256 ;x++) |
|---|
| 238 | { |
|---|
| 239 | entries[x].val = fmakeword(stdin,'&',&cl); |
|---|
| 240 | plustospace(entries[x].val); |
|---|
| 241 | unescape_url(entries[x].val); |
|---|
| 242 | entries[x].name = makeword(entries[x].val,'='); |
|---|
| 243 | |
|---|
| 244 | //basic anti hacker |
|---|
| 245 | //Allow posted page cursors. See PageMachine() |
|---|
| 246 | //escape_shell_cmd(entries[x].val); |
|---|
| 247 | |
|---|
| 248 | if(!strcmp(entries[x].name,"gcFunction")) |
|---|
| 249 | sprintf(gcFunction,"%.99s",entries[x].val); |
|---|
| 250 | else if(!strcmp(entries[x].name,"guListMode")) |
|---|
| 251 | sscanf(entries[x].val,"%u",&guListMode); |
|---|
| 252 | else if(!strcmp(entries[x].name,"gcLogin")) |
|---|
| 253 | sprintf(gcLogin,"%.99s",entries[x].val); |
|---|
| 254 | else if(!strcmp(entries[x].name,"gcPasswd")) |
|---|
| 255 | sprintf(gcPasswd,"%.99s",entries[x].val); |
|---|
| 256 | } |
|---|
| 257 | |
|---|
| 258 | //SSLCookieLogin() |
|---|
| 259 | if(!strcmp(gcFunction,"Login")) SetLogin(); |
|---|
| 260 | |
|---|
| 261 | if(!guPermLevel || !gcUser[0] || !guLoginClient) |
|---|
| 262 | SSLCookieLogin(); |
|---|
| 263 | |
|---|
| 264 | //Main Post Menu |
|---|
| 265 | tDatacenterCommands(entries,x); |
|---|
| 266 | tNodeCommands(entries,x); |
|---|
| 267 | tContainerCommands(entries,x); |
|---|
| 268 | tPropertyCommands(entries,x); |
|---|
| 269 | tTypeCommands(entries,x); |
|---|
| 270 | tOSTemplateCommands(entries,x); |
|---|
| 271 | tNameserverCommands(entries,x); |
|---|
| 272 | tSearchdomainCommands(entries,x); |
|---|
| 273 | tConfigCommands(entries,x); |
|---|
| 274 | tIPCommands(entries,x); |
|---|
| 275 | tGroupTypeCommands(entries,x); |
|---|
| 276 | tGroupCommands(entries,x); |
|---|
| 277 | tGroupGlueCommands(entries,x); |
|---|
| 278 | tClientCommands(entries,x); |
|---|
| 279 | tAuthorizeCommands(entries,x); |
|---|
| 280 | tTemplateCommands(entries,x); |
|---|
| 281 | tTemplateSetCommands(entries,x); |
|---|
| 282 | tTemplateTypeCommands(entries,x); |
|---|
| 283 | tLogCommands(entries,x); |
|---|
| 284 | tLogTypeCommands(entries,x); |
|---|
| 285 | tLogMonthCommands(entries,x); |
|---|
| 286 | tMonthCommands(entries,x); |
|---|
| 287 | tGlossaryCommands(entries,x); |
|---|
| 288 | tJobCommands(entries,x); |
|---|
| 289 | tJobStatusCommands(entries,x); |
|---|
| 290 | tStatusCommands(entries,x); |
|---|
| 291 | tConfigurationCommands(entries,x); |
|---|
| 292 | |
|---|
| 293 | |
|---|
| 294 | iExtMainCommands(entries,x); |
|---|
| 295 | |
|---|
| 296 | NoSuchFunction(); |
|---|
| 297 | |
|---|
| 298 | return(0); |
|---|
| 299 | |
|---|
| 300 | }//end of main() |
|---|
| 301 | |
|---|
| 302 | #include "mainfunc.h" |
|---|
| 303 | |
|---|
| 304 | void unxsVZ(const char *cResult) |
|---|
| 305 | { |
|---|
| 306 | Header_ism3("Main",0); |
|---|
| 307 | |
|---|
| 308 | if(cResult[0]) |
|---|
| 309 | { |
|---|
| 310 | if(!strcmp(cResult,"CloneReport")) |
|---|
| 311 | CloneReport(cResult); |
|---|
| 312 | else if(!strcmp(cResult,"ContainerReport")) |
|---|
| 313 | ContainerReport(cResult); |
|---|
| 314 | else |
|---|
| 315 | DashBoard(cResult); |
|---|
| 316 | } |
|---|
| 317 | else |
|---|
| 318 | { |
|---|
| 319 | ExtMainContent(); |
|---|
| 320 | } |
|---|
| 321 | |
|---|
| 322 | Footer_ism3(); |
|---|
| 323 | |
|---|
| 324 | }//void unxsVZ(const char *cResult) |
|---|
| 325 | |
|---|
| 326 | |
|---|
| 327 | void StyleSheet(void) |
|---|
| 328 | { |
|---|
| 329 | printf("<style type=\"text/css\">\n"); |
|---|
| 330 | printf("<!--\n"); |
|---|
| 331 | |
|---|
| 332 | printf("input.smallButton {width:50px;}\n"); |
|---|
| 333 | printf("input.medButton {width:100px;}\n"); |
|---|
| 334 | printf("input.largeButton {width:150px;}\n"); |
|---|
| 335 | printf("input.warnButton {color:red;}\n"); |
|---|
| 336 | printf("input.lwarnButton {color:red;width:150px;}\n"); |
|---|
| 337 | printf("input.alertButton {color:#DAA520;}\n"); |
|---|
| 338 | printf("input.lalertButton {color:#DAA520;width:150px;}\n"); |
|---|
| 339 | printf("input.revButton {color:white;background:black;}\n"); |
|---|
| 340 | printf("input.lrevButton {color:white;background:black;width:150px;}\n"); |
|---|
| 341 | printf("A.darkLink {color:black; text-decoration:none;}\n"); |
|---|
| 342 | printf("A.darkLink:hover {color:blue; text-decoration:underline;}\n"); |
|---|
| 343 | printf("A:hover {color:blue; text-decoration:underline;}\n"); |
|---|
| 344 | |
|---|
| 345 | printf("textarea {font-family: Arial,Helvetica; font-size: 11px;}\n"); |
|---|
| 346 | printf("pre {font-family: Arial,Helvetica; font-size: 11px;}\n"); |
|---|
| 347 | printf("input {font-family: Arial,Helvetica; font-size: 11px;}\n"); |
|---|
| 348 | printf("select {font-family: Arial,Helvetica; font-size: 11px;}\n"); |
|---|
| 349 | |
|---|
| 350 | printf("body\n"); |
|---|
| 351 | printf("{\n"); |
|---|
| 352 | printf("\tmargin-top: 0px;\n"); |
|---|
| 353 | printf("\tmargin-bottom: 12px;\n"); |
|---|
| 354 | printf("\tmargin-left: 12px;\n"); |
|---|
| 355 | printf("\tmargin-right: 10px;\n"); |
|---|
| 356 | printf("\tfont-family: Arial,Helvetica;\n"); |
|---|
| 357 | printf("\t#font-size: 85%%;\n"); |
|---|
| 358 | printf("\tfont-size: 65%%;\n"); |
|---|
| 359 | printf("\tline-height: 135%%;\n"); |
|---|
| 360 | printf("\tpadding: 0px;\n"); |
|---|
| 361 | printf("}\n"); |
|---|
| 362 | |
|---|
| 363 | printf("br.clearall\n"); |
|---|
| 364 | printf("{\n"); |
|---|
| 365 | printf("\tclear: both;\n"); |
|---|
| 366 | printf("}\n"); |
|---|
| 367 | |
|---|
| 368 | printf("td\n"); |
|---|
| 369 | printf("{\n"); |
|---|
| 370 | printf("\tfont-family: Arial,Helvetica;\n"); |
|---|
| 371 | printf("}\n"); |
|---|
| 372 | |
|---|
| 373 | printf("#menuholder\n"); |
|---|
| 374 | printf("{\n"); |
|---|
| 375 | printf("\t#width: 100%%;\n"); |
|---|
| 376 | printf("}\n"); |
|---|
| 377 | |
|---|
| 378 | printf("#menutab\n"); |
|---|
| 379 | printf("{\n"); |
|---|
| 380 | printf("\tbackground: #e5e5e5 url('/images/hairline.gif') repeat-x bottom center;\n"); |
|---|
| 381 | printf("\tborder-top: 0px solid #BEBFBF;\n"); |
|---|
| 382 | printf("\tborder-right: 1px solid #BEBFBF;\n"); |
|---|
| 383 | printf("\tmargin-top: 8px;\n"); |
|---|
| 384 | printf("}\n"); |
|---|
| 385 | |
|---|
| 386 | printf("#topline\n"); |
|---|
| 387 | printf("{\n"); |
|---|
| 388 | printf("\t#width: 100%%;\n"); |
|---|
| 389 | printf("\tbackground: transparent url('/images/hairline.gif') repeat-x top center;\n"); |
|---|
| 390 | printf("}\n"); |
|---|
| 391 | |
|---|
| 392 | printf("#menutab ul, #menutab ol\n"); |
|---|
| 393 | printf("{\n"); |
|---|
| 394 | printf("\tmargin: 0;\n"); |
|---|
| 395 | printf("\tpadding: 0px 0px 0;\n"); |
|---|
| 396 | printf("\tlist-style: none;\n"); |
|---|
| 397 | printf("}\n"); |
|---|
| 398 | |
|---|
| 399 | printf("#menutab li\n"); |
|---|
| 400 | printf("{\n"); |
|---|
| 401 | printf("\tfloat: left;\n"); |
|---|
| 402 | printf("\tbackground: url('/images/left.gif') no-repeat left top;\n"); |
|---|
| 403 | printf("\tmargin: 0;\n"); |
|---|
| 404 | printf("\tpadding: 0 0 0 9px;\n"); |
|---|
| 405 | printf("}\n"); |
|---|
| 406 | |
|---|
| 407 | printf("#menutab a, #menutab a.last\n"); |
|---|
| 408 | printf("{\n"); |
|---|
| 409 | printf("\tfloat:left;\n"); |
|---|
| 410 | printf("\tdisplay: block;\n"); |
|---|
| 411 | printf("\tbackground: url('/images/right.gif') no-repeat right top;\n"); |
|---|
| 412 | printf("\tpadding: 5px 15px 2px 6px;\n"); |
|---|
| 413 | printf("\tcolor: #222;\n"); |
|---|
| 414 | printf("\ttext-decoration: none;\n"); |
|---|
| 415 | printf("}\n"); |
|---|
| 416 | |
|---|
| 417 | printf("/* Commented Backslash Hack\n"); |
|---|
| 418 | printf("\thides rule from IE5-Mac \\*/\n"); |
|---|
| 419 | printf("\t#menutab a, #menutab a.last {float:none;}\n"); |
|---|
| 420 | printf("/* End IE5-Mac hack */\n"); |
|---|
| 421 | |
|---|
| 422 | printf("#menutab a.last\n"); |
|---|
| 423 | printf("{\n"); |
|---|
| 424 | printf("\tbackground: url('/images/right_last.gif') no-repeat right top;\n"); |
|---|
| 425 | printf("\tpadding: 5px 17px 2px 6px;\n"); |
|---|
| 426 | printf("}\n"); |
|---|
| 427 | |
|---|
| 428 | printf("#menutab a:hover\n"); |
|---|
| 429 | printf("{\n"); |
|---|
| 430 | printf("\tcolor: black;\n"); |
|---|
| 431 | printf("\ttext-decoration: underline;\n"); |
|---|
| 432 | printf("}\n"); |
|---|
| 433 | |
|---|
| 434 | printf("#menutab #current\n"); |
|---|
| 435 | printf("{\n"); |
|---|
| 436 | printf("\tbackground-image: url('/images/left_on.gif');\n"); |
|---|
| 437 | printf("}\n"); |
|---|
| 438 | |
|---|
| 439 | printf("#menutab #current a\n"); |
|---|
| 440 | printf("{\n"); |
|---|
| 441 | printf("\tbackground-image: url('/images/right_on.gif');\n"); |
|---|
| 442 | printf("\tpadding-bottom: 3px;\n"); |
|---|
| 443 | printf("\ttext-decoration: none;\n"); |
|---|
| 444 | printf("}\n"); |
|---|
| 445 | |
|---|
| 446 | printf("-->\n"); |
|---|
| 447 | printf("</style>\n"); |
|---|
| 448 | |
|---|
| 449 | }//void StyleSheet(void) |
|---|
| 450 | |
|---|
| 451 | |
|---|
| 452 | void jsCalendarHeader(void) |
|---|
| 453 | { |
|---|
| 454 | printf("<link rel='stylesheet' type='text/css' media='all' href='/css/calendar-blue.css'/>\n"); |
|---|
| 455 | printf("<script type='text/javascript' src='/js/calendar.js'></script>\n"); |
|---|
| 456 | printf("<script type='text/javascript' src='/js/calendar-en.js'></script>\n"); |
|---|
| 457 | printf("<script type='text/javascript' src='/js/calendar-setup.js'></script>\n"); |
|---|
| 458 | }//void jsCalendarHeader(void) |
|---|
| 459 | |
|---|
| 460 | |
|---|
| 461 | void jsToggleCheckboxes(void) |
|---|
| 462 | { |
|---|
| 463 | printf("<script>" |
|---|
| 464 | "function checkAll(checkname, toggle)" |
|---|
| 465 | "{" |
|---|
| 466 | " for (i = 0; i < checkname.length; i++)" |
|---|
| 467 | " if( checkname[i].name.indexOf(\"NoCA\")==(-1) )" |
|---|
| 468 | " {" |
|---|
| 469 | " checkname[i].checked = toggle.checked? true:false" |
|---|
| 470 | " }" |
|---|
| 471 | "}" |
|---|
| 472 | "</script>"); |
|---|
| 473 | }//void jsToggleCheckboxes(void) |
|---|
| 474 | |
|---|
| 475 | |
|---|
| 476 | void jsCalendarInput(char *cInputName,char *cValue,unsigned uMode) |
|---|
| 477 | { |
|---|
| 478 | char cMode[16]={""}; |
|---|
| 479 | if(!uMode) |
|---|
| 480 | sprintf(cMode,"disabled"); |
|---|
| 481 | |
|---|
| 482 | printf("<input id='%s' class='field_input' type='text' name='%s' value='%s' size=40 maxlength=31" |
|---|
| 483 | " style='display: ; vertical-align: middle; ' %s >\n",cInputName,cInputName,cValue,cMode); |
|---|
| 484 | |
|---|
| 485 | if(uMode) |
|---|
| 486 | { |
|---|
| 487 | printf("<img date_trigger=1 class=record_button date_field='%s' id='date_trigger_%s_501'" |
|---|
| 488 | " src=\"/images/calendar.gif\"" |
|---|
| 489 | //Can't find swapClass function have to ask Hugo... |
|---|
| 490 | //" onmouseout=\"swapClass(event); this.src='/images/calendar.gif'\"" |
|---|
| 491 | //" onmouseover=\"swapClass(event); this.src='/images/calendar_mo.gif'\"" |
|---|
| 492 | " onmousedown=\"this.style.top='1px'; this.style.left='1px'\"" |
|---|
| 493 | " onmouseup=\"this.style.top='0px'; this.style.left='0px'\"" |
|---|
| 494 | " style=\"position: relative; vertical-align: middle; display: ;\"" |
|---|
| 495 | " title='Select date'/>\n",cInputName,cInputName); |
|---|
| 496 | printf("<script type='text/javascript'>\n" |
|---|
| 497 | "Calendar.setup({\n" |
|---|
| 498 | "\tinputField : '%s',\n" |
|---|
| 499 | "\tifFormat : '%%Y-%%m-%%d',\n" |
|---|
| 500 | "\tbutton : 'date_trigger_%s_501',\n" |
|---|
| 501 | "\talign : 'bR',\n" |
|---|
| 502 | "\tsingleClick : true,\n" |
|---|
| 503 | "\tweekNumbers : false,\n" |
|---|
| 504 | "\tstep : 1,\n" |
|---|
| 505 | "\ttimeFormat : 12\n" |
|---|
| 506 | "});</script>\n",cInputName,cInputName); |
|---|
| 507 | } |
|---|
| 508 | else |
|---|
| 509 | printf("<input type=hidden name='%s' value='%s'>\n",cInputName,cValue); |
|---|
| 510 | |
|---|
| 511 | }//void jsCalendarInput(char *cInputName,char *cValue,unsigned uMode) |
|---|
| 512 | |
|---|
| 513 | |
|---|
| 514 | void Header_ism3(const char *title, int iJs) |
|---|
| 515 | { |
|---|
| 516 | printf("Content-type: text/html\n\n"); |
|---|
| 517 | printf("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"" |
|---|
| 518 | " \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n"); |
|---|
| 519 | printf("<html><head><title>"HEADER_TITLE" %s %s </title>",gcHostname,title); |
|---|
| 520 | printf("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">\n"); |
|---|
| 521 | StyleSheet(); |
|---|
| 522 | if(iJs==1) |
|---|
| 523 | jsCalendarHeader(); |
|---|
| 524 | else if(iJs==2) |
|---|
| 525 | jsToggleCheckboxes(); |
|---|
| 526 | printf("<script language='JavaScript' src='/css/popups.js'></script>\n"); |
|---|
| 527 | printf("</head><body><form name=formMain action=unxsVZ.cgi method=post><blockquote>\n"); |
|---|
| 528 | printf("<img src=/images/unxslogo.gif> \n"); |
|---|
| 529 | |
|---|
| 530 | //ModuleRAD3NavBars() |
|---|
| 531 | if(!strcmp(gcFunction,"tDatacenter") || !strcmp(gcFunction,"tDatacenterTools") || |
|---|
| 532 | !strcmp(gcFunction,"tDatacenterList")) |
|---|
| 533 | ExttDatacenterNavBar(); |
|---|
| 534 | else if(!strcmp(gcFunction,"tNode") || !strcmp(gcFunction,"tNodeTools") || |
|---|
| 535 | !strcmp(gcFunction,"tNodeList")) |
|---|
| 536 | ExttNodeNavBar(); |
|---|
| 537 | else if(!strcmp(gcFunction,"tContainer") || !strcmp(gcFunction,"tContainerTools") || |
|---|
| 538 | !strcmp(gcFunction,"tContainerList")) |
|---|
| 539 | ExttContainerNavBar(); |
|---|
| 540 | else if(!strcmp(gcFunction,"tProperty") || !strcmp(gcFunction,"tPropertyTools") || |
|---|
| 541 | !strcmp(gcFunction,"tPropertyList")) |
|---|
| 542 | ExttPropertyNavBar(); |
|---|
| 543 | else if(!strcmp(gcFunction,"tType") || !strcmp(gcFunction,"tTypeTools") || |
|---|
| 544 | !strcmp(gcFunction,"tTypeList")) |
|---|
| 545 | ExttTypeNavBar(); |
|---|
| 546 | else if(!strcmp(gcFunction,"tOSTemplate") || !strcmp(gcFunction,"tOSTemplateTools") || |
|---|
| 547 | !strcmp(gcFunction,"tOSTemplateList")) |
|---|
| 548 | ExttOSTemplateNavBar(); |
|---|
| 549 | else if(!strcmp(gcFunction,"tNameserver") || !strcmp(gcFunction,"tNameserverTools") || |
|---|
| 550 | !strcmp(gcFunction,"tNameserverList")) |
|---|
| 551 | ExttNameserverNavBar(); |
|---|
| 552 | else if(!strcmp(gcFunction,"tSearchdomain") || !strcmp(gcFunction,"tSearchdomainTools") || |
|---|
| 553 | !strcmp(gcFunction,"tSearchdomainList")) |
|---|
| 554 | ExttSearchdomainNavBar(); |
|---|
| 555 | else if(!strcmp(gcFunction,"tConfig") || !strcmp(gcFunction,"tConfigTools") || |
|---|
| 556 | !strcmp(gcFunction,"tConfigList")) |
|---|
| 557 | ExttConfigNavBar(); |
|---|
| 558 | else if(!strcmp(gcFunction,"tIP") || !strcmp(gcFunction,"tIPTools") || |
|---|
| 559 | !strcmp(gcFunction,"tIPList")) |
|---|
| 560 | ExttIPNavBar(); |
|---|
| 561 | else if(!strcmp(gcFunction,"tGroupType") || !strcmp(gcFunction,"tGroupTypeTools") || |
|---|
| 562 | !strcmp(gcFunction,"tGroupTypeList")) |
|---|
| 563 | ExttGroupTypeNavBar(); |
|---|
| 564 | else if(!strcmp(gcFunction,"tGroup") || !strcmp(gcFunction,"tGroupTools") || |
|---|
| 565 | !strcmp(gcFunction,"tGroupList")) |
|---|
| 566 | ExttGroupNavBar(); |
|---|
| 567 | else if(!strcmp(gcFunction,"tGroupGlue") || !strcmp(gcFunction,"tGroupGlueTools") || |
|---|
| 568 | !strcmp(gcFunction,"tGroupGlueList")) |
|---|
| 569 | ExttGroupGlueNavBar(); |
|---|
| 570 | else if(!strcmp(gcFunction,"tClient") || !strcmp(gcFunction,"tClientTools") || |
|---|
| 571 | !strcmp(gcFunction,"tClientList")) |
|---|
| 572 | ExttClientNavBar(); |
|---|
| 573 | else if(!strcmp(gcFunction,"tAuthorize") || !strcmp(gcFunction,"tAuthorizeTools") || |
|---|
| 574 | !strcmp(gcFunction,"tAuthorizeList")) |
|---|
| 575 | ExttAuthorizeNavBar(); |
|---|
| 576 | else if(!strcmp(gcFunction,"tTemplate") || !strcmp(gcFunction,"tTemplateTools") || |
|---|
| 577 | !strcmp(gcFunction,"tTemplateList")) |
|---|
| 578 | ExttTemplateNavBar(); |
|---|
| 579 | else if(!strcmp(gcFunction,"tTemplateSet") || !strcmp(gcFunction,"tTemplateSetTools") || |
|---|
| 580 | !strcmp(gcFunction,"tTemplateSetList")) |
|---|
| 581 | ExttTemplateSetNavBar(); |
|---|
| 582 | else if(!strcmp(gcFunction,"tTemplateType") || !strcmp(gcFunction,"tTemplateTypeTools") || |
|---|
| 583 | !strcmp(gcFunction,"tTemplateTypeList")) |
|---|
| 584 | ExttTemplateTypeNavBar(); |
|---|
| 585 | else if(!strcmp(gcFunction,"tLog") || !strcmp(gcFunction,"tLogTools") || |
|---|
| 586 | !strcmp(gcFunction,"tLogList")) |
|---|
| 587 | ExttLogNavBar(); |
|---|
| 588 | else if(!strcmp(gcFunction,"tLogType") || !strcmp(gcFunction,"tLogTypeTools") || |
|---|
| 589 | !strcmp(gcFunction,"tLogTypeList")) |
|---|
| 590 | ExttLogTypeNavBar(); |
|---|
| 591 | else if(!strcmp(gcFunction,"tLogMonth") || !strcmp(gcFunction,"tLogMonthTools") || |
|---|
| 592 | !strcmp(gcFunction,"tLogMonthList")) |
|---|
| 593 | ExttLogMonthNavBar(); |
|---|
| 594 | else if(!strcmp(gcFunction,"tMonth") || !strcmp(gcFunction,"tMonthTools") || |
|---|
| 595 | !strcmp(gcFunction,"tMonthList")) |
|---|
| 596 | ExttMonthNavBar(); |
|---|
| 597 | else if(!strcmp(gcFunction,"tGlossary") || !strcmp(gcFunction,"tGlossaryTools") || |
|---|
| 598 | !strcmp(gcFunction,"tGlossaryList")) |
|---|
| 599 | ExttGlossaryNavBar(); |
|---|
| 600 | else if(!strcmp(gcFunction,"tJob") || !strcmp(gcFunction,"tJobTools") || |
|---|
| 601 | !strcmp(gcFunction,"tJobList")) |
|---|
| 602 | ExttJobNavBar(); |
|---|
| 603 | else if(!strcmp(gcFunction,"tJobStatus") || !strcmp(gcFunction,"tJobStatusTools") || |
|---|
| 604 | !strcmp(gcFunction,"tJobStatusList")) |
|---|
| 605 | ExttJobStatusNavBar(); |
|---|
| 606 | else if(!strcmp(gcFunction,"tStatus") || !strcmp(gcFunction,"tStatusTools") || |
|---|
| 607 | !strcmp(gcFunction,"tStatusList")) |
|---|
| 608 | ExttStatusNavBar(); |
|---|
| 609 | else if(!strcmp(gcFunction,"tConfiguration") || !strcmp(gcFunction,"tConfigurationTools") || |
|---|
| 610 | !strcmp(gcFunction,"tConfigurationList")) |
|---|
| 611 | ExttConfigurationNavBar(); |
|---|
| 612 | |
|---|
| 613 | |
|---|
| 614 | //Login info |
|---|
| 615 | //printf("<font size=3><b>unxsVZ</b></font> \n "); |
|---|
| 616 | if(!guPermLevel) |
|---|
| 617 | { |
|---|
| 618 | printf(" <font color=red>Your IP address %s has been logged</font>",gcHost); |
|---|
| 619 | } |
|---|
| 620 | else |
|---|
| 621 | { |
|---|
| 622 | printf(" <font color=red>%s ",gcUser); |
|---|
| 623 | if(strcmp(gcUser,gcCompany)) printf("(%s) ",gcCompany); |
|---|
| 624 | printf("logged in from %s [%s]</font>",gcHost,cUserLevel(guPermLevel)); |
|---|
| 625 | } |
|---|
| 626 | |
|---|
| 627 | //Logout link |
|---|
| 628 | if(guSSLCookieLogin) |
|---|
| 629 | { |
|---|
| 630 | printf(" <a title='Erase login cookies' href=unxsVZ.cgi?gcFunction=Logout>Logout</a> "); |
|---|
| 631 | printf(" <a title='Quick dashboard link' href=unxsVZ.cgi?gcFunction=Dashboard>Dashboard</a> "); |
|---|
| 632 | } |
|---|
| 633 | |
|---|
| 634 | //Generate Menu Items |
|---|
| 635 | printf("\n<!-- tab menu -->\n"); |
|---|
| 636 | printf("<div id=menuholder>\n"); |
|---|
| 637 | printf("\t<div id=menutab>\n"); |
|---|
| 638 | |
|---|
| 639 | printf("\t\t<div id=topline>\n"); |
|---|
| 640 | printf("\t\t\t<ol>\n"); |
|---|
| 641 | |
|---|
| 642 | |
|---|
| 643 | //Main always exists for RAD |
|---|
| 644 | printf("\t\t\t<li"); |
|---|
| 645 | if(strncmp(gcFunction,"Main",4)) |
|---|
| 646 | printf(">\n"); |
|---|
| 647 | else |
|---|
| 648 | printf(" id=current>\n"); |
|---|
| 649 | printf("\t\t\t<a title='Home start page' href=unxsVZ.cgi?gcFunction=Main>Main</a>\n"); |
|---|
| 650 | printf("\t\t\t</li>\n"); |
|---|
| 651 | |
|---|
| 652 | //tDatacenter |
|---|
| 653 | if(guPermLevel>=7) |
|---|
| 654 | { |
|---|
| 655 | printf("\t\t\t<li"); |
|---|
| 656 | if(strcmp(gcFunction,"tDatacenter") && strcmp(gcFunction,"tDatacenterTools") && |
|---|
| 657 | strcmp(gcFunction,"tDatacenterList")) |
|---|
| 658 | printf(">\n"); |
|---|
| 659 | else |
|---|
| 660 | printf(" id=current>\n"); |
|---|
| 661 | printf("\t\t\t<a title='Datacenter' href=unxsVZ.cgi?gcFunction=tDatacenter>tDatacenter</a>\n"); |
|---|
| 662 | } |
|---|
| 663 | //tNode |
|---|
| 664 | if(guPermLevel>=7) |
|---|
| 665 | { |
|---|
| 666 | printf("\t\t\t<li"); |
|---|
| 667 | if(strcmp(gcFunction,"tNode") && strcmp(gcFunction,"tNodeTools") && |
|---|
| 668 | strcmp(gcFunction,"tNodeList")) |
|---|
| 669 | printf(">\n"); |
|---|
| 670 | else |
|---|
| 671 | printf(" id=current>\n"); |
|---|
| 672 | printf("\t\t\t<a title='Hardware node' href=unxsVZ.cgi?gcFunction=tNode>tNode</a>\n"); |
|---|
| 673 | } |
|---|
| 674 | //tContainer |
|---|
| 675 | if(guPermLevel>=7) |
|---|
| 676 | { |
|---|
| 677 | printf("\t\t\t<li"); |
|---|
| 678 | if(strcmp(gcFunction,"tContainer") && strcmp(gcFunction,"tContainerTools") && |
|---|
| 679 | strcmp(gcFunction,"tContainerList")) |
|---|
| 680 | printf(">\n"); |
|---|
| 681 | else |
|---|
| 682 | printf(" id=current>\n"); |
|---|
| 683 | printf("\t\t\t<a title='OpenVZ Container' href=unxsVZ.cgi?gcFunction=tContainer>tContainer</a>\n"); |
|---|
| 684 | } |
|---|
| 685 | //tProperty |
|---|
| 686 | if(guPermLevel>=20) |
|---|
| 687 | { |
|---|
| 688 | printf("\t\t\t<li"); |
|---|
| 689 | if(strcmp(gcFunction,"tProperty") && strcmp(gcFunction,"tPropertyTools") && |
|---|
| 690 | strcmp(gcFunction,"tPropertyList")) |
|---|
| 691 | printf(">\n"); |
|---|
| 692 | else |
|---|
| 693 | printf(" id=current>\n"); |
|---|
| 694 | printf("\t\t\t<a title='Shared property table' href=unxsVZ.cgi?gcFunction=tProperty>tProperty</a>\n"); |
|---|
| 695 | } |
|---|
| 696 | //tType |
|---|
| 697 | if(guPermLevel>=20) |
|---|
| 698 | { |
|---|
| 699 | printf("\t\t\t<li"); |
|---|
| 700 | if(strcmp(gcFunction,"tType") && strcmp(gcFunction,"tTypeTools") && |
|---|
| 701 | strcmp(gcFunction,"tTypeList")) |
|---|
| 702 | printf(">\n"); |
|---|
| 703 | else |
|---|
| 704 | printf(" id=current>\n"); |
|---|
| 705 | printf("\t\t\t<a title='Property Type' href=unxsVZ.cgi?gcFunction=tType>tType</a>\n"); |
|---|
| 706 | } |
|---|
| 707 | //tOSTemplate |
|---|
| 708 | if(guPermLevel>=20) |
|---|
| 709 | { |
|---|
| 710 | printf("\t\t\t<li"); |
|---|
| 711 | if(strcmp(gcFunction,"tOSTemplate") && strcmp(gcFunction,"tOSTemplateTools") && |
|---|
| 712 | strcmp(gcFunction,"tOSTemplateList")) |
|---|
| 713 | printf(">\n"); |
|---|
| 714 | else |
|---|
| 715 | printf(" id=current>\n"); |
|---|
| 716 | printf("\t\t\t<a title='Container OS Template' href=unxsVZ.cgi?gcFunction=tOSTemplate>tOSTemplate</a>\n"); |
|---|
| 717 | } |
|---|
| 718 | //tNameserver |
|---|
| 719 | if(guPermLevel>=20) |
|---|
| 720 | { |
|---|
| 721 | printf("\t\t\t<li"); |
|---|
| 722 | if(strcmp(gcFunction,"tNameserver") && strcmp(gcFunction,"tNameserverTools") && |
|---|
| 723 | strcmp(gcFunction,"tNameserverList")) |
|---|
| 724 | printf(">\n"); |
|---|
| 725 | else |
|---|
| 726 | printf(" id=current>\n"); |
|---|
| 727 | printf("\t\t\t<a title='Container Resolver Nameserver Set' href=unxsVZ.cgi?gcFunction=tNameserver>tNameserver</a>\n"); |
|---|
| 728 | } |
|---|
| 729 | //tSearchdomain |
|---|
| 730 | if(guPermLevel>=20) |
|---|
| 731 | { |
|---|
| 732 | printf("\t\t\t<li"); |
|---|
| 733 | if(strcmp(gcFunction,"tSearchdomain") && strcmp(gcFunction,"tSearchdomainTools") && |
|---|
| 734 | strcmp(gcFunction,"tSearchdomainList")) |
|---|
| 735 | printf(">\n"); |
|---|
| 736 | else |
|---|
| 737 | printf(" id=current>\n"); |
|---|
| 738 | printf("\t\t\t<a title='Container Resolver Searchdomain' href=unxsVZ.cgi?gcFunction=tSearchdomain>tSearchdomain</a>\n"); |
|---|
| 739 | } |
|---|
| 740 | //tConfig |
|---|
| 741 | if(guPermLevel>=20) |
|---|
| 742 | { |
|---|
| 743 | printf("\t\t\t<li"); |
|---|
| 744 | if(strcmp(gcFunction,"tConfig") && strcmp(gcFunction,"tConfigTools") && |
|---|
| 745 | strcmp(gcFunction,"tConfigList")) |
|---|
| 746 | printf(">\n"); |
|---|
| 747 | else |
|---|
| 748 | printf(" id=current>\n"); |
|---|
| 749 | printf("\t\t\t<a title='Config File Used on Creation' href=unxsVZ.cgi?gcFunction=tConfig>tConfig</a>\n"); |
|---|
| 750 | } |
|---|
| 751 | //tIP |
|---|
| 752 | if(guPermLevel>=10) |
|---|
| 753 | { |
|---|
| 754 | printf("\t\t\t<li"); |
|---|
| 755 | if(strcmp(gcFunction,"tIP") && strcmp(gcFunction,"tIPTools") && |
|---|
| 756 | strcmp(gcFunction,"tIPList")) |
|---|
| 757 | printf(">\n"); |
|---|
| 758 | else |
|---|
| 759 | printf(" id=current>\n"); |
|---|
| 760 | printf("\t\t\t<a title='IPs used and reserved for use' href=unxsVZ.cgi?gcFunction=tIP>tIP</a>\n"); |
|---|
| 761 | } |
|---|
| 762 | //tGroupType |
|---|
| 763 | if(guPermLevel>=20) |
|---|
| 764 | { |
|---|
| 765 | printf("\t\t\t<li"); |
|---|
| 766 | if(strcmp(gcFunction,"tGroupType") && strcmp(gcFunction,"tGroupTypeTools") && |
|---|
| 767 | strcmp(gcFunction,"tGroupTypeList")) |
|---|
| 768 | printf(">\n"); |
|---|
| 769 | else |
|---|
| 770 | printf(" id=current>\n"); |
|---|
| 771 | printf("\t\t\t<a title='Container or node group type' href=unxsVZ.cgi?gcFunction=tGroupType>tGroupType</a>\n"); |
|---|
| 772 | } |
|---|
| 773 | //tGroup |
|---|
| 774 | if(guPermLevel>=10) |
|---|
| 775 | { |
|---|
| 776 | printf("\t\t\t<li"); |
|---|
| 777 | if(strcmp(gcFunction,"tGroup") && strcmp(gcFunction,"tGroupTools") && |
|---|
| 778 | strcmp(gcFunction,"tGroupList")) |
|---|
| 779 | printf(">\n"); |
|---|
| 780 | else |
|---|
| 781 | printf(" id=current>\n"); |
|---|
| 782 | printf("\t\t\t<a title='Container or node group' href=unxsVZ.cgi?gcFunction=tGroup>tGroup</a>\n"); |
|---|
| 783 | } |
|---|
| 784 | //tGroupGlue |
|---|
| 785 | if(guPermLevel>=20) |
|---|
| 786 | { |
|---|
| 787 | printf("\t\t\t<li"); |
|---|
| 788 | if(strcmp(gcFunction,"tGroupGlue") && strcmp(gcFunction,"tGroupGlueTools") && |
|---|
| 789 | strcmp(gcFunction,"tGroupGlueList")) |
|---|
| 790 | printf(">\n"); |
|---|
| 791 | else |
|---|
| 792 | printf(" id=current>\n"); |
|---|
| 793 | printf("\t\t\t<a title='Glues uContainers or uNodes to uGroups' href=unxsVZ.cgi?gcFunction=tGroupGlue>tGroupGlue</a>\n"); |
|---|
| 794 | } |
|---|
| 795 | //tClient |
|---|
| 796 | if(guPermLevel>=10) |
|---|
| 797 | { |
|---|
| 798 | printf("\t\t\t<li"); |
|---|
| 799 | if(strcmp(gcFunction,"tClient") && strcmp(gcFunction,"tClientTools") && |
|---|
| 800 | strcmp(gcFunction,"tClientList")) |
|---|
| 801 | printf(">\n"); |
|---|
| 802 | else |
|---|
| 803 | printf(" id=current>\n"); |
|---|
| 804 | printf("\t\t\t<a title='Client Info' href=unxsVZ.cgi?gcFunction=tClient>tClient</a>\n"); |
|---|
| 805 | } |
|---|
| 806 | //tAuthorize |
|---|
| 807 | if(guPermLevel>=20) |
|---|
| 808 | { |
|---|
| 809 | printf("\t\t\t<li"); |
|---|
| 810 | if(strcmp(gcFunction,"tAuthorize") && strcmp(gcFunction,"tAuthorizeTools") && |
|---|
| 811 | strcmp(gcFunction,"tAuthorizeList")) |
|---|
| 812 | printf(">\n"); |
|---|
| 813 | else |
|---|
| 814 | printf(" id=current>\n"); |
|---|
| 815 | printf("\t\t\t<a title='Login Authorization' href=unxsVZ.cgi?gcFunction=tAuthorize>tAuthorize</a>\n"); |
|---|
| 816 | } |
|---|
| 817 | //tTemplate |
|---|
| 818 | if(guPermLevel>=20) |
|---|
| 819 | { |
|---|
| 820 | printf("\t\t\t<li"); |
|---|
| 821 | if(strcmp(gcFunction,"tTemplate") && strcmp(gcFunction,"tTemplateTools") && |
|---|
| 822 | strcmp(gcFunction,"tTemplateList")) |
|---|
| 823 | printf(">\n"); |
|---|
| 824 | else |
|---|
| 825 | printf(" id=current>\n"); |
|---|
| 826 | printf("\t\t\t<a title='tTemplate' href=unxsVZ.cgi?gcFunction=tTemplate>tTemplate</a>\n"); |
|---|
| 827 | } |
|---|
| 828 | //tTemplateSet |
|---|
| 829 | if(guPermLevel>=20) |
|---|
| 830 | { |
|---|
| 831 | printf("\t\t\t<li"); |
|---|
| 832 | if(strcmp(gcFunction,"tTemplateSet") && strcmp(gcFunction,"tTemplateSetTools") && |
|---|
| 833 | strcmp(gcFunction,"tTemplateSetList")) |
|---|
| 834 | printf(">\n"); |
|---|
| 835 | else |
|---|
| 836 | printf(" id=current>\n"); |
|---|
| 837 | printf("\t\t\t<a title='tTemplateSet' href=unxsVZ.cgi?gcFunction=tTemplateSet>tTemplateSet</a>\n"); |
|---|
| 838 | } |
|---|
| 839 | //tTemplateType |
|---|
| 840 | if(guPermLevel>=20) |
|---|
| 841 | { |
|---|
| 842 | printf("\t\t\t<li"); |
|---|
| 843 | if(strcmp(gcFunction,"tTemplateType") && strcmp(gcFunction,"tTemplateTypeTools") && |
|---|
| 844 | strcmp(gcFunction,"tTemplateTypeList")) |
|---|
| 845 | printf(">\n"); |
|---|
| 846 | else |
|---|
| 847 | printf(" id=current>\n"); |
|---|
| 848 | printf("\t\t\t<a title='tTemplateType' href=unxsVZ.cgi?gcFunction=tTemplateType>tTemplateType</a>\n"); |
|---|
| 849 | } |
|---|
| 850 | //tLog |
|---|
| 851 | if(guPermLevel>=20) |
|---|
| 852 | { |
|---|
| 853 | printf("\t\t\t<li"); |
|---|
| 854 | if(strcmp(gcFunction,"tLog") && strcmp(gcFunction,"tLogTools") && |
|---|
| 855 | strcmp(gcFunction,"tLogList")) |
|---|
| 856 | printf(">\n"); |
|---|
| 857 | else |
|---|
| 858 | printf(" id=current>\n"); |
|---|
| 859 | printf("\t\t\t<a title='tLog' href=unxsVZ.cgi?gcFunction=tLog>tLog</a>\n"); |
|---|
| 860 | } |
|---|
| 861 | //tLogType |
|---|
| 862 | if(guPermLevel>=20) |
|---|
| 863 | { |
|---|
| 864 | printf("\t\t\t<li"); |
|---|
| 865 | if(strcmp(gcFunction,"tLogType") && strcmp(gcFunction,"tLogTypeTools") && |
|---|
| 866 | strcmp(gcFunction,"tLogTypeList")) |
|---|
| 867 | printf(">\n"); |
|---|
| 868 | else |
|---|
| 869 | printf(" id=current>\n"); |
|---|
| 870 | printf("\t\t\t<a title='tLogType' href=unxsVZ.cgi?gcFunction=tLogType>tLogType</a>\n"); |
|---|
| 871 | } |
|---|
| 872 | //tLogMonth |
|---|
| 873 | if(guPermLevel>=20) |
|---|
| 874 | { |
|---|
| 875 | printf("\t\t\t<li"); |
|---|
| 876 | if(strcmp(gcFunction,"tLogMonth") && strcmp(gcFunction,"tLogMonthTools") && |
|---|
| 877 | strcmp(gcFunction,"tLogMonthList")) |
|---|
| 878 | printf(">\n"); |
|---|
| 879 | else |
|---|
| 880 | printf(" id=current>\n"); |
|---|
| 881 | printf("\t\t\t<a title='tLogMonth' href=unxsVZ.cgi?gcFunction=tLogMonth>tLogMonth</a>\n"); |
|---|
| 882 | } |
|---|
| 883 | //tMonth |
|---|
| 884 | if(guPermLevel>=20) |
|---|
| 885 | { |
|---|
| 886 | printf("\t\t\t<li"); |
|---|
| 887 | if(strcmp(gcFunction,"tMonth") && strcmp(gcFunction,"tMonthTools") && |
|---|
| 888 | strcmp(gcFunction,"tMonthList")) |
|---|
| 889 | printf(">\n"); |
|---|
| 890 | else |
|---|
| 891 | printf(" id=current>\n"); |
|---|
| 892 | printf("\t\t\t<a title='tMonth' href=unxsVZ.cgi?gcFunction=tMonth>tMonth</a>\n"); |
|---|
| 893 | } |
|---|
| 894 | //tGlossary |
|---|
| 895 | if(guPermLevel>=20) |
|---|
| 896 | { |
|---|
| 897 | printf("\t\t\t<li"); |
|---|
| 898 | if(strcmp(gcFunction,"tGlossary") && strcmp(gcFunction,"tGlossaryTools") && |
|---|
| 899 | strcmp(gcFunction,"tGlossaryList")) |
|---|
| 900 | printf(">\n"); |
|---|
| 901 | else |
|---|
| 902 | printf(" id=current>\n"); |
|---|
| 903 | printf("\t\t\t<a title='tGlossary' href=unxsVZ.cgi?gcFunction=tGlossary>tGlossary</a>\n"); |
|---|
| 904 | } |
|---|
| 905 | //tJob |
|---|
| 906 | if(guPermLevel>=7) |
|---|
| 907 | { |
|---|
| 908 | printf("\t\t\t<li"); |
|---|
| 909 | if(strcmp(gcFunction,"tJob") && strcmp(gcFunction,"tJobTools") && |
|---|
| 910 | strcmp(gcFunction,"tJobList")) |
|---|
| 911 | printf(">\n"); |
|---|
| 912 | else |
|---|
| 913 | printf(" id=current>\n"); |
|---|
| 914 | printf("\t\t\t<a title='tJob' href=unxsVZ.cgi?gcFunction=tJob>tJob</a>\n"); |
|---|
| 915 | } |
|---|
| 916 | //tJobStatus |
|---|
| 917 | if(guPermLevel>=20) |
|---|
| 918 | { |
|---|
| 919 | printf("\t\t\t<li"); |
|---|
| 920 | if(strcmp(gcFunction,"tJobStatus") && strcmp(gcFunction,"tJobStatusTools") && |
|---|
| 921 | strcmp(gcFunction,"tJobStatusList")) |
|---|
| 922 | printf(">\n"); |
|---|
| 923 | else |
|---|
| 924 | printf(" id=current>\n"); |
|---|
| 925 | printf("\t\t\t<a title='tJobStatus' href=unxsVZ.cgi?gcFunction=tJobStatus>tJobStatus</a>\n"); |
|---|
| 926 | } |
|---|
| 927 | //tStatus |
|---|
| 928 | if(guPermLevel>=20) |
|---|
| 929 | { |
|---|
| 930 | printf("\t\t\t<li"); |
|---|
| 931 | if(strcmp(gcFunction,"tStatus") && strcmp(gcFunction,"tStatusTools") && |
|---|
| 932 | strcmp(gcFunction,"tStatusList")) |
|---|
| 933 | printf(">\n"); |
|---|
| 934 | else |
|---|
| 935 | printf(" id=current>\n"); |
|---|
| 936 | printf("\t\t\t<a title='tStatus' href=unxsVZ.cgi?gcFunction=tStatus>tStatus</a>\n"); |
|---|
| 937 | } |
|---|
| 938 | //tConfiguration |
|---|
| 939 | if(guPermLevel>=20) |
|---|
| 940 | { |
|---|
| 941 | printf("\t\t\t<li"); |
|---|
| 942 | if(strcmp(gcFunction,"tConfiguration") && strcmp(gcFunction,"tConfigurationTools") && |
|---|
| 943 | strcmp(gcFunction,"tConfigurationList")) |
|---|
| 944 | printf(">\n"); |
|---|
| 945 | else |
|---|
| 946 | printf(" id=current>\n"); |
|---|
| 947 | printf("\t\t\t<a title='tConfiguration' href=unxsVZ.cgi?gcFunction=tConfiguration>tConfiguration</a>\n"); |
|---|
| 948 | } |
|---|
| 949 | |
|---|
| 950 | |
|---|
| 951 | printf("\t\t\t</ol>\n"); |
|---|
| 952 | |
|---|
| 953 | printf("\t\t\t<br class=clearall >\n"); |
|---|
| 954 | printf("\t\t</div>\n"); |
|---|
| 955 | printf("\t</div>\n"); |
|---|
| 956 | printf("</div>\n"); |
|---|
| 957 | |
|---|
| 958 | }//Header_ism3(char *title, int js) |
|---|
| 959 | |
|---|
| 960 | |
|---|
| 961 | void Footer_ism3(void) |
|---|
| 962 | { |
|---|
| 963 | printf("</blockquote>"); |
|---|
| 964 | |
|---|
| 965 | mysql_close(&gMysql); |
|---|
| 966 | exit(0); |
|---|
| 967 | |
|---|
| 968 | }//Footer_ism3(void) |
|---|
| 969 | |
|---|
| 970 | |
|---|
| 971 | void NoSuchFunction(void) |
|---|
| 972 | { |
|---|
| 973 | |
|---|
| 974 | sprintf(gcQuery,"[%s] Not Recognized",gcFunction); |
|---|
| 975 | unxsVZ(gcQuery); |
|---|
| 976 | } |
|---|
| 977 | |
|---|
| 978 | void ProcessControlVars(pentry entries[], int x) |
|---|
| 979 | { |
|---|
| 980 | register int i; |
|---|
| 981 | |
|---|
| 982 | for(i=0;i<x;i++) |
|---|
| 983 | { |
|---|
| 984 | if(!strcmp(entries[i].name,"gcFilter")) |
|---|
| 985 | strcpy(gcFilter,entries[i].val); |
|---|
| 986 | else if(!strcmp(entries[i].name,"gcCommand")) |
|---|
| 987 | strcpy(gcCommand,entries[i].val); |
|---|
| 988 | else if(!strcmp(entries[i].name,"gcFind")) |
|---|
| 989 | strcpy(gcFind,entries[i].val); |
|---|
| 990 | else if(!strcmp(entries[i].name,"gluRowid")) |
|---|
| 991 | sscanf(entries[i].val,"%lu",&gluRowid); |
|---|
| 992 | } |
|---|
| 993 | } |
|---|
| 994 | |
|---|
| 995 | //guMode=0 page guMode, guMode=1 list auto header mode |
|---|
| 996 | void PageMachine(char *cFuncName, int iLmode, char *cMsg) |
|---|
| 997 | { |
|---|
| 998 | |
|---|
| 999 | if(iLmode) |
|---|
| 1000 | { |
|---|
| 1001 | //List mode |
|---|
| 1002 | |
|---|
| 1003 | if(gluRowid<1) gluRowid=1; |
|---|
| 1004 | if(gluRowid>(guN=((guI/SHOWPAGE)+1))) gluRowid=guN; |
|---|
| 1005 | |
|---|
| 1006 | if(!strcmp(gcFind," >")) |
|---|
| 1007 | { |
|---|
| 1008 | //If NOT on last page show next page |
|---|
| 1009 | if( gluRowid >= guN-1 ) |
|---|
| 1010 | { |
|---|
| 1011 | //If on last page adjust end |
|---|
| 1012 | guStart= ((guI/SHOWPAGE)*SHOWPAGE) + 1; |
|---|
| 1013 | guEnd=guI; |
|---|
| 1014 | } |
|---|
| 1015 | else |
|---|
| 1016 | { |
|---|
| 1017 | guStart=((gluRowid)*SHOWPAGE)+1; |
|---|
| 1018 | guEnd=guStart+SHOWPAGE-1; |
|---|
| 1019 | gluRowid++; |
|---|
| 1020 | } |
|---|
| 1021 | } |
|---|
| 1022 | else if(!strcmp(gcFind,"< ")) |
|---|
| 1023 | { |
|---|
| 1024 | if(gluRowid>1 ) |
|---|
| 1025 | { |
|---|
| 1026 | gluRowid--; |
|---|
| 1027 | guStart=(gluRowid)*SHOWPAGE-SHOWPAGE+1; |
|---|
| 1028 | guEnd=guStart+SHOWPAGE-1; |
|---|
| 1029 | } |
|---|
| 1030 | else |
|---|
| 1031 | { |
|---|
| 1032 | guStart=1; |
|---|
| 1033 | if(guI > SHOWPAGE) |
|---|
| 1034 | { |
|---|
| 1035 | guEnd=SHOWPAGE; |
|---|
| 1036 | } |
|---|
| 1037 | else |
|---|
| 1038 | { |
|---|
| 1039 | guEnd=guI; |
|---|
| 1040 | } |
|---|
| 1041 | gluRowid=1; |
|---|
| 1042 | } |
|---|
| 1043 | } |
|---|
| 1044 | else if(!strcmp(gcFind,">>")) |
|---|
| 1045 | { |
|---|
| 1046 | guStart= ((guI/SHOWPAGE)*SHOWPAGE) + 1; |
|---|
| 1047 | guEnd=guI; |
|---|
| 1048 | gluRowid=guN; |
|---|
| 1049 | } |
|---|
| 1050 | else if(1) |
|---|
| 1051 | { |
|---|
| 1052 | guStart=1; |
|---|
| 1053 | if(guI > SHOWPAGE) |
|---|
| 1054 | { |
|---|
| 1055 | guEnd=SHOWPAGE; |
|---|
| 1056 | } |
|---|
| 1057 | else |
|---|
| 1058 | { |
|---|
| 1059 | guEnd=guI; |
|---|
| 1060 | } |
|---|
| 1061 | gluRowid=1; |
|---|
| 1062 | } |
|---|
| 1063 | |
|---|
| 1064 | guListMode=1; |
|---|
| 1065 | Header_ism3(cFuncName,0); |
|---|
| 1066 | |
|---|
| 1067 | if(!guI) |
|---|
| 1068 | { |
|---|
| 1069 | printf(LANG_PAGEMACHINE_HINT); |
|---|
| 1070 | |
|---|
| 1071 | } |
|---|
| 1072 | |
|---|
| 1073 | |
|---|
| 1074 | printf(LANG_PAGEMACHINE_SHOWING,1+(guStart/SHOWPAGE),guN,guStart,guEnd,guI); |
|---|
| 1075 | |
|---|
| 1076 | |
|---|
| 1077 | printf("<input type=hidden name=gluRowid value=%lu>",gluRowid); |
|---|
| 1078 | printf("<input type=hidden name=gcFunction value=%s >",cFuncName); |
|---|
| 1079 | printf("<input type=hidden name=guListMode value=1 >\n"); |
|---|
| 1080 | } |
|---|
| 1081 | else |
|---|
| 1082 | { |
|---|
| 1083 | //Page mode |
|---|
| 1084 | //on entry guI has number of rows |
|---|
| 1085 | //on entry gluRowid has current position unless guI=1 |
|---|
| 1086 | //if guI=1 then we need to figure out real guI |
|---|
| 1087 | |
|---|
| 1088 | guN=guI; |
|---|
| 1089 | |
|---|
| 1090 | if(gluRowid<1) |
|---|
| 1091 | { |
|---|
| 1092 | gluRowid=1; |
|---|
| 1093 | return; |
|---|
| 1094 | } |
|---|
| 1095 | |
|---|
| 1096 | if(!strcmp(gcFind," >")) |
|---|
| 1097 | { |
|---|
| 1098 | //If on last page stay there |
|---|
| 1099 | if( gluRowid >= guI ) |
|---|
| 1100 | { |
|---|
| 1101 | //If on last page adjust guEnd |
|---|
| 1102 | gluRowid=guI; |
|---|
| 1103 | } |
|---|
| 1104 | else |
|---|
| 1105 | { |
|---|
| 1106 | gluRowid++; |
|---|
| 1107 | } |
|---|
| 1108 | } |
|---|
| 1109 | else if(!strcmp(gcFind,"< ")) |
|---|
| 1110 | { |
|---|
| 1111 | if(gluRowid>1 ) |
|---|
| 1112 | { |
|---|
| 1113 | gluRowid--; |
|---|
| 1114 | } |
|---|
| 1115 | else |
|---|
| 1116 | { |
|---|
| 1117 | gluRowid=1; |
|---|
| 1118 | } |
|---|
| 1119 | } |
|---|
| 1120 | else if(!strcmp(gcFind,">>")) |
|---|
| 1121 | { |
|---|
| 1122 | gluRowid=guI; |
|---|
| 1123 | } |
|---|
| 1124 | else if(!strcmp(gcFind,"<<")) |
|---|
| 1125 | { |
|---|
| 1126 | gluRowid=1; |
|---|
| 1127 | } |
|---|
| 1128 | else if(1) |
|---|
| 1129 | { |
|---|
| 1130 | //If on last page stay there |
|---|
| 1131 | if( gluRowid >= guI ) |
|---|
| 1132 | { |
|---|
| 1133 | gluRowid=guI; |
|---|
| 1134 | } |
|---|
| 1135 | } |
|---|
| 1136 | |
|---|
| 1137 | }//guEnd iLmode |
|---|
| 1138 | |
|---|
| 1139 | }//PageMachine() |
|---|
| 1140 | |
|---|
| 1141 | |
|---|
| 1142 | void OpenFieldSet(char *cLabel, unsigned uWidth) |
|---|
| 1143 | { |
|---|
| 1144 | printf("<fieldset><legend><b>%s</b></legend><table width=%u%%>\n",cLabel,uWidth); |
|---|
| 1145 | |
|---|
| 1146 | }//void OpenFieldSet() |
|---|
| 1147 | |
|---|
| 1148 | |
|---|
| 1149 | void CloseFieldSet(void) |
|---|
| 1150 | { |
|---|
| 1151 | printf("</table></fieldset>\n"); |
|---|
| 1152 | |
|---|
| 1153 | }//void CloseFieldSet(void) |
|---|
| 1154 | |
|---|
| 1155 | |
|---|
| 1156 | void OpenRow(const char *cFieldLabel, const char *cColor) |
|---|
| 1157 | { |
|---|
| 1158 | //Skip underlined cFieldLabel for tGlossary.cLabel use. |
|---|
| 1159 | if(cFieldLabel[0]=='<') |
|---|
| 1160 | { |
|---|
| 1161 | register int j; |
|---|
| 1162 | char cGlossary[33]=""; |
|---|
| 1163 | |
|---|
| 1164 | for(j=3;cFieldLabel[j]&&j<32;j++) |
|---|
| 1165 | { |
|---|
| 1166 | if(!isalnum(cFieldLabel[j]) && cFieldLabel[j]!=' ') |
|---|
| 1167 | { |
|---|
| 1168 | cGlossary[j]=0; |
|---|
| 1169 | break; |
|---|
| 1170 | } |
|---|
| 1171 | else |
|---|
| 1172 | { |
|---|
| 1173 | cGlossary[j]=cFieldLabel[j]; |
|---|
| 1174 | } |
|---|
| 1175 | } |
|---|
| 1176 | printf("<tr><td width=20%% valign=top><a class=darkLink " |
|---|
| 1177 | "href=# onClick=\"open_popup('?gcFunction=Glossary&cLabel=%2$s')\">" |
|---|
| 1178 | "<font color=%1$s>%3$s</font></td><td>",cColor,cGlossary+3,cFieldLabel); |
|---|
| 1179 | } |
|---|
| 1180 | else |
|---|
| 1181 | { |
|---|
| 1182 | printf("<tr><td width=20%% valign=top><a class=darkLink " |
|---|
| 1183 | "href=# onClick=\"open_popup('?gcFunction=Glossary&cLabel=%2$s')\">" |
|---|
| 1184 | "<font color=%1$s>%2$s</font></td><td>",cColor,cFieldLabel); |
|---|
| 1185 | } |
|---|
| 1186 | |
|---|
| 1187 | }//void OpenRow() |
|---|
| 1188 | |
|---|
| 1189 | |
|---|
| 1190 | |
|---|
| 1191 | void tTablePullDownOwner(const char *cTableName, const char *cFieldName, |
|---|
| 1192 | const char *cOrderby, unsigned uSelector, unsigned uMode) |
|---|
| 1193 | { |
|---|
| 1194 | register int i,n; |
|---|
| 1195 | char cLabel[256]; |
|---|
| 1196 | MYSQL_RES *mysqlRes; |
|---|
| 1197 | MYSQL_ROW mysqlField; |
|---|
| 1198 | |
|---|
| 1199 | char cSelectName[100]={""}; |
|---|
| 1200 | char cHidden[100]={""}; |
|---|
| 1201 | char cLocalTableName[256]={""}; |
|---|
| 1202 | char *cp; |
|---|
| 1203 | char *cMode=""; |
|---|
| 1204 | |
|---|
| 1205 | if(!uMode) |
|---|
| 1206 | cMode="disabled"; |
|---|
| 1207 | |
|---|
| 1208 | if(!cTableName[0] || !cFieldName[0] || !cOrderby[0]) |
|---|
| 1209 | { |
|---|
| 1210 | printf("Invalid input tTablePullDown()"); |
|---|
| 1211 | return; |
|---|
| 1212 | } |
|---|
| 1213 | |
|---|
| 1214 | //Extended functionality |
|---|
| 1215 | strncpy(cLocalTableName,cTableName,255); |
|---|
| 1216 | if((cp=strchr(cLocalTableName,';'))) |
|---|
| 1217 | { |
|---|
| 1218 | strncpy(cSelectName,cp+1,99); |
|---|
| 1219 | cSelectName[99]=0; |
|---|
| 1220 | *cp=0; |
|---|
| 1221 | } |
|---|
| 1222 | |
|---|
| 1223 | |
|---|
| 1224 | if(guLoginClient==1) |
|---|
| 1225 | sprintf(gcQuery,"SELECT _rowid,%s FROM %s ORDER BY %s", |
|---|
| 1226 | cFieldName,cLocalTableName,cOrderby); |
|---|
| 1227 | else |
|---|
| 1228 | sprintf(gcQuery,"SELECT _rowid,%s FROM %s WHERE uOwner=%u OR uOwner IN" |
|---|
| 1229 | " (SELECT uClient FROM " TCLIENT " WHERE uOwner=%u) ORDER BY %s", |
|---|
| 1230 | cFieldName,cLocalTableName,guCompany,guCompany,cOrderby); |
|---|
| 1231 | |
|---|
| 1232 | MYSQL_RUN_STORE_TEXT_RET_VOID(mysqlRes); |
|---|
| 1233 | i=mysql_num_rows(mysqlRes); |
|---|
| 1234 | |
|---|
| 1235 | if(cSelectName[0]) |
|---|
| 1236 | sprintf(cLabel,"%s",cSelectName); |
|---|
| 1237 | else |
|---|
| 1238 | sprintf(cLabel,"%s_%sPullDown",cLocalTableName,cFieldName); |
|---|
| 1239 | |
|---|
| 1240 | if(i>0) |
|---|
| 1241 | { |
|---|
| 1242 | printf("<select name=%s %s>\n",cLabel,cMode); |
|---|
| 1243 | |
|---|
| 1244 | //Default no selection |
|---|
| 1245 | printf("<option title='No selection'>---</option>\n"); |
|---|
| 1246 | |
|---|
| 1247 | for(n=0;n<i;n++) |
|---|
| 1248 | { |
|---|
| 1249 | int unsigned field0=0; |
|---|
| 1250 | |
|---|
| 1251 | mysqlField=mysql_fetch_row(mysqlRes); |
|---|
| 1252 | sscanf(mysqlField[0],"%u",&field0); |
|---|
| 1253 | |
|---|
| 1254 | if(uSelector != field0) |
|---|
| 1255 | { |
|---|
| 1256 | printf("<option>%s</option>\n",mysqlField[1]); |
|---|
| 1257 | } |
|---|
| 1258 | else |
|---|
| 1259 | { |
|---|
| 1260 | printf("<option selected>%s</option>\n",mysqlField[1]); |
|---|
| 1261 | if(!uMode) |
|---|
| 1262 | sprintf(cHidden,"<input type=hidden name=%.99s value='%.99s'>\n", |
|---|
| 1263 | cLabel,mysqlField[1]); |
|---|
| 1264 | } |
|---|
| 1265 | } |
|---|
| 1266 | } |
|---|
| 1267 | else |
|---|
| 1268 | { |
|---|
| 1269 | printf("<select name=%s %s><option title='No selection'>---</option></select>\n" |
|---|
| 1270 | ,cLabel,cMode); |
|---|
| 1271 | if(!uMode) |
|---|
| 1272 | sprintf(cHidden,"<input type=hidden name=%99s value='0'>\n",cLabel); |
|---|
| 1273 | } |
|---|
| 1274 | printf("</select>\n"); |
|---|
| 1275 | if(cHidden[0]) |
|---|
| 1276 | printf("%s",cHidden); |
|---|
| 1277 | |
|---|
| 1278 | }//tTablePullDownOwner() |
|---|
| 1279 | |
|---|
| 1280 | |
|---|
| 1281 | void tTablePullDown(const char *cTableName, const char *cFieldName, |
|---|
| 1282 | const char *cOrderby, unsigned uSelector, unsigned uMode) |
|---|
| 1283 | { |
|---|
| 1284 | register int i,n; |
|---|
| 1285 | char cLabel[256]; |
|---|
| 1286 | MYSQL_RES *mysqlRes; |
|---|
| 1287 | MYSQL_ROW mysqlField; |
|---|
| 1288 | |
|---|
| 1289 | char cSelectName[100]={""}; |
|---|
| 1290 | char cHidden[100]={""}; |
|---|
| 1291 | char cLocalTableName[256]={""}; |
|---|
| 1292 | char *cp; |
|---|
| 1293 | char *cMode=""; |
|---|
| 1294 | |
|---|
| 1295 | if(!uMode) |
|---|
| 1296 | cMode="disabled"; |
|---|
| 1297 | |
|---|
| 1298 | if(!cTableName[0] || !cFieldName[0] || !cOrderby[0]) |
|---|
| 1299 | { |
|---|
| 1300 | printf("Invalid input tTablePullDown()"); |
|---|
| 1301 | return; |
|---|
| 1302 | } |
|---|
| 1303 | |
|---|
| 1304 | //Extended functionality |
|---|
| 1305 | strncpy(cLocalTableName,cTableName,255); |
|---|
| 1306 | if((cp=strchr(cLocalTableName,';'))) |
|---|
| 1307 | { |
|---|
| 1308 | strncpy(cSelectName,cp+1,99); |
|---|
| 1309 | cSelectName[99]=0; |
|---|
| 1310 | *cp=0; |
|---|
| 1311 | } |
|---|
| 1312 | |
|---|
| 1313 | |
|---|
| 1314 | sprintf(gcQuery,"SELECT _rowid,%s FROM %s ORDER BY %s", |
|---|
| 1315 | cFieldName,cLocalTableName,cOrderby); |
|---|
| 1316 | |
|---|
| 1317 | MYSQL_RUN_STORE_TEXT_RET_VOID(mysqlRes); |
|---|
| 1318 | |
|---|
| 1319 | i=mysql_num_rows(mysqlRes); |
|---|
| 1320 | |
|---|
| 1321 | if(cSelectName[0]) |
|---|
| 1322 | sprintf(cLabel,"%s",cSelectName); |
|---|
| 1323 | else |
|---|
| 1324 | sprintf(cLabel,"%s_%sPullDown",cLocalTableName,cFieldName); |
|---|
| 1325 | |
|---|
| 1326 | if(i>0) |
|---|
| 1327 | { |
|---|
| 1328 | printf("<select name=%s %s>\n",cLabel,cMode); |
|---|
| 1329 | |
|---|
| 1330 | //Default no selection |
|---|
| 1331 | printf("<option title='No selection'>---</option>\n"); |
|---|
| 1332 | |
|---|
| 1333 | for(n=0;n<i;n++) |
|---|
| 1334 | { |
|---|
| 1335 | int unsigned field0=0; |
|---|
| 1336 | |
|---|
| 1337 | mysqlField=mysql_fetch_row(mysqlRes); |
|---|
| 1338 | sscanf(mysqlField[0],"%u",&field0); |
|---|
| 1339 | |
|---|
| 1340 | if(uSelector != field0) |
|---|
| 1341 | { |
|---|
| 1342 | printf("<option>%s</option>\n",mysqlField[1]); |
|---|
| 1343 | } |
|---|
| 1344 | else |
|---|
| 1345 | { |
|---|
| 1346 | printf("<option selected>%s</option>\n",mysqlField[1]); |
|---|
| 1347 | if(!uMode) |
|---|
| 1348 | sprintf(cHidden,"<input type=hidden name=%.99s value='%.99s'>\n", |
|---|
| 1349 | cLabel,mysqlField[1]); |
|---|
| 1350 | } |
|---|
| 1351 | } |
|---|
| 1352 | } |
|---|
| 1353 | else |
|---|
| 1354 | { |
|---|
| 1355 | printf("<select name=%s %s><option title='No selection'>---</option></select>\n" |
|---|
| 1356 | ,cLabel,cMode); |
|---|
| 1357 | if(!uMode) |
|---|
| 1358 | sprintf(cHidden,"<input type=hidden name=%.99s value='0'>\n",cLabel); |
|---|
| 1359 | } |
|---|
| 1360 | printf("</select>\n"); |
|---|
| 1361 | if(cHidden[0]) |
|---|
| 1362 | printf("%s",cHidden); |
|---|
| 1363 | |
|---|
| 1364 | }//tTablePullDown() |
|---|
| 1365 | |
|---|
| 1366 | |
|---|
| 1367 | int ReadPullDown(const char *cTableName,const char *cFieldName,const char *cLabel) |
|---|
| 1368 | { |
|---|
| 1369 | MYSQL_RES *mysqlRes; |
|---|
| 1370 | MYSQL_ROW mysqlField; |
|---|
| 1371 | |
|---|
| 1372 | unsigned int iRowid=0;//Not found |
|---|
| 1373 | |
|---|
| 1374 | sprintf(gcQuery,"SELECT _rowid FROM %s WHERE %s='%s'", |
|---|
| 1375 | cTableName,cFieldName,TextAreaSave((char *) cLabel)); |
|---|
| 1376 | MYSQL_RUN_STORE(mysqlRes); |
|---|
| 1377 | if((mysqlField=mysql_fetch_row(mysqlRes))) |
|---|
| 1378 | sscanf(mysqlField[0],"%u",&iRowid); |
|---|
| 1379 | mysql_free_result(mysqlRes); |
|---|
| 1380 | return(iRowid); |
|---|
| 1381 | |
|---|
| 1382 | }//ReadPullDown(char *cTableName,char *cLabel) |
|---|
| 1383 | |
|---|
| 1384 | |
|---|
| 1385 | int ReadPullDownOwner(const char *cTableName,const char *cFieldName, |
|---|
| 1386 | const char *cLabel,const unsigned uOwner) |
|---|
| 1387 | { |
|---|
| 1388 | MYSQL_RES *mysqlRes; |
|---|
| 1389 | MYSQL_ROW mysqlField; |
|---|
| 1390 | |
|---|
| 1391 | unsigned int iRowid=0;//Not found |
|---|
| 1392 | |
|---|
| 1393 | sprintf(gcQuery,"SELECT _rowid FROM %s WHERE %s='%s' AND (uOwner=%u OR uOwner=%u)", |
|---|
| 1394 | cTableName,cFieldName,TextAreaSave((char *) cLabel),uOwner,guCompany); |
|---|
| 1395 | MYSQL_RUN_STORE(mysqlRes); |
|---|
| 1396 | if((mysqlField=mysql_fetch_row(mysqlRes))) |
|---|
| 1397 | sscanf(mysqlField[0],"%u",&iRowid); |
|---|
| 1398 | mysql_free_result(mysqlRes); |
|---|
| 1399 | return(iRowid); |
|---|
| 1400 | |
|---|
| 1401 | }//ReadPullDownOwner() |
|---|
| 1402 | |
|---|
| 1403 | |
|---|
| 1404 | char *TextAreaSave(char *cField) |
|---|
| 1405 | { |
|---|
| 1406 | register unsigned int i=0,j=0,uNum=0,uCtrlM=0; |
|---|
| 1407 | char *cCopy=NULL; |
|---|
| 1408 | |
|---|
| 1409 | for(i=0;cField[i];i++) |
|---|
| 1410 | { |
|---|
| 1411 | if(cField[i]=='\'' || cField[i]=='\\') uNum++; |
|---|
| 1412 | if(cField[i]=='\r') uCtrlM++; |
|---|
| 1413 | } |
|---|
| 1414 | if(!uNum && !uCtrlM) return(cField); |
|---|
| 1415 | |
|---|
| 1416 | if(uNum) |
|---|
| 1417 | cCopy=(char *)malloc( ( (strlen(cField)) + (uNum*2) + 1 )); |
|---|
| 1418 | else |
|---|
| 1419 | cCopy=(char *)cField; |
|---|
| 1420 | |
|---|
| 1421 | if(!cCopy) unxsVZ("TextAreaInput() malloc error"); |
|---|
| 1422 | |
|---|
| 1423 | i=0; |
|---|
| 1424 | while(cField[i]) |
|---|
| 1425 | { |
|---|
| 1426 | if( cField[i]=='\'' ) |
|---|
| 1427 | { |
|---|
| 1428 | cCopy[j++]='\\'; |
|---|
| 1429 | cCopy[j++]='\''; |
|---|
| 1430 | } |
|---|
| 1431 | else if( cField[i]=='\\') |
|---|
| 1432 | { |
|---|
| 1433 | cCopy[j++]='\\'; |
|---|
| 1434 | cCopy[j++]='\\'; |
|---|
| 1435 | } |
|---|
| 1436 | |
|---|
| 1437 | //Remove nasty ctrl-m's. fsck /u Bill! |
|---|
| 1438 | else if(cField[i]!='\r') |
|---|
| 1439 | { |
|---|
| 1440 | cCopy[j++]=cField[i]; |
|---|
| 1441 | } |
|---|
| 1442 | i++; |
|---|
| 1443 | } |
|---|
| 1444 | |
|---|
| 1445 | cCopy[j]=0; |
|---|
| 1446 | return(cCopy); |
|---|
| 1447 | |
|---|
| 1448 | }//char *TextAreaSave(char *cField) |
|---|
| 1449 | |
|---|
| 1450 | |
|---|
| 1451 | char *TransformAngleBrackets(char *cField) |
|---|
| 1452 | { |
|---|
| 1453 | register unsigned int i=0,j=0,uNum=0; |
|---|
| 1454 | char *cCopy=NULL; |
|---|
| 1455 | |
|---|
| 1456 | for(i=0;cField[i];i++) |
|---|
| 1457 | if(cField[i]=='<' || cField[i]=='>') uNum++; |
|---|
| 1458 | if(!uNum) return(cField); |
|---|
| 1459 | cCopy=(char *)malloc( ( (strlen(cField)) + (uNum*4) + 1 )); |
|---|
| 1460 | |
|---|
| 1461 | if(!cCopy) unxsVZ("TransformAngleBrackets() malloc error"); |
|---|
| 1462 | |
|---|
| 1463 | i=0; |
|---|
| 1464 | while(cField[i]) |
|---|
| 1465 | { |
|---|
| 1466 | //Expand angle brackets into HTML codes |
|---|
| 1467 | if( cField[i]=='<' ) |
|---|
| 1468 | { |
|---|
| 1469 | cCopy[j++]='&'; |
|---|
| 1470 | cCopy[j++]='l'; |
|---|
| 1471 | cCopy[j++]='t'; |
|---|
| 1472 | cCopy[j++]=';'; |
|---|
| 1473 | } |
|---|
| 1474 | else if( cField[i]=='>' ) |
|---|
| 1475 | { |
|---|
| 1476 | cCopy[j++]='&'; |
|---|
| 1477 | cCopy[j++]='g'; |
|---|
| 1478 | cCopy[j++]='t'; |
|---|
| 1479 | cCopy[j++]=';'; |
|---|
| 1480 | } |
|---|
| 1481 | else if(1) |
|---|
| 1482 | { |
|---|
| 1483 | cCopy[j++]=cField[i]; |
|---|
| 1484 | } |
|---|
| 1485 | i++; |
|---|
| 1486 | } |
|---|
| 1487 | |
|---|
| 1488 | cCopy[j]=0; |
|---|
| 1489 | return(cCopy); |
|---|
| 1490 | |
|---|
| 1491 | }//char *TransformAngleBrackets(char *cField) |
|---|
| 1492 | |
|---|
| 1493 | |
|---|
| 1494 | char *EncodeDoubleQuotes(char *cField) |
|---|
| 1495 | { |
|---|
| 1496 | register unsigned int i=0,j=0,uNum=0; |
|---|
| 1497 | char *cCopy=NULL; |
|---|
| 1498 | |
|---|
| 1499 | for(i=0;cField[i];i++) |
|---|
| 1500 | if(cField[i]=='"') uNum++; |
|---|
| 1501 | if(!uNum) return(cField); |
|---|
| 1502 | cCopy=(char *)malloc( ( (strlen(cField)) + (uNum*5) + 1 )); |
|---|
| 1503 | |
|---|
| 1504 | if(!cCopy) unxsVZ("EncodeDoubleQuotes() malloc error"); |
|---|
| 1505 | |
|---|
| 1506 | i=0; |
|---|
| 1507 | while(cField[i]) |
|---|
| 1508 | { |
|---|
| 1509 | //Expand double quote into HTML codes |
|---|
| 1510 | if( cField[i]=='"' ) |
|---|
| 1511 | { |
|---|
| 1512 | cCopy[j++]='&'; |
|---|
| 1513 | cCopy[j++]='q'; |
|---|
| 1514 | cCopy[j++]='u'; |
|---|
| 1515 | cCopy[j++]='o'; |
|---|
| 1516 | cCopy[j++]='t'; |
|---|
| 1517 | cCopy[j++]=';'; |
|---|
| 1518 | } |
|---|
| 1519 | else if(1) |
|---|
| 1520 | { |
|---|
| 1521 | cCopy[j++]=cField[i]; |
|---|
| 1522 | } |
|---|
| 1523 | i++; |
|---|
| 1524 | } |
|---|
| 1525 | |
|---|
| 1526 | cCopy[j]=0; |
|---|
| 1527 | return(cCopy); |
|---|
| 1528 | |
|---|
| 1529 | }//char *EncodeDoubleQuotes(char *cField) |
|---|
| 1530 | |
|---|
| 1531 | |
|---|
| 1532 | void YesNo(unsigned uSelect) |
|---|
| 1533 | { |
|---|
| 1534 | if(uSelect) |
|---|
| 1535 | printf("Yes"); |
|---|
| 1536 | else |
|---|
| 1537 | printf("No"); |
|---|
| 1538 | |
|---|
| 1539 | }//YesNo() |
|---|
| 1540 | |
|---|
| 1541 | |
|---|
| 1542 | void YesNoPullDown(char *cFieldName, unsigned uSelect, unsigned uMode) |
|---|
| 1543 | { |
|---|
| 1544 | char cHidden[100]={""}; |
|---|
| 1545 | char *cMode=""; |
|---|
| 1546 | |
|---|
| 1547 | if(!uMode) |
|---|
| 1548 | cMode="disabled"; |
|---|
| 1549 | |
|---|
| 1550 | printf("<select name=cYesNo%s %s>\n",cFieldName,cMode); |
|---|
| 1551 | |
|---|
| 1552 | if(uSelect==0) |
|---|
| 1553 | printf("<option selected>No</option>\n"); |
|---|
| 1554 | else |
|---|
| 1555 | printf("<option>No</option>\n"); |
|---|
| 1556 | |
|---|
| 1557 | if(uSelect==1) |
|---|
| 1558 | { |
|---|
| 1559 | printf("<option selected>Yes</option>\n"); |
|---|
| 1560 | if(!uMode) |
|---|
| 1561 | sprintf(cHidden,"<input type=hidden name=cYesNo%s value='Yes'>\n", |
|---|
| 1562 | cFieldName); |
|---|
| 1563 | } |
|---|
| 1564 | else |
|---|
| 1565 | { |
|---|
| 1566 | printf("<option>Yes</option>\n"); |
|---|
| 1567 | } |
|---|
| 1568 | |
|---|
| 1569 | printf("</select>\n"); |
|---|
| 1570 | if(cHidden[0]) |
|---|
| 1571 | printf("%s",cHidden); |
|---|
| 1572 | |
|---|
| 1573 | }//YesNoPullDown() |
|---|
| 1574 | |
|---|
| 1575 | |
|---|
| 1576 | int ReadYesNoPullDown(const char *cLabel) |
|---|
| 1577 | { |
|---|
| 1578 | if(!strcmp(cLabel,"Yes")) |
|---|
| 1579 | return(1); |
|---|
| 1580 | else |
|---|
| 1581 | return(0); |
|---|
| 1582 | |
|---|
| 1583 | }//ReadYesNoPullDown(char *cLabel) |
|---|
| 1584 | |
|---|
| 1585 | |
|---|
| 1586 | const char *ForeignKey(const char *cTableName, const char *cFieldName, unsigned uKey) |
|---|
| 1587 | { |
|---|
| 1588 | MYSQL_RES *mysqlRes; |
|---|
| 1589 | MYSQL_ROW mysqlField; |
|---|
| 1590 | |
|---|
| 1591 | static char scKey[16]; |
|---|
| 1592 | |
|---|
| 1593 | sprintf(gcQuery,"SELECT %s FROM %s WHERE _rowid=%u", |
|---|
| 1594 | cFieldName,cTableName,uKey); |
|---|
| 1595 | mysql_query(&gMysql,gcQuery); |
|---|
| 1596 | if(mysql_errno(&gMysql)) return(mysql_error(&gMysql)); |
|---|
| 1597 | |
|---|
| 1598 | mysqlRes=mysql_store_result(&gMysql); |
|---|
| 1599 | if(mysql_num_rows(mysqlRes)==1) |
|---|
| 1600 | { |
|---|
| 1601 | mysqlField=mysql_fetch_row(mysqlRes); |
|---|
| 1602 | return(mysqlField[0]); |
|---|
| 1603 | } |
|---|
| 1604 | |
|---|
| 1605 | if(!uKey) |
|---|
| 1606 | { |
|---|
| 1607 | return("---"); |
|---|
| 1608 | } |
|---|
| 1609 | else |
|---|
| 1610 | { |
|---|
| 1611 | sprintf(scKey,"%u",uKey); |
|---|
| 1612 | return(scKey); |
|---|
| 1613 | } |
|---|
| 1614 | |
|---|
| 1615 | }//const char *ForeignKey(const char *cTableName, const char *cFieldName, unsigned uKey) |
|---|
| 1616 | |
|---|
| 1617 | |
|---|
| 1618 | void InitialInstall(void) |
|---|
| 1619 | { |
|---|
| 1620 | unxsVZ("Please run\ |
|---|
| 1621 | unxsVZ.cgi Initialize <mysqlpwd> from the command line"); |
|---|
| 1622 | |
|---|
| 1623 | }//void InitialInstall(void) |
|---|
| 1624 | |
|---|
| 1625 | |
|---|
| 1626 | |
|---|
| 1627 | //tValidFunc functions: Form validation feedback |
|---|
| 1628 | |
|---|
| 1629 | const char *IsZero(unsigned uInput) |
|---|
| 1630 | { |
|---|
| 1631 | if(uInput) |
|---|
| 1632 | return("black"); |
|---|
| 1633 | else |
|---|
| 1634 | return("red"); |
|---|
| 1635 | |
|---|
| 1636 | }//const char *IsZero(unsigned uInput) |
|---|
| 1637 | |
|---|
| 1638 | |
|---|
| 1639 | const char *BadIPNum(const char *cInput) |
|---|
| 1640 | { |
|---|
| 1641 | if( cInput!=NULL && cInput[0] && strcmp(cInput,"0.0.0.0")) |
|---|
| 1642 | return("black"); |
|---|
| 1643 | else |
|---|
| 1644 | return("red"); |
|---|
| 1645 | |
|---|
| 1646 | }//const char *BadIPNum(const char *cInput) |
|---|
| 1647 | |
|---|
| 1648 | |
|---|
| 1649 | const char *EmptyString(const char *cInput) |
|---|
| 1650 | { |
|---|
| 1651 | if(cInput!=NULL && cInput[0]) |
|---|
| 1652 | return("black"); |
|---|
| 1653 | else |
|---|
| 1654 | return("red"); |
|---|
| 1655 | |
|---|
| 1656 | }//const char *EmptyString(const char *cInput) |
|---|
| 1657 | |
|---|
| 1658 | |
|---|
| 1659 | //tInputFunc functions: Convert data on cgi form post |
|---|
| 1660 | |
|---|
| 1661 | char *IPNumber(char *cInput) |
|---|
| 1662 | { |
|---|
| 1663 | unsigned a=0,b=0,c=0,d=0; |
|---|
| 1664 | |
|---|
| 1665 | sscanf(cInput,"%u.%u.%u.%u",&a,&b,&c,&d); |
|---|
| 1666 | |
|---|
| 1667 | if(a>255) a=0; |
|---|
| 1668 | if(b>255) b=0; |
|---|
| 1669 | if(c>255) c=0; |
|---|
| 1670 | if(d>255) d=0; |
|---|
| 1671 | |
|---|
| 1672 | sprintf(cInput,"%u.%u.%u.%u",a,b,c,d); |
|---|
| 1673 | |
|---|
| 1674 | return(cInput); |
|---|
| 1675 | |
|---|
| 1676 | }//char *IPNumber(char *cInput) |
|---|
| 1677 | |
|---|
| 1678 | |
|---|
| 1679 | char *IPv4CIDR(char *cInput) |
|---|
| 1680 | { |
|---|
| 1681 | unsigned a=0,b=0,c=0,d=0,e=0; |
|---|
| 1682 | |
|---|
| 1683 | sscanf(cInput,"%u.%u.%u.%u/%u",&a,&b,&c,&d,&e); |
|---|
| 1684 | |
|---|
| 1685 | if(a>255) a=0; |
|---|
| 1686 | if(b>255) b=0; |
|---|
| 1687 | if(c>255) c=0; |
|---|
| 1688 | if(d>255) d=0; |
|---|
| 1689 | if(e>32) e=32; |
|---|
| 1690 | if(e<20) e=20; |
|---|
| 1691 | |
|---|
| 1692 | //TODO ggw 8/2003 CIDR alignment math for a.b.c.d vs CIDR range 20-32 |
|---|
| 1693 | //16 class C's - one IP |
|---|
| 1694 | |
|---|
| 1695 | sprintf(cInput,"%u.%u.%u.%u/%u",a,b,c,d,e); |
|---|
| 1696 | |
|---|
| 1697 | return(cInput); |
|---|
| 1698 | |
|---|
| 1699 | }//char *IPv4CIDR(char *cInput) |
|---|
| 1700 | |
|---|
| 1701 | |
|---|
| 1702 | char *IPv4Range(char *cInput) |
|---|
| 1703 | { |
|---|
| 1704 | unsigned a=0,b=0,c=0,d=0,e=0; |
|---|
| 1705 | |
|---|
| 1706 | sscanf(cInput,"%u.%u.%u.%u-%u",&a,&b,&c,&d,&e); |
|---|
| 1707 | |
|---|
| 1708 | if(a>255) a=0; |
|---|
| 1709 | if(b>255) b=0; |
|---|
| 1710 | if(c>255) c=0; |
|---|
| 1711 | if(d>255) d=0; |
|---|
| 1712 | if(e>255) e=0; |
|---|
| 1713 | if(e<d) e=d; |
|---|
| 1714 | |
|---|
| 1715 | sprintf(cInput,"%u.%u.%u.%u-%u",a,b,c,d,e); |
|---|
| 1716 | |
|---|
| 1717 | return(cInput); |
|---|
| 1718 | |
|---|
| 1719 | }//char *IPv4Range(char *cInput) |
|---|
| 1720 | |
|---|
| 1721 | |
|---|
| 1722 | char *IPv4All(char *cInput) |
|---|
| 1723 | { |
|---|
| 1724 | if(strchr(cInput,'-')) |
|---|
| 1725 | IPv4Range(cInput); |
|---|
| 1726 | else if(strchr(cInput,'/')) |
|---|
| 1727 | IPv4CIDR(cInput); |
|---|
| 1728 | else if(1) |
|---|
| 1729 | IPNumber(cInput); |
|---|
| 1730 | |
|---|
| 1731 | return(cInput); |
|---|
| 1732 | |
|---|
| 1733 | }//char *IPv4All(char *cInput) |
|---|
| 1734 | |
|---|
| 1735 | |
|---|
| 1736 | char *EmailInput(char *cInput) |
|---|
| 1737 | { |
|---|
| 1738 | register int i; |
|---|
| 1739 | |
|---|
| 1740 | for(i=0;cInput[i];i++) |
|---|
| 1741 | { |
|---|
| 1742 | |
|---|
| 1743 | if(!isalnum(cInput[i]) && cInput[i]!='.' && cInput[i]!='-' |
|---|
| 1744 | && cInput[i]!='@' && cInput[i]!='_') |
|---|
| 1745 | break; |
|---|
| 1746 | if(isupper(cInput[i])) cInput[i]=tolower(cInput[i]); |
|---|
| 1747 | } |
|---|
| 1748 | cInput[i]=0; |
|---|
| 1749 | |
|---|
| 1750 | return(cInput); |
|---|
| 1751 | |
|---|
| 1752 | }//char *EmailInput(char *cInput) |
|---|
| 1753 | |
|---|
| 1754 | |
|---|
| 1755 | char *cMoneyInput(char *cInput) |
|---|
| 1756 | { |
|---|
| 1757 | register int i,j; |
|---|
| 1758 | char cOutput[32]; |
|---|
| 1759 | |
|---|
| 1760 | //Allow only certain chars nums $ , and . Ex. $250,000.00 |
|---|
| 1761 | for(i=0;cInput[i];i++) |
|---|
| 1762 | { |
|---|
| 1763 | if(!isdigit(cInput[i]) && cInput[i]!='.' && cInput[i]!=',' |
|---|
| 1764 | && cInput[i]!='$') |
|---|
| 1765 | break; |
|---|
| 1766 | } |
|---|
| 1767 | cInput[i]=0; |
|---|
| 1768 | |
|---|
| 1769 | //Strip non internal chars |
|---|
| 1770 | for(i=0,j=0;cInput[i];i++) |
|---|
| 1771 | { |
|---|
| 1772 | if(cInput[i]==',' || cInput[i]=='$') |
|---|
| 1773 | { |
|---|
| 1774 | ; |
|---|
| 1775 | } |
|---|
| 1776 | else |
|---|
| 1777 | { |
|---|
| 1778 | cOutput[j++]=cInput[i]; |
|---|
| 1779 | } |
|---|
| 1780 | } |
|---|
| 1781 | cOutput[j]=0; |
|---|
| 1782 | sprintf(cInput,"%.31s",cOutput); |
|---|
| 1783 | |
|---|
| 1784 | //Only allow one . |
|---|
| 1785 | unsigned uCountPeriods=0; |
|---|
| 1786 | for(i=strlen(cInput);i>0;i--) |
|---|
| 1787 | { |
|---|
| 1788 | if(cInput[i]=='.') |
|---|
| 1789 | { |
|---|
| 1790 | uCountPeriods++; |
|---|
| 1791 | if(uCountPeriods>1) |
|---|
| 1792 | cInput[i]=','; |
|---|
| 1793 | } |
|---|
| 1794 | } |
|---|
| 1795 | if(uCountPeriods>1) |
|---|
| 1796 | cMoneyInput(cInput); |
|---|
| 1797 | |
|---|
| 1798 | return(cInput); |
|---|
| 1799 | |
|---|
| 1800 | }//char *cMoneyInput(char *cInput) |
|---|
| 1801 | |
|---|
| 1802 | |
|---|
| 1803 | char *cMoneyDisplay(char *cInput) |
|---|
| 1804 | { |
|---|
| 1805 | double fBuffer; |
|---|
| 1806 | int i; |
|---|
| 1807 | // |
|---|
| 1808 | //We need to convert to double before calling strfmon |
|---|
| 1809 | fBuffer=atof(cInput); |
|---|
| 1810 | i=strlen(cInput); |
|---|
| 1811 | i+=3; |
|---|
| 1812 | //Of course you may change the locale if appropiate. |
|---|
| 1813 | setlocale(LC_MONETARY, "en_US"); |
|---|
| 1814 | strfmon(cInput,i, "%n",fBuffer); |
|---|
| 1815 | |
|---|
| 1816 | return(cInput); |
|---|
| 1817 | |
|---|
| 1818 | }//char *cMoneyDisplay(char *cInput) |
|---|
| 1819 | |
|---|
| 1820 | |
|---|
| 1821 | char *FQDomainName(char *cInput) |
|---|
| 1822 | { |
|---|
| 1823 | register int i; |
|---|
| 1824 | |
|---|
| 1825 | for(i=0;cInput[i];i++) |
|---|
| 1826 | { |
|---|
| 1827 | |
|---|
| 1828 | if(!isalnum(cInput[i]) && cInput[i]!='.' && cInput[i]!='-' ) |
|---|
| 1829 | break; |
|---|
| 1830 | if(isupper(cInput[i])) cInput[i]=tolower(cInput[i]); |
|---|
| 1831 | } |
|---|
| 1832 | cInput[i]=0; |
|---|
| 1833 | |
|---|
| 1834 | return(cInput); |
|---|
| 1835 | |
|---|
| 1836 | }//char *FQDomainName(char *cInput) |
|---|
| 1837 | |
|---|
| 1838 | |
|---|
| 1839 | char *WordToLower(char *cInput) |
|---|
| 1840 | { |
|---|
| 1841 | register int i; |
|---|
| 1842 | |
|---|
| 1843 | for(i=0;cInput[i];i++) |
|---|
| 1844 | { |
|---|
| 1845 | |
|---|
| 1846 | if(!isalnum(cInput[i]) && cInput[i]!='_' && cInput[i]!='-' |
|---|
| 1847 | && cInput[i]!='@' && cInput[i]!='.' ) break; |
|---|
| 1848 | if(isupper(cInput[i])) cInput[i]=tolower(cInput[i]); |
|---|
| 1849 | } |
|---|
| 1850 | cInput[i]=0; |
|---|
| 1851 | |
|---|
| 1852 | return(cInput); |
|---|
| 1853 | |
|---|
| 1854 | }//char *WordToLower(char *cInput) |
|---|
| 1855 | |
|---|
| 1856 | |
|---|
| 1857 | //SSLCookieLogin() Functions |
|---|
| 1858 | void SetLogin(void) |
|---|
| 1859 | { |
|---|
| 1860 | if( iValidLogin(0) ) |
|---|
| 1861 | { |
|---|
| 1862 | printf("Set-Cookie: unxsVZLogin=%s;\n",gcLogin); |
|---|
| 1863 | printf("Set-Cookie: unxsVZPasswd=%s;\n",gcPasswd); |
|---|
| 1864 | strncpy(gcUser,gcLogin,41); |
|---|
| 1865 | GetPLAndClient(gcUser); |
|---|
| 1866 | guSSLCookieLogin=1; |
|---|
| 1867 | unxsVZ("DashBoard"); |
|---|
| 1868 | } |
|---|
| 1869 | else |
|---|
| 1870 | { |
|---|
| 1871 | guSSLCookieLogin=0; |
|---|
| 1872 | SSLCookieLogin(); |
|---|
| 1873 | } |
|---|
| 1874 | |
|---|
| 1875 | }//void SetLogin(void) |
|---|
| 1876 | |
|---|
| 1877 | |
|---|
| 1878 | char *cGetPasswd(char *gcLogin); |
|---|
| 1879 | int iValidLogin(int mode) |
|---|
| 1880 | { |
|---|
| 1881 | char cSalt[16]={""}; |
|---|
| 1882 | char cPassword[100]={""}; |
|---|
| 1883 | |
|---|
| 1884 | //Notes: |
|---|
| 1885 | //Mode=1 means we have encrypted passwd from cookie |
|---|
| 1886 | |
|---|
| 1887 | strcpy(cPassword,cGetPasswd(gcLogin)); |
|---|
| 1888 | if(cPassword[0]) |
|---|
| 1889 | { |
|---|
| 1890 | if(!mode) |
|---|
| 1891 | { |
|---|
| 1892 | //MD5 vs DES salt determination |
|---|
| 1893 | if(cPassword[0]=='$' && cPassword[2]=='$') |
|---|
| 1894 | sprintf(cSalt,"%.12s",cPassword); |
|---|
| 1895 | else |
|---|
| 1896 | sprintf(cSalt,"%.2s",cPassword); |
|---|
| 1897 | EncryptPasswdWithSalt(gcPasswd,cSalt); |
|---|
| 1898 | if(!strcmp(gcPasswd,cPassword)) |
|---|
| 1899 | { |
|---|
| 1900 | guCompany=1;//If next line does not work |
|---|
| 1901 | GetPLAndClient(gcLogin); |
|---|
| 1902 | guPermLevel=0; |
|---|
| 1903 | guLoginClient=0; |
|---|
| 1904 | //tLogType.cLabel='backend login'->uLogType=6 |
|---|
| 1905 | //Alpha testing ON DUPLICATE KEY UPDATE to avoid some replication problems |
|---|
| 1906 | //that I have seen in logfiles. |
|---|
| 1907 | sprintf(gcQuery,"INSERT INTO tLog SET cLabel='login ok %.99s',uLogType=6,uPermLevel=%u," |
|---|
| 1908 | " uLoginClient=%u,cLogin='%.99s',cHost='%.99s',cServer='%.99s',uOwner=%u," |
|---|
| 1909 | " uCreatedBy=1,uCreatedDate=UNIX_TIMESTAMP(NOW()) ON DUPLICATE KEY UPDATE" |
|---|
| 1910 | " cLabel='login ok %.99s',uLogType=6,uPermLevel=%u," |
|---|
| 1911 | " uLoginClient=%u,cLogin='%.99s',cHost='%.99s',cServer='%.99s',uOwner=%u," |
|---|
| 1912 | " uCreatedBy=1,uCreatedDate=UNIX_TIMESTAMP(NOW())", |
|---|
| 1913 | gcLogin,guPermLevel,guLoginClient,gcLogin,gcHost,gcHostname,guCompany, |
|---|
| 1914 | gcLogin,guPermLevel,guLoginClient,gcLogin,gcHost,gcHostname,guCompany); |
|---|
| 1915 | MYSQL_RUN; |
|---|
| 1916 | return(1); |
|---|
| 1917 | } |
|---|
| 1918 | } |
|---|
| 1919 | else |
|---|
| 1920 | { |
|---|
| 1921 | if(!strcmp(gcPasswd,cPassword)) return(1); |
|---|
| 1922 | } |
|---|
| 1923 | } |
|---|
| 1924 | if(!mode) |
|---|
| 1925 | { |
|---|
| 1926 | guCompany=1;//If next line does not work |
|---|
| 1927 | GetPLAndClient(gcLogin); |
|---|
| 1928 | guPermLevel=0; |
|---|
| 1929 | guLoginClient=0; |
|---|
| 1930 | sprintf(gcQuery,"INSERT INTO tLog SET cLabel='login failed %.99s',uLogType=6,uPermLevel=%u," |
|---|
| 1931 | " uLoginClient=%u,cLogin='%.99s',cHost='%.99s',cServer='%.99s',uOwner=%u," |
|---|
| 1932 | " uCreatedBy=1,uCreatedDate=UNIX_TIMESTAMP(NOW()) ON DUPLICATE KEY UPDATE" |
|---|
| 1933 | " cLabel='login failed %.99s',uLogType=6,uPermLevel=%u," |
|---|
| 1934 | " uLoginClient=%u,cLogin='%.99s',cHost='%.99s',cServer='%.99s',uOwner=%u," |
|---|
| 1935 | " uCreatedBy=1,uCreatedDate=UNIX_TIMESTAMP(NOW())", |
|---|
| 1936 | gcLogin,guPermLevel,guLoginClient,gcLogin,gcHost,gcHostname,guCompany, |
|---|
| 1937 | gcLogin,guPermLevel,guLoginClient,gcLogin,gcHost,gcHostname,guCompany); |
|---|
| 1938 | MYSQL_RUN; |
|---|
| 1939 | } |
|---|
| 1940 | return 0; |
|---|
| 1941 | |
|---|
| 1942 | }//iValidLogin() |
|---|
| 1943 | |
|---|
| 1944 | |
|---|
| 1945 | char *cGetPasswd(char *gcLogin) |
|---|
| 1946 | { |
|---|
| 1947 | static char cPasswd[100]={""}; |
|---|
| 1948 | MYSQL_RES *mysqlRes; |
|---|
| 1949 | MYSQL_ROW mysqlField; |
|---|
| 1950 | char *cp; |
|---|
| 1951 | |
|---|
| 1952 | //SQL injection code |
|---|
| 1953 | if((cp=strchr(gcLogin,'\''))) *cp=0; |
|---|
| 1954 | |
|---|
| 1955 | sprintf(gcQuery,"SELECT cPasswd FROM " TAUTHORIZE " WHERE cLabel='%s'", |
|---|
| 1956 | gcLogin); |
|---|
| 1957 | mysql_query(&gMysql,gcQuery); |
|---|
| 1958 | if(mysql_errno(&gMysql)) |
|---|
| 1959 | htmlPlainTextError(mysql_error(&gMysql)); |
|---|
| 1960 | mysqlRes=mysql_store_result(&gMysql); |
|---|
| 1961 | cPasswd[0]=0; |
|---|
| 1962 | if((mysqlField=mysql_fetch_row(mysqlRes))) |
|---|
| 1963 | sprintf(cPasswd,"%.99s",mysqlField[0]); |
|---|
| 1964 | mysql_free_result(mysqlRes); |
|---|
| 1965 | |
|---|
| 1966 | |
|---|
| 1967 | return(cPasswd); |
|---|
| 1968 | |
|---|
| 1969 | }//char *cGetPasswd(char *gcLogin) |
|---|
| 1970 | |
|---|
| 1971 | |
|---|
| 1972 | void SSLCookieLogin(void) |
|---|
| 1973 | { |
|---|
| 1974 | char *ptr,*ptr2; |
|---|
| 1975 | |
|---|
| 1976 | //Parse out login and passwd from cookies |
|---|
| 1977 | #ifdef SSLONLY |
|---|
| 1978 | if(getenv("HTTPS")==NULL) |
|---|
| 1979 | unxsVZ("Non SSL access denied"); |
|---|
| 1980 | #endif |
|---|
| 1981 | |
|---|
| 1982 | if(getenv("HTTP_COOKIE")!=NULL) |
|---|
| 1983 | strncpy(gcCookie,getenv("HTTP_COOKIE"),1022); |
|---|
| 1984 | |
|---|
| 1985 | if(gcCookie[0]) |
|---|
| 1986 | { |
|---|
| 1987 | |
|---|
| 1988 | if((ptr=strstr(gcCookie,"unxsVZLogin="))) |
|---|
| 1989 | { |
|---|
| 1990 | ptr+=strlen("unxsVZLogin="); |
|---|
| 1991 | if((ptr2=strchr(ptr,';'))) |
|---|
| 1992 | { |
|---|
| 1993 | *ptr2=0; |
|---|
| 1994 | strncpy(gcLogin,ptr,99); |
|---|
| 1995 | *ptr2=';'; |
|---|
| 1996 | } |
|---|
| 1997 | else |
|---|
| 1998 | { |
|---|
| 1999 | strncpy(gcLogin,ptr,99); |
|---|
| 2000 | } |
|---|
| 2001 | } |
|---|
| 2002 | if((ptr=strstr(gcCookie,"unxsVZPasswd="))) |
|---|
| 2003 | { |
|---|
| 2004 | ptr+=strlen("unxsVZPasswd="); |
|---|
| 2005 | if((ptr2=strchr(ptr,';'))) |
|---|
| 2006 | { |
|---|
| 2007 | *ptr2=0; |
|---|
| 2008 | sprintf(gcPasswd,"%.99s",ptr); |
|---|
| 2009 | *ptr2=';'; |
|---|
| 2010 | } |
|---|
| 2011 | else |
|---|
| 2012 | { |
|---|
| 2013 | sprintf(gcPasswd,"%.99s",ptr); |
|---|
| 2014 | } |
|---|
| 2015 | } |
|---|
| 2016 | |
|---|
| 2017 | }//if gcCookie[0] time saver |
|---|
| 2018 | |
|---|
| 2019 | if(!iValidLogin(1)) |
|---|
| 2020 | htmlSSLLogin(); |
|---|
| 2021 | |
|---|
| 2022 | strncpy(gcUser,gcLogin,41); |
|---|
| 2023 | GetPLAndClient(gcUser); |
|---|
| 2024 | if(!guPermLevel || !guLoginClient) |
|---|
| 2025 | unxsVZ("Access denied"); |
|---|
| 2026 | gcPasswd[0]=0; |
|---|
| 2027 | guSSLCookieLogin=1; |
|---|
| 2028 | |
|---|
| 2029 | }//SSLCookieLogin() |
|---|
| 2030 | |
|---|
| 2031 | |
|---|
| 2032 | void htmlSSLLogin(void) |
|---|
| 2033 | { |
|---|
| 2034 | Header_ism3("",0); |
|---|
| 2035 | |
|---|
| 2036 | printf("<p>\n"); |
|---|
| 2037 | printf("Login: <input type=text size=20 maxlength=98 name=gcLogin>\n"); |
|---|
| 2038 | printf(" Passwd: <input type=password size=20 maxlength=20 name=gcPasswd>\n"); |
|---|
| 2039 | printf("<font size=1> <input type=submit name=gcFunction value=Login>\n"); |
|---|
| 2040 | |
|---|
| 2041 | Footer_ism3(); |
|---|
| 2042 | |
|---|
| 2043 | }//void htmlSSLLogin(void) |
|---|
| 2044 | |
|---|
| 2045 | |
|---|
| 2046 | void EncryptPasswdWithSalt(char *gcPasswd, char *cSalt) |
|---|
| 2047 | { |
|---|
| 2048 | char cPasswd[100]={""}; |
|---|
| 2049 | char *cp; |
|---|
| 2050 | |
|---|
| 2051 | sprintf(cPasswd,"%.99s",gcPasswd); |
|---|
| 2052 | cp=crypt(cPasswd,cSalt); |
|---|
| 2053 | sprintf(gcPasswd,"%.99s",cp); |
|---|
| 2054 | |
|---|
| 2055 | //Debug only |
|---|
| 2056 | //printf("Content-type: text/html\n\n"); |
|---|
| 2057 | //printf("gcPasswd=(%s),cSalt=(%s)",gcPasswd,cSalt); |
|---|
| 2058 | //exit(0); |
|---|
| 2059 | |
|---|
| 2060 | }//void EncryptPasswdWithSalt(char *gcPasswd, char *cSalt) |
|---|
| 2061 | |
|---|
| 2062 | |
|---|
| 2063 | void GetPLAndClient(char *cUser) |
|---|
| 2064 | { |
|---|
| 2065 | MYSQL_RES *mysqlRes; |
|---|
| 2066 | MYSQL_ROW mysqlField; |
|---|
| 2067 | |
|---|
| 2068 | //SQL FROM the defined external tables must provide db.tAuthorize and db.tClient for the other SQL |
|---|
| 2069 | // to work. |
|---|
| 2070 | sprintf(gcQuery,"SELECT tAuthorize.uPerm,tAuthorize.uCertClient,tAuthorize.uOwner," |
|---|
| 2071 | "tClient.cLabel" |
|---|
| 2072 | " FROM " TAUTHORIZE "," TCLIENT |
|---|
| 2073 | " WHERE tAuthorize.uOwner=tClient.uClient" |
|---|
| 2074 | " AND tAuthorize.cLabel='%s'",cUser); |
|---|
| 2075 | MYSQL_RUN_STORE(mysqlRes); |
|---|
| 2076 | if(mysql_num_rows(mysqlRes)) |
|---|
| 2077 | { |
|---|
| 2078 | mysqlField=mysql_fetch_row(mysqlRes); |
|---|
| 2079 | sscanf(mysqlField[0],"%d",&guPermLevel); |
|---|
| 2080 | sscanf(mysqlField[1],"%u",&guLoginClient); |
|---|
| 2081 | sscanf(mysqlField[2],"%u",&guCompany); |
|---|
| 2082 | sprintf(gcCompany,"%.99s",mysqlField[3]); |
|---|
| 2083 | } |
|---|
| 2084 | mysql_free_result(mysqlRes); |
|---|
| 2085 | |
|---|
| 2086 | }//void GetPLAndClient() |
|---|
| 2087 | |
|---|
| 2088 | |
|---|
| 2089 | void GetClientOwner(unsigned uClient, unsigned *uOwner) |
|---|
| 2090 | { |
|---|
| 2091 | MYSQL_RES *mysqlRes; |
|---|
| 2092 | MYSQL_ROW mysqlField; |
|---|
| 2093 | char cQuery[512]={""}; |
|---|
| 2094 | |
|---|
| 2095 | sprintf(cQuery,"SELECT uOwner FROM " TCLIENT " WHERE uClient=%u",uClient); |
|---|
| 2096 | mysql_query(&gMysql,cQuery); |
|---|
| 2097 | if(mysql_errno(&gMysql)) htmlPlainTextError(mysql_error(&gMysql)); |
|---|
| 2098 | mysqlRes=mysql_store_result(&gMysql); |
|---|
| 2099 | |
|---|
| 2100 | *uOwner=0; |
|---|
| 2101 | if((mysqlField=mysql_fetch_row(mysqlRes))) |
|---|
| 2102 | sscanf(mysqlField[0],"%u",uOwner); |
|---|
| 2103 | mysql_free_result(mysqlRes); |
|---|
| 2104 | |
|---|
| 2105 | }//void GetClientOwner(unsigned uClient, unsigned *uOwner) |
|---|
| 2106 | |
|---|
| 2107 | |
|---|
| 2108 | void unxsVZLog(unsigned uTablePK, char *cTableName, char *cLogEntry) |
|---|
| 2109 | { |
|---|
| 2110 | char cQuery[512]={""}; |
|---|
| 2111 | |
|---|
| 2112 | //uLogType==1 is this back-office cgi by default tLogType install |
|---|
| 2113 | sprintf(cQuery,"INSERT INTO tLog SET cLabel='%.63s',uLogType=1,uPermLevel=%u,uLoginClient=%u,cLogin='%.99s'," |
|---|
| 2114 | " cHost='%.99s',uTablePK=%u,cTableName='%.31s',cHash=MD5(CONCAT('%s','%u','%u','%s','%s'," |
|---|
| 2115 | " '%u','%s','%s',UNIX_TIMESTAMP(NOW()))),uOwner=%u,uCreatedBy=1,uCreatedDate=UNIX_TIMESTAMP(NOW())", |
|---|
| 2116 | cLogEntry, |
|---|
| 2117 | guPermLevel, |
|---|
| 2118 | guLoginClient, |
|---|
| 2119 | gcLogin, |
|---|
| 2120 | gcHost, |
|---|
| 2121 | uTablePK, |
|---|
| 2122 | cTableName, |
|---|
| 2123 | cLogEntry, |
|---|
| 2124 | guPermLevel, |
|---|
| 2125 | guLoginClient, |
|---|
| 2126 | gcLogin, |
|---|
| 2127 | gcHost, |
|---|
| 2128 | uTablePK, |
|---|
| 2129 | cTableName, |
|---|
| 2130 | cLogKey, |
|---|
| 2131 | guCompany); |
|---|
| 2132 | |
|---|
| 2133 | mysql_query(&gMysql,cQuery); |
|---|
| 2134 | if(mysql_errno(&gMysql)) htmlPlainTextError(mysql_error(&gMysql)); |
|---|
| 2135 | |
|---|
| 2136 | }//void unxsVZLog(unsigned uTablePK, char *cTableName, char *cLogEntry) |
|---|
| 2137 | |
|---|
| 2138 | |
|---|
| 2139 | long unsigned luGetCreatedDate(char *cTableName, unsigned uTablePK) |
|---|
| 2140 | { |
|---|
| 2141 | MYSQL_RES *mysqlRes; |
|---|
| 2142 | MYSQL_ROW mysqlField; |
|---|
| 2143 | long unsigned luCreatedDate=0; |
|---|
| 2144 | char cQuery[512]={""}; |
|---|
| 2145 | |
|---|
| 2146 | sprintf(cQuery,"SELECT uCreatedDate FROM %s WHERE _rowid=%u", |
|---|
| 2147 | cTableName,uTablePK); |
|---|
| 2148 | mysql_query(&gMysql,cQuery); |
|---|
| 2149 | if(mysql_errno(&gMysql)) |
|---|
| 2150 | htmlPlainTextError(mysql_error(&gMysql)); |
|---|
| 2151 | |
|---|
| 2152 | mysqlRes=mysql_store_result(&gMysql); |
|---|
| 2153 | |
|---|
| 2154 | if((mysqlField=mysql_fetch_row(mysqlRes))) |
|---|
| 2155 | sscanf(mysqlField[0],"%lu",&luCreatedDate); |
|---|
| 2156 | mysql_free_result(mysqlRes); |
|---|
| 2157 | |
|---|
| 2158 | return(luCreatedDate); |
|---|
| 2159 | |
|---|
| 2160 | }//long unsigned luGetCreatedDate(char *cTableName, unsigned uTablePK) |
|---|
| 2161 | |
|---|
| 2162 | |
|---|
| 2163 | long unsigned luGetModDate(char *cTableName, unsigned uTablePK) |
|---|
| 2164 | { |
|---|
| 2165 | MYSQL_RES *mysqlRes; |
|---|
| 2166 | MYSQL_ROW mysqlField; |
|---|
| 2167 | long unsigned luModDate=0; |
|---|
| 2168 | char cQuery[512]={""}; |
|---|
| 2169 | |
|---|
| 2170 | sprintf(cQuery,"SELECT uModDate FROM %s WHERE _rowid=%u", |
|---|
| 2171 | cTableName,uTablePK); |
|---|
| 2172 | mysql_query(&gMysql,cQuery); |
|---|
| 2173 | if(mysql_errno(&gMysql)) |
|---|
| 2174 | htmlPlainTextError(mysql_error(&gMysql)); |
|---|
| 2175 | |
|---|
| 2176 | mysqlRes=mysql_store_result(&gMysql); |
|---|
| 2177 | if((mysqlField=mysql_fetch_row(mysqlRes))) |
|---|
| 2178 | sscanf(mysqlField[0],"%lu",&luModDate); |
|---|
| 2179 | mysql_free_result(mysqlRes); |
|---|
| 2180 | |
|---|
| 2181 | return(luModDate); |
|---|
| 2182 | |
|---|
| 2183 | }//long unsigned luGetModDate(char *cTableName, unsigned uTablePK) |
|---|
| 2184 | |
|---|
| 2185 | |
|---|
| 2186 | void htmlPlainTextError(const char *cError) |
|---|
| 2187 | { |
|---|
| 2188 | printf("Content-type: text/plain\n\n"); |
|---|
| 2189 | printf("Please report this unxsVZ fatal error ASAP:\n%s\n",cError); |
|---|
| 2190 | |
|---|
| 2191 | //Attempt to report error in tLog |
|---|
| 2192 | sprintf(gcQuery,"INSERT INTO tLog SET cLabel='htmlPlainTextError',uLogType=4,uPermLevel=%u," |
|---|
| 2193 | " uLoginClient=%u,cLogin='%s',cHost='%s',cMessage=\"%s (%.24s)\",cServer='%s'," |
|---|
| 2194 | " cHash=MD5(CONCAT('%u','%u','%s','%s',\"%s (%.24s)\",'%s',UNIX_TIMESTAMP(NOW())," |
|---|
| 2195 | " '%s')),uOwner=%u,uCreatedBy=%u,uCreatedDate=UNIX_TIMESTAMP(NOW()),uTablePK=%u,cTableName='errno'", |
|---|
| 2196 | guPermLevel, |
|---|
| 2197 | guLoginClient, |
|---|
| 2198 | gcLogin, |
|---|
| 2199 | gcHost, |
|---|
| 2200 | cError, |
|---|
| 2201 | gcQuery, |
|---|
| 2202 | gcHostname, |
|---|
| 2203 | guPermLevel, |
|---|
| 2204 | guLoginClient, |
|---|
| 2205 | gcLogin, |
|---|
| 2206 | gcHost, |
|---|
| 2207 | cError, |
|---|
| 2208 | gcQuery, |
|---|
| 2209 | gcHostname, |
|---|
| 2210 | cLogKey, |
|---|
| 2211 | guCompany, |
|---|
| 2212 | guLoginClient, |
|---|
| 2213 | mysql_errno(&gMysql)); |
|---|
| 2214 | mysql_query(&gMysql,gcQuery); |
|---|
| 2215 | if(mysql_errno(&gMysql)) |
|---|
| 2216 | printf("Another error occurred while attempting to log: %s\n", |
|---|
| 2217 | mysql_error(&gMysql)); |
|---|
| 2218 | exit(0); |
|---|
| 2219 | |
|---|
| 2220 | }//void htmlPlainTextError(const char *cError) |
|---|
| 2221 | |
|---|
| 2222 | |
|---|
| 2223 | //This algo is based on GPL work in php-4.0.4p11 url.c and FSF face file urlencode.c |
|---|
| 2224 | //Then modified to suit our needs and readability and UK style guidelines |
|---|
| 2225 | char *cURLEncode(char *cURL) |
|---|
| 2226 | { |
|---|
| 2227 | register int x,y; |
|---|
| 2228 | unsigned char *cp; |
|---|
| 2229 | int len=strlen(cURL); |
|---|
| 2230 | |
|---|
| 2231 | static unsigned char hexchars[] = "0123456789ABCDEF"; |
|---|
| 2232 | |
|---|
| 2233 | cp=(unsigned char *)malloc(3*strlen(cURL)+1); |
|---|
| 2234 | for(x=0,y=0;len--;x++,y++) |
|---|
| 2235 | { |
|---|
| 2236 | cp[y]=(unsigned char)cURL[x]; |
|---|
| 2237 | if(cp[y]==' ') |
|---|
| 2238 | { |
|---|
| 2239 | cp[y]='+'; |
|---|
| 2240 | } |
|---|
| 2241 | else if( (cp[y]<'0' && cp[y]!='-' && cp[y]!='.') || |
|---|
| 2242 | (cp[y]<'A' && cp[y]>'9') || |
|---|
| 2243 | (cp[y]>'Z' && cp[y]<'a' && cp[y]!='_') || |
|---|
| 2244 | (cp[y]>'z') ) |
|---|
| 2245 | { |
|---|
| 2246 | cp[y++]='%'; |
|---|
| 2247 | cp[y++]=hexchars[(unsigned char) cURL[x] >> 4]; |
|---|
| 2248 | cp[y]=hexchars[(unsigned char) cURL[x] & 15]; |
|---|
| 2249 | } |
|---|
| 2250 | } |
|---|
| 2251 | |
|---|
| 2252 | cp[y]='\0'; |
|---|
| 2253 | return((char *)cp); |
|---|
| 2254 | |
|---|
| 2255 | }//char *cURLEncode(char *cURL) |
|---|
| 2256 | |
|---|
| 2257 | //Starting cleanup of current client contact role permissions model |
|---|
| 2258 | //Description |
|---|
| 2259 | //1-. Root user == 1. Initial install super user, sets up root tClient ASP company |
|---|
| 2260 | // and thus the uOwner of this tClient entry is root. There should be only one |
|---|
| 2261 | // such company but this is not mandatory. This company will have the only |
|---|
| 2262 | // contacts that may have access to everything. |
|---|
| 2263 | // Root user if owner of a record blocks delete operations done by others. |
|---|
| 2264 | //2-. If record uOwner is 0 something is broken and only Root can delete or modify. |
|---|
| 2265 | //3-. Any contact of a company with perm level >= admin can mod any record |
|---|
| 2266 | // owned by parent company. For delete with perm level >= root. |
|---|
| 2267 | //4-. Any company contact with perm level >= root can delete or mod any record |
|---|
| 2268 | // of companies owned by parent company. |
|---|
| 2269 | //5-. Any contact of perm level >=user that created a record and is owned by parent company can mod that record. |
|---|
| 2270 | // Similarly for delete if user is admin level |
|---|
| 2271 | // |
|---|
| 2272 | //7 user level |
|---|
| 2273 | //10 admin level |
|---|
| 2274 | //12 root level |
|---|
| 2275 | unsigned uAllowDel(const unsigned uOwner, const unsigned uCreatedBy) |
|---|
| 2276 | { |
|---|
| 2277 | //Set guReseller for tests to see if the owner of the owner is guCompany. |
|---|
| 2278 | if(uOwner) GetClientOwner(uOwner,&guReseller); |
|---|
| 2279 | |
|---|
| 2280 | if( (guPermLevel>10 && uOwner==guCompany) //r3 |
|---|
| 2281 | || (guPermLevel>9 && guCompany==guReseller) //r4 |
|---|
| 2282 | || (guPermLevel>9 && uCreatedBy==guLoginClient && |
|---|
| 2283 | (uOwner==guCompany || guCompany==guReseller)) //r5 |
|---|
| 2284 | || (guPermLevel>11 && guCompany==1) //r1 |
|---|
| 2285 | || (guPermLevel>11 && guLoginClient==1) )//r2 |
|---|
| 2286 | return(1); |
|---|
| 2287 | return(0); |
|---|
| 2288 | }//unsigned uAllowDel(...) |
|---|
| 2289 | |
|---|
| 2290 | |
|---|
| 2291 | unsigned uAllowMod(const unsigned uOwner, const unsigned uCreatedBy) |
|---|
| 2292 | { |
|---|
| 2293 | if(uOwner) GetClientOwner(uOwner,&guReseller); |
|---|
| 2294 | if( (guPermLevel>9 && uOwner==guCompany) //r3 |
|---|
| 2295 | || (guPermLevel>9 && guCompany==guReseller) //r4 |
|---|
| 2296 | || (guPermLevel>6 && uCreatedBy==guLoginClient && |
|---|
| 2297 | (uOwner==guCompany || guCompany==guReseller)) //r5 |
|---|
| 2298 | || (guPermLevel>11 && guCompany==1) //r1 |
|---|
| 2299 | || (guPermLevel>11 && guLoginClient==1) )//r2 |
|---|
| 2300 | return(1); |
|---|
| 2301 | return(0); |
|---|
| 2302 | }//unsigned uAllowMod(...) |
|---|
| 2303 | |
|---|
| 2304 | |
|---|
| 2305 | void ExtListSelect(const char *cTable,const char *cVarList) |
|---|
| 2306 | { |
|---|
| 2307 | if(guLoginClient==1 && guPermLevel>11)//Root can read access all |
|---|
| 2308 | sprintf(gcQuery,"SELECT %s FROM %s", |
|---|
| 2309 | cVarList,cTable); |
|---|
| 2310 | else |
|---|
| 2311 | sprintf(gcQuery,"SELECT %1$s FROM %3$s," TCLIENT |
|---|
| 2312 | " WHERE %3$s.uOwner=tClient.uClient" |
|---|
| 2313 | " AND (tClient.uClient=%2$u OR tClient.uOwner" |
|---|
| 2314 | " IN (SELECT uClient FROM " TCLIENT " WHERE uOwner=%2$u OR uClient=%2$u))", |
|---|
| 2315 | cVarList,guCompany,cTable); |
|---|
| 2316 | }//void ExtListSelect(...) |
|---|
| 2317 | |
|---|
| 2318 | |
|---|
| 2319 | void ExtListSelectPublic(const char *cTable,const char *cVarList) |
|---|
| 2320 | { |
|---|
| 2321 | sprintf(gcQuery,"SELECT %s FROM %s",cVarList,cTable); |
|---|
| 2322 | }//void ExtListSelectPublic(...) |
|---|
| 2323 | |
|---|
| 2324 | |
|---|
| 2325 | void ExtSelect(const char *cTable,const char *cVarList) |
|---|
| 2326 | { |
|---|
| 2327 | if(guLoginClient==1 && guPermLevel>11)//Root can read access all |
|---|
| 2328 | //sprintf(gcQuery,"SELECT %s FROM %s ORDER BY u%s", |
|---|
| 2329 | sprintf(gcQuery,"SELECT %s FROM %s", |
|---|
| 2330 | //cVarList,cTable,cTable+1); |
|---|
| 2331 | cVarList,cTable); |
|---|
| 2332 | else |
|---|
| 2333 | sprintf(gcQuery,"SELECT %1$s FROM %3$s," TCLIENT |
|---|
| 2334 | " WHERE %3$s.uOwner=tClient.uClient" |
|---|
| 2335 | " AND (tClient.uClient=%2$u OR tClient.uOwner" |
|---|
| 2336 | " IN (SELECT uClient FROM " TCLIENT " WHERE uOwner=%2$u OR uClient=%2$u))", |
|---|
| 2337 | //" ORDER BY u%4$s", |
|---|
| 2338 | cVarList,guCompany, |
|---|
| 2339 | cTable); |
|---|
| 2340 | //cTable,cTable+1); |
|---|
| 2341 | }//void ExtSelect(...) |
|---|
| 2342 | |
|---|
| 2343 | |
|---|
| 2344 | //For those tables you want anybody to be able to read. Like tStatus. |
|---|
| 2345 | void ExtSelectPublic(const char *cTable,const char *cVarList) |
|---|
| 2346 | { |
|---|
| 2347 | sprintf(gcQuery,"SELECT %.1024s FROM %.99s ORDER BY _rowid",cVarList,cTable); |
|---|
| 2348 | |
|---|
| 2349 | }//void ExtSelectPublic(...) |
|---|
| 2350 | |
|---|
| 2351 | |
|---|
| 2352 | void ExtSelectPublicOrder(const char *cTable,const char *cVarList,const char *cOrderBy) |
|---|
| 2353 | { |
|---|
| 2354 | sprintf(gcQuery,"SELECT %.1024s FROM %.99s ORDER BY %.99s",cVarList,cTable,cOrderBy); |
|---|
| 2355 | |
|---|
| 2356 | }//void ExtSelectPublicOrder(...) |
|---|
| 2357 | |
|---|
| 2358 | |
|---|
| 2359 | |
|---|
| 2360 | void ExtSelectSearchPublic(const char *cTable,const char *cVarList,const char *cSearchField,const char *cSearch) |
|---|
| 2361 | { |
|---|
| 2362 | sprintf(gcQuery,"SELECT %s FROM %s WHERE %s LIKE '%s%%' ORDER BY %s", |
|---|
| 2363 | cVarList,cTable,cSearchField,cSearch,cSearchField); |
|---|
| 2364 | }//void ExtSelectSearchPublic(...) |
|---|
| 2365 | |
|---|
| 2366 | |
|---|
| 2367 | void ExtSelectSearch(const char *cTable,const char *cVarList,const char *cSearchField,const char *cSearch) |
|---|
| 2368 | { |
|---|
| 2369 | if(guLoginClient==1 && guPermLevel>11)//Root can read access all |
|---|
| 2370 | sprintf(gcQuery,"SELECT %s FROM %s WHERE %s LIKE '%s%%' ORDER BY %s", |
|---|
| 2371 | cVarList,cTable,cSearchField,cSearch,cSearchField); |
|---|
| 2372 | else |
|---|
| 2373 | sprintf(gcQuery,"SELECT %1$s FROM %3$s," TCLIENT |
|---|
| 2374 | " WHERE %3$s.uOwner=tClient.uClient" |
|---|
| 2375 | " AND (tClient.uClient=%2$u OR tClient.uOwner" |
|---|
| 2376 | " IN (SELECT uClient FROM " TCLIENT " WHERE uOwner=%2$u OR uClient=%2$u))" |
|---|
| 2377 | "AND %3$s.%4$s LIKE '%5$s%%' ORDER BY %4$s", |
|---|
| 2378 | cVarList,guCompany,cTable,cSearchField,cSearch); |
|---|
| 2379 | }//void ExtSelectSearch(...) |
|---|
| 2380 | |
|---|
| 2381 | |
|---|
| 2382 | void ExtSelect2(const char *cTable,const char *cVarList,unsigned uMaxResults) |
|---|
| 2383 | { |
|---|
| 2384 | if(guPermLevel>11 && guLoginClient==1)//Root can read access all |
|---|
| 2385 | sprintf(gcQuery,"SELECT %1$s FROM %2$s ORDER BY %2$s._rowid", |
|---|
| 2386 | cVarList,cTable); |
|---|
| 2387 | else |
|---|
| 2388 | sprintf(gcQuery,"SELECT %1$s FROM %3$s," TCLIENT |
|---|
| 2389 | " WHERE %3$s.uOwner=" TCLIENT ".uClient" |
|---|
| 2390 | " AND (" TCLIENT ".uClient=%2$u OR " TCLIENT ".uOwner" |
|---|
| 2391 | " IN (SELECT uClient FROM " TCLIENT " WHERE uOwner=%2$u OR uClient=%2$u))" |
|---|
| 2392 | " ORDER BY %3$s._rowid", |
|---|
| 2393 | cVarList,guCompany, |
|---|
| 2394 | cTable); |
|---|
| 2395 | if(uMaxResults) |
|---|
| 2396 | { |
|---|
| 2397 | char cLimit[33]={""}; |
|---|
| 2398 | sprintf(cLimit," LIMIT %u",uMaxResults); |
|---|
| 2399 | strcat(gcQuery,cLimit); |
|---|
| 2400 | } |
|---|
| 2401 | |
|---|
| 2402 | }//void ExtSelect2(...) |
|---|
| 2403 | |
|---|
| 2404 | |
|---|
| 2405 | void ExtSelectRow(const char *cTable,const char *cVarList,unsigned uRow) |
|---|
| 2406 | { |
|---|
| 2407 | if(guLoginClient==1 && guPermLevel>11)//Root can read access all |
|---|
| 2408 | //sprintf(gcQuery,"SELECT %s FROM %s WHERE u%s=%u ORDER BY u%s", |
|---|
| 2409 | sprintf(gcQuery,"SELECT %s FROM %s WHERE u%s=%u", |
|---|
| 2410 | //cVarList,cTable,cTable+1,uRow,cTable+1); |
|---|
| 2411 | cVarList,cTable,cTable+1,uRow); |
|---|
| 2412 | else |
|---|
| 2413 | sprintf(gcQuery,"SELECT %1$s FROM %3$s," TCLIENT |
|---|
| 2414 | " WHERE %3$s.uOwner=tClient.uClient" |
|---|
| 2415 | " AND %3$s.u%4$s=%5$u" |
|---|
| 2416 | " AND (tClient.uClient=%2$u OR tClient.uOwner" |
|---|
| 2417 | " IN (SELECT uClient FROM " TCLIENT " WHERE uOwner=%2$u OR uClient=%2$u))", |
|---|
| 2418 | cVarList,guCompany, |
|---|
| 2419 | cTable,cTable+1,uRow); |
|---|
| 2420 | }//void ExtSelectRow(...) |
|---|
| 2421 | |
|---|
| 2422 | |
|---|
| 2423 | void ExtSelectRowPublic(const char *cTable,const char *cVarList,unsigned uRow) |
|---|
| 2424 | { |
|---|
| 2425 | sprintf(gcQuery,"SELECT %s FROM %s WHERE u%s=%u",cVarList,cTable,cTable+1,uRow); |
|---|
| 2426 | }//void ExtSelectRowPublic(...) |
|---|
| 2427 | |
|---|
| 2428 | |
|---|
| 2429 | //Passwd stuff |
|---|
| 2430 | static unsigned char itoa64[] = /* 0 ... 63 => ascii - 64 */ |
|---|
| 2431 | "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; |
|---|
| 2432 | |
|---|
| 2433 | void to64(s, v, n) |
|---|
| 2434 | register char *s; |
|---|
| 2435 | register long v; |
|---|
| 2436 | register int n; |
|---|
| 2437 | { |
|---|
| 2438 | while (--n >= 0) { |
|---|
| 2439 | *s++ = itoa64[v&0x3f]; |
|---|
| 2440 | v >>= 6; |
|---|
| 2441 | } |
|---|
| 2442 | }//void to64(s, v, n) |
|---|
| 2443 | |
|---|
| 2444 | |
|---|
| 2445 | void EncryptPasswd(char *pw) |
|---|
| 2446 | { |
|---|
| 2447 | //Notes: |
|---|
| 2448 | // We should change time based salt |
|---|
| 2449 | // (could be used for faster dictionary attack) |
|---|
| 2450 | // to /dev/random based system. |
|---|
| 2451 | |
|---|
| 2452 | char salt[3]; |
|---|
| 2453 | char passwd[102]={""}; |
|---|
| 2454 | char *cpw; |
|---|
| 2455 | char cMethod[16] ={""}; |
|---|
| 2456 | |
|---|
| 2457 | GetConfiguration("cCryptMethod",cMethod,0,0,0,0); |
|---|
| 2458 | if(!strcmp(cMethod,"MD5")) |
|---|
| 2459 | { |
|---|
| 2460 | char cSalt[] = "$1$01234567$"; |
|---|
| 2461 | (void)srand((int)time((time_t *)NULL)); |
|---|
| 2462 | to64(&cSalt[3],rand(),8); |
|---|
| 2463 | cpw = crypt(pw,cSalt); |
|---|
| 2464 | // error not verified, str NULL ("") returned |
|---|
| 2465 | } |
|---|
| 2466 | else |
|---|
| 2467 | { |
|---|
| 2468 | // default DES method |
|---|
| 2469 | sprintf(passwd,"%.99s",pw); |
|---|
| 2470 | (void)srand((int)time((time_t *)NULL)); |
|---|
| 2471 | to64(&salt[0],rand(),2); |
|---|
| 2472 | cpw=crypt(passwd,salt); |
|---|
| 2473 | } |
|---|
| 2474 | sprintf(pw,"%.99s",cpw); |
|---|
| 2475 | |
|---|
| 2476 | }//void EncryptPasswd(char *pw) |
|---|
| 2477 | |
|---|
| 2478 | |
|---|
| 2479 | void tContainerGroupPullDown(unsigned uGroup, unsigned uMode) |
|---|
| 2480 | { |
|---|
| 2481 | register int i,n; |
|---|
| 2482 | MYSQL_RES *mysqlRes; |
|---|
| 2483 | MYSQL_ROW mysqlField; |
|---|
| 2484 | |
|---|
| 2485 | char cHidden[100]={""}; |
|---|
| 2486 | char *cMode=""; |
|---|
| 2487 | |
|---|
| 2488 | if(!uMode) |
|---|
| 2489 | cMode="disabled"; |
|---|
| 2490 | |
|---|
| 2491 | sprintf(gcQuery,"SELECT uGroup,cLabel FROM tGroup WHERE uGroupType=1 ORDER BY cLabel"); |
|---|
| 2492 | MYSQL_RUN_STORE_TEXT_RET_VOID(mysqlRes); |
|---|
| 2493 | i=mysql_num_rows(mysqlRes); |
|---|
| 2494 | if(i>0) |
|---|
| 2495 | { |
|---|
| 2496 | printf("<select name=ctContainerGroupPullDown %s>\n",cMode); |
|---|
| 2497 | |
|---|
| 2498 | printf("<option title='No selection'>---</option>\n"); |
|---|
| 2499 | for(n=0;n<i;n++) |
|---|
| 2500 | { |
|---|
| 2501 | int unsigned field0=0; |
|---|
| 2502 | |
|---|
| 2503 | mysqlField=mysql_fetch_row(mysqlRes); |
|---|
| 2504 | sscanf(mysqlField[0],"%u",&field0); |
|---|
| 2505 | if(uGroup != field0) |
|---|
| 2506 | { |
|---|
| 2507 | printf("<option>%s</option>\n",mysqlField[1]); |
|---|
| 2508 | } |
|---|
| 2509 | else |
|---|
| 2510 | { |
|---|
| 2511 | printf("<option selected>%s</option>\n",mysqlField[1]); |
|---|
| 2512 | if(!uMode) |
|---|
| 2513 | sprintf(cHidden,"<input type=hidden name=ctContainerGroupPullDown value='%.99s'>\n", |
|---|
| 2514 | mysqlField[1]); |
|---|
| 2515 | } |
|---|
| 2516 | } |
|---|
| 2517 | } |
|---|
| 2518 | else |
|---|
| 2519 | { |
|---|
| 2520 | printf("<select name=ctContainerGroupPullDown %s><option title='No selection'>---</option></select>\n",cMode); |
|---|
| 2521 | if(!uMode) |
|---|
| 2522 | sprintf(cHidden,"<input type=hidden name=ctContainerGroupPullDown value='0'>\n"); |
|---|
| 2523 | } |
|---|
| 2524 | printf("</select>\n"); |
|---|
| 2525 | if(cHidden[0]) |
|---|
| 2526 | printf("%s",cHidden); |
|---|
| 2527 | |
|---|
| 2528 | }//tContainerGroupPullDown() |
|---|
| 2529 | |
|---|