Jump to content

irigsoft

uniGUI Subscriber
  • Posts

    1105
  • Joined

  • Last visited

  • Days Won

    16

irigsoft last won the day on January 18

irigsoft had the most liked content!

Recent Profile Visitors

4071 profile views

irigsoft's Achievements

Advanced Member

Advanced Member (4/4)

80

Reputation

  1. at this moment I know, only this way. If you find another one, could you please share it
  2. Hello, I use this to bind socket: function PortAvailable(Port:STring):boolean; var svr : TTCPBlockSocket; begin svr := TTCPBlockSocket.Create; try svr.Bind('0.0.0.0',Port); svr.Listen; result := svr.LastError = 0; Svr.CloseSocket; finally svr.Free; end; end; procedure TUniServerModule.UniGUIServerModuleBeforeInit(Sender: TObject); begin //check port usage if (not PortAvailable (YourServerPort)) then begin UniServerModule.Terminated := True; Application.Terminate; exit; end; end;
  3. Hello, I didn't. But I don't use hyperserver. I think that problem is in my application and stop asking for help, but i don't have solution
  4. Hello, I use this in my server. 1. set uniDBGrid.Column [YourColumn].ShowSummary := True; 2. set this uniDBGrid.JSInterface.JSCode to hide Summary uniDBGrid.JSInterface.JSCode('var me='#1'; var _view=null; var _lockedview=null; if (!me.lockedGrid && !me.normalGrid) {_view=me.getView()} else {_view=me.normalGrid.getView(); _lockedview=me.lockedGrid.getView()}; ' + 'if (_view) {_view.summaryFeature.summaryBar.hide()};' + 'if (_lockedview) {_lockedview.summaryFeature.summaryBar.hide()};' ); 3. set this uniDBGrid.JSInterface.JSCode to show Summary uniDBGrid.JSInterface.JSCode('var me='#1'; var _view=null; var _lockedview=null; if (!me.lockedGrid && !me.normalGrid) {_view=me.getView()} else {_view=me.normalGrid.getView(); _lockedview=me.lockedGrid.getView()}; ' + 'if (_view) {_view.summaryFeature.summaryBar.show()};' + 'if (_lockedview) {_lockedview.summaryFeature.summaryBar.show()};' ); I set this JSCode when create Form for uniDBGrid's uniDBGrid.OnColumnSummaryResult := MyUniDBGridSettingsColumnSummaryResult; procedure MyUniDBGridSettingsColumnSummaryResult( Column: TUniDBGridColumn; GroupFieldValue: Variant; Attribs: TUniCellAttribs; var Result: string); var F : Extended;//Real; StrListSumi : TStringLIst; begin StrListSumi := TStringLIst.Create; try Attribs.Color := $00E2E2E2; Attribs.Font.Size := 8; Attribs.Font.Style := [fsItalic]; if (Column.Field IS TNumericField) AND (Column.Visible) then begin StrListSumi.Add (Column.Title.Caption + '=0'); uniMainModule.fCALCULATESUMCOLUMN (TUniDBGrid (Column.Grid),StrListSumi,False); Result := 'SUM</br>(' + StrListSumi.Values [Column.Title.Caption] + ')';//Format ('%4.2f',[F]);//FormatCurr('0,0.00 ', F);// + FmtSettings.CurrencyString; end; except end; StrListSumi.Clear; StrListSumi.Free; end; function TUniMainModule.fCALCULATESUMCOLUMN (SelDbGrid : TuniDBGrid; SelFields : TStringLIst; ShowTotals : Boolean) :TStringLIst; var k,I,J : Integer; Tryfloat : Extended; sSum : String; MyHeader : TStringGrid; Data : array of Double; MyDBGrid : TDBGrid; B : TBookmark; begin If (not TuniDBGrid (SelDbGrid).DataSource.DataSet.Active) then exit; TRY B := TuniDBGrid (SelDbGrid).DataSource.DataSet.GetBookmark; TuniDBGrid (SelDbGrid).DataSource.DataSet.DisableControls; for I := 0 to TuniDBGrid (SelDbGrid).Columns.Count - 1 do begin if TuniDBGrid (SelDbGrid) = nil then break; if SelFields <> nil then begin if (SelFields.IndexOfName (AnsiUpperCase (TuniDBGrid (SelDbGrid).Columns[I].Title.Caption)) <> -1) then begin sSum := '0.00'; TuniDBGrid (SelDbGrid).DataSource.DataSet.First; if TuniDBGrid (SelDbGrid).DataSource.DataSet.RecordCount > 0 then begin while not TAdoQuery (TuniDBGrid (SelDbGrid).DataSource.DataSet).EOF do begin Try if TuniDBGrid (SelDbGrid).Columns [I].Field <> nil then begin sSum := Calculate (sSum + '+' + TuniDBGrid (SelDbGrid).Columns [I].Field.AsString,6); end; EXCEPT //break; End; TAdoQuery (TuniDBGrid (SelDbGrid).DataSource.DataSet).Next; end; end; SelFields.ValueFromIndex [SelFields.IndexOfName (AnsiUpperCase (TuniDBGrid (SelDbGrid).Columns[I].Title.Caption))] := Calculate (sSum,2); end; end; end; TuniDBGrid (SelDbGrid).DataSource.DataSet.EnableControls; EXCEPT END; Result := SelFields; end;
  5. Hello, look for C:\Program Files (x86)\FMSoft\Framework\uniGUI\Demos\Desktop\ThemeChange
  6. Hello. Is there a way to know if client use UploadFile or send HTML request in UniGUIServerModuleHTTPCommand. Is it possible to set variable value on UniFileUploadExecute ?
  7. for security reasons. I am trying to protect the StandAlone server (from hackers) when uploading files If someone tries to upload files larger than enabled by me (in my settings) then I want to close the session and stop the upload. In some of my designs I give rights to the user to upload files using uniFileUpload components, but in others they will be able to do so via the API, and I also want to prevent cases where someone tries to illegally upload files to a physical server (in case my security to be breached for any reason)
  8. Hello. I use this procedure to control the size of uploaded files by monitoring ARequestInfo.ContentLength in the UniGUIServerModuleHTTPCommand, but if the file is larger than my size, I want the session to close and the upload to abort. But this does not happen. var contentLength : Int64; begin contentLength := 2000; //read from file with settings If ARequestInfo.HasContentLength then begin if ARequestInfo.ContentLength > contentLength then begin AResponseInfo.ContentText := '<h1>BIG Content</h1>'; Handled := True; AResponseInfo.CloseSession; AResponseInfo.CloseConnection:=true; try UniServerModule.Lock; UniServerModule.Logger.AddLog ('HTMLSysLog',FormatDateTime ('dd.MM.yyyy HH:mm:ss',Now) + ' : ' + ' BIG Post.ContentLength: ' + IntToStr (ARequestInfo.ContentLength) + 'IP: ' + ARequestInfo.RemoteIP + ', URI: ' + ARequestInfo.URI + ', COMMAND: ' + ARequestInfo.Command ,'HtmlLog'); finally UniServerModule.UnLock; end; exit; end; end; What do I need to do to be able to block file uploads ? I want to close session and stop uploading file, not limit MaxAllowedSize ! here is a test project: FileUpload.zip
  9. hi, maybe this will give you some ideas:
  10. this work for me on Chrome: https://stackoverflow.com/questions/20194722/can-you-get-a-users-local-lan-ip-address-via-javascript "Last year I used Linblow's answer (2018-Oct-19) to successfully discover my local IP via javascript. However, recent Chrome updates (76?) have wonked this method so that it now returns an obfuscated IP, such as: 1f4712db-ea17-4bcf-a596-105139dfd8bf.local If you have full control over your browser, you can undo this behavior by turning it off in Chrome Flags, by typing this into your address bar: chrome://flags/#enable-webrtc-allow-input-volume-adjustment and DISABLING the flag Anonymize local IPs exposed by WebRTC In my case, I require the IP for a TamperMonkey script to determine my present location and do different things based on my location. I also have full control over my own browser settings (no Corporate Policies, etc). So for me, changing the chrome://flags setting does the trick." and use this code in uniButtonClick uniSession.AddJS ('const findLocalIp = (logInfo = true) => new Promise( (resolve, reject) => {' + ' window.RTCPeerConnection = window.RTCPeerConnection' + ' || window.mozRTCPeerConnection' + ' || window.webkitRTCPeerConnection;' + ' if ( typeof window.RTCPeerConnection == ''undefined'' )' + ' return reject(''WebRTC not supported by browser'');' + ' let pc = new RTCPeerConnection();' + ' let ips = [];' + ' pc.createDataChannel("");' + ' pc.createOffer()' + ' .then(offer => pc.setLocalDescription(offer))' + ' .catch(err => reject(err));' + ' pc.onicecandidate = event => {' + ' if ( !event || !event.candidate ) {' // All ICE candidates have been sent. + ' if ( ips.length == 0 )' + ' return reject(''WebRTC disabled or restricted by browser'');' + ' return resolve(ips);' + ' }' + ' let parts = event.candidate.candidate.split('' '');' + ' let [base,componentId,protocol,priority,ip,port,,type,...attr] = parts;' + ' let component = [''rtp'', ''rtpc''];' + ' if ( ! ips.some(e => e == ip) )' + ' ips.push(ip);' + ' if ( ! logInfo )' + ' return;' // + ' console.log(" candidate: " + base.split('':'')[1]);' // + ' console.log(" component: " + component[componentId - 1]);' // + ' console.log(" protocol: " + protocol);' // + ' console.log(" priority: " + priority);' // + ' console.log(" ip: " + ip);' // + ' console.log(" port: " + port);' // + ' console.log(" type: " + type);' // + ' if ( attr.length ) {' // + ' console.log("attributes: ");' // + ' for(let i = 0; i < attr.length; i += 2)' // + ' console.log("> " + attr[i] + ": " + attr[i+1]);' // + ' };' // + ' console.log();' + ' let p = document.getElementById(''' + UniLabel10.JSID + ''');' + ' p.innerHTML = ip;' + ' alert (ip);' + ' };' + '} );' //read local IP on Client Side // + 'let p = document.getElementById(''ip'');' // + 'findLocalIp().then(' // + ' ips => {' // + ' let s = '';' // + ' ips.forEach( ip => s += ip + ''<br>'' );' // + ' p.innerHTML = s;' // + ' };' // + ' err => p.innerHTML = err' // + ' );' + 'findLocalIp();' ); Here is a demo Project ClientInfo.zip
  11. maybe this will help too: https://www.c-sharpcorner.com/blogs/getting-client-ip-address-or-local-ip-address-in-javascript https://stackoverflow.com/questions/20194722/can-you-get-a-users-local-lan-ip-address-via-javascript https://www.geeksforgeeks.org/how-to-get-client-ip-address-using-javascript/
  12. Hello, I use unique identificator for PC like POS ID, generated from Session ID (because Session ID is unique)
  13. based on this: https://fiddle.sencha.com/#view/editor&fiddle/3kc1 , here is a example: ClientInfo.zip
  14. It's simple: Form.Script.Add (Your javascript code); example: ClientInfo.zip
  15. procedure SetFormSize (SelForm : TUniForm); var ClientWidth, ClientHeight : Integer; begin Try SelForm.SuspendLayouts; SelForm.Left := 0; SelForm.Top := 0; ClientWidth := UniSession.UniApplication.ScreenWidth; ClientHeight := UniSession.UniApplication.ScreenHeight; SelForm.Width := ClientWidth; SelForm.Height := ClientHeight; if (uniMainModule.AppPlatform <> [upDesktop]) then begin SelForm.WindowState := wsNormal; SelForm.Left := 0; SelForm.Top := 0; //get screen size of device ClientWidth := UniSession.UniApplication.ScreenWidth; ClientHeight := UniSession.UniApplication.ScreenHeight; if UniSession.FormsList.Count <= 1 then exit; //get size of biger form if (ClientWidth < FormMinWidth) then ClientWidth := TUniForm (UniSession.FormsList [UniSession.FormsList.Count - 1]).Width; if (ClientHeight < FormMinHeight) then ClientHeight := TUniForm (UniSession.FormsList [UniSession.FormsList.Count - 1]).Height; //get default minsize if ClientWidth < FormMinWidth then ClientWidth := FormMinWidth; if ClientHeight < FormMinHeight then ClientHeight := FormMinHeight; //get Form's size if ClientWidth < SelForm.Width then ClientWidth := SelForm.Width; if ClientHeight < SelForm.Height then ClientHeight := SelForm.Height; //set Form's size SelForm.Width := ClientWidth; SelForm.Height := ClientHeight; end; SelForm.Repaint; //set mainform size form_general.Left := 0; form_general.Top := 0; form_general.Width := SelForm.Width; form_general.Height := SelForm.Height; form_general.Invalidate; //set Top form Size TUniForm (UniSession.FormsList [UniSession.FormsList.Count - 1]).Height := SelForm.Height; TUniForm (UniSession.FormsList [UniSession.FormsList.Count - 1]).Width := SelForm.Width; TUniForm (UniSession.FormsList [UniSession.FormsList.Count - 1]).Invalidate; Finally SelForm.ResumeLayouts; End; end; I'm using this function on the server side to expand the screen format. When I need to, I use DBgrid.Align := alClient and that works for me. There is a way to do this on the client side as well, but I can't be of help there!
×
×
  • Create New...