cluster Posted October 18, 2015 Share Posted October 18, 2015 is it possible adding PHP code inside domainoptions.tpl? I would like to remove www. http:// and .ext from SLD $_POST if entered if(isset($_POST['sld']) && strlen($_POST['sld']) > 0) { $domain = str_replace(array('www.', 'http://'), NULL, clean($_POST['sld'])); $myString = $domain; $findMe = '.'; $pos = strpos($myString, $findMe); if ($pos === false) { $sld = $domain; } else { $id1=strpos($domain, '.'); $sld = substr($domain, 0, $id1); } 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted October 18, 2015 Share Posted October 18, 2015 is it possible adding PHP code inside domainoptions.tpl?I would like to remove www. http:// and .ext from SLD $_POST if entered you could, but do you really need to? 1. if you *have* to, you could enable {php} in the settings -> other -> allow php smarty tags - but remember that at some future point, WHMCS is going to disable this option. 2. you can use PHP commands directly in Smarty.. {if ($variable|strpos:"." !== false)} 3. if you want to do this in domainoptions.tpl, can you not use the existing Smarty variables? $searchResults.tld $searchResults.sld 0 Quote Link to comment Share on other sites More sharing options...
cluster Posted October 18, 2015 Author Share Posted October 18, 2015 you could, but do you really need to? 1. if you *have* to, you could enable {php} in the settings -> other -> allow php smarty tags - but remember that at some future point, WHMCS is going to disable this option. 2. you can use PHP commands directly in Smarty.. {if ($variable|strpos:"." !== false)} 3. if you want to do this in domainoptions.tpl, can you not use the existing Smarty variables? $searchResults.tld $searchResults.sld I agree with you, it could be a security risk if using w/ allow php smarty tags. Is there a part of sample code how to use strpos and replace w/ smarty variables ... or do you think it could be done with jquery before the invalid checks? 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted October 18, 2015 Share Posted October 18, 2015 I agree with you, it could be a security risk if using w/ allow php smarty tags.Is there a part of sample code how to use strpos and replace w/ smarty variables ... or do you think it could be done with jquery before the invalid checks? my instinct would be that if there is an existing Smarty variable available that can be relied upon to be accurate for your needs, to use that - if what you're trying to do is Smarty based. with regards to strpos, let me give you two examples... the first just takes a variable, splits it into tld and sld, then displays all 3 on screen. {assign var="domain" value="google.com"} domain = {$domain} tld = {$domain|substr:($domain|strpos:"."+1)} sld = {$domain|substr:0:($domain|strpos:".")} probably in your case, you won't need to assign the variable as it will already exist, you'll just need to manipulate it. second example would be if you want to create Smarty variables from the parts.. {assign var="domsearch" value=$domain|strpos:"."} {assign var="sld" value=$domain|substr:0:$domsearch} {assign var="tld" value=$domain|substr:($domsearch+1)} {$sld} {$tld} 0 Quote Link to comment Share on other sites More sharing options...
cluster Posted October 18, 2015 Author Share Posted October 18, 2015 wow, very good! many thanks 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.