Jump to content

Intergration Question


craigrg

Recommended Posts

Hi people

 

I am currently working on intagrating WHMCS with my website.

 

What i am wanting to do is use the logging code that is used on the portal template on the top right which is located http://www.mydomain.com/client'>http://www.mydomain.com/client

 

I would like to use the code in the root directory http://www.mydomain.com

 

I know that there is the Integration Code in the admin panel but that does not give the welcome message when a user logs in.

 

<div id="welcome_box">{if $loggedin}{$LANG.welcomeback}, <strong>{$clientsdetails.firstname}</strong>   <img src="templates/{$template}/images/icons/details.gif" alt="{$LANG.clientareanavdetails}" width="16" height="16" border="0" class="absmiddle" /> <a href="clientarea.php?action=details" title="{$LANG.clientareanavdetails}"><strong>{$LANG.clientareanavdetails}</strong></a>   <img src="templates/{$template}/images/icons/logout.gif" alt="{$LANG.logouttitle}" width="16" height="16" border="0" class="absmiddle" /> <a href="logout.php" title="Logout"><strong>{$LANG.logouttitle}</strong></a>{else}{$LANG.please} <a href="clientarea.php" title="{$LANG.loginbutton}"><strong>{$LANG.loginbutton}</strong></a> {$LANG.or} <a href="register.php" title="{$LANG.clientregistertitle}"><strong>{$LANG.clientregistertitle}</strong></a>{/if}</div>

Link to comment
Share on other sites

Not the most beautiful solution, but it will do the job:

 

<?php
require("client/dbconnect.php"); // Give in the path to the dbconnect.php in the WHMCS root.

if($_SESSION['uid'])
{
$result = mysql_query("SELECT firstname FROM tblclients WHERE id='".$_SESSION['uid']."' LIMIT 1;");

while($row = mysql_fetch_array($result))
	echo $_LANG['welcomeback'].", ".$row['firstname']."<br /><a href=\"clientarea.php?action=details\"><strong>".$_LANG['clientareanavdetails']."</a> <a href=\"logout.php\"><strong>".$_LANG['logouttitle']."</strong></a>";
}
else
echo $_LANG['please']." <a href=\"clientarea.php\" title=\"Login\"><strong>".$_LANG['loginbutton']."</strong></a> ".$_LANG['or']." <a href=\"register.php\" title=\"Register\"><strong>".$_LANG['clientregistertitle']."</strong></a>";
?>

Edited by m00
Link to comment
Share on other sites

HTML is a static code, PHP is dynamic. You can't run PHP code inside a HTML file. What you can do is the following. Make a file in your WHMCS directory (/client/) called status.php and put in the following code:

<?php
require("dbconnect.php");

if($_SESSION['uid'])
{
   $result = mysql_query("SELECT firstname FROM tblclients WHERE id='".$_SESSION['uid']."' LIMIT 1;");

   while($row = mysql_fetch_array($result))
       echo "document.write('".$_LANG['welcomeback'].", ".$row['firstname']." | <a href=\"clientarea.php?action=details\"><strong>".$_LANG['clientareanavdetails']."</a> <a href=\"logout.php\"><strong>".$_LANG['logouttitle']."</strong></a>');";
}
else
   echo "document.write('".$_LANG['please']." <a href=\"clientarea.php\" title=\"Login\"><strong>".$_LANG['loginbutton']."</strong></a> ".$_LANG['or']." <a href=\"register.php\" title=\"Register\"><strong>".$_LANG['clientregistertitle']."</strong></a>');";
?> 

 

Put the following code in your HTML page:

 

<script type="text/javascript" src="client/status.php"></script>

 

It will show you the login status using Javascript, which is possible in HTML.

Link to comment
Share on other sites

  • 11 years later...

I'm using the 3rd party payment gateway has a callback file, however the callback file is not too much protected due to IPN response from the gateway, since I wanted to know if I can make the $CUSTOM_SESSION['invoice_id'] in view invoice as client page , then check the invoice id at callback file. 

Link to comment
Share on other sites

The above code wont work because mysql_query was removed in PHP 7 and really using WHMCS internal classes and making WHMCS do the heavy lifting for database access is the preferred way, at least IMO.   As such, here you go in a untested rewrite:

<?php
require("../init.php");
use WHMCS\User\Client;

/*
 * @Author steven99
 *  Get status of current status of client and welcome them back or have them login .
 *  NOTE: This will only work within WHMCS and not an external page as it requires
 *  the same PHP session to be used
 */
global $_LANG;

if (isset($_SESSION['UID']) and is_numeric($_SESSION['UID']))
{
    $Client = Client::find($_SESSION['UID']);
    if ($Client)
    {?>
        <?=$_LANG['welcomeback']?> <?=$Client->firstname?> <a href="clientarea.php?action=details"><strong><?=$_LANG['clientareanavdetails']?></a> <a href="logout.php"><strong><?=$_LANG['logouttitle']?></strong></a>
    <?php
    }
}
else
{?>
    <?=$_LANG['please']?> <a href="clientarea.php" title="Login"><strong><?=$_LANG['loginbutton']?></strong></a><?=$_LANG['or']?> <a href="register.php" title="Register"><strong><?=$_LANG['clientregistertitle']?></strong></a>
<?php
}

 

Edited by steven99
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