function check_for_registration(&$account, &$player, $fp, $nick, $channel, $callback, $validationMessages = true) { //Force $validationMessages to always be boolean. $validationMessages = $validationMessages === true; $db = new SmrMySqlDatabase(); // only registered users are allowed to use this command $db->query('SELECT * FROM irc_seen WHERE nick = ' . $db->escapeString($nick) . ' AND registered = 1 AND channel = ' . $db->escapeString($channel)); if (!$db->nextRecord()) { global $actions; // execute a whois and continue here on whois fputs($fp, 'WHOIS ' . $nick . EOL); array_push($actions, array('MSG_318', $channel, $nick, $callback, time(), $validationMessages)); return true; } $registeredNick = $db->getField('registered_nick'); // get alliance_id and game_id for this channel $alliance =& SmrAlliance::getAllianceByIrcChannel($channel, true); if ($alliance == null) { if ($validationMessages === true) { fputs($fp, 'PRIVMSG ' . $channel . ' :' . $nick . ', the channel ' . $channel . ' has not been registered with me.' . EOL); } return true; } // get smr account $account = SmrAccount::getAccountByIrcNick($nick, true); if ($account == null) { if ($registeredNick != '') { $account = SmrAccount::getAccountByIrcNick($registeredNick, true); } if ($account == null) { if ($validationMessages === true) { fputs($fp, 'PRIVMSG ' . $channel . ' :' . $nick . ', please set your \'irc nick\' in SMR preferences to your registered nick so i can recognize you.' . EOL); } return true; } } // get smr player $player = SmrPlayer::getPlayer($account->getAccountID(), $alliance->getGameId(), true); if ($player == null) { if ($validationMessages === true) { fputs($fp, 'PRIVMSG ' . $channel . ' :' . $nick . ', you have not joined the game that this channel belongs to.' . EOL); } return true; } // is the user part of this alliance? (no need to check for 0, cannot happen at this point in code) if ($player->getAllianceID() != $alliance->getAllianceID()) { if ($validationMessages === true) { fputs($fp, 'KICK ' . $channel . ' ' . $nick . ' :You are not a member of this alliance!' . EOL); } return true; } return false; }
function channel_msg_sms_send($fp, $rdata, $account, $player) { if (preg_match('/^:(.*)!(.*)@(.*)\\sPRIVMSG\\s(.*)\\s:!sms send ([^ ]+) (.*)\\s$/i', $rdata, $msg)) { $nick = $msg[1]; $user = $msg[2]; $host = $msg[3]; $channel = $msg[4]; $recv = $msg[5]; $msg = trim($msg[6]); echo_r('[SMS_SEND] by ' . $nick . ' in ' . $channel . ' for ' . $recv); if (($blacklist_reason = $account->isSmsBlacklisted()) !== false) { fputs($fp, 'PRIVMSG ' . $channel . ' :' . $nick . ', you are not allowed to send text messages via ' . IRC_BOT_NICK . '. Reason: ' . $blacklist_reason . EOL); return true; } // check if we know this user we try to send a text too $recv_account =& SmrAccount::getAccountByIrcNick($recv, true); if ($recv_account == null) { fputs($fp, 'PRIVMSG ' . $channel . ' :' . $nick . ', I don\'t know a player that goes by the nick \'' . $recv . '\'.' . EOL); return true; } // do we have a cellphone number? if (strlen($recv_account->getCellPhone()) == 0) { fputs($fp, 'PRIVMSG ' . $channel . ' :' . $nick . ', ' . $recv_account->getIrcNick() . ' has not provided a cell phone number.' . EOL); return true; } // do we have a msg if (empty($msg)) { fputs($fp, 'PRIVMSG ' . $channel . ' :' . $nick . ', you don\'t mind me asking what do you want to send to ' . $recv_account->getIrcNick() . '?' . EOL); return true; } // message too long? if (strlen($msg) > 160) { fputs($fp, 'PRIVMSG ' . $channel . ' :' . $nick . ', the message you want to send contains more than 160 characters.' . EOL); return true; } // +--------------------------------------------+ // | Copyright (c) 2007-2009 by MOBILANT.DE | // +--------------------------------------------+ $url = 'http://gw.mobilant.com'; $request = ''; $param = array(); $param['key'] = SMS_GATEWAY_KEY; $param['message'] = $msg; // numbers like +177 will be (for some reason) 'corrected' to a german number because it's a common area code here // therefor support asked me to use 00-1-77 instad of +1-77 $param['to'] = '00' . substr($recv_account->getCellPhone(), 1); // $param['from'] = 'SMR'; $param['route'] = 'direct'; $param['debug'] = SMS_DEBUG; $param['message_id'] = '1'; $param['dlr'] = '1'; $param['response'] = '1'; foreach ($param as $key => $val) { $request .= $key . '=' . urlencode($val); $request .= '&'; } echo_r('Calling url: ' . $url . '?' . $request); // request url = send text $response = @file($url . '?' . $request); $response_code = intval($response[0]); $message_id = intval($response[1]); // insert log $db = new SmrMySqlDatabase(); $db->query('INSERT INTO account_sms_log (account_id, time, receiver_id, receiver_cell, response_code, message_id) VALUES (' . $account->getAccountID() . ', ' . time() . ', ' . $recv_account->getAccountID() . ', ' . $db->escapeString($recv_account->getCellPhone()) . ', ' . $response_code . ', ' . $message_id . ')'); // confirm sending if (SMS_DEBUG) { fputs($fp, 'PRIVMSG ' . $channel . ' :' . $nick . ', sending SMS messages is currently disabled.' . EOL); } else { if ($response_code == 100) { fputs($fp, 'PRIVMSG ' . $channel . ' :' . $nick . ', your text message will be delivered to ' . $recv_account->getIrcNick() . ' immediately.' . EOL); } elseif ($response_code == 10) { fputs($fp, 'PRIVMSG ' . $channel . ' :' . $nick . ', there was an error while sending your text message: Unknown receiver number!' . EOL); } elseif ($response_code == 20) { fputs($fp, 'PRIVMSG ' . $channel . ' :' . $nick . ', there was an error while sending your text message: Unknown sender number!' . EOL); } elseif ($response_code == 30) { fputs($fp, 'PRIVMSG ' . $channel . ' :' . $nick . ', there was an error while sending your text message: Error in message!' . EOL); } elseif ($response_code == 40) { fputs($fp, 'PRIVMSG ' . $channel . ' :' . $nick . ', there was an error while sending your text message: Unknown route!' . EOL); } elseif ($response_code == 50) { fputs($fp, 'PRIVMSG ' . $channel . ' :' . $nick . ', there was an error while sending your text message: Identification failed!' . EOL); } elseif ($response_code == 60) { fputs($fp, 'PRIVMSG ' . $channel . ' :' . $nick . ', there was an error while sending your text message: Insufficient funds! Please donate!' . EOL); } elseif ($response_code == 70) { fputs($fp, 'PRIVMSG ' . $channel . ' :' . $nick . ', there was an error while sending your text message: Text message can\'t be delivered!' . EOL); } elseif ($response_code == 71) { fputs($fp, 'PRIVMSG ' . $channel . ' :' . $nick . ', there was an error while sending your text message: Feature not possible!' . EOL); } elseif ($response_code == 80) { fputs($fp, 'PRIVMSG ' . $channel . ' :' . $nick . ', there was an error while sending your text message: Error while delivering to SMS-C!' . EOL); } else { fputs($fp, 'PRIVMSG ' . $channel . ' :' . $nick . ', there was an error while sending your text message' . EOL); } } return true; } return false; }