Annotation of sbbs/src/sbbs3/ctrl/webcfgdlgunit.cpp, revision 1.1.1.1

1.1       root        1: /* Synchronet Control Panel (GUI Borland C++ Builder Project for Win32) */
                      2: 
                      3: /* $Id: WebCfgDlgUnit.cpp,v 1.4 2005/04/26 08:49:35 rswindell Exp $ */
                      4: 
                      5: /****************************************************************************
                      6:  * @format.tab-size 4          (Plain Text/Source Code File Header)                    *
                      7:  * @format.use-tabs true       (see http://www.synchro.net/ptsc_hdr.html)              *
                      8:  *                                                                                                                                                     *
                      9:  * Copyright 2005 Rob Swindell - http://www.synchro.net/copyright.html         *
                     10:  *                                                                                                                                                     *
                     11:  * This program is free software; you can redistribute it and/or                       *
                     12:  * modify it under the terms of the GNU General Public License                         *
                     13:  * as published by the Free Software Foundation; either version 2                      *
                     14:  * of the License, or (at your option) any later version.                                      *
                     15:  * See the GNU General Public License for more details: gpl.txt or                     *
                     16:  * http://www.fsf.org/copyleft/gpl.html                                                                                *
                     17:  *                                                                                                                                                     *
                     18:  * Anonymous FTP access to the most recent released source is available at     *
                     19:  * ftp://vert.synchro.net, ftp://cvs.synchro.net and ftp://ftp.synchro.net     *
                     20:  *                                                                                                                                                     *
                     21:  * Anonymous CVS access to the development source and modification history     *
                     22:  * is available at cvs.synchro.net:/cvsroot/sbbs, example:                                     *
                     23:  * cvs -d :pserver:[email protected]:/cvsroot/sbbs login                       *
                     24:  *     (just hit return, no password is necessary)                                                     *
                     25:  * cvs -d :pserver:[email protected]:/cvsroot/sbbs checkout src                *
                     26:  *                                                                                                                                                     *
                     27:  * For Synchronet coding style and modification guidelines, see                                *
                     28:  * http://www.synchro.net/source.html                                                                          *
                     29:  *                                                                                                                                                     *
                     30:  * You are encouraged to submit any modifications (preferably in Unix diff     *
                     31:  * format) via e-mail to [email protected]                                                                      *
                     32:  *                                                                                                                                                     *
                     33:  * Note: If this box doesn't appear square, then you need to fix your tabs.    *
                     34:  ****************************************************************************/
                     35: 
                     36: //---------------------------------------------------------------------------
                     37: 
                     38: #include <vcl.h>
                     39: #pragma hdrstop
                     40: 
                     41: #include "MainFormUnit.h"
                     42: #include "WebCfgDlgUnit.h"
                     43: #include "TextFileEditUnit.h"
                     44: #include <stdio.h>                     // sprintf()
                     45: #include <mmsystem.h>          // sndPlaySound()
                     46: //---------------------------------------------------------------------------
                     47: #pragma package(smart_init)
                     48: #pragma resource "*.dfm"
                     49: TWebCfgDlg *WebCfgDlg;
                     50: //---------------------------------------------------------------------------
                     51: __fastcall TWebCfgDlg::TWebCfgDlg(TComponent* Owner)
                     52:     : TForm(Owner)
                     53: {
                     54: }
                     55: //---------------------------------------------------------------------------
                     56: void __fastcall TWebCfgDlg::FormShow(TObject *Sender)
                     57: {
                     58:     char str[128];
                     59:     char** p;
                     60: 
                     61:     if(MainForm->web_startup.interface_addr==0)
                     62:         NetworkInterfaceEdit->Text="<ANY>";
                     63:     else {
                     64:         sprintf(str,"%d.%d.%d.%d"
                     65:             ,(MainForm->web_startup.interface_addr>>24)&0xff
                     66:             ,(MainForm->web_startup.interface_addr>>16)&0xff
                     67:             ,(MainForm->web_startup.interface_addr>>8)&0xff
                     68:             ,MainForm->web_startup.interface_addr&0xff
                     69:         );
                     70:         NetworkInterfaceEdit->Text=AnsiString(str);
                     71:     }
                     72:     if(MainForm->web_startup.max_clients==0)
                     73:         MaxClientsEdit->Text="infinite";
                     74:     else
                     75:         MaxClientsEdit->Text=AnsiString((int)MainForm->web_startup.max_clients);
                     76:     MaxInactivityEdit->Text=AnsiString((int)MainForm->web_startup.max_inactivity);
                     77:        PortEdit->Text=AnsiString((int)MainForm->web_startup.port);
                     78:     AutoStartCheckBox->Checked=MainForm->WebAutoStart;
                     79: 
                     80:     HtmlRootEdit->Text=AnsiString(MainForm->web_startup.root_dir);
                     81:     ErrorSubDirEdit->Text=AnsiString(MainForm->web_startup.error_dir);
                     82:     CGIDirEdit->Text=AnsiString(MainForm->web_startup.cgi_dir);
                     83:     EmbeddedJsExtEdit->Text=AnsiString(MainForm->web_startup.js_ext);
                     84:     ServerSideJsExtEdit->Text=AnsiString(MainForm->web_startup.ssjs_ext);
                     85: 
                     86:     CGIContentEdit->Text=AnsiString(MainForm->web_startup.default_cgi_content);
                     87:     CGIMaxInactivityEdit->Text=AnsiString((int)MainForm->web_startup.max_cgi_inactivity);
                     88: 
                     89:     IndexFileEdit->Text.SetLength(0);
                     90:     for(p=MainForm->web_startup.index_file_name;*p;p++) {
                     91:         if(p!=MainForm->web_startup.index_file_name)
                     92:             IndexFileEdit->Text=IndexFileEdit->Text+",";
                     93:         IndexFileEdit->Text=IndexFileEdit->Text+AnsiString(*p);
                     94:     }
                     95: 
                     96:     CGIExtEdit->Text.SetLength(0);
                     97:     for(p=MainForm->web_startup.cgi_ext;*p;p++) {
                     98:         if(p!=MainForm->web_startup.cgi_ext)
                     99:             CGIExtEdit->Text=CGIExtEdit->Text+",";
                    100:         CGIExtEdit->Text=CGIExtEdit->Text+AnsiString(*p);
                    101:     }
                    102: 
                    103:     CGICheckBox->Checked=!(MainForm->web_startup.options&WEB_OPT_NO_CGI);
                    104: 
                    105:     AnswerSoundEdit->Text=AnsiString(MainForm->web_startup.answer_sound);
                    106:     HangupSoundEdit->Text=AnsiString(MainForm->web_startup.hangup_sound);
                    107:     HackAttemptSoundEdit->Text=AnsiString(MainForm->web_startup.hack_sound);
                    108: 
                    109:        DebugTxCheckBox->Checked=MainForm->web_startup.options&WEB_OPT_DEBUG_TX;
                    110:        DebugRxCheckBox->Checked=MainForm->web_startup.options&WEB_OPT_DEBUG_RX;
                    111:     AccessLogCheckBox->Checked=MainForm->web_startup.options&WEB_OPT_HTTP_LOGGING;
                    112:     AccessLogCheckBoxClick(Sender);
                    113: 
                    114:     VirtualHostsCheckBox->Checked=MainForm->web_startup.options&WEB_OPT_VIRTUAL_HOSTS;
                    115: 
                    116:     HostnameCheckBox->Checked
                    117:         =!(MainForm->web_startup.options&BBS_OPT_NO_HOST_LOOKUP);
                    118: 
                    119:     PageControl->ActivePage=GeneralTabSheet;
                    120: 
                    121:     CGICheckBoxClick(Sender);
                    122: }
                    123: //---------------------------------------------------------------------------
                    124: void __fastcall TWebCfgDlg::OKBtnClick(TObject *Sender)
                    125: {
                    126:     char    str[128],*p;
                    127:     DWORD   addr;
                    128: 
                    129:     SAFECOPY(str,NetworkInterfaceEdit->Text.c_str());
                    130:     p=str;
                    131:     while(*p && *p<=' ') p++;
                    132:     if(*p && isdigit(*p)) {
                    133:         addr=atoi(p)<<24;
                    134:         while(*p && *p!='.') p++;
                    135:         if(*p=='.') p++;
                    136:         addr|=atoi(p)<<16;
                    137:         while(*p && *p!='.') p++;
                    138:         if(*p=='.') p++;
                    139:         addr|=atoi(p)<<8;
                    140:         while(*p && *p!='.') p++;
                    141:         if(*p=='.') p++;
                    142:         addr|=atoi(p);
                    143:         MainForm->web_startup.interface_addr=addr;
                    144:     } else
                    145:         MainForm->web_startup.interface_addr=0;
                    146:     MainForm->web_startup.max_clients=MaxClientsEdit->Text.ToIntDef(10);
                    147:     MainForm->web_startup.max_inactivity=MaxInactivityEdit->Text.ToIntDef(300);
                    148:     MainForm->web_startup.port=PortEdit->Text.ToIntDef(23);
                    149:     MainForm->WebAutoStart=AutoStartCheckBox->Checked;
                    150: 
                    151:     SAFECOPY(MainForm->web_startup.root_dir
                    152:         ,HtmlRootEdit->Text.c_str());
                    153:     SAFECOPY(MainForm->web_startup.error_dir
                    154:         ,ErrorSubDirEdit->Text.c_str());
                    155:     SAFECOPY(MainForm->web_startup.cgi_dir
                    156:         ,CGIDirEdit->Text.c_str());
                    157:     SAFECOPY(MainForm->web_startup.js_ext
                    158:         ,EmbeddedJsExtEdit->Text.c_str());
                    159:     SAFECOPY(MainForm->web_startup.ssjs_ext
                    160:         ,ServerSideJsExtEdit->Text.c_str());
                    161: 
                    162:     SAFECOPY(MainForm->web_startup.default_cgi_content
                    163:         ,CGIContentEdit->Text.c_str());
                    164:     MainForm->web_startup.max_cgi_inactivity
                    165:         =CGIMaxInactivityEdit->Text.ToIntDef(120);
                    166: 
                    167:     strListFree(&MainForm->web_startup.index_file_name);
                    168:     strListSplitCopy(&MainForm->web_startup.index_file_name,
                    169:         IndexFileEdit->Text.c_str(),",");
                    170: 
                    171:     strListFree(&MainForm->web_startup.cgi_ext);
                    172:     strListSplitCopy(&MainForm->web_startup.cgi_ext,
                    173:         CGIExtEdit->Text.c_str(),",");
                    174: 
                    175:        if(CGICheckBox->Checked==false)
                    176:        MainForm->web_startup.options|=WEB_OPT_NO_CGI;
                    177:     else
                    178:            MainForm->web_startup.options&=~WEB_OPT_NO_CGI;
                    179: 
                    180:     SAFECOPY(MainForm->web_startup.answer_sound
                    181:         ,AnswerSoundEdit->Text.c_str());
                    182:     SAFECOPY(MainForm->web_startup.hangup_sound
                    183:         ,HangupSoundEdit->Text.c_str());
                    184:     SAFECOPY(MainForm->web_startup.hack_sound
                    185:         ,HackAttemptSoundEdit->Text.c_str());
                    186: 
                    187:        if(DebugTxCheckBox->Checked==true)
                    188:        MainForm->web_startup.options|=WEB_OPT_DEBUG_TX;
                    189:     else
                    190:            MainForm->web_startup.options&=~WEB_OPT_DEBUG_TX;
                    191:        if(DebugRxCheckBox->Checked==true)
                    192:        MainForm->web_startup.options|=WEB_OPT_DEBUG_RX;
                    193:     else
                    194:            MainForm->web_startup.options&=~WEB_OPT_DEBUG_RX;
                    195:        if(AccessLogCheckBox->Checked==true)
                    196:        MainForm->web_startup.options|=WEB_OPT_HTTP_LOGGING;
                    197:     else
                    198:            MainForm->web_startup.options&=~WEB_OPT_HTTP_LOGGING;
                    199:        if(HostnameCheckBox->Checked==false)
                    200:        MainForm->web_startup.options|=BBS_OPT_NO_HOST_LOOKUP;
                    201:     else
                    202:            MainForm->web_startup.options&=~BBS_OPT_NO_HOST_LOOKUP;
                    203:        if(VirtualHostsCheckBox->Checked==true)
                    204:        MainForm->web_startup.options|=WEB_OPT_VIRTUAL_HOSTS;
                    205:     else
                    206:            MainForm->web_startup.options&=~WEB_OPT_VIRTUAL_HOSTS;
                    207: 
                    208:     MainForm->SaveIniSettings(Sender);
                    209: }
                    210: //---------------------------------------------------------------------------
                    211: void __fastcall TWebCfgDlg::AnswerSoundButtonClick(TObject *Sender)
                    212: {
                    213:        OpenDialog->FileName=AnswerSoundEdit->Text;
                    214:        if(OpenDialog->Execute()==true) {
                    215:        AnswerSoundEdit->Text=OpenDialog->FileName;
                    216:         sndPlaySound(OpenDialog->FileName.c_str(),SND_ASYNC);
                    217:     }
                    218: }
                    219: //---------------------------------------------------------------------------
                    220: void __fastcall TWebCfgDlg::HangupSoundButtonClick(TObject *Sender)
                    221: {
                    222:        OpenDialog->FileName=HangupSoundEdit->Text;
                    223:        if(OpenDialog->Execute()==true) {
                    224:        HangupSoundEdit->Text=OpenDialog->FileName;
                    225:         sndPlaySound(OpenDialog->FileName.c_str(),SND_ASYNC);
                    226:        }
                    227: }
                    228: //---------------------------------------------------------------------------
                    229: void __fastcall TWebCfgDlg::HackAttemptSoundButtonClick(TObject *Sender)
                    230: {
                    231:        OpenDialog->FileName=HackAttemptSoundEdit->Text;
                    232:        if(OpenDialog->Execute()==true) {
                    233:        HackAttemptSoundEdit->Text=OpenDialog->FileName;
                    234:         sndPlaySound(OpenDialog->FileName.c_str(),SND_ASYNC);
                    235:        }
                    236: }
                    237: //---------------------------------------------------------------------------
                    238: 
                    239: void __fastcall TWebCfgDlg::AccessLogCheckBoxClick(TObject *Sender)
                    240: {
                    241:     LogBaseLabel->Enabled=AccessLogCheckBox->Checked;
                    242:     LogBaseNameEdit->Enabled=AccessLogCheckBox->Checked;
                    243: }
                    244: //---------------------------------------------------------------------------
                    245: 
                    246: void __fastcall TWebCfgDlg::CGIEnvButtonClick(TObject *Sender)
                    247: {
                    248:        char path[MAX_PATH+1];
                    249: 
                    250:     iniFileName(path,sizeof(path),MainForm->cfg.ctrl_dir,"cgi_env.ini");
                    251:        Application->CreateForm(__classid(TTextFileEditForm), &TextFileEditForm);
                    252:        TextFileEditForm->Filename=AnsiString(path);
                    253:     TextFileEditForm->Caption="CGI Environment Variables";
                    254:        TextFileEditForm->ShowModal();
                    255:     delete TextFileEditForm;
                    256: }
                    257: //---------------------------------------------------------------------------
                    258: 
                    259: void __fastcall TWebCfgDlg::WebHandlersButtonClick(TObject *Sender)
                    260: {
                    261:        char path[MAX_PATH+1];
                    262: 
                    263:     iniFileName(path,sizeof(path),MainForm->cfg.ctrl_dir,"web_handler.ini");
                    264:        Application->CreateForm(__classid(TTextFileEditForm), &TextFileEditForm);
                    265:        TextFileEditForm->Filename=AnsiString(path);
                    266:     TextFileEditForm->Caption="Web Content Handlers";
                    267:        TextFileEditForm->ShowModal();
                    268:     delete TextFileEditForm;
                    269: }
                    270: //---------------------------------------------------------------------------
                    271: 
                    272: void __fastcall TWebCfgDlg::CGICheckBoxClick(TObject *Sender)
                    273: {
                    274:     bool enabled=CGICheckBox->Checked;
                    275: 
                    276:     CGIDirLabel->Enabled=enabled;
                    277:     CGIDirEdit->Enabled=enabled;
                    278:     CGIExtLabel->Enabled=enabled;
                    279:     CGIExtEdit->Enabled=enabled;
                    280:     CGIContentLabel->Enabled=enabled;
                    281:     CGIContentEdit->Enabled=enabled;
                    282:     CGIMaxInactivityLabel->Enabled=enabled;
                    283:     CGIMaxInactivityEdit->Enabled=enabled;
                    284:     CGIEnvButton->Enabled=enabled;
                    285: }
                    286: //---------------------------------------------------------------------------
                    287: 

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.