| 1 | /* |
|---|
| 2 | FILE |
|---|
| 3 | $Id$ |
|---|
| 4 | (Built initially by unixservice.com mysqlRAD2) |
|---|
| 5 | PURPOSE |
|---|
| 6 | Non schema-dependent table and application table related functions. |
|---|
| 7 | AUTHOR/LEGAL |
|---|
| 8 | (C) 2007-2010 Gary Wallis for Unixservice, LLC. |
|---|
| 9 | GPLv2 license applies. See LICENSE file included. |
|---|
| 10 | */ |
|---|
| 11 | |
|---|
| 12 | //ModuleFunctionProtos() |
|---|
| 13 | |
|---|
| 14 | void LogSummary(void); |
|---|
| 15 | |
|---|
| 16 | |
|---|
| 17 | void ExtProcesstLogVars(pentry entries[], int x) |
|---|
| 18 | { |
|---|
| 19 | /* |
|---|
| 20 | register int i; |
|---|
| 21 | for(i=0;i<x;i++) |
|---|
| 22 | { |
|---|
| 23 | } |
|---|
| 24 | */ |
|---|
| 25 | }//void ExtProcesstLogVars(pentry entries[], int x) |
|---|
| 26 | |
|---|
| 27 | |
|---|
| 28 | void ExttLogCommands(pentry entries[], int x) |
|---|
| 29 | { |
|---|
| 30 | |
|---|
| 31 | if(!strcmp(gcFunction,"tLogTools")) |
|---|
| 32 | { |
|---|
| 33 | |
|---|
| 34 | } |
|---|
| 35 | |
|---|
| 36 | }//void ExttLogCommands(pentry entries[], int x) |
|---|
| 37 | |
|---|
| 38 | |
|---|
| 39 | void ExttLogButtons(void) |
|---|
| 40 | { |
|---|
| 41 | OpenFieldSet("tLog Aux Panel",100); |
|---|
| 42 | |
|---|
| 43 | printf("<u>Table Tips</u><br>"); |
|---|
| 44 | printf("This table holds the non-archived logged and MD5 signed operations that have taken place in the system." |
|---|
| 45 | " Usually data is available here only for the current month. When possible context related info is" |
|---|
| 46 | " provided below. Current unxsVZ version does not save delete (Del) operation data.<p>" |
|---|
| 47 | "<a href=unxsVZ.cgi?gcFunction=tLogMonth>tLogMonth</a> allows access to all archived (read-only and" |
|---|
| 48 | " compressed) monthly tLog data sets. These archives are created from the command line usually by crontab" |
|---|
| 49 | " operation."); |
|---|
| 50 | LogSummary(); |
|---|
| 51 | CloseFieldSet(); |
|---|
| 52 | |
|---|
| 53 | }//void ExttLogButtons(void) |
|---|
| 54 | |
|---|
| 55 | |
|---|
| 56 | void ExttLogAuxTable(void) |
|---|
| 57 | { |
|---|
| 58 | |
|---|
| 59 | }//void ExttLogAuxTable(void) |
|---|
| 60 | |
|---|
| 61 | |
|---|
| 62 | void ExttLogGetHook(entry gentries[], int x) |
|---|
| 63 | { |
|---|
| 64 | register int i; |
|---|
| 65 | |
|---|
| 66 | for(i=0;i<x;i++) |
|---|
| 67 | { |
|---|
| 68 | if(!strcmp(gentries[i].name,"uLog")) |
|---|
| 69 | { |
|---|
| 70 | sscanf(gentries[i].val,"%u",&uLog); |
|---|
| 71 | guMode=6; |
|---|
| 72 | } |
|---|
| 73 | } |
|---|
| 74 | tLog(""); |
|---|
| 75 | |
|---|
| 76 | }//void ExttLogGetHook(entry gentries[], int x) |
|---|
| 77 | |
|---|
| 78 | |
|---|
| 79 | void ExttLogSelect(void) |
|---|
| 80 | { |
|---|
| 81 | ExtSelect("tLog",VAR_LIST_tLog); |
|---|
| 82 | |
|---|
| 83 | }//void ExttLogSelect(void) |
|---|
| 84 | |
|---|
| 85 | |
|---|
| 86 | void ExttLogSelectRow(void) |
|---|
| 87 | { |
|---|
| 88 | ExtSelectRow("tLog",VAR_LIST_tLog,uLog); |
|---|
| 89 | |
|---|
| 90 | }//void ExttLogSelectRow(void) |
|---|
| 91 | |
|---|
| 92 | |
|---|
| 93 | void ExttLogListSelect(void) |
|---|
| 94 | { |
|---|
| 95 | char cCat[512]; |
|---|
| 96 | |
|---|
| 97 | if(guLoginClient!=1 || guPermLevel<12) |
|---|
| 98 | return; |
|---|
| 99 | |
|---|
| 100 | ExtListSelect("tLog",VAR_LIST_tLog); |
|---|
| 101 | |
|---|
| 102 | //Changes here must be reflected below in ExttLogListFilter() |
|---|
| 103 | if(!strcmp(gcFilter,"uLog")) |
|---|
| 104 | { |
|---|
| 105 | sscanf(gcCommand,"%u",&uLog); |
|---|
| 106 | strcat(gcQuery," WHERE "); |
|---|
| 107 | sprintf(cCat,"tLog.uLog=%u ORDER BY uLog",uLog); |
|---|
| 108 | strcat(gcQuery,cCat); |
|---|
| 109 | } |
|---|
| 110 | else if(!strcmp(gcFilter,"cLabel")) |
|---|
| 111 | { |
|---|
| 112 | strcat(gcQuery," WHERE "); |
|---|
| 113 | sprintf(cCat,"tLog.cLabel='%s' ORDER BY uLog",gcCommand); |
|---|
| 114 | strcat(gcQuery,cCat); |
|---|
| 115 | } |
|---|
| 116 | else if(!strcmp(gcFilter,"uLogType")) |
|---|
| 117 | { |
|---|
| 118 | sscanf(gcCommand,"%u",&uLogType); |
|---|
| 119 | strcat(gcQuery," WHERE "); |
|---|
| 120 | sprintf(cCat,"tLog.uLogType=%u ORDER BY uLog",uLogType); |
|---|
| 121 | strcat(gcQuery,cCat); |
|---|
| 122 | } |
|---|
| 123 | else if(!strcmp(gcFilter,"uLoginClient")) |
|---|
| 124 | { |
|---|
| 125 | sscanf(gcCommand,"%u",&uLoginClient); |
|---|
| 126 | strcat(gcQuery," WHERE "); |
|---|
| 127 | sprintf(cCat,"tLog.uLoginClient=%u ORDER BY uLog",uLoginClient); |
|---|
| 128 | strcat(gcQuery,cCat); |
|---|
| 129 | } |
|---|
| 130 | else if(!strcmp(gcFilter,"cLogin")) |
|---|
| 131 | { |
|---|
| 132 | strcat(gcQuery," WHERE "); |
|---|
| 133 | sprintf(cCat,"tLog.cLogin LIKE '%s' ORDER BY cLogin,uLog",gcCommand); |
|---|
| 134 | strcat(gcQuery,cCat); |
|---|
| 135 | } |
|---|
| 136 | else if(!strcmp(gcFilter,"cHost")) |
|---|
| 137 | { |
|---|
| 138 | strcat(gcQuery," WHERE "); |
|---|
| 139 | sprintf(cCat,"tLog.cHost LIKE '%s' ORDER BY cHost,uLog",gcCommand); |
|---|
| 140 | strcat(gcQuery,cCat); |
|---|
| 141 | } |
|---|
| 142 | else if(!strcmp(gcFilter,"uTablePK")) |
|---|
| 143 | { |
|---|
| 144 | strcat(gcQuery," WHERE "); |
|---|
| 145 | sprintf(cCat,"tLog.uTablePK=%s ORDER BY cTableName,uTablePK,uLog",gcCommand); |
|---|
| 146 | strcat(gcQuery,cCat); |
|---|
| 147 | } |
|---|
| 148 | else if(!strcmp(gcFilter,"uZone")) |
|---|
| 149 | { |
|---|
| 150 | unsigned uZone=0; |
|---|
| 151 | |
|---|
| 152 | sscanf(gcCommand,"%u",&uZone); |
|---|
| 153 | sprintf(cCat,",tResource WHERE tLog.uTablePK=tResource.uResource AND cTableName='tResource'" |
|---|
| 154 | " AND tResource.uZone=%u",uZone); |
|---|
| 155 | strcat(gcQuery,cCat); |
|---|
| 156 | } |
|---|
| 157 | else if(1) |
|---|
| 158 | { |
|---|
| 159 | //None NO FILTER |
|---|
| 160 | strcpy(gcFilter,"None"); |
|---|
| 161 | strcat(gcQuery," ORDER BY uLog"); |
|---|
| 162 | } |
|---|
| 163 | |
|---|
| 164 | }//void ExttLogListSelect(void) |
|---|
| 165 | |
|---|
| 166 | |
|---|
| 167 | void ExttLogListFilter(void) |
|---|
| 168 | { |
|---|
| 169 | //Filter |
|---|
| 170 | printf(" Filter on "); |
|---|
| 171 | printf("<select name=gcFilter>"); |
|---|
| 172 | if(strcmp(gcFilter,"uLog")) |
|---|
| 173 | printf("<option>uLog</option>"); |
|---|
| 174 | else |
|---|
| 175 | printf("<option selected>uLog</option>"); |
|---|
| 176 | if(strcmp(gcFilter,"cLabel")) |
|---|
| 177 | printf("<option>cLabel</option>"); |
|---|
| 178 | else |
|---|
| 179 | printf("<option selected>cLabel</option>"); |
|---|
| 180 | if(strcmp(gcFilter,"uLogType")) |
|---|
| 181 | printf("<option>uLogType</option>"); |
|---|
| 182 | else |
|---|
| 183 | printf("<option selected>uLogType</option>"); |
|---|
| 184 | if(strcmp(gcFilter,"uLoginClient")) |
|---|
| 185 | printf("<option>uLoginClient</option>"); |
|---|
| 186 | else |
|---|
| 187 | printf("<option selected>uLoginClient</option>"); |
|---|
| 188 | if(strcmp(gcFilter,"cLogin")) |
|---|
| 189 | printf("<option>cLogin</option>"); |
|---|
| 190 | else |
|---|
| 191 | printf("<option selected>cLogin</option>"); |
|---|
| 192 | if(strcmp(gcFilter,"cHost")) |
|---|
| 193 | printf("<option>cHost</option>"); |
|---|
| 194 | else |
|---|
| 195 | printf("<option selected>cHost</option>"); |
|---|
| 196 | if(strcmp(gcFilter,"uTablePK")) |
|---|
| 197 | printf("<option>uTablePK</option>"); |
|---|
| 198 | else |
|---|
| 199 | printf("<option selected>uTablePK</option>"); |
|---|
| 200 | if(strcmp(gcFilter,"uZone")) |
|---|
| 201 | printf("<option>uZone</option>"); |
|---|
| 202 | else |
|---|
| 203 | printf("<option selected>uZone</option>"); |
|---|
| 204 | if(strcmp(gcFilter,"None")) |
|---|
| 205 | printf("<option>None</option>"); |
|---|
| 206 | else |
|---|
| 207 | printf("<option selected>None</option>"); |
|---|
| 208 | printf("</select>"); |
|---|
| 209 | |
|---|
| 210 | }//void ExttLogListFilter(void) |
|---|
| 211 | |
|---|
| 212 | |
|---|
| 213 | void ExttLogNavBar(void) |
|---|
| 214 | { |
|---|
| 215 | if(uOwner) GetClientOwner(uOwner,&guReseller); |
|---|
| 216 | |
|---|
| 217 | printf(LANG_NBB_SKIPFIRST); |
|---|
| 218 | printf(LANG_NBB_SKIPBACK); |
|---|
| 219 | printf(LANG_NBB_SEARCH); |
|---|
| 220 | |
|---|
| 221 | if(guLoginClient==1 && guPermLevel>=12 && uLog) |
|---|
| 222 | printf(LANG_NBB_LIST); |
|---|
| 223 | |
|---|
| 224 | printf(LANG_NBB_SKIPNEXT); |
|---|
| 225 | printf(LANG_NBB_SKIPLAST); |
|---|
| 226 | printf(" \n"); |
|---|
| 227 | |
|---|
| 228 | }//void ExttLogNavBar(void) |
|---|
| 229 | |
|---|
| 230 | |
|---|
| 231 | void LogSummary(void) |
|---|
| 232 | { |
|---|
| 233 | |
|---|
| 234 | if(uLog && cLabel[0] && guPermLevel>10 && uTablePK[0] && cTableName[0]) |
|---|
| 235 | { |
|---|
| 236 | unsigned uTPK=0; |
|---|
| 237 | sscanf(uTablePK,"%u",&uTPK); |
|---|
| 238 | |
|---|
| 239 | printf("<p><u>LogSummary</u><br>\n"); |
|---|
| 240 | if(!strcmp(cTableName,"tZone")) |
|---|
| 241 | { |
|---|
| 242 | printf("tZone<blockquote>\n"); |
|---|
| 243 | printf("%s<br>\n",ForeignKey("tZone","cZone",uTPK)); |
|---|
| 244 | printf("</blockquote>\n"); |
|---|
| 245 | } |
|---|
| 246 | else if(!strcmp(cTableName,"tResource")) |
|---|
| 247 | { |
|---|
| 248 | unsigned uZone=0; |
|---|
| 249 | unsigned uRRType=0; |
|---|
| 250 | |
|---|
| 251 | sscanf(ForeignKey("tResource","uZone",uTPK),"%u",&uZone); |
|---|
| 252 | sscanf(ForeignKey("tResource","uRRType",uTPK),"%u",&uRRType); |
|---|
| 253 | |
|---|
| 254 | if( strcmp(cLabel,"Del") && uTPK && uZone && uRRType) |
|---|
| 255 | { |
|---|
| 256 | |
|---|
| 257 | printf("<a title='Jump to tResource entry' href=unxsVZ.cgi?gcFunction=tResource&" |
|---|
| 258 | "uResource=%u>tResource</a><blockquote>\n",uTPK); |
|---|
| 259 | printf("cZone=%s<br>\n",ForeignKey("tZone","cZone",uZone)); |
|---|
| 260 | printf("cName=%s<br>\n",ForeignKey("tResource","cName",uTPK)); |
|---|
| 261 | printf("RRType=%s<br>\n",ForeignKey("tRRType","cLabel",uRRType)); |
|---|
| 262 | printf("cParam1=%s<br>\n",ForeignKey("tResource","cParam1",uTPK)); |
|---|
| 263 | printf("cParam2=%s<br>\n",ForeignKey("tResource","cParam2",uTPK)); |
|---|
| 264 | printf("cComment=%s<br>\n",ForeignKey("tResource","cComment",uTPK)); |
|---|
| 265 | } |
|---|
| 266 | |
|---|
| 267 | if(uLoginClient) |
|---|
| 268 | { |
|---|
| 269 | printf("Contact=<a title='Jump to tClient entry' href=unxsVZ.cgi?gcFunction=" |
|---|
| 270 | "tClient&uClient=%u>%s</a><br></blockquote>\n",uLoginClient, |
|---|
| 271 | ForeignKey("tClient","cLabel",uLoginClient)); |
|---|
| 272 | } |
|---|
| 273 | } |
|---|
| 274 | else if(1) |
|---|
| 275 | { |
|---|
| 276 | printf("No summary available for %s\n",cTableName); |
|---|
| 277 | } |
|---|
| 278 | } |
|---|
| 279 | }//void LogSummary(void); |
|---|
| 280 | |
|---|