Jump to content

Create a simple hook for showing IP-number throughout the website?


-M-

Recommended Posts

Hi guys,

 

Well I am getting the hang of WHMCS and modifying the (Smarty) templates, but still have problems with running / creating (simple) hooks.

 

I mentioned this about 1 or 2 months ago, but still haven't been able to get it working. I am getting fatal errors and blank pages so far. Or if I do something correctly, nothing shows up.

 

I have sort of similar code on my main (non-WHMCS) page and it works.

 

The (non-working) hook I have created looks like this:

 

(I changed the RSS feed from our own to one from the BBC)

 

require($_SERVER['DOCUMENT_ROOT'].'/includes/MagicParser.php');

function tidy_substr($text,$length,$append=""){
	if (strlen($text) > $length){
	  $breakOffset = $length;
	  if ($breakOffset !== false){
		$text = substr($text,0,$breakOffset).$append;
	  }
	}
	return $text;
}

                 $counter = 0;
                 function myRecordHandler($record) {
                   global $counter;
                   print "<a class='list-group-item whrssfeedfix' href=".$record["LINK"].">".$record["TITLE"]."</a>";
                 $counter++;
                 return ($counter == 10);
                  }

                 $url = "http://feeds.bbci.co.uk/news/world/rss.xml";

	  MagicParser_parse($url,"myRecordHandler","xml|RSS/CHANNEL/ITEM/");

 

This code doesn't provide me any errors (no fatal PHP errors, no blank pages), however nothing shows up either; it's just blank.

 

Maybe I need to make some call to this, in order to get it displayed?

 

If I enable PHP-tags in WHMCS, and I copy the above code into the clientareahome.tpl it works without problems.

But as Brian pointed out some while ago, it's better not to enable PHP-tags. And this is the only case I even use them. So I rather get rid of this.

 

There are other RSS solutions, however I want to be able to use this one, because;

 

a) I purchased this script a while back and been using it ever since

b) it also has a caching system (not enabled in the above coding), so it doesn't hammer our servers.

 

Anyways, I really don't know how to make a call for this from within the clientareahome.tpl.

 

 

Also, something else, but also related to hooks.

 

How do you create a hook for WHMCS, so you can always display the users IP anywhere on the WHMCS site?

The general one, which is called {$ipaddress}, doesn't work everywhere. I want something simple which uses $_SERVER['REMOTE_ADDR']; in order to display the user's IP address anywhere where I please.

 

Thank you in advance for your help. I hope someone can help me out with this.

Edited by MvdL1979
Fixed typo in require address.
Link to comment
Share on other sites

Also, something else, but also related to hooks.

 

How do you create a hook for WHMCS, so you can always display the users IP anywhere on the WHMCS site?

The general one, which is called {$ipaddress}, doesn't work everywhere. I want something simple which uses $_SERVER['REMOTE_ADDR']; in order to display the user's IP address anywhere where I please.

it would be simple to create a hook to do this, but you should be able to use the Smarty code below to show the IP in a template wherever you want.

 

{$smarty.server.REMOTE_ADDR}

you might wish to use it in an if statement to first see if $ipaddress exists, if so use it... else use the above.

Link to comment
Share on other sites

If I enable PHP-tags in WHMCS, and I copy the above code into the clientareahome.tpl it works without problems. But as Brian pointed out some while ago, it's better not to enable PHP-tags. And this is the only case I even use them. So I rather get rid of this.

I don't think I would have set not to enable them, just to be aware that at some future point, WHMCS will disable the option. :idea:

 

if it were me, and the above php code works in the template, i'd happily use {php} tags in the short-term and add the code in the template... then work on finding a hook solution in the long-term.

 

WHMCS development is a slow beast, and WHMCS are vague with dates at the best of times - so when they say "may be removed in a future versions.", it's removal is not imminent... at a guess, you're probably looking at Summer 2016 after v6 has been available for a year.. but don't hold me to that! :)

 

with regards to the hook, you might get a better response by posting in Marketplace and offering to pay for a solution... if you already have working code, then it shouldn't need a great deal of work to change it to a working hook.

Link to comment
Share on other sites

I emailed the developer of this script, maybe he can help.

 

For the time being I will use the {php} tags. Guess I will have settle with that for the time being.

 

yeah, well to be honest, the budget for WHMCS is depleted after already having developers working on it for over 500 USD. :)

 

Anyways, thank you for answering.

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