• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

[GESIOR ACC] - Create Character

Gabriel Tibiano

New Member
Joined
Nov 21, 2009
Messages
420
Reaction score
4
Hello guys, i'm searching for help me with this code.
The problem is that the function is accepting names with ' "


accountmanagement.php
PHP:
//## CREATE CHARACTER on account ###
        if($action == "createcharacter")
        {
                if(count($config['site']['worlds']) > 1)
                {
                        if(isset($_REQUEST['world']))
                                $world_id = (int) $_REQUEST['world'];
                }
                else
                        $world_id = 0;
                if(!isset($world_id))
                {
                        $main_content .= 'Before you can create character you must select world: ';
                        foreach($config['site']['worlds'] as $id => $world_n)
                                $main_content .= '<br /><a href="?subtopic=accountmanagement&action=createcharacter&world='.$id.'">- '.$world_n.'</a>';
                        $main_content .= '<br /><h3><a href="?subtopic=accountmanagement">BACK</a></h3>';
                }
                else
                {
                        $main_content .= '<script type="text/javascript">
                        var nameHttp;

function checkName()
{
                if(document.getElementById("newcharname").value=="")
                {
                        document.getElementById("name_check").innerHTML = \'<b><font color="red">Please enter new character name.</font></b>\';
                        return;
                }
                nameHttp=GetXmlHttpObject();
                if (nameHttp==null)
                {
                        return;
                }
                var newcharname = document.getElementById("newcharname").value;
                var url="ajax/check_name.php?name=" + newcharname + "&uid="+Math.random();
                nameHttp.onreadystatechange=NameStateChanged;
                nameHttp.open("GET",url,true);
                nameHttp.send(null);
}

function NameStateChanged()
{
                if (nameHttp.readyState==4)
                {
                        document.getElementById("name_check").innerHTML=nameHttp.responseText;
                }
}
</script>';
                        $newchar_name = stripslashes(ucwords(strtolower(trim($_POST['newcharname']))));
                        $newchar_sex = $_POST['newcharsex'];
                        $newchar_vocation = $_POST['newcharvocation'];
                        $newchar_town = $_POST['newchartown'];
                        if($_POST['savecharacter'] != 1)
                        {
                                $main_content .= 'Please choose a name';
                                if(count($config['site']['newchar_vocations'][$world_id]) > 1)
                                        $main_content .= ', vocation';
                                $main_content .= ' and sex for your character. <br/>In any case the name must not violate the naming conventions stated in the <a href="?subtopic=tibiarules" target="_blank" >'.$config['server']['serverName'].' Rules</a>, or your character might get deleted or name locked.';
                                if($account_logged->getPlayersList()->count() >= $config['site']['max_players_per_account'])
                                        $main_content .= '<b><font color="red"> You have maximum number of characters per account on your account. Delete one before you make new.</font></b>';
                                $main_content .= '<br/><br/><form action="?subtopic=accountmanagement&action=createcharacter" method="post" ><input type="hidden" name="world" value="'.$world_id.'" ><input type="hidden" name=savecharacter value="1" ><div class="TableContainer" >  <table class="Table3" cellpadding="0" cellspacing="0" >    <div class="CaptionContainer" >      <div class="CaptionInnerContainer" ><span class="CaptionEdgeLeftTop" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif);" /></span><span class="CaptionEdgeRightTop" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif);" /></span><span class="CaptionBorderTop" style="background-image:url('.$layout_name.'/images/content/table-headline-border.gif);" ></span><span class="CaptionVerticalLeft" style="background-image:url('.$layout_name.'/images/content/box-frame-vertical.gif);" /></span><div class="Text" >Create Character</div>        <span class="CaptionVerticalRight" style="background-image:url('.$layout_name.'/images/content/box-frame-vertical.gif);" /></span><span class="CaptionBorderBottom" style="background-image:url('.$layout_name.'/images/content/table-headline-border.gif);" ></span><span class="CaptionEdgeLeftBottom" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif);" /></span><span class="CaptionEdgeRightBottom" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif);" /></span></div>    </div><tr>      <td>        <div class="InnerTableContainer" >          <table style="width:100%;" ><tr><td><div class="TableShadowContainerRightTop" >  <div class="TableShadowRightTop" style="background-image:url('.$layout_name.'/images/content/table-shadow-rt.gif);" ></div></div><div class="TableContentAndRightShadow" style="background-image:url('.$layout_name.'/images/content/table-shadow-rm.gif);" >  <div class="TableContentContainer" ><table class="TableContent" width="100%" ><tr class="LabelH" ><td style="width:50%;" ><span >Name</td><td><span >Sex</td></tr><tr class="Odd" ><td><input id="newcharname" name="newcharname" onkeyup="checkName();" value="'.$newchar_name.'" size="30" maxlength="29" ><BR><font size="1" face="verdana,arial,helvetica"><div id="name_check">Please enter your character name.</div></font></td><td>';
                                $main_content .= '<input type="radio" name="newcharsex" value="1" ';
                                if($newchar_sex == 1)
                                        $main_content .= 'checked="checked" ';
                                $main_content .= '>male<br/>';
                                $main_content .= '<input type="radio" name="newcharsex" value="0" ';
                                if($newchar_sex == "0")
                                        $main_content .= 'checked="checked" ';
                                $main_content .= '>female<br/></td></tr></table></div></div></table></div>';
                                if(count($config['site']['newchar_towns'][$world_id]) > 1 || count($config['site']['newchar_vocations'][$world_id]) > 1)
                                        $main_content .= '<div class="InnerTableContainer" >          <table style="width:100%;" ><tr>';
                                if(count($config['site']['newchar_vocations'][$world_id]) > 1)
                                {
                                        $main_content .= '<td><table class="TableContent" width="100%" ><tr class="Odd" valign="top"><td width="160"><br /><b>Select your vocation:</b></td><td><table class="TableContent" width="100%" >';
                                        foreach($config['site']['newchar_vocations'][$world_id] as $char_vocation_key => $sample_char)
                                        {
                                                $main_content .= '<tr><td><input type="radio" name="newcharvocation" value="'.$char_vocation_key.'" ';
                                                if($newchar_vocation == $char_vocation_key)
                                                        $main_content .= 'checked="checked" ';
                                                $main_content .= '>'.$vocation_name[$world_id][0][$char_vocation_key].'</td></tr>';
                                        }
                                        $main_content .= '</table></table></td>';
                                }
                                if(count($config['site']['newchar_towns'][$world_id]) > 1)
                                {
                                        $main_content .= '<td><table class="TableContent" width="100%" ><tr class="Odd" valign="top"><td width="160"><br /><b>Select your city:</b></td><td><table class="TableContent" width="100%" >';
                                        foreach($config['site']['newchar_towns'][$world_id] as $town_id)
                                        {
                                                $main_content .= '<tr><td><input type="radio" name="newchartown" value="'.$town_id.'" ';
                                                if($newchar_town == $town_id)
                                                        $main_content .= 'checked="checked" ';
                                                $main_content .= '>'.$towns_list[$world_id][$town_id].'</td></tr>';
                                        }
                                        $main_content .= '</table></table></td>';
                                }
                                if(count($config['site']['newchar_towns'][$world_id]) > 1 || count($config['site']['newchar_vocations'][$world_id]) > 1)
                                        $main_content .= '</tr></table></div>';
                                $main_content .= '</table></div></td></tr><br/><table style="width:100%;" ><tr align="center" ><td><table border="0" cellspacing="0" cellpadding="0" ><tr><td style="border:0px;" ><div class="BigButton" style="background-image:url('.$layout_name.'/images/buttons/sbutton.gif)" ><div onMouseOver="MouseOverBigButton(this);" onMouseOut="MouseOutBigButton(this);" ><div class="BigButtonOver" style="background-image:url('.$layout_name.'/images/buttons/sbutton_over.gif);" ></div><input class="ButtonText" type="image" name="Submit" alt="Submit" src="'.$layout_name.'/images/buttons/_sbutton_submit.gif" ></div></div></td><tr></form></table></td><td><table border="0" cellspacing="0" cellpadding="0" ><form action="?subtopic=accountmanagement" method="post" ><tr><td style="border:0px;" ><div class="BigButton" style="background-image:url('.$layout_name.'/images/buttons/sbutton.gif)" ><div onMouseOver="MouseOverBigButton(this);" onMouseOut="MouseOutBigButton(this);" ><div class="BigButtonOver" style="background-image:url('.$layout_name.'/images/buttons/sbutton_over.gif);" ></div><input class="ButtonText" type="image" name="Back" alt="Back" src="'.$layout_name.'/images/buttons/_sbutton_back.gif" ></div></div></td></tr></form></table></td></tr></table>';
                        }
                        else
                        {      
                                if(empty($newchar_name))
                                        $newchar_errors[] = 'Please enter a name for your character!';
                                if(empty($newchar_sex) && $newchar_sex != "0")
                                        $newchar_errors[] = 'Please select the sex for your character!';
                                if(count($config['site']['newchar_vocations'][$world_id]) > 1)
                                {
                                        if(empty($newchar_vocation))
                                                $newchar_errors[] = 'Please select a vocation for your character.';
                                }
                                else
                                        $newchar_vocation = $config['site']['newchar_vocations'][$world_id][0];
                                if(count($config['site']['newchar_towns'][$world_id]) > 1)
                                {
                                        if(empty($newchar_town))
                                                $newchar_errors[] = 'Please select a town for your character.';
                                }
                                else
                                        $newchar_town = $config['site']['newchar_towns'][$world_id][0];
                                if(empty($newchar_errors))
                                {
                                        if(!check_name_new_char($newchar_name))
                                                $newchar_errors[] = 'This name contains invalid letters, words or format. Please use only a-Z, - , \' and space.';
                                        if($newchar_sex != 1 && $newchar_sex != "0")
                                                $newchar_errors[] = 'Sex must be equal <b>0 (female)</b> or <b>1 (male)</b>.';
                                        if(!in_array($newchar_town, $config['site']['newchar_towns'][$world_id]))
                                                $newchar_errors[] = 'Please select valid town.';
                                        if(count($config['site']['newchar_vocations'][$world_id]) > 1)
                                        {
                                                $newchar_vocation_check = FALSE;
                                                foreach($config['site']['newchar_vocations'][$world_id] as $char_vocation_key => $sample_char)
                                                        if($newchar_vocation == $char_vocation_key)
                                                                $newchar_vocation_check = TRUE;
                                                if(!$newchar_vocation_check)
                                                        $newchar_errors[] = 'Unknown vocation. Please fill in form again.';
                                        }
                                        else
                                                $newchar_vocation = 0;
                                }
                                if(empty($newchar_errors))
                                {
                                        $check_name_in_database = $ots->createObject('Player');
                                        $check_name_in_database->find($newchar_name);
                                        if($check_name_in_database->isLoaded())
                                                $newchar_errors[] .= 'This name is already used. Please choose another name!';
                                        $number_of_players_on_account = $account_logged->getPlayersList()->count();
                                        if($number_of_players_on_account >= $config['site']['max_players_per_account'])
                                                $newchar_errors[] .= 'You have too many characters on your account <b>('.$number_of_players_on_account.'/'.$config['site']['max_players_per_account'].')</b>!';
                                }
                                if(empty($newchar_errors))
                                {
                                        $char_to_copy_name = $config['site']['newchar_vocations'][$world_id][$newchar_vocation];
                                        $char_to_copy = new OTS_Player();
                                        $char_to_copy->find($char_to_copy_name);
                                        if(!$char_to_copy->isLoaded())
                                                $newchar_errors[] .= 'Wrong characters configuration. Try again or contact with admin. ADMIN: Edit file config/config.php and set valid characters to copy names. Character to copy'.$char_to_copy_name.'</b> doesn\'t exist.';
                                }
                                if(empty($newchar_errors))
                                {
                                        if($newchar_sex == "0")
                                                $char_to_copy->setLookType(136);
                                        $player = $ots->createObject('Player');
                                    $player->setName($newchar_name);
                                    $player->setAccount($account_logged);
                                    $player->setGroup($char_to_copy->getGroup());
                                    $player->setSex($newchar_sex);
                                    $player->setVocation($char_to_copy->getVocation());
                                    $player->setConditions($char_to_copy->getConditions());
                                    $player->setRank($char_to_copy->getRank());
                                    $player->setLookAddons($char_to_copy->getLookAddons());
                                    $player->setTownId($newchar_town);
                                    $player->setExperience($char_to_copy->getExperience());
                                    $player->setLevel($char_to_copy->getLevel());
                                    $player->setMagLevel($char_to_copy->getMagLevel());
                                    $player->setHealth($char_to_copy->getHealth());
                                    $player->setHealthMax($char_to_copy->getHealthMax());
                                    $player->setMana($char_to_copy->getMana());
                                    $player->setManaMax($char_to_copy->getManaMax());
                                    $player->setManaSpent($char_to_copy->getManaSpent());
                                    $player->setSoul($char_to_copy->getSoul());
                                    $player->setDirection($char_to_copy->getDirection());
                                    $player->setLookBody($char_to_copy->getLookBody());
                                    $player->setLookFeet($char_to_copy->getLookFeet());
                                    $player->setLookHead($char_to_copy->getLookHead());
                                    $player->setLookLegs($char_to_copy->getLookLegs());
                                    $player->setLookType($char_to_copy->getLookType());
                                    $player->setCap($char_to_copy->getCap());
                                        $player->setPosX(0);
                                        $player->setPosY(0);
                                        $player->setPosZ(0);
                                    $player->setLossExperience($char_to_copy->getLossExperience());
                                    $player->setLossMana($char_to_copy->getLossMana());
                                    $player->setLossSkills($char_to_copy->getLossSkills());
                                        $player->setLossItems($char_to_copy->getLossItems());
                                        $player->save();
                                        unset($player);
                                        $player = $ots->createObject('Player');
                                        $player->find($newchar_name);
                                        if($player->isLoaded())
                                        {
						$player->setCustomField('world_id', (int) $world_id);
                                                $player->setSkill(0,$char_to_copy->getSkill(0));
                                                $player->setSkill(1,$char_to_copy->getSkill(1));
                                                $player->setSkill(2,$char_to_copy->getSkill(2));
                                                $player->setSkill(3,$char_to_copy->getSkill(3));
                                                $player->setSkill(4,$char_to_copy->getSkill(4));
                                                $player->setSkill(5,$char_to_copy->getSkill(5));
                                                $player->setSkill(6,$char_to_copy->getSkill(6));
                                                $player->save();
                                                $loaded_items_to_copy = $SQL->query("SELECT * FROM player_items WHERE player_id = ".$char_to_copy->getId()."");
                                                foreach($loaded_items_to_copy as $save_item)
                                                        $SQL->query("INSERT INTO `player_items` (`player_id` ,`pid` ,`sid` ,`itemtype`, `count`, `attributes`) VALUES ('".$player->getId()."', '".$save_item['pid']."', '".$save_item['sid']."', '".$save_item['itemtype']."', '".$save_item['count']."', '".$save_item['attributes']."');");
                                                $main_content .= '<div class="TableContainer" >  <table class="Table1" cellpadding="0" cellspacing="0" >    <div class="CaptionContainer" >      <div class="CaptionInnerContainer" >        <span class="CaptionEdgeLeftTop" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif);" /></span>        <span class="CaptionEdgeRightTop" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif);" /></span>        <span class="CaptionBorderTop" style="background-image:url('.$layout_name.'/images/content/table-headline-border.gif);" ></span>        <span class="CaptionVerticalLeft" style="background-image:url('.$layout_name.'/images/content/box-frame-vertical.gif);" /></span>        <div class="Text" >Character Created</div>        <span class="CaptionVerticalRight" style="background-image:url('.$layout_name.'/images/content/box-frame-vertical.gif);" /></span>        <span class="CaptionBorderBottom" style="background-image:url('.$layout_name.'/images/content/table-headline-border.gif);" ></span>        <span class="CaptionEdgeLeftBottom" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif);" /></span>        <span class="CaptionEdgeRightBottom" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif);" /></span>      </div>    </div>    <tr>      <td>        <div class="InnerTableContainer" >          <table style="width:100%;" ><tr><td>The character <b>'.$newchar_name.'</b> has been created.<br/>Please select the outfit when you log in for the first time.<br/><br/><b>See you on '.$config['server']['serverName'].'!</b></td></tr>          </table>        </div>  </table></div></td></tr><br/><center><table border="0" cellspacing="0" cellpadding="0" ><form action="?subtopic=accountmanagement" method="post" ><tr><td style="border:0px;" ><div class="BigButton" style="background-image:url('.$layout_name.'/images/buttons/sbutton.gif)" ><div onMouseOver="MouseOverBigButton(this);" onMouseOut="MouseOutBigButton(this);" ><div class="BigButtonOver" style="background-image:url('.$layout_name.'/images/buttons/sbutton_over.gif);" ></div><input class="ButtonText" type="image" name="Back" alt="Back" src="'.$layout_name.'/images/buttons/_sbutton_back.gif" ></div></div></td></tr></form></table></center>';
                                        }
                                        else
                                        {
                                                echo "Error. Can\'t create character. Probably problem with database. Try again or contact with admin.";
                                                exit;
                                        }
                                }
                                else
                                {
                                        $main_content .= '<div class="SmallBox" >  <div class="MessageContainer" >    <div class="BoxFrameHorizontal" style="background-image:url('.$layout_name.'/images/content/box-frame-horizontal.gif);" /></div>    <div class="BoxFrameEdgeLeftTop" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif);" /></div>    <div class="BoxFrameEdgeRightTop" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif);" /></div>    <div class="ErrorMessage" >      <div class="BoxFrameVerticalLeft" style="background-image:url('.$layout_name.'/images/content/box-frame-vertical.gif);" /></div>      <div class="BoxFrameVerticalRight" style="background-image:url('.$layout_name.'/images/content/box-frame-vertical.gif);" /></div>      <div class="AttentionSign" style="background-image:url('.$layout_name.'/images/content/attentionsign.gif);" /></div><b>The Following Errors Have Occurred:</b><br/>';
                                        foreach($newchar_errors as $newchar_error)
                                                $main_content .= '<li>'.$newchar_error;
                                        $main_content .= '</div>    <div class="BoxFrameHorizontal" style="background-image:url('.$layout_name.'/images/content/box-frame-horizontal.gif);" /></div>    <div class="BoxFrameEdgeRightBottom" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif);" /></div>    <div class="BoxFrameEdgeLeftBottom" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif);" /></div>  </div></div><br/>';
                                        $main_content .= 'Please choose a name';
                                        if(count($config['site']['newchar_vocations'][$world_id]) > 1)
                                                $main_content .= ', vocation';
                                        $main_content .= ' and sex for your character. <br/>In any case the name must not violate the naming conventions stated in the <a href="?subtopic=tibiarules" target="_blank" >'.$config['server']['serverName'].' Rules</a>, or your character might get deleted or name locked.<br/><br/><form action="?subtopic=accountmanagement&action=createcharacter" method="post" ><input type="hidden" name="world" value="'.$world_id.'" ><input type="hidden" name=savecharacter value="1" ><div class="TableContainer" >  <table class="Table3" cellpadding="0" cellspacing="0" >    <div class="CaptionContainer" >      <div class="CaptionInnerContainer" ><span class="CaptionEdgeLeftTop" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif);" /></span><span class="CaptionEdgeRightTop" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif);" /></span><span class="CaptionBorderTop" style="background-image:url('.$layout_name.'/images/content/table-headline-border.gif);" ></span><span class="CaptionVerticalLeft" style="background-image:url('.$layout_name.'/images/content/box-frame-vertical.gif);" /></span><div class="Text" >Create Character</div>        <span class="CaptionVerticalRight" style="background-image:url('.$layout_name.'/images/content/box-frame-vertical.gif);" /></span><span class="CaptionBorderBottom" style="background-image:url('.$layout_name.'/images/content/table-headline-border.gif);" ></span><span class="CaptionEdgeLeftBottom" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif);" /></span><span class="CaptionEdgeRightBottom" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif);" /></span></div>    </div><tr>      <td>        <div class="InnerTableContainer" >          <table style="width:100%;" ><tr><td><div class="TableShadowContainerRightTop" >  <div class="TableShadowRightTop" style="background-image:url('.$layout_name.'/images/content/table-shadow-rt.gif);" ></div></div><div class="TableContentAndRightShadow" style="background-image:url('.$layout_name.'/images/content/table-shadow-rm.gif);" >  <div class="TableContentContainer" ><table class="TableContent" width="100%" ><tr class="LabelH" ><td style="width:50%;" ><span >Name</td><td><span >Sex</td></tr><tr class="Odd" ><td><input id="newcharname" name="newcharname" onkeyup="checkName();" value="'.$newchar_name.'" size="30" maxlength="29" ><BR><font size="1" face="verdana,arial,helvetica"><div id="name_check">Please enter your character name.</div></font></td><td>';
                                        $main_content .= '<input type="radio" name="newcharsex" value="1" ';
                                        if($newchar_sex == 1)
                                                $main_content .= 'checked="checked" ';
                                        $main_content .= '>male<br/>';
                                        $main_content .= '<input type="radio" name="newcharsex" value="0" ';
                                        if($newchar_sex == "0")
                                                $main_content .= 'checked="checked" ';
                                        $main_content .= '>female<br/></td></tr></table></div></div></table></div>';
                                        if(count($config['site']['newchar_towns'][$world_id]) > 1 || count($config['site']['newchar_vocations'][$world_id]) > 1)
                                                $main_content .= '<div class="InnerTableContainer" >          <table style="width:100%;" ><tr>';
                                        if(count($config['site']['newchar_vocations'][$world_id]) > 1)
                                        {
                                                $main_content .= '<td><table class="TableContent" width="100%" ><tr class="Odd" valign="top"><td width="160"><br /><b>Select your vocation:</b></td><td><table class="TableContent" width="100%" >';
                                                foreach($config['site']['newchar_vocations'][$world_id] as $char_vocation_key => $sample_char)
                                                {
                                                        $main_content .= '<tr><td><input type="radio" name="newcharvocation" value="'.$char_vocation_key.'" ';
                                                        if($newchar_vocation == $char_vocation_key)
                                                                $main_content .= 'checked="checked" ';
                                                        $main_content .= '>'.$vocation_name[$world_id][0][$char_vocation_key].'</td></tr>';
                                                }
                                                $main_content .= '</table></table></td>';
                                        }
                                        if(count($config['site']['newchar_towns'][$world_id]) > 1)
                                        {
                                                $main_content .= '<td><table class="TableContent" width="100%" ><tr class="Odd" valign="top"><td width="160"><br /><b>Select your city:</b></td><td><table class="TableContent" width="100%" >';
                                                foreach($config['site']['newchar_towns'][$world_id] as $town_id)
                                                {
                                                        $main_content .= '<tr><td><input type="radio" name="newchartown" value="'.$town_id.'" ';
                                                        if($newchar_town == $town_id)
                                                                $main_content .= 'checked="checked" ';
                                                        $main_content .= '>'.$towns_list[$world_id][$town_id].'</td></tr>';
                                                }
                                                $main_content .= '</table></table></td>';
                                        }
                                        if(count($config['site']['newchar_towns'][$world_id]) > 1 || count($config['site']['newchar_vocations'][$world_id]) > 1)
                                                $main_content .= '</tr></table></div>';
                                        $main_content .= '</table></div></td></tr><br/><table style="width:100%;" ><tr align="center" ><td><table border="0" cellspacing="0" cellpadding="0" ><tr><td style="border:0px;" ><div class="BigButton" style="background-image:url('.$layout_name.'/images/buttons/sbutton.gif)" ><div onMouseOver="MouseOverBigButton(this);" onMouseOut="MouseOutBigButton(this);" ><div class="BigButtonOver" style="background-image:url('.$layout_name.'/images/buttons/sbutton_over.gif);" ></div><input class="ButtonText" type="image" name="Submit" alt="Submit" src="'.$layout_name.'/images/buttons/_sbutton_submit.gif" ></div></div></td><tr></form></table></td><td><table border="0" cellspacing="0" cellpadding="0" ><form action="?subtopic=accountmanagement" method="post" ><tr><td style="border:0px;" ><div class="BigButton" style="background-image:url('.$layout_name.'/images/buttons/sbutton.gif)" ><div onMouseOver="MouseOverBigButton(this);" onMouseOut="MouseOutBigButton(this);" ><div class="BigButtonOver" style="background-image:url('.$layout_name.'/images/buttons/sbutton_over.gif);" ></div><input class="ButtonText" type="image" name="Back" alt="Back" src="'.$layout_name.'/images/buttons/_sbutton_back.gif" ></div></div></td></tr></form></table></td></tr></table>';
                                }
                        }
                }
        }




