weelow Posted April 3, 2020 Share Posted April 3, 2020 Hello, I was looking for a fast way to do this, and came across the below thread, which is closed now and the original poster did not mention how he did it using global $CONFIG. I am going to describe how it can be done with a way other than directly accessing the database. In the below URL it describes how you can get the base url where WHMCS is installed Spoiler \WHMCS\Utility\Environment\WebHelper::getBaseUrl() Refrence: https://docs.whmcs.com/WHMCS_Base_URL_Template_Variable This displays retrives the base url only so if this is the link to your whmcs https://www.yourdomain.com/whmcfolder/ this function will display as follows in html "/whmcsfolder" to get the complete url to display add the following: Spoiler $protocol = $_SERVER['HTTPS'] == 'on' ? 'https' : 'http'; $baseurl = \WHMCS\Utility\Environment\WebHelper::getBaseUrl(); $url = $protocol.'://'.$_SERVER['HTTP_HOST'].$baseurl; The above $url will display as follows https://www.yourdomain.com/whmcfolder/ I hope this is useful for anyone. Additions are always welcome of course. Have a good day 0 Quote Link to comment Share on other sites More sharing options...
Kian Posted April 3, 2020 Share Posted April 3, 2020 I find easier and more reliable to select it from database with: SELECT value FROM tblconfiguration WHERE setting = 'SystemURL' LIMIT 1 With HTTP_HOST in fact you are dependent on http request header that can be manipulated while SERVER_NAME is not always available (it depends on server configuration). In conclusion I always use the one in database especially for licensing scripts 😋 0 Quote Link to comment Share on other sites More sharing options...
weelow Posted April 3, 2020 Author Share Posted April 3, 2020 Is there a faster way to get it though, i mean it should be already loaded from the database why load it again. I am trying to find if the global $CONFIG variable can do such thing but i cant find any information about it anywhere. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted April 3, 2020 Share Posted April 3, 2020 9 hours ago, weelow said: I was looking for a fast way to do this, and came across the below thread, which is closed now and the original poster did not mention how he did it using global $CONFIG. global $CONFIG; $URL = $CONFIG['SystemURL']; i'd go along with Kian and get the value from the database, either using Capsule as per your linked thread or using the model. use WHMCS\Config\Setting; $url = Setting::getValue('SystemURL'); 0 Quote Link to comment Share on other sites More sharing options...
weelow Posted April 3, 2020 Author Share Posted April 3, 2020 Thanks guys 0 Quote Link to comment Share on other sites More sharing options...
mfoland Posted April 15, 2020 Share Posted April 15, 2020 I agree! Use Capsule! I've taken the time to learn how to interact with the database using Capsule, and it's very easy 🙂 Good Luck! 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.