Announcement

Collapse
No announcement yet.

How to get data from one server and display it on another?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to get data from one server and display it on another?

    Earlier I used to display the active users on the forum in a table on my front page.

    Now I don't have the forum on the same server anymore... :|

    So someway I need to get the data I want to display from the forum server to show up on my other server.

    I used this code to display the users:
    Code:
    <?
    
    
    chdir($DOCUMENT_ROOT . "/forums");
    
    require($DOCUMENT_ROOT . "/forums/global.php");
    
    
    
      if ($displayloggedin==1) {
    
        $datecut=time()-$cookietimeout;
    
        $loggedins=$DB_site->query_first("SELECT COUNT(sessionid) AS sessions FROM session");
    
        $totalonline=$loggedins[sessions];
    
        $loggedins=$DB_site->query_first("SELECT COUNT(sessionid) AS sessions FROM session WHERE userid=0");
    
        $numberguest=$loggedins[sessions];
    
        $loggedins=$DB_site->query_first("SELECT COUNT(sessionid) AS sessions FROM session WHERE userid<>0");
    
        $numberregistered=$loggedins[sessions];
    
    
    
        $numbervisible=0;
    
        $loggedins=$DB_site->query("SELECT DISTINCT user.userid,username,location FROM user,session WHERE session.userid=user.userid AND session.userid<>0 AND invisible=0 AND usergroupid<>3 ORDER BY username");
    
        if ($loggedin=$DB_site->fetch_array($loggedins)) {
    
          $numbervisible++;
    
          $userid=$loggedin[userid];
    
          $username=$loggedin[username];
    
          $location=$loggedin[location];
    
    
    
          eval("\$activeusers .= \"".gettemplate("loggedinuser")."\";");
    
    
    
          while ($loggedin=$DB_site->fetch_array($loggedins)) {
    
            $numbervisible++;
    
            $userid=$loggedin[userid];
    
            $username=$loggedin[username];
    
            $location=$loggedin[location];
    
            eval("\$activeusers .= \", ".gettemplate("loggedinuser")."\";");
    
          }
    
        }
    
        $numberinvisible=$numberregistered-$numbervisible;
    
        eval("\$loggedinusers = \"".gettemplate("loggedinusers")."\";");
    
      }
    
    
    
    echo "$activeusers and $numberguest guests.";
    
    chdir($DOCUMENT_ROOT);
    
    ?>

    So the thing is :
    Code:
    chdir($DOCUMENT_ROOT . "/forums");
    
    require($DOCUMENT_ROOT . "/forums/global.php");
    should not be done on the "site server" but on the forum server.

    first I just added the IP address before the /forums to see if it would work, but it didn't.
    Then I checked out php.net and found some functions like connect() and socket() and other things like that.
    But I'm not sure how to do this... it must be able to be done somehow, right? :/

    Maybe someone here has done a thing like this before?

  • #2
    Nevermind.
    I didn't know I could use the include() from other servers, but apparently I could

    Comment


    • #3
      That&#039;s what&#039;s so nice about PHP

      When we first started with our current host, I wanted to do some global includes (one for the top and bottom of every page), and not knowing any better I was using SHTML to do it. Only problem was, we started with subdomains, and the subdomains are seen on the server as separate domains, not callable by ../../filename.shtml. So I started looking at PHP (which was a change when we switched hosts - we hadn't had it before). I found I could make one subdomain for the include - http://i.mydomain.com - and call it from all over - img.mydomain.com, board.mydomain.com. I was thrilled. Instead of 18 copies of the include folder (and having to remember to update those 18 folders every time I made a change to the files), I only needed one!

      Sorry for the off-topic rambling.

      Comment

      widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
      Working...
      X