-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
3203 lines (2744 loc) · 88.4 KB
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
FILE
unxsVZ/main.c
PURPOSE
Main cgi interface and common functions used for all the other
table tx.c files and their schema independent txfunc.h files -until
you mess with them in non standard ways...lol.
AUTHOR/LEGAL
(C) Gary Wallis 2001-2016 for Unixservice, LLC.
GPLv2 license applies. See LICENSE file included.
*/
#include "mysqlrad.h"
#include <ctype.h>
#include "language.h"
#include "local.h"
//Global vars
#define SHOWPAGE 30
MYSQL gMysql;
MYSQL gMysqlUBC;
char *gcUBCDBIP0={""};//must be set to DBIP0 to be used as alternative
char *gcUBCDBIP1={""};
char gcUBCDBIP0Buffer[32]={""};
char gcUBCDBIP1Buffer[32]={""};
FILE *gLfp=NULL;
unsigned long gluRowid;
unsigned guStart;
unsigned guEnd;
unsigned guI;
unsigned guN=SHOWPAGE;
char gcCommand[100];
char gcPage[100];
char gcFilter[100];
char gcAuxFilter[256];
char gcFind[100];
unsigned guMode;
int guPermLevel=0;
unsigned guLoginClient=0;
unsigned guAuthorize=0;
unsigned guReseller=0;
unsigned guCompany=0;
char gcCompany[100]={""};
char gcUser[100]={""};
char gcHost[32]={""};
char gcIPMask[32]={""};//tAuthorize.cIPMask on login it is gcHost
char gcHostname[100]={""};
//libunxsvz required
char cStartDate[32]={""};
char cStartTime[32]={""};
unsigned guDatacenter=0;
char cLogKey[16]={"Ksdj458jssdUjf79"};
//SSLLoginCookie()
char gcCookie[1024]={""};
char gcLogin[100]={""};
char gcPasswd[100]={""};
unsigned guSSLCookieLogin=0;
unsigned guRequireOTPLogin=0;
unsigned guOTPExpired=0;
char gcOTP[16]={""};
char gcOTPInfo[128]={"Nothing yet"};
char gcOTPSecret[65]={""};
char gcFunction[100]={""};
unsigned guListMode=0;
char gcQuery[8192]={""};
char *gcQstr=gcQuery;
//git describe version info from makefile define
char *gcBuildInfo="GitVersion:"GitVersion;
char *gcRADStatus="";
//Local
void Footer_ism3(void);
void Header_ism3(const char *cMsg, int iJs);
const char *ForeignKey(const char *cTableName, const char *cFieldName, unsigned uKey);
const char *ForeignKey2(const char *cTableName, const char *cFieldName, unsigned uKey);
char *cEmailInput(char *cInput);
void GetClientOwner(unsigned uClient, unsigned *uOwner);
void htmlPlainTextError(const char *cError);
//Ext
int iExtMainCommands(pentry entries[], int x);
void ExtMainContent(void);
void ExtMainShell(int iArgc, char *cArgv[]);
void DashBoard(const char *cOptionalMsg);
//Only local
void ConnectDb(char *cMessage);
void jsToggleCheckboxes(void);
void NoSuchFunction(void);
void unxsVZ(const char *cResult);
void InitialInstall(void);
const char *cUserLevel(unsigned uPermLevel);
int iValidLogin(int iMode);
void SSLCookieLogin(void);
void SetLogin(void);
void EncryptPasswdWithSalt(char *gcPasswd, char *cSalt);
void GetPLAndClient(char *cUser);
void htmlSSLLogin(void);
void GeneratePasswd(char *pw);
void UpdateOTPExpire(unsigned uAuthorize,unsigned uClient);
void LoginFirewallJobs(unsigned uLoginClient,char *cIP);
void LogoutFirewallJobs(unsigned uLoginClient,char *cIP);
void RemoveLoginSession(const char *cIP,const char *gcUser,const char *gcCompany);
//mainfunc.h for symbolic links to this program
void CalledByAlias(int iArgc,char *cArgv[]);
//Testing globalization
pentry entries[512];
entry gentries[16];
int x;
void voidLogout(void)
{
printf("Set-Cookie: unxsVZLogin=; discard; expires=\"Mon, 01-Jan-1971 00:10:10 GMT\"\n");
printf("Set-Cookie: unxsVZPasswd=; discard; expires=\"Mon, 01-Jan-1971 00:10:10 GMT\"\n");
sprintf(gcQuery,"INSERT INTO tLog SET cLabel='logout %.99s',uLogType=6,uPermLevel=%u,"
" uLoginClient=%u,cLogin='%.99s',cHost='%.15s/%.15s',cServer='%.99s',uOwner=%u,uCreatedBy=1,"
" uCreatedDate=UNIX_TIMESTAMP(NOW()) ON DUPLICATE KEY UPDATE "
" cLabel='logout %.99s',uLogType=6,uPermLevel=%u,"
" uLoginClient=%u,cLogin='%.99s',cHost='%.15s/%.15s',cServer='%.99s',uOwner=%u,uCreatedBy=1,"
" uCreatedDate=UNIX_TIMESTAMP(NOW())",
gcLogin,guPermLevel,
guLoginClient,gcLogin,gcHost,gcIPMask,gcHostname,guCompany,
gcLogin,guPermLevel,
guLoginClient,gcLogin,gcHost,gcIPMask,gcHostname,guCompany);
MYSQL_RUN;
if(gcIPMask[0])
LogoutFirewallJobs(guLoginClient,gcIPMask);
else
LogoutFirewallJobs(guLoginClient,gcHost);
if(guAuthorize)
{
gcIPMask[0]=0;
sprintf(gcQuery,"UPDATE tAuthorize SET cIPMask='' WHERE uAuthorize=%u",guAuthorize);
MYSQL_RUN;
}
if(gcOTPSecret[0])
{
UpdateOTPExpire(0,guLoginClient);
guRequireOTPLogin=1;
}
gcCookie[0]=0;
guPermLevel=0;
guLoginClient=0;
gcUser[0]=0;
gcCompany[0]=0;
guSSLCookieLogin=0;
htmlSSLLogin();
}//voidLogout(void)
int main(int iArgc, char *cArgv[])
{
char *gcl;
int cl=0;
gethostname(gcHostname, 98);
if(!strstr(cArgv[0],"unxsVZ.cgi"))
CalledByAlias(iArgc,cArgv);
if(getenv("REMOTE_HOST")!=NULL)
sprintf(gcHost,"%.99s",getenv("REMOTE_HOST"));
else if(getenv("REMOTE_ADDR")!=NULL)
{
char cMessage[256]={""};
ConnectDb(cMessage);
if(cMessage[0]) unxsVZ(cMessage);
sprintf(gcHost,"%.99s",getenv("REMOTE_ADDR"));
}
else
{
ExtMainShell(iArgc,cArgv);
}
if(strcmp(getenv("REQUEST_METHOD"),"POST"))
{
SSLCookieLogin();
gcl = getenv("QUERY_STRING");
for(x=0;gcl[0] != '\0' && x<16;x++)
{
getword(gentries[x].val,gcl,'&');
plustospace(gentries[x].val);
unescape_url(gentries[x].val);
getword(gentries[x].name,gentries[x].val,'=');
//basic anti hacker
escape_shell_cmd(gentries[x].val);
//Local vars
if(!strcmp(gentries[x].name,"gcFunction"))
sprintf(gcFunction,"%.99s",gentries[x].val);
}
if(gcFunction[0])
{
if(!strcmp(gcFunction,"Main"))
unxsVZ("");
else if(!strcmp(gcFunction,"Logout"))
voidLogout();
else if(!strcmp(gcFunction,"tDatacenter"))
ExttDatacenterGetHook(gentries,x);
else if(!strcmp(gcFunction,"tNode"))
ExttNodeGetHook(gentries,x);
else if(!strcmp(gcFunction,"tContainer"))
ExttContainerGetHook(gentries,x);
else if(!strcmp(gcFunction,"tProperty"))
ExttPropertyGetHook(gentries,x);
else if(!strcmp(gcFunction,"tType"))
ExttTypeGetHook(gentries,x);
else if(!strcmp(gcFunction,"tContainerType"))
ExttContainerTypeGetHook(gentries,x);
else if(!strcmp(gcFunction,"tPerm"))
ExttPermGetHook(gentries,x);
else if(!strcmp(gcFunction,"tOSTemplate"))
ExttOSTemplateGetHook(gentries,x);
else if(!strcmp(gcFunction,"tNameserver"))
ExttNameserverGetHook(gentries,x);
else if(!strcmp(gcFunction,"tSearchdomain"))
ExttSearchdomainGetHook(gentries,x);
else if(!strcmp(gcFunction,"tConfig"))
ExttConfigGetHook(gentries,x);
else if(!strcmp(gcFunction,"tIP"))
ExttIPGetHook(gentries,x);
else if(!strcmp(gcFunction,"tGroupType"))
ExttGroupTypeGetHook(gentries,x);
else if(!strcmp(gcFunction,"tGroup"))
ExttGroupGetHook(gentries,x);
else if(!strcmp(gcFunction,"tGroupGlue"))
ExttGroupGlueGetHook(gentries,x);
else if(!strcmp(gcFunction,"tClient"))
ExttClientGetHook(gentries,x);
else if(!strcmp(gcFunction,"tAuthorize"))
ExttAuthorizeGetHook(gentries,x);
else if(!strcmp(gcFunction,"tTemplate"))
ExttTemplateGetHook(gentries,x);
else if(!strcmp(gcFunction,"tTemplateSet"))
ExttTemplateSetGetHook(gentries,x);
else if(!strcmp(gcFunction,"tTemplateType"))
ExttTemplateTypeGetHook(gentries,x);
else if(!strcmp(gcFunction,"tLog"))
ExttLogGetHook(gentries,x);
else if(!strcmp(gcFunction,"tLogType"))
ExttLogTypeGetHook(gentries,x);
else if(!strcmp(gcFunction,"tLogMonth"))
ExttLogMonthGetHook(gentries,x);
else if(!strcmp(gcFunction,"tMonth"))
ExttMonthGetHook(gentries,x);
else if(!strcmp(gcFunction,"tGlossary"))
ExttGlossaryGetHook(gentries,x);
else if(!strcmp(gcFunction,"tJob"))
ExttJobGetHook(gentries,x);
else if(!strcmp(gcFunction,"tJobStatus"))
ExttJobStatusGetHook(gentries,x);
else if(!strcmp(gcFunction,"tStatus"))
ExttStatusGetHook(gentries,x);
else if(!strcmp(gcFunction,"tFWStatus"))
ExttFWStatusGetHook(gentries,x);
else if(!strcmp(gcFunction,"tFWRule"))
ExttFWRuleGetHook(gentries,x);
else if(!strcmp(gcFunction,"tIPType"))
ExttIPTypeGetHook(gentries,x);
else if(!strcmp(gcFunction,"tConfiguration"))
ExttConfigurationGetHook(gentries,x);
else if(!strcmp(gcFunction,"Dashboard"))
unxsVZ("DashBoard");
else if(!strcmp(gcFunction,"Glossary"))
GlossaryGetHook(gentries,x);
}
unxsVZ(ISPNAME);
}//end get method interface section
//Post method interface
cl = atoi(getenv("CONTENT_LENGTH"));
for(x=0;cl && (!feof(stdin)) && x<512 ;x++)
{
entries[x].val = fmakeword(stdin,'&',&cl);
plustospace(entries[x].val);
unescape_url(entries[x].val);
entries[x].name = makeword(entries[x].val,'=');
//basic anti hacker
//Allow posted page cursors. See PageMachine()
//escape_shell_cmd(entries[x].val);
if(!strcmp(entries[x].name,"gcFunction"))
sprintf(gcFunction,"%.99s",entries[x].val);
else if(!strcmp(entries[x].name,"guListMode"))
sscanf(entries[x].val,"%u",&guListMode);
else if(!strcmp(entries[x].name,"gcLogin"))
sprintf(gcLogin,"%.99s",entries[x].val);
else if(!strcmp(entries[x].name,"gcPasswd"))
sprintf(gcPasswd,"%.99s",entries[x].val);
else if(!strcmp(entries[x].name,"gcOTP"))
sprintf(gcOTP,"%.15s",entries[x].val);
}
//SSLCookieLogin()
if(!strcmp(gcFunction,"Login")) SetLogin();
if(!guPermLevel || !gcUser[0] || !guLoginClient)
SSLCookieLogin();
//Main Post Menu
tDatacenterCommands(entries,x);
tNodeCommands(entries,x);
tContainerCommands(entries,x);
tPropertyCommands(entries,x);
tTypeCommands(entries,x);
tContainerTypeCommands(entries,x);
tPermCommands(entries,x);
tOSTemplateCommands(entries,x);
tNameserverCommands(entries,x);
tSearchdomainCommands(entries,x);
tConfigCommands(entries,x);
tIPCommands(entries,x);
tGroupTypeCommands(entries,x);
tGroupCommands(entries,x);
tGroupGlueCommands(entries,x);
tClientCommands(entries,x);
tAuthorizeCommands(entries,x);
tTemplateCommands(entries,x);
tTemplateSetCommands(entries,x);
tTemplateTypeCommands(entries,x);
tLogCommands(entries,x);
tLogTypeCommands(entries,x);
tLogMonthCommands(entries,x);
tMonthCommands(entries,x);
tGlossaryCommands(entries,x);
tJobCommands(entries,x);
tJobStatusCommands(entries,x);
tStatusCommands(entries,x);
tFWStatusCommands(entries,x);
tFWRuleCommands(entries,x);
tIPTypeCommands(entries,x);
tConfigurationCommands(entries,x);
iExtMainCommands(entries,x);
NoSuchFunction();
return(0);
}//end of main()
#include "mainfunc.h"
void unxsVZ(const char *cResult)
{
Header_ism3("Main",0);
if(cResult[0])
{
if(!strcmp(cResult,"CloneReport"))
CloneReport(cResult);
else if(!strcmp(cResult,"ContainerReport"))
ContainerReport(cResult);
else if(!strcmp(cResult,"CapacityReport"))
CapacityReport(cResult);
else if(!strcmp(cResult,"NodeMapReport"))
NodeMapReport(cResult);
else if(!strcmp(cResult,"HardwareReport"))
HardwareReport(cResult);
else if(!strcmp(cResult,"SessionReport"))
SessionReport(cResult);
else
DashBoard(cResult);
}
else
{
ExtMainContent();
}
Footer_ism3();
}//void unxsVZ(const char *cResult)
void StyleSheet(void)
{
printf("<!-- StyleSheet() -->\n");
printf("<link rel=stylesheet type=text/css href=/css/radBackend.css />\n");
}//void StyleSheet(void)
/*
* Uses Clean Calendar
* Copyright 2007-2009 Marc Grabanski ([email protected]) http://marcgrabanski.com
* Project Page: http://marcgrabanski.com/article/clean-calendar
* Under the MIT License
*
* Install only two files in your html/js dir
*/
void jsCalendarHeader(void)
{
printf("<link rel='stylesheet' type='text/css' media='all' href='/js/calendar.css'/>\n");
printf("<script type='text/javascript' src='/js/calendar.js'></script>\n");
}//void jsCalendarHeader(void)
void jsCalendarInput(char *cInputName,char *cValue,unsigned uMode)
{
char cMode[16]={""};
if(!uMode)
sprintf(cMode,"disabled");
printf("<input type=text title='Enter date US style month/day/full-year'"
" class=calendarSelectDate name='%s' value='%s' %s ><div id=calendarDiv></div>",cInputName,cValue,cMode);
}//void jsCalendarInput(char *cInputName,char *cValue,unsigned uMode)
void jsToggleCheckboxes(void)
{
printf("<script>"
"function checkAll(checkname, toggle)"
"{"
" for (i = 0; i < checkname.length; i++)"
" if( checkname[i].name.indexOf(\"NoCA\")==(-1) )"
" {"
" checkname[i].checked = toggle.checked? true:false"
" }"
"}"
"</script>");
}//void jsToggleCheckboxes(void)
void Header_ism3(const char *title, int iJs)
{
printf("Content-type: text/html\n\n");
printf("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\""
" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n");
printf("<html><head><title>"HEADER_TITLE" %s %s </title>",gcHostname,title);
printf("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">\n");
if(iJs==1)
{
jsCalendarHeader();
}
else if(iJs==2)
{
jsToggleCheckboxes();
}
else if(iJs==3)
{
jsCalendarHeader();
jsToggleCheckboxes();
}
StyleSheet();
printf("<script language='JavaScript' src='/css/popups.js'></script>\n");
printf("<link rel=\"shortcut icon\" type=image/x-icon href=/images/unxsvz.ico?v=2>\n");
printf("</head><body><form name=formMain action=unxsVZ.cgi method=post><blockquote>\n");
//printf("<img src=/images/unxslogo.gif> \n");
//ModuleRAD3NavBars()
if(!strcmp(gcFunction,"tDatacenter") || !strcmp(gcFunction,"tDatacenterTools") ||
!strcmp(gcFunction,"tDatacenterList"))
ExttDatacenterNavBar();
else if(!strcmp(gcFunction,"tNode") || !strcmp(gcFunction,"tNodeTools") ||
!strcmp(gcFunction,"tNodeList"))
ExttNodeNavBar();
else if(!strcmp(gcFunction,"tContainer") || !strcmp(gcFunction,"tContainerTools") ||
!strcmp(gcFunction,"tContainerList"))
ExttContainerNavBar();
else if(!strcmp(gcFunction,"tProperty") || !strcmp(gcFunction,"tPropertyTools") ||
!strcmp(gcFunction,"tPropertyList"))
ExttPropertyNavBar();
else if(!strcmp(gcFunction,"tType") || !strcmp(gcFunction,"tTypeTools") ||
!strcmp(gcFunction,"tTypeList"))
ExttTypeNavBar();
else if(!strcmp(gcFunction,"tContainerType") || !strcmp(gcFunction,"tContainerTypeTools") ||
!strcmp(gcFunction,"tContainerTypeList"))
ExttContainerTypeNavBar();
else if(!strcmp(gcFunction,"tPerm") || !strcmp(gcFunction,"tPermTools") ||
!strcmp(gcFunction,"tPermList"))
ExttPermNavBar();
else if(!strcmp(gcFunction,"tOSTemplate") || !strcmp(gcFunction,"tOSTemplateTools") ||
!strcmp(gcFunction,"tOSTemplateList"))
ExttOSTemplateNavBar();
else if(!strcmp(gcFunction,"tNameserver") || !strcmp(gcFunction,"tNameserverTools") ||
!strcmp(gcFunction,"tNameserverList"))
ExttNameserverNavBar();
else if(!strcmp(gcFunction,"tSearchdomain") || !strcmp(gcFunction,"tSearchdomainTools") ||
!strcmp(gcFunction,"tSearchdomainList"))
ExttSearchdomainNavBar();
else if(!strcmp(gcFunction,"tConfig") || !strcmp(gcFunction,"tConfigTools") ||
!strcmp(gcFunction,"tConfigList"))
ExttConfigNavBar();
else if(!strcmp(gcFunction,"tIP") || !strcmp(gcFunction,"tIPTools") ||
!strcmp(gcFunction,"tIPList"))
ExttIPNavBar();
else if(!strcmp(gcFunction,"tGroupType") || !strcmp(gcFunction,"tGroupTypeTools") ||
!strcmp(gcFunction,"tGroupTypeList"))
ExttGroupTypeNavBar();
else if(!strcmp(gcFunction,"tGroup") || !strcmp(gcFunction,"tGroupTools") ||
!strcmp(gcFunction,"tGroupList"))
ExttGroupNavBar();
else if(!strcmp(gcFunction,"tGroupGlue") || !strcmp(gcFunction,"tGroupGlueTools") ||
!strcmp(gcFunction,"tGroupGlueList"))
ExttGroupGlueNavBar();
else if(!strcmp(gcFunction,"tClient") || !strcmp(gcFunction,"tClientTools") ||
!strcmp(gcFunction,"tClientList"))
ExttClientNavBar();
else if(!strcmp(gcFunction,"tAuthorize") || !strcmp(gcFunction,"tAuthorizeTools") ||
!strcmp(gcFunction,"tAuthorizeList"))
ExttAuthorizeNavBar();
else if(!strcmp(gcFunction,"tTemplate") || !strcmp(gcFunction,"tTemplateTools") ||
!strcmp(gcFunction,"tTemplateList"))
ExttTemplateNavBar();
else if(!strcmp(gcFunction,"tTemplateSet") || !strcmp(gcFunction,"tTemplateSetTools") ||
!strcmp(gcFunction,"tTemplateSetList"))
ExttTemplateSetNavBar();
else if(!strcmp(gcFunction,"tTemplateType") || !strcmp(gcFunction,"tTemplateTypeTools") ||
!strcmp(gcFunction,"tTemplateTypeList"))
ExttTemplateTypeNavBar();
else if(!strcmp(gcFunction,"tLog") || !strcmp(gcFunction,"tLogTools") ||
!strcmp(gcFunction,"tLogList"))
ExttLogNavBar();
else if(!strcmp(gcFunction,"tLogType") || !strcmp(gcFunction,"tLogTypeTools") ||
!strcmp(gcFunction,"tLogTypeList"))
ExttLogTypeNavBar();
else if(!strcmp(gcFunction,"tLogMonth") || !strcmp(gcFunction,"tLogMonthTools") ||
!strcmp(gcFunction,"tLogMonthList"))
ExttLogMonthNavBar();
else if(!strcmp(gcFunction,"tMonth") || !strcmp(gcFunction,"tMonthTools") ||
!strcmp(gcFunction,"tMonthList"))
ExttMonthNavBar();
else if(!strcmp(gcFunction,"tGlossary") || !strcmp(gcFunction,"tGlossaryTools") ||
!strcmp(gcFunction,"tGlossaryList"))
ExttGlossaryNavBar();
else if(!strcmp(gcFunction,"tJob") || !strcmp(gcFunction,"tJobTools") ||
!strcmp(gcFunction,"tJobList"))
ExttJobNavBar();
else if(!strcmp(gcFunction,"tJobStatus") || !strcmp(gcFunction,"tJobStatusTools") ||
!strcmp(gcFunction,"tJobStatusList"))
ExttJobStatusNavBar();
else if(!strcmp(gcFunction,"tStatus") || !strcmp(gcFunction,"tStatusTools") ||
!strcmp(gcFunction,"tStatusList"))
ExttStatusNavBar();
else if(!strcmp(gcFunction,"tFWStatus") || !strcmp(gcFunction,"tFWStatusTools") ||
!strcmp(gcFunction,"tFWStatusList"))
ExttFWStatusNavBar();
else if(!strcmp(gcFunction,"tFWRule") || !strcmp(gcFunction,"tFWRuleTools") ||
!strcmp(gcFunction,"tFWRuleList"))
ExttFWRuleNavBar();
else if(!strcmp(gcFunction,"tIPType") || !strcmp(gcFunction,"tIPTypeTools") ||
!strcmp(gcFunction,"tIPTypeList"))
ExttIPTypeNavBar();
else if(!strcmp(gcFunction,"tConfiguration") || !strcmp(gcFunction,"tConfigurationTools") ||
!strcmp(gcFunction,"tConfigurationList"))
ExttConfigurationNavBar();
//Login info
printf("<font size=3><b>unxsVZ</b></font> \n ");
if(!guPermLevel)
{
printf(" <font color=red>Your IP address %s has been logged</font>",gcHost);
//debug only
//printf(" <font color=red>%s ",gcUser);
//if(strcmp(gcUser,gcCompany)) printf("(%s) ",gcCompany);
//printf("debug %s [%s/%u (%s)]</font>",gcHost,cUserLevel(guPermLevel),guReseller,gcOTPInfo);
}
else
{
printf(" <font color=red>%s ",gcUser);
if(strcmp(gcUser,gcCompany)) printf("(%s) ",gcCompany);
printf("logged in from %s [%s/%u]</font>",gcHost,cUserLevel(guPermLevel),guReseller);
//printf("debug %s [%s/%u (%s)]</font>",gcHost,cUserLevel(guPermLevel),guReseller,gcOTPInfo);
}
//Logout link
if(guSSLCookieLogin)
{
printf(" <a title='Erase login cookies' href=unxsVZ.cgi?gcFunction=Logout>Logout</a> ");
printf(" <a title='Quick dashboard link' href=unxsVZ.cgi?gcFunction=Dashboard>Dashboard</a> ");
}
//Generate Menu Items
printf("\n<!-- tab menu -->\n");
printf("<div id=menuholder>\n");
printf("\t<div id=menutab>\n");
printf("\t\t<div id=topline>\n");
printf("\t\t\t<ol>\n");
//Main always exists for RAD
printf("\t\t\t<li");
if(strncmp(gcFunction,"Main",4))
printf(">\n");
else
printf(" id=current>\n");
printf("\t\t\t<a title='Home start page' href=unxsVZ.cgi?gcFunction=Main>Main</a>\n");
printf("\t\t\t</li>\n");
if(guSSLCookieLogin)
{
//tDatacenter
if(guPermLevel>=7)
{
printf("\t\t\t<li");
if(strcmp(gcFunction,"tDatacenter") && strcmp(gcFunction,"tDatacenterTools") &&
strcmp(gcFunction,"tDatacenterList"))
printf(">\n");
else
printf(" id=current>\n");
printf("\t\t\t<a title='Datacenter' href=unxsVZ.cgi?gcFunction=tDatacenter>tDatacenter</a>\n");
}
//tNode
if(guPermLevel>=6)
{
printf("\t\t\t<li");
if(strcmp(gcFunction,"tNode") && strcmp(gcFunction,"tNodeTools") &&
strcmp(gcFunction,"tNodeList"))
printf(">\n");
else
printf(" id=current>\n");
printf("\t\t\t<a title='Hardware node' href=unxsVZ.cgi?gcFunction=tNode>tNode</a>\n");
}
//tContainer
if(guPermLevel>=7)
{
printf("\t\t\t<li");
if(strcmp(gcFunction,"tContainer") && strcmp(gcFunction,"tContainerTools") &&
strcmp(gcFunction,"tContainerList"))
printf(">\n");
else
printf(" id=current>\n");
printf("\t\t\t<a title='OpenVZ Container' href=unxsVZ.cgi?gcFunction=tContainer>tContainer</a>\n");
}
//tProperty
if(!strcmp(gcFunction,"tProperty") || !strcmp(gcFunction,"tPropertyTools") || !strcmp(gcFunction,"tPropertyList"))
printf("\t\t\t<li id=current>\t\t\t<a title='Shared property table' href=unxsVZ.cgi?gcFunction=tProperty>tProperty</a>\n");
//tType
if(guPermLevel>=20)
{
printf("\t\t\t<li");
if(strcmp(gcFunction,"tType") && strcmp(gcFunction,"tTypeTools") &&
strcmp(gcFunction,"tTypeList"))
printf(">\n");
else
printf(" id=current>\n");
printf("\t\t\t<a title='Property Type' href=unxsVZ.cgi?gcFunction=tType>tType</a>\n");
}
//tContainerType
if(guPermLevel>=20)
{
printf("\t\t\t<li");
if(strcmp(gcFunction,"tContainerType") && strcmp(gcFunction,"tContainerTypeTools") &&
strcmp(gcFunction,"tContainerTypeList"))
printf(">\n");
else
printf(" id=current>\n");
printf("\t\t\t<a title='Property Type' href=unxsVZ.cgi?gcFunction=tContainerType>tContainerType</a>\n");
}
//tPerm
if(guPermLevel>=20)
{
printf("\t\t\t<li");
if(strcmp(gcFunction,"tPerm") && strcmp(gcFunction,"tPermTools") &&
strcmp(gcFunction,"tPermList"))
printf(">\n");
else
printf(" id=current>\n");
printf("\t\t\t<a title='Granular permissions control table' href=unxsVZ.cgi?gcFunction=tPerm>tPerm</a>\n");
}
//tOSTemplate
if(guPermLevel>=20)
{
printf("\t\t\t<li");
if(strcmp(gcFunction,"tOSTemplate") && strcmp(gcFunction,"tOSTemplateTools") &&
strcmp(gcFunction,"tOSTemplateList"))
printf(">\n");
else
printf(" id=current>\n");
printf("\t\t\t<a title='Container OS Template' href=unxsVZ.cgi?gcFunction=tOSTemplate>tOSTemplate</a>\n");
}
//tNameserver
if(guPermLevel>=20)
{
printf("\t\t\t<li");
if(strcmp(gcFunction,"tNameserver") && strcmp(gcFunction,"tNameserverTools") &&
strcmp(gcFunction,"tNameserverList"))
printf(">\n");
else
printf(" id=current>\n");
printf("\t\t\t<a title='Container Resolver Nameserver Set' href=unxsVZ.cgi?gcFunction=tNameserver>tNameserver</a>\n");
}
//tSearchdomain
if(guPermLevel>=20)
{
printf("\t\t\t<li");
if(strcmp(gcFunction,"tSearchdomain") && strcmp(gcFunction,"tSearchdomainTools") &&
strcmp(gcFunction,"tSearchdomainList"))
printf(">\n");
else
printf(" id=current>\n");
printf("\t\t\t<a title='Container Resolver Searchdomain' href=unxsVZ.cgi?gcFunction=tSearchdomain>tSearchdomain</a>\n");
}
//tConfig
if(guPermLevel>=20)
{
printf("\t\t\t<li");
if(strcmp(gcFunction,"tConfig") && strcmp(gcFunction,"tConfigTools") &&
strcmp(gcFunction,"tConfigList"))
printf(">\n");
else
printf(" id=current>\n");
printf("\t\t\t<a title='Config File Used on Creation' href=unxsVZ.cgi?gcFunction=tConfig>tConfig</a>\n");
}
//tIP
if(guPermLevel>=10)
{
printf("\t\t\t<li");
if(strcmp(gcFunction,"tIP") && strcmp(gcFunction,"tIPTools") &&
strcmp(gcFunction,"tIPList"))
printf(">\n");
else
printf(" id=current>\n");
printf("\t\t\t<a title='IPs used and reserved for use' href=unxsVZ.cgi?gcFunction=tIP>tIP</a>\n");
}
//tGroupType
if(guPermLevel>=20)
{
printf("\t\t\t<li");
if(strcmp(gcFunction,"tGroupType") && strcmp(gcFunction,"tGroupTypeTools") &&
strcmp(gcFunction,"tGroupTypeList"))
printf(">\n");
else
printf(" id=current>\n");
printf("\t\t\t<a title='Container or node group type' href=unxsVZ.cgi?gcFunction=tGroupType>tGroupType</a>\n");
}
//tGroup
if(guPermLevel>=10)
{
printf("\t\t\t<li");
if(strcmp(gcFunction,"tGroup") && strcmp(gcFunction,"tGroupTools") &&
strcmp(gcFunction,"tGroupList"))
printf(">\n");
else
printf(" id=current>\n");
printf("\t\t\t<a title='Container or node group' href=unxsVZ.cgi?gcFunction=tGroup>tGroup</a>\n");
}
//tGroupGlue
if(guPermLevel>=20)
{
printf("\t\t\t<li");
if(strcmp(gcFunction,"tGroupGlue") && strcmp(gcFunction,"tGroupGlueTools") &&
strcmp(gcFunction,"tGroupGlueList"))
printf(">\n");
else
printf(" id=current>\n");
printf("\t\t\t<a title='Glues uContainers or uNodes to uGroups' href=unxsVZ.cgi?gcFunction=tGroupGlue>tGroupGlue</a>\n");
}
//tClient
if(guPermLevel>=10)
{
printf("\t\t\t<li");
if(strcmp(gcFunction,"tClient") && strcmp(gcFunction,"tClientTools") &&
strcmp(gcFunction,"tClientList"))
printf(">\n");
else
printf(" id=current>\n");
printf("\t\t\t<a title='Client Info' href=unxsVZ.cgi?gcFunction=tClient>tClient</a>\n");
}
//tAuthorize
if(!strcmp(gcFunction,"tAuthorize") || !strcmp(gcFunction,"tAuthorizeTools") || !strcmp(gcFunction,"tAuthorizeList"))
printf("\t\t\t<li id=current>\t\t\t<a title='Login Authorization' href=unxsVZ.cgi?gcFunction=tAuthorize>tAuthorize</a>\n");
//tTemplate
if(guPermLevel>=20)
{
printf("\t\t\t<li");
if(strcmp(gcFunction,"tTemplate") && strcmp(gcFunction,"tTemplateTools") &&
strcmp(gcFunction,"tTemplateList"))
printf(">\n");
else
printf(" id=current>\n");
printf("\t\t\t<a title='tTemplate' href=unxsVZ.cgi?gcFunction=tTemplate>tTemplate</a>\n");
}
//tTemplateSet
if(guPermLevel>=20)
{
printf("\t\t\t<li");
if(strcmp(gcFunction,"tTemplateSet") && strcmp(gcFunction,"tTemplateSetTools") &&
strcmp(gcFunction,"tTemplateSetList"))
printf(">\n");
else
printf(" id=current>\n");
printf("\t\t\t<a title='tTemplateSet' href=unxsVZ.cgi?gcFunction=tTemplateSet>tTemplateSet</a>\n");
}
//tTemplateType
if(guPermLevel>=20)
{
printf("\t\t\t<li");
if(strcmp(gcFunction,"tTemplateType") && strcmp(gcFunction,"tTemplateTypeTools") &&
strcmp(gcFunction,"tTemplateTypeList"))
printf(">\n");
else
printf(" id=current>\n");
printf("\t\t\t<a title='tTemplateType' href=unxsVZ.cgi?gcFunction=tTemplateType>tTemplateType</a>\n");
}
//tLog
if(guPermLevel>=20)
{
printf("\t\t\t<li");
if(strcmp(gcFunction,"tLog") && strcmp(gcFunction,"tLogTools") &&
strcmp(gcFunction,"tLogList"))
printf(">\n");
else
printf(" id=current>\n");
printf("\t\t\t<a title='tLog' href=unxsVZ.cgi?gcFunction=tLog>tLog</a>\n");
}
//tLogType
if(guPermLevel>=20)
{
printf("\t\t\t<li");
if(strcmp(gcFunction,"tLogType") && strcmp(gcFunction,"tLogTypeTools") &&
strcmp(gcFunction,"tLogTypeList"))
printf(">\n");
else
printf(" id=current>\n");
printf("\t\t\t<a title='tLogType' href=unxsVZ.cgi?gcFunction=tLogType>tLogType</a>\n");
}
//tLogMonth
if(guPermLevel>=20)
{
printf("\t\t\t<li");
if(strcmp(gcFunction,"tLogMonth") && strcmp(gcFunction,"tLogMonthTools") &&
strcmp(gcFunction,"tLogMonthList"))
printf(">\n");
else
printf(" id=current>\n");
printf("\t\t\t<a title='tLogMonth' href=unxsVZ.cgi?gcFunction=tLogMonth>tLogMonth</a>\n");
}
//tMonth
if(guPermLevel>=20)
{
printf("\t\t\t<li");
if(strcmp(gcFunction,"tMonth") && strcmp(gcFunction,"tMonthTools") &&
strcmp(gcFunction,"tMonthList"))
printf(">\n");
else
printf(" id=current>\n");
printf("\t\t\t<a title='tMonth' href=unxsVZ.cgi?gcFunction=tMonth>tMonth</a>\n");
}
//tGlossary
if(guPermLevel>=20)
{
printf("\t\t\t<li");
if(strcmp(gcFunction,"tGlossary") && strcmp(gcFunction,"tGlossaryTools") &&
strcmp(gcFunction,"tGlossaryList"))
printf(">\n");
else
printf(" id=current>\n");
printf("\t\t\t<a title='tGlossary' href=unxsVZ.cgi?gcFunction=tGlossary>tGlossary</a>\n");
}
//tJob
if(guPermLevel>=7)
{
printf("\t\t\t<li");
if(strcmp(gcFunction,"tJob") && strcmp(gcFunction,"tJobTools") &&
strcmp(gcFunction,"tJobList"))
printf(">\n");
else
printf(" id=current>\n");
printf("\t\t\t<a title='tJob' href=unxsVZ.cgi?gcFunction=tJob>tJob</a>\n");
}
//tJobStatus
if(guPermLevel>=20)
{
printf("\t\t\t<li");
if(strcmp(gcFunction,"tJobStatus") && strcmp(gcFunction,"tJobStatusTools") &&
strcmp(gcFunction,"tJobStatusList"))
printf(">\n");
else
printf(" id=current>\n");
printf("\t\t\t<a title='tJobStatus' href=unxsVZ.cgi?gcFunction=tJobStatus>tJobStatus</a>\n");
}
//tStatus
if(guPermLevel>=20)
{
printf("\t\t\t<li");
if(strcmp(gcFunction,"tStatus") && strcmp(gcFunction,"tStatusTools") &&
strcmp(gcFunction,"tStatusList"))
printf(">\n");
else
printf(" id=current>\n");
printf("\t\t\t<a title='tStatus' href=unxsVZ.cgi?gcFunction=tStatus>tStatus</a>\n");
}
//tFWStatus
if(guPermLevel>=20)
{
printf("\t\t\t<li");
if(strcmp(gcFunction,"tFWStatus") && strcmp(gcFunction,"tFWStatusTools") &&
strcmp(gcFunction,"tFWStatusList"))
printf(">\n");
else
printf(" id=current>\n");
printf("\t\t\t<a title='tFWStatus' href=unxsVZ.cgi?gcFunction=tFWStatus>tFWStatus</a>\n");
}
//tIPType
if(guPermLevel>=20)
{
printf("\t\t\t<li");
if(strcmp(gcFunction,"tIPType") && strcmp(gcFunction,"tIPTypeTools") &&
strcmp(gcFunction,"tIPTypeList"))
printf(">\n");
else
printf(" id=current>\n");
printf("\t\t\t<a title='tIPType' href=unxsVZ.cgi?gcFunction=tIPType>tIPType</a>\n");
}
//tFWRule
if(guPermLevel>=20)
{
printf("\t\t\t<li");
if(strcmp(gcFunction,"tFWRule") && strcmp(gcFunction,"tFWRuleTools") &&
strcmp(gcFunction,"tFWRuleList"))
printf(">\n");
else
printf(" id=current>\n");
printf("\t\t\t<a title='tFWRule' href=unxsVZ.cgi?gcFunction=tFWRule>tFWRule</a>\n");
}
//tConfiguration
if(guPermLevel>=20)
{
printf("\t\t\t<li");
if(strcmp(gcFunction,"tConfiguration") && strcmp(gcFunction,"tConfigurationTools") &&
strcmp(gcFunction,"tConfigurationList"))
printf(">\n");
else
printf(" id=current>\n");
printf("\t\t\t<a title='tConfiguration' href=unxsVZ.cgi?gcFunction=tConfiguration>tConfiguration</a>\n");
}
}
printf("\t\t\t</ol>\n");
printf("\t\t\t<br class=clearall >\n");
printf("\t\t</div>\n");
printf("\t</div>\n");
printf("</div>\n");
}//Header_ism3(char *title, int js)
void Footer_ism3(void)
{
printf("</blockquote>");
mysql_close(&gMysql);
exit(0);
}//Footer_ism3(void)
void NoSuchFunction(void)
{
sprintf(gcQuery,"[%s] Not Recognized",gcFunction);
unxsVZ(gcQuery);
}
void ProcessControlVars(pentry entries[], int x)
{
register int i;
for(i=0;i<x;i++)
{
if(!strcmp(entries[i].name,"gcFilter"))
sprintf(gcFilter,"%.99s",entries[i].val);
else if(!strcmp(entries[i].name,"gcAuxFilter"))
sprintf(gcAuxFilter,"%.255s",entries[i].val);
else if(!strcmp(entries[i].name,"gcCommand"))
sprintf(gcCommand,"%.99s",entries[i].val);
else if(!strcmp(entries[i].name,"gcFind"))
sprintf(gcFind,"%.99s",entries[i].val);
else if(!strcmp(entries[i].name,"gluRowid"))
sscanf(entries[i].val,"%lu",&gluRowid);
else if(!strcmp(entries[i].name,"gcPage"))
sprintf(gcPage,"%.99s",entries[i].val);
}
}