Jump to content

Get client servers name from new created php page


peto

Recommended Posts

Hi, I'm new to this world and I'm a bit lost about the resources that WHMCS provides to integrate this solution within our bussines.

 

I'm trying to create a link to a external web site like (sitebuilder.server.myserver.es) from the WHMCS client area administration page. So, I have created a link on that page modifying homepage.tpl, that redirects to a php page called sitebuilder.php.

 

Ok, now in that page (sitebuilder.php) i want to redirect the user to one or another page depending on the server where he has his domain hosted. Seeing this code may help to understand what im trying to do:

 

<?php

define("CLIENTAREA", true);

require("dbconnect.php");
require("includes/functions.php");
require("includes/clientareafunctions.php");

// Comprobamos si el usuario está logeado
if ($_SESSION['uid']) {
 // $sitebuilderserver = " ";
 header("Location: http://sitebuilder.server." . $sitebuilderserver . ".es");
} else {
 // Cargamos el entorno WHMCS
 $pagetitle = $_LANG['clientareatitle'];
 $pageicon = "images/support/clientarea.gif";
 $breadcrumbnav = '<a href="index.php">' . $_LANG['globalsystemname'] . '</a>';
 $breadcrumbnav .= ' > <a href="sitebuilder.php">' . $_LANG['sitebuildertitle'] . '</a>';
 initialiseClientArea($pagetitle, $pageicon, $breadcrumbnav);
 // Archivo template para realizar login
 $templatefile = "login";
 $smartyvalues["formaction"] = "dologin.php?goto=sitebuilder";
}

outputClientArea($templatefile);

?>

 

I suppose i'll have to consult mysql database to get what i need, but i don't know which tables. ¿Is there any reference about the database?¿Any idea of what should i do to obtain that server names?

 

Maybe I could do it in a loaded smarty template file accessing a variable like $clientdetails.servers or something like that but i need to do it directly from the php file.

 

Thanks in advance.

Link to comment
Share on other sites

Try This:

 

<?php 

define("CLIENTAREA", true); 

require("dbconnect.php"); 
require("includes/functions.php"); 
require("includes/clientareafunctions.php"); 

// Comprobamos si el usuario está logeado 
if ($_SESSION['uid']) { 
 $uid = $_SESSION['uid'];
 $sql = "SELECT s.hostname FROM tblservers s, tblhosting h WHERE h.userid = $uid AND s.id = h.server";
 $data = mysql_query($sql);
 $row = mysql_fetch_array($data);
 $sitebuilderserver = $row[0];
 header("Location: http://sitebuilder.server." . $sitebuilderserver . ".es"); 
} else { 
 // Cargamos el entorno WHMCS 
 $pagetitle = $_LANG['clientareatitle']; 
 $pageicon = "images/support/clientarea.gif"; 
 $breadcrumbnav = '<a href="index.php">' . $_LANG['globalsystemname'] . '</a>'; 
 $breadcrumbnav .= ' > <a href="sitebuilder.php">' . $_LANG['sitebuildertitle'] . '</a>'; 
 initialiseClientArea($pagetitle, $pageicon, $breadcrumbnav); 
 // Archivo template para realizar login 
 $templatefile = "login"; 
 $smartyvalues["formaction"] = "dologin.php?goto=sitebuilder"; 
} 

outputClientArea($templatefile); 

?>

 

Of course, this probably wont work, since some customers may have more than 1 account. You'd need to make a loop if you want to link all of their accounts this way.

 

This is also completely untested, so good luck. :)

Link to comment
Share on other sites

Thanks for the reply. I used your suggestion to finally get this query:

 

$sql = "SELECT s.hostname
         FROM tblservers s
         INNER JOIN tblhosting h
         ON s.id=h.server
         WHERE h.userid = $uid";

 

That way I can obtain those clients that have an active domain ignoring those who don't.

 

By the way, I found all the database information from a getting a backup and loading it into a local SQL client, so I think I won't have this kind of troubles any more hehe.

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