Jump to content

using php in domainoptions.tpl


cluster

Recommended Posts

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);
}

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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}

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated