DragonPrime - LoGD Resource Community
Welcome Guest
  • Good afternoon, Guest.
    Please log in, or register.
  • July 20, 2018, 01:18:58 PM
Home Forums News Downloads Login Register Advanced Search
* * *
DragonPrime Menu
Login
 
 
Resource Pages
Search

Pages: [1]   Go Down
  Print  
Author Topic: limiting concurrent connections  (Read 2569 times)
0 Members and 1 Guest are viewing this topic.
sixf00t4
Mod God
*****
Offline Offline

Posts: 1916



View Profile WWW
« on: June 29, 2004, 07:33:49 PM »

I think anpera had a mod to do this?  My server almost doubled in users, and i need something to slow people down befor my server goes down!  Smiley
Logged

anpera
Guest
« Reply #1 on: July 09, 2004, 05:46:23 AM »

Well, I posted this mod on sourceforge. But in the meantime there were a lot of changes and improvements on it. So I hope I got all the changes...

(There is a mod for this mod that makes superusers can login even if server is full, but that's not my work at all so I left it out.)

Limit can be set in superuser grotto. 0 is unlimited and default.

Code:
---- Open:
configuration.php

---- Find:
"gameadminemail"=>"Admin Email",

---- After, add:
"maxonline"=>"Restrict users online (0 for unlimited),int",



---- Open:
index.php

---- Find:
output("Enter your name and password to enter the realm.`n");

---- Before, add:
$result = db_fetch_assoc(db_query("SELECT COUNT(acctid) AS onlinecount FROM accounts WHERE locked=0 AND loggedin=1 AND laston>'".date("Y-m-d H:i:s",strtotime("-".getsetting("LOGINTIMEOUT",900)." seconds"))."'"));
$onlinecount = $result['onlinecount'];
if ($onlinecount<getsetting("maxonline",0) || getsetting("maxonline",0)==0){

---- Find:
addnav("","login.php");

---- After, add:
} else {
   output("`^`bServer is full.`b`nPlease wait until someone logs out.`n`n");
   if ($_GET['op']=="timeout"){
      $session['message'].=" Your session has timed out, you must log in again.`n";
      if (!isset($_COOKIE['PHPSESSID'])){
         $session['message'].=" Also, it appears that you may be blocking cookies from this site.  At least session cookies must be enabled in order to use this site.`n";
      }
   }
   if ($session[message]>"") output("`b`\$$session[message]`b`n");
   output(templatereplace("full")."`c",true);
}



---- Open:
login.php

---- Find:
$sql = "SELECT * FROM accounts WHERE login = '$HTTP_POST_VARS[name]' AND password=MD5('$HTTP_POST_VARS[password]') AND locked=0";

---- Before, add:
$result = db_fetch_assoc(db_query("SELECT COUNT(acctid) AS onlinecount FROM accounts WHERE locked=0 AND loggedin=1 AND laston>'".date("Y-m-d H:i:s",strtotime("-".getsetting("LOGINTIMEOUT",900)." seconds"))."'"));
$onlinecount = $result['onlinecount'];

---- Find:
//loaduser($session['user']);

---- Before, add:
if ($onlinecount<getsetting("maxonline",0) || getsetting("maxonline",0)==0){

---- Find:
header("Location: {$session['user']['restorepage']}");
exit();
}

---- After, add:
}else{
   $session['user'] = array();
   $session[message]="`4Error: Server full.`0";
   redirect("index.php");
}



---- Open:
templates/yarbrough.htm (or whatever your default template is)

---- Find:
end of file

---- Add:
<!--!full-->
<table width='212' height='234' border='0' cellpadding='0' cellspacing='0' background='images/logindragon.gif' class='noborder'>
   <tr>
      <td valign='bottom' align='center' class='noborder'>
         <br>`b`$Server<br><br>full!`b<br><br><br>
         <img src='images/trans.gif' width='1' height='37' align='absmiddle' alt=''>
      </td>
   </tr>
</table>

I hope it works Huh
Logged
Kendaer
Guest
« Reply #2 on: July 09, 2004, 07:53:31 AM »

This is part of 0.9.8 just so you know.. (I'd thought this was part of 0.9.7 too, but I guess not)
Logged
Arune
Member
Mod God
*****
Offline Offline

Posts: 718


Arune Vai - khatfield


View Profile WWW
« Reply #3 on: July 12, 2004, 05:20:51 PM »

http://dragonprime.net/index.php?board=3;action=display;threadid=58

Is where it is posted. It was the most updated working version at the time.

Looks like Anpera has done some updating since =p

Arune
« Last Edit: July 12, 2004, 05:22:02 PM by Arune » Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  


*
DragonPrime Notices
Please take the time to read the FAQ and browse the DragonPedia

Support Us
No funds raised yet this year
Your help is greatly appreciated!
Recent Topics
DragonPrime LoGD
Who's Online
46 Guests, 0 Users
Home Forums News Downloads Login Register Advanced Search