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:

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

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:

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:

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:

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

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   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.



×
×
  • 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