Results 1 to 18 of 18
  1. #1
    Join Date
    Apr 2012
    Location
    United States
    Posts
    1,249

    display badge just on ssl pages

    Hi, i want to display my SSL badge on the page but the instructions from the company say to display it just on pages that are https i have my WHMCS set to https://www.sitename.com/billing but the https does not appear until i go to order or login.

    In other words portal home is not SSL. I am familiar with the templates but not sure how to do just the pages that are SSL without having to put the badge on every single template page. Is there a primary local i can put this..

    THanks

  2. #2
    Join Date
    Apr 2012
    Location
    San Francisco, CA
    Posts
    25
    You could use JavaScript to display the badge only if the page was accessed over SSL.

    For example:

    HTML Code:
    <div id="sslbadge" style="display: none;">
        <img src="..."/>
    </div>
    
    <script>
    if ("https:" === window.location.protocol) {
        document.getElementById('sslbadge').style.display = '';
    }
    </script>
    ServerPilot - modern, secure hosting control panel for cloud servers and VPSes.
    Manage all of your servers and PHP apps from one, central location.
    Optimized for developers, businesses, and hosting companies selling VPSes.
    Follow @ServerPilot on Twitter.

  3. #3
    Join Date
    Apr 2012
    Location
    United States
    Posts
    1,249
    Thats great thanks so much, i thought about JS but i didnt know what to use in the if statement, thanks so much... awesome..

  4. #4
    Join Date
    Sep 2008
    Posts
    87
    You could use PHP in the templates to check for SSL:

    Code:
    {php}
      if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER 'SERVER_PORT'] == 443) {
        echo '<div id="sslbadge" style="display: none;"><img src="..."/></div>';
      }
    {/php}
    This would check it on the server side, as opposed to the client side, as it would with javascript. You would have to add it to header.tpl or footer.tpl to get it to display on every page in WHMCS.

  5. #5
    Join Date
    Apr 2012
    Location
    San Francisco, CA
    Posts
    25
    You're very welcome.
    ServerPilot - modern, secure hosting control panel for cloud servers and VPSes.
    Manage all of your servers and PHP apps from one, central location.
    Optimized for developers, businesses, and hosting companies selling VPSes.
    Follow @ServerPilot on Twitter.

  6. #6
    Join Date
    Apr 2012
    Location
    United States
    Posts
    1,249
    thanks also sean

  7. #7
    Join Date
    Apr 2012
    Location
    United States
    Posts
    1,249
    i tried this but it does not work just fyi, not sure why

    PHP Code:

    {if !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443}
    <
    center>
    <
    img src="/images/ssl_seal.gif" border="0" alt="SSL Seal" />
    </
    center>
    {/if} 
    sean you do have a typo in your code $_SERVER 'SERVER_PORT'] u forgot the open backet [ but even with that it will not pick up the ssl page, im doing some testing.

  8. #8
    Join Date
    Apr 2012
    Location
    United States
    Posts
    1,249
    Its not picking up the js way either


    Code:
    <div id="sslbadge" style="display: none;">
        <img src="/images/ssl_seal.gif" border="0" alt="SSL Seal" />
    </div>
    <script type="text/javascript">
    if ("https:" === window.location.protocol) 
    {
     document.getElementById('sslbadge').style.display = 'block';
    }
    </script>

  9. #9
    Join Date
    Apr 2012
    Location
    United States
    Posts
    1,249
    @Justin well bud looks like your solution was the winner here lol.. although i did have to make some small changes.


    here is what finally worked and this is in footer tpl

    i checked the source and in the source it was only showing this much.

    Code:
    <script type="text/javascript">
    if(location.protocol === "https:") 
    </script>
    so i was like ok no wonder its not doing anything because its not being told what to do. So then i realized (and this is a guess on my part) that since this is inside a smarty tpl file and smarty uses {} for php operations, then it probably confused the portion inside the js brackets for php.

    So i removed the brackets which i think are just for decoration anyway, and whallaaa there it was.

    i did try to use margin:0px auto to center and stay away from the center tag but nothing i tried css wise worked so i juse went back to the center tag.

    here is the final code..

    Code:
    <!-- added to only show seal on ssl pages -->
    <div id="sslbadge" style="display:none;">
        <center>
        <img src="/images/ssl_seal.gif" border="0" alt="SSL Seal" />
        </center>  
    </div>
    
    <script type="text/javascript">
    if(location.protocol === "https:") 
     document.getElementById('sslbadge').style.display = '';
    </script>
    <!-- end add -->
    Thanks everyone who replied

  10. #10
    Join Date
    Sep 2008
    Posts
    87
    Sorry for the typo. I found that code after a quick Google search. I would be more inclined to do this check at a server level (PHP), rather than relying on Javascript (client level). With all the different web browsers out there (especially different versions of IE), you may get different results from clients. Just my opinion...

  11. #11
    Join Date
    Feb 2006
    Posts
    4,799
    You can go with a simpler approach via PHP in the smarty templates as well:

    Code:
    {php}
    if($_SERVER['SERVER_PORT']==443){
    $sslbadge = '<div id=\"sslbadge\" style=\"display:none;\"><center><img src=\"/images/ssl_seal.gif\" border=\"0\" alt=\"SSL Seal\" /></center></div>';}
    else{$sslbadge = 'none';}
    {/php}
    You would then need to add the following to the template where the badge was to be displayed.

    Code:
    {php}
    if($sslbadge!='none'){echo $sslbadge;}
    {/php}
    You could always include the badge on every load and just toggle the display with php as well.
    WHMEasyBackup.com - Take Control Of Your Backups!
    Complete Backup Solution For WHM Reseller Accounts
    Download Trial

  12. #12
    Join Date
    Apr 2012
    Location
    United States
    Posts
    1,249
    I agree Sean and im not really sure why that php i came up with for the template file would not work, it follows the same format as the rest of the php code in the smarty tpl file.

    But who knows, maybe even though those are server functions maybe they still need to be defined in smarty first, im not sure why it did work. If thats the case i would have to do a new php file and write a quick hook for WHMCS as the php files are encrypted. I maybe fiddle with this a bit more when i have more time..

    Thanks for the reply, that was a good find..

    @DWS thanks so much....i fiddle with this when i have more time
    Last edited by durangod; 11-27-2013 at 02:00 PM.

  13. #13
    Join Date
    Sep 2008
    Posts
    87
    Quote Originally Posted by DWS2006 View Post
    You can go with a simpler approach via PHP in the smarty templates as well:

    Code:
    {php}
    if($_SERVER['SERVER_PORT']==443){
    $sslbadge = '<div id=\"sslbadge\" style=\"display:none;\"><center><img src=\"/images/ssl_seal.gif\" border=\"0\" alt=\"SSL Seal\" /></center></div>';}
    else{$sslbadge = 'none';}
    {/php}
    You would then need to add the following to the template where the badge was to be displayed.

    Code:
    {php}
    if($sslbadge!='none'){echo $sslbadge;}
    {/php}
    You could always include the badge on every load and just toggle the display with php as well.
    I think to get that to work, you would have to create the template variable in your PHP code:

    Code:
    $this->_tpl_vars['sslbadge'] = $sslbadge;

  14. #14
    Join Date
    Feb 2006
    Posts
    4,799
    Anything inside {php}{/php} tags should parse just like normal php, unless they've updated something. I have code included that way in the latest release and it still works. It should work fine as long as both snippets are included in the same template file (Though you could just as easily do it all in one go, I just like to separate the base function from the display - but that's old school). I'm assuming something like this will be in the header/footer files.
    WHMEasyBackup.com - Take Control Of Your Backups!
    Complete Backup Solution For WHM Reseller Accounts
    Download Trial

  15. #15
    Join Date
    Sep 2008
    Posts
    87
    Agreed. So, the first piece of code would need to be called on every page (in the header or footer), to use the second piece of code in all templates.
    Last edited by SeanCP; 11-27-2013 at 02:23 PM.

  16. #16
    Join Date
    Feb 2006
    Posts
    4,799
    Quote Originally Posted by SeanCP View Post
    Code:
    $this->_tpl_vars['sslbadge'] = $sslbadge;
    I think you would need to add the code you quoted to do anything cross-template. But if this is just going to be used in the header or footer, no real need to define template vars.
    WHMEasyBackup.com - Take Control Of Your Backups!
    Complete Backup Solution For WHM Reseller Accounts
    Download Trial

  17. #17
    Join Date
    Apr 2012
    Location
    United States
    Posts
    1,249
    seems to be working, thanks so much


    PHP Code:

    <!-- added to only show seal on ssl pages -->
    {
    php}
    if (!empty(
    $_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443)
    {
    echo 
    "<center><img src=\"/images/ssl_seal.gif\" border=\"0\" alt=\"SSL Seal\" /></center>";
    }  
    {/
    php}
    <!-- 
    end add --> 

  18. #18
    Join Date
    Sep 2008
    Posts
    87
    Glad to hear it. As DWS2006 stated earlier, you can use PHP code, within the templates, as long as it is within the {php} {/php} tags.

Similar Threads

  1. any ideas why non-ssl pages are blank, ssl pages work
    By AtoZ in forum Hosting Security and Technology
    Replies: 3
    Last Post: 02-01-2008, 11:49 PM
  2. IE does not display pages correctly
    By num85 in forum Web Design and Content
    Replies: 7
    Last Post: 11-20-2007, 01:51 AM
  3. multiple pages display for search
    By furqan_sindhu in forum Web Design and Content
    Replies: 2
    Last Post: 04-04-2006, 12:29 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •