Jump to content

Auto suspend failing on cron due to license check


SeanP

Recommended Posts

I have a custom module, that is licensed using the WHMCS Licensing Addon. All of the functions, including the "Suspend" function, work properly when the buttons are pressed from the admin area. However, when the admin cron job runs, and attempts to auto suspend a product because it is overdue on payment, the auto suspend does not work. Apparently, when it cron job calls the suspend function in the module, it does not report an IP or domain when doing the license check, and the module is failing with a licensing error. The license check requires a valid IP and domain to work properly. How do I resolve this, as the cron job does not send an IP or domain? I've tried this from two different servers (one prod, and one dev) with no luck. Am I missing something?

 

Sean

Link to comment
Share on other sites

It appears the license check uses the $_SERVER array to determine the IP and domain ($_SERVER['SERVER_ADDR'] for IP and $_SERVER['SERVER_NAME'] for domain). This does not work for CLI applications, or when running the module functions from the command line (as during execution of the cron script). Instead, you can use the following:

 

$host= php_uname('n'); // or $host = gethostname(); if using php 5.3 or later

$ip = gethostbyname($host);

 

So, I guess I will need to modify the license check code, to use these php functions, if the $_SERVER array doesn't return anything.

 

Has anyone else run into this issue for licensed server modules?

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