Jump to content
  • 0

[php] You questions


Question

7 answers to this question

Recommended Posts

  • 0
Posted

[Geo]Sky, $this-catch();

 

1. you should create */engine/inc/server_status.php with this content:

  Quote
<?php

 

if(!defined('DATALIFEENGINE')) die ("Hacking attempt!");

 

# =====================================================

# lineage2 server_status v.0.1b

# author: atomos, special for maxcheters.com

# =====================================================

 

// connecting mysql class

$_db = new db;

 

// configs for gamea and login servers

$_config = array(

 

'login_ip' => 'localhost',

'login_port' => '80',

 

'game_ip' => 'localhost',

'game_port' => '80',

 

'game_dbhost' => 'localhost',

'game_dbname' => 'l2j',

'game_dbuser' => 'root',

'game_dbpass' => 'root',

 

);

 

// online players

if($_db->query_online("SELECT * FROM characters WHERE online = '1' AND accesslevel = '0'") != false)

{

$status_online = $_db->num_rows();

}

else

{

$status_online = 0;

}

 

// checking login/game servers for online/offline

if(fsockopen($_config['login_ip'], $_config['login_port'], $errno, $errstr, 1) >= 1)

{

$tpl->set('{status_login}', 'online');

}

else

{

$tpl->set('{status_login}', 'offline');

}

 

if(fsockopen($_config['game_ip'], $_config['game_port'], $errno, $errstr, 1) >= 1)

{

$tpl->set('{status_game}', 'online');

}

else

{

$tpl->set('{status_game}', 'offline');

}

 

$tpl->set('{status_online}', $status_online);

 

$_db->close();

 

?>

 

2. Make include in */engine/init.php, before ?> in the end of the page.. add

  Quote
require_once ROOT_DIR . '/engine/inc/server_status.php';

 

3. Modify you mysql class: open */engine/classes/mysql.class.php and add new one after function query:

  Quote
function query_online($query, $show_error = true)

{

global $_config;

 

if(!$this->db_id) $this->connect($_config['game_dbuser'], $_config['game_dbpass'], $_config['game_dbname'], $_config['game_host']);

 

if(!($this->query_id = mysql_query($this->db_id, $query) )) {

 

$this->mysql_error = mysql_error($this->db_id);

$this->mysql_error_num = mysql_errno($this->db_id);

}

 

$this->query_num ++;

 

return $this->query_id;

}

 

4. add some html in you current main.tpl:

  Quote
Login: <font class="server_{status_login}">{status_login}</font>

Game: <font class="server_{status_game}">{status_game}</font>

Online: <font class="server_{status_game}">{status_online}</font>

 

4. last one. css part:

  Quote
.server_online {text-transform: capitalize; color: green;}

.server_offline {text-transform: capitalize; color: red;}

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


×
×
  • Create New...

AdBlock Extension Detected!

Our website is made possible by displaying online advertisements to our members.

Please disable AdBlock browser extension first, to be able to use our community.

I've Disabled AdBlock