ajax \/ dont have lines
 
checkname.php (ajax)
PHP:
<?PHP
echo '<?xml version="1.0" encoding="utf-8" standalone="yes"?>';
$config_ini = parse_ini_file('../config/config.ini');
include('../config/config.php');
$name = strtolower(stripslashes(trim($_REQUEST['name'])));
if(empty($name))
{
	echo '<font color="red">Please enter new character name.</font>';
	exit;
}

//first word can't be:
$first_words_blocked = array('gm ','cm ', 'god ','tutor ', "'", '-');
//names blocked:
$names_blocked = array('gm','cm', 'god', 'tutor');
//name can't contain:
$words_blocked = array('gamemaster', 'game master', 'game-master', "game'master", '  ', '--', "''","' ", " '", '- ', ' -', "-'", "'-", 'fuck', 'sux', 'suck', 'noob', 'tutor');
$temp = strspn("$name", "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM");
if($temp != strlen($name))
{
	echo '<font color="red">Name contains illegal letters. Use only: <b>qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM</b></font>';
	exit;
}
if(strlen($name) > 25)
{
	echo '<font color="red">Too long name. Max. lenght <b>25</b> letters.</font>';
	exit;
}
foreach($names_blocked as $word)
	if($word == $name)
	{
		echo '<font color="red">Blocked names:<b> '.$names_blocked[0];
		if(count($names_blocked) > 1)
			foreach($names_blocked as $word)
				if($word != $names_blocked[0])
					echo ','.$word;
		echo '</b></font>';
		exit;
	}
