本文整理汇总了PHP中CheckName函数的典型用法代码示例。如果您正苦于以下问题:PHP CheckName函数的具体用法?PHP CheckName怎么用?PHP CheckName使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CheckName函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: psuedoSend
public function psuedoSend()
{
global $USER, $LNG, $CONF, $UNI, $SESSION;
$newUsername = HTTP::_GP('pseudo', $USER['username'], UTF8_SUPPORT);
$SQL = "";
$redirectTo = 'game.php?page=settings';
if (!empty($newUsername) && $USER['username'] != $newUsername) {
if (!CheckName($newUsername)) {
$this->printMessage($LNG['op_user_name_no_alphanumeric']);
} elseif ($USER['uctime'] >= TIMESTAMP - USERNAME_CHANGETIME) {
$this->printMessage($LNG['op_change_name_pro_week']);
} else {
$Count = $GLOBALS['DATABASE']->getFirstCell("SELECT (SELECT COUNT(*) FROM " . USERS . " WHERE `universe` = " . $UNI . " AND `username` = '" . $GLOBALS['DATABASE']->sql_escape($newUsername) . "') + (SELECT COUNT(*) FROM " . USERS_VALID . " WHERE `universe` = " . $UNI . " AND `username` = '" . $GLOBALS['DATABASE']->sql_escape($newUsername) . "')");
if (!empty($Count)) {
$this->printMessage(sprintf($LNG['op_change_name_exist'], $newUsername));
} else {
$SQL = "UPDATE " . USERS . " SET username = '" . $GLOBALS['DATABASE']->sql_escape($newUsername) . "', uctime = " . TIMESTAMP . " WHERE id = " . $USER['id'] . ";";
$GLOBALS['DATABASE']->multi_query($SQL);
$redirectTo = 'index.php';
$SESSION->DestroySession();
}
}
}
$this->printMessage('<span class="vert">' . $LNG['op_options_changed'] . '</span>');
}
示例2: getACSPageData
public function getACSPageData($fleetID)
{
global $USER, $PLANET, $LNG, $UNI;
$fleetResult = $GLOBALS['DATABASE']->query("SELECT fleet_start_time, fleet_end_id, fleet_group, fleet_mess \n\t\t\t\t\t\t\t\t\t FROM " . FLEETS . "\n\t\t\t\t\t\t\t\t\t WHERE fleet_id = " . $fleetID . ";");
if ($GLOBALS['DATABASE']->numRows($fleetResult) != 1) {
return array();
}
$fleetData = $GLOBALS['DATABASE']->fetch_array($fleetResult);
$GLOBALS['DATABASE']->free_result($fleetResult);
if ($fleetData['fleet_mess'] == 1 || $fleetData['fleet_start_time'] <= TIMESTAMP) {
return array();
}
if ($fleetData['fleet_group'] == 0) {
$acsData = $this->createACS($fleetID, $fleetData);
} else {
$acsData = $this->loadACS($fleetID, $fleetData);
}
if (empty($acsData)) {
return array();
}
$acsName = HTTP::_GP('acsName', '', UTF8_SUPPORT);
if (!empty($acsName)) {
if (!CheckName($acsName)) {
$this->sendJSON($LNG['fl_acs_newname_alphanum']);
}
$GLOBALS['DATABASE']->query("UPDATE " . AKS . " SET name = '" . $GLOBALS['DATABASE']->sql_escape($acsName) . "' WHERE id = " . $acsData['id'] . ";");
$this->sendJSON(false);
}
$invitedUsers = array();
$userResult = $GLOBALS['DATABASE']->query("SELECT id, username\n\t\t\t\t\t\t\t\t\t FROM " . USERS_ACS . "\n\t\t\t\t\t\t\t\t\t INNER JOIN " . USERS . " ON userID = id \n\t\t\t\t\t\t\t\t\t WHERE acsID = " . $acsData['id'] . ";");
while ($userRow = $GLOBALS['DATABASE']->fetch_array($userResult)) {
$invitedUsers[$userRow['id']] = $userRow['username'];
}
$GLOBALS['DATABASE']->free_result($userResult);
$newUser = HTTP::_GP('username', '', UTF8_SUPPORT);
$statusMessage = "";
if (!empty($newUser)) {
$newUserID = $GLOBALS['DATABASE']->getFirstCell("SELECT id FROM " . USERS . " WHERE universe = " . $UNI . " AND username = '" . $GLOBALS['DATABASE']->sql_escape($newUser) . "';");
if (empty($newUserID)) {
$statusMessage = $LNG['fl_player'] . " " . $newUser . " " . $LNG['fl_dont_exist'];
} elseif (isset($invitedUsers[$newUserID])) {
$statusMessage = $LNG['fl_player'] . " " . $newUser . " " . $LNG['fl_already_invited'];
} else {
$statusMessage = $LNG['fl_player'] . " " . $newUser . " " . $LNG['fl_add_to_attack'];
$GLOBALS['DATABASE']->query("INSERT INTO " . USERS_ACS . " SET acsID = " . $acsData['id'] . ", userID = " . $newUserID . ";");
$invitedUsers[$newUserID] = $newUser;
$inviteTitle = $LNG['fl_acs_invitation_title'];
$inviteMessage = $LNG['fl_player'] . $USER['username'] . $LNG['fl_acs_invitation_message'];
SendSimpleMessage($newUserID, $USER['id'], TIMESTAMP, 1, $USER['username'], $inviteTitle, $inviteMessage);
}
}
return array('invitedUsers' => $invitedUsers, 'acsName' => $acsData['name'], 'mainFleetID' => $fleetID, 'statusMessage' => $statusMessage);
}
示例3: mysql_query
}
if (isset($_POST['insert'])) {
$name = $_POST['name'];
$boat_id = $_POST['boat_id'];
// bootnaam
if ($boat_id == 0) {
$boat = "algemeen";
} else {
$query2 = "SELECT Naam from boten WHERE ID={$boat_id};";
$result2 = mysql_query($query2);
$row2 = mysql_fetch_assoc($result2);
$boat = $row2['Naam'];
}
//
$note = addslashes($_POST['note']);
if (!CheckName($name)) {
$fail_msg_name = "U dient een geldige voor- en achternaam op te geven. Let op: de apostrof (') wordt niet geaccepteerd.";
}
if (isset($fail_msg_name)) {
$fail = TRUE;
}
if (!isset($fail)) {
$query = "INSERT INTO `schades` (Datum, Naam, Boot_ID, Oms_lang) VALUES ('{$today_db}', '{$name}', '{$boat_id}', '{$note}');";
$result = mysql_query($query);
if (!$result) {
die("toevoegen klacht mislukt." . mysql_error());
} else {
// mail aan matcom
$message = $name . " heeft zojuist een schade gemeld betreffende '" . $boat . "'.<br>";
SendEmail("materiaal@hunze.nl", "Nieuwe schademelding", $message);
// feedback op scherm
示例4: exit
}
} else {
if ($USER[$resource[124]] == 0) {
exit($LNG['fl_expedition_tech_required']);
}
$ActualFleets = $db->uniquequery("SELECT COUNT(*) as state FROM " . FLEETS . " WHERE `fleet_owner` = '" . $_SESSION['id'] . "' AND `fleet_mission` = '15';");
if ($ActualFleets['state'] >= floor(sqrt($USER[$resource[124]]))) {
exit($LNG['fl_expedition_fleets_limit']);
}
}
exit('OK');
break;
case 'renameplanet':
$newname = request_var('newname', '', UTF8_SUPPORT);
if (!empty($newname)) {
if (!CheckName($newname)) {
exit(UTF8_SUPPORT ? $LNG['ov_newname_no_space'] : $LNG['ov_newname_alphanum']);
} else {
$db->query("UPDATE " . PLANETS . " SET `name` = '" . $db->sql_escape($newname) . "' WHERE `id` = '" . $_SESSION['planet'] . "';");
}
}
break;
case 'deleteplanet':
$password = request_var('password', '', true);
if (!empty($password)) {
$USER = $db->uniquequery("SELECT u.`password`, u.`id_planet`, p.`galaxy`, p.`system`, p.`planet`, p.`planet_type`, p.`id_luna` FROM " . USERS . " as u, " . PLANETS . " as p WHERE p.`id` = '" . $_SESSION['planet'] . "' AND u.`id` = '" . $_SESSION['id'] . "';");
$IfFleets = $db->uniquequery("SELECT COUNT(*) as state FROM " . FLEETS . " WHERE (`fleet_owner` = '" . $_SESSION['id'] . "' AND `fleet_start_galaxy` = '" . $USER['galaxy'] . "' AND `fleet_start_system` = '" . $USER['system'] . "' AND `fleet_start_planet` = '" . $USER['planet'] . "') OR (`fleet_target_owner` = '" . $_SESSION['id'] . "' AND `fleet_end_galaxy` = '" . $USER['galaxy'] . "' AND `fleet_end_system` = '" . $USER['system'] . "' AND `fleet_end_planet` = '" . $USER['planet'] . "');");
if ($IfFleets['state'] > 0) {
exit(json_encode(array('mess' => $LNG['ov_abandon_planet_not_possible'])));
} elseif ($USER['id_planet'] == $_SESSION['planet']) {
exit(json_encode(array('mess' => $LNG['ov_principal_planet_cant_abanone'])));
示例5: CheckName
#!/usr/bin/php
<?php
require_once "../../conf/cis/Config.php";
require_once "../../lib/cis/Lib.php";
function CheckName($var)
{
global $tbl_db_info;
$Conn = mysql_connect($tbl_db_info[0], $tbl_db_info[1], $tbl_db_info[2]);
mysql_select_db($tbl_db_info[3], $Conn);
$ret = "";
$uid = intval($var["userid"]);
$serv_id = intval($var["serv_id"]);
$rolename = mysql_escape_string($var["rolename"]);
$qs = "select distinct us_uId from tbl_char c, tbl_char_static cs where cs.cs_uId = c.cs_uId and (c_sName = '{$rolename}' or c_sNameFormer = '{$rolename}')";
$result = mysql_query($qs);
while ($row = mysql_fetch_row($result)) {
if ($row[0] != $uid) {
$ret = "400";
return;
}
}
$ret = "200";
header("Content-type: text/html; charset=utf-8");
header("Content-Length:" . strlen($ret));
print $ret;
}
CheckName($_GET);
?>
示例6: rename
function rename()
{
global $LNG, $PLANET;
$newname = HTTP::_GP('name', '', UTF8_SUPPORT);
if (!empty($newname)) {
if (!CheckName($newname)) {
$this->sendJSON(array('message' => $LNG['ov_newname_specialchar'], 'error' => true));
} else {
$GLOBALS['DATABASE']->query("UPDATE " . PLANETS . " SET name = '" . $GLOBALS['DATABASE']->sql_escape($newname) . "' WHERE id = " . $PLANET['id'] . ";");
$this->sendJSON(array('message' => $LNG['ov_newname_done'], 'error' => false));
}
}
}
示例7: createAllianceProcessor
private function createAllianceProcessor()
{
global $USER, $UNI, $LNG;
$atag = HTTP::_GP('atag', '', UTF8_SUPPORT);
$aname = HTTP::_GP('aname', '', UTF8_SUPPORT);
if (empty($atag)) {
$this->printMessage('<span class="rouge">' . $LNG['al_tag_required'] . '</span>', true, array("?page=alliance&mode=create", 3));
}
if (empty($aname)) {
$this->printMessage('<span class="rouge">' . $LNG['al_name_required'] . '</span>', true, array("?page=alliance&mode=create", 3));
}
if (!CheckName($aname) || !CheckName($atag)) {
$this->printMessage('<span class="rouge">' . $LNG['al_newname_specialchar'] . '</span>', true, array("?page=alliance&mode=create", 3));
}
$allianceCount = $GLOBALS['DATABASE']->getFirstCell("SELECT COUNT(*) FROM " . ALLIANCE . " WHERE ally_universe = " . $UNI . " AND (ally_tag = '" . $GLOBALS['DATABASE']->sql_escape($atag) . "' OR ally_name = '" . $GLOBALS['DATABASE']->sql_escape($aname) . "');");
if ($allianceCount != 0) {
$this->printMessage('<span class="rouge">' . sprintf($LNG['al_already_exists'], $aname) . '</span>', true, array("?page=alliance&mode=create", 3));
}
$GLOBALS['DATABASE']->multi_query("INSERT INTO " . ALLIANCE . " SET\n\t\t\t\t\t\tally_name\t\t\t\t= '" . $GLOBALS['DATABASE']->sql_escape($aname) . "',\n\t\t\t\t\t\tally_tag\t\t\t\t= '" . $GLOBALS['DATABASE']->sql_escape($atag) . "' ,\n\t\t\t\t\t\tally_owner\t\t\t\t= " . $USER['id'] . ",\n\t\t\t\t\t\tally_owner_range\t\t= '" . $LNG['al_default_leader_name'] . "',\n\t\t\t\t\t\tally_members\t\t\t= 1,\n\t\t\t\t\t\tally_register_time\t\t= " . TIMESTAMP . ",\n\t\t\t\t\t\tally_universe \t\t\t= " . $UNI . ";\n\t\t\t\t\t\tSET @allianceID = LAST_INSERT_ID();\n\t\t\t\t\t\tUPDATE " . USERS . " SET\n\t\t\t\t\t\tally_id\t\t\t\t\t= @allianceID,\n\t\t\t\t\t\tally_rank_id\t\t\t= 0,\n\t\t\t\t\t\tally_register_time \t\t= " . TIMESTAMP . "\n\t\t\t\t\t\tWHERE id = " . $USER['id'] . ";\n\t\t\t\t\t\tUPDATE " . STATPOINTS . " SET\n\t\t\t\t\t\tid_ally \t\t\t\t= @allianceID\n\t\t\t\t\t\tWHERE id_owner = " . $USER['id'] . ";");
$this->printMessage('<span class="vert">' . sprintf($LNG['al_created'], $aname . ' [' . $atag . ']') . '</span>', true, array('?page=alliance', 3));
}
示例8: function
});
$app->get('/Login/id/:mid/pw/:pw', function () {
$uri = $_SERVER['REQUEST_URI'];
$arr_items = split('/', $uri);
$pw = $arr_items[count($arr_items) - 1];
$id = $arr_items[count($arr_items) - 3];
//echo $id." ".$pw;
Login($id, $pw);
});
$app->get('/Check/id/:mid', function () {
$uri = $_SERVER['REQUEST_URI'];
$arr_items = split('/', $uri);
$id = $arr_items[count($arr_items) - 1];
//$id = $arr_items[count($arr_items) - 3];
//echo $id;
CheckName($id);
});
// POST route
$app->post('/post', function () {
echo 'This is a POST route';
});
// PUT route
$app->put('/put', function () {
echo 'This is a PUT route';
});
// PATCH route
$app->patch('/patch', function () {
echo 'This is a PATCH route';
});
// DELETE route
$app->delete('/delete', function () {
示例9: ShowCreatorPage
function ShowCreatorPage()
{
global $LNG, $USER, $UNI, $CONF;
$template = new template();
switch ($_GET['mode']) {
case 'user':
$LNG->includeData(array('PUBLIC'));
if ($_POST) {
$UserName = HTTP::_GP('name', '', UTF8_SUPPORT);
$UserPass = HTTP::_GP('password', '');
$UserPass2 = HTTP::_GP('password2', '');
$UserMail = HTTP::_GP('email', '');
$UserMail2 = HTTP::_GP('email2', '');
$UserLang = HTTP::_GP('lang', '');
$UserAuth = HTTP::_GP('authlevel', 0);
$Galaxy = HTTP::_GP('galaxy', 0);
$System = HTTP::_GP('system', 0);
$Planet = HTTP::_GP('planet', 0);
$ExistsUser = $GLOBALS['DATABASE']->getFirstCell("SELECT (SELECT COUNT(*) FROM " . USERS . " WHERE universe = " . $_SESSION['adminuni'] . " AND username = '" . $GLOBALS['DATABASE']->sql_escape($UserName) . "') + (SELECT COUNT(*) FROM " . USERS_VALID . " WHERE universe = " . $_SESSION['adminuni'] . " AND username = '" . $GLOBALS['DATABASE']->sql_escape($UserName) . "')");
$ExistsMails = $GLOBALS['DATABASE']->getFirstCell("SELECT (SELECT COUNT(*) FROM " . USERS . " WHERE universe = " . $_SESSION['adminuni'] . " AND (email = '" . $GLOBALS['DATABASE']->sql_escape($UserMail) . "' OR email_2 = '" . $GLOBALS['DATABASE']->sql_escape($UserMail) . "')) + (SELECT COUNT(*) FROM " . USERS_VALID . " WHERE universe = " . $_SESSION['adminuni'] . " AND email = '" . $GLOBALS['DATABASE']->sql_escape($UserMail) . "')");
if (!ValidateAddress($UserMail)) {
$errors .= $LNG['invalid_mail_adress'];
}
if (empty($UserName)) {
$errors .= $LNG['empty_user_field'];
}
if (strlen($UserPass) < 6) {
$errors .= $LNG['password_lenght_error'];
}
if ($UserPass != $UserPass2) {
$errors .= $LNG['different_passwords'];
}
if ($UserMail != $UserMail2) {
$errors .= $LNG['different_mails'];
}
if (!CheckName($UserName)) {
$errors .= $LNG['user_field_specialchar'];
}
if ($ExistsUser != 0) {
$errors .= $LNG['user_already_exists'];
}
if ($ExistsMails != 0) {
$errors .= $LNG['mail_already_exists'];
}
if (CheckPlanetIfExist($Galaxy, $System, $Planet, $_SESSION['adminuni'])) {
$errors .= $LNG['planet_already_exists'];
}
if ($Galaxy > Config::get('max_galaxy') || $System > Config::get('max_system') || $Planet > Config::get('max_planets')) {
$errors .= $LNG['po_complete_all2'];
}
if (!empty($errors)) {
$template->message($errors, '?page=create&mode=user', 10, true);
exit;
}
$SQL = "INSERT INTO " . USERS . " SET\n\t\t\t\tusername\t\t= '" . $GLOBALS['DATABASE']->sql_escape($UserName) . "',\n\t\t\t\tpassword\t\t= '" . cryptPassword($UserPass) . "',\n\t\t\t\temail\t\t\t= '" . $GLOBALS['DATABASE']->sql_escape($UserMail) . "',\n\t\t\t\temail_2\t\t\t= '" . $GLOBALS['DATABASE']->sql_escape($UserMail) . "',\n\t\t\t\tlang\t\t\t= '" . $GLOBALS['DATABASE']->sql_escape($UserLang) . "',\n\t\t\t\tauthlevel\t\t= " . $UserAuth . ",\n\t\t\t\tip_at_reg\t\t= '" . $_SERVER['REMOTE_ADDR'] . "',\n\t\t\t\tid_planet\t\t= 0,\n\t\t\t\tuniverse\t\t= " . $_SESSION['adminuni'] . ",\n\t\t\t\tonlinetime\t\t= " . TIMESTAMP . ",\n\t\t\t\tregister_time\t= " . TIMESTAMP . ",\n\t\t\t\tdpath\t\t\t= '" . DEFAULT_THEME . "',\n\t\t\t\ttimezone\t\t= '" . Config::get('timezone') . "',\n\t\t\t\tuctime\t\t\t= 0;";
$GLOBALS['DATABASE']->query($SQL);
$UserID = $GLOBALS['DATABASE']->GetInsertID();
require_once 'includes/functions/CreateOnePlanetRecord.php';
$PlanerID = CreateOnePlanetRecord($Galaxy, $System, $Planet, $_SESSION['adminuni'], $UserID, $LNG['fcm_planet'], true, $UserAuth);
$SQL = "UPDATE " . USERS . " SET \n\t\t\t\tid_planet\t= " . $PlanerID . ",\n\t\t\t\tgalaxy\t\t= " . $Galaxy . ",\n\t\t\t\tsystem\t\t= " . $System . ",\n\t\t\t\tplanet\t\t= " . $Planet . "\n\t\t\t\tWHERE\n\t\t\t\tid\t\t\t= " . $UserID . ";\n\t\t\t\tINSERT INTO " . STATPOINTS . " SET \n\t\t\t\tid_owner\t= " . $UserID . ",\n\t\t\t\tuniverse\t= " . $_SESSION['adminuni'] . ",\n\t\t\t\tstat_type\t= 1,\n\t\t\t\ttech_rank\t= " . (Config::get('users_amount') + 1) . ",\n\t\t\t\tbuild_rank\t= " . (Config::get('users_amount') + 1) . ",\n\t\t\t\tdefs_rank\t= " . (Config::get('users_amount') + 1) . ",\n\t\t\t\tfleet_rank\t= " . (Config::get('users_amount') + 1) . ",\n\t\t\t\ttotal_rank\t= " . (Config::get('users_amount') + 1) . ";";
$GLOBALS['DATABASE']->multi_query($SQL);
Config::update(array('users_amount' => Config::get('users_amount') + 1));
$template->message($LNG['new_user_success'], '?page=create&mode=user', 5, true);
exit;
}
$AUTH = array();
$AUTH[AUTH_USR] = $LNG['user_level'][AUTH_USR];
if ($USER['authlevel'] >= AUTH_OPS) {
$AUTH[AUTH_OPS] = $LNG['user_level'][AUTH_OPS];
}
if ($USER['authlevel'] >= AUTH_MOD) {
$AUTH[AUTH_MOD] = $LNG['user_level'][AUTH_MOD];
}
if ($USER['authlevel'] >= AUTH_ADM) {
$AUTH[AUTH_ADM] = $LNG['user_level'][AUTH_ADM];
}
$template->assign_vars(array('admin_auth' => $USER['authlevel'], 'new_add_user' => $LNG['new_add_user'], 'new_creator_refresh' => $LNG['new_creator_refresh'], 'new_creator_go_back' => $LNG['new_creator_go_back'], 'universe' => $LNG['mu_universe'], 'user_reg' => $LNG['user_reg'], 'pass_reg' => $LNG['pass_reg'], 'pass2_reg' => $LNG['pass2_reg'], 'email_reg' => $LNG['email_reg'], 'email2_reg' => $LNG['email2_reg'], 'new_coord' => $LNG['new_coord'], 'new_range' => $LNG['new_range'], 'lang_reg' => $LNG['lang_reg'], 'new_title' => $LNG['new_title'], 'Selector' => array('auth' => $AUTH, 'lang' => $LNG->getAllowedLangs(false))));
$template->show('CreatePageUser.tpl');
break;
case 'moon':
if ($_POST) {
$PlanetID = HTTP::_GP('add_moon', 0);
$MoonName = HTTP::_GP('name', '', UTF8_SUPPORT);
$Diameter = HTTP::_GP('diameter', 0);
$FieldMax = HTTP::_GP('field_max', 0);
$MoonPlanet = $GLOBALS['DATABASE']->getFirstRow("SELECT temp_max, temp_min, id_luna, galaxy, system, planet, planet_type, destruyed, id_owner FROM " . PLANETS . " WHERE id = '" . $PlanetID . "' AND universe = '" . $_SESSION['adminuni'] . "' AND planet_type = '1' AND destruyed = '0';");
if (!isset($MoonPlanet)) {
$template->message($LNG['mo_planet_doesnt_exist'], '?page=create&mode=moon', 3, true);
exit;
}
require_once 'includes/functions/CreateOneMoonRecord.php';
if (empty($MoonName)) {
$MoonName = $LNG['type_planet'][3];
}
if (CreateOneMoonRecord($MoonPlanet['galaxy'], $MoonPlanet['system'], $MoonPlanet['planet'], $_SESSION['adminuni'], $MoonPlanet['id_owner'], $MoonName, 20, TIMESTAMP, $_POST['diameter_check'] == 'on' ? 0 : $Diameter) !== false) {
$template->message($LNG['mo_moon_added'], '?page=create&mode=moon', 3, true);
} else {
$template->message($LNG['mo_moon_unavaible'], '?page=create&mode=moon', 3, true);
}
exit;
//.........这里部分代码省略.........
示例10:
if (empty($UserPlanet)) {
$errors .= $LNG['empty_planet_field'];
}
if (!isset($UserPass[5])) {
$errors .= $LNG['password_lenght_error'];
}
if ($UserPass != $UserPass2) {
$errors .= $LNG['different_passwords'];
}
if ($UserEmail != $UserEmail2) {
$errors .= $LNG['different_mails'];
}
if (!CheckName($UserName)) {
$errors .= UTF8_SUPPORT ? $LNG['user_field_no_space'] : $LNG['user_field_no_alphanumeric'];
}
if (!CheckName($UserPlanet)) {
$errors .= UTF8_SUPPORT ? $LNG['planet_field_no_space'] : $LNG['planet_field_no_alphanumeric'];
}
if ($agbrules != 'on') {
$errors .= $LNG['terms_and_conditions'];
}
if (isset($Exist['userv']['username']) || isset($Exist['valid']['username']) && ($UserName == $Exist['userv']['username'] || $UserName == $Exist['valid']['username'])) {
$errors .= $LNG['user_already_exists'];
}
if ((isset($Exist['userv']['email']) || isset($Exist['valid']['email'])) && ($UserEmail == $Exist['userv']['email'] || $UserEmail == $Exist['valid']['email'])) {
$errors .= $LNG['mail_already_exists'];
}
if (!empty($errors)) {
$template->message($errors, '?page=reg&lang=' . $LANG, 3, true);
exit;
}
示例11: __construct
public function __construct()
{
global $USER, $PLANET, $CONF, $LNG, $LANG, $UNI, $db, $SESSION, $THEME;
$mode = request_var('mode', '');
$exit = request_var('exit_modus', '');
$db_deaktjava = request_var('db_deaktjava', '');
$PlanetRess = new ResourceUpdate();
$PlanetRess->CalcResource();
$PlanetRess->SavePlanetToDB();
$template = new template();
$SQLQuery = "";
switch ($mode) {
case "exit":
if ($exit == 'on' and $USER['urlaubs_until'] <= TIMESTAMP) {
$SQLQuery .= "UPDATE " . USERS . " SET `urlaubs_modus` = '0', `urlaubs_until` = '0' WHERE `id` = '" . $USER['id'] . "' LIMIT 1;UPDATE " . PLANETS . " SET `last_update` = '" . TIMESTAMP . "', `energy_used` = '10', `energy_max` = '10', `metal_mine_porcent` = '10', `crystal_mine_porcent` = '10', `deuterium_sintetizer_porcent` = '10', `solar_plant_porcent` = '10', `fusion_plant_porcent` = '10', `solar_satelit_porcent` = '10' WHERE `id_owner` = '" . $USER["id"] . "';";
}
$SQLQuery .= $db_deaktjava == 'on' ? "UPDATE " . USERS . " SET `db_deaktjava` = '" . TIMESTAMP . "' WHERE `id` = '" . $USER['id'] . "' LIMIT 1;" : "UPDATE " . USERS . " SET `db_deaktjava` = '0' WHERE `id` = '" . $USER['id'] . "' LIMIT 1;";
$db->multi_query($SQLQuery);
$template->message($LNG['op_options_changed'], '?page=options', 1);
break;
case "change":
$design = request_var('design', '');
$noipcheck = request_var('noipcheck', '');
$USERname = request_var('db_character', $USER['username'], UTF8_SUPPORT);
$db_email = request_var('db_email', $USER['email']);
$spio_anz = max(request_var('spio_anz', 5), 1);
$settings_tooltiptime = request_var('settings_tooltiptime', 1);
$settings_fleetactions = max(request_var('settings_fleetactions', 1), 1);
$settings_planetmenu = request_var('settings_planetmenu', '');
$settings_esp = request_var('settings_esp', '');
$settings_wri = request_var('settings_wri', '');
$settings_bud = request_var('settings_bud', '');
$settings_mis = request_var('settings_mis', '');
$settings_rep = request_var('settings_rep', '');
$settings_tnstor = request_var('settings_tnstor', '');
$urlaubs_modus = request_var('urlaubs_modus', '');
$SetSort = request_var('settings_sort', 0);
$SetOrder = request_var('settings_order', 0);
$db_password = request_var('db_password', '');
$newpass1 = request_var('newpass1', '');
$newpass2 = request_var('newpass2', '');
$hof = request_var('hof', '');
$adm_pl_prot = request_var('adm_pl_prot', '');
$langs = request_var('langs', $LANG->getUser());
$dpath = request_var('dpath', $THEME->getThemeName());
$design = $design == 'on' ? 1 : 0;
$hof = $hof == 'on' ? 1 : 0;
$noipcheck = $noipcheck == 'on' ? 1 : 0;
$settings_esp = $settings_esp == 'on' ? 1 : 0;
$settings_wri = $settings_wri == 'on' ? 1 : 0;
$settings_bud = $settings_bud == 'on' ? 1 : 0;
$settings_mis = $settings_mis == 'on' ? 1 : 0;
$settings_rep = $settings_rep == 'on' ? 1 : 0;
$settings_tnstor = $settings_tnstor == 'on' ? 1 : 0;
$settings_planetmenu = $settings_planetmenu == 'on' ? 1 : 0;
$db_deaktjava = $db_deaktjava == 'on' ? TIMESTAMP : 0;
$langs = in_array($langs, $LANG->getAllowedLangs()) ? $langs : $LANG->getUser();
$dpath = in_array($dpath, Theme::getAvalibleSkins()) ? $dpath : $THEME->getThemeName();
if ($urlaubs_modus == 'on') {
if (!$this->CheckVMode()) {
$template->message($LNG['op_cant_activate_vacation_mode'], '?page=options', 3);
exit;
}
$SQLQuery .= "UPDATE " . USERS . " SET \r\n\t\t\t\t\t\t\t\t\t`urlaubs_modus` = '1',\r\n\t\t\t\t\t\t\t\t\t`urlaubs_until` = '" . (TIMESTAMP + VACATION_MIN_TIME) . "'\r\n\t\t\t\t\t\t\t\t\tWHERE `id` = '" . $USER["id"] . "';\r\n\t\t\t\t\t\t\t\t\tUPDATE " . PLANETS . " SET\r\n\t\t\t\t\t\t\t\t\t`energy_used` = '0',\r\n\t\t\t\t\t\t\t\t\t`energy_max` = '0',\r\n\t\t\t\t\t\t\t\t\t`metal_mine_porcent` = '0',\r\n\t\t\t\t\t\t\t\t\t`crystal_mine_porcent` = '0',\r\n\t\t\t\t\t\t\t\t\t`deuterium_sintetizer_porcent` = '0',\r\n\t\t\t\t\t\t\t\t\t`solar_plant_porcent` = '0',\r\n\t\t\t\t\t\t\t\t\t`fusion_plant_porcent` = '0',\r\n\t\t\t\t\t\t\t\t\t`solar_satelit_porcent` = '0',\r\n\t\t\t\t\t\t\t\t\t`metal_perhour` = '0',\r\n `crystal_perhour` = '0',\r\n `deuterium_perhour` = '0'\r\n WHERE `id_owner` = '" . $USER["id"] . "';";
}
$SQLQuery .= "UPDATE " . USERS . " SET\r\n\t\t\t\t\t\t\t\t`dpath` = '" . $db->sql_escape($dpath) . "',\r\n\t\t\t\t\t\t\t\t`design` = '" . $design . "',\r\n\t\t\t\t\t\t\t\t`noipcheck` = '" . $noipcheck . "',\r\n\t\t\t\t\t\t\t\t`planet_sort` = '" . $SetSort . "',\r\n\t\t\t\t\t\t\t\t`planet_sort_order` = '" . $SetOrder . "',\r\n\t\t\t\t\t\t\t\t`spio_anz` = '" . $spio_anz . "',\r\n\t\t\t\t\t\t\t\t`settings_tooltiptime` = '" . $settings_tooltiptime . "',\r\n\t\t\t\t\t\t\t\t`settings_fleetactions` = '" . $settings_fleetactions . "',\r\n\t\t\t\t\t\t\t\t`settings_planetmenu` = '" . $settings_planetmenu . "',\r\n\t\t\t\t\t\t\t\t`settings_esp` = '" . $settings_esp . "',\r\n\t\t\t\t\t\t\t\t`settings_wri` = '" . $settings_wri . "',\r\n\t\t\t\t\t\t\t\t`settings_bud` = '" . $settings_bud . "',\r\n\t\t\t\t\t\t\t\t`settings_mis` = '" . $settings_mis . "',\r\n\t\t\t\t\t\t\t\t`settings_tnstor` = '" . $settings_tnstor . "',\r\n\t\t\t\t\t\t\t\t`db_deaktjava` = '" . $db_deaktjava . "',\r\n\t\t\t\t\t\t\t\t`lang` = '" . $langs . "',\r\n\t\t\t\t\t\t\t\t`hof` = '" . $hof . "',\r\n\t\t\t\t\t\t\t\t`settings_rep` = '" . $settings_rep . "' \r\n\t\t\t\t\t\t\t\tWHERE `id` = '" . $USER["id"] . "';";
if ($USER['authlevel'] > 0) {
$SQLQuery .= $adm_pl_prot == 'on' ? "UPDATE " . PLANETS . " SET `id_level` = '" . $USER['authlevel'] . "' WHERE `id_owner` = '" . $USER['id'] . "';" : "UPDATE " . PLANETS . " SET `id_level` = '0' WHERE `id_owner` = '" . $USER['id'] . "';";
}
if (!empty($db_email) && $db_email != $USER['email'] && md5($db_password) == $USER['password']) {
if (!ValidateAddress($db_email)) {
$template->message($LNG['op_not_vaild_mail'], '?page=options', 3);
exit;
}
$query = $db->uniquequery("SELECT id FROM " . USERS . " WHERE email = '" . $db->sql_escape($db_email) . "' OR email_2 = '" . $db->sql_escape($db_email) . "';");
if (!empty($query)) {
$template->message(sprintf($LNG['op_change_mail_exist'], $db_email), '?page=options', 3);
exit;
}
$SQLQuery .= "UPDATE " . USERS . " SET `email` = '" . $db->sql_escape($db_email) . "', `setmail` = '" . (TIMESTAMP + 604800) . "' WHERE `id` = '" . $USER['id'] . "';";
}
if (!empty($newpass1) && md5($db_password) == $USER["password"] && $newpass1 == $newpass2) {
$newpass = md5($newpass1);
$SQLQuery .= "UPDATE " . USERS . " SET `password` = '" . $newpass . "' WHERE `id` = '" . $USER['id'] . "';";
$SESSION->DestroySession();
$template->message($LNG['op_password_changed'], "index.php", 3);
} elseif ($USER['username'] != $USERname) {
if (!CheckName($USERname)) {
$template->message($LNG['op_user_name_no_alphanumeric'], '?page=options', 3);
} elseif ($USER['uctime'] >= TIMESTAMP - 60 * 60 * 24 * 7) {
$template->message($LNG['op_change_name_pro_week'], '?page=options', 3);
} else {
$query = $db->uniquequery("SELECT id FROM " . USERS . " WHERE username='" . $db->sql_escape($USERname) . "';");
if (!empty($query)) {
$template->message(sprintf($LNG['op_change_name_exist'], $USERname), '?page=options', 3);
} else {
require ROOT_PATH . 'includes/classes/class.Records.php';
$Records = new records();
$RecordsArray = $Records->RenameRecordOwner($USER['username'], $USERname, $UNI);
$SQLQuery .= "UPDATE " . USERS . " SET `username` = '" . $db->sql_escape($USERname) . "', `uctime` = '" . TIMESTAMP . "' WHERE `id`= '" . $USER['id'] . "';";
//.........这里部分代码省略.........
示例12: ShowCreatorPage
function ShowCreatorPage()
{
global $LNG, $db, $USER;
$template = new template();
$template->page_header();
switch ($_GET['mode']) {
case 'user':
includeLang('PUBLIC');
if ($_POST) {
$UserName = request_var('name', '', UTF8_SUPPORT);
$UserPass = request_var('password', '');
$UserPass2 = request_var('password2', '');
$UserMail = request_var('email', '');
$UserMail2 = request_var('email2', '');
$UserLang = request_var('lang', '');
$UserAuth = request_var('authlevel', 0);
$Galaxy = request_var('galaxy', 0);
$System = request_var('system', 0);
$Planet = request_var('planet', 0);
if ($CONF['capaktiv'] === '1') {
require_once 'includes/libs/reCAPTCHA/recaptchalib.php';
$resp = recaptcha_check_answer($CONF['capprivate'], $_SERVER['REMOTE_ADDR'], request_var('recaptcha_challenge_field', ''), request_var('recaptcha_response_field', ''));
if (!$resp->is_valid) {
$errorlist .= $LNG['wrong_captcha'];
}
}
$Exist['userv'] = $db->uniquequery("SELECT username, email FROM " . USERS . " WHERE username = '" . $db->sql_escape($UserName) . "' OR email = '" . $db->sql_escape($UserEmail) . "';");
$Exist['vaild'] = $db->uniquequery("SELECT username, email FROM " . USERS_VALID . " WHERE username = '" . $db->sql_escape($UserName) . "' OR email = '" . $db->sql_escape($UserEmail) . "';");
if (!ValidateAddress($UserMail)) {
$errors .= $LNG['invalid_mail_adress'];
}
if (empty($UserName)) {
$errors .= $LNG['empty_user_field'];
}
if (strlen($UserPass) < 6) {
$errors .= $LNG['password_lenght_error'];
}
if ($UserPass != $UserPass2) {
$errors .= $LNG['different_passwords'];
}
if ($UserMail != $UserMail2) {
$errors .= $LNG['different_mails'];
}
if (!CheckName($UserName)) {
$errors .= UTF8_SUPPORT ? $LNG['user_field_no_space'] : $LNG['user_field_no_alphanumeric'];
}
if (isset($Exist['userv']['username']) || isset($Exist['vaild']['username']) && ($UserName == $Exist['userv']['username'] || $UserName == $Exist['vaild']['username'])) {
$errors .= $LNG['user_already_exists'];
}
if ((isset($Exist['userv']['email']) || isset($Exist['vaild']['email'])) && ($UserEmail == $Exist['userv']['email'] || $UserEmail == $Exist['vaild']['email'])) {
$errors .= $LNG['mail_already_exists'];
}
if (CheckPlanetIfExist($Galaxy, $System, $Position)) {
$errors .= $LNG['planet_already_exists'];
}
if (!empty($errors)) {
$template->message($errors, '?page=create&mode=user', 3, true);
exit;
}
$SQL = "INSERT INTO " . USERS . " SET ";
$SQL .= "`username` = '" . $db->sql_escape($UserName) . "', ";
$SQL .= "`email` = '" . $db->sql_escape($UserMail) . "', ";
$SQL .= "`email_2` = '" . $db->sql_escape($UserMail) . "', ";
$SQL .= "`lang` = '" . $db->sql_escape($UserLang) . "', ";
$SQL .= "`authlevel` = '" . $UserAuth . "', ";
$SQL .= "`ip_at_reg` = '" . $_SERVER['REMOTE_ADDR'] . "', ";
$SQL .= "`id_planet` = '0', ";
$SQL .= "`onlinetime` = '" . TIMESTAMP . "', ";
$SQL .= "`register_time` = '" . TIMESTAMP . "', ";
$SQL .= "`password` = '" . md5($UserPass) . "', ";
$SQL .= "`dpath` = '" . DEFAULT_SKINPATH . "', ";
$SQL .= "`uctime`= '0';";
$db->query($SQL);
$db->query("UPDATE " . CONFIG . " SET `config_value` = config_value + '1' WHERE `config_name` = 'users_amount';");
$ID_USER = $db->uniquequery("SELECT `id` FROM " . USERS . " WHERE `username` = '" . $db->sql_escape($UserName) . "';");
require_once ROOT_PATH . 'includes/functions/CreateOnePlanetRecord.' . PHP_EXT;
CreateOnePlanetRecord($Galaxy, $System, $Planet, $ID_USER['id'], $UserPlanet, true, $UserAuth);
$ID_PLANET = $db->uniquequery("SELECT `id` FROM " . PLANETS . " WHERE `id_owner` = '" . $ID_USER['id'] . "';");
$SQL = "UPDATE " . USERS . " SET ";
$SQL .= "`id_planet` = '" . $ID_PLANET['id'] . "', ";
$SQL .= "`galaxy` = '" . $Galaxy . "', ";
$SQL .= "`system` = '" . $System . "', ";
$SQL .= "`planet` = '" . $Planet . "' ";
$SQL .= "WHERE ";
$SQL .= "`id` = '" . $ID_USER['id'] . "' ";
$SQL .= "LIMIT 1;";
$db->query($SQL);
$template->message($LNG['new_user_success'], '?page=create&mode=user', 3, true);
exit;
}
$AUTH[0] = $LNG['user_level'][0];
if ($USER['authlevel'] >= AUTH_OPS) {
$AUTH[AUTH_OPS] = $LNG['user_level'][AUTH_OPS];
}
if ($USER['authlevel'] >= AUTH_MOD) {
$AUTH[AUTH_MOD] = $LNG['user_level'][AUTH_MOD];
}
if ($USER['authlevel'] >= AUTH_ADM) {
$AUTH[AUTH_ADM] = $LNG['user_level'][AUTH_ADM];
}
//.........这里部分代码省略.........
示例13: makeReservation
function makeReservation($id, $boat_id, $name, $team_name, $email, $mpb, $date, $start_time_hrs, $start_time_mins, $end_time_hrs, $end_time_mins, $ergo_lo = 0, $ergo_hi = 0)
{
global $database_host;
global $database_user;
global $database_pass;
global $database;
global $opzoektabel;
global $koudwaterprotocol;
global $today_db;
global $thehour;
global $theminute;
global $themonth;
$NR_OF_CONCEPTS = 8;
// LET OP: aanpassen als het aantal Concept-ergo's verandert! (ivm blokinschrijving)
$bisdblink = mysql_connect($database_host, $database_user, $database_pass);
if (!mysql_select_db($database, $bisdblink)) {
$messages[] = "Fout: database niet gevonden.";
$returnArray = array("success" => false, "messages" => $messages);
return $returnArray;
}
$messages = array();
// check persoonsnaam
if (!CheckName($name)) {
$messages[] = "• U dient een geldige voor- en achternaam op te geven. Let op: de apostrof (') wordt niet geaccepteerd.";
}
// email is niet verplicht, maar moet wel correct zijn
if ($email && !CheckEmail($email)) {
$messages[] = "• U dient een geldig e-mailadres op te geven.";
}
// check date
$date_db = 0;
if (!$date || !CheckTheDate($date) || $mpb != "Societeit" && !InRange($date, 10)) {
$messages[] = "• U dient een (geldige) inschrijfdatum op te geven, van vandaag tot over maximaal 10 dagen.";
} else {
$date_db = DateToDBdate($date);
if (strtotime($date_db) < strtotime($today_db)) {
$messages[] = "Een inschrijving kan niet in het verleden plaatsvinden.";
}
}
// check time
if (!is_numeric($start_time_hrs) || $start_time_hrs < 6 || $start_time_hrs > 23) {
$messages[] = "Ongeldig start-uur.";
}
if (!is_numeric($end_time_hrs) || $end_time_hrs < 6 || $end_time_hrs > 23) {
$messages[] = "Ongeldig eind-uur.";
}
if ($start_time_mins != "00" && $start_time_mins != "0" && $start_time_mins != "15" && $start_time_mins != "30" && $start_time_mins != "45") {
$messages[] = "Ongeldige start-minuten.";
}
if ($end_time_mins != "00" && $end_time_mins != "0" && $end_time_mins != "15" && $end_time_mins != "30" && $end_time_mins != "45") {
$messages[] = "Ongeldige eind-minuten.";
}
$start_time = $start_time_hrs . ":" . $start_time_mins;
$end_time = $end_time_hrs . ":" . $end_time_mins;
$duration = ($end_time_hrs - $start_time_hrs) * 60 + ($end_time_mins - $start_time_mins);
if ($duration <= 0) {
$messages[] = "De eindtijd van een inschrijving dient later dan de begintijd te zijn.";
}
if ($date_db == $today_db && ($start_time_hrs < $thehour || $start_time_hrs == $thehour && $start_time_mins < $theminute)) {
$messages[] = "Een inschrijving kan niet in het verleden beginnen.";
}
// check ergo-blok
if (!is_numeric($ergo_lo) || !is_numeric($ergo_hi) || $ergo_lo < 0 || $ergo_lo > $NR_OF_CONCEPTS || $ergo_hi < 0 || $ergo_hi > $NR_OF_CONCEPTS) {
$messages[] = "Nummering van de Concept-ergometers klopt niet.";
}
$ergo_range = $ergo_hi - $ergo_lo;
if ($ergo_range < 0) {
$messages[] = "Het blok moet lopen van de laagst- t/m de hoogst-genummerde Concept-ergometer.";
$ergo_lo = 0;
$ergo_hi = 0;
}
// check boat
if (!is_numeric($boat_id) || $boat_id == 0) {
$boat = "";
$messages[] = "U heeft geen boot geselecteerd.";
} else {
$query_bootnaam = "SELECT Naam FROM boten WHERE ID={$boat_id};";
$result_bootnaam = mysql_query($query_bootnaam);
$row_bootnaam = mysql_fetch_assoc($result_bootnaam);
$boat = $row_bootnaam['Naam'];
}
// cat. & grade bepalen n.a.v. boot die wordt ingeschreven
$query = "SELECT Roeigraad, `Type` FROM boten WHERE ID='" . $boat_id . "';";
$result = mysql_query($query);
if ($result) {
$row = mysql_fetch_assoc($result);
$grade = $row['Roeigraad'];
$type = $row['Type'];
$query2 = "SELECT Categorie FROM types WHERE `Type`='" . $type . "';";
$result2 = mysql_query($query2);
if ($result2) {
$row2 = mysql_fetch_assoc($result2);
$cat = $row2['Categorie'];
}
}
// check op uit de vaart
$query = "SELECT * \r\t\tFROM uitdevaart \r\t\tWHERE Verwijderd=0 \r\t\tAND Boot_ID='{$boat_id}' \r\t\tAND Startdatum<='{$date_db}' \r\t\tAND (Einddatum='0' OR Einddatum='0000-00-00' OR Einddatum IS NULL OR Einddatum>='{$date_db}');";
$result = mysql_query($query);
if (!$result) {
$messages[] = "Ophalen van uit de vaart-informatie mislukt.";
//.........这里部分代码省略.........
示例14: apostrof
// tijden
$start_time_hrs = $_POST['start_time_hrs'];
$start_time_mins = $_POST['start_time_mins'];
$start_time = $start_time_hrs . ":" . $start_time_mins;
$end_time_hrs = $_POST['end_time_hrs'];
$end_time_mins = $_POST['end_time_mins'];
$end_time = $end_time_hrs . ":" . $end_time_mins;
$duration = ($end_time_hrs - $start_time_hrs) * 60 + ($end_time_mins - $start_time_mins);
if ($duration <= 0) {
$fail_msg_time = "De eindtijd van een outing dient later dan de begintijd te zijn.";
}
// boot
$boat_id = $_POST['boat_id'];
// naam
$pname = $_POST['pname'];
if (!CheckName($pname)) {
$fail_msg_pname = "U dient een geldige voor- en achternaam op te geven. Let op: de apostrof (') wordt niet geaccepteerd.";
}
// ploegnaam
$name = $_POST['name'];
// e-mail
$email = $_POST['email'];
// niet verplicht, maar moet wel correct zijn
if ($email && !CheckEmail($email)) {
$fail_msg_email = "U dient een geldig e-mailadres op te geven.";
}
// als niet gefaald, repeterend spitsblok toevoegen
if (isset($fail_msg_startdate) || isset($fail_msg_enddate) || isset($fail_msg_date) || isset($fail_msg_time) || isset($fail_msg_pname) || isset($fail_msg_email)) {
$fail = true;
} else {
if ($spits_id) {
示例15: __construct
public function __construct()
{
global $USER, $PLANET, $LNG, $db, $UNI;
$parse = $LNG;
$mode = request_var('mode', '');
$a = request_var('a', 1);
$sort1 = request_var('sort1', '');
$sort2 = request_var('sort2', '');
$edit = request_var('edit', '');
$rank = request_var('rank', '');
$kick = request_var('kick', '');
$id = request_var('id', '');
$action = request_var('action', '');
$allyid = request_var('allyid', '');
$tag = request_var('tag', '');
$PlanetRess = new ResourceUpdate();
$PlanetRess->CalcResource();
$PlanetRess->SavePlanetToDB();
$template = new template();
if ($USER['ally_id'] != 0 && $USER['ally_request'] != 0) {
$db->query("UPDATE `" . USERS . "` SET `ally_id` = 0 WHERE `id` = " . $USER['id'] . ";");
redirectTo("game.php?page=alliance");
}
switch ($USER['ally_id']) {
case 0:
switch ($mode) {
case 'ainfo':
$allyrow = $db->uniquequery("SELECT * FROM " . ALLIANCE . " WHERE ally_tag='" . $db->sql_escape($tag) . "' OR id='" . $db->sql_escape($a) . "';");
if (!$allyrow) {
die(redirectTo("game.php?page=alliance"));
}
$this->ainfo($allyrow, $template);
break;
case 'make':
if ($USER['ally_request'] == 0) {
if ($action == "send") {
$atag = request_var('atag', '', UTF8_SUPPORT);
$aname = request_var('aname', '', UTF8_SUPPORT);
if (empty($atag)) {
$template->message($LNG['al_tag_required'], "?page=alliance&mode=make", 3);
}
if (empty($aname)) {
$template->message($LNG['al_name_required'], "?page=alliance&mode=make", 3);
}
if (!CheckName($aname) || !CheckName($atag)) {
$template->message(UTF8_SUPPORT ? $LNG['al_newname_no_space'] : $LNG['al_newname_alphanum'], "?page=alliance&mode=make", 3);
}
$tagquery = $db->countquery("SELECT COUNT(*) FROM `" . ALLIANCE . "` WHERE `ally_universe` = '" . $UNI . "' AND (ally_tag = '" . $db->sql_escape($atag) . "' OR ally_name = '" . $db->sql_escape($aname) . "');");
if ($tagquery == 0) {
$template->message(sprintf($LNG['al_already_exists'], $aname), "?page=alliance&mode=make", 3);
}
$db->multi_query("INSERT INTO " . ALLIANCE . " SET\r\n `ally_name`='" . $db->sql_escape($aname) . "',\r\n `ally_tag`='" . $db->sql_escape($atag) . "' ,\r\n `ally_owner`='" . $USER['id'] . "',\r\n `ally_owner_range`='Leader',\r\n `ally_members`='1',\r\n `ally_register_time`='" . TIMESTAMP . "',\r\n\t\t\t\t\t\t\t\t`ally_universe` ='" . $UNI . "';\r\n UPDATE " . USERS . " SET\r\n `ally_id`= (SELECT `id` FROM " . ALLIANCE . " WHERE ally_name = '" . $db->sql_escape($aname) . "'),\r\n `ally_name` = '" . $db->sql_escape($aname) . "',\r\n `ally_register_time` = '" . TIMESTAMP . "'\r\n WHERE `id` = '" . $USER['id'] . "';\r\n UPDATE " . STATPOINTS . " SET\r\n `id_ally` = (SELECT `id` FROM " . ALLIANCE . " WHERE ally_name = '" . $db->sql_escape($aname) . "')\r\n WHERE `id_owner` = '" . $USER['id'] . "';");
$template->message(sprintf($LNG['al_created'], $atag), "?page=alliance", 3);
} else {
$template->assign_vars(array('al_make_alliance' => $LNG['al_make_alliance'], 'al_make_ally_tag_required' => $LNG['al_make_ally_tag_required'], 'al_make_ally_name_required' => $LNG['al_make_ally_name_required'], 'al_make_submit' => $LNG['al_make_submit']));
$template->show("alliance_make.tpl");
}
} else {
redirectTo("game.php?page=alliance");
}
break;
case 'search':
if ($USER['ally_request'] == 0) {
$searchtext = request_var('searchtext', '', UTF8_SUPPORT);
if (!empty($searchtext)) {
$Search = $db->query("SELECT id, ally_tag, ally_name, ally_members FROM " . ALLIANCE . " WHERE ally_name LIKE '%" . $db->sql_escape($searchtext, true) . "%' OR ally_tag LIKE '%" . $db->sql_escape($searchtext, true) . "%' LIMIT 30;");
$SeachResult = array();
while ($CurrRow = $db->fetch_array($Search)) {
$SeachResult[] = array('id' => $CurrRow['id'], 'tag' => $CurrRow['ally_tag'], 'name' => $CurrRow['ally_name'], 'members' => $CurrRow['ally_members']);
}
}
$template->assign_vars(array('searchtext' => $searchtext, 'SeachResult' => $SeachResult, 'al_find_submit' => $LNG['al_find_submit'], 'al_find_text' => $LNG['al_find_text'], 'al_find_alliances' => $LNG['al_find_alliances'], 'al_make_submit' => $LNG['al_make_submit'], 'al_find_no_alliances' => $LNG['al_find_no_alliances'], 'al_ally_info_members' => $LNG['al_ally_info_members'], 'al_ally_info_name' => $LNG['al_ally_info_name'], 'al_ally_info_tag' => $LNG['al_ally_info_tag']));
$template->show("alliance_searchform.tpl");
} else {
redirectTo("game.php" . "?page=alliance");
}
break;
case 'apply':
if ($USER['ally_request'] == 0) {
$text = request_var('text', '', true);
$allyrow = $db->uniquequery("SELECT `ally_tag`, `ally_request`, `ally_request_notallow` FROM " . ALLIANCE . " WHERE id='" . $db->sql_escape($allyid) . "';");
if (!$allyrow) {
redirectTo("game.php?page=alliance");
}
if ($allyrow['ally_request_notallow'] == 1) {
$template->message($LNG['al_alliance_closed']);
exit;
} else {
if ($action == "send") {
$db->query("UPDATE " . USERS . " SET `ally_request`='" . $db->sql_escape($allyid) . "', ally_request_text='" . $db->sql_escape($text) . "', ally_register_time='" . TIMESTAMP . "' WHERE `id`='" . $USER['id'] . "';");
$template->message($LNG['al_request_confirmation_message'], "?page=alliance");
} else {
$template->assign_vars(array('allyid' => $allyid, 'al_your_request_title' => $LNG['al_your_request_title'], 'applytext' => !empty($allyrow['ally_request']) ? $allyrow['ally_request'] : $LNG['al_default_request_text'], 'al_write_request' => sprintf($LNG['al_write_request'], $allyrow['ally_tag']), 'al_applyform_reload' => $LNG['al_applyform_reload'], 'al_applyform_send' => $LNG['al_applyform_send'], 'al_message' => $LNG['al_message']));
$template->show("alliance_applyform.tpl");
}
}
} else {
redirectTo("game.php?page=alliance");
}
break;
//.........这里部分代码省略.........