View Full Version : Action hook Hi, PreDomainRegister
Hi,
What I need to have is before a domain is registered so action hook PreDomainRegister that the domain name is send to another system.
So for example if the domain = test.com I need it to send test.com throw destination.com/index.php?domain=test.com
Hope somebody can help me how i need to do this, everything i tried did not work at all :S
thehost5968
02-28-10, 12:57 AM
You will need to give more details as the way you have above nothing will happen at destination.com/index.php?domain=test.com unless a call to the page happens and as the client is on your whmcs site page and will stay it can not be your client.
I think you need to store the info at destination.com/index.php?domain=test.com or what is happening there?
You will need to give more details as the way you have above nothing will happen at destination.com/index.php?domain=test.com unless a call to the page happens and as the client is on your whmcs site page and will stay it can not be your client.
I think you need to store the info at destination.com/index.php?domain=test.com or what is happening there?
At the moment destination.com/index.php?domain=… receives a domain it will be added to his database.
The thing is, I only need to have the domain name test.com (or whatever whmcs tells on predomainregister) send to destination.com/index.php so he can add it to his database.
For example my last try:
<?php
function create($vars) {
$domain = $vars["domain"];
echo "
<form id=\"send\" action=\"http://destination.com/add.php\" method=\"post\">
<input name=\"domain\" value=\"<?php echo $domain; ?>\" type=\"text\" />
</form>
<script type=\"text/javascript\">
function myfunc () {
var frm = document.getElementById(\"send\");
frm.submit();
}
window.onload = myfunc;
</script>";
}
add_hook("PreDomainRegister",0,"create");
?>
For example my last try:
<?php
function create($vars) {
$domain = $vars["domain"];
echo "
<form id=\"send\" action=\"http://destination.com/add.php\" method=\"post\">
<input name=\"domain\" value=\"<?php echo $domain; ?>\" type=\"text\" />
</form>
<script type=\"text/javascript\">
function myfunc () {
var frm = document.getElementById(\"send\");
frm.submit();
}
window.onload = myfunc;
</script>";
}
add_hook("PreDomainRegister",0,"create");
?>
That's not possible. Is this only something what should be posted on the background, or does the client als needs to get a output from that post?
No, it only needs to send the domain given by WHMCS to the other system so he can add it to his database.
You can try something like this:
<?php
function create($vars)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://destination.com/add.php");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 100);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, array("domain" => $vars['domain']));
$data = curl_exec($ch);
curl_close($ch);
}
add_hook("PreDomainRegister", 0, "create");
?>
It will be executed at the background. The client doesn't get any output from the hook process.
I tried but get:
Warning: Cannot modify header information - headers already sent by (output started at /home/whmcs/includes/hooks/domain_hook.php:15) in /home/whmcs/admin/ordersadd.php on line 0
Line 15 = ?>
Remove all spaces after the ?>.
Ok that did the trick :) only the domain is not added on the other system
Current code there to get the domain variable
if (isset($_POST['domain'])) {
$domain = trim($_POST['domain']);
} elseif (isset($_REQUEST['domain'])) {
$domain = trim($_REQUEST['domain']);
} else {
$domain = "";
}
Ok that did the trick :) only the domain is not added on the other system
Current code there to get the domain variable
if (isset($_POST['domain'])) {
$domain = trim($_POST['domain']);
} elseif (isset($_REQUEST['domain'])) {
$domain = trim($_REQUEST['domain']);
} else {
$domain = "";
}
That script shouldn't give any problems. To start with, you can add this to your "add.php" page:
mail("
[email protected]","Domain Add","The domain add page was called.\n\nVariables:\n".print_r(get_defined_vars(), true));
It will send you an e-mail when the page is called (to verify that the action hook does it's job). In that e-mail are also the declared variables. Based on that, you can try to customize the add script.
I don't get an e-mail, I also don't see anything in the access log that add.php has been called.
********* - - [28/Feb/2010:14:33:06 +0100] "GET /add.php HTTP/1.1" 200 557 "-" "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0)"
was the last log
Add the following line under $data = curl_exec($ch); in your action hook:
if(curl_exec($ch) === false) die(curl_error($ch));
If there's a problem with the connection, it will display the error.
also dont get a error, is this action hook working when i add an domain order throw the admin?
When I send a domain name to the registrar, it just activates the action hook on my test environment.
<?php
function testje($vars)
{
die("stop!");
}
add_hook("PreDomainRegister", 1, "testje");
?>
Well if I have made the order in the admin then set the registrar to none and made sure send to registrar is selected, I click on accept order. But the hook doesn’t do anything.
I now have edited the hook to your test hook, but it doesn’t do anything it just goes on as normally :S
You have a PM with my contact details. I am willing to take a look.
Powered by vBulletin® Version 4.2.1 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.