本文整理汇总了PHP中SmrMySqlDatabase::query方法的典型用法代码示例。如果您正苦于以下问题:PHP SmrMySqlDatabase::query方法的具体用法?PHP SmrMySqlDatabase::query怎么用?PHP SmrMySqlDatabase::query使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SmrMySqlDatabase
的用法示例。
在下文中一共展示了SmrMySqlDatabase::query方法的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: 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);
}
}
示例5: 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;
}
示例6: 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;
}
示例7: 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;
}
示例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: array
}
$PHP_OUTPUT .= '</select>';
$PHP_OUTPUT .= '</td>';
}
//$alliance_vs[] = $curr_alliance_id;
}
$PHP_OUTPUT .= '<td width=10% valign="top">None</td>';
$PHP_OUTPUT .= '</tr>';
//$db->query('SELECT * FROM alliance WHERE game_id = ' . $db->escapeNumber($player->getGameID()) . ' ORDER BY alliance_kills DESC, alliance_name LIMIT 5');
foreach ($alliance_vs as $key => $id) {
$PHP_OUTPUT .= '<tr>';
// get current alliance
$curr_id = $id;
if ($id > 0) {
$curr_alliance =& SmrAlliance::getAlliance($id, $player->getGameID());
$db2->query('SELECT 1 FROM player WHERE alliance_id = ' . $db2->escapeNumber($curr_id) . ' AND game_id = ' . $db2->escapeNumber($player->getGameID()) . ' LIMIT 1');
$out = $db2->nextRecord();
$PHP_OUTPUT .= '<td width=10% valign="top"';
if ($player->getAllianceID() == $curr_alliance->getAllianceID()) {
$PHP_OUTPUT .= ' class="bold"';
}
if ($out) {
$PHP_OUTPUT .= ' class="red"';
}
$PHP_OUTPUT .= '>';
$container1 = array();
$container1['url'] = 'skeleton.php';
$container1['body'] = 'rankings_alliance_vs_alliance.php';
$container1['alliance_id'] = $curr_alliance->getAllianceID();
$PHP_OUTPUT .= create_link($container1, $curr_alliance->getAllianceName());
//$PHP_OUTPUT.=('.$db->escapeString($curr_alliance->getAllianceName()');
示例10: addslashes
$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: array
}
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>";
print_table();
print "<tr><th align=center>Rank</th><th align=center>Player</th><th align=center>{$cat} {$action}</th></tr>";
if ($cat == "<b>Money Donated to SMR</b>") {
$db->query("SELECT account_id, sum(amount) as amount FROM account_donated " . "GROUP BY account_id ORDER BY amount DESC LIMIT 25");
} else {
$db->query("SELECT account_id, {$row} as amount FROM {$table} {$row} > 0 ORDER BY amount DESC LIMIT 25");
}
while ($db->next_record()) {
$this_acc = new SMR_ACCOUNT();
$this_acc->get_by_id($db->f("account_id"));
if ($db->f("account_id") == ".SmrSession::{$old_account_id}.") {
$bold = " style=\"font-weight:bold;\"";
} else {
$bold = "";
}
print "<tr>";
print "<td align=center{$bold}>" . $rank++ . "</td>";
//link to stat page
$container = array();
示例12: SmrMySqlDatabase
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>';
}
$PHP_OUTPUT .= '</table><br />';
示例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 "<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);*/
print "<tr>";
print "<td>{$construction_name}</td>";
print "<td>{$construction_description}</td>";
print "<td align=\"center\">";
print $planet->construction[$construction_id];
print "/";