Jump to content

Down for Maintenance when using integration code


Keksi

Recommended Posts

Hi,

 

I'm trying to get a integrationcode to work in MODX.

 

What I'm trying to accomplish is:

If user is logged in = Show some links, etc.

If user is logged out = Show loginform.

 

I have tried so many scripts from this forum, but i cant really get anyone to work.

 

With the last one, i have actually got the integration halfway correct i think. The problem is that i get the standard whmcs "Down for Maintenance - Upgrade in progress" message.

 

This is the code I'm trying to use:

require("dbconnect.php");

if (!empty($GLOBALS['clientsdetails']['id']))
   {
       require_once ("includes/clientfunctions.php");
       $userdetails = getclientsdetails($GLOBALS['clientsdetails']['id']);
   }
   $firstname= $userdetails['firstname'];

if ($_SESSION['uid'] > 0) {
echo "<strong>Hello $firstname! You are logged in.</strong>   <a href=\"/logout.php\">(Click for Logout)</a>";
}
else 
{ 
echo "Login form is put in here";
} 

1108498.jpeg

 

So:

1. Anyone have a clue on how i can resolve this?

2. Do i really need to include dbconnect.php, when both MODX and WHMCS is in the same DB?

When not including the dbconnect.php file, the script shows me the loginform, even when I'm actually logged in to the client area.

Link to comment
Share on other sites

I dont know about modx, but the inclusion of dbconnect pulls in the required functions to use WHMCS.

 

Have you tried to var_dump $GLOBALS? I'm willing to bet that $GLOBALS['clientsdetails']['id'] is not set.

 

If they are indeed logged in, you can use $_SESSION['uid'] assuming that WHMCS is on the same domain.

 

Something like this maybe

 

require_once ("dbconnect.php");
require_once ("includes/clientfunctions.php");

if ((isset($_SESSION['uid'])) && ($_SESSION['uid'] > 0)) {
 $userdetails = getclientsdetails($_SESSION['uid']);
 $firstname= $userdetails['firstname'];
 echo "<strong>Hello $firstname! You are logged in.</strong>   <a href=\"/logout.php\">(Click for Logout)</a>";
} else {
 // not logged in
}

Link to comment
Share on other sites

Thanks for your reply.

 

When using this code, i still get the Down for Maintenance message.

 

When removing "require_once ("dbconnect.php");"

I get the logged out message.

 

If var_dump $GLOBALS can help understand whats wrong, how to i write that in a PHP code?

When using:

<?php
var_dump $GLOBALS
?>

I get this message:

Parse error: syntax error, unexpected T_VARIABLE in /home/path-to-home-area/core/cache/includes/elements/modsnippet/44.include.cache.php on line 10

Witch is a part of MODX

Link to comment
Share on other sites

Ok, i tried that now and copied the result to Notepad.

Length: 319679.......

 

I tried searching for "clientsdetails" and i got two results inside here:

$thread->remove(); } } break; } return;" ["locked"]=> string(1) "0" ["properties"]=> NULL ["disabled"]=> string(1) "0" ["moduleguid"]=> string(0) "" ["static"]=> string(1) "0" ["static_file"]=> string(0) "" } } ["sourceCache"]=> array(3) { ["modChunk"]=> array(0) { } ["modSnippet"]=> array(1) { ["WHMCSLogin"]=> array(3) { ["fields"]=> array(15) { ["id"]=> int(44) ["source"]=> int(1) ["property_preprocess"]=> bool(false) ["name"]=> string(10) "WHMCSLogin" ["description"]=> string(0) "" ["editor_type"]=> int(0) ["category"]=> int(0) ["cache_type"]=> int(0) ["snippet"]=> string(381) "require_once ("includes/clientfunctions.php"); if ((isset($_SESSION['uid'])) && ($_SESSION['uid'] > 0)) { $userdetails = getclientsdetails($_SESSION['uid']); $firstname= $userdetails['firstname']; echo "Hello $firstname! You are logged in. (Click for Logout)"; } else { // not logged in } var_dump($GLOBALS);" ["locked"]=> bool(false) ["properties"]=> array(0) { } ["moduleguid"]=> string(0) "" ["static"]=> bool(false) ["static_file"]=> string(0) "" ["content"]=> string(381) "require_once ("includes/clientfunctions.php"); if ((isset($_SESSION['uid'])) && ($_SESSION['uid'] > 0)) { $userdetails = getclientsdetails($_SESSION['uid']); $firstname= $userdetails['firstname']; echo "Hello $firstname! You are logged in. (Click for Logout)"; } else { // not logged in } var_dump($GLOBALS);" } ["policies"]=> array(1) { ["web"]=> array(0) { } } ["source"]=> array(6) { ["id"]=> int(1) ["name"]=> string(10) "Filesystem" ["description"]=> string(0) "" ["class_key"]=> string(26) "sources.modFileMediaSource" ["properties"]=> array(0) { } ["is_stream"]=> bool(true) } } } ["modTemplateVar"]=> array(0) { } } ["Event"]=> NULL ["stopOnNotice"]=> bool(false) ["pdo"]=> &object(PDO)#11 (0) { } ["config"]=> array(277) { ["access_category_enabled"]=> string(1) "1" ["access_context_enabled"]=> string(1) "1" ["access_resource_group_enabled"]=> string(1) "1" ["allow_forward_across_contexts"]=> string(0) "" ["allow_manager_login_forgot_password"]=>

 

But it looks like it is only showing exactly what i (you) wrote in the php script.

 

This is the script i used:

<?php
require_once ("includes/clientfunctions.php");

if ((isset($_SESSION['uid'])) && ($_SESSION['uid'] > 0)) {
 $userdetails = getclientsdetails($_SESSION['uid']);
 $firstname= $userdetails['firstname'];
 echo "<strong>Hello $firstname! You are logged in.</strong>   <a href=\"/logout.php\">(Click for Logout)</a>";
} else {
 // not logged in
}  
var_dump($GLOBALS);
?>

 

This was without including dbconnect.php, as if i do, I get the Down for Maintenance message.

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