We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 22303 MODX Staff
    • 10,725 Posts
    I'd like to propose we add one additional dynamic global variable to be determined in config.inc.php along with $base_path and $base_url. Currently, $base_url returns the relative path, which is wonderful. However, at times, I need know the absolute URL of the site, including if it is an SSL request, or coming in on a different port. In those cases I propose a method like this...

    	$site_url = (!isset($_SERVER['HTTPS']) || strtolower($_SERVER['HTTPS']) != 'on')? "http://" : "https://" ;
    	$site_url .= $_SERVER['HTTP_HOST']; 
    	$site_url .= ($_SERVER['SERVER_PORT']==80 || isset($_SERVER['HTTPS']) || strtolower($_SERVER['HTTPS'])=='on')? "":":".$_SERVER['SERVER_PORT']; 
    	$site_url .= "/";
    


    I can then use this to easily fix the [+surl+] bug in the emails.

    In addition, I'm going to add one additional parameter to the mail() call to prevent user's spam detection systems from rejecting the MODx emails as spam (since the return-path on shared servers is often different from the $emailsender set in the site configuration) -->
    ... ,"-f $emailsender")


    The -f switch tells sendmail to set the return-path to the specified address.

    Any concerns or alternate ideas?
      • 32963
      • 1,732 Posts
      Sounds very good Jason.

      The only problem I'm having is that I seem to be confusing site_url with base_url. When I first read about a need for site_url I said but base_url already exists! To me name site_url means the url for the website or subsite (e.g. www.myname.com/maryj).

      IMO I would use $host_url instead.

      exmaple:

      Modx site https://www.myname.com/maryj

      $base_url = /maryj
      $base_path = c:/sites/maryj
      $host_url = https://www.myname.com/

      we could even have $base_full_url = https://www.myname.com/maryj/ which would be just a combination of host_url and base_url

      What do you think?
        xWisdom
        www.xwisdomhtml.com
        The fear of the Lord is the beginning of wisdom:
        MODx Co-Founder - Create and do more with less.
        • 22303 MODX Staff
        • 10,725 Posts
        The only problem I'm having is that I seem to be confusing site_url with base_url. When I first read about a need for site_url I said but base_url already exists! To me name site_url means the url for the website or subsite (e.g. www.myname.com/maryj).

        IMO I would use $host_url instead.

        exmaple:

        Modx site https://www.myname.com/maryj

        $base_url = /maryj
        $base_path = c:/sites/maryj
        $host_url = https://www.myname.com/

        we could even have $base_full_url = https://www.myname.com/maryj/ which would be just a combination of host_url and base_url

        What do you think?

        shockedops:

        I think I was looking to build $base_full_url in the first place (that's why I had all that other code there with the REQUEST_URI :idea: ) -- anyway, I don't see any purpose for $host_url at this point...do you? If not, I'll just append the $base_url onto my idea and create $base_full_url. Sound good?
          • 32963
          • 1,732 Posts

          I think I was looking to build $base_full_url in the first place (that's why I had all that other code there with the REQUEST_URI :idea: ) -- anyway, I don't see any purpose for $host_url at this point...do you? If not, I'll just append the $base_url onto my idea and create $base_full_url. Sound good?

          Sounds very good.
            xWisdom
            www.xwisdomhtml.com
            The fear of the Lord is the beginning of wisdom:
            MODx Co-Founder - Create and do more with less.