| 1 | /* |
|---|
| 2 | FILE |
|---|
| 3 | $Id$ |
|---|
| 4 | PURPOSE |
|---|
| 5 | Non-schema dependent tclient.c expansion. |
|---|
| 6 | AUTHOR |
|---|
| 7 | GPL License applies, see www.fsf.org for details |
|---|
| 8 | See LICENSE file in this distribution |
|---|
| 9 | (C) 2001-2009 Gary Wallis and Hugo Urquiza. |
|---|
| 10 | */ |
|---|
| 11 | |
|---|
| 12 | #define BO_CUSTOMER "Back-Office Customer" |
|---|
| 13 | #define BO_RESELLER "Back-Office Reseller" |
|---|
| 14 | #define BO_ADMIN "Back-Office Admin" |
|---|
| 15 | #define BO_ROOT "Back-Office Root" |
|---|
| 16 | #define ORG_CUSTOMER "Organization Customer" |
|---|
| 17 | #define ORG_WEBMASTER "Organization Webmaster" |
|---|
| 18 | #define ORG_SALES "Organization Sales Force" |
|---|
| 19 | #define ORG_SERVICE "Organization Customer Service" |
|---|
| 20 | #define ORG_ACCT "Organization Bookkeeper" |
|---|
| 21 | #define ORG_ADMIN "Organization Admin" |
|---|
| 22 | |
|---|
| 23 | #define BO_ROOT_VAL 12 |
|---|
| 24 | #define BO_ADMIN_VAL 10 |
|---|
| 25 | #define BO_RESELLER_VAL 8 |
|---|
| 26 | #define BO_CUSTOMER_VAL 7 |
|---|
| 27 | #define ORG_CUSTOMER_VAL 1 |
|---|
| 28 | #define ORG_WEBMASTER_VAL 2 |
|---|
| 29 | #define ORG_SALES_VAL 3 |
|---|
| 30 | #define ORG_SERVICE_VAL 4 |
|---|
| 31 | #define ORG_ACCT_VAL 5 |
|---|
| 32 | #define ORG_ADMIN_VAL 6 |
|---|
| 33 | |
|---|
| 34 | static char cPasswd[36]={""}; |
|---|
| 35 | static char cLogin[33]={""}; |
|---|
| 36 | static char cExtLabel[16]={""}; |
|---|
| 37 | static char cuPerm[33]={ORG_ADMIN}; |
|---|
| 38 | static unsigned uPerm=0; |
|---|
| 39 | static unsigned uOnlyASPs=0; |
|---|
| 40 | static char cSearch[100]={""}; |
|---|
| 41 | |
|---|
| 42 | //Aux drop/pull downs |
|---|
| 43 | static char cForClientPullDown[256]={"---"}; |
|---|
| 44 | static unsigned uForClient=0; |
|---|
| 45 | |
|---|
| 46 | |
|---|
| 47 | unsigned IsAuthUser(char *cLabel, unsigned uOwner, unsigned uCertClient); |
|---|
| 48 | void PermLevelDropDown(char *cuPerm); |
|---|
| 49 | |
|---|
| 50 | void EncryptPasswdWithSalt(char *cPasswd,char *cSalt); |
|---|
| 51 | void EncryptPasswd(char *cPasswd);//main.c |
|---|
| 52 | void GetClientMaxParams(unsigned uClient,unsigned *uMaxSites,unsigned *uMaxIPs); |
|---|
| 53 | const char *cUserLevel(unsigned uPermLevel); |
|---|
| 54 | unsigned uMaxClientsReached(unsigned uClient); |
|---|
| 55 | void tTablePullDownResellers(unsigned uSelector,unsigned uBanner); |
|---|
| 56 | void ContactsNavList(void); |
|---|
| 57 | void htmlRecordContext(void); |
|---|
| 58 | |
|---|
| 59 | |
|---|
| 60 | void ExtProcesstClientVars(pentry entries[], int x) |
|---|
| 61 | { |
|---|
| 62 | |
|---|
| 63 | register int i; |
|---|
| 64 | |
|---|
| 65 | for(i=0;i<x;i++) |
|---|
| 66 | { |
|---|
| 67 | if(!strcmp(entries[i].name,"cPasswd")) |
|---|
| 68 | sprintf(cPasswd,"%.35s",entries[i].val); |
|---|
| 69 | else if(!strcmp(entries[i].name,"cLogin")) |
|---|
| 70 | sprintf(cLogin,"%.32s",entries[i].val); |
|---|
| 71 | else if(!strcmp(entries[i].name,"cExtLabel")) |
|---|
| 72 | sprintf(cExtLabel,"%.32s",entries[i].val); |
|---|
| 73 | else if(!strcmp(entries[i].name,"cuPerm")) |
|---|
| 74 | { |
|---|
| 75 | sprintf(cuPerm,"%.32s",entries[i].val); |
|---|
| 76 | sprintf(cuPerm,"%.32s",entries[i].val); |
|---|
| 77 | if(!strcmp(cuPerm,ORG_ADMIN)) |
|---|
| 78 | uPerm=ORG_ADMIN_VAL; |
|---|
| 79 | else if(!strcmp(cuPerm,BO_ADMIN)) |
|---|
| 80 | uPerm=BO_ADMIN_VAL; |
|---|
| 81 | else if(!strcmp(cuPerm,BO_ROOT)) |
|---|
| 82 | uPerm=BO_ROOT_VAL; |
|---|
| 83 | else if(!strcmp(cuPerm,BO_CUSTOMER)) |
|---|
| 84 | uPerm=BO_CUSTOMER_VAL; |
|---|
| 85 | else if(!strcmp(cuPerm,BO_RESELLER)) |
|---|
| 86 | uPerm=BO_RESELLER_VAL; |
|---|
| 87 | } |
|---|
| 88 | else if(!strcmp(entries[i].name,"cForClientPullDown")) |
|---|
| 89 | { |
|---|
| 90 | strcpy(cForClientPullDown,entries[i].val); |
|---|
| 91 | uForClient=ReadPullDown(TCLIENT,"cLabel", |
|---|
| 92 | cForClientPullDown); |
|---|
| 93 | } |
|---|
| 94 | else if(!strcmp(entries[i].name,"cSearch")) |
|---|
| 95 | sprintf(cSearch,"%.99s",TextAreaSave(entries[i].val)); |
|---|
| 96 | else if(!strcmp(entries[i].name,"uOnlyASPs")) |
|---|
| 97 | uOnlyASPs=1; |
|---|
| 98 | } |
|---|
| 99 | |
|---|
| 100 | }//void ExtProcesstClientVars(pentry entries[], int x) |
|---|
| 101 | |
|---|
| 102 | |
|---|
| 103 | void ExttClientCommands(pentry entries[], int x) |
|---|
| 104 | { |
|---|
| 105 | MYSQL_RES *res; |
|---|
| 106 | |
|---|
| 107 | if(!strcmp(gcFunction,"tClientTools")) |
|---|
| 108 | { |
|---|
| 109 | if(!strcmp(gcCommand,LANG_NB_NEW)) |
|---|
| 110 | { |
|---|
| 111 | if(guPermLevel>=10) |
|---|
| 112 | { |
|---|
| 113 | ProcesstClientVars(entries,x); |
|---|
| 114 | if(guLoginClient!=1 && uMaxClientsReached(guCompany)) |
|---|
| 115 | { |
|---|
| 116 | guMode=0; |
|---|
| 117 | tClient("Your reseller maximum of customers has been reached"); |
|---|
| 118 | } |
|---|
| 119 | guMode=2000; |
|---|
| 120 | //These just for GUI cleanup |
|---|
| 121 | cCode[0]=0; |
|---|
| 122 | uModDate=0; |
|---|
| 123 | uModBy=0; |
|---|
| 124 | tClient(LANG_NB_CONFIRMNEW); |
|---|
| 125 | } |
|---|
| 126 | else |
|---|
| 127 | tClient("<blink>Error</blink>: Denied by permissions settings"); |
|---|
| 128 | } |
|---|
| 129 | else if(!strcmp(gcCommand,LANG_NB_CONFIRMNEW)) |
|---|
| 130 | { |
|---|
| 131 | if(guPermLevel>=10) |
|---|
| 132 | { |
|---|
| 133 | ProcesstClientVars(entries,x); |
|---|
| 134 | |
|---|
| 135 | //Validate |
|---|
| 136 | guMode=2000; |
|---|
| 137 | if(guLoginClient!=1 && uMaxClientsReached(guCompany)) |
|---|
| 138 | { |
|---|
| 139 | guMode=0; |
|---|
| 140 | tClient("Your maximum of customers has been reached"); |
|---|
| 141 | } |
|---|
| 142 | if(strlen(cLabel)<3) |
|---|
| 143 | tClient("<blink>Error</blink>: Invalid cLabel!"); |
|---|
| 144 | guMode=0; |
|---|
| 145 | |
|---|
| 146 | if(!uForClient) |
|---|
| 147 | { |
|---|
| 148 | uOwner=guCompany; |
|---|
| 149 | sprintf(cCode,"Organization"); |
|---|
| 150 | } |
|---|
| 151 | else |
|---|
| 152 | { |
|---|
| 153 | uOwner=uForClient; |
|---|
| 154 | sprintf(cCode,"Contact"); |
|---|
| 155 | } |
|---|
| 156 | uClient=0;//Update .c this is dumb |
|---|
| 157 | uCreatedBy=guLoginClient; |
|---|
| 158 | //These just for GUI cleanup |
|---|
| 159 | uModDate=0; |
|---|
| 160 | uModBy=0; |
|---|
| 161 | NewtClient(0); |
|---|
| 162 | } |
|---|
| 163 | else |
|---|
| 164 | tClient("<blink>Error</blink>: Denied by permissions settings"); |
|---|
| 165 | } |
|---|
| 166 | else if(!strcmp(gcCommand,LANG_NB_DELETE)) |
|---|
| 167 | { |
|---|
| 168 | ProcesstClientVars(entries,x); |
|---|
| 169 | if(uAllowDel(uOwner,uCreatedBy)) |
|---|
| 170 | { |
|---|
| 171 | guMode=2001; |
|---|
| 172 | tClient(LANG_NB_CONFIRMDEL); |
|---|
| 173 | } |
|---|
| 174 | else |
|---|
| 175 | tClient("<blink>Error</blink>: Denied by permissions settings"); |
|---|
| 176 | } |
|---|
| 177 | else if(!strcmp(gcCommand,LANG_NB_CONFIRMDEL)) |
|---|
| 178 | { |
|---|
| 179 | ProcesstClientVars(entries,x); |
|---|
| 180 | if(uAllowDel(uOwner,uCreatedBy)) |
|---|
| 181 | { |
|---|
| 182 | guMode=2001; |
|---|
| 183 | //This must be customized |
|---|
| 184 | sprintf(gcQuery,"SELECT uDatacenter FROM tDatacenter WHERE uOwner=%u OR uCreatedBy=%u", |
|---|
| 185 | uClient,uClient); |
|---|
| 186 | mysql_query(&gMysql,gcQuery); |
|---|
| 187 | if(mysql_errno(&gMysql)) |
|---|
| 188 | tClient(mysql_error(&gMysql)); |
|---|
| 189 | res=mysql_store_result(&gMysql); |
|---|
| 190 | if(mysql_num_rows(res)) |
|---|
| 191 | tClient("Can't delete client with datacenters"); |
|---|
| 192 | mysql_free_result(res); |
|---|
| 193 | sprintf(gcQuery,"SELECT uNode FROM tNode WHERE uOwner=%u OR uCreatedBy=%u", |
|---|
| 194 | uClient,uClient); |
|---|
| 195 | mysql_query(&gMysql,gcQuery); |
|---|
| 196 | if(mysql_errno(&gMysql)) |
|---|
| 197 | tClient(mysql_error(&gMysql)); |
|---|
| 198 | res=mysql_store_result(&gMysql); |
|---|
| 199 | if(mysql_num_rows(res)) |
|---|
| 200 | tClient("Can't delete client with nodes"); |
|---|
| 201 | mysql_free_result(res); |
|---|
| 202 | sprintf(gcQuery,"SELECT uContainer FROM tContainer WHERE uOwner=%u OR uCreatedBy=%u", |
|---|
| 203 | uClient,uClient); |
|---|
| 204 | mysql_query(&gMysql,gcQuery); |
|---|
| 205 | if(mysql_errno(&gMysql)) |
|---|
| 206 | tClient(mysql_error(&gMysql)); |
|---|
| 207 | res=mysql_store_result(&gMysql); |
|---|
| 208 | if(mysql_num_rows(res)) |
|---|
| 209 | tClient("Can't delete client with containers"); |
|---|
| 210 | mysql_free_result(res); |
|---|
| 211 | sprintf(gcQuery,"SELECT uLog FROM tLog WHERE uOwner=%u OR uCreatedBy=%u", |
|---|
| 212 | uClient,uClient); |
|---|
| 213 | mysql_query(&gMysql,gcQuery); |
|---|
| 214 | if(mysql_errno(&gMysql)) |
|---|
| 215 | tClient(mysql_error(&gMysql)); |
|---|
| 216 | res=mysql_store_result(&gMysql); |
|---|
| 217 | if(mysql_num_rows(res)) |
|---|
| 218 | tClient("Can't delete client with log entries"); |
|---|
| 219 | mysql_free_result(res); |
|---|
| 220 | |
|---|
| 221 | if(!strcmp(cCode,"Contact")) |
|---|
| 222 | { |
|---|
| 223 | sprintf(gcQuery,"DELETE FROM " TAUTHORIZE |
|---|
| 224 | " WHERE (cLabel='%s' OR uCertClient=%u)", |
|---|
| 225 | cLabel,uClient); |
|---|
| 226 | mysql_query(&gMysql,gcQuery); |
|---|
| 227 | if(mysql_errno(&gMysql)) |
|---|
| 228 | tClient(mysql_error(&gMysql)); |
|---|
| 229 | } |
|---|
| 230 | else if(!strcmp(cCode,"Organization")) |
|---|
| 231 | { |
|---|
| 232 | sprintf(gcQuery,"DELETE FROM " TCLIENT |
|---|
| 233 | " WHERE uOwner=%u",uClient); |
|---|
| 234 | mysql_query(&gMysql,gcQuery); |
|---|
| 235 | if(mysql_errno(&gMysql)) |
|---|
| 236 | tClient(mysql_error(&gMysql)); |
|---|
| 237 | sprintf(gcQuery,"DELETE FROM " TAUTHORIZE |
|---|
| 238 | " WHERE uOwner=%u",uClient); |
|---|
| 239 | mysql_query(&gMysql,gcQuery); |
|---|
| 240 | if(mysql_errno(&gMysql)) |
|---|
| 241 | tClient(mysql_error(&gMysql)); |
|---|
| 242 | } |
|---|
| 243 | |
|---|
| 244 | guMode=5; |
|---|
| 245 | DeletetClient(); |
|---|
| 246 | } |
|---|
| 247 | else |
|---|
| 248 | tClient("<blink>Error</blink>: Denied by permissions settings"); |
|---|
| 249 | } |
|---|
| 250 | else if(!strcmp(gcCommand,LANG_NB_MODIFY)) |
|---|
| 251 | { |
|---|
| 252 | ProcesstClientVars(entries,x); |
|---|
| 253 | if(uAllowMod(uOwner,uCreatedBy)) |
|---|
| 254 | { |
|---|
| 255 | guMode=2002; |
|---|
| 256 | tClient(LANG_NB_CONFIRMMOD); |
|---|
| 257 | } |
|---|
| 258 | else |
|---|
| 259 | tClient("<blink>Error</blink>: Denied by permissions settings"); |
|---|
| 260 | } |
|---|
| 261 | else if(!strcmp(gcCommand,LANG_NB_CONFIRMMOD)) |
|---|
| 262 | { |
|---|
| 263 | ProcesstClientVars(entries,x); |
|---|
| 264 | if(uAllowMod(uOwner,uCreatedBy)) |
|---|
| 265 | { |
|---|
| 266 | //Validate |
|---|
| 267 | guMode=2002; |
|---|
| 268 | if(strlen(cLabel)<3) |
|---|
| 269 | tClient("<blink>Error</blink>: Invalid cLabel!"); |
|---|
| 270 | guMode=0; |
|---|
| 271 | |
|---|
| 272 | uModBy=guLoginClient; |
|---|
| 273 | if(uForClient && uClient>1) |
|---|
| 274 | { |
|---|
| 275 | sprintf(gcQuery,"UPDATE " TCLIENT " SET uOwner=%u WHERE uClient=%u", |
|---|
| 276 | uForClient,uClient); |
|---|
| 277 | mysql_query(&gMysql,gcQuery); |
|---|
| 278 | if(mysql_errno(&gMysql)) |
|---|
| 279 | htmlPlainTextError(mysql_error(&gMysql)); |
|---|
| 280 | uOwner=uForClient; |
|---|
| 281 | } |
|---|
| 282 | ModtClient(); |
|---|
| 283 | } |
|---|
| 284 | else |
|---|
| 285 | tClient("<blink>Error</blink>: Denied by permissions settings"); |
|---|
| 286 | } |
|---|
| 287 | |
|---|
| 288 | else if(!strcmp(gcCommand,"Authorize")) |
|---|
| 289 | { |
|---|
| 290 | ProcesstClientVars(entries,x); |
|---|
| 291 | if(uAllowMod(uOwner,uCreatedBy)) |
|---|
| 292 | { |
|---|
| 293 | guMode=3000; |
|---|
| 294 | tClient("Enter login, passwd, user level and confirm." |
|---|
| 295 | " To authorize a new user to use an interface or this back-office."); |
|---|
| 296 | } |
|---|
| 297 | else |
|---|
| 298 | tClient("<blink>Error</blink>: Denied by permissions settings"); |
|---|
| 299 | } |
|---|
| 300 | else if(!strcmp(gcCommand,"Confirm Authorize")) |
|---|
| 301 | { |
|---|
| 302 | ProcesstClientVars(entries,x); |
|---|
| 303 | if(uAllowMod(uOwner,uCreatedBy)) |
|---|
| 304 | { |
|---|
| 305 | time_t clock; |
|---|
| 306 | char cClrPasswd[33]={""}; |
|---|
| 307 | |
|---|
| 308 | time(&clock); |
|---|
| 309 | |
|---|
| 310 | if(strlen(cLogin)<6) |
|---|
| 311 | { |
|---|
| 312 | guMode=3000; |
|---|
| 313 | tClient("Login must be at least 6 chars!"); |
|---|
| 314 | } |
|---|
| 315 | |
|---|
| 316 | if(strlen(cPasswd)<4) |
|---|
| 317 | { |
|---|
| 318 | guMode=3000; |
|---|
| 319 | tClient("Passwd must be at least 4 chars!"); |
|---|
| 320 | } |
|---|
| 321 | |
|---|
| 322 | if(uPerm<1 || uPerm>12) |
|---|
| 323 | { |
|---|
| 324 | guMode=3000; |
|---|
| 325 | sprintf(gcQuery,"uPerm level error:%u",uPerm); |
|---|
| 326 | tClient(gcQuery); |
|---|
| 327 | } |
|---|
| 328 | |
|---|
| 329 | //sprintf(cClrPasswd,"%.32s",cPasswd); |
|---|
| 330 | EncryptPasswd(cPasswd); |
|---|
| 331 | if(uPerm==12) uClient=1;//uCertClient root alias temp hack |
|---|
| 332 | sprintf(gcQuery,"INSERT INTO " TAUTHORIZE " SET cLabel='%s',uPerm=%u," |
|---|
| 333 | "uCertClient=%u,cPasswd='%s',uOwner=%u,uCreatedBy=%u," |
|---|
| 334 | "uCreatedDate=UNIX_TIMESTAMP(NOW()),cIPMask='0.0.0.0',cClrPasswd='%s'", |
|---|
| 335 | cLogin,uPerm,uClient,cPasswd,uOwner,guLoginClient,cClrPasswd); |
|---|
| 336 | |
|---|
| 337 | mysql_query(&gMysql,gcQuery); |
|---|
| 338 | if(mysql_errno(&gMysql)) |
|---|
| 339 | { |
|---|
| 340 | printf("Content-type: text/plain\n\n"); |
|---|
| 341 | printf("mysql_error: %s\n",mysql_error(&gMysql)); |
|---|
| 342 | exit(0); |
|---|
| 343 | } |
|---|
| 344 | tClient("Contact Authorized"); |
|---|
| 345 | } |
|---|
| 346 | else |
|---|
| 347 | tClient("<blink>Error</blink>: Denied by permissions settings"); |
|---|
| 348 | |
|---|
| 349 | }//Confirm auth |
|---|
| 350 | |
|---|
| 351 | } |
|---|
| 352 | |
|---|
| 353 | }//void ExttClientCommands(pentry entries[], int x) |
|---|
| 354 | |
|---|
| 355 | |
|---|
| 356 | void ExttClientButtons(void) |
|---|
| 357 | { |
|---|
| 358 | unsigned uDefault=0; |
|---|
| 359 | |
|---|
| 360 | OpenFieldSet("tClient Aux Panel",100); |
|---|
| 361 | |
|---|
| 362 | switch(guMode) |
|---|
| 363 | { |
|---|
| 364 | case 2000: |
|---|
| 365 | printf("<u>New: Step 1 Tips</u><br>"); |
|---|
| 366 | printf("Here you would usually enter a new company name into cLabel. Optionally some standardized company info in cInfo, like addresses phone numbers and such. A main company email is usually helpful, cCode is used internally. <br>If you are creating a contact for an existing company select that company from the drop down select below and use cLabel for the contact name (Ex. Anne Flechter) and the cInfo would be the contacts personal phone numbers and or address etc."); |
|---|
| 367 | if(guPermLevel>7) |
|---|
| 368 | { |
|---|
| 369 | if(uOwner==1) |
|---|
| 370 | tTablePullDownResellers(uClient,1); |
|---|
| 371 | else |
|---|
| 372 | tTablePullDownResellers(uOwner,1); |
|---|
| 373 | } |
|---|
| 374 | printf(LANG_NBB_CONFIRMNEW); |
|---|
| 375 | printf("<br>\n"); |
|---|
| 376 | break; |
|---|
| 377 | |
|---|
| 378 | case 2001: |
|---|
| 379 | printf(LANG_NBB_CONFIRMDEL); |
|---|
| 380 | printf("<br>Note: Will also delete tAuthorize entries related to this uClient. Probably not a good idea to delete Root owned tClient records this way, even if you have the permissions to do so.\n"); |
|---|
| 381 | break; |
|---|
| 382 | |
|---|
| 383 | case 2002: |
|---|
| 384 | printf("<u>Modify: Step 1 Tips</u><br>"); |
|---|
| 385 | printf("Here you can modify the contact or company name. In the later case still keeping all associated contacts. You can update the cInfo text area. Add an email or company or contact code.<br>A much more advanced operation and one that must be done with care is the use of the 'Change or Create' drop down select: It is meant primarily to associate or change the association of contacts or other orphan tClient records with a given company. In any case the 'Change or Create' feature must be used with caution since it may affect many other tClient and tAuthorize records indirectly, especially if used on a company record."); |
|---|
| 386 | |
|---|
| 387 | htmlRecordContext(); |
|---|
| 388 | if(guPermLevel>7) |
|---|
| 389 | { |
|---|
| 390 | tTablePullDownResellers(uForClient,1); |
|---|
| 391 | } |
|---|
| 392 | printf("<p>"); |
|---|
| 393 | printf(LANG_NBB_CONFIRMMOD); |
|---|
| 394 | break; |
|---|
| 395 | |
|---|
| 396 | case 3000: |
|---|
| 397 | printf("<u>Authorize: Step 1 Tips</u><br>Depending on the user level you may authorize a contact to access interfaces (like the organization/contact portal.) Or even to use this back-office. In the 'Login' you would enter a login (that can be the same as the tClient.cLabel) for this contact and a password. The most common user permission level is 'Organization Admin' that would allow this contact to login to the idnsOrg.cgi interface and have full control over the companies DNS resource records. The second most common user level is 'Back-Office Root' that will allow the user full access to this back-office unxsVZ.cgi interface.<p>\n"); |
|---|
| 398 | if(guPermLevel>7) |
|---|
| 399 | PermLevelDropDown(cuPerm); |
|---|
| 400 | printf("<br>Login <input type=text title='Login to use' name=cLogin value='%s'" |
|---|
| 401 | " size=20 maxlength=32>\n",cLabel); |
|---|
| 402 | printf("<br>Passwd <input type=text title='Login passwd' name=cPasswd size=20 maxlength=15>"); |
|---|
| 403 | printf("<input class=largeButton title='Confirm authorization' type=submit name=gcCommand value='Confirm Authorize'>"); |
|---|
| 404 | break; |
|---|
| 405 | |
|---|
| 406 | default: |
|---|
| 407 | if(guPermLevel>9) |
|---|
| 408 | { |
|---|
| 409 | uDefault=1; |
|---|
| 410 | printf("<u>Table Tips</u><br>"); |
|---|
| 411 | printf("Here you can create new companies (organizations in general) or add new contacts" |
|---|
| 412 | " to existing companies. Once a new contact is made you can authorize her to use" |
|---|
| 413 | " interfaces or even this backoffice web interface." |
|---|
| 414 | " The system wide hierachical model used is: A single root user, under this root" |
|---|
| 415 | " user application service provider companies (ASPs) exist, at least one ASP needs" |
|---|
| 416 | " to be created. Under (or as part of) the ASP at least one admin level contact must" |
|---|
| 417 | " be created, this contact can then create or reseller companies or end user" |
|---|
| 418 | " companies. The reseller companies may in turn create other end user companies" |
|---|
| 419 | " that they can manage. End user companies only manage their own resources, via" |
|---|
| 420 | " their contacts. Finally the contacts are assigned a role that limits the" |
|---|
| 421 | " operations they can perform for their company and the interfaces they can use."); |
|---|
| 422 | printf("<p><u>Search Tools</u><br>"); |
|---|
| 423 | printf("Enter the complete or the first part of a company or contact name below." |
|---|
| 424 | " Not case sensitive. You can use %% and _ SQL LIKE matching chars.<br>"); |
|---|
| 425 | //" The check box further limits your search.<br>"); |
|---|
| 426 | printf("<input type=text title='cLabel search. Use %% . and _ for pattern matching.'" |
|---|
| 427 | " name=cSearch value=\"%s\" maxlength=99 size=20><br>",cSearch); |
|---|
| 428 | /* |
|---|
| 429 | //This is broken will fix later ;) TODO |
|---|
| 430 | printf("Only ASPs <input title='Limit search to Root owned tClient records that in" |
|---|
| 431 | " this model are the controlling ASP companies' type=checkbox name=uOnlyASPs "); |
|---|
| 432 | if(uOnlyASPs) |
|---|
| 433 | printf("checked><br>"); |
|---|
| 434 | else |
|---|
| 435 | printf("><br>"); |
|---|
| 436 | */ |
|---|
| 437 | |
|---|
| 438 | htmlRecordContext(); |
|---|
| 439 | } |
|---|
| 440 | |
|---|
| 441 | if( strcmp(cCode,"Organization") && uClient && guPermLevel>9 && uClient!=guLoginClient |
|---|
| 442 | && !IsAuthUser(cLabel,uOwner,uClient) &&guMode!=5 && uOwner!=1) |
|---|
| 443 | { |
|---|
| 444 | printf("<p><input class=largeButton title='Authorize %s to manage his company resources'" |
|---|
| 445 | "type=submit name=gcCommand value='Authorize'>",cLabel); |
|---|
| 446 | } |
|---|
| 447 | |
|---|
| 448 | ContactsNavList(); |
|---|
| 449 | } |
|---|
| 450 | |
|---|
| 451 | if(!uDefault) |
|---|
| 452 | { |
|---|
| 453 | if(cSearch[0]) |
|---|
| 454 | printf("<input type=hidden name=cSearch value=\"%s\">",cSearch); |
|---|
| 455 | if(uOnlyASPs) |
|---|
| 456 | printf("<input type=hidden name=uOnlyASPs value=1>"); |
|---|
| 457 | } |
|---|
| 458 | CloseFieldSet(); |
|---|
| 459 | |
|---|
| 460 | |
|---|
| 461 | }//void ExttClientButtons(void) |
|---|
| 462 | |
|---|
| 463 | |
|---|
| 464 | void ExttClientAuxTable(void) |
|---|
| 465 | { |
|---|
| 466 | |
|---|
| 467 | }//void ExttClientAuxTable(void) |
|---|
| 468 | |
|---|
| 469 | |
|---|
| 470 | void ExttClientGetHook(entry gentries[], int x) |
|---|
| 471 | { |
|---|
| 472 | register int i; |
|---|
| 473 | |
|---|
| 474 | for(i=0;i<x;i++) |
|---|
| 475 | { |
|---|
| 476 | if(!strcmp(gentries[i].name,"uClient")) |
|---|
| 477 | { |
|---|
| 478 | sscanf(gentries[i].val,"%u",&uClient); |
|---|
| 479 | guMode=6; |
|---|
| 480 | } |
|---|
| 481 | else if(!strcmp(gentries[i].name,"uOnlyASPs")) |
|---|
| 482 | { |
|---|
| 483 | sscanf(gentries[i].val,"%u",&uOnlyASPs); |
|---|
| 484 | } |
|---|
| 485 | else if(!strcmp(gentries[i].name,"cSearch")) |
|---|
| 486 | { |
|---|
| 487 | sprintf(cSearch,"%.99s",gentries[i].val); |
|---|
| 488 | } |
|---|
| 489 | } |
|---|
| 490 | tClient(""); |
|---|
| 491 | |
|---|
| 492 | }//void ExttClientGetHook(entry gentries[], int x) |
|---|
| 493 | |
|---|
| 494 | |
|---|
| 495 | void ExttClientSelect(void) |
|---|
| 496 | { |
|---|
| 497 | if(cSearch[0]) |
|---|
| 498 | { |
|---|
| 499 | if(guLoginClient==1 && guPermLevel>11)//Root can read access all |
|---|
| 500 | sprintf(gcQuery,"SELECT " VAR_LIST_tClient " FROM " TCLIENT |
|---|
| 501 | " WHERE cLabel LIKE '%s%%' ORDER BY cLabel",cSearch); |
|---|
| 502 | else |
|---|
| 503 | sprintf(gcQuery,"SELECT " VAR_LIST_tClient " FROM " TCLIENT |
|---|
| 504 | " WHERE (uClient=%1$u OR uOwner IN (SELECT uClient FROM " TCLIENT |
|---|
| 505 | " WHERE uOwner=%1$u OR uClient=%1$u)) AND cLabel LIKE '%2$s%%'" |
|---|
| 506 | " ORDER BY cLabel", |
|---|
| 507 | guCompany,cSearch); |
|---|
| 508 | } |
|---|
| 509 | else |
|---|
| 510 | { |
|---|
| 511 | if(guLoginClient==1 && guPermLevel>11)//Root can read access all |
|---|
| 512 | sprintf(gcQuery,"SELECT " VAR_LIST_tClient " FROM " TCLIENT " ORDER BY uClient"); |
|---|
| 513 | else |
|---|
| 514 | sprintf(gcQuery,"SELECT " VAR_LIST_tClient " FROM " TCLIENT |
|---|
| 515 | " WHERE (uClient=%1$u OR uOwner" |
|---|
| 516 | " IN (SELECT uClient FROM " TCLIENT " WHERE uOwner=%1$u OR uClient=%1$u))" |
|---|
| 517 | " ORDER BY uClient",guCompany); |
|---|
| 518 | } |
|---|
| 519 | |
|---|
| 520 | }//void ExttClientSelect(void) |
|---|
| 521 | |
|---|
| 522 | |
|---|
| 523 | void ExttClientSelectRow(void) |
|---|
| 524 | { |
|---|
| 525 | ExtSelectRow("tClient",VAR_LIST_tClient,uClient); |
|---|
| 526 | if(guLoginClient==1 && guPermLevel>11)//Root can read access all |
|---|
| 527 | sprintf(gcQuery,"SELECT " VAR_LIST_tClient " FROM tClient WHERE uClient=%u ORDER BY uClient", |
|---|
| 528 | uClient); |
|---|
| 529 | else |
|---|
| 530 | sprintf(gcQuery,"SELECT " VAR_LIST_tClient " FROM " TCLIENT |
|---|
| 531 | " WHERE uClient=%2$u AND (uClient=%1$u OR uOwner" |
|---|
| 532 | " IN (SELECT uClient FROM " TCLIENT " WHERE uOwner=%1$u OR uClient=%1$u))" |
|---|
| 533 | " ORDER BY uClient",guCompany,uClient); |
|---|
| 534 | |
|---|
| 535 | }//void ExttClientSelectRow(void) |
|---|
| 536 | |
|---|
| 537 | |
|---|
| 538 | void ExttClientListSelect(void) |
|---|
| 539 | { |
|---|
| 540 | char cCat[512]; |
|---|
| 541 | |
|---|
| 542 | ExtListSelect("tClient",VAR_LIST_tClient); |
|---|
| 543 | if(guLoginClient==1 && guPermLevel>11)//Root can read access all |
|---|
| 544 | sprintf(gcQuery,"SELECT " VAR_LIST_tClient " FROM " TCLIENT); |
|---|
| 545 | else |
|---|
| 546 | sprintf(gcQuery,"SELECT " VAR_LIST_tClient " FROM " TCLIENT |
|---|
| 547 | " WHERE (uClient=%1$u OR uOwner" |
|---|
| 548 | " IN (SELECT uClient FROM " TCLIENT " WHERE uOwner=%1$u OR uClient=%1$u))" |
|---|
| 549 | ,guCompany); |
|---|
| 550 | |
|---|
| 551 | //Changes here must be reflected below in ExttClientListFilter() |
|---|
| 552 | if(!strcmp(gcFilter,"uClient")) |
|---|
| 553 | { |
|---|
| 554 | sscanf(gcCommand,"%u",&uClient); |
|---|
| 555 | if(guPermLevel<10) |
|---|
| 556 | strcat(gcQuery," AND "); |
|---|
| 557 | else |
|---|
| 558 | strcat(gcQuery," WHERE "); |
|---|
| 559 | sprintf(cCat,"uClient=%u ORDER BY uClient", |
|---|
| 560 | uClient); |
|---|
| 561 | strcat(gcQuery,cCat); |
|---|
| 562 | } |
|---|
| 563 | else if(!strcmp(gcFilter,"cLabel")) |
|---|
| 564 | { |
|---|
| 565 | if(guPermLevel<10) |
|---|
| 566 | strcat(gcQuery," AND "); |
|---|
| 567 | else |
|---|
| 568 | strcat(gcQuery," WHERE "); |
|---|
| 569 | sprintf(cCat,"cLabel LIKE '%s' ORDER BY cLabel",gcCommand); |
|---|
| 570 | strcat(gcQuery,cCat); |
|---|
| 571 | } |
|---|
| 572 | else if(1) |
|---|
| 573 | { |
|---|
| 574 | //None NO FILTER |
|---|
| 575 | strcpy(gcFilter,"None"); |
|---|
| 576 | strcat(gcQuery," ORDER BY uClient"); |
|---|
| 577 | } |
|---|
| 578 | |
|---|
| 579 | }//void ExttClientListSelect(void) |
|---|
| 580 | |
|---|
| 581 | |
|---|
| 582 | void ExttClientListFilter(void) |
|---|
| 583 | { |
|---|
| 584 | //Filter |
|---|
| 585 | printf("<td align=right >Select "); |
|---|
| 586 | printf("<select name=gcFilter>"); |
|---|
| 587 | if(strcmp(gcFilter,"uClient")) |
|---|
| 588 | printf("<option>uClient</option>"); |
|---|
| 589 | else |
|---|
| 590 | printf("<option selected>uClient</option>"); |
|---|
| 591 | if(strcmp(gcFilter,"cLabel")) |
|---|
| 592 | printf("<option>cLabel</option>"); |
|---|
| 593 | else |
|---|
| 594 | printf("<option selected>cLabel</option>"); |
|---|
| 595 | if(strcmp(gcFilter,"None")) |
|---|
| 596 | printf("<option>None</option>"); |
|---|
| 597 | else |
|---|
| 598 | printf("<option selected>None</option>"); |
|---|
| 599 | printf("</select>"); |
|---|
| 600 | |
|---|
| 601 | }//void ExttClientListFilter(void) |
|---|
| 602 | |
|---|
| 603 | |
|---|
| 604 | void ExttClientNavBar(void) |
|---|
| 605 | { |
|---|
| 606 | printf(LANG_NBB_SKIPFIRST); |
|---|
| 607 | printf(LANG_NBB_SKIPBACK); |
|---|
| 608 | printf(LANG_NBB_SEARCH); |
|---|
| 609 | |
|---|
| 610 | if(guPermLevel>=10 && !guListMode) |
|---|
| 611 | printf(LANG_NBB_NEW); |
|---|
| 612 | |
|---|
| 613 | if(uAllowMod(uOwner,uCreatedBy)) |
|---|
| 614 | printf(LANG_NBB_MODIFY); |
|---|
| 615 | |
|---|
| 616 | if(uAllowDel(uOwner,uCreatedBy)) |
|---|
| 617 | printf(LANG_NBB_DELETE); |
|---|
| 618 | |
|---|
| 619 | if(uOwner) |
|---|
| 620 | printf(LANG_NBB_LIST); |
|---|
| 621 | |
|---|
| 622 | printf(LANG_NBB_SKIPNEXT); |
|---|
| 623 | printf(LANG_NBB_SKIPLAST); |
|---|
| 624 | |
|---|
| 625 | }//void ExttClientNavBar(void) |
|---|
| 626 | |
|---|
| 627 | |
|---|
| 628 | unsigned IsAuthUser(char *cLabel, unsigned uOwner, unsigned uCertClient) |
|---|
| 629 | { |
|---|
| 630 | unsigned uRetVal=0; |
|---|
| 631 | MYSQL_RES *res; |
|---|
| 632 | MYSQL_ROW field; |
|---|
| 633 | |
|---|
| 634 | if(uOwner==1) |
|---|
| 635 | return(0); |
|---|
| 636 | |
|---|
| 637 | sprintf(gcQuery,"SELECT uPerm FROM " TAUTHORIZE |
|---|
| 638 | " WHERE (cLabel='%s' OR uCertClient=%u ) AND uOwner=%u ",cLabel,uCertClient,uOwner); |
|---|
| 639 | mysql_query(&gMysql,gcQuery); |
|---|
| 640 | if(mysql_errno(&gMysql)) |
|---|
| 641 | { |
|---|
| 642 | printf("%s",mysql_error(&gMysql)); |
|---|
| 643 | return(0); |
|---|
| 644 | } |
|---|
| 645 | res=mysql_store_result(&gMysql); |
|---|
| 646 | if((field=mysql_fetch_row(res))) |
|---|
| 647 | sscanf(field[0],"%u",&uRetVal); |
|---|
| 648 | mysql_free_result(res); |
|---|
| 649 | |
|---|
| 650 | return(uRetVal); |
|---|
| 651 | |
|---|
| 652 | }//unsigned IsAuthUser() |
|---|
| 653 | |
|---|
| 654 | |
|---|
| 655 | unsigned uMaxClientsReached(unsigned uClient) |
|---|
| 656 | { |
|---|
| 657 | MYSQL_RES *res; |
|---|
| 658 | MYSQL_ROW field; |
|---|
| 659 | unsigned uRetVal=1; |
|---|
| 660 | unsigned uMaxClients=2; |
|---|
| 661 | unsigned uClients=0; |
|---|
| 662 | |
|---|
| 663 | sprintf(gcQuery,"SELECT cInfo FROM " TCLIENT " WHERE uClient=%u",uClient); |
|---|
| 664 | |
|---|
| 665 | mysql_query(&gMysql,gcQuery); |
|---|
| 666 | if(mysql_errno(&gMysql)) |
|---|
| 667 | tClient(mysql_error(&gMysql)); |
|---|
| 668 | |
|---|
| 669 | res=mysql_store_result(&gMysql); |
|---|
| 670 | if((field=mysql_fetch_row(res))) |
|---|
| 671 | { |
|---|
| 672 | char *cp; |
|---|
| 673 | |
|---|
| 674 | if((cp=strstr(field[0],"uMaxClients="))) |
|---|
| 675 | sscanf(cp+12,"%u",&uMaxClients); |
|---|
| 676 | } |
|---|
| 677 | mysql_free_result(res); |
|---|
| 678 | |
|---|
| 679 | sprintf(gcQuery,"SELECT COUNT(uClient) FROM " TCLIENT " WHERE uOwner=%u",uClient); |
|---|
| 680 | |
|---|
| 681 | mysql_query(&gMysql,gcQuery); |
|---|
| 682 | if(mysql_errno(&gMysql)) |
|---|
| 683 | tClient(mysql_error(&gMysql)); |
|---|
| 684 | |
|---|
| 685 | res=mysql_store_result(&gMysql); |
|---|
| 686 | if((field=mysql_fetch_row(res))) |
|---|
| 687 | sscanf(field[0],"%u",&uClients); |
|---|
| 688 | mysql_free_result(res); |
|---|
| 689 | |
|---|
| 690 | if(uClients<uMaxClients) |
|---|
| 691 | uRetVal=0; |
|---|
| 692 | |
|---|
| 693 | return(uRetVal); |
|---|
| 694 | |
|---|
| 695 | }//unsigned uMaxClientsReached(unsigned uClient) |
|---|
| 696 | |
|---|
| 697 | |
|---|
| 698 | void tTablePullDownResellers(unsigned uSelector,unsigned uBanner) |
|---|
| 699 | { |
|---|
| 700 | if(guPermLevel<10) |
|---|
| 701 | return; |
|---|
| 702 | |
|---|
| 703 | MYSQL_RES *res; |
|---|
| 704 | MYSQL_ROW field; |
|---|
| 705 | |
|---|
| 706 | register int i,n; |
|---|
| 707 | |
|---|
| 708 | if(guPermLevel>11) |
|---|
| 709 | { |
|---|
| 710 | sprintf(gcQuery,"SELECT uClient,cLabel FROM " TCLIENT |
|---|
| 711 | " WHERE cCode='Organization' AND uClient!=1" |
|---|
| 712 | " ORDER BY cLabel"); |
|---|
| 713 | } |
|---|
| 714 | else |
|---|
| 715 | { |
|---|
| 716 | sprintf(gcQuery,"SELECT uClient,cLabel FROM " TCLIENT |
|---|
| 717 | " WHERE cLabel!='%s'" |
|---|
| 718 | " AND cCode='Organization'" |
|---|
| 719 | " AND (uClient=%u OR uOwner" |
|---|
| 720 | " IN (SELECT uClient FROM " TCLIENT " WHERE uOwner=%u OR uClient=%u))" |
|---|
| 721 | " ORDER BY cLabel", |
|---|
| 722 | gcUser, |
|---|
| 723 | guCompany, |
|---|
| 724 | guCompany, |
|---|
| 725 | guCompany); |
|---|
| 726 | } |
|---|
| 727 | |
|---|
| 728 | mysql_query(&gMysql,gcQuery); |
|---|
| 729 | if(mysql_errno(&gMysql)) |
|---|
| 730 | { |
|---|
| 731 | printf("%s",mysql_error(&gMysql)); |
|---|
| 732 | return; |
|---|
| 733 | } |
|---|
| 734 | res=mysql_store_result(&gMysql); |
|---|
| 735 | i=mysql_num_rows(res); |
|---|
| 736 | |
|---|
| 737 | if(i>0) |
|---|
| 738 | { |
|---|
| 739 | if(uBanner) |
|---|
| 740 | printf("<p>Optionally select an existing company<br>"); |
|---|
| 741 | printf("<select name=cForClientPullDown>\n"); |
|---|
| 742 | |
|---|
| 743 | //Default no selection |
|---|
| 744 | printf("<option>---</option>\n"); |
|---|
| 745 | |
|---|
| 746 | for(n=0;n<i;n++) |
|---|
| 747 | { |
|---|
| 748 | unsigned ufield0=0; |
|---|
| 749 | |
|---|
| 750 | field=mysql_fetch_row(res); |
|---|
| 751 | sscanf(field[0],"%u",&ufield0); |
|---|
| 752 | |
|---|
| 753 | if(uSelector != ufield0) |
|---|
| 754 | { |
|---|
| 755 | printf("<option>%s</option>\n",field[1]); |
|---|
| 756 | } |
|---|
| 757 | else |
|---|
| 758 | { |
|---|
| 759 | printf("<option selected>%s</option>\n",field[1]); |
|---|
| 760 | } |
|---|
| 761 | } |
|---|
| 762 | printf("</select>\n"); |
|---|
| 763 | } |
|---|
| 764 | |
|---|
| 765 | }//tTablePullDownResellers() |
|---|
| 766 | |
|---|
| 767 | |
|---|
| 768 | void PermLevelDropDown(char *cuPerm) |
|---|
| 769 | { |
|---|
| 770 | printf("User Level "); |
|---|
| 771 | |
|---|
| 772 | printf("<select name=cuPerm>\n"); |
|---|
| 773 | |
|---|
| 774 | //Allow resellers to add their customers |
|---|
| 775 | if(guPermLevel>7) |
|---|
| 776 | { |
|---|
| 777 | printf("<option "); |
|---|
| 778 | if(!strcmp(cuPerm,BO_CUSTOMER)) |
|---|
| 779 | printf("selected>"); |
|---|
| 780 | else |
|---|
| 781 | printf(">"); |
|---|
| 782 | printf("%s</option>\n",BO_CUSTOMER); |
|---|
| 783 | } |
|---|
| 784 | |
|---|
| 785 | //Allow admins to add resellers |
|---|
| 786 | //and organization admins |
|---|
| 787 | if(guPermLevel>9) |
|---|
| 788 | { |
|---|
| 789 | printf("<option "); |
|---|
| 790 | if(!strcmp(cuPerm,BO_RESELLER)) |
|---|
| 791 | printf("selected>"); |
|---|
| 792 | else |
|---|
| 793 | printf(">"); |
|---|
| 794 | printf("%s</option>\n",BO_RESELLER); |
|---|
| 795 | |
|---|
| 796 | printf("<option "); |
|---|
| 797 | if(!strcmp(cuPerm,BO_ADMIN)) |
|---|
| 798 | printf("selected>"); |
|---|
| 799 | else |
|---|
| 800 | printf(">"); |
|---|
| 801 | printf("%s</option>\n",BO_ADMIN); |
|---|
| 802 | |
|---|
| 803 | printf("<option "); |
|---|
| 804 | if(!strcmp(cuPerm,ORG_ADMIN)) |
|---|
| 805 | printf("selected>"); |
|---|
| 806 | else |
|---|
| 807 | printf(">"); |
|---|
| 808 | printf("%s</option>\n",ORG_ADMIN); |
|---|
| 809 | } |
|---|
| 810 | |
|---|
| 811 | //Allow root to add admin and other root users |
|---|
| 812 | if(guPermLevel>11) |
|---|
| 813 | { |
|---|
| 814 | printf("<option "); |
|---|
| 815 | if(!strcmp(cuPerm,BO_ADMIN)) |
|---|
| 816 | printf("selected>"); |
|---|
| 817 | else |
|---|
| 818 | printf(">"); |
|---|
| 819 | printf("%s</option>\n",BO_ADMIN); |
|---|
| 820 | |
|---|
| 821 | printf("<option "); |
|---|
| 822 | if(!strcmp(cuPerm,BO_ROOT)) |
|---|
| 823 | printf("selected>"); |
|---|
| 824 | else |
|---|
| 825 | printf(">"); |
|---|
| 826 | printf("%s</option>\n",BO_ROOT); |
|---|
| 827 | } |
|---|
| 828 | |
|---|
| 829 | printf("</select>\n"); |
|---|
| 830 | |
|---|
| 831 | }//void PermLevelDropDown(char *cuPerm) |
|---|
| 832 | |
|---|
| 833 | |
|---|
| 834 | const char *cUserLevel(unsigned uPermLevel) |
|---|
| 835 | { |
|---|
| 836 | switch(uPermLevel) |
|---|
| 837 | { |
|---|
| 838 | case BO_ROOT_VAL: |
|---|
| 839 | return(BO_ROOT); |
|---|
| 840 | break; |
|---|
| 841 | case BO_ADMIN_VAL: |
|---|
| 842 | return(BO_ADMIN); |
|---|
| 843 | break; |
|---|
| 844 | case BO_RESELLER_VAL: |
|---|
| 845 | return(BO_RESELLER); |
|---|
| 846 | break; |
|---|
| 847 | case BO_CUSTOMER_VAL: |
|---|
| 848 | return(BO_CUSTOMER); |
|---|
| 849 | break; |
|---|
| 850 | case ORG_ADMIN_VAL: |
|---|
| 851 | return(ORG_ADMIN); |
|---|
| 852 | break; |
|---|
| 853 | case ORG_ACCT_VAL: |
|---|
| 854 | return(ORG_ACCT); |
|---|
| 855 | break; |
|---|
| 856 | case ORG_SERVICE_VAL: |
|---|
| 857 | return(ORG_SERVICE); |
|---|
| 858 | break; |
|---|
| 859 | case ORG_SALES_VAL: |
|---|
| 860 | return(ORG_SALES); |
|---|
| 861 | break; |
|---|
| 862 | case ORG_WEBMASTER_VAL: |
|---|
| 863 | return(ORG_WEBMASTER); |
|---|
| 864 | break; |
|---|
| 865 | case ORG_CUSTOMER_VAL: |
|---|
| 866 | return(ORG_CUSTOMER); |
|---|
| 867 | break; |
|---|
| 868 | default: |
|---|
| 869 | return("---"); |
|---|
| 870 | break; |
|---|
| 871 | } |
|---|
| 872 | |
|---|
| 873 | }//const char *cUserLevel(unsigned uPermLevel) |
|---|
| 874 | |
|---|
| 875 | |
|---|
| 876 | void tAuthorizeNavList(void);//tauthorizefunc.h |
|---|
| 877 | void ContactsNavList(void) |
|---|
| 878 | { |
|---|
| 879 | MYSQL_RES *res; |
|---|
| 880 | MYSQL_ROW field; |
|---|
| 881 | |
|---|
| 882 | if(guPermLevel<10 || !uClient) |
|---|
| 883 | return; |
|---|
| 884 | |
|---|
| 885 | //Login info |
|---|
| 886 | if(uOwner!=1 && strcmp(cCode,"Organization")) |
|---|
| 887 | { |
|---|
| 888 | tAuthorizeNavList(); |
|---|
| 889 | } |
|---|
| 890 | |
|---|
| 891 | //NavList proper |
|---|
| 892 | sprintf(gcQuery,"SELECT uClient,cLabel FROM " TCLIENT " WHERE uOwner=%u AND uOwner!=1",uClient); |
|---|
| 893 | mysql_query(&gMysql,gcQuery); |
|---|
| 894 | if(mysql_errno(&gMysql)) |
|---|
| 895 | { |
|---|
| 896 | printf("<p><u>Controlled Companies or Contacts NavList</u><br>\n"); |
|---|
| 897 | printf("%s<br>\n",mysql_error(&gMysql)); |
|---|
| 898 | return; |
|---|
| 899 | } |
|---|
| 900 | |
|---|
| 901 | res=mysql_store_result(&gMysql); |
|---|
| 902 | if(mysql_num_rows(res)) |
|---|
| 903 | { |
|---|
| 904 | printf("<p><u>Controlled Companies or Contacts NavList</u><br>\n"); |
|---|
| 905 | while((field=mysql_fetch_row(res))) |
|---|
| 906 | { |
|---|
| 907 | printf("<a class=darkLink href=unxsVZ.cgi?gcFunction=tClient&uClient=%s&uOnlyASPs=%u" |
|---|
| 908 | ,field[0],uOnlyASPs); |
|---|
| 909 | if(cSearch[0]) |
|---|
| 910 | { |
|---|
| 911 | spacetoplus(cSearch); |
|---|
| 912 | printf("&cSearch=%s",cSearch); |
|---|
| 913 | } |
|---|
| 914 | printf(">%s</a><br>",field[1]); |
|---|
| 915 | } |
|---|
| 916 | } |
|---|
| 917 | mysql_free_result(res); |
|---|
| 918 | |
|---|
| 919 | }//void ContactsNavList(void) |
|---|
| 920 | |
|---|
| 921 | |
|---|
| 922 | void htmlRecordContext(void) |
|---|
| 923 | { |
|---|
| 924 | printf("<p><u>Record Context Info</u><br>"); |
|---|
| 925 | if(uOwner>1 && strcmp(cCode,"Contact")) |
|---|
| 926 | printf("'%s' appears to be a reseller or ASP owned company or organization",cLabel); |
|---|
| 927 | else if(uOwner>1 && strcmp(cCode,"Organization")) |
|---|
| 928 | printf("'%s' appears to be a contact of <a class=darkLink" |
|---|
| 929 | " href=unxsVZ.cgi?gcFunction=tClient&uClient=%u>'%s'</a>", |
|---|
| 930 | cLabel,uOwner,ForeignKey(TCLIENT,"cLabel",uOwner)); |
|---|
| 931 | else if(uOwner==1 && strcmp(cLabel,"Root")) |
|---|
| 932 | printf("'%s' appears to be an ASP root company",cLabel); |
|---|
| 933 | else if(uOwner==1 && !strcmp(cLabel,"Root")) |
|---|
| 934 | printf("'Root' is the system created root user. This user is the only user that can" |
|---|
| 935 | " create ASP level companies. Make sure the passwd is changed" |
|---|
| 936 | " regularly via the tAuthorize table."); |
|---|
| 937 | }//void htmlRecordContext(void) |
|---|