Код:
<?php
/**********************************************************
WoW PHP Website scripts
Made by Jesper96 of Ac-Web.org
---------------------------------------
Tested with WAMPSERVER 2.0i using:
PHP: v5.3
MySQL: v5.1.36
Apache: v2.2.11
Before you start complaining about errors, check if your webserver is outdated!
Function list:
$script->tickets("host", "username", "password", "database"); [Total active tickets]
$script->items("host", "username", "password", "database"); [Total items]
$script->npcs("host", "username", "password", "database"); [Total npcs]
$script->accounts("host", "username", "password", "database"); [total accounts]
$script->gm_accounts("host", "username", "password", "database"); [total GM/ADMIN accounts]
$script->char_all("host", "username", "password", "database"); [total characters]
$script->char_horde("host", "username", "password", "database"); [total horde characters]
$script->char_alliance("host", "username", "password", "database"); [total alliance characters]
$script->online_all("host", "username", "password", "database"); [online players]
$script->online_gms("host", "username", "password", "database"); [online GMs]
$script->online_horde("host", "username", "password", "database"); [online horde players]
$script->online_alliance("host", "username", "password", "database"); [online alliance players]
$script->realmstatus("ip", "port"); [Shows if the realm is online/offline]
---------------------------------------
:: How to use ::
Part 1; Intergration:
Just add this line somewhere on your site (Doesn't matter where);
<?php require('scripts.php'); ?>
Note that your document has to be .php!
Part 2; Adding the scripts where you want them:
The basic code for adding a script:
<?php $script->accounts("host", "username", "password", "database"); ?>
Don't forgot to change the config values.
You can find a full function list above.
Don't edit below this if you don't know what you're doing!
*********************************************************/
class script {
// total active tickets
function tickets($host, $user, $pass, $db) {
$connection = mysql_connect($host, $user, $pass);
if(!$connection) {
die(mysql_error());
}
mysql_select_db($db, $connection) or die(mysql_error());
$query = mysql_query("SELECT ticketid FROM gm_tickets WHERE deleted = '0'", $connection);
$total = mysql_num_rows($query);
echo $total;
}
// total npcs
function npcs($host, $user, $pass, $db) {
$connection = mysql_connect($host, $user, $pass);
if(!$connection) {
die(mysql_error());
}
mysql_select_db($db, $connection) or die(mysql_error());
$query = mysql_query("SELECT entry FROM creature_names", $connection);
$total = mysql_num_rows($query);
echo $total;
}
// total items
function items($host, $user, $pass, $db) {
$connection = mysql_connect($host, $user, $pass);
if(!$connection) {
die(mysql_error());
}
mysql_select_db($db, $connection) or die(mysql_error());
$query = mysql_query("SELECT entry FROM items", $connection);
$total = mysql_num_rows($query);
echo $total;
}
// total accounts
function accounts($host, $user, $pass, $db) {
$connection = mysql_connect($host, $user, $pass);
if(!$connection) {
die(mysql_error());
}
mysql_select_db($db, $connection) or die(mysql_error());
$query = mysql_query("SELECT acct FROM accounts", $connection);
$total = mysql_num_rows($query);
echo $total;
}
// total GM accounts
function gm_accounts($host, $user, $pass, $db) {
$connection = mysql_connect($host, $user, $pass);
if(!$connection) {
die(mysql_error());
}
mysql_select_db($db, $connection) or die(mysql_error());
$query = mysql_query("SELECT acct FROM accounts WHERE gm IN (az, a, 1, 2, 3)", $connection);
$total = mysql_num_rows($query);
echo $total;
}
// total characters [all]
function char_all($host, $user, $pass, $db) {
$connection = mysql_connect($host, $user, $pass);
if(!$connection) {
die(mysql_error());
}
mysql_select_db($db, $connection) or die(mysql_error());
$query = mysql_query("SELECT guid FROM characters", $connection);
$total = mysql_num_rows($query);
echo $total;
}
// total characters [alliance]
function char_alliance($host, $user, $pass, $db) {
$connection = mysql_connect($host, $user, $pass);
if(!$connection) {
die(mysql_error());
}
mysql_select_db($db, $connection) or die(mysql_error());
$query = mysql_query("SELECT guid FROM characters WHERE race IN (1, 3, 4, 7, 11)", $connection);
$total = mysql_num_rows($query);
echo $total;
}
// total characters [horde]
function char_horde($host, $user, $pass, $db) {
$connection = mysql_connect($host, $user, $pass);
if(!$connection) {
die(mysql_error());
}
mysql_select_db($db, $connection) or die(mysql_error());
$query = mysql_query("SELECT guid FROM characters WHERE race IN (2, 5, 6, 8, 10)", $connection);
$total = mysql_num_rows($query);
echo $total;
}
// characters online [all]
function online_all($host, $user, $pass, $db) {
$connection = mysql_connect($host, $user, $pass);
if(!$connection) {
die(mysql_error());
}
mysql_select_db($db, $connection) or die(mysql_error());
$query = mysql_query("SELECT guid FROM characters WHERE online = '1'", $connection);
$total = mysql_num_rows($query);
echo $total;
}
// characters online [GM's]
function online_gms($host, $user, $pass, $db) {
$connection = mysql_connect($host, $user, $pass);
if(!$connection) {
die(mysql_error());
}
mysql_select_db($db, $connection) or die(mysql_error());
$query = mysql_query("SELECT guid FROM characters WHERE online = '1' AND gm IN (1, 2, 3, a, az)", $connection);
$total = mysql_num_rows($query);
echo $total;
}
// characters online [horde]
function online_horde($host, $user, $pass, $db) {
$connection = mysql_connect($host, $user, $pass);
if(!$connection) {
die(mysql_error());
}
mysql_select_db($db, $connection) or die(mysql_error());
$query = mysql_query("SELECT guid FROM characters WHERE race IN (2, 5, 6, 8, 10) AND online='1'", $connection);
$total = mysql_num_rows($query);
echo $total;
}
// characters online [alliance]
function online_alliance($host, $user, $pass, $db) {
$connection = mysql_connect($host, $user, $pass);
if(!$connection) {
die(mysql_error());
}
mysql_select_db($db, $connection) or die(mysql_error());
$query = mysql_query("SELECT guid FROM characters WHERE race IN (1, 3, 4, 7, 11) AND online='1'", $connection);
$total = mysql_num_rows($query);
echo $total;
}
// online status
function realmstatus($ip, $port) {
error_reporting(0);
$test = fsockopen($host,$port,$errno,$errstr,3);
if(!$test)
{ echo "<font color=\"red\">Offline</font>"; }
else { echo "<font color=\"green\">Online</font>"; }
}
}
$script = new script();
?>
Това е един скрипт с които се извежда информация от датабаза, но ми дава следната грешка:
[phpBB Debug] PHP Notice: in file /var/www/cata/includes/status.php on line 115: mysql_num_rows() expects parameter 1 to be resource, boolean given - забележете старт тага на грешката phpBB Debug, сайта е интегриран с форума и явно заради това, как да го оправя?