<?php
define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './forum/';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup();
$place = $_GET['place'];
?>
<?php include('head.html');
if ($place == "center"){
echo 'Altara - Adoption Center';
}
else if ($place == "shop"){
echo 'Altara - Shopping District';
}
else {
echo 'Altara - Adopt';
}
include('head2.html');
if ($place == "center"){
echo 'Adoption Center';
}
else if ($place == "shop"){
echo 'Shopping District';
}
else {
echo 'Adopt';
}
?>
</h2>
<div class="story">
<p>
<?php
$result = mysql_query("SELECT * FROM forum_banlist WHERE ban_userid = ".$user->data['user_id']) or die(mysql_error());
if ($user->data['user_id'] == ANONYMOUS)
{
echo 'Please <a href="http://www.altara.99webs.info/forum/ucp.php?mode=login">login</a> or <a href="http://www.altara.99webs.info/forum/ucp.php?mode=register">register</a> to access more of the site.';
}
else if ($result == "TRUE"){
echo 'You have been banned from access to this site.';
}
else
{
$sql_result = mysql_query("SELECT * FROM adopt_user WHERE uid = '".$user->data['user_id']."'") or die(mysql_error());
if($sql_result=TRUE){
$adoptid = $_POST['adoptid'];
$arraynum = $_POST['arraynum'] - 1;
$price1 = $_POST['price1'];
$price2 = $_POST['price2'];
$sql_result = mysql_query("SELECT * FROM adopt_user WHERE uid = '".$user->data['user_id']."'") or die(mysql_error());
while($row = mysql_fetch_array($sql_result))
{
$usercash1 = $row['cash'];
$usercash2 = $row['cash2'];
}
//ID ARRAY
$input = explode(",", $adoptid);
$rand_keys = array_rand($input, 2);
$species = $input[$rand_keys[0]];
$result = mysql_query("SELECT * FROM adopt_species WHERE id = '".$adoptid."'") or die(mysql_error());
while($row = mysql_fetch_array($result))
{
$genratio = $row['genratio'];
$eggimg = $row['eggimg'];
$hp = $row['defhp'];
$att = $row['defatt'];
$def = $row['defdef'];
$spd = $row['defspd'];
$trade = $row['trade'];
$breed = $row['breed'];
$limit = $row['ownlimit'];
$itemup = $row['itemup'];
$tradeup = $row['tradeup'];
$friendup = $row['friendup'];
$growthrate = $row['growthrate'];
$specname = $row['name'];
}
$newcash1 = $usercash1 - $price1;
$newcash2 = $usercash2 - $price2;
if ($newcash1 > 0 || $newcash2 > 0){
//GENDERS
if ($genratio == "male"){
$gender = "Male";
}
else if ($genratio == "female"){
$gender = "Female";
}
else if ($genratio == "moremale"){
$rand = rand(1,4);
if ($rand == 1){
$gender = "Female";
}
else {
$gender = "Male";
}
}
else if ($genratio == "morefemale"){
$rand = rand(1,4);
if ($rand == 1){
$gender = "Male";
}
else {
$gender = "Female";
}
}
else if ($genratio == "50"){
$rand = rand(0,1);
if ($rand == 1){
$gender = "Female";
}
else {
$gender = "Male";
}
}
else {
$gender = "Ungendered";
}
//NATURES
$input = array("Bossy", "Brave", "Calm", "Cautious", "Curious", "Deceitful", "Docile", "Excitable", "Loyal", "Funny", "Hardy", "Hasty", "Kind", "Lonely", "Modest", "Moody", "Naive", "Nervous", "Quiet", "Quirky", "Rash", "Reserved", "Serious", "Shy", "Sincere");
$rand_keys = array_rand($input, 2);
$nature = $input[$rand_keys[0]];
mysql_query("INSERT INTO adopt_adopts VALUES ('0','".$user->data['user_id']."', 'Unnamed', '".$gender."', '".$nature."', '".$hp."', '".$hp."', '".$att."', '".$def."', '".$spd."', '0', '0', '".$eggimg."', '".$species."', '".$trade."', '".$breed."', '0', '0', '".$user->data['user_id']."', '0', '0', '0', '".$itemup."', '".$tradeup."', '".$friendup."', '".$growthrate."', '".$specname."')") or die(mysql_error());
//id,owner,name,gender,nature,currenthp,maxhp,att,def,spd,stage,exp,image,species,trade,breed,traded,friendship,ot,mother,father,group,itemup,tradeup,friendup,growthrate, speciesname
$newid = mysql_insert_id();
echo'<p><strong>Congrats!</strong> You\'ve just recieved a new egg! </p>
<img src="'.$eggimg.'">
<p>You can click <a href="/feed.php?id='.$newid.'">here</a> to warm the egg and help it grow, or you can click <a href="/creature.php?id='.$newid.'">here</a> to view the newly recieved egg.</p>';
}
else {
echo 'Sorry there was an issue! Please try again. If the problem persists, contact the Admin or ask for help on the forums';
}
}
else {
echo $user->data['username'] . ' you have NOT completed registration! Please go <a href="/complete.php">here</a> to complete your registration to fully access the adoptable portion of this site.';
}
}
?>
<?php include('foot.html'); ?>