本文整理汇总了PHP中Neuron_Core_Tools::checkInput方法的典型用法代码示例。如果您正苦于以下问题:PHP Neuron_Core_Tools::checkInput方法的具体用法?PHP Neuron_Core_Tools::checkInput怎么用?PHP Neuron_Core_Tools::checkInput使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Neuron_Core_Tools
的用法示例。
在下文中一共展示了Neuron_Core_Tools::checkInput方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getInput
public static function getInput($dat, $key, $type, $default = false)
{
global ${$dat};
$dat = ${$dat};
if (!isset($dat[$key])) {
return $default;
} else {
// Check if the value has the right type
if (Neuron_Core_Tools::checkInput($dat[$key], $type)) {
return $dat[$key];
} else {
return $default;
}
}
}
示例2: processInput
public function processInput()
{
$_SESSION['clan_overview_lastrefresh'] = null;
$login = Neuron_Core_Login::__getInstance();
$data = $this->getRequestData();
$input = $this->getInputData();
if (isset($data['id']) && $data['id'] > 0) {
$clan = new Dolumar_Players_Clan($data['id']);
if ($clan) {
if (!isset($input['action'])) {
$input['action'] = 'overview';
}
switch ($input['action']) {
case 'join':
$this->updateContent($this->getJoinClan($clan));
break;
case 'government':
$this->updateContent($this->getGovernment($clan));
break;
case 'leave':
$this->updateContent($this->getLeaveClan($clan));
break;
case 'overview':
default:
$this->updateContent($this->getOverview($clan));
break;
}
}
} elseif ($login->isLogin()) {
$profile = Neuron_GameServer::getPlayer();
$clans = $profile->getClans();
if (count($clans) == 0 && isset($input['clanname'])) {
if (Neuron_Core_Tools::checkInput($input['clanname'], 'unitname')) {
if ($this->makeClan($input['clanname'])) {
$this->updateContent();
} else {
$this->updateContent($this->getNoClan($profile, $this->getError()));
}
} else {
$this->updateContent($this->getNoClan($profile, 'err_clanname'));
}
}
}
}
示例3: getAddSquad
private function getAddSquad()
{
$input = $this->getInputData();
if (isset($input['squadName']) && Neuron_Core_Tools::checkInput($input['squadName'], 'unitname') && isset($input['squadUnit'])) {
// Check if unit type exists
$unit = Dolumar_Units_Unit::getUnitFromId($input['squadUnit'], $this->village->getRace(), $this->village);
if ($unit) {
// Add the squad
$objSquad = $this->village->addSquad($input['squadName'], $input['squadUnit']);
if ($objSquad) {
return $this->getAddUnits($objSquad);
} else {
return $this->getOverview();
}
} else {
$this->alert('Invalid unit type: ' . $input['squadUnit']);
}
} else {
$text = Neuron_Core_Text::__getInstance();
$text->setFile('squads');
$text->setSection('addSquad');
$page = new Neuron_Core_Template();
if (isset($input['squadName'])) {
$page->set('warning', $text->get('squadNameSyntax'));
}
$page->set('title', $text->get('title'));
$page->set('name', $text->get('name'));
$page->set('submit', $text->get('submit'));
$page->set('toReturn', $text->getClickTo($text->get('toReturn')));
// Load all units
$units = $this->village->getMyUnits();
foreach ($units as $unit) {
if ($unit->getSquadlessAmount() > 0) {
$page->addListValue('units', array('name' => $unit->getName(), 'id' => $unit->getUnitId()));
}
}
return $page->parse('squads/add.tpl');
}
}
示例4: setName
public function setName($name)
{
$this->loadData();
if (Neuron_Core_Tools::checkInput($name, 'village')) {
if ($this->isFound()) {
// Check if this name exists
$db = Neuron_Core_Database::__getInstance();
$found = $db->select('villages', array('vid'), "vname = '{$db->escape($name)}' AND vid != {$this->getId()}");
if (count($found) == 0) {
$db->update('villages', array('vname' => $name), "vid = '" . $this->id . "'");
$this->data['vname'] = $name;
return true;
} else {
$this->error = 'village_name_duplicate';
return false;
}
} else {
$this->error = 'village_not_found';
return false;
}
} else {
$this->error = 'invalid_village_syntax';
return false;
}
}
示例5: changeNickname
public function changeNickname($nickname)
{
$db = Neuron_Core_Database::__getInstance();
$this->loadData();
if (!empty($this->data['nickname'])) {
if (Neuron_Core_Tools::checkInput($nickname, 'username')) {
$data = Neuron_GameServer_Mappers_PlayerMapper::getFromNickname($nickname);
if (!isset($data)) {
Neuron_GameServer_Mappers_PlayerMapper::setNickname($this, $nickname);
if ($chk == 1) {
$this->data['nickname'] = $nickname;
return true;
} else {
$this->error = 'update_failed';
return false;
}
} else {
$this->error = 'user_found';
return false;
}
} else {
$this->error = 'error_username';
return false;
}
} else {
$this->error = 'nickname_not_set';
}
}
示例6: processRegistration
private function processRegistration($username, $email, $password, $password2)
{
$db = Neuron_Core_Database::__getInstance();
$login = Neuron_Core_Login::__getInstance();
$text = Neuron_Core_Text::__getInstance();
$text->setFile('account');
$text->setSection('register');
// Check input
if (!Neuron_Core_Tools::checkInput($username, 'username')) {
$this->updateContent($this->showRegisterForm('usernameFormat'));
} elseif (!Neuron_Core_Tools::checkInput($password, 'password')) {
$this->updateContent($this->showRegisterForm('passwordFormat'));
} elseif (!Neuron_Core_Tools::checkInput($email, 'email')) {
$this->updateContent($this->showRegisterForm('emailFormat'));
} elseif ($password != $password2) {
$this->updateContent($this->showRegisterForm('passwordMismatch'));
} else {
// Next step: checking username and stuff
$userCheck = $db->select('n_players', array('plid'), "nickname = '{$username}' AND isRemoved = 0");
$mailCheck = $db->select('n_players', array('plid'), "email = '{$email}' AND isRemoved = 0");
if (count($userCheck) > 0) {
$this->updateContent($this->showRegisterForm('userFound'));
} elseif (count($mailCheck) > 0) {
$this->updateContent($this->showRegisterForm('emailFound'));
} else {
/*
Check for referrer.
*/
$referrer = intval(Neuron_Core_Tools::getInput('_COOKIE', 'preferrer', 'int'));
$user = Neuron_GameServer::getPlayer($referrer);
$ref_id = $user ? $user->getId() : null;
// Create the account
$id = $login->registerAccount($username, $email, $password, $ref_id);
$user = Neuron_GameServer::getPlayer($id);
/*
if (!$isInfinite)
{
// Withdraw 1 invitation
$db->update
(
'invitation_codes',
array
(
'invLeft' => '--'
),
"invCode = '$invitation'"
);
}
else
{
// Add 1 invitation
$db->update
(
'invitation_codes',
array
(
'invLeft' => '++'
),
"invCode = '$invitation'"
);
}
*/
// Show "finished" page
$page = new Neuron_Core_Template();
$page->set('done', $text->get('done'));
$page->set('login', $text->get('login'));
$page->set('tracker_url', htmlentities($user->getTrackerUrl('registration')));
$this->updateContent($page->parse('register/register_done.tpl'));
}
}
}