本文整理汇总了PHP中SmrMySqlDatabase类的典型用法代码示例。如果您正苦于以下问题:PHP SmrMySqlDatabase类的具体用法?PHP SmrMySqlDatabase怎么用?PHP SmrMySqlDatabase使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SmrMySqlDatabase类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: notice_nickserv_registered_user
function notice_nickserv_registered_user($fp, $rdata)
{
// :NickServ!services@coldfront.net NOTICE Caretaker
if (preg_match('/^:NickServ!services@coldfront.net NOTICE ' . IRC_BOT_NICK . ' :([^ ]+) is ([^.]+)\\s$/i', $rdata, $msg)) {
$nick = $msg[1];
$registeredNick = $msg[2];
echo_r('[NOTICE_NICKSERV_REGISTERED_NICK] ' . $nick . ' is ' . $registeredNick);
$db = new SmrMySqlDatabase();
$db2 = new SmrMySqlDatabase();
$db->query('SELECT * FROM irc_seen WHERE nick = ' . $db->escapeString($nick));
while ($db->nextRecord()) {
$seen_id = $db->getField('seen_id');
$db2->query('UPDATE irc_seen SET
registered_nick = ' . $db->escapeString($registeredNick) . '
WHERE seen_id = ' . $seen_id);
}
global $actions;
foreach ($actions as $key => $action) {
// is that a callback for our nick?
if ($action[0] == 'NICKSERV_INFO' && $nick == $action[2]) {
echo_r('Callback found: ' . $action[3]);
unset($actions[$key]);
eval($action[3]);
}
}
return true;
}
return false;
}
示例2: channel_msg_ship
function channel_msg_ship($fp, $rdata)
{
global $channel;
if (preg_match('/^:(.*)!(.*)@(.*)\\sPRIVMSG\\s' . $channel . '\\s:!ship\\s(.*)\\s$/i', $rdata, $msg)) {
echo_r($msg);
$db = new SmrMySqlDatabase();
$db->query('SELECT * FROM ship_type WHERE ship_name LIKE ' . $db->escape_string('%' . $msg[4] . '%'));
if ($db->nextRecord()) {
$ship_name = $db->getField('ship_name');
$hardpoint = $db->getField('hardpoint');
$speed = $db->getField('speed');
$cost = $db->getField('cost');
$name_length = strlen($ship_name);
$hp_length = strlen('Hardpoints');
$speed_length = strlen('Speed');
$cost_length = max(strlen('Costs'), strlen($cost));
fputs($fp, 'NOTICE ' . $msg[1] . ' :' . str_pad('Name', $name_length) . ' | ' . str_pad('Hardpoints', $hp_length) . ' | ' . str_pad('Speed', $speed_length) . ' | ' . str_pad('Costs', $cost_length) . EOL);
fputs($fp, 'NOTICE ' . $msg[1] . ' :' . str_pad($ship_name, $name_length) . ' | ' . str_pad($hardpoint, $hp_length) . ' | ' . str_pad($speed, $speed_length) . ' | ' . str_pad($cost, $cost_length) . EOL);
} else {
fputs($fp, 'NOTICE ' . $msg[1] . ' :There is no ship called ' . $msg[4] . '!' . EOL);
}
return true;
}
return false;
}
示例3: channel_msg_rank
function channel_msg_rank($fp, $rdata)
{
global $channel, $nick;
// did he gave us no parameter?
if (preg_match('/^:(.*)!(.*)@(.*)\\sPRIVMSG\\s' . $channel . '\\s:!rank\\s$/i', $rdata, $msg) || preg_match('/^:(.*)!(.*)@(.*)\\sPRIVMSG\\s' . $nick . '\\s:rank\\s$/i', $rdata, $msg)) {
echo_r($msg);
fputs($fp, 'NOTICE ' . $msg[1] . ' :SYNTAX !rank <nick>' . EOL);
return true;
}
// in channel we only accept !rank
// in private msg we accept both
if (preg_match('/^:(.*)!(.*)@(.*)\\sPRIVMSG\\s' . $channel . '\\s:!rank\\s(.*)\\s$/i', $rdata, $msg) || preg_match('/^:(.*)!(.*)@(.*)\\sPRIVMSG\\s' . $nick . '\\s:?rank\\s(.*)\\s$/i', $rdata, $msg)) {
echo_r($msg);
$db = new SmrMySqlDatabase();
$db2 = new SmrMySqlDatabase();
$db->query('SELECT * FROM player WHERE player_name = ' . $db->escape_string($msg[4], true));
if ($db->getNumRows()) {
while ($db->nextRecord()) {
$player_name = stripslashes($db->getField('player_name'));
$experience = $db->getField('experience');
$game_id = $db->getField('game_id');
$db2->query('SELECT COUNT(*) as our_rank FROM player ' . 'WHERE game_id = ' . $game_id . ' AND ' . '(experience > ' . $experience . ' OR ' . '(experience = ' . $experience . ' AND ' . 'player_name <= ' . $db->escape_string($player_name, true) . ' ))');
if ($db2->nextRecord()) {
$our_rank = $db2->getField('our_rank');
}
// how many players are there?
$db2->query('SELECT COUNT(*) as total_player FROM player WHERE game_id = ' . $game_id);
if ($db2->nextRecord()) {
$total_player = $db2->getField('total_player');
}
$db2->query('SELECT game_name FROM game WHERE game_id = ' . $game_id);
if ($db2->nextRecord()) {
$game_name = $db2->getField('game_name');
}
fputs($fp, 'NOTICE ' . $msg[1] . ' :' . $msg[1] . ' you are ranked ' . $our_rank . ' out of ' . $total_player . ' in ' . $game_name . '!' . EOL);
}
} else {
fputs($fp, 'NOTICE ' . $msg[1] . ' :No Trader found that matches your query!' . EOL);
}
return true;
}
return false;
}
示例4: channel_msg_level
function channel_msg_level($fp, $rdata)
{
global $channel, $nick;
// in channel we only accept !rank
// in private msg we accept both
if (preg_match('/^:(.*)!(.*)@(.*)\\sPRIVMSG\\s' . $channel . '\\s:!level\\s(.*)\\s$/i', $rdata, $msg) || preg_match('/^:(.*)!(.*)@(.*)\\sPRIVMSG\\s' . $nick . '\\s:?level\\s(.*)\\s$/i', $rdata, $msg)) {
echo_r($msg);
$db = new SmrMySqlDatabase();
$db->query('SELECT * FROM level WHERE level_id = ' . $msg[4]);
if ($db->nextRecord()) {
$level_name = $db->getField('level_name');
$experience = $db->getField('requirement');
fputs($fp, 'NOTICE ' . $msg[1] . ' :For a ' . $level_name . ' you need to have ' . $experience . ' experience points!' . EOL);
} else {
fputs($fp, 'NOTICE ' . $msg[1] . ' :This Level doesn\'t exist!!' . EOL);
}
return true;
}
return false;
}
示例5: user_nick
/**
* Someone changed his nick
*/
function user_nick($fp, $rdata)
{
if (preg_match('/^:(.*)!(.*)@(.*)\\sNICK\\s:(.*)\\s$/i', $rdata, $msg)) {
$nick = $msg[1];
$user = $msg[2];
$host = $msg[3];
$new_nick = $msg[4];
echo_r('[NICK] ' . $nick . ' -> ' . $new_nick);
// database object
$db = new SmrMySqlDatabase();
$db2 = new SmrMySqlDatabase();
$channel_list = array();
// 'sign off' all active old_nicks (multiple channels)
$db->query('SELECT * FROM irc_seen WHERE nick = ' . $db->escapeString($nick) . ' AND signed_off = 0');
while ($db->nextRecord()) {
$seen_id = $db->getInt('seen_id');
// remember channels where this nick was active
array_push($channel_list, $db->getField('channel'));
$db2->query('UPDATE irc_seen SET signed_off = ' . time() . ' WHERE seen_id = ' . $seen_id);
}
// now sign in the new_nick in every channel
foreach ($channel_list as $channel) {
// 'sign in' the new nick
$db->query('SELECT * FROM irc_seen WHERE nick = ' . $db->escapeString($new_nick) . ' AND channel = ' . $db->escapeString($channel));
if ($db->nextRecord()) {
// exiting nick?
$seen_id = $db->getField('seen_id');
$db->query('UPDATE irc_seen SET ' . 'signed_on = ' . time() . ', ' . 'signed_off = 0, ' . 'user = ' . $db->escapeString($user) . ', ' . 'host = ' . $db->escapeString($host) . ', ' . 'registered = NULL ' . 'WHERE seen_id = ' . $seen_id);
} else {
// new nick?
$db->query('INSERT INTO irc_seen (nick, user, host, channel, signed_on) VALUES(' . $db->escapeString($new_nick) . ', ' . $db->escapeString($user) . ', ' . $db->escapeString($host) . ', ' . $db->escapeString($channel) . ', ' . time() . ')');
}
}
unset($channel_list);
return true;
}
return false;
}
示例6: check_sms_response
function check_sms_response($fp)
{
// get one dlr per time so we do not spam anyone
$db = new SmrMySqlDatabase();
$db->query('SELECT *
FROM account_sms_response
LEFT JOIN account_sms_log USING (message_id)
WHERE announce = 0');
if ($db->nextRecord()) {
$response_id = $db->getField('response_id');
$message_id = $db->getField('message_id');
$message = $db->getField('message');
$orig_sender_id = $db->getField('account_id');
echo_r('Found new SMS response... ' . $message_id);
$orig_sender =& SmrAccount::getAccount($orig_sender_id, true);
fputs($fp, 'NOTICE ' . $orig_sender->getIrcNick() . ' :You have received a response to your text: ' . EOL);
fputs($fp, 'NOTICE ' . $orig_sender->getIrcNick() . ' :' . $message . EOL);
// update announce status
$db->query('UPDATE account_sms_response
SET announce = 1
WHERE response_id = ' . $response_id);
}
}
示例7: channel_part
function channel_part($fp, $rdata)
{
// :Azool!Azool@coldfront-F706F7E1.co.hfc.comcastbusiness.net PART #smr-irc :
// :SomeGuy!mrspock@coldfront-DD847655.dip.t-dialin.net PART #smr-irc
if (preg_match('/^:(.*)!(.*)@(.*)\\sPART\\s(.*?)\\s/i', $rdata, $msg)) {
$nick = $msg[1];
$user = $msg[2];
$host = $msg[3];
$channel = $msg[4];
echo_r('[PART] ' . $nick . '!' . $user . '@' . $host . ' ' . $channel);
// database object
$db = new SmrMySqlDatabase();
$db->query('SELECT * FROM irc_seen WHERE nick = ' . $db->escapeString($nick) . ' AND channel = ' . $db->escapeString($channel));
// exiting nick?
if ($db->nextRecord()) {
$seen_id = $db->getField('seen_id');
$db->query('UPDATE irc_seen SET signed_off = ' . time() . ' WHERE seen_id = ' . $seen_id);
} else {
// we don't know this one, but who cares? he just left anyway...
}
return true;
}
return false;
}
示例8: channel_msg_seedlist_del
function channel_msg_seedlist_del($fp, $rdata, $account, $player)
{
if (preg_match('/^:(.*)!(.*)@(.*)\\sPRIVMSG\\s(.*)\\s:!seedlist del (.*)\\s$/i', $rdata, $msg)) {
$nick = $msg[1];
$user = $msg[2];
$host = $msg[3];
$channel = $msg[4];
$sectors = explode(' ', $msg[5]);
echo_r('[SEEDLIST_DEL] by ' . $nick . ' in ' . $channel);
// check if $nick is leader
if (!$player->isAllianceLeader(true)) {
fputs($fp, 'PRIVMSG ' . $channel . ' :' . $nick . ', only the leader of the alliance manages the seedlist.' . EOL);
return true;
}
foreach ($sectors as $sector) {
// see if the sector is numeric
if (!is_numeric($sector)) {
fputs($fp, 'PRIVMSG ' . $channel . ' :The sectors all need to be numeric. Example: !seedlist del 1537' . EOL);
return true;
}
}
// add sectors to db
$db = new SmrMySqlDatabase();
$db->query('DELETE FROM alliance_has_seedlist
WHERE alliance_id = ' . $player->getAllianceID() . '
AND game_id = ' . $player->getGameID() . '
AND sector_id IN (' . $db->escapeArray($sectors) . ')');
fputs($fp, 'PRIVMSG ' . $channel . ' :The sectors have been deleted.' . EOL);
return true;
}
return false;
}
示例9: get_file_loc
<?php
require_once get_file_loc('SmrAlliance.class.inc');
$template->assign('PageTopic', 'Alliance VS Alliance Rankings');
require_once get_file_loc('menu.inc');
create_ranking_menu(1, 3);
$db2 = new SmrMySqlDatabase();
$container = array();
$container['url'] = 'skeleton.php';
$container['body'] = 'rankings_alliance_vs_alliance.php';
$PHP_OUTPUT .= create_echo_form($container);
if (isset($_REQUEST['alliancer'])) {
SmrSession::updateVar('alliancer', $_REQUEST['alliancer']);
}
$alliancer = $var['alliancer'];
$PHP_OUTPUT .= '<div align="center">';
$PHP_OUTPUT .= '<p>Here are the rankings of alliances vs other alliances<br />';
$PHP_OUTPUT .= 'Click on an alliances name for more detailed death stats.</p>';
$PHP_OUTPUT .= '<table class="standard" width="95%">';
$PHP_OUTPUT .= '<tr>';
$PHP_OUTPUT .= '<th rowspan="9">Killed</th><th colspan="8">Killers</th></tr><tr><td></td>';
if (empty($alliancer)) {
$alliance_vs = array();
$db->query('SELECT * FROM alliance WHERE game_id = ' . $db->escapeNumber($player->getGameID()) . ' ORDER BY alliance_kills DESC, alliance_name LIMIT 5');
while ($db->nextRecord()) {
$alliance_vs[] = $db->getField('alliance_id');
}
//$PHP_OUTPUT.=('empty '.$alliancer);
} else {
$alliance_vs = $alliancer;
}
示例10: player_visited_port
$port_info[$good_id] = $transaction;
}
//insert the last port
$db2->query("REPLACE INTO player_visited_port (account_id, game_id, sector_id, visited, port_info) " . "VALUES({$account_id}, {$game_id}, {$current_sector_id}, {$current_time}, '" . addslashes(serialize($port_info)) . "')");
//offer another drink and such
print "<div align=center>Galaxy Info has been added. Enjoy!</div><br>";
include get_file_loc("bar_opening.php");
} else {
//find what gal they want
$container = array();
$container["url"] = "skeleton.php";
$container["body"] = "bar_main.php";
$container["script"] = "bar_galmap_buy.php";
$container["process"] = "yes";
print "<div align=center>What galaxy do you want info on?<br>";
print_form($container);
print "<select type=select name=gal_id>";
print "<option value=0>[Select a galaxy]</option>";
$db->query("SELECT galaxy_id FROM sector WHERE game_id = {$player->game_id} GROUP BY galaxy_id ORDER BY galaxy_id ASC");
$db2 = new SmrMySqlDatabase();
while ($db->next_record()) {
$gal_id = $db->f("galaxy_id");
$db2->query("SELECT * FROM galaxy WHERE galaxy_id = {$gal_id}");
if ($db2->next_record()) {
print "<option value={$gal_id}>" . $db2->f("galaxy_name") . "</option>";
}
}
print "</select><br>";
print_submit("Buy the map");
print "</form></div>";
}
示例11: SMR_HISTORY_DB
$row .= $two;
break;
}
}
//for future when we have curr game stats
if (isset($game_id)) {
$table = "player_has_stats_cache WHERE game_id = {$game_id} AND";
$db2 = new SMR_HISTORY_DB();
$db2->query("SELECT * FROM game WHERE game_id = {$game_id}");
//if next record we have an old game so we query the hist db
if ($db2->next_record()) {
$db = new SMR_HISTORY_DB();
$past = "Yes";
$table = "player_has_stats WHERE game_id = {$game_id} AND";
} else {
$db = new SmrMySqlDatabase();
}
} else {
$table = "account_has_stats_cache WHERE";
}
print "<div align=center>";
print_topic("Hall of Fame - {$cat} {$action}");
$container = array();
$container["url"] = "skeleton.php";
$container["body"] = "hall_of_fame_new.php";
if (isset($game_id)) {
$container["game_id"] = $game_id;
}
print_link($container, "<b><<Back</b>");
print "<br>";
print "Here are the ranks of players by {$cat} {$action}<br><br>";
示例12: SmrMySqlDatabase
$PHP_OUTPUT .= '<span class="red bold">ERROR: </span>Player is already blacklisted.';
break;
case 3:
$PHP_OUTPUT .= '<span class="yellow">' . $_REQUEST['PlayerName'] . '</span> has been added to your blacklist.';
break;
case 4:
$PHP_OUTPUT .= '<span class="red bold">ERROR: </span>No entries selected for deletion.';
break;
default:
$PHP_OUTPUT .= '<span class="red bold">ERROR: </span>Unknown error event.';
break;
}
$PHP_OUTPUT .= '<br /><br />';
}
$PHP_OUTPUT .= '<h2>Blacklisted Players</h2><br />';
$db = new SmrMySqlDatabase();
$db->query('SELECT p.player_name, p.game_id, b.entry_id FROM player p JOIN message_blacklist b ON p.account_id = b.blacklisted_id AND b.game_id = p.game_id WHERE b.account_id=' . $db->escapeNumber($player->getAccountID()) . ' ORDER BY p.game_id, p.player_name');
if ($db->getNumRows()) {
$container = array();
$container['url'] = 'message_blacklist_del.php';
$form = create_form($container, 'Remove Selected');
$PHP_OUTPUT .= $form['form'];
$PHP_OUTPUT .= '<table class="standard"><tr><th>Option</th><th>Name</th><th>Game ID</th>';
while ($db->nextRecord()) {
$row = $db->getRow();
$PHP_OUTPUT .= '<tr>';
$PHP_OUTPUT .= '<td class="center shrink"><input type="checkbox" name="entry_ids[]" value="' . $row['entry_id'] . '"></td>';
$PHP_OUTPUT .= '<td>' . $row['player_name'] . '</td>';
$PHP_OUTPUT .= '<td>' . $row['game_id'] . '</td>';
$PHP_OUTPUT .= '</tr>';
}
示例13: SmrMySqlDatabase
<?php
$template->assign('PageTopic', 'Word Filter');
$db = new SmrMySqlDatabase();
$db->query('SELECT * FROM word_filter');
if (isset($var['error'])) {
switch ($var['error']) {
case 1:
$PHP_OUTPUT .= '<span class="red bold">ERROR: </span>Invalid input.';
break;
case 2:
$PHP_OUTPUT .= '<span class="yellow">' . strtoupper(trim($_REQUEST['Word'])) . '</span> will now be replaced with <span class="yellow">' . strtoupper(trim($_REQUEST['WordReplacement'])) . '</span>.';
break;
case 3:
$PHP_OUTPUT .= '<span class="red bold">ERROR: </span>No entries selected for deletion.';
break;
default:
$PHP_OUTPUT .= '<span class="red bold">ERROR: </span>Unknown error event.';
break;
}
$PHP_OUTPUT .= '<br /><br />';
}
$PHP_OUTPUT .= '<h2>Filtered Words</h2><br />';
if (!$db->getNumRows()) {
$PHP_OUTPUT .= 'No words are currently being filtered.<br /><br />';
} else {
$container = array();
$container['url'] = 'word_filter_del.php';
$form = create_form($container, 'Remove Selected');
$PHP_OUTPUT .= $form['form'];
$PHP_OUTPUT .= '<table class="standard"><tr><th>Option</th><th>Word</th><th>Replacement</th></tr>';
示例14: realpath
<?php
try {
echo '<pre>';
// global config
require_once realpath(dirname(__FILE__)) . '/../../htdocs/config.inc';
// bot config
require_once TOOLS . 'npc/config.specific.php';
// needed libs
require_once LIB . 'Default/SmrMySqlDatabase.class.inc';
require_once LIB . 'Default/Globals.class.inc';
$db = new SmrMySqlDatabase();
debug('Script started');
define('SCRIPT_ID', $db->getInsertID());
$db->query('UPDATE npc_logs SET script_id=' . SCRIPT_ID . ' WHERE log_id=' . SCRIPT_ID);
define('NPCScript', true);
$descriptorSpec = array(0 => array("pipe", "r"), 1 => array("pipe", "w"));
$engine = proc_open(UCI_CHESS_ENGINE, $descriptorSpec, $pipes);
$toEngine =& $pipes[0];
$fromEngine =& $pipes[1];
function readFromEngine($block = true)
{
global $fromEngine;
stream_set_blocking($fromEngine, $block == true ? 1 : 0);
while (($s = fgets($fromEngine)) !== false) {
debug('<-- ' . trim($s));
stream_set_blocking($fromEngine, 0);
}
}
function writeToEngine($s, $block = true, $read = true)
{
示例15: SmrMySqlDatabase
print "<p>";
print "<div align=\"center\">";
print "<table cellspacing=\"0\" cellpadding=\"3\" border=\"0\" class=\"standard\">";
print "<tr>";
print "<th>Type</th>";
print "<th>Description</th>";
print "<th>Current</th>";
print "<th>Cost</th>";
print "<th>Build</th>";
print "</tr>";
// get game speed
$db->query("SELECT * FROM game WHERE game_id = {$player->game_id}");
if ($db->next_record()) {
$game_speed = $db->f("game_speed");
}
$db2 = new SmrMySqlDatabase();
$db->query("SELECT * FROM planet_construction ORDER BY construction_id");
while ($db->next_record()) {
$construction_id = $db->f("construction_id");
$construction_name = $db->f("construction_name");
$construction_description = $db->f("construction_description");
$db2->query("SELECT * FROM planet_cost_credits WHERE construction_id = {$construction_id}");
if ($db2->next_record()) {
$cost = $db2->f("amount");
}
/*$container = array();
$container["url"] = "planet_construction_processing.php";
$container["construction_id"] = $construction_id;
$container["cost"] = $cost;
print_form($container);*/