foreach($config['site']['monsters'] as $word)
	if($word == $name)
	{
		echo '<font color="red"><b>You can not use monster name.</b></font>';
		exit;
	}
foreach($config['site']['npc'] as $word)
	if($word == $name)
	{
		echo '<font color="red"><b>You can not use NPC name.</b></font>';
		exit;
	}	
foreach($first_words_blocked as $word)
	if($word == substr($name, 0, strlen($word)))
	{
		echo '<font color="red">First letters in name can\'t be:<b> '.$first_words_blocked[0];
		if(count($first_words_blocked) > 1)
			foreach($first_words_blocked as $word)
				if($word != $first_words_blocked[0])
					echo ','.$word;
		echo '</b></font>';
		exit;
	}
if(substr($name, -1) == "'" || substr($name, -1) == "-")
{
	echo '<font color="red">Last letter can\'t be <b>\'</b> and <b>-</b></font>';
	exit;
}
foreach($words_blocked as $word)
	if (!(strpos($name, $word) === false))
	{
		echo '<font color="red">Name can\'t cointain words:<b> '.$words_blocked[0];
		if(count($words_blocked) > 1)
			foreach($words_blocked as $word)
				if($word != $words_blocked[0])
					echo ','.$word;
		echo '</b></font>';
		exit;
	}
for($i = 0; $i < strlen($name); $i++)
	if($name[$i] == $name[($i+1)] && $name[$i] == $name[($i+2)])
	{
		echo '<font color="red">Name can\'t contain 3 same letters one by one.</font><br /><font color="green"><u>Good:</u> M<b>oo</b>nster</font><font color="red"><br />Wrong: M<b>ooo</b>nster</font>';
		exit;
	}
for($i = 0; $i < strlen($name); $i++)
	if($name[$i-1] == ' ' && $name[$i+1] == ' ')
	{
		echo '<font color="red">Use normal name format.</font><br /><font color="green"><u>Good:</u> <b>Gesior</b></font><font color="red"><br />Wrong: <b>G e s ior</b></font>';
		exit;
	}
if(substr($name, 1, 1) == ' ')
{
	echo '<font color="red">Use normal name format.</font><br /><font color="green"><u>Good:</u> <b>Gesior</b></font><font color="red"><br />Wrong: <b>G esior</b></font>';
	exit;
}
if(substr($name, -2, 1) == " ")
{
	echo '<font color="red">Use normal name format.</font><br /><font color="green"><u>Good:</u> <b>Gesior</b></font><font color="red"><br />Wrong: <b>Gesio r</b></font>';
	exit;
}
else
		//connect to DB
		$server_config = parse_ini_file($config_ini['server_path'].'config.lua');
		if(isset($server_config['mysqlHost']))
		{
			//new (0.2.6+) ots config.lua file
			$mysqlhost = $server_config['mysqlHost'];
			$mysqluser = $server_config['mysqlUser'];
			$mysqlpass = $server_config['mysqlPass'];
			$mysqldatabase = $server_config['mysqlDatabase'];
			$sqlitefile = $server_config['sqliteDatabase'];
		}
		elseif(isset($server_config['sqlHost']))
		{
			//old (0.2.4) ots config.lua file
			$mysqlhost = $server_config['sqlHost'];
			$mysqluser = $server_config['sqlUser'];
			$mysqlpass = $server_config['sqlPass'];
			$mysqldatabase = $server_config['sqlDatabase'];
			$sqlitefile = $server_config['sqliteDatabase'];
		}
		// loads #####POT mainfile#####
		include('../pot/OTS.php');
		// PDO and POT connects to database
		$ots = POT::getInstance();
		if($server_config['sqlType'] == "mysql")
			$ots->connect(POT::DB_MYSQL, array('host' => $mysqlhost, 'user' => $mysqluser, 'password' => $mysqlpass, 'database' => $mysqldatabase) );
		elseif($server_config['sqlType'] == "sqlite")
			$ots->connect(POT::DB_SQLITE, array('database' => $config_ini['server_path'].$sqlitefile));
		$name_db = new OTS_Player();
		$name_db->find($name);
		if($name_db->isLoaded())
			echo '<font color="red"><b>Player with this name already exist.</b></font>';
		else
			echo '<font color="green">Good. Your name will be:<br />"<b>'.ucwords($name).'</b>"</font>';

?>
 
Back
Top