Jump to content

How to set up hook to make DNS management automatic?


Recommended Posts

I took the part of the registration process where the viewer clicks "DNS management" out, as I found it confusing. I would like to allow my clients to manage their DNS settings if they choose to do so, and would like to set it up so that DNS management is automatically turned on. I understand that in their account area along with their support tickets and invoices, will be an area to manage DNS.

 

I have heard that I need to set up a hook to make this happen, but I am not a programmer. Is there some existing code that I can paste in?

 

I would be super appreciative if anyone can point me in the right direction. Thanks!

Link to comment
Share on other sites

This code should do it for you... I tested it on my dev setup so it works :)

 

Just to confirm what it does: it will turn DNS Management ON for EVERY domain in your system. If that's not what you want, don't install it!

 

<?php

// Written by Josh Bonfield - josh@b-digital.biz

// Place these lines in a file called autodns_manage_hook.php in the /includes/hooks/ folder

// On the daily cron, it will search for all who have DNS management as OFF and set it to ON.

function autodns_manage_hook()
{
   // Set all DNS Management options to ON

   $sql = "SELECT id FROM `tbldomains` WHERE `dnsmanagement` = '';";
   $sql = mysql_query($sql);

   while($row = mysql_fetch_assoc($sql))
   {
       // Loop through & set them all to 'on'
       $sql2 = "UPDATE `tbldomains` SET `dnsmanagement` = 'on' WHERE `tbldomains`.`id` =".$row["id"].";";
       $sql2 = mysql_query($sql2);
   }
}

add_hook('DailyCronJob', 0, 'autodns_manage_hook');

?>

Link to comment
Share on other sites

  • 2 weeks later...

Not really sure why you're looping through all the domains, its not really needed other than to add extra fluff to basically a one-liner.

 

Try this:

function autodns_manage_hook()
{
     update_query("tbldomains", array("dnsmanagement"=>"on"), array("dnsmanagement"=>""));
}

add_hook('DailyCronJob', 0, 'autodns_manage_hook');

Link to comment
Share on other sites

Thanks, should I place the code in a file called autodns_manage_hook.php in the /includes/hooks/ folder? I got the same result as using bdigitalstudios code, it places the following code above my website (visible in the frontend):

 

{\rtf1\ansi\ansicpg1252\cocoartf1038\cocoasubrtf250 {\fonttbl\f0\fmodern\fcharset0 Courier;} {\colortbl;\red255\green255\blue255;} \margl1440\margr1440\vieww9000\viewh8400\viewkind0 \deftab720 \pard\pardeftab720 \f0\fs24 \cf0 function autodns_manage_hook()\ \{\ update_query("tbldomains", array("dnsmanagement"=>"on"), array("dnsmanagement"=>""));\ \}\ \ add_hook('DailyCronJob', 0, 'autodns_manage_hook');\ }

 

Could this be due to the fact that I am using softwared called Jintegrator! to integrate WHMCS into joomla?

Link to comment
Share on other sites

ok, I looked at the configuration.php file in the root of my WHMCS, as well as the joomla one, I didnt see anyting about display_errors. Which file, and where?

 

display_errors would be in the configuration.php file for whmcs. Its not there by default, so you would have had add it for it to be there.

 

Otherwise I'm not sure what the problem might be.

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