•  · 6 friends

UNA installer still forgot to detect http or https

I just upgrading to Dolphin 7.4.1. Next step I should start to study how to use dolphin_migration for migration dolphins to UNA.

But, on the UNA website, downloaded UNA 9 with only 4 modules. So I downloaded UNA on github:

https://github.com/unaio/una

UNA installer still forgot to detect http or https, If the site is already using https, we will see a messy page after the installation is complete.

💓0 😆0 😲0 😥0 😠0 0
  • 999
  • More
Replies (3)
    • UNA installer detects if https by checking 'HTTPS' server variable, usually it's set when site is using https, if you have another way to properly detect https you are welcome to share it.

      💓0 😆0 😲0 😥0 😠0 0
      • Maybe in your or other server support $_SERVER['HTTPS'], but my server not support that.

        So, when we install Dolphin or UNA, we will see the wrong URL. please see install01 and install02.

        I writing this program to display the environment variables supported by my server:

        < ? php
        echo '<PRE>';
        print_r($_SERVER);
        echo '</PRE><br />';

        please see install03 for Server A and install04 for Server B.

        You can see that there is no $_SERVER['HTTPS'] in the server variable.

        therefore I use $_SERVER['HTTP_X_FORWARDED_PROTO'] to rewrite this proto()

            protected function proto()
            {
                if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']))
                    return $_SERVER['HTTP_X_FORWARDED_PROTO'] . '://';
                elseif ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS']) || getenv('UNA_HTTPS'))
                    return 'https://';
                else
                    return 'http://';
                //return (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS']) || getenv('UNA_HTTPS') ? 'https://' : 'http://';
            }

        OR

            protected function proto()
            {
                if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']))
                    return $_SERVER['HTTP_X_FORWARDED_PROTO'] . '://';
                else
                    return (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS']) || getenv('UNA_HTTPS') ? 'https://' : 'http://';
            }
        
        

        Please see install5 for the execution result of the installation.

        This is the dolphin installer's index.php:

        $confFirst['site_url']  = array(
            'name'    => "Site URL",
            'ex'      => "http://www.mydomain.com/path/",
            'desc'    => "Your site URL (slash at the end is required)",
            'def'     => "http://",
            'def_exp' => function () {
                    $str = $_SERVER['HTTP_X_FORWARDED_PROTO'].'://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];
                    return preg_replace("/install\/(index\.php$)/", "", $str);
            },
            'check'   => function ($arg0) { return strlen($arg0) >= 10 ? true : false; }
        );

        P.S. When I re-edited the article iin Dolphin  (of blog) and UNA, some words in PHP and HTML disappeared and could not be used! for example:

        ' < PRE > ' ;

        < ? php

        But there is no such problem in the Dolphin Forum!

        💓0 😆0 😲0 😥0 😠0 0
        • Thank you for the explanation and sample code:

          https://github.com/unaio/una/issues/2062

          💓0 😆0 😲0 😥0 😠0 0
          Not logged in users can't 'Comments Post'.
          2
          2
          Added:
          Category:

          UNA - Network Infrastructure for Communities

          Close