Jump to content

Ron

uniGUI Subscriber
  • Posts

    374
  • Joined

  • Last visited

  • Days Won

    31

Posts posted by Ron

  1. If you want to close port 80 totally, you can do it on the server's firewall.

    If not, you can redirect port 80 calls to the SSL port if you run the app as a DLL, e.g for apache:

    RewriteEngine On
    RewriteCond %{HTTPS} off
    RewriteRule (.*) https://%{SERVER_NAME}/$1 [R,L] 

    I'm sure you can do the same thing for IIS.

  2. If all you have are the hours, 02 will always be less than 22 - so you need more data than just the hours.

    When crossing into a new day, you need to differentiate between dates, so you need some date reference for each point in time.

    Whatever the reference is, a datetime comparison will work as long as the last datetime is defined as being x hours after the first.

  3. uses System.Net.HttpClientComponent,
    
    function getHTML(URL:string):string;
    var
      aResponse: TStringStream;
      http: TNetHTTPClient;
    begin
      result:='';
      try
        http:=TNetHTTPClient.Create;    
        aResponse := TStringStream.Create;
        try
          http.Get(url, aResponse);
          result:= aResponse.DataString;
        finally
          aResponse.Free;
          http.free;
        end;
      except
        on E:Exception do
          showMessage('Get htmlfile error: '+ E.Message);
      end;
    end;

    Using TNetHTTPClient makes it a lot easier to connect to different webservers that have strict requirements when it comes to SSL setup, than when using Indy.

  4. I am sorry to hear about your struggle to find a solution. People generally do not have such issues, is my impression.

    I have installed apache manually on several machines and have never had any problems that were not solved rather quickly on this ISAPI solution by configuration.

    As the manual suggests, only a few configurations in the httpd.conf are needed, and whether you run 32 or 64 bits version should be irrelevant.

    I personally prefer the apache solution because it is so easy to setup, with just a few quick modifications.

    I have made an example project, with windows binaries of Apache 2.4 from ApacheLounge, in the attached file.

    1) Unzip Apache24.zip to C:\Apache24

    2) Go to \bin subdir and run httpd.

    3) Open http://localhost:81/test in browser, to load test.dll project in \test subdir.

     

    The only mods to the httpd.conf that I did was

    1) For the mime section: AddHandler isapi-handler .dll   

    2) <Directory "C:/apache24/test">
        Options FollowSymLinks ExecCGI
        AllowOverride None
        DirectoryIndex test.dll
        Require all granted
    </Directory>
    Alias /test "C:/apache24/test"

    3) Set port to 81, to not conflict with your WAMP server, if you have it running.

    The ISAPI module was already activated in the httpd.conf. It took me about ten minutes to make this example project.

    You can also download Apache binaries directly from https://www.apachelounge.com/download/VC15/
    and just use my modified httpd.conf file and compile the test.dll yourself from the project.

    https://home.apache.org/~steffenal/VC15/binaries/httpd-2.4.46-win32-VC15.zip

    Apache24.zip

    test.zip

  5. In that video he moves the documentroot and adds index.dll as default file.

    Of course it works, but it is not the preferred way, as you have to rename your apps to index.dll.

    The manual way should work fine, and you can also there add the app as the index file without renaming it,
    and it leaves the documentroot for other files you might want to serve, e.g. PHP files for quick backend access.

    But I am happy that you found a solution, and things will get a lot easier as you continue experimenting :)

  6. It should not be an issue with the server, so there should be no reason to replace apache.

    If the apache server is setup correctly and is able to serve any html page, it should work fine with Unigui, and if not you have a config issue.

    Also, I do not use the WAMP packages, but download the apache windows binaries and install it manually - not much work at all.
    Basically you just download, unzip and run one single line to install the httpd as a windows service, and that's it.

  7. You should edit httpd.conf and not httpd-vhosts.conf as you have listed.

    Also make sure you reference the DLL file and not EXE as you seem to have done in the browser.

    What you have in your Directory setup seems to be correct, except for the space between "/" and the alias name, in the alias declaration.
    And you may add the line "DirectoryIndex swdweb.dll" as default file to load if you want to avoid having to specify the filename:

     

    Alias /SWDweb "C:/SWDweb"
    <Directory "C:/SWDweb">
        Options Indexes FollowSymLinks ExecCGI
        AllowOverride None
        Require all granted
        DirectoryIndex swdweb.dll
    </Directory>

     

  8.   //insert into myfiletable values(0, :date, :filename, :file);
      with SaveFileQuery do begin
        paramByName('date').AsDateTime:=now;
        paramByName('filename').AsInteger:=uniFileUpload1.fileName;
    
        try
          blob := TMemoryStream.Create;
          blob.Seek(0, soFromBeginning);
          try
            blob.loadFromFile(myFileName);                      //if you have the file on disc
            myFastReport.SaveToStream(blob, true, true, false); //if you need to save a PDF report
          finally
          end;
        finally
          paramByName('file').LoadFromStream(blob, ftBlob);                   //if you use any of the above options
          paramByName('file').LoadFromStream(uniFileUpload1.stream, ftBlob);  //if you have not saved the file yet
          ExecSQL;
          blob.Free
        end;
      end;

     

  9. If you are making an http request from the client (which you do when you use JS, as all JS runs in the browser client) then you can only communicate with the local computer through CORS, and the local webserver must be configured to accept such requests. If you want to communicate to the outside world, you have to do it from the server side, and that is straightforward using e.g. idHTTP and doing a simple http get request.
     

    Example of JS call to local webserver using CORS
    
    UniSession.AddJS('$.get("http://127.0.0.1:'+uniMainModule.corsPort+'?event='+inttostr(EventID)+'&op='+uniMainModule.operator+'", function( data ){' +
         ' ajaxRequest(TransactionForm.form, ["cashRegisterEvent"], { response : data });  '+
       ' }); ');
    
    
    Apache set up for CORS in httpd.conf
    
    <VirtualHost *:80>
        DocumentRoot "c:\program files (x86)\cashreg\apache22\htdocs"
        Header set Access-Control-Allow-Origin "*"
    </VirtualHost>
    
    
    IndyHTTPServer set up for CORS
    
     if sameText('127.0.0.1', ARequestInfo.RemoteIP) and (ARequestInfo.CommandType=hcGet) and (length(aRequestInfo.Params.text)>0) then begin
        AResponseInfo.CustomHeaders.AddValue('Access-Control-Allow-Origin', '*');
        EventIDStr:=aRequestInfo.Params[0];

     

  10. 4 hours ago, Freeman35 said:

    If program will use on LAN, I perfer native application. I hate, but you can use, lazarus(freePascal). Many component can find for it. Yes its not like a delphi but much useful. Delphi support just x64 kernel. And not all linux release. Just "Ubuntu 18.04 LTS, Ubuntu 16.04 LTS, Ubuntu 14.04 LTS, and RedHat Enterprise Linux (version 7) " where is centOS ??? where is ubuntu 19.x ??? where is bsd ??? etc.

    follow this link

    http://docwiki.embarcadero.com/RADStudio/Rio/en/Supported_Target_Platforms

    So, lazarus much better idea for you. Delphi IDE just work on windows. but FPC(freePascal) and lazarus application (IDE application) work every where. raspberry pi too :)

    I created a couple of apps in Lazarus some years ago, it actually works.

    http://microhertz.org/

     

    hrm1.png

    rifer1p5.png

    • Like 1
  11. You have to check a server which is usually online,
    or a list of servers if you cannot be certain of a single server.

    In principle you can never rely fully on a single server,
    as hardware/technology by nature cannot be trusted 100%.

    If you have a list of ten servers, and half of them reply
    correctly, you can probably assume that you are connected.

    If none of them reply at all, chances are that you may not be connected.

    You can check DNS servers, but even they go down at times,
    but usually not for long. Google's DNS's are at 8.8.8.8 and 8.8.4.4.

  12. 14 hours ago, SayeyeZohor said:

    hi, i want to open url with another browser in my web application like "explorer, Mozila , ..."

    I don't think you can choose which browser to open.

    The default browser will be called, just as when you double-click an .htm file in File Explorer.

  13. Please realize that InetIsOffline function is not reliable, as this is what
    signals the tray internet status icon, and I guess we've all experienced times
    when the status claimed we had internet access while we did not have it.

    There is potentially much lag in that function, in my experience.

    The point of checking for internet connection is to be sure you have it,
    or sure you don't have it. To know this you actually have to try to get
    some data from an outside server, or preferrably several servers as the
    one server you check may be down. You can use a list of servers.

    Internet is a living thing where devices come in and drop out all the time,
    so "internet access" is a rather vague term. Define the internet?
    Even Google has been down for a little while, several times...

  14. The only "reliable" way is to try get some data from a server of your choice:

    function TMainF.isInternetConnection: Boolean;
    begin
      try
        IdHTTP.Get('http://www.svtech.cz');
      except
        on E: Exception do begin
          if not (E is EIdHTTPProtocolException) then begin
            Result := False;
            Exit;
          end;
        end;
      end;
      Result := True;
    end;

     

    • Upvote 1
  15. On 12/3/2019 at 12:21 PM, kkelchev said:

    UniGUI is the best thing that has happened for Delphi community since 10-15 years

    And I'm ready to sign this statement with my both hands.

    Have a nice day.

    I fully agree, and it is the great integration with Delphi and its visual tools,
    and the server-centric approach that makes it so powerful and almost priceless.

  16. You want to respond to http requests for doing simple tasks, and you can use Unigui for this.

    The benefit is to have all the code in one place.

    The best way to do this is to use URL parameters for those tasks, with an ID for identifying the user,
    and picking this up in the MainForm, and there choosing which subform to display.

    Normally a user would have to log in to your app, but in the MainModule you also check for
    the presence of a URL parameter and do an automatic login based on the URL ID, which
    you check against a table with an expiry date.

    So for the task you direct the user to your special form and let him do whatever it is,
    and then afterwards either log him out or direct him to his account page, e.g.

    The HTTPCommand function is presently not working in ISAPI mode, so I would not
    go that way. Besides, it is not necessary at all when you can use URL parameters as explained above.

    The only reason you would actually use HTTPCommand would be if you did not want to engage
    any forms but just do some simple HTTP response - but for that kind of job I would rather
    create a VCL service app using the Indy HTTP Server. It would give me much more freedom
    to configure the server, as it would not be running under Apache or IIS and restricted to their port.

  17. Only the simplest webapps are completely stateless, as far as I know.

    There are two basic ways to store state:
    1) on the server, using session control with session data stored on the server
    2) on the client, as a session identifier passed in the URL back and forth

    The second option is what they call stateless, as state is not stored on the server
    but on the client, so it is really not stateless per se. Please correct me if I am wrong.

    With Unigui you can do both, but since every form takes an initial loading of
    a MainModule, it may not be as efficient as with e.g. TMSWebCore, where
    you only have a bunch of html, css and js files to load.

    With good webserver preloading and caching you may come close, though.

×
×
  • Create New...