Results 1 to 6 of 6

Thread: Down for Maintenance when using integration code

  1. #1
    Join Date
    Jun 2010
    Posts
    33

    Default Down for Maintenance when using integration code

    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:
    PHP Code:
    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>&nbsp;&nbsp;&nbsp;<a href=\"/logout.php\">(Click for Logout)</a>";
    }
    else 

    echo 
    "Login form is put in here";



    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.

  2. #2
    Join Date
    Feb 2009
    Location
    Atlanta, GA
    Posts
    1,683

    Default

    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

    PHP Code:
    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>&nbsp;&nbsp;&nbsp;<a href=\"/logout.php\">(Click for Logout)</a>";
    } else {
      
    // not logged in


  3. #3
    Join Date
    Jun 2010
    Posts
    33

    Default

    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 Code:
    <?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

  4. #4
    Join Date
    Jun 2010
    Posts
    33

    Default

    Maybe this have something to do with my problem?
    http://forum.whmcs.com/showthread.php?t=40012

  5. #5
    Join Date
    Feb 2009
    Location
    Atlanta, GA
    Posts
    1,683

    Default

    You did not use var_dump properly..

    Code:
    var_dump($GLOBALS);
    With regards to that other post, its possible thats the problem you're having.

  6. #6
    Join Date
    Jun 2010
    Posts
    33

    Default

    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 Code:
    <?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>&nbsp;&nbsp;&nbsp;<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.