本文整理汇总了PHP中SmrMySqlDatabase::escape_string方法的典型用法代码示例。如果您正苦于以下问题:PHP SmrMySqlDatabase::escape_string方法的具体用法?PHP SmrMySqlDatabase::escape_string怎么用?PHP SmrMySqlDatabase::escape_string使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SmrMySqlDatabase
的用法示例。
在下文中一共展示了SmrMySqlDatabase::escape_string方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: private_msg_weapon
function private_msg_weapon($fp, $rdata)
{
global $channel;
$type = 0;
if (preg_match('/^:(.*)!(.*)@(.*)\\sPRIVMSG\\s' . $channel . '\\s:!weapon\\sname\\s(.*)\\s$/i', $rdata, $msg_1)) {
$name = $msg_1[1];
sleep(2);
$type = 1;
} elseif (preg_match('/^:(.*)!(.*)@(.*)\\sPRIVMSG\\s' . $channel . '\\s:!weapon\\slevel\\s(.*)\\s(.*)\\s$/i', $rdata, $msg_2)) {
$name = $msg_2[1];
sleep(2);
$type = 2;
} elseif (preg_match('/^:(.*)!(.*)@(.*)\\sPRIVMSG\\s' . $channel . '\\s:!weapon\\srange\\s(.*)\\s(.*)\\s(.*)\\s(.*)\\s$/i', $rdata, $msg_3)) {
$name = $msg_3[1];
sleep(2);
$type = 3;
}
//first lets get our orders so we can make sure our query will work
$a = array();
$a[] = 'cost';
$a[] = 'weapon_name';
$a[] = 'shield_damage';
$a[] = 'armour_damage';
$a[] = 'accuracy';
$a[] = 'race_id';
$a[] = 'buyer_restriction';
$a[] = 'power_level';
$db = new SmrMySqlDatabase();
if ($type == 1) {
$db->query('SELECT * FROM weapon_type JOIN race USING(race_id) WHERE weapon_name LIKE ' . $db->escape_string('%' . $msg_1[4] . '%'));
} elseif ($type == 2) {
if (in_array($msg_2[5], $a)) {
$db->query('SELECT * FROM weapon_type JOIN race USING(race_id) WHERE power_level = ' . $msg_2[4] . ' ORDER BY ' . $msg_2[5] . ' DESC');
} else {
$db->query('SELECT * FROM weapon_type JOIN race USING(race_id) WHERE power_level = ' . $msg_2[4]);
}
} elseif ($type == 3) {
//[4] = object
//[5] = lower limit
//[6] = upper limit
//[7] = order
//first make sure we arent flooding
sleep(2);
if (in_array($msg_3[4], $a) && in_array($msg_3[7], $a)) {
$db->query('SELECT * FROM weapon_type JOIN race USING(race_id) WHERE ' . $msg_3[4] . ' > ' . $msg_3[5] . ' AND ' . $msg_3[4] . ' < ' . $msg_3[6] . ' ORDER BY ' . $msg_3[7] . ' DESC');
} elseif (in_array($msg_3[4], $a)) {
$db->query('SELECT * FROM weapon_type JOIN race USING(race_id) WHERE ' . $msg_3[4] . ' > ' . $msg_3[5] . ' AND ' . $msg_3[4] . ' < ' . $msg_3[6]);
} else {
$rand = mt_rand(0, 7);
$object = $a[$rand];
$db->query('SELECT * FROM weapon_type JOIN race USING(race_id) WHERE ' . $object . ' > ' . $msg_3[5] . ' AND ' . $object . ' < ' . $msg_3[6]);
}
}
if ($db->getNumRows()) {
fputs($fp, 'PRIVMSG ' . $name . ' :Name | Cost | Shield Damage | Armour Damage | Accuracy | Race | Restriction' . EOL);
sleep(2);
while ($db->nextRecord()) {
$weapon_name = $db->getField('weapon_name');
$hardpoint = $db->getField('power_level');
$shield = $db->getField('shield_damage');
$armour = $db->getField('armour_damage');
$acc = $db->getField('accuracy');
$race = $db->getField('race_name');
$restrict = $db->getField('buyer_restriction');
$cost = $db->getField('cost');
$private_message = 'PRIVMSG ' . $name . ' :' . $weapon_name . ' | ' . $cost . ' | ' . $shield . ' | ' . $armour . ' | ' . $acc . ' | ' . $race . ' | ';
if ($restrict == 1) {
$private_message .= 'Good';
} elseif ($restrict == 2) {
$private_message .= 'Evil';
} else {
$private_message .= 'None';
}
$private_message .= EOL;
fputs($fp, $private_message);
sleep(2);
}
} elseif ($type == 1) {
fputs($fp, 'PRIVMSG ' . $name . ' :There is no weapon called ' . $msg_1[5] . '!' . EOL);
} elseif ($type == 2) {
fputs($fp, 'PRIVMSG ' . $name . ' :There is no weapon with ' . $msg_2[4] . ' power level!' . EOL);
} elseif ($type == 3) {
fputs($fp, 'PRIVMSG ' . $name . ' :There is no weapon in the cost range of ' . $msg_3[4] . ' - ' . $msg_3[5] . '!' . EOL);
}
if (isset($type)) {
return true;
}
return false;
}
示例4: catch
try {
$account =& SmrAccount::createAccount($login, $password, $email, $first_name, $last_name, $address, $city, $postal_code, $country_code, $icq, $timez, $referral);
} catch (Exception $e) {
$msg = 'Invalid referral id!';
header('Location: ' . URL . '/error.php?msg=' . rawurlencode(htmlspecialchars($msg, ENT_QUOTES)));
exit;
}
$account->increaseSmrRewardCredits(2 * CREDITS_PER_DOLLAR);
// Give $2 worth of "reward" credits for joining.
if ($socialLogin) {
$account->addAuthMethod($_SESSION['socialLogin']->getLoginType(), $_SESSION['socialLogin']->getUserID());
$account->setValidated(true);
session_destroy();
}
// register session
SmrSession::$account_id = $account->getAccountID();
// save ip
$account->updateIP();
// send email with validation code to user
mail($email, 'New Space Merchant Realms User', 'Your validation code is: ' . $account->getValidationCode() . EOL . 'The Space Merchant Realms server is on the web at ' . URL . '/' . EOL . 'Please verify within the next 7 days or your account will be automatically deleted.', 'From: support@smrealms.de');
// remember when we sent validation code
$db->query('INSERT INTO notification (notification_type, account_id, time) ' . 'VALUES(\'validation_code\', ' . $db->escapeNumber(SmrSession::$account_id) . ', ' . $db->escapeNumber(TIME) . ')');
// insert into the account stats table
$db->query('INSERT INTO account_has_stats (account_id, HoF_name) VALUES(' . $db->escapeNumber(SmrSession::$account_id) . ', ' . $db->escape_string($account->getLogin()) . ')');
$container = create_container('login_processing2.php');
$container['login'] = $login;
$container['password'] = $password;
forwardURL($container);
} catch (Exception $e) {
handleException($e);
}
示例5: header
exit;
}
if ($_POST['email'] == $account->getEmail()) {
$msg = 'You have to use a different email than the registered one!';
header('Location: ' . URL . '/error.php?msg=' . rawurlencode(htmlspecialchars($msg, ENT_QUOTES)));
exit;
}
// get user and host for the provided address
list($user, $host) = explode('@', $_POST['email']);
// check if the host got a MX or at least an A entry
if (!checkdnsrr($host, 'MX') && !checkdnsrr($host, 'A')) {
$msg = 'This is not a valid email address!';
header('Location: ' . URL . '/error.php?msg=' . rawurlencode(htmlspecialchars($msg, ENT_QUOTES)));
exit;
}
$db->query('SELECT * FROM account WHERE email = ' . $db->escape_string($_POST['email']));
if ($db->getNumRows() > 0) {
$msg = 'This eMail address is already registered.';
header('Location: ' . URL . '/error.php?msg=' . rawurlencode(htmlspecialchars($msg, ENT_QUOTES)));
exit;
}
$account->setEmail($_POST['email']);
$account->setValidationCode(substr(SmrSession::$session_id, 0, 10));
$account->setValidated(false);
$account->update();
// remember when we sent validation code
$db->query('REPLACE INTO notification (notification_type, account_id, time)
VALUES(\'validation_code\', ' . $db->escapeNumber($account->getAccountID()) . ', ' . $db->escapeNumber(TIME) . ')');
mail($email, 'Your validation code!', 'You changed your email address registered within SMR and need to revalidate now!' . EOL . EOL . ' Your new validation code is: ' . $account->getValidationCode() . EOL . EOL . 'The Space Merchant Realms server is on the web at ' . URL . '/.' . EOL . 'You\'ll find a quick how-to-play here <a href="http://wiki.smrealms.de/index.php?title=Video_Tutorials#A_Look_At_The_Game">SMR Wiki: A look at the game</a>' . EOL . 'Please verify within the next 7 days or your account will be automatically deleted.', 'From: support@smrealms.de');
// get rid of that email permission
$db->query('DELETE FROM account_is_closed
示例6: process_messages
function process_messages(&$players, $killed_id)
{
global $session, $player;
$killer_id = $players[$killed_id][KILLER];
$db = new SmrMySqlDatabase();
$temp = 'You were <span class="red">DESTROYED</span> by ' . $players[$killer_id][PLAYER_NAME] . ' in sector <span class="blue">#' . $player->getSectorID() . '</span>';
$msg .= '(' . SmrSession::$game_id . ',' . $killed_id . ',2,' . $db->escape_string($temp) . ',' . $killer_id . ',' . TIME . ',\'FALSE\',' . MESSAGE_EXPIRES . ')';
$temp = 'You <span class="red">DESTROYED</span> ' . $players[$killed_id][PLAYER_NAME] . ' in sector <span class="blue">#' . $player->getSectorID() . '</span>';
$msg .= ',(' . SmrSession::$game_id . ',' . $killer_id . ',2,' . $db->escape_string($temp) . ',' . $killed_id . ',' . TIME . ',\'FALSE\',' . MESSAGE_EXPIRES . ')';
return $msg;
}