root/trunk/tostemplatefunc.h

Revision 1918, 18.8 KB (checked in by Dylan, 4 weeks ago)

unxsVZ fixed clone node IP allocation logic bug.

  • Property svn:keywords set to id
Line 
1/*
2FILE
3        $Id$
4        (Built initially by unixservice.com mysqlRAD2)
5PURPOSE
6        Non schema-dependent table and application table related functions.
7AUTHOR
8        (C) 2001-2009 Unixservice, LLC.
9 
10*/
11
12
13void tOSTemplateNavList(void);
14unsigned htmlOSTemplateContext(void);
15unsigned LocalImportTemplateJob(unsigned uOSTemplate);
16
17//file scoped var
18static unsigned uDatacenter=0;
19static char cuDatacenterPullDown[256]={""};
20
21void ExtProcesstOSTemplateVars(pentry entries[], int x)
22{
23        register int i;
24        for(i=0;i<x;i++)
25        {
26                if(!strcmp(entries[i].name,"uDatacenter"))
27                        sscanf(entries[i].val,"%u",&uDatacenter);
28                else if(!strcmp(entries[i].name,"cuDatacenterPullDown"))
29                {
30                        sprintf(cuDatacenterPullDown,"%.255s",entries[i].val);
31                        uDatacenter=ReadPullDown("tDatacenter","cLabel",cuDatacenterPullDown);
32                }
33        }
34}//void ExtProcesstOSTemplateVars(pentry entries[], int x)
35
36
37void ExttOSTemplateCommands(pentry entries[], int x)
38{
39
40        if(!strcmp(gcFunction,"tOSTemplateTools"))
41        {
42                MYSQL_RES *res;
43                long unsigned luActualModDate=-1;
44
45                if(!strcmp(gcCommand,LANG_NB_NEW))
46                {
47                        if(guPermLevel>=10)
48                        {
49                                ProcesstOSTemplateVars(entries,x);
50                                guMode=2000;
51                                tOSTemplate(LANG_NB_CONFIRMNEW);
52                        }
53                }
54                else if(!strcmp(gcCommand,LANG_NB_CONFIRMNEW))
55                {
56                        if(guPermLevel>=10)
57                        {
58                                ProcesstOSTemplateVars(entries,x);
59
60                                guMode=2000;
61                                //Check entries here
62                                if(strlen(cLabel)<3)
63                                        tOSTemplate("<blink>Error</blink>: cLabel too short!");
64                                sprintf(gcQuery,"SELECT uOSTemplate FROM tOSTemplate WHERE cLabel='%s'",cLabel);
65                                mysql_query(&gMysql,gcQuery);
66                                if(mysql_errno(&gMysql))
67                                                htmlPlainTextError(mysql_error(&gMysql));
68                                res=mysql_store_result(&gMysql);
69                                if(mysql_num_rows(res))
70                                {
71                                        mysql_free_result(res);
72                                        tOSTemplate("<blink>Error</blink>: tOSTemplate.cLabel already in use!");
73                                }
74                                guMode=0;
75
76                                uOSTemplate=0;
77                                uCreatedBy=guLoginClient;
78                                uOwner=guCompany;
79                                uModBy=0;//Never modified
80                                uModDate=0;//Never modified
81                                NewtOSTemplate(1);
82                                if(!uOSTemplate)
83                                        tOSTemplate("<blink>Error</blink>: New tOSTemplate entry was not created!");
84
85                                sprintf(gcQuery,"INSERT INTO tProperty SET uKey=%u,uType="PROP_OSTEMPLATE
86                                                ",cName='cDatacenter',cValue='All Datacenters',uOwner=%u,uCreatedBy=%u"
87                                                ",uCreatedDate=UNIX_TIMESTAMP(NOW())"
88                                                        ,uOSTemplate,guCompany,guLoginClient);
89                                mysql_query(&gMysql,gcQuery);
90                                if(mysql_errno(&gMysql))
91                                                htmlPlainTextError(mysql_error(&gMysql));
92                                tOSTemplate("New OS template created");
93                        }
94                }
95                else if(!strcmp(gcCommand,LANG_NB_DELETE))
96                {
97                        ProcesstOSTemplateVars(entries,x);
98                        if(uAllowDel(uOwner,uCreatedBy))
99                        {
100                                guMode=0;
101                                sscanf(ForeignKey("tOSTemplate","uModDate",uOSTemplate),"%lu",&luActualModDate);
102                                if(uModDate!=luActualModDate)
103                                        tOSTemplate("<blink>Error</blink>: This record was modified. Reload it!");
104                                sprintf(gcQuery,"SELECT uOSTemplate FROM tContainer WHERE uOSTemplate=%u",
105                                                uOSTemplate);
106                                mysql_query(&gMysql,gcQuery);
107                                if(mysql_errno(&gMysql))
108                                                htmlPlainTextError(mysql_error(&gMysql));
109                                res=mysql_store_result(&gMysql);
110                                if(mysql_num_rows(res))
111                                {
112                                        mysql_free_result(res);
113                                        tOSTemplate("<blink>Error</blink>: Can't delete a template used by a container!");
114                                }
115                                guMode=2001;
116                                tOSTemplate(LANG_NB_CONFIRMMOD);
117                        }
118                }
119                else if(!strcmp(gcCommand,LANG_NB_CONFIRMDEL))
120                {
121                        ProcesstOSTemplateVars(entries,x);
122                        if(uAllowDel(uOwner,uCreatedBy))
123                        {
124                                guMode=5;
125                                sscanf(ForeignKey("tOSTemplate","uModDate",uOSTemplate),"%lu",&luActualModDate);
126                                if(uModDate!=luActualModDate)
127                                        tOSTemplate("<blink>Error</blink>: This record was modified. Reload it!");
128                                sprintf(gcQuery,"SELECT uOSTemplate FROM tContainer WHERE uOSTemplate=%u",
129                                                uOSTemplate);
130                                mysql_query(&gMysql,gcQuery);
131                                if(mysql_errno(&gMysql))
132                                                htmlPlainTextError(mysql_error(&gMysql));
133                                res=mysql_store_result(&gMysql);
134                                if(mysql_num_rows(res))
135                                {
136                                        mysql_free_result(res);
137                                        tOSTemplate("<blink>Error</blink>: Can't delete a template used by a container!");
138                                }
139                                DeletetOSTemplate();
140                        }
141                }
142                else if(!strcmp(gcCommand,LANG_NB_MODIFY))
143                {
144                        ProcesstOSTemplateVars(entries,x);
145                        if(uAllowMod(uOwner,uCreatedBy))
146                        {
147                                guMode=2002;
148                                sscanf(ForeignKey("tOSTemplate","uModDate",uOSTemplate),"%lu",&luActualModDate);
149                                if(uModDate!=luActualModDate)
150                                        tOSTemplate("<blink>Error</blink>: This record was modified. Reload it!");
151                                tOSTemplate(LANG_NB_CONFIRMMOD);
152                        }
153                }
154                else if(!strcmp(gcCommand,LANG_NB_CONFIRMMOD))
155                {
156                        ProcesstOSTemplateVars(entries,x);
157                        if(uAllowMod(uOwner,uCreatedBy))
158                        {
159                                guMode=2002;
160                                //Check entries here
161                                sprintf(gcQuery,"SELECT uOSTemplate FROM tContainer WHERE uOSTemplate=%u",
162                                                uOSTemplate);
163                                mysql_query(&gMysql,gcQuery);
164                                if(mysql_errno(&gMysql))
165                                                htmlPlainTextError(mysql_error(&gMysql));
166                                res=mysql_store_result(&gMysql);
167                                if(mysql_num_rows(res))
168                                {
169                                        mysql_free_result(res);
170                                        tOSTemplate("<blink>Error</blink>: Can't modify a template used by a container!");
171                                }
172                                sscanf(ForeignKey("tOSTemplate","uModDate",uOSTemplate),"%lu",&luActualModDate);
173                                if(uModDate!=luActualModDate)
174                                        tOSTemplate("<blink>Error</blink>: This record was modified. Reload it!");
175                                if(strlen(cLabel)<3)
176                                        tOSTemplate("<blink>Error</blink>: cLabel too short!");
177                                guMode=0;
178
179                                uModBy=guLoginClient;
180                                ModtOSTemplate();
181                        }
182                }
183                else if(!strcmp(gcCommand,"Local Import"))
184                {
185                        if(guPermLevel>=10)
186                        {
187                                ProcesstOSTemplateVars(entries,x);
188                                guMode=6;
189                                if(uOSTemplate<1)
190                                        tOSTemplate("<blink>Error</blink>: Unexpected uOSTemplate&lt;1 error!");
191
192                                sprintf(gcQuery,"SELECT uOSTemplate FROM tContainer WHERE uOSTemplate=%u",
193                                                uOSTemplate);
194                                mysql_query(&gMysql,gcQuery);
195                                if(mysql_errno(&gMysql))
196                                                htmlPlainTextError(mysql_error(&gMysql));
197                                res=mysql_store_result(&gMysql);
198                                if(mysql_num_rows(res))
199                                {
200                                        mysql_free_result(res);
201                                        tOSTemplate("<blink>Error</blink>: Can't import a template already in use!");
202                                }
203                                sscanf(ForeignKey("tOSTemplate","uModDate",uOSTemplate),"%lu",&luActualModDate);
204                                if(uModDate!=luActualModDate)
205                                        tOSTemplate("<blink>Error</blink>: This record was modified. Reload it!");
206                                if(strlen(cLabel)<3)
207                                        tOSTemplate("<blink>Error</blink>: cLabel too short!");
208                               
209                                if(LocalImportTemplateJob(uOSTemplate))
210                                        tOSTemplate("Local Import job created");
211                                else
212                                        tOSTemplate("<blink>Error</blink>: LocalImportTemplateJob() failed!");
213                        }
214                }
215                else if(!strcmp(gcCommand,"Enable"))
216                {
217                        ProcesstOSTemplateVars(entries,x);
218                        if(uAllowMod(uOwner,uCreatedBy))
219                        {
220                                guMode=6;
221                                sscanf(ForeignKey("tOSTemplate","uModDate",uOSTemplate),"%lu",&luActualModDate);
222                                if(uModDate!=luActualModDate)
223                                        tOSTemplate("<blink>Error</blink>: This record was modified. Reload it.");
224                                if(!uDatacenter)
225                                        sprintf(gcQuery,"INSERT tProperty SET cName='cDatacenter',cValue='All Datacenters',"
226                                                "uType=%u,uKey=%u,uOwner=%u,uCreatedBy=%u,uCreatedDate=UNIX_TIMESTAMP(NOW())",
227                                                uPROP_OSTEMPLATE,uOSTemplate,uOwner,guLoginClient);
228                                else
229                                        sprintf(gcQuery,"INSERT tProperty SET cName='cDatacenter',cValue='%s',"
230                                                "uType=%u,uKey=%u,uOwner=%u,uCreatedBy=%u,uCreatedDate=UNIX_TIMESTAMP(NOW())",
231                                                ForeignKey("tDatacenter","cLabel",uDatacenter),
232                                                uPROP_OSTEMPLATE,uOSTemplate,uOwner,guLoginClient);
233                                mysql_query(&gMysql,gcQuery);
234                                if(mysql_errno(&gMysql))
235                                                htmlPlainTextError(mysql_error(&gMysql));
236                        }
237                        else
238                        {
239                                tOSTemplate("<blink>Error</blink>: Enable not allowed!");
240                        }
241                }
242                else if(!strcmp(gcCommand,"Disable"))
243                {
244                        ProcesstOSTemplateVars(entries,x);
245                        if(uAllowMod(uOwner,uCreatedBy))
246                        {
247                                guMode=6;
248                                sscanf(ForeignKey("tOSTemplate","uModDate",uOSTemplate),"%lu",&luActualModDate);
249                                if(uModDate!=luActualModDate)
250                                        tOSTemplate("<blink>Error</blink>: This record was modified. Reload it.");
251                                if(!uDatacenter)
252                                        //Delete all
253                                        sprintf(gcQuery,"DELETE FROM tProperty WHERE cName='cDatacenter'"
254                                                " AND uType=%u AND uKey=%u AND (uOwner=%u OR uCreatedBy=%u)",
255                                                uPROP_OSTEMPLATE,uOSTemplate,guCompany,guLoginClient);
256                                else
257                                        sprintf(gcQuery,"DELETE FROM tProperty WHERE cName='cDatacenter' AND cValue='%s'"
258                                                " AND uType=%u AND uKey=%u AND (uOwner=%u OR uCreatedBy=%u)",
259                                                ForeignKey("tDatacenter","cLabel",uDatacenter),
260                                                uPROP_OSTEMPLATE,uOSTemplate,guCompany,guLoginClient);
261                                mysql_query(&gMysql,gcQuery);
262                                if(mysql_errno(&gMysql))
263                                                htmlPlainTextError(mysql_error(&gMysql));
264                        }
265                        else
266                        {
267                                tOSTemplate("<blink>Error</blink>: Disable not allowed!");
268                        }
269                }
270                else if(!strcmp(gcCommand,"Clear All"))
271                {
272                        ProcesstOSTemplateVars(entries,x);
273                        if(uAllowMod(uOwner,uCreatedBy))
274                        {
275                                guMode=6;
276                                if(guCompany==1)
277                                        sprintf(gcQuery,"DELETE FROM tProperty WHERE cName='cDatacenter'"
278                                                " AND uType=%u",uPROP_OSTEMPLATE);
279                                else
280                                        sprintf(gcQuery,"DELETE FROM tProperty WHERE cName='cDatacenter'"
281                                                " AND uType=%u AND (uOwner=%u OR uCreatedBy=%u)",
282                                                uPROP_OSTEMPLATE,guCompany,guLoginClient);
283                                mysql_query(&gMysql,gcQuery);
284                                if(mysql_errno(&gMysql))
285                                                htmlPlainTextError(mysql_error(&gMysql));
286                                tOSTemplate("'Clear All' done");
287                        }
288                        else
289                        {
290                                tOSTemplate("<blink>Error</blink>: 'Clear All' not allowed!");
291                        }
292                }
293        }
294
295}//void ExttOSTemplateCommands(pentry entries[], int x)
296
297
298unsigned LocalImportTemplateJob(unsigned uOSTemplate)
299{
300        MYSQL_RES *res;
301        MYSQL_ROW field;
302        unsigned uCount=0;
303        unsigned uNode=0;
304        unsigned uDatacenter=0;
305        char cHostname[100];
306
307        if(gethostname(cHostname,99)!=0)
308                return(0);
309
310        sprintf(gcQuery,"SELECT uNode,uDatacenter FROM tNode WHERE cLabel='%.99s'",cHostname);
311        mysql_query(&gMysql,gcQuery);
312        if(mysql_errno(&gMysql))
313                htmlPlainTextError(mysql_error(&gMysql));
314        res=mysql_store_result(&gMysql);
315        if((field=mysql_fetch_row(res)))
316        {
317                sscanf(field[0],"%u",&uNode);
318                sscanf(field[1],"%u",&uDatacenter);
319        }
320        mysql_free_result(res);
321
322        if(!uNode || !uDatacenter || !uOSTemplate)
323                return(0);
324
325        sprintf(gcQuery,"INSERT INTO tJob SET cLabel='LocalImportTemplateJob(%u)',cJobName='LocalImportTemplateJob'"
326                        ",uDatacenter=%u,uNode=%u,uContainer=0"
327                        ",uJobDate=UNIX_TIMESTAMP(NOW())"
328                        ",uJobStatus=1"
329                        ",cJobData='uOSTemplate=%u;'"
330                        ",uOwner=%u,uCreatedBy=%u,uCreatedDate=UNIX_TIMESTAMP(NOW())",
331                                uOSTemplate,
332                                uDatacenter,uNode,uOSTemplate,
333                                uOwner,guLoginClient);
334        mysql_query(&gMysql,gcQuery);
335        if(mysql_errno(&gMysql))
336                htmlPlainTextError(mysql_error(&gMysql));
337        uCount=mysql_insert_id(&gMysql);
338        unxsVZLog(uOSTemplate,"tOSTemplate","LocalImport");
339        return(uCount);
340
341}//unsigned LocalImportTemplateJob(...)
342
343
344unsigned htmlOSTemplateContext(void)
345{
346        unsigned uRows=0;
347        MYSQL_RES *res;
348
349        sprintf(gcQuery,"SELECT uOSTemplate FROM tContainer WHERE uOSTemplate=%u",uOSTemplate);
350        mysql_query(&gMysql,gcQuery);
351        if(mysql_errno(&gMysql))
352                htmlPlainTextError(mysql_error(&gMysql));
353        res=mysql_store_result(&gMysql);
354        uRows=mysql_num_rows(res);
355        printf("Used by %u containers.",uRows);
356        mysql_free_result(res);
357
358        return(uRows);
359
360}//unsigned htmlOSTemplateContext(void)
361
362
363void ExttOSTemplateButtons(void)
364{
365        unsigned uNum=0;
366
367        OpenFieldSet("tOSTemplate Aux Panel",100);
368        switch(guMode)
369        {
370                case 2000:
371                        printf("<p><u>Enter/mod data</u><br>");
372                        printf(LANG_NBB_CONFIRMNEW);
373                break;
374
375                case 2001:
376                        printf("<p><u>Think twice</u><br>");
377                        printf(LANG_NBB_CONFIRMDEL);
378                break;
379
380                case 2002:
381                        printf("<p><u>Review changes</u><br>");
382                        printf(LANG_NBB_CONFIRMMOD);
383                break;
384
385                default:
386
387                        printf("<u>Table Tips</u><br>");
388                        printf("Make sure that the cLabel entries (new or modified) have a corresponding "
389                                "/vz/template/cache/&lt;cLabel&gt;.tar.gz file on all unxsVZ controlled "
390                                "nodes. Please note the 32 character limitation on older versions of the "
391                                "software (limit is now 100 chars.)"
392                                "<p><u>Automated way to install an external template</u><br>"
393                                "1-. Transfer &lt;unused tOSTemplate.cLabel&gt;.tar.gz to a node with a local "
394                                "unxsVZ webmin and place in /vz/template/cache.<br>"
395                                "2-. Transfer &lt;unused tOSTemplate.cLabel&gt;.tar.gz.md5sum to a node with a local "
396                                "unxsVZ webmin and place in /vz/template/cache. This .md5sum file must correspond "
397                                "to to the file transferred in step 1-. This file must also have the expected md5sum "
398                                " command format with a fully qualified path to the tar.gz template file "
399                                "(see man md5sum for more info.)<br>"
400                                "3-. Run a [Local Import] job, after adding the new tOSTemplate.cLabel.<br>");
401                        printf("<p><u>Record Context Info</u><br>");
402                        uNum=htmlOSTemplateContext();
403                        tOSTemplateNavList();
404
405                        if(uOSTemplate>0 && uNum==0)
406                        {
407                                printf("<p><u>Extended table actions</u><br>");
408                                printf("<input class=largeButton title='Submit a job for the local import of the currently selected "
409                                        "template' type=submit name=gcCommand value='Local Import'>");
410                        }
411        }
412        CloseFieldSet();
413
414}//void ExttOSTemplateButtons(void)
415
416
417void ExttOSTemplateAuxTable(void)
418{
419        if(!uOSTemplate || guMode==2000 )//uMODE_NEW
420                return;
421
422        MYSQL_RES *res;
423        MYSQL_ROW field;
424
425        sprintf(gcQuery,"tOSTemplate %s Property Panel",cLabel);
426        OpenFieldSet(gcQuery,100);
427        sprintf(gcQuery,"SELECT uProperty,cName,cValue FROM tProperty WHERE uKey=%u AND uType="PROP_OSTEMPLATE
428                        " ORDER BY cName",uOSTemplate);
429
430        mysql_query(&gMysql,gcQuery);
431        if(mysql_errno(&gMysql))
432                htmlPlainTextError(mysql_error(&gMysql));
433
434        res=mysql_store_result(&gMysql);
435        printf("<table cols=2>");
436        if(mysql_num_rows(res))
437        {
438                while((field=mysql_fetch_row(res)))
439                {
440                        printf("<tr>\n");
441                        printf("<td width=200 valign=top><a class=darkLink href=unxsVZ.cgi?"
442                                        "gcFunction=tProperty&uProperty=%s&cReturn=tOSTemplate_%u>"
443                                        "%s</a></td><td>%s</td>\n",
444                                                field[0],uOSTemplate,field[1],field[2]);
445                        printf("</tr>\n");
446                }
447        }
448
449        //Simple interface to add to tConfiguration table
450        if(uAllowMod(uOwner,uCreatedBy))
451        {
452                printf("<tr>");
453                printf("<td width=200 valign=top><input type=submit class=largeButton"
454                " title='Enable for one or more datacenters; for new container creation'"
455                " name=gcCommand value='Enable'><p>");
456                printf("<input type=submit class=largeButton"
457                " title='Disable for one or more datacenters; for new container creation'"
458                " name=gcCommand value='Disable'><p>");
459                printf("<input type=submit class=lwarnButton"
460                " title='Clear all templates from tProperty association'"
461                " name=gcCommand value='Clear All'></td>");
462                printf("<td valign=top> Select a datacenter or none (---) for all ");
463                tTablePullDown("tDatacenter;cuDatacenterPullDown","cLabel","cLabel",uDatacenter,1);
464                printf("</td>");
465                printf("</tr>\n");
466        }
467       
468        printf("</table>");
469
470        CloseFieldSet();
471
472}//void ExttOSTemplateAuxTable(void)
473
474
475void ExttOSTemplateGetHook(entry gentries[], int x)
476{
477        register int i;
478
479        for(i=0;i<x;i++)
480        {
481                if(!strcmp(gentries[i].name,"uOSTemplate"))
482                {
483                        sscanf(gentries[i].val,"%u",&uOSTemplate);
484                        guMode=6;
485                }
486        }
487        tOSTemplate("");
488
489}//void ExttOSTemplateGetHook(entry gentries[], int x)
490
491
492void ExttOSTemplateSelect(void)
493{
494        ExtSelect("tOSTemplate",VAR_LIST_tOSTemplate);
495
496}//void ExttOSTemplateSelect(void)
497
498
499void ExttOSTemplateSelectRow(void)
500{
501        ExtSelectRow("tOSTemplate",VAR_LIST_tOSTemplate,uOSTemplate);
502
503}//void ExttOSTemplateSelectRow(void)
504
505
506void ExttOSTemplateListSelect(void)
507{
508        char cCat[512];
509
510        ExtListSelect("tOSTemplate",VAR_LIST_tOSTemplate);
511       
512        //Changes here must be reflected below in ExttOSTemplateListFilter()
513        if(!strcmp(gcFilter,"uOSTemplate"))
514        {
515                sscanf(gcCommand,"%u",&uOSTemplate);
516                if(guLoginClient==1 && guPermLevel>11)
517                        strcat(gcQuery," WHERE ");
518                else
519                        strcat(gcQuery," AND ");
520                sprintf(cCat,"tOSTemplate.uOSTemplate=%u ORDER BY uOSTemplate",uOSTemplate);
521                strcat(gcQuery,cCat);
522        }
523        else if(1)
524        {
525                //None NO FILTER
526                strcpy(gcFilter,"None");
527                strcat(gcQuery," ORDER BY uOSTemplate");
528        }
529
530}//void ExttOSTemplateListSelect(void)
531
532
533void ExttOSTemplateListFilter(void)
534{
535        //Filter
536        printf("&nbsp;&nbsp;&nbsp;Filter on ");
537        printf("<select name=gcFilter>");
538        if(strcmp(gcFilter,"uOSTemplate"))
539                printf("<option>uOSTemplate</option>");
540        else
541                printf("<option selected>uOSTemplate</option>");
542        if(strcmp(gcFilter,"None"))
543                printf("<option>None</option>");
544        else
545                printf("<option selected>None</option>");
546        printf("</select>");
547
548}//void ExttOSTemplateListFilter(void)
549
550
551void ExttOSTemplateNavBar(void)
552{
553        printf(LANG_NBB_SKIPFIRST);
554        printf(LANG_NBB_SKIPBACK);
555        printf(LANG_NBB_SEARCH);
556
557        if(guPermLevel>=10 && !guListMode)
558                printf(LANG_NBB_NEW);
559
560        if(uAllowMod(uOwner,uCreatedBy))
561                printf(LANG_NBB_MODIFY);
562
563        if(uAllowDel(uOwner,uCreatedBy))
564                printf(LANG_NBB_DELETE);
565
566        if(uOwner)
567                printf(LANG_NBB_LIST);
568
569        printf(LANG_NBB_SKIPNEXT);
570        printf(LANG_NBB_SKIPLAST);
571        printf("&nbsp;&nbsp;&nbsp;\n");
572
573}//void ExttOSTemplateNavBar(void)
574
575
576void tOSTemplateNavList(void)
577{
578        MYSQL_RES *res;
579        MYSQL_ROW field;
580        MYSQL_RES *res2;
581
582        ExtSelect("tOSTemplate","tOSTemplate.uOSTemplate,tOSTemplate.cLabel");
583
584        mysql_query(&gMysql,gcQuery);
585        if(mysql_errno(&gMysql))
586        {
587                printf("<p><u>tOSTemplateNavList</u><br>\n");
588                printf("%s",mysql_error(&gMysql));
589                return;
590        }
591
592        res=mysql_store_result(&gMysql);
593        if(mysql_num_rows(res))
594        {       
595                printf("<p><u>tOSTemplateNavList</u><br>\n");
596
597               
598                while((field=mysql_fetch_row(res)))
599                {
600                        printf("<a class=darkLink href=unxsVZ.cgi?gcFunction=tOSTemplate"
601                                        "&uOSTemplate=%s>%s</a>",field[0],field[1]);
602                        sprintf(gcQuery,"SELECT uProperty FROM tProperty WHERE uKey=%s AND uType="PROP_OSTEMPLATE"",field[0]);
603                        mysql_query(&gMysql,gcQuery);
604                        if(mysql_errno(&gMysql))
605                                printf("%s",mysql_error(&gMysql));
606                        res2=mysql_store_result(&gMysql);
607                        if(mysql_num_rows(res2))
608                                printf("*");
609                        printf("<br>\n");
610                                mysql_free_result(res2);
611                }
612        }
613        mysql_free_result(res);
614
615}//void tOSTemplateNavList(void)
616
617
Note: See TracBrowser for help on using the browser.