Jump to content

pedrisco

Members
  • Posts

    43
  • Joined

  • Last visited

Everything posted by pedrisco

  1. The file name is the application name plus ".ini", and its content is something like.. ... [database] connectionString=SQLOLEDB.1;User ID=sa;Initial Catalog="database";Data Source=127.0.0.1,1433;Password=blahblehblih Then i do something like this... ... interface ... type TUniMainModule = class(TUniGUIMainModule) ADOConn: TADOConnection; procedure UniGUIMainModuleCreate(Sender: TObject); ... end; Implementation ... Uses IniFiles, ...; ... procedure TUniMainModule.UniGUIMainModuleCreate(Sender: TObject); begin with TMemIniFile.Create(changeFileExt( paramStr(0) , '.conf' )) do begin AdoConn.close; AdoConn.connectionString := ReadString('database','connectionString',''); free; end; try ADOConn.open; ... end; end; Good luck
  2. Where AllowedIP is the function that manages the allowed ip's, i do something like this... procedure TUniServerModule.UniGUIServerModuleHTTPCommand(ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo; var Handled: Boolean); begin if not AllowedIP( ARequestInfo.RemoteIP ) then begin AResponseInfo.ContentText := '<h1>Access denied</h1>'; Handled := True; Exit; end; ...
  3. http://forums.unigui.com/index.php?/topic/9184-redirect-http-to-https/
  4. In UniServerModule.CustomFiles i add a js file containing this code.
  5. I use a command line parameter to say the application to run as a process or as a service. I'm sure there is a better way, but it works for me. The dpr looks like this... program main; uses SvcMgr, ServiceModule in 'ServiceModule.pas' {mainWebService: TUniGUIService}, Forms, Windows, Classes, SysUtils, ServerModule in 'ServerModule.pas' {UniServerModule: TUniGUIServerModule}, Login in 'Login.pas' {LoginForm: TUniLoginForm}, MainModule in 'MainModule.pas' {UniMainModule: TUniGUIMainModule}, Main in 'Main.pas' {MainForm: TUniForm}; {$R *.res} begin if upperCase( paramStr(1) ) <> '/APP' then with SvcMgr.Application do begin //started at system32... SetCurrentDir( extractFileDir(paramStr(0)) ); if not DelayInitialize or Installing then Initialize; CreateForm(TmainVstWebService, mainVstWebService); Run; end else with Forms.Application do begin Initialize; TUniServerModule.Create(Forms.Application); Run; end; end.
  6. Cause security reasons you can't make it through the browser unless you use browser specific features, but in a local network you can use the next function, you can use hostname or ip address, i've tested with ipv4 and it works (xe3). function GetMacAddress(const AServerName : string) : string; type TNetTransportEnum = function(pszServer : PWideChar; Level : DWORD; var pbBuffer : pointer; PrefMaxLen : LongInt; var EntriesRead : DWORD; var TotalEntries : DWORD; var ResumeHandle : DWORD) : DWORD; stdcall; TNetApiBufferFree = function(Buffer : pointer) : DWORD; stdcall; PTransportInfo = ^TTransportInfo; TTransportInfo = record quality_of_service : DWORD; number_of_vcs : DWORD; transport_name : PWChar; transport_address : PWChar; wan_ish : boolean; end; var E,ResumeHandle, EntriesRead, TotalEntries : DWORD; FLibHandle : THandle; sMachineName, sMacAddr, Retvar : string; pBuffer : pointer; pInfo : PTransportInfo; FNetTransportEnum : TNetTransportEnum; FNetApiBufferFree : TNetApiBufferFree; pszServer : array[0..128] of WideChar; i,ii,iIdx : integer; begin sMachineName := trim(AServerName); Retvar := '00-00-00-00-00-00'; // Add leading \\ if missing if (sMachineName <> '') and (length(sMachineName) = 2) then begin if copy(sMachineName,1,2) <> '\\' then sMachineName := '\\' + sMachineName end; // Setup and load from DLL pBuffer := nil; ResumeHandle := 0; FLibHandle := LoadLibrary('NETAPI32.DLL'); // Execute the external function if FLibHandle <>0 then begin @FNetTransportEnum := GetProcAddress(FLibHandle,'NetWkstaTransportEnum'); @FNetApiBufferFree := GetProcAddress(FLibHandle,'NetApiBufferFree'); E := FNetTransportEnum(StringToWideChar(sMachineName,pszServer,129),0, pBuffer,-1,EntriesRead,TotalEntries,Resumehandle); if E = 0 then begin pInfo := pBuffer; // Enumerate all protocols - look for TCPIP for i := 1 to EntriesRead do begin if pos('TCPIP',UpperCase(pInfo^.transport_name)) <>0 then begin // Got It - now format result 'xx-xx-xx-xx-xx-xx' iIdx := 1; sMacAddr := pInfo^.transport_address; for ii := 1 to 12 do begin Retvar[iIdx] := sMacAddr[ii]; inc(iIdx); if iIdx in [3,6,9,12,15] then inc(iIdx); end; end; inc(pInfo); end; if pBuffer <>nil then FNetApiBufferFree(pBuffer); end; try FreeLibrary(FLibHandle); except // Silent Error end; end; Result := Retvar; end; source:https://www.experts-exchange.com/questions/28333946/Delphi-How-to-Get-MAC-Address-from-Computer-on-LAN-if-I-Know-Its-Name.html Hope it helps.
  7. Hi, look what i've found... https://github.com/ebekker/ACMESharp/wiki/Quick-Start It really works. So after you get "Status Valid" you can... Get-ACMECertificate your_cert_alias -ExportKeyPEM "key.pem" -ExportCertificatePEM "cert.pem" -ExportIssuerPEM "root.pem"
  8. Hi, here i go, this is the (hard) way i'm doing with letsencrypt, i'm getting an "A-" (cause Forward Secrecy), but if you see any wrong or unsecure thing please tell me. REM Environment = Micro$oft Windows 7 64bits + OpenSSL-Win64 1.0.2h. REM first we make the request, the private and public keys... openssl req -nodes -newkey rsa:2048 -keyout key.pem -out request.csr -subj "/C=CL/ST=Santiago/L=Santiago/O=My Company Name/CN=mydomain.ddns.net" openssl genrsa 4096 > account.key openssl rsa -in account.key -pubout > accountPub.key REM here you've got key.pem, what you can put directly in uniServerModule.SSLOptions.KeyFile . REM copy and paste accountPub.key content in step 1 (Account Public Key) and press the button. REM copy and paste request.csr content in step 2 (Certificate Signing Request) and press the button. REM copy the text echoed by the 3 lines in the step 3 in each KEY variable at the next "set KEY" commands and run it. set KEY1="blahblahblah....blah" set KEY2="blehblehbleh....bleh" set KEY3="blihblihblih........................blih" set PRIV_KEY=account.key echo|set /p=%KEY1% | openssl dgst -sha256 -hex -sign %PRIV_KEY% > 1.in echo|set /p=%KEY2% | openssl dgst -sha256 -hex -sign %PRIV_KEY% > 2.in echo|set /p=%KEY3% | openssl dgst -sha256 -hex -sign %PRIV_KEY% > 3.in REM copy the content of the files 1.in, 2.in and 3.in, and paste them in the right input text in the step 3, and press button. REM copy the text echoed by the line in the step 4 in the KEY4 variable at the next "set KEY" commands and run it. set PRIV_KEY=account.key set KEY4="blohblohbloh....bloh" echo|set /p=%KEY4% | openssl dgst -sha256 -hex -sign %PRIV_KEY% > 4.in REM copy the 4.in content and paste in the input text in step 4. REM go to "Option 2 - file-based". REM write the content in the right file, with the right file name, with the right path. REM prepare your server for serving the right content, with something like this.... REM procedure TUniServerModule.UniGUIServerModuleHTTPDocument( const Document: string; const InParams: TStrings; REM ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo; var Handled: Boolean); REM var fileName:String; REM begin REM fileName := FilesFolderPath + stringReplace( Document , '/' , '\',[rfReplaceAll]); REM if fileExists( fileName ) then begin REM AResponseInfo.ContentStream := TFileStream.Create( fileName, fmOpenRead OR fmShareDenyNone); REM Handled := True; REM end; REM end; REM press the button. REM copy the "Signed Certificate" text in the file signed.crt, and "Intermediate Certificate" text in the Intermediate.crt. openssl x509 -in signed.crt -out cert.pem -outform PEM openssl x509 -in intermediate.crt -out root.pem -outform PEM REM here you've finally got the fricking cert.pem and root.pem that you can put in uniServerModule.SSLOptions.CertFile and uniServerModule.SSLOptions.RootCertFile. REM optionally you can make the dhparam... openssl dhparam -outform PEM -out dhparam.pem 2048 Good Luck
  9. Hi AFAIK there is no specific report library for uniGui so you can peek any of them, but IMHO i would recommend any excel band oriented. I worked with Report Smith, Crystal Reports, QuickReport, FastReport, but i recommend some like FlexCel. Every single user knows excel so all of them can customize a template, and most of them ask for it. If you want a read only file, build the workbook and export it to pdf.
  10. Hi What about RemObjects Pascal Script ?, its license is very permissive, i have downloaded it many times but i don't have the time to test it, i've tried some RemObjects products and they usually work fine.
  11. In case someone need it... if (window.location.protocol === 'http:') { window.location.href = 'https:' + window.location.href.slice(5); };
  12. Hi Pressing f5 key is a fast and standard way to restart, forcing the browser to clean the cache and reload the entire web page, and as far as i know uniGui keeps that standard way, allowing you (besides other things) to update ExtJS lib when you upgrade uniGui (cause the browser MUST clean cache and reload that new ExtJS lib). So the user should know that when he press f5, the application will restart, just like closing and starting again the application or in this case, the browser (and the same with the tab). This feature (cache control) was thought in the beginning of times to save time reloading media files (movies, images, big text files, scripts, etc.). Moreover you can disable this f5 key effect, adding dkDisableF5 to MainModule.DocumentKeyOptions. I hope another user/developer answers your question in a better way i'm doing, because maybe i'm wrong and uniGui indeed can restore the application state after pressing f5. But considering you can disable it, the only case in which you need uniGui keeps its state using a cookie (or something else), would be a browser restart or an entire client restart, what would bring some security issues. Finally, i hate to answer a question with another one, but why would you press f5 to "restart" a web page to the same state it was before pressing it ?
  13. En general se trata de cambiar los componentes visuales de la vcl (o de terceros) a su equivalente de UniGui, es decir, reemplazar en el dfm cada componente visual (p.e. TButton por TUniButton, TLabel por TUniLabel y así), luego el IDE te ayuda a corregir el .pas al momento de guardar. Hace un par de años migré una aplicación de escritorio con UniGui, te puedo decir que reutilicé más del 90% del código fuente, y que al hacerlo ni siquiera tuve que entender la lógica del sistema, solo reemplacé los componentes visuales. En ese momento la versión beta aun carecía de muchas cosas que me obligaron a hacer modificaciones en el código, pero en muy pocas ocasiones, en particular me refiero a las cajas modales (messagedlg y showmessage) y la falta del TListView. Suerte
  14. http://stackoverflow.com/questions/15236293/printing-from-a-webserver-to-a-thermal-printer-with-no-intermediary/15252523#15252523 i hope it helps
  15. Thanks Delphi Developer actuallly i tricked it with js by now, just like you suggest. i've tested with 0.99.96.1322. and btw, just for people that will use this trick... the first line does restricts the maximum length and the second avoids the warning hint about exceeding the limit, so you need both.
  16. I cannt post in "Active Reports", so i drop it here... TuniEdit doesn't consider the changes made to maxlength in runtime, it just keep considering the design time assigned value. Tnanks
×
×
  • Create